Closed Bug 1338910 Opened 8 years ago Closed 8 years ago

Context with const are slow

Categories

(Core :: JavaScript Engine: JIT, defect, P1)

52 Branch
defect

Tracking

()

RESOLVED FIXED

People

(Reporter: memmie, Assigned: tcampbell)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0 Build ID: 20170209120619 Steps to reproduce: I reduce the problem to the following test: ``` const test = ""; function noop(){test;} console.time("5m empty loop const"); for (var i = 0; i < 5000000; i++); console.timeEnd("5m empty loop const"); ``` ``` var test = ""; function noop(){test;} console.time("5m empty loop var"); for (var i = 0; i < 5000000; i++); console.timeEnd("5m empty loop var"); ``` The noop function have a reference to a constante in the same context. An empty loop is executed 5 million times. Actual results: 5m empty loop const : minuteur démarré 5m empty loop const : 37.09 ms 5m empty loop var : minuteur démarré 5m empty loop var : 2.52 ms The test with the reference to a constant spend ~15 more time than the one with the variable reference Expected results: The time spend should be the same. Better, the reference inside the noop shouldn't have any impact to the declaring context execution
Component: Untriaged → JavaScript Engine
Product: Firefox → Core
where do you put the code? can you provide standalone testcase? I confirmed the issue only if the code is not at toplevel, like, inside block, or inside function. in that case, it should be the same issue as bug 1284590, that depends on bug 1273858.
Attached file test.html (deleted) —
thanks :) confirmed.
Status: UNCONFIRMED → NEW
Component: JavaScript Engine → JavaScript Engine: JIT
Depends on: 1273858
Ever confirmed: true
Blocks: es6perf
Bug 1273858 should fix this. Marking as P1 to retest when that lands.
Priority: -- → P1
(In reply to Hannes Verschore [:h4writer] from comment #4) > Bug 1273858 should fix this. Marking as P1 to retest when that lands. Confirmed. Bug 1273858 patches fix this on my build. As h4writer says, once that lands this can be retested.
Assignee: nobody → tcampbell
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
This seems to have broken again const is 4x slower than var vs v8 where const is a few percent faster https://jsperf.com/const-vs-var
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: