Parser: Report use counts once per feature
Reporting use counts by invoking a callback once per occurrence has a large overhead cost in certain situations, for example when it needs to be dispatched to a different thread (which is the case for Web Workers). Parsing large scripts can produce a lot of occurrences (strict/sloppy mode once per function). Chromium (the only known user of UseCounters so far) does not actually care about number of occurrences, but simply whether they happened at least once. This commit changes behavior to report features at most once, which dramatically improves performance for impacted use cases, and should not affect the only known real world usage. R=littledan@chromium.org BUG=chromium:614775 Review-Url: https://codereview.chromium.org/2062203002 Cr-Commit-Position: refs/heads/master@{#36979}
This commit is contained in:
parent
2d1f977c93
commit
2f6be682ac
1
AUTHORS
1
AUTHORS
@ -92,6 +92,7 @@ Mike Pennisi <mike@mikepennisi.com>
|
||||
Milton Chiang <milton.chiang@mediatek.com>
|
||||
Myeong-bo Shim <m0609.shim@samsung.com>
|
||||
Nicolas Antonius Ernst Leopold Maria Kaiser <nikai@nikai.net>
|
||||
Oleksandr Chekhovskyi <oleksandr.chekhovskyi@gmail.com>
|
||||
Paolo Giarrusso <p.giarrusso@gmail.com>
|
||||
Patrick Gansterer <paroga@paroga.com>
|
||||
Peter Varga <pvarga@inf.u-szeged.hu>
|
||||
|
@ -5214,7 +5214,7 @@ void Parser::Internalize(Isolate* isolate, Handle<Script> script, bool error) {
|
||||
// Move statistics to Isolate.
|
||||
for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
|
||||
++feature) {
|
||||
for (int i = 0; i < use_counts_[feature]; ++i) {
|
||||
if (use_counts_[feature] > 0) {
|
||||
isolate->CountUsage(v8::Isolate::UseCounterFeature(feature));
|
||||
}
|
||||
}
|
||||
|
@ -3569,10 +3569,8 @@ TEST(UseAsmUseCount) {
|
||||
CcTest::isolate()->SetUseCounterCallback(MockUseCounterCallback);
|
||||
CompileRun("\"use asm\";\n"
|
||||
"var foo = 1;\n"
|
||||
"\"use asm\";\n" // Only the first one counts.
|
||||
"function bar() { \"use asm\"; var baz = 1; }");
|
||||
// Optimizing will double-count because the source is parsed twice.
|
||||
CHECK_EQ(i::FLAG_always_opt ? 4 : 2, use_counts[v8::Isolate::kUseAsm]);
|
||||
CHECK_LT(0, use_counts[v8::Isolate::kUseAsm]);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user