зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1434965 - Create an implementation of JS::ForEachTrackedOptimizationAttemptOp which takes a lambda. r=njn
This moves the meat of the processing from operator() into the lambda, so that it can be read in the function that calls forEachOptimizationAttempt. Now the person who wants to understand this code hopefully won't need to scroll up and down as much. MozReview-Commit-ID: H9zRf1Vbswg --HG-- extra : rebase_source : a742fa4c076437c7af6837280f725ee4532cbf2c
This commit is contained in:
Родитель
14feaf3477
Коммит
77e86db941
|
@ -232,29 +232,27 @@ private:
|
|||
uint32_t mNextFreeIndex;
|
||||
};
|
||||
|
||||
class StreamOptimizationAttemptsOp : public JS::ForEachTrackedOptimizationAttemptOp
|
||||
template<typename LambdaT>
|
||||
class ForEachTrackedOptimizationAttemptsLambdaOp
|
||||
: public JS::ForEachTrackedOptimizationAttemptOp
|
||||
{
|
||||
SpliceableJSONWriter& mWriter;
|
||||
UniqueJSONStrings& mUniqueStrings;
|
||||
|
||||
public:
|
||||
StreamOptimizationAttemptsOp(SpliceableJSONWriter& aWriter, UniqueJSONStrings& aUniqueStrings)
|
||||
: mWriter(aWriter),
|
||||
mUniqueStrings(aUniqueStrings)
|
||||
{ }
|
||||
|
||||
void operator()(JS::TrackedStrategy strategy, JS::TrackedOutcome outcome) override {
|
||||
enum Schema : uint32_t {
|
||||
STRATEGY = 0,
|
||||
OUTCOME = 1
|
||||
};
|
||||
|
||||
AutoArraySchemaWriter writer(mWriter, mUniqueStrings);
|
||||
writer.StringElement(STRATEGY, JS::TrackedStrategyString(strategy));
|
||||
writer.StringElement(OUTCOME, JS::TrackedOutcomeString(outcome));
|
||||
explicit ForEachTrackedOptimizationAttemptsLambdaOp(LambdaT&& aLambda)
|
||||
: mLambda(Move(aLambda))
|
||||
{}
|
||||
void operator()(JS::TrackedStrategy aStrategy, JS::TrackedOutcome aOutcome) override {
|
||||
mLambda(aStrategy, aOutcome);
|
||||
}
|
||||
private:
|
||||
LambdaT mLambda;
|
||||
};
|
||||
|
||||
template<typename LambdaT> ForEachTrackedOptimizationAttemptsLambdaOp<LambdaT>
|
||||
MakeForEachTrackedOptimizationAttemptsLambdaOp(LambdaT&& aLambda)
|
||||
{
|
||||
return ForEachTrackedOptimizationAttemptsLambdaOp<LambdaT>(Move(aLambda));
|
||||
}
|
||||
|
||||
uint32_t UniqueJSONStrings::GetOrAddIndex(const char* aStr)
|
||||
{
|
||||
uint32_t index;
|
||||
|
@ -462,8 +460,18 @@ StreamJITFrameOptimizations(SpliceableJSONWriter& aWriter,
|
|||
|
||||
aWriter.StartArrayProperty("data");
|
||||
{
|
||||
StreamOptimizationAttemptsOp attemptOp(aWriter, aUniqueStrings);
|
||||
aJITFrame.forEachOptimizationAttempt(attemptOp, script.address(), &pc);
|
||||
auto op = MakeForEachTrackedOptimizationAttemptsLambdaOp(
|
||||
[&](JS::TrackedStrategy strategy, JS::TrackedOutcome outcome) {
|
||||
enum Schema : uint32_t {
|
||||
STRATEGY = 0,
|
||||
OUTCOME = 1
|
||||
};
|
||||
|
||||
AutoArraySchemaWriter writer(aWriter, aUniqueStrings);
|
||||
writer.StringElement(STRATEGY, JS::TrackedStrategyString(strategy));
|
||||
writer.StringElement(OUTCOME, JS::TrackedOutcomeString(outcome));
|
||||
});
|
||||
aJITFrame.forEachOptimizationAttempt(op, script.address(), &pc);
|
||||
}
|
||||
aWriter.EndArray();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче