Chromium Code Reviews| Index: test/cctest/test-serialize.cc |
| diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc |
| index 8750cd87afbc5c1a7854766d6ea1d2704dda51f4..73c356471bf6b0f3300eb9dcb339427776fb811d 100644 |
| --- a/test/cctest/test-serialize.cc |
| +++ b/test/cctest/test-serialize.cc |
| @@ -2022,8 +2022,11 @@ void SerializedCallbackReplacement( |
| args.GetReturnValue().Set(v8_num(1337)); |
| } |
| +static int serialized_static_field = 314; |
|
vogelheim
2016/11/10 09:37:10
Huh?
Yang
2016/11/10 10:36:19
We are just checking that this static address is c
|
| + |
| intptr_t original_external_references[] = { |
| - reinterpret_cast<intptr_t>(SerializedCallback), 0}; |
| + reinterpret_cast<intptr_t>(SerializedCallback), |
| + reinterpret_cast<intptr_t>(&serialized_static_field), 0}; |
| intptr_t replaced_external_references[] = { |
| reinterpret_cast<intptr_t>(SerializedCallbackReplacement), 0}; |
| @@ -2142,7 +2145,6 @@ TEST(SnapshotCreatorTemplates) { |
| InternalFieldData* a1 = new InternalFieldData{11}; |
| InternalFieldData* b0 = new InternalFieldData{20}; |
| InternalFieldData* c0 = new InternalFieldData{30}; |
| - InternalFieldData* c1 = new InternalFieldData{31}; |
| v8::SnapshotCreator creator(original_external_references); |
| v8::Isolate* isolate = creator.GetIsolate(); |
| @@ -2158,7 +2160,7 @@ TEST(SnapshotCreatorTemplates) { |
| v8::Context::New(isolate, no_extension, global_template); |
| v8::Local<v8::ObjectTemplate> object_template = |
| v8::ObjectTemplate::New(isolate); |
| - object_template->SetInternalFieldCount(2); |
| + object_template->SetInternalFieldCount(3); |
| v8::Context::Scope context_scope(context); |
| ExpectInt32("f()", 42); |
| @@ -2169,12 +2171,17 @@ TEST(SnapshotCreatorTemplates) { |
| object_template->NewInstance(context).ToLocalChecked(); |
| v8::Local<v8::Object> c = |
| object_template->NewInstance(context).ToLocalChecked(); |
| + v8::Local<v8::External> null_external = |
| + v8::External::New(isolate, nullptr); |
| + v8::Local<v8::External> field_external = |
| + v8::External::New(isolate, &serialized_static_field); |
| a->SetInternalField(0, b); |
| a->SetAlignedPointerInInternalField(1, a1); |
| b->SetAlignedPointerInInternalField(0, b0); |
| b->SetInternalField(1, c); |
| c->SetAlignedPointerInInternalField(0, c0); |
| - c->SetAlignedPointerInInternalField(1, c1); |
| + c->SetInternalField(1, null_external); |
| + c->SetInternalField(2, field_external); |
| CHECK(context->Global()->Set(context, v8_str("a"), a).FromJust()); |
| CHECK_EQ(0, creator.AddContext(context)); |
| @@ -2186,7 +2193,6 @@ TEST(SnapshotCreatorTemplates) { |
| delete a1; |
| delete b0; |
| - delete c1; |
| delete c0; |
| } |
| @@ -2239,19 +2245,28 @@ TEST(SnapshotCreatorTemplates) { |
| a->GetInternalField(0)->ToObject(context).ToLocalChecked(); |
| InternalFieldData* a1 = reinterpret_cast<InternalFieldData*>( |
| a->GetAlignedPointerFromInternalField(1)); |
| + v8::Local<v8::Value> a2 = a->GetInternalField(2); |
| + |
| InternalFieldData* b0 = reinterpret_cast<InternalFieldData*>( |
| b->GetAlignedPointerFromInternalField(0)); |
| v8::Local<v8::Object> c = |
| b->GetInternalField(1)->ToObject(context).ToLocalChecked(); |
| + v8::Local<v8::Value> b2 = b->GetInternalField(2); |
| + |
| InternalFieldData* c0 = reinterpret_cast<InternalFieldData*>( |
| c->GetAlignedPointerFromInternalField(0)); |
| - InternalFieldData* c1 = reinterpret_cast<InternalFieldData*>( |
| - c->GetAlignedPointerFromInternalField(1)); |
| + v8::Local<v8::Value> c1 = c->GetInternalField(1); |
| + v8::Local<v8::Value> c2 = c->GetInternalField(2); |
| CHECK_EQ(11, a1->data); |
| + CHECK(a2->IsUndefined()); |
| CHECK_EQ(20, b0->data); |
| + CHECK(b2->IsUndefined()); |
| CHECK_EQ(30, c0->data); |
| - CHECK_EQ(31, c1->data); |
| + CHECK(c1->IsExternal()); |
| + CHECK_NULL(v8::Local<v8::External>::Cast(c1)->Value()); |
| + CHECK_EQ(static_cast<void*>(&serialized_static_field), |
| + v8::Local<v8::External>::Cast(c2)->Value()); |
| // Accessing out of bound returns empty MaybeHandle. |
| CHECK(v8::ObjectTemplate::FromSnapshot(isolate, 2).IsEmpty()); |
| @@ -2260,7 +2275,6 @@ TEST(SnapshotCreatorTemplates) { |
| delete a1; |
| delete b0; |
| - delete c1; |
| delete c0; |
| } |