Closed Bug 1262212 Opened 8 years ago Closed 2 years ago

new Object() is deathly slow

Categories

(Core :: JavaScript Engine, defect)

defect

Tracking

()

RESOLVED FIXED
108 Branch
Tracking Status
firefox48 --- wontfix
firefox108 --- fixed

People

(Reporter: bzbarsky, Assigned: anba)

References

Details

Attachments

(5 files)

Attached file Testcase
See attached testcase: new Object is 200x slower than the other things being tested.
We could optimize this like the Object.create(null) optimization in bug 1066878.

Alternative is to self-host, but it'd be unfortunate to conflate type information for |Object()| by giving all objects the same group. It'd be nice to look at the caller of the self-hosted function to determine the allocation site, but that's a bit complicated (to make fast).
Severity: normal → S3

CreateThis always allocates an AllocKind::OBJECT4 object (cf. NewObjectGCKind()),
so we can end up with allocating an object with fewer reserved slots than indicated
by its class. To avoid this situation inline the relevant bits of CreateThis into
JS_NewObjectForConstructor.

Assignee: nobody → andrebargull
Status: NEW → ASSIGNED

Both functions are now only used for obj_construct, so inline resp. move them
next to obj_construct.

Depends on D160639

Inline new Object() calls by using the same CacheIR instructions we use when
creating object literals.

Depends on D160640

Pushed by andre.bargull@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/9dca46830de3
Part 1: Don't call CreateThis in JS_NewObjectForConstructor. r=jandem
https://hg.mozilla.org/integration/autoland/rev/6c098893465f
Part 2: Inline NewObjectScriptedCall and CreateThis into obj_construct. r=jandem
https://hg.mozilla.org/integration/autoland/rev/b17767ae7ab0
Part 3: Inline `new Object()` calls. r=jandem
https://hg.mozilla.org/integration/autoland/rev/d05811d05349
Part 4: Move CacheIR inlining of Object into a single method. r=jandem
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: