Commit f782f74b authored by Yang Guo's avatar Yang Guo Committed by Commit Bot

[snapshot] do not skip nullptr embedder fields.

R=petermarshall@chromium.org

Bug: chromium:617892
Change-Id: I4077ae567297d18edd6c6748f9f64bbdafb34896
Reviewed-on: https://chromium-review.googlesource.com/616561
Commit-Queue: Yang Guo <yangguo@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47368}
parent 67d8b0c8
......@@ -141,8 +141,6 @@ void PartialSerializer::SerializeEmbedderFields() {
int embedder_fields_count = obj->GetEmbedderFieldCount();
for (int i = 0; i < embedder_fields_count; i++) {
if (obj->GetEmbedderField(i)->IsHeapObject()) continue;
// Do not attempt to serialize nullptr embedder fields.
if (obj->GetEmbedderField(i) == 0) continue;
StartupData data = serialize_embedder_fields_.callback(
v8::Utils::ToLocal(obj), i, serialize_embedder_fields_.data);
......
......@@ -597,9 +597,9 @@ v8::StartupData SerializeInternalFields(v8::Local<v8::Object> holder, int index,
CHECK_EQ(reinterpret_cast<void*>(2016), data);
InternalFieldData* embedder_field = static_cast<InternalFieldData*>(
holder->GetAlignedPointerFromInternalField(index));
if (embedder_field == nullptr) return {nullptr, 0};
int size = sizeof(*embedder_field);
char* payload = new char[size];
DCHECK(embedder_field != nullptr);
// We simply use memcpy to serialize the content.
memcpy(payload, embedder_field, size);
return {payload, size};
......@@ -609,6 +609,10 @@ std::vector<InternalFieldData*> deserialized_data;
void DeserializeInternalFields(v8::Local<v8::Object> holder, int index,
v8::StartupData payload, void* data) {
if (payload.raw_size == 0) {
holder->SetAlignedPointerInInternalField(index, nullptr);
return;
}
CHECK_EQ(reinterpret_cast<void*>(2017), data);
InternalFieldData* embedder_field = new InternalFieldData{0};
memcpy(embedder_field, payload.data, payload.raw_size);
......@@ -660,6 +664,7 @@ void TypedArrayTestHelper(const char* code,
v8::DeserializeInternalFieldsCallback(DeserializeInternalFields,
reinterpret_cast<void*>(2017)));
delete[] blob.data; // We can dispose of the snapshot blob now.
CHECK(deserialized_data.empty()); // We do not expect any embedder data.
v8::Context::Scope c_scope(context);
TestInt32Expectations(expectations);
}
......
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