Closed Bug 810715 Opened 12 years ago Closed 12 years ago

De-lazify a JSFunction's script before querying its ndefaults value

Categories

(Core :: JavaScript Engine, defect)

Other Branch
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: till, Unassigned)

References

Details

(Whiteboard: [js:t])

Attachments

(1 file, 1 obsolete file)

To support default parameters in functions with lazily created bytecode, the ndefaults field has to move to JSFunction. This is because fooFunction.length can be called before fooFunction is invoked the first time and thus de-lazified. From a quick look at all the sites that set ndefaults, it looks like they all have access to the containing JSFunction and could set the field on that just as well.
Whiteboard: [js:t]
Try run for b38b02bc6579 is complete. Detailed breakdown of the results available here: https://tbpl.mozilla.org/?tree=Try&rev=b38b02bc6579 Results (out of 1 total builds): failure: 1 Builds (or logs if builds failed) available at: http://ftp.mozilla.org/pub/mozilla.org/firefox/try-builds/tschneidereit@gmail.com-b38b02bc6579
This adds an ndefaults field to JSFunction and keeps it in sync with the one on JSScript. Removing ndefaults from the script isn't feasible since, as opposed to what I said in comment 0, we don't always have a JSFunction available when setting ndefaults, after all.
Attachment #707107 - Flags: review?(luke)
Could you remind me why foo.length couldn't first clone the script?
That'd certainly be an option, too. You think that the case of foo.length being queried without foo being called will be too rare to bother about the needless clone?
Yeah, I wouldn't worry about trying to delay the clone; it stands to reason that if they are querying the length they are about to (or just did) call the function.
You're right, of course: Going to any lengths at all to prevent cloning here is just plain silly. This makes the new patch rather boring. To spice it up a little, I fixed an unrelated call to getOrCreateScript where the result wasn't checked. Hope that's ok.
Attachment #707524 - Flags: review?(luke)
Attachment #707107 - Attachment is obsolete: true
Attachment #707107 - Flags: review?(luke)
Comment on attachment 707524 [details] [diff] [review] De-lazify a JSFunction's script before querying its ndefaults value. r=? Review of attachment 707524 [details] [diff] [review]: ----------------------------------------------------------------- Great!
Attachment #707524 - Flags: review?(luke) → review+
Summary: Move JSScript::ndefaults to JSFunction → De-lazify a JSFunction's script before querying its ndefaults value
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla21
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: