Commit 1416c6c9 authored by yangguo's avatar yangguo Committed by Commit bot

[serializer] wipe simulator redirects for accessor infos.

R=jochen@chromium.org
BUG=chromium:617892

Review-Url: https://codereview.chromium.org/2561783002
Cr-Commit-Position: refs/heads/master@{#41587}
parent 0ce8f19b
......@@ -363,9 +363,8 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
};
static const AccessorRefTable getters[] = {
#define ACCESSOR_INFO_DECLARATION(name) \
{ FUNCTION_ADDR(&Accessors::name##Getter), \
"Redirect to Accessors::" #name "Getter"},
#define ACCESSOR_INFO_DECLARATION(name) \
{FUNCTION_ADDR(&Accessors::name##Getter), "Accessors::" #name "Getter"},
ACCESSOR_INFO_LIST(ACCESSOR_INFO_DECLARATION)
#undef ACCESSOR_INFO_DECLARATION
};
......@@ -377,10 +376,7 @@ void ExternalReferenceTable::AddAccessors(Isolate* isolate) {
};
for (unsigned i = 0; i < arraysize(getters); ++i) {
const char* name = getters[i].name + 12; // Skip "Redirect to " prefix.
Add(getters[i].address, name);
Add(AccessorInfo::redirect(isolate, getters[i].address, ACCESSOR_GETTER),
getters[i].name);
Add(getters[i].address, getters[i].name);
}
for (unsigned i = 0; i < arraysize(setters); ++i) {
......
......@@ -93,6 +93,7 @@ void Deserializer::Deserialize(Isolate* isolate) {
isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
DeserializeDeferredObjects();
FlushICacheForNewIsolate();
RestoreExternalReferenceRedirectors(&accessor_infos_);
}
isolate_->heap()->set_native_contexts_list(
......@@ -316,6 +317,10 @@ HeapObject* Deserializer::PostProcessNewObject(HeapObject* obj, int space) {
if (deserializing_user_code() || space == LO_SPACE) {
new_code_objects_.Add(Code::cast(obj));
}
} else if (obj->IsAccessorInfo()) {
if (isolate_->external_reference_redirector()) {
accessor_infos_.Add(AccessorInfo::cast(obj));
}
}
// Check alignment.
DCHECK_EQ(0, Heap::GetFillToAlign(obj->address(), obj->RequiredAlignment()));
......
......@@ -138,6 +138,7 @@ class Deserializer : public SerializerDeserializer {
List<HeapObject*> deserialized_large_objects_;
List<Code*> new_code_objects_;
List<AccessorInfo*> accessor_infos_;
List<Handle<String> > new_internalized_strings_;
List<Handle<Script> > new_scripts_;
......
......@@ -21,8 +21,7 @@ ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
for (uint32_t i = 0; i < table->size(); ++i) {
Address addr = table->address(i);
DCHECK(map_->Get(addr).IsNothing() ||
strncmp(table->name(i), "Redirect to ", 12) == 0);
DCHECK(map_->Get(addr).IsNothing());
map_->Set(addr, i);
DCHECK(map_->Get(addr).IsJust());
}
......@@ -81,5 +80,14 @@ bool SerializerDeserializer::CanBeDeferred(HeapObject* o) {
return !o->IsString() && !o->IsScript();
}
void SerializerDeserializer::RestoreExternalReferenceRedirectors(
List<AccessorInfo*>* accessor_infos) {
// Restore wiped accessor infos.
for (AccessorInfo* info : *accessor_infos) {
Foreign::cast(info->js_getter())
->set_foreign_address(info->redirected_getter());
}
}
} // namespace internal
} // namespace v8
......@@ -86,6 +86,8 @@ class SerializerDeserializer : public ObjectVisitor {
protected:
static bool CanBeDeferred(HeapObject* o);
void RestoreExternalReferenceRedirectors(List<AccessorInfo*>* accessor_infos);
// ---------- byte code range 0x00..0x7f ----------
// Byte codes in this range represent Where, HowToCode and WhereToPoint.
// Where the pointed-to object can be found:
......
......@@ -21,6 +21,7 @@ StartupSerializer::StartupSerializer(
}
StartupSerializer::~StartupSerializer() {
RestoreExternalReferenceRedirectors(&accessor_infos_);
OutputStatistics("StartupSerializer");
}
......@@ -66,6 +67,14 @@ void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
FlushSkip(skip);
if (isolate_->external_reference_redirector() && obj->IsAccessorInfo()) {
// Wipe external reference redirects in the accessor info.
AccessorInfo* info = AccessorInfo::cast(obj);
Address original_address = Foreign::cast(info->getter())->foreign_address();
Foreign::cast(info->js_getter())->set_foreign_address(original_address);
accessor_infos_.Add(info);
}
// Object has not yet been serialized. Serialize it here.
ObjectSerializer object_serializer(this, obj, &sink_, how_to_code,
where_to_point);
......
......@@ -73,6 +73,7 @@ class StartupSerializer : public Serializer {
bool serializing_immortal_immovables_roots_;
std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_;
PartialCacheIndexMap partial_cache_index_map_;
List<AccessorInfo*> accessor_infos_;
DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
};
......
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