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 @@
#include "bindings/core/v8/V8GCController.h"
#include "core/testing/DeathAwareScriptWrappable.h"
#include "platform/bindings/TraceWrapperV8Reference.h"
#include "platform/bindings/V8DOMWrapper.h"
#include "platform/bindings/V8PerIsolateData.h"
#include "testing/gtest/include/gtest/gtest.h"
......@@ -379,16 +380,16 @@ TEST(ScriptWrappableMarkingVisitor, WriteBarrierForScriptWrappable) {
HeapObjectHeader::FromPayload(target)->MarkWrapperHeader();
// Create a 'wrapper' object.
v8::Local<v8::ObjectTemplate> t = v8::ObjectTemplate::New(scope.GetIsolate());
t->SetInternalFieldCount(2);
v8::Local<v8::Object> obj =
t->NewInstance(scope.GetContext()).ToLocalChecked();
v8::Local<v8::Object> wrapper = V8DOMWrapper::CreateWrapper(
scope.GetIsolate(), scope.GetContext()->Global(),
target->GetWrapperTypeInfo());
// Upon setting the wrapper we should have executed the write barrier.
CHECK_EQ(0u, raw_visitor->NumberOfMarkedWrappers());
bool success =
target->SetWrapper(scope.GetIsolate(), target->GetWrapperTypeInfo(), obj);
CHECK(success);
v8::Local<v8::Object> final_wrapper =
V8DOMWrapper::AssociateObjectWithWrapper(
scope.GetIsolate(), target, target->GetWrapperTypeInfo(), wrapper);
CHECK(!final_wrapper.IsEmpty());
CHECK_EQ(1u, raw_visitor->NumberOfMarkedWrappers());
}
......
......@@ -51,7 +51,7 @@ class V8DOMWrapper {
STATIC_ONLY(V8DOMWrapper);
public:
static v8::Local<v8::Object> CreateWrapper(
PLATFORM_EXPORT static v8::Local<v8::Object> CreateWrapper(
v8::Isolate*,
v8::Local<v8::Object> creation_context,
const WrapperTypeInfo*);
......@@ -61,11 +61,11 @@ class V8DOMWrapper {
// ScriptWrappable is not yet associated with any wrapper. Returns the
// wrapper already associated or |wrapper| if not yet associated.
// The caller should always use the returned value rather than |wrapper|.
WARN_UNUSED_RESULT static v8::Local<v8::Object> AssociateObjectWithWrapper(
v8::Isolate*,
ScriptWrappable*,
const WrapperTypeInfo*,
v8::Local<v8::Object> wrapper);
PLATFORM_EXPORT WARN_UNUSED_RESULT static v8::Local<v8::Object>
AssociateObjectWithWrapper(v8::Isolate*,
ScriptWrappable*,
const WrapperTypeInfo*,
v8::Local<v8::Object> wrapper);
static void SetNativeInfo(v8::Isolate*,
v8::Local<v8::Object>,
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