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

Side by Side Diff: src/snapshot/startup-serializer.cc

Issue 1811263002: [serializer] tweak startup serializer for warming up. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix Created 4 years, 9 months 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/api.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/startup-serializer.h" 5 #include "src/snapshot/startup-serializer.h"
6 6
7 #include "src/objects-inl.h" 7 #include "src/objects-inl.h"
8 #include "src/v8threads.h" 8 #include "src/v8threads.h"
9 9
10 namespace v8 { 10 namespace v8 {
11 namespace internal { 11 namespace internal {
12 12
13 StartupSerializer::StartupSerializer( 13 StartupSerializer::StartupSerializer(
14 Isolate* isolate, SnapshotByteSink* sink, 14 Isolate* isolate, SnapshotByteSink* sink,
15 FunctionCodeHandling function_code_handling) 15 FunctionCodeHandling function_code_handling)
16 : Serializer(isolate, sink), 16 : Serializer(isolate, sink),
17 function_code_handling_(function_code_handling), 17 function_code_handling_(function_code_handling),
18 serializing_builtins_(false) { 18 serializing_builtins_(false) {
19 InitializeCodeAddressMap(); 19 InitializeCodeAddressMap();
20 } 20 }
21 21
22 StartupSerializer::~StartupSerializer() { 22 StartupSerializer::~StartupSerializer() {
23 OutputStatistics("StartupSerializer"); 23 OutputStatistics("StartupSerializer");
24 } 24 }
25 25
26 void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code, 26 void StartupSerializer::SerializeObject(HeapObject* obj, HowToCode how_to_code,
27 WhereToPoint where_to_point, int skip) { 27 WhereToPoint where_to_point, int skip) {
28 DCHECK(!obj->IsJSFunction()); 28 DCHECK(!obj->IsJSFunction());
29 29
30 if (obj->IsCode()) { 30 if (function_code_handling_ == CLEAR_FUNCTION_CODE) {
31 if (obj->IsCode()) {
32 Code* code = Code::cast(obj);
33 // If the function code is compiled (either as native code or bytecode),
34 // replace it with lazy-compile builtin. Only exception is when we are
35 // serializing the canonical interpreter-entry-trampoline builtin.
36 if (code->kind() == Code::FUNCTION ||
37 (!serializing_builtins_ && code->is_interpreter_entry_trampoline())) {
38 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
39 }
40 } else if (obj->IsBytecodeArray()) {
41 obj = isolate()->heap()->undefined_value();
42 }
43 } else if (obj->IsCode()) {
44 DCHECK_EQ(KEEP_FUNCTION_CODE, function_code_handling_);
31 Code* code = Code::cast(obj); 45 Code* code = Code::cast(obj);
32 // If the function code is compiled (either as native code or bytecode), 46 if (code->kind() == Code::FUNCTION) {
33 // replace it with lazy-compile builtin. Only exception is when we are 47 code->ClearInlineCaches();
34 // serializing the canonical interpreter-entry-trampoline builtin. 48 code->set_profiler_ticks(0);
35 if (function_code_handling_ == CLEAR_FUNCTION_CODE &&
36 (code->kind() == Code::FUNCTION ||
37 (!serializing_builtins_ && code->is_interpreter_entry_trampoline()))) {
38 obj = isolate()->builtins()->builtin(Builtins::kCompileLazy);
39 } 49 }
40 } else if (obj->IsBytecodeArray()) {
41 obj = isolate()->heap()->undefined_value();
42 } 50 }
43 51
44 int root_index = root_index_map_.Lookup(obj); 52 int root_index = root_index_map_.Lookup(obj);
45 // We can only encode roots as such if it has already been serialized. 53 // We can only encode roots as such if it has already been serialized.
46 // That applies to root indices below the wave front. 54 // That applies to root indices below the wave front.
47 if (root_index != RootIndexMap::kInvalidRootIndex) { 55 if (root_index != RootIndexMap::kInvalidRootIndex) {
48 if (root_has_been_serialized_.test(root_index)) { 56 if (root_has_been_serialized_.test(root_index)) {
49 PutRoot(root_index, obj, how_to_code, where_to_point, skip); 57 PutRoot(root_index, obj, how_to_code, where_to_point, skip);
50 return; 58 return;
51 } 59 }
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 root_index == Heap::kStackLimitRootIndex || 154 root_index == Heap::kStackLimitRootIndex ||
147 root_index == Heap::kRealStackLimitRootIndex) { 155 root_index == Heap::kRealStackLimitRootIndex) {
148 return true; 156 return true;
149 } 157 }
150 return Heap::RootIsImmortalImmovable(root_index) != 158 return Heap::RootIsImmortalImmovable(root_index) !=
151 serializing_immortal_immovables_roots_; 159 serializing_immortal_immovables_roots_;
152 } 160 }
153 161
154 } // namespace internal 162 } // namespace internal
155 } // namespace v8 163 } // namespace v8
OLDNEW
« no previous file with comments | « src/api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698