Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(104)

Side by Side Diff: src/snapshot/serialize.cc

Issue 1475953002: [stubs] A new approach to TF stubs (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix Win64 build Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/snapshot/serialize.h ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/snapshot/serialize.h" 5 #include "src/snapshot/serialize.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 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 DisallowHeapAllocation no_gc; 533 DisallowHeapAllocation no_gc;
534 isolate_->heap()->IterateSmiRoots(this); 534 isolate_->heap()->IterateSmiRoots(this);
535 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG); 535 isolate_->heap()->IterateStrongRoots(this, VISIT_ONLY_STRONG);
536 isolate_->heap()->RepairFreeListsAfterDeserialization(); 536 isolate_->heap()->RepairFreeListsAfterDeserialization();
537 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL); 537 isolate_->heap()->IterateWeakRoots(this, VISIT_ALL);
538 DeserializeDeferredObjects(); 538 DeserializeDeferredObjects();
539 FlushICacheForNewIsolate(); 539 FlushICacheForNewIsolate();
540 } 540 }
541 541
542 isolate_->heap()->set_native_contexts_list( 542 isolate_->heap()->set_native_contexts_list(
543 isolate_->heap()->code_stub_context()); 543 isolate_->heap()->undefined_value());
544
545 // The allocation site list is build during root iteration, but if no sites 544 // The allocation site list is build during root iteration, but if no sites
546 // were encountered then it needs to be initialized to undefined. 545 // were encountered then it needs to be initialized to undefined.
547 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) { 546 if (isolate_->heap()->allocation_sites_list() == Smi::FromInt(0)) {
548 isolate_->heap()->set_allocation_sites_list( 547 isolate_->heap()->set_allocation_sites_list(
549 isolate_->heap()->undefined_value()); 548 isolate_->heap()->undefined_value());
550 } 549 }
551 550
552 // Update data pointers to the external strings containing natives sources. 551 // Update data pointers to the external strings containing natives sources.
553 Natives::UpdateSourceCache(isolate_->heap()); 552 Natives::UpdateSourceCache(isolate_->heap());
554 ExtraNatives::UpdateSourceCache(isolate_->heap()); 553 ExtraNatives::UpdateSourceCache(isolate_->heap());
555 CodeStubNatives::UpdateSourceCache(isolate_->heap());
556 554
557 // Issue code events for newly deserialized code objects. 555 // Issue code events for newly deserialized code objects.
558 LOG_CODE_EVENT(isolate_, LogCodeObjects()); 556 LOG_CODE_EVENT(isolate_, LogCodeObjects());
559 LOG_CODE_EVENT(isolate_, LogCompiledFunctions()); 557 LOG_CODE_EVENT(isolate_, LogCompiledFunctions());
560 } 558 }
561 559
562 560
563 MaybeHandle<Object> Deserializer::DeserializePartial( 561 MaybeHandle<Object> Deserializer::DeserializePartial(
564 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) { 562 Isolate* isolate, Handle<JSGlobalProxy> global_proxy) {
565 Initialize(isolate); 563 Initialize(isolate);
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 case kNativesStringResource: 1159 case kNativesStringResource:
1162 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()), 1160 current = CopyInNativesSource(Natives::GetScriptSource(source_.Get()),
1163 current); 1161 current);
1164 break; 1162 break;
1165 1163
1166 case kExtraNativesStringResource: 1164 case kExtraNativesStringResource:
1167 current = CopyInNativesSource( 1165 current = CopyInNativesSource(
1168 ExtraNatives::GetScriptSource(source_.Get()), current); 1166 ExtraNatives::GetScriptSource(source_.Get()), current);
1169 break; 1167 break;
1170 1168
1171 case kCodeStubNativesStringResource:
1172 current = CopyInNativesSource(
1173 CodeStubNatives::GetScriptSource(source_.Get()), current);
1174 break;
1175
1176 // Deserialize raw data of variable length. 1169 // Deserialize raw data of variable length.
1177 case kVariableRawData: { 1170 case kVariableRawData: {
1178 int size_in_bytes = source_.GetInt(); 1171 int size_in_bytes = source_.GetInt();
1179 byte* raw_data_out = reinterpret_cast<byte*>(current); 1172 byte* raw_data_out = reinterpret_cast<byte*>(current);
1180 source_.CopyRaw(raw_data_out, size_in_bytes); 1173 source_.CopyRaw(raw_data_out, size_in_bytes);
1181 break; 1174 break;
1182 } 1175 }
1183 1176
1184 case kVariableRepeat: { 1177 case kVariableRepeat: {
1185 int repeats = source_.GetInt(); 1178 int repeats = source_.GetInt();
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 // strong roots have been serialized we can create a partial snapshot 1665 // strong roots have been serialized we can create a partial snapshot
1673 // which will repopulate the cache with objects needed by that partial 1666 // which will repopulate the cache with objects needed by that partial
1674 // snapshot. 1667 // snapshot.
1675 isolate->partial_snapshot_cache()->Clear(); 1668 isolate->partial_snapshot_cache()->Clear();
1676 InitializeCodeAddressMap(); 1669 InitializeCodeAddressMap();
1677 } 1670 }
1678 1671
1679 1672
1680 void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, 1673 void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
1681 WhereToPoint where_to_point, int skip) { 1674 WhereToPoint where_to_point, int skip) {
1682 // Make sure that all functions are derived from the code-stub context 1675 DCHECK(!obj->IsJSFunction());
1683 DCHECK(!obj->IsJSFunction() ||
1684 JSFunction::cast(obj)->GetCreationContext() ==
1685 isolate()->heap()->code_stub_context());
1686 1676
1687 int root_index = root_index_map_.Lookup(obj); 1677 int root_index = root_index_map_.Lookup(obj);
1688 // We can only encode roots as such if it has already been serialized. 1678 // We can only encode roots as such if it has already been serialized.
1689 // That applies to root indices below the wave front. 1679 // That applies to root indices below the wave front.
1690 if (root_index != RootIndexMap::kInvalidRootIndex && 1680 if (root_index != RootIndexMap::kInvalidRootIndex &&
1691 root_index < root_index_wave_front_) { 1681 root_index < root_index_wave_front_) {
1692 PutRoot(root_index, obj, how_to_code, where_to_point, skip); 1682 PutRoot(root_index, obj, how_to_code, where_to_point, skip);
1693 return; 1683 return;
1694 } 1684 }
1695 1685
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
2200 Natives::GetSourceCache(serializer_->isolate()->heap()), 2190 Natives::GetSourceCache(serializer_->isolate()->heap()),
2201 kNativesStringResource)) { 2191 kNativesStringResource)) {
2202 return; 2192 return;
2203 } 2193 }
2204 if (SerializeExternalNativeSourceString( 2194 if (SerializeExternalNativeSourceString(
2205 ExtraNatives::GetBuiltinsCount(), resource_pointer, 2195 ExtraNatives::GetBuiltinsCount(), resource_pointer,
2206 ExtraNatives::GetSourceCache(serializer_->isolate()->heap()), 2196 ExtraNatives::GetSourceCache(serializer_->isolate()->heap()),
2207 kExtraNativesStringResource)) { 2197 kExtraNativesStringResource)) {
2208 return; 2198 return;
2209 } 2199 }
2210 if (SerializeExternalNativeSourceString(
2211 CodeStubNatives::GetBuiltinsCount(), resource_pointer,
2212 CodeStubNatives::GetSourceCache(serializer_->isolate()->heap()),
2213 kCodeStubNativesStringResource)) {
2214 return;
2215 }
2216 // One of the strings in the natives cache should match the resource. We 2200 // One of the strings in the natives cache should match the resource. We
2217 // don't expect any other kinds of external strings here. 2201 // don't expect any other kinds of external strings here.
2218 UNREACHABLE(); 2202 UNREACHABLE();
2219 } 2203 }
2220 2204
2221 2205
2222 Address Serializer::ObjectSerializer::PrepareCode() { 2206 Address Serializer::ObjectSerializer::PrepareCode() {
2223 // To make snapshots reproducible, we make a copy of the code object 2207 // To make snapshots reproducible, we make a copy of the code object
2224 // and wipe all pointers in the copy, which we then serialize. 2208 // and wipe all pointers in the copy, which we then serialize.
2225 Code* original = Code::cast(object_); 2209 Code* original = Code::cast(object_);
(...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after
2814 SerializedCodeData* scd = new SerializedCodeData(cached_data); 2798 SerializedCodeData* scd = new SerializedCodeData(cached_data);
2815 SanityCheckResult r = scd->SanityCheck(isolate, source); 2799 SanityCheckResult r = scd->SanityCheck(isolate, source);
2816 if (r == CHECK_SUCCESS) return scd; 2800 if (r == CHECK_SUCCESS) return scd;
2817 cached_data->Reject(); 2801 cached_data->Reject();
2818 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 2802 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
2819 delete scd; 2803 delete scd;
2820 return NULL; 2804 return NULL;
2821 } 2805 }
2822 } // namespace internal 2806 } // namespace internal
2823 } // namespace v8 2807 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/serialize.h ('k') | src/x64/interface-descriptors-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698