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

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

Issue 1940283002: [serializer] cache ICs only as code stubs with key. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 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/snapshot/code-serializer.h ('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/code-serializer.h" 5 #include "src/snapshot/code-serializer.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/log.h" 8 #include "src/log.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 #include "src/profiler/cpu-profiler.h" 10 #include "src/profiler/cpu-profiler.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 case Code::HANDLER: // No handlers patched in yet. 66 case Code::HANDLER: // No handlers patched in yet.
67 case Code::REGEXP: // No regexp literals initialized yet. 67 case Code::REGEXP: // No regexp literals initialized yet.
68 case Code::NUMBER_OF_KINDS: // Pseudo enum value. 68 case Code::NUMBER_OF_KINDS: // Pseudo enum value.
69 case Code::BYTECODE_HANDLER: // No direct references to handlers. 69 case Code::BYTECODE_HANDLER: // No direct references to handlers.
70 CHECK(false); 70 CHECK(false);
71 case Code::BUILTIN: 71 case Code::BUILTIN:
72 SerializeBuiltin(code_object->builtin_index(), how_to_code, 72 SerializeBuiltin(code_object->builtin_index(), how_to_code,
73 where_to_point); 73 where_to_point);
74 return; 74 return;
75 case Code::STUB: 75 case Code::STUB:
76 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point);
77 return;
78 #define IC_KIND_CASE(KIND) case Code::KIND: 76 #define IC_KIND_CASE(KIND) case Code::KIND:
79 IC_KIND_LIST(IC_KIND_CASE) 77 IC_KIND_LIST(IC_KIND_CASE)
80 #undef IC_KIND_CASE 78 #undef IC_KIND_CASE
81 SerializeIC(code_object, how_to_code, where_to_point); 79 SerializeCodeStub(code_object->stub_key(), how_to_code, where_to_point);
82 return; 80 return;
83 case Code::FUNCTION: 81 case Code::FUNCTION:
84 DCHECK(code_object->has_reloc_info_for_serialization()); 82 DCHECK(code_object->has_reloc_info_for_serialization());
85 SerializeGeneric(code_object, how_to_code, where_to_point); 83 SerializeGeneric(code_object, how_to_code, where_to_point);
86 return; 84 return;
87 case Code::WASM_FUNCTION: 85 case Code::WASM_FUNCTION:
88 case Code::WASM_TO_JS_FUNCTION: 86 case Code::WASM_TO_JS_FUNCTION:
89 case Code::JS_TO_WASM_FUNCTION: 87 case Code::JS_TO_WASM_FUNCTION:
90 UNREACHABLE(); 88 UNREACHABLE();
91 } 89 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 140
143 if (FLAG_trace_serializer) { 141 if (FLAG_trace_serializer) {
144 PrintF(" Encoding code stub %s as %d\n", 142 PrintF(" Encoding code stub %s as %d\n",
145 CodeStub::MajorName(CodeStub::MajorKeyFromKey(stub_key)), index); 143 CodeStub::MajorName(CodeStub::MajorKeyFromKey(stub_key)), index);
146 } 144 }
147 145
148 sink_->Put(kAttachedReference + how_to_code + where_to_point, "CodeStub"); 146 sink_->Put(kAttachedReference + how_to_code + where_to_point, "CodeStub");
149 sink_->PutInt(index, "CodeStub key"); 147 sink_->PutInt(index, "CodeStub key");
150 } 148 }
151 149
152 void CodeSerializer::SerializeIC(Code* ic, HowToCode how_to_code,
153 WhereToPoint where_to_point) {
154 // The IC may be implemented as a stub.
155 uint32_t stub_key = ic->stub_key();
156 if (stub_key != CodeStub::NoCacheKey()) {
157 if (FLAG_trace_serializer) {
158 PrintF(" %s is a code stub\n", Code::Kind2String(ic->kind()));
159 }
160 SerializeCodeStub(stub_key, how_to_code, where_to_point);
161 return;
162 }
163 // The IC may be implemented as builtin. Only real builtins have an
164 // actual builtin_index value attached (otherwise it's just garbage).
165 // Compare to make sure we are really dealing with a builtin.
166 int builtin_index = ic->builtin_index();
167 if (builtin_index < Builtins::builtin_count) {
168 Builtins::Name name = static_cast<Builtins::Name>(builtin_index);
169 Code* builtin = isolate()->builtins()->builtin(name);
170 if (builtin == ic) {
171 if (FLAG_trace_serializer) {
172 PrintF(" %s is a builtin\n", Code::Kind2String(ic->kind()));
173 }
174 DCHECK(ic->kind() == Code::KEYED_LOAD_IC ||
175 ic->kind() == Code::KEYED_STORE_IC);
176 SerializeBuiltin(builtin_index, how_to_code, where_to_point);
177 return;
178 }
179 }
180 UNREACHABLE();
181 }
182
183 int CodeSerializer::AddCodeStubKey(uint32_t stub_key) { 150 int CodeSerializer::AddCodeStubKey(uint32_t stub_key) {
184 // TODO(yangguo) Maybe we need a hash table for a faster lookup than O(n^2). 151 // TODO(yangguo) Maybe we need a hash table for a faster lookup than O(n^2).
185 int index = 0; 152 int index = 0;
186 while (index < stub_keys_.length()) { 153 while (index < stub_keys_.length()) {
187 if (stub_keys_[index] == stub_key) return index; 154 if (stub_keys_[index] == stub_key) return index;
188 index++; 155 index++;
189 } 156 }
190 stub_keys_.Add(stub_key); 157 stub_keys_.Add(stub_key);
191 return index; 158 return index;
192 } 159 }
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 SanityCheckResult r = scd->SanityCheck(isolate, source); 373 SanityCheckResult r = scd->SanityCheck(isolate, source);
407 if (r == CHECK_SUCCESS) return scd; 374 if (r == CHECK_SUCCESS) return scd;
408 cached_data->Reject(); 375 cached_data->Reject();
409 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r); 376 source->GetIsolate()->counters()->code_cache_reject_reason()->AddSample(r);
410 delete scd; 377 delete scd;
411 return NULL; 378 return NULL;
412 } 379 }
413 380
414 } // namespace internal 381 } // namespace internal
415 } // namespace v8 382 } // namespace v8
OLDNEW
« no previous file with comments | « src/snapshot/code-serializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698