Commit a0c28b8a authored by Michael Lippautz's avatar Michael Lippautz Committed by Commit Bot

[wrapper-tracing] Fix write barrier test

The test was manually hooking up a wrapper in a non-supported way.
Switch to using the providing bindings methods.

This was flushed out when incremental marking started scanning roots
right after the test and encountered a broken leftover object.

Bug: chromium:757440
Change-Id: I0636c48a22d88f2d85ded1ebab2732d3ef6de077
Reviewed-on: https://chromium-review.googlesource.com/997795Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Michael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#548581}
parent cb5a488e
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "bindings/core/v8/V8GCController.h" #include "bindings/core/v8/V8GCController.h"
#include "core/testing/DeathAwareScriptWrappable.h" #include "core/testing/DeathAwareScriptWrappable.h"
#include "platform/bindings/TraceWrapperV8Reference.h" #include "platform/bindings/TraceWrapperV8Reference.h"
#include "platform/bindings/V8DOMWrapper.h"
#include "platform/bindings/V8PerIsolateData.h" #include "platform/bindings/V8PerIsolateData.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
...@@ -379,16 +380,16 @@ TEST(ScriptWrappableMarkingVisitor, WriteBarrierForScriptWrappable) { ...@@ -379,16 +380,16 @@ TEST(ScriptWrappableMarkingVisitor, WriteBarrierForScriptWrappable) {
HeapObjectHeader::FromPayload(target)->MarkWrapperHeader(); HeapObjectHeader::FromPayload(target)->MarkWrapperHeader();
// Create a 'wrapper' object. // Create a 'wrapper' object.
v8::Local<v8::ObjectTemplate> t = v8::ObjectTemplate::New(scope.GetIsolate()); v8::Local<v8::Object> wrapper = V8DOMWrapper::CreateWrapper(
t->SetInternalFieldCount(2); scope.GetIsolate(), scope.GetContext()->Global(),
v8::Local<v8::Object> obj = target->GetWrapperTypeInfo());
t->NewInstance(scope.GetContext()).ToLocalChecked();
// Upon setting the wrapper we should have executed the write barrier. // Upon setting the wrapper we should have executed the write barrier.
CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers()); CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers());
bool success = v8::Local<v8::Object> final_wrapper =
target->SetWrapper(scope.GetIsolate(), target->GetWrapperTypeInfo(), obj); V8DOMWrapper::AssociateObjectWithWrapper(
CHECK(success); scope.GetIsolate(), target, target->GetWrapperTypeInfo(), wrapper);
CHECK(!final_wrapper.IsEmpty());
CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers()); CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers());
} }
......
...@@ -51,7 +51,7 @@ class V8DOMWrapper { ...@@ -51,7 +51,7 @@ class V8DOMWrapper {
STATIC_ONLY(V8DOMWrapper); STATIC_ONLY(V8DOMWrapper);
public: public:
static v8::Local<v8::Object> CreateWrapper( PLATFORM_EXPORT static v8::Local<v8::Object> CreateWrapper(
v8::Isolate*, v8::Isolate*,
v8::Local<v8::Object> creation_context, v8::Local<v8::Object> creation_context,
const WrapperTypeInfo*); const WrapperTypeInfo*);
...@@ -61,11 +61,11 @@ class V8DOMWrapper { ...@@ -61,11 +61,11 @@ class V8DOMWrapper {
// ScriptWrappable is not yet associated with any wrapper. Returns the // ScriptWrappable is not yet associated with any wrapper. Returns the
// wrapper already associated or |wrapper| if not yet associated. // wrapper already associated or |wrapper| if not yet associated.
// The caller should always use the returned value rather than |wrapper|. // The caller should always use the returned value rather than |wrapper|.
WARN_UNUSED_RESULT static v8::Local<v8::Object> AssociateObjectWithWrapper( PLATFORM_EXPORT WARN_UNUSED_RESULT static v8::Local<v8::Object>
v8::Isolate*, AssociateObjectWithWrapper(v8::Isolate*,
ScriptWrappable*, ScriptWrappable*,
const WrapperTypeInfo*, const WrapperTypeInfo*,
v8::Local<v8::Object> wrapper); v8::Local<v8::Object> wrapper);
static void SetNativeInfo(v8::Isolate*, static void SetNativeInfo(v8::Isolate*,
v8::Local<v8::Object>, v8::Local<v8::Object>,
const WrapperTypeInfo*, const WrapperTypeInfo*,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment