Closed Bug 563575 Opened 15 years ago Closed 15 years ago

encapsulate jsobj.cpp dslots accesses

Categories

(Core :: JavaScript Engine, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: n.nethercote, Assigned: n.nethercote)

References

Details

(Whiteboard: fixed-in-tracemonkey)

Attachments

(1 file)

Attached patch patchSplinter Review
his patch removes all but one (which I'll do later) of the non-encapsulated uses of dslots from jsobj.cpp. Notable things: - Adds addressOfDenseArrayElement(). - SLOTS_TO_DYNAMIC_WORDS and DYNAMIC_WORDS_TO_SLOTS were changed to JSObject inline methods. - js_AllocSlots(), js_GrowSlots() and js_ShrinkSlots() were pulled in as JSObject methods. - I replaced this idiom: *slots++ = nslots; with this: slots++; slots[-1] = nslots; which is clearer and will make later changes to the meaning of slots[-1] easier.
Attachment #443275 - Flags: review?(brendan)
Blocks: 555429
Blocks: 558262
No longer blocks: 555429
Comment on attachment 443275 [details] [diff] [review] patch >+ jsval *tmpdslots = dslots; >+ tmpdslots = (jsval*) cx->realloc(dslots - 1, nwords * sizeof(jsval)); First set of tmpdslots is useless -- lose it. >+ if (!tmpdslots) >+ return false; >+ >+ dslots = tmpdslots; The tmpdslots name here is a bit off. Not sure what to suggest -- "dslotsvec"? /be
Attachment #443275 - Flags: review?(brendan) → review+
(In reply to comment #1) > (From update of attachment 443275 [details] [diff] [review]) > >+ jsval *tmpdslots = dslots; > >+ tmpdslots = (jsval*) cx->realloc(dslots - 1, nwords * sizeof(jsval)); > > First set of tmpdslots is useless -- lose it. > > >+ if (!tmpdslots) > >+ return false; > >+ > >+ dslots = tmpdslots; > > The tmpdslots name here is a bit off. Not sure what to suggest -- "dslotsvec"? It feels spot on to me -- you can't use dslots directly because if realloc() fails you will have trashed the old dslots value. So you need to use a temporary. Hence tmpdslots.
Whiteboard: fixed-in-tracemonkey
tmpdslots is ok -- I've used names like that and will again -- what I was getting at was that it never is advanced such that tmpdslots[-1] is the length. So could it have a different name to connote the lack of the +1 bias? No big. /be
Status: ASSIGNED → RESOLVED
Closed: 15 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: