OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/snapshot/deserializer.h" | 5 #include "src/snapshot/deserializer.h" |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/external-reference-table.h" | 8 #include "src/external-reference-table.h" |
9 #include "src/heap/heap.h" | 9 #include "src/heap/heap.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
(...skipping 19 matching lines...) Expand all Loading... | |
30 | 30 |
31 void Deserializer::FlushICacheForNewIsolate() { | 31 void Deserializer::FlushICacheForNewIsolate() { |
32 DCHECK(!deserializing_user_code_); | 32 DCHECK(!deserializing_user_code_); |
33 // The entire isolate is newly deserialized. Simply flush all code pages. | 33 // The entire isolate is newly deserialized. Simply flush all code pages. |
34 for (Page* p : *isolate_->heap()->code_space()) { | 34 for (Page* p : *isolate_->heap()->code_space()) { |
35 Assembler::FlushICache(isolate_, p->area_start(), | 35 Assembler::FlushICache(isolate_, p->area_start(), |
36 p->area_end() - p->area_start()); | 36 p->area_end() - p->area_start()); |
37 } | 37 } |
38 } | 38 } |
39 | 39 |
40 void Deserializer::FlushICacheForNewCodeObjects() { | 40 void Deserializer::FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects() { |
41 DCHECK(deserializing_user_code_); | 41 DCHECK(deserializing_user_code_); |
42 for (Code* code : new_code_objects_) { | 42 for (Code* code : new_code_objects_) { |
43 // Record all references to embedded objects in the new code object. | |
44 for (RelocIterator it(code, | |
45 RelocInfo::ModeMask(RelocInfo::EMBEDDED_OBJECT)); | |
46 !it.done(); it.next()) { | |
47 isolate_->heap()->RecordWriteIntoCode(code, it.rinfo(), | |
Yang
2016/08/03 12:29:52
This entire for loop is duplicate code from CopyCo
ahaas
2016/08/04 08:54:11
Done.
| |
48 it.rinfo()->target_object()); | |
49 } | |
50 | |
43 if (FLAG_serialize_age_code) code->PreAge(isolate_); | 51 if (FLAG_serialize_age_code) code->PreAge(isolate_); |
44 Assembler::FlushICache(isolate_, code->instruction_start(), | 52 Assembler::FlushICache(isolate_, code->instruction_start(), |
45 code->instruction_size()); | 53 code->instruction_size()); |
46 } | 54 } |
47 } | 55 } |
48 | 56 |
49 bool Deserializer::ReserveSpace() { | 57 bool Deserializer::ReserveSpace() { |
50 #ifdef DEBUG | 58 #ifdef DEBUG |
51 for (int i = NEW_SPACE; i < kNumberOfSpaces; ++i) { | 59 for (int i = NEW_SPACE; i < kNumberOfSpaces; ++i) { |
52 CHECK(reservations_[i].length() > 0); | 60 CHECK(reservations_[i].length() > 0); |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
140 return Handle<SharedFunctionInfo>(); | 148 return Handle<SharedFunctionInfo>(); |
141 } else { | 149 } else { |
142 deserializing_user_code_ = true; | 150 deserializing_user_code_ = true; |
143 HandleScope scope(isolate); | 151 HandleScope scope(isolate); |
144 Handle<SharedFunctionInfo> result; | 152 Handle<SharedFunctionInfo> result; |
145 { | 153 { |
146 DisallowHeapAllocation no_gc; | 154 DisallowHeapAllocation no_gc; |
147 Object* root; | 155 Object* root; |
148 VisitPointer(&root); | 156 VisitPointer(&root); |
149 DeserializeDeferredObjects(); | 157 DeserializeDeferredObjects(); |
150 FlushICacheForNewCodeObjects(); | 158 FlushICacheForNewCodeObjectsAndRecordEmbeddedObjects(); |
151 result = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root)); | 159 result = Handle<SharedFunctionInfo>(SharedFunctionInfo::cast(root)); |
152 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); | 160 isolate->heap()->RegisterReservationsForBlackAllocation(reservations_); |
153 } | 161 } |
154 CommitPostProcessedObjects(isolate); | 162 CommitPostProcessedObjects(isolate); |
155 return scope.CloseAndEscape(result); | 163 return scope.CloseAndEscape(result); |
156 } | 164 } |
157 } | 165 } |
158 | 166 |
159 Deserializer::~Deserializer() { | 167 Deserializer::~Deserializer() { |
160 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. | 168 // TODO(svenpanne) Re-enable this assertion when v8 initialization is fixed. |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
806 | 814 |
807 default: | 815 default: |
808 CHECK(false); | 816 CHECK(false); |
809 } | 817 } |
810 } | 818 } |
811 CHECK_EQ(limit, current); | 819 CHECK_EQ(limit, current); |
812 return true; | 820 return true; |
813 } | 821 } |
814 } // namespace internal | 822 } // namespace internal |
815 } // namespace v8 | 823 } // namespace v8 |
OLD | NEW |