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 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 for (int i = 0; i < Natives::GetBuiltinsCount(); i++) { |
574 Object* source = isolate_->heap()->natives_source_cache()->get(i); | 574 Object* source = isolate_->heap()->natives_source_cache()->get(i); |
575 if (!source->IsUndefined()) { | 575 if (!source->IsUndefined()) { |
576 ExternalOneByteString::cast(source)->update_data_cache(); | 576 ExternalOneByteString::cast(source)->update_data_cache(); |
577 } | 577 } |
578 } | 578 } |
579 | 579 |
580 for (int i = 0; i < ExtraNatives::GetBuiltinsCount(); i++) { | |
581 Object* source = isolate_->heap()->extra_natives_source_cache()->get(i); | |
Yang
2015/08/13 12:28:24
now that we have this code three times, can we tem
| |
582 if (!source->IsUndefined()) { | |
583 ExternalOneByteString::cast(source)->update_data_cache(); | |
584 } | |
585 } | |
586 | |
580 for (int i = 0; i < CodeStubNatives::GetBuiltinsCount(); i++) { | 587 for (int i = 0; i < CodeStubNatives::GetBuiltinsCount(); i++) { |
581 Object* source = isolate_->heap()->code_stub_natives_source_cache()->get(i); | 588 Object* source = isolate_->heap()->code_stub_natives_source_cache()->get(i); |
582 if (!source->IsUndefined()) { | 589 if (!source->IsUndefined()) { |
583 ExternalOneByteString::cast(source)->update_data_cache(); | 590 ExternalOneByteString::cast(source)->update_data_cache(); |
584 } | 591 } |
585 } | 592 } |
586 | 593 |
587 FlushICacheForNewCodeObjects(); | 594 FlushICacheForNewCodeObjects(); |
588 | 595 |
589 // Issue code events for newly deserialized code objects. | 596 // Issue code events for newly deserialized code objects. |
(...skipping 584 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 | 1181 // If we get here then that indicates that you have a mismatch between |
1175 // the number of GC roots when serializing and deserializing. | 1182 // the number of GC roots when serializing and deserializing. |
1176 CHECK(false); | 1183 CHECK(false); |
1177 break; | 1184 break; |
1178 | 1185 |
1179 case kNativesStringResource: | 1186 case kNativesStringResource: |
1180 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), | 1187 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), |
1181 current); | 1188 current); |
1182 break; | 1189 break; |
1183 | 1190 |
1191 case kExtraNativesStringResource: | |
1192 current = CopyInNativesSource( | |
1193 ExtraNatives::GetScriptSource(source_.Get()), current); | |
1194 break; | |
1195 | |
1184 case kCodeStubNativesStringResource: | 1196 case kCodeStubNativesStringResource: |
1185 current = CopyInNativesSource( | 1197 current = CopyInNativesSource( |
1186 CodeStubNatives::GetScriptSource(source_.Get()), current); | 1198 CodeStubNatives::GetScriptSource(source_.Get()), current); |
1187 break; | 1199 break; |
1188 | 1200 |
1189 // Deserialize raw data of variable length. | 1201 // Deserialize raw data of variable length. |
1190 case kVariableRawData: { | 1202 case kVariableRawData: { |
1191 int size_in_bytes = source_.GetInt(); | 1203 int size_in_bytes = source_.GetInt(); |
1192 byte* raw_data_out = reinterpret_cast<byte*>(current); | 1204 byte* raw_data_out = reinterpret_cast<byte*>(current); |
1193 source_.CopyRaw(raw_data_out, size_in_bytes); | 1205 source_.CopyRaw(raw_data_out, size_in_bytes); |
(...skipping 991 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2185 v8::String::ExternalOneByteStringResource** resource_pointer) { | 2197 v8::String::ExternalOneByteStringResource** resource_pointer) { |
2186 Address references_start = reinterpret_cast<Address>(resource_pointer); | 2198 Address references_start = reinterpret_cast<Address>(resource_pointer); |
2187 OutputRawData(references_start); | 2199 OutputRawData(references_start); |
2188 if (SerializeExternalNativeSourceString( | 2200 if (SerializeExternalNativeSourceString( |
2189 Natives::GetBuiltinsCount(), resource_pointer, | 2201 Natives::GetBuiltinsCount(), resource_pointer, |
2190 serializer_->isolate()->heap()->natives_source_cache(), | 2202 serializer_->isolate()->heap()->natives_source_cache(), |
2191 kNativesStringResource)) { | 2203 kNativesStringResource)) { |
2192 return; | 2204 return; |
2193 } | 2205 } |
2194 if (SerializeExternalNativeSourceString( | 2206 if (SerializeExternalNativeSourceString( |
2207 ExtraNatives::GetBuiltinsCount(), resource_pointer, | |
2208 serializer_->isolate()->heap()->extra_natives_source_cache(), | |
Yang
2015/08/13 12:28:24
We can then also replace the third argument with E
| |
2209 kExtraNativesStringResource)) { | |
2210 return; | |
2211 } | |
2212 if (SerializeExternalNativeSourceString( | |
2195 CodeStubNatives::GetBuiltinsCount(), resource_pointer, | 2213 CodeStubNatives::GetBuiltinsCount(), resource_pointer, |
2196 serializer_->isolate()->heap()->code_stub_natives_source_cache(), | 2214 serializer_->isolate()->heap()->code_stub_natives_source_cache(), |
2197 kCodeStubNativesStringResource)) { | 2215 kCodeStubNativesStringResource)) { |
2198 return; | 2216 return; |
2199 } | 2217 } |
2200 // One of the strings in the natives cache should match the resource. We | 2218 // One of the strings in the natives cache should match the resource. We |
2201 // don't expect any other kinds of external strings here. | 2219 // don't expect any other kinds of external strings here. |
2202 UNREACHABLE(); | 2220 UNREACHABLE(); |
2203 } | 2221 } |
2204 | 2222 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2800 SerializedCodeData* scd = new SerializedCodeData(cached_data); | 2818 SerializedCodeData* scd = new SerializedCodeData(cached_data); |
2801 SanityCheckResult r = scd->SanityCheck(isolate, source); | 2819 SanityCheckResult r = scd->SanityCheck(isolate, source); |
2802 if (r == CHECK_SUCCESS) return scd; | 2820 if (r == CHECK_SUCCESS) return scd; |
2803 cached_data->Reject(); | 2821 cached_data->Reject(); |
2804 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); | 2822 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); |
2805 delete scd; | 2823 delete scd; |
2806 return NULL; | 2824 return NULL; |
2807 } | 2825 } |
2808 } // namespace internal | 2826 } // namespace internal |
2809 } // namespace v8 | 2827 } // namespace v8 |
OLD | NEW |