Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Issue 12217025: For HashTable-backed JS objects, use the proper type in the table() accessor (Closed)

Created:
7 years, 10 months ago by adamk
Modified:
7 years, 10 months ago
Reviewers:
Michael Starzinger
CC:
v8-dev
Visibility:
Public.

Description

For HashTable-backed JS objects, use the proper type in the table() accessor Currently nearly all code using JSSet/JSMap/JSWeakMap does a cast whenever calling table(). This patch simply puts that cast inside the accessor. The only possible way for table() to not be valid is during heap verification (which has been fixed up to not call the accessor) or if GC occurs during construction of the hash table itself (where a call to HeapObject::RawField has been moved up to do the read instead of going through the accessor). This is a precursor to making a similar change to JSArray::length(), but is hopefully less dramatic, since there are many fewer uses of sets and maps than arrays.

Patch Set 1 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+39 lines, -33 lines) Patch
M src/mark-compact.cc View 3 chunks +4 lines, -5 lines 0 comments Download
M src/objects.h View 3 chunks +3 lines, -3 lines 0 comments Download
M src/objects.cc View 1 chunk +2 lines, -3 lines 0 comments Download
M src/objects-debug.cc View 1 chunk +14 lines, -6 lines 0 comments Download
M src/objects-inl.h View 1 chunk +3 lines, -3 lines 0 comments Download
M src/runtime.cc View 13 chunks +13 lines, -13 lines 0 comments Download

Messages

Total messages: 4 (0 generated)
adamk
7 years, 10 months ago (2013-02-05 23:55:24 UTC) #1
Michael Starzinger
This essentially introduces a lie into our type-system, because there are observable points in time ...
7 years, 10 months ago (2013-02-06 11:43:12 UTC) #2
Michael Starzinger
I could be convinced to change the return-type of the table() accessor to HeapObject, because ...
7 years, 10 months ago (2013-02-06 11:46:34 UTC) #3
adamk
7 years, 10 months ago (2013-02-06 16:53:15 UTC) #4
On 2013/02/06 11:43:12, Michael Starzinger wrote:
> This essentially introduces a lie into our type-system, because there are
> observable points in time where the kTableOffset field does not contain an
> ObjectHashTable. The fact that the heap verifier observes this heap-state
proves
> that these points exist. Even though these time-windows are small they exist
and
> just because there are more use-sites that see an ObjectHashTable than
use-sites
> that see "undefined" in there, IMHO doesn't justify hiding this fact.

Fair enough, I put this together on a whim because it seemed weird that all
these callers would know something about the objects that they didn't know about
themselves. The short window of non-ObjectHashTable-ness seems like simply an
accident (see, e.g., the TODO in Heap::InitializeJSObjectFromMap) that should be
_internal_ to the JSWeakMap/JSMap/JSSet classes. But I'm sympathetic that it's
not worth "lying" in this case (and yeah, I don't think it's worth changing to
HeapObject).

Thanks for providing your perspective on this, I'm slowly learning the v8
way-of-doing-things by asking questions like this.

Powered by Google App Engine
This is Rietveld 408576698