Closed Bug 723346 Opened 13 years ago Closed 13 years ago

GC: make sharpObjectMap a modern HashTable

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla13

People

(Reporter: terrence, Assigned: terrence)

References

Details

Attachments

(1 file, 1 obsolete file)

This has the same problem as other places where we have markable, nursery allocable objects as hash table keys: we may need to move them about during GC. We should, at the very least, replace this old table with a new one so that we only have to solve the problems in one place. Another option here is to rip out the recursive toSource. It's not part of any spec and if it were, it would most likely want to throw on recursion.
Does sharpObjectMap have anything to do with sharps, which Waldo just removed support for? I looked at the code but am none the wiser.
Yes, but now it's only used for toSource. (It might as well be renamed at the same time.)
Depends on: 724586
Attached patch V1: minimal (obsolete) — Splinter Review
I ended up doing this in as minimal a fashion as possible. It turns out that this code path relies on at least 4 different bools, an int, and a pointer treated as a bool. I printed these out for examples in the test suite and it seems that they all do have different, specific purposes. AFAICT the relationship looks roughly like: hasGen = !hasGen && !isSharp alreadySeen = hasGen || isSharp ida = map->depth == 0 && !isSharp isSharp = alreadySeen && ida ++map->depth when !isSharp --map->depth unconditionally (not sure how this works, but I added asserts) I'm fairly certain this could be untwisted further, but it's beyond the scope of this bug.
Assignee: general → terrence
Status: NEW → ASSIGNED
Attachment #595607 - Flags: review?(jwalden+bmo)
Comment on attachment 595607 [details] [diff] [review] V1: minimal Review of attachment 595607 [details] [diff] [review]: ----------------------------------------------------------------- I don't have much confidence in my review of this, but it looks like it's the right translation. I think. Keep an eye out for regressions, and sic the fuzzers on this if you can. ::: js/src/jsobj.cpp @@ +358,5 @@ > > if (idap) > *idap = ida; > + if (isSharp) > + *isSharp = sharpid.isSharp; I don't believe it's the case that |isSharp| can ever be NULL -- just do this assignment unconditionally. @@ +416,5 @@ > * to justify spending efforts. > */ > + for (JSSharpTable::Range r = map->table.all(); !r.empty(); r.popFront()) { > + MarkRoot(trc, r.front().key, "sharp table entry"); > + } Don't brace this single-line body. @@ +446,5 @@ > JSIdArray *ida; > bool alreadySeen = false; > + bool isSharp = false; > + bool success = js_EnterSharpObject(cx, obj, &ida, &alreadySeen, &isSharp); > + if (!success) Eliminate the unnecessary |bool success| temporary here. @@ +466,5 @@ > + JS_ASSERT(!isSharp); > + if (alreadySeen) { > + JSSharpTable::Ptr p = cx->sharpObjectMap.table.lookup(obj); > + JS_ASSERT(p); > + JS_ASSERT(p->value.isSharp == isSharp); Make that |!p->value.isSharp|.
Attachment #595607 - Flags: review?(jwalden+bmo) → review+
Attachment #595607 - Attachment is obsolete: true
Attachment #597916 - Flags: review+
Gary, would it be possible to get some fuzzing on Object.toSource and Array.toSource with this patch applied?
> Gary, would it be possible to get some fuzzing on Object.toSource and > Array.toSource with this patch applied? Sure - Christian might be interested too. :)
> Gary, would it be possible to get some fuzzing on Object.toSource and > Array.toSource with this patch applied? This seems to hold up well after an hour or two's worth of fuzzing, in other words the patch didn't blow up the fuzzer.
Status: ASSIGNED → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla13
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: