| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
| 8 #include "src/api.h" | 8 #include "src/api.h" |
| 9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
| 10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 isolate_->heap()->code_stub_context()); | 563 isolate_->heap()->code_stub_context()); |
| 564 | 564 |
| 565 // The allocation site list is build during root iteration, but if no sites | 565 // The allocation site list is build during root iteration, but if no sites |
| 566 // were encountered then it needs to be initialized to undefined. | 566 // were encountered then it needs to be initialized to undefined. |
| 567 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) { | 567 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) { |
| 568 isolate_->heap()->set_allocation_sites_list( | 568 isolate_->heap()->set_allocation_sites_list( |
| 569 isolate_->heap()->undefined_value()); | 569 isolate_->heap()->undefined_value()); |
| 570 } | 570 } |
| 571 | 571 |
| 572 // Update data pointers to the external strings containing natives sources. | 572 // Update data pointers to the external strings containing natives sources. |
| 573 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { | 573 Natives::UpdateSourceCache(isolate_->heap()); |
| 574 Object* source = isolate_->heap()->natives_source_cache()->get(i); | 574 ExtraNatives::UpdateSourceCache(isolate_->heap()); |
| 575 if (!source->IsUndefined()) { | 575 CodeStubNatives::UpdateSourceCache(isolate_->heap()); |
| 576 ExternalOneByteString::cast(source)->update_data_cache(); | |
| 577 } | |
| 578 } | |
| 579 | |
| 580 for (int i = 0; i < CodeStubNatives::GetBuiltinsCount(); i++) { | |
| 581 Object* source = isolate_->heap()->code_stub_natives_source_cache()->get(i); | |
| 582 if (!source->IsUndefined()) { | |
| 583 ExternalOneByteString::cast(source)->update_data_cache(); | |
| 584 } | |
| 585 } | |
| 586 | 576 |
| 587 FlushICacheForNewCodeObjects(); | 577 FlushICacheForNewCodeObjects(); |
| 588 | 578 |
| 589 // Issue code events for newly deserialized code objects. | 579 // Issue code events for newly deserialized code objects. |
| 590 LOG_CODE_EVENT(isolate_, LogCodeObjects()); | 580 LOG_CODE_EVENT(isolate_, LogCodeObjects()); |
| 591 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); | 581 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); |
| 592 } | 582 } |
| 593 | 583 |
| 594 | 584 |
| 595 MaybeHandle<Object> Deserializer::DeserializePartial( | 585 MaybeHandle<Object> Deserializer::DeserializePartial( |
| (...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1174 // If we get here then that indicates that you have a mismatch between | 1164 // If we get here then that indicates that you have a mismatch between |
| 1175 // the number of GC roots when serializing and deserializing. | 1165 // the number of GC roots when serializing and deserializing. |
| 1176 CHECK(false); | 1166 CHECK(false); |
| 1177 break; | 1167 break; |
| 1178 | 1168 |
| 1179 case kNativesStringResource: | 1169 case kNativesStringResource: |
| 1180 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), | 1170 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), |
| 1181 current); | 1171 current); |
| 1182 break; | 1172 break; |
| 1183 | 1173 |
| 1174 case kExtraNativesStringResource: |
| 1175 current = CopyInNativesSource( |
| 1176 ExtraNatives::GetScriptSource(source_.Get()), current); |
| 1177 break; |
| 1178 |
| 1184 case kCodeStubNativesStringResource: | 1179 case kCodeStubNativesStringResource: |
| 1185 current = CopyInNativesSource( | 1180 current = CopyInNativesSource( |
| 1186 CodeStubNatives::GetScriptSource(source_.Get()), current); | 1181 CodeStubNatives::GetScriptSource(source_.Get()), current); |
| 1187 break; | 1182 break; |
| 1188 | 1183 |
| 1189 // Deserialize raw data of variable length. | 1184 // Deserialize raw data of variable length. |
| 1190 case kVariableRawData: { | 1185 case kVariableRawData: { |
| 1191 int size_in_bytes = source_.GetInt(); | 1186 int size_in_bytes = source_.GetInt(); |
| 1192 byte* raw_data_out = reinterpret_cast<byte*>(current); | 1187 byte* raw_data_out = reinterpret_cast<byte*>(current); |
| 1193 source_.CopyRaw(raw_data_out, size_in_bytes); | 1188 source_.CopyRaw(raw_data_out, size_in_bytes); |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 return false; | 2175 return false; |
| 2181 } | 2176 } |
| 2182 | 2177 |
| 2183 | 2178 |
| 2184 void Serializer::ObjectSerializer::VisitExternalOneByteString( | 2179 void Serializer::ObjectSerializer::VisitExternalOneByteString( |
| 2185 v8::String::ExternalOneByteStringResource** resource_pointer) { | 2180 v8::String::ExternalOneByteStringResource** resource_pointer) { |
| 2186 Address references_start = reinterpret_cast<Address>(resource_pointer); | 2181 Address references_start = reinterpret_cast<Address>(resource_pointer); |
| 2187 OutputRawData(references_start); | 2182 OutputRawData(references_start); |
| 2188 if (SerializeExternalNativeSourceString( | 2183 if (SerializeExternalNativeSourceString( |
| 2189 Natives::GetBuiltinsCount(), resource_pointer, | 2184 Natives::GetBuiltinsCount(), resource_pointer, |
| 2190 serializer_->isolate()->heap()->natives_source_cache(), | 2185 Natives::GetSourceCache(serializer_->isolate()->heap()), |
| 2191 kNativesStringResource)) { | 2186 kNativesStringResource)) { |
| 2192 return; | 2187 return; |
| 2193 } | 2188 } |
| 2194 if (SerializeExternalNativeSourceString( | 2189 if (SerializeExternalNativeSourceString( |
| 2190 ExtraNatives::GetBuiltinsCount(), resource_pointer, |
| 2191 ExtraNatives::GetSourceCache(serializer_->isolate()->heap()), |
| 2192 kExtraNativesStringResource)) { |
| 2193 return; |
| 2194 } |
| 2195 if (SerializeExternalNativeSourceString( |
| 2195 CodeStubNatives::GetBuiltinsCount(), resource_pointer, | 2196 CodeStubNatives::GetBuiltinsCount(), resource_pointer, |
| 2196 serializer_->isolate()->heap()->code_stub_natives_source_cache(), | 2197 CodeStubNatives::GetSourceCache(serializer_->isolate()->heap()), |
| 2197 kCodeStubNativesStringResource)) { | 2198 kCodeStubNativesStringResource)) { |
| 2198 return; | 2199 return; |
| 2199 } | 2200 } |
| 2200 // One of the strings in the natives cache should match the resource. We | 2201 // One of the strings in the natives cache should match the resource. We |
| 2201 // don't expect any other kinds of external strings here. | 2202 // don't expect any other kinds of external strings here. |
| 2202 UNREACHABLE(); | 2203 UNREACHABLE(); |
| 2203 } | 2204 } |
| 2204 | 2205 |
| 2205 | 2206 |
| 2206 Address Serializer::ObjectSerializer::PrepareCode() { | 2207 Address Serializer::ObjectSerializer::PrepareCode() { |
| (...skipping 593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2800 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2801 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
| 2801 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2802 SanityCheckResult r = scd->SanityCheck(isolate, source); |
| 2802 if (r == CHECK_SUCCESS) return scd; | 2803 if (r == CHECK_SUCCESS) return scd; |
| 2803 cached_data->Reject(); | 2804 cached_data->Reject(); |
| 2804 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2805 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
| 2805 delete scd; | 2806 delete scd; |
| 2806 return NULL; | 2807 return NULL; |
| 2807 } | 2808 } |
| 2808 } // namespace internal | 2809 } // namespace internal |
| 2809 } // namespace v8 | 2810 } // namespace v8 |
| OLD | NEW |