Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

Commit

Permalink
Deserializer: flush code cache while code pointers are still valid.
Browse files Browse the repository at this point in the history
Omitting test case because it would be brittle and become useless soon.

R=mlippautz@chromium.org
BUG=chromium:523453
LOG=N

Review URL: https://codereview.chromium.org/1312763002

Cr-Commit-Position: refs/heads/master@{#30331}
  • Loading branch information
hashseed authored and Commit bot committed Aug 24, 2015
1 parent 2454469 commit e642fde
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
26 changes: 14 additions & 12 deletions src/snapshot/serialize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -500,16 +500,19 @@ void Deserializer::DecodeReservation(
}


void Deserializer::FlushICacheForNewCodeObjects() {
if (!deserializing_user_code_) {
// The entire isolate is newly deserialized. Simply flush all code pages.
PageIterator it(isolate_->heap()->code_space());
while (it.has_next()) {
Page* p = it.next();
CpuFeatures::FlushICache(p->area_start(),
p->area_end() - p->area_start());
}
void Deserializer::FlushICacheForNewIsolate() {
DCHECK(!deserializing_user_code_);
// The entire isolate is newly deserialized. Simply flush all code pages.
PageIterator it(isolate_->heap()->code_space());
while (it.has_next()) {
Page* p = it.next();
CpuFeatures::FlushICache(p->area_start(), p->area_end() - p->area_start());
}
}


void Deserializer::FlushICacheForNewCodeObjects() {
DCHECK(deserializing_user_code_);
for (Code* code : new_code_objects_) {
CpuFeatures::FlushICache(code->instruction_start(),
code->instruction_size());
Expand Down Expand Up @@ -557,6 +560,7 @@ void Deserializer::Deserialize(Isolate* isolate) {
isolate_->heap()->RepairFreeListsAfterDeserialization();
isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
DeserializeDeferredObjects();
FlushICacheForNewIsolate();
}

isolate_->heap()->set_native_contexts_list(
Expand All @@ -574,8 +578,6 @@ void Deserializer::Deserialize(Isolate* isolate) {
ExtraNatives::UpdateSourceCache(isolate_->heap());
CodeStubNatives::UpdateSourceCache(isolate_->heap());

FlushICacheForNewCodeObjects();

// Issue code events for newly deserialized code objects.
LOG_CODE_EVENT(isolate_, LogCodeObjects());
LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
Expand Down Expand Up @@ -631,6 +633,7 @@ MaybeHandle<SharedFunctionInfo> Deserializer::DeserializeCode(
Object* root;
VisitPointer(&root);
DeserializeDeferredObjects();
FlushICacheForNewCodeObjects();
result = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root));
}
CommitPostProcessedObjects(isolate);
Expand Down Expand Up @@ -2625,7 +2628,6 @@ MaybeHandle<SharedFunctionInfo> CodeSerializer::Deserialize(
if (FLAG_profile_deserialization) PrintF("[Deserializing failed]\n");
return MaybeHandle<SharedFunctionInfo>();
}
deserializer.FlushICacheForNewCodeObjects();

if (FLAG_profile_deserialization) {
double ms = timer.Elapsed().InMillisecondsF();
Expand Down
5 changes: 3 additions & 2 deletions src/snapshot/serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,6 @@ class Deserializer: public SerializerDeserializer {
// Deserialize a shared function info. Fail gracefully.
MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate);

void FlushICacheForNewCodeObjects();

// Pass a vector of externally-provided objects referenced by the snapshot.
// The ownership to its backing store is handed over as well.
void SetAttachedObjects(Vector<Handle<Object> > attached_objects) {
Expand Down Expand Up @@ -576,6 +574,9 @@ class Deserializer: public SerializerDeserializer {

void DeserializeDeferredObjects();

void FlushICacheForNewIsolate();
void FlushICacheForNewCodeObjects();

void CommitPostProcessedObjects(Isolate* isolate);

// Fills in some heap data in an area from start to end (non-inclusive). The
Expand Down

0 comments on commit e642fde

Please sign in to comment.