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

Issue 11190050: Heavy cleanup of the external pointer API. (Closed)

Created:
8 years, 2 months ago by Sven Panne
Modified:
8 years, 1 month ago
CC:
v8-dev
Visibility:
Public.

Description

Heavy cleanup of the external pointer API. Added highly efficient Object::SetAlignedPointerInInternalField and Object::GetAlignedPointerFromInternalField functions for 2-byte-aligned pointers. Their non-aligned counterparts Object::GetPointerFromInternalField and Object::SetPointerInInternalField are now deprecated utility functions. External is now a true Value again, with New/Value/Cast using a JSObject with an internal field containing a Foreign. External::Wrap, and External::Unwrap are now deprecated utility functions. Added Context::GetEmbedderData and Context::SetEmbedderData. Deprecated Context::GetData and Context::SetData, these are now only wrappers to access internal field 0. Added highly efficient Context::SetAlignedPointerInEmbedderData and Context::GetAlignedPointerFromEmbedderData functions for 2-byte-aligned pointers. Committed: https://code.google.com/p/v8/source/detail?r=12849

Patch Set 1 #

Patch Set 2 : Make External objects non-extensible #

Patch Set 3 : Context::GetInternalField / Context::SetInternalField fully implemented #

Patch Set 4 : Cleaned up Object::GetInternalField and Object::SetInternalField #

Patch Set 5 : Improved resizing strategy. Fixed assertion. #

Patch Set 6 : Context cleanup #

Patch Set 7 : Renamings, cleanup and a rebase #

Total comments: 5

Patch Set 8 : Avoid Handle allocation in Object::GetPointerFromInternalField, there might be no HandleScope #

Patch Set 9 : #

Patch Set 10 : Added more unit tests #

Patch Set 11 : #

Total comments: 19

Patch Set 12 : Addressed feedback #

Patch Set 13 : Rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+525 lines, -326 lines) Patch
M include/v8.h View 1 2 3 4 5 6 7 8 9 10 11 12 16 chunks +161 lines, -107 lines 0 comments Download
M src/api.h View 1 2 3 4 5 6 7 8 9 10 11 4 chunks +3 lines, -3 lines 0 comments Download
M src/api.cc View 1 2 3 4 5 6 7 8 9 10 11 6 chunks +116 lines, -134 lines 0 comments Download
M src/bootstrapper.cc View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -2 lines 0 comments Download
M src/compiler.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +3 lines, -1 line 0 comments Download
M src/contexts.h View 1 2 3 4 5 3 chunks +5 lines, -2 lines 0 comments Download
M src/factory.h View 1 2 2 chunks +5 lines, -0 lines 0 comments Download
M src/factory.cc View 1 2 2 chunks +13 lines, -0 lines 0 comments Download
M src/heap.h View 1 2 3 4 2 chunks +5 lines, -1 line 0 comments Download
M src/heap.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +22 lines, -0 lines 0 comments Download
M src/objects.h View 1 2 3 4 5 2 chunks +3 lines, -0 lines 0 comments Download
M src/objects-inl.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +8 lines, -0 lines 0 comments Download
M src/profile-generator.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +1 line, -1 line 0 comments Download
M test/cctest/test-api.cc View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +96 lines, -0 lines 0 comments Download
M test/cctest/test-debug.cc View 1 chunk +3 lines, -0 lines 0 comments Download
M test/cctest/test-decls.cc View 1 chunk +2 lines, -1 line 0 comments Download
M tools/grokdump.py View 1 chunk +76 lines, -74 lines 0 comments Download

Messages

Total messages: 8 (0 generated)
Sven Panne
Unit tests for the Context API part are still missing, but the rest is ready ...
8 years, 2 months ago (2012-10-23 14:01:13 UTC) #1
abarth-chromium
I mostly looked at the API side of this CL because that's the part I ...
8 years, 2 months ago (2012-10-23 15:16:30 UTC) #2
Sven Panne
https://codereview.chromium.org/11190050/diff/2034/include/v8.h File include/v8.h (right): https://codereview.chromium.org/11190050/diff/2034/include/v8.h#newcode1987 include/v8.h:1987: V8_DEPRECATED(static inline void* Unwrap(Handle<Value> obj)); On 2012/10/23 15:16:30, abarth ...
8 years, 2 months ago (2012-10-24 06:31:35 UTC) #3
abarth-chromium
That all makes sense. I'll be sure to move WebKit over to the aligned pointer ...
8 years, 2 months ago (2012-10-24 06:45:01 UTC) #4
Sven Panne
https://codereview.chromium.org/11190050/diff/2034/include/v8.h File include/v8.h (right): https://codereview.chromium.org/11190050/diff/2034/include/v8.h#newcode4729 include/v8.h:4729: O** result = HandleScope::CreateHandle(I::ReadEmbedderData<O*>(this, index)); On 2012/10/23 15:16:30, abarth ...
8 years, 2 months ago (2012-10-24 07:36:58 UTC) #5
Sven Panne
Added missing unit tests, so this CL should be reviewable in its full glory... :-)
8 years, 2 months ago (2012-10-24 12:12:33 UTC) #6
Michael Starzinger
LGTM (if comments are addressed). https://codereview.chromium.org/11190050/diff/14009/include/v8.h File include/v8.h (right): https://codereview.chromium.org/11190050/diff/14009/include/v8.h#newcode1632 include/v8.h:1632: * a field, you ...
8 years, 1 month ago (2012-10-25 09:41:53 UTC) #7
Sven Panne
8 years, 1 month ago (2012-10-25 14:23:08 UTC) #8
Addressed feedback, waiting to land this until our bleeding_edge is open for
non-bug-fixes again...

https://codereview.chromium.org/11190050/diff/14009/include/v8.h
File include/v8.h (right):

https://codereview.chromium.org/11190050/diff/14009/include/v8.h#newcode1632
include/v8.h:1632: * a field, you must use GetAlignedPointerFromInternalField,
everything else
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Can we rephrase the comment so that it doesn't use personal pronouns. E.g.
"Such
> a field must be retrieved via GetAlignedPointerFromInternalField, everything
> else [...]"

Done here and at similar places.

https://codereview.chromium.org/11190050/diff/14009/src/api.cc
File src/api.cc (right):

https://codereview.chromium.org/11190050/diff/14009/src/api.cc#newcode827
src/api.cc:827: data->set(index, *Utils::OpenHandle(*value));
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Even though this pattern is safe, GCMole might report it as a false positive.

Done.

https://codereview.chromium.org/11190050/diff/14009/src/api.cc#newcode4239
src/api.cc:4239: static bool ObjectFieldOK(i::Handle<i::JSObject> obj,
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Can we call this InternalFieldOK?

Done.

https://codereview.chromium.org/11190050/diff/14009/src/api.cc#newcode4262
src/api.cc:4262: obj->SetInternalField(index, *Utils::OpenHandle(*value));
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Even though this pattern is safe, GCMole might report it as a false positive.

Done.

https://codereview.chromium.org/11190050/diff/14009/src/api.cc#newcode4742
src/api.cc:4742: // TODO(svenpanne) This should somehow be Utils::ToLocal.
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> You can get a ToLocal by calling it ExternalToLocal and adding the following
> line to api.h, I would prefer that:
> 
> MAKE_TO_LOCAL(ExternalToLocal, JSObject, External)

Ooops, forgot that TODO. Good point, one can even remove the old incorrect
conversion From Foreign to External.

https://codereview.chromium.org/11190050/diff/14009/src/bootstrapper.cc
File src/bootstrapper.cc (right):

https://codereview.chromium.org/11190050/diff/14009/src/bootstrapper.cc#newco...
src/bootstrapper.cc:1244:
native_context()->set_embedder_data(*factory->NewFixedArray(2));
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> This pattern is not GC-safe and GCMole will (hopefully) complain about it.
First
> allocate the array, and then take the native_context dereference.
> 
> Handle<FixedArray> embedder_data = factory->NewFixedArray(2);
> native_context()->set_embedder_data(embedder_data);

Done.

https://codereview.chromium.org/11190050/diff/14009/src/compiler.cc
File src/compiler.cc (right):

https://codereview.chromium.org/11190050/diff/14009/src/compiler.cc#newcode436
src/compiler.cc:436: FixedArray* array =
(*isolate->native_context())->embedder_data();
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> This can just be "isolate->native_context()->embedder_data()" without the
> explicit dereference.

Done. Excessive overloading FTW! :-P

https://codereview.chromium.org/11190050/diff/14009/src/objects.h
File src/objects.h (right):

https://codereview.chromium.org/11190050/diff/14009/src/objects.h#newcode2414
src/objects.h:2414: STATIC_CHECK(kHeaderSize ==
Internals::kFixedArrayHeaderSize);
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Can we move this to FixedArrayBase, right after the constant is actually
> defined? Closer is better.

I put the check here intentionally, and I think it is actually a better place
than the one in FixedArrayBase: The user of kFixedArrayHeaderSize only cares
about the fact that the object in question is a FixedArray and not about the
implementation hierarchy. I really want to assert that FixedArray::kHeaderSize
is equal to kFixedArrayHeaderSize, so it belongs here.

https://codereview.chromium.org/11190050/diff/14009/test/cctest/test-api.cc
File test/cctest/test-api.cc (right):

https://codereview.chromium.org/11190050/diff/14009/test/cctest/test-api.cc#n...
test/cctest/test-api.cc:2060: 
On 2012/10/25 09:41:53, Michael Starzinger wrote:
> Add second empty newline for readability.

Done.

Powered by Google App Engine
This is Rietveld 408576698