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

Side by Side Diff: src/ic/ic-compiler.cc

Issue 1326483002: Vector ICs: Adapting store ic classes for vectors. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE and comment. Created 5 years, 3 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/ic/ic-compiler.h ('k') | src/type-feedback-vector.h » ('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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ic/ic-compiler.h" 5 #include "src/ic/ic-compiler.h"
6 6
7 #include "src/cpu-profiler.h" 7 #include "src/cpu-profiler.h"
8 #include "src/ic/handler-compiler.h" 8 #include "src/ic/handler-compiler.h"
9 #include "src/ic/ic-inl.h" 9 #include "src/ic/ic-inl.h"
10 10
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 stub = LoadFastElementStub(isolate, is_js_array, elements_kind, 112 stub = LoadFastElementStub(isolate, is_js_array, elements_kind,
113 convert_hole_to_undefined).GetCode(); 113 convert_hole_to_undefined).GetCode();
114 } else { 114 } else {
115 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state)) 115 stub = LoadDictionaryElementStub(isolate, LoadICState(extra_ic_state))
116 .GetCode(); 116 .GetCode();
117 } 117 }
118 return stub; 118 return stub;
119 } 119 }
120 120
121 121
122 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphicHandler(
123 Handle<Map> receiver_map, LanguageMode language_mode,
124 KeyedAccessStoreMode store_mode) {
125 Isolate* isolate = receiver_map->GetIsolate();
126 ExtraICState extra_state =
127 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
128
129 DCHECK(store_mode == STANDARD_STORE ||
130 store_mode == STORE_AND_GROW_NO_TRANSITION ||
131 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
132 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
133
134 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
135 Handle<Code> code =
136 compiler.CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode);
137 return code;
138 }
139
140
122 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( 141 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic(
123 Handle<Map> receiver_map, LanguageMode language_mode, 142 Handle<Map> receiver_map, LanguageMode language_mode,
124 KeyedAccessStoreMode store_mode) { 143 KeyedAccessStoreMode store_mode) {
125 Isolate* isolate = receiver_map->GetIsolate(); 144 Isolate* isolate = receiver_map->GetIsolate();
126 ExtraICState extra_state = 145 ExtraICState extra_state =
127 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode); 146 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
128 Code::Flags flags = 147 Code::Flags flags =
129 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, extra_state); 148 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, extra_state);
130 149
131 DCHECK(store_mode == STANDARD_STORE || 150 DCHECK(store_mode == STANDARD_STORE ||
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 Handle<Code> ic = stub->GetCodeCopy(pattern); 232 Handle<Code> ic = stub->GetCodeCopy(pattern);
214 233
215 if (!receiver_map->is_dictionary_map()) { 234 if (!receiver_map->is_dictionary_map()) {
216 Map::UpdateCodeCache(receiver_map, name, ic); 235 Map::UpdateCodeCache(receiver_map, name, ic);
217 } 236 }
218 237
219 return ic; 238 return ic;
220 } 239 }
221 240
222 241
223 Handle<Code> PropertyICCompiler::ComputeKeyedLoadPolymorphic(
224 MapHandleList* receiver_maps, LanguageMode language_mode) {
225 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
226 DCHECK(KeyedLoadIC::GetKeyType(kNoExtraICState) == ELEMENT);
227 Code::Flags flags = Code::ComputeFlags(Code::KEYED_LOAD_IC, POLYMORPHIC);
228 Handle<PolymorphicCodeCache> cache =
229 isolate->factory()->polymorphic_code_cache();
230 Handle<Object> probe = cache->Lookup(receiver_maps, flags);
231 if (probe->IsCode()) return Handle<Code>::cast(probe);
232
233 CodeHandleList handlers(receiver_maps->length());
234 ElementHandlerCompiler compiler(isolate);
235 compiler.CompileElementHandlers(receiver_maps, &handlers, language_mode);
236 PropertyICCompiler ic_compiler(isolate, Code::KEYED_LOAD_IC);
237 Handle<Code> code = ic_compiler.CompilePolymorphic(
238 receiver_maps, &handlers, isolate->factory()->empty_string(),
239 Code::NORMAL, ELEMENT);
240
241 isolate->counters()->keyed_load_polymorphic_stubs()->Increment();
242
243 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code);
244 return code;
245 }
246
247
248 Handle<Code> PropertyICCompiler::ComputePolymorphic( 242 Handle<Code> PropertyICCompiler::ComputePolymorphic(
249 Code::Kind kind, MapHandleList* maps, CodeHandleList* handlers, 243 Code::Kind kind, MapHandleList* maps, CodeHandleList* handlers,
250 int valid_maps, Handle<Name> name, ExtraICState extra_ic_state) { 244 int valid_maps, Handle<Name> name, ExtraICState extra_ic_state) {
251 Handle<Code> handler = handlers->at(0); 245 Handle<Code> handler = handlers->at(0);
252 Code::StubType type = valid_maps == 1 ? handler->type() : Code::NORMAL; 246 Code::StubType type = valid_maps == 1 ? handler->type() : Code::NORMAL;
253 DCHECK(kind == Code::LOAD_IC || kind == Code::STORE_IC); 247 DCHECK(kind == Code::LOAD_IC || kind == Code::STORE_IC);
254 PropertyICCompiler ic_compiler(name->GetIsolate(), kind, extra_ic_state); 248 PropertyICCompiler ic_compiler(name->GetIsolate(), kind, extra_ic_state);
255 return ic_compiler.CompilePolymorphic(maps, handlers, name, type, PROPERTY); 249 return ic_compiler.CompilePolymorphic(maps, handlers, name, type, PROPERTY);
256 } 250 }
257 251
258 252
253 void PropertyICCompiler::ComputeKeyedStorePolymorphicHandlers(
254 MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
255 CodeHandleList* handlers, KeyedAccessStoreMode store_mode,
256 LanguageMode language_mode) {
257 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
258 DCHECK(store_mode == STANDARD_STORE ||
259 store_mode == STORE_AND_GROW_NO_TRANSITION ||
260 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
261 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
262 ExtraICState extra_state =
263 KeyedStoreIC::ComputeExtraICState(language_mode, store_mode);
264 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state);
265 compiler.CompileKeyedStorePolymorphicHandlers(
266 receiver_maps, transitioned_maps, handlers, store_mode);
267 }
268
269
259 Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic( 270 Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic(
260 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode, 271 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode,
261 LanguageMode language_mode) { 272 LanguageMode language_mode) {
262 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); 273 Isolate* isolate = receiver_maps->at(0)->GetIsolate();
263 DCHECK(store_mode == STANDARD_STORE || 274 DCHECK(store_mode == STANDARD_STORE ||
264 store_mode == STORE_AND_GROW_NO_TRANSITION || 275 store_mode == STORE_AND_GROW_NO_TRANSITION ||
265 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || 276 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS ||
266 store_mode == STORE_NO_TRANSITION_HANDLE_COW); 277 store_mode == STORE_NO_TRANSITION_HANDLE_COW);
267 Handle<PolymorphicCodeCache> cache = 278 Handle<PolymorphicCodeCache> cache =
268 isolate->factory()->polymorphic_code_cache(); 279 isolate->factory()->polymorphic_code_cache();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder()); 342 Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder());
332 Handle<Code> code = GetCodeWithFlags(flags, name); 343 Handle<Code> code = GetCodeWithFlags(flags, name);
333 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name)); 344 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, *name));
334 #ifdef DEBUG 345 #ifdef DEBUG
335 code->VerifyEmbeddedObjects(); 346 code->VerifyEmbeddedObjects();
336 #endif 347 #endif
337 return code; 348 return code;
338 } 349 }
339 350
340 351
341 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( 352 void PropertyICCompiler::CompileKeyedStorePolymorphicHandlers(
342 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode) { 353 MapHandleList* receiver_maps, MapHandleList* transitioned_maps,
343 // Collect MONOMORPHIC stubs for all |receiver_maps|. 354 CodeHandleList* handlers, KeyedAccessStoreMode store_mode) {
344 CodeHandleList handlers(receiver_maps->length());
345 MapHandleList transitioned_maps(receiver_maps->length());
346 for (int i = 0; i < receiver_maps->length(); ++i) { 355 for (int i = 0; i < receiver_maps->length(); ++i) {
347 Handle<Map> receiver_map(receiver_maps->at(i)); 356 Handle<Map> receiver_map(receiver_maps->at(i));
348 Handle<Code> cached_stub; 357 Handle<Code> cached_stub;
349 Handle<Map> transitioned_map = 358 Handle<Map> transitioned_map =
350 Map::FindTransitionedMap(receiver_map, receiver_maps); 359 Map::FindTransitionedMap(receiver_map, receiver_maps);
351 360
352 // TODO(mvstanton): The code below is doing pessimistic elements 361 // TODO(mvstanton): The code below is doing pessimistic elements
353 // transitions. I would like to stop doing that and rely on Allocation Site 362 // transitions. I would like to stop doing that and rely on Allocation Site
354 // Tracking to do a better job of ensuring the data types are what they need 363 // Tracking to do a better job of ensuring the data types are what they need
355 // to be. Not all the elements are in place yet, pessimistic elements 364 // to be. Not all the elements are in place yet, pessimistic elements
(...skipping 16 matching lines...) Expand all
372 } else if (receiver_map->has_fast_elements() || 381 } else if (receiver_map->has_fast_elements() ||
373 receiver_map->has_fixed_typed_array_elements()) { 382 receiver_map->has_fixed_typed_array_elements()) {
374 cached_stub = StoreFastElementStub(isolate(), is_js_array, 383 cached_stub = StoreFastElementStub(isolate(), is_js_array,
375 elements_kind, store_mode).GetCode(); 384 elements_kind, store_mode).GetCode();
376 } else { 385 } else {
377 cached_stub = 386 cached_stub =
378 StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); 387 StoreElementStub(isolate(), elements_kind, store_mode).GetCode();
379 } 388 }
380 } 389 }
381 DCHECK(!cached_stub.is_null()); 390 DCHECK(!cached_stub.is_null());
382 handlers.Add(cached_stub); 391 handlers->Add(cached_stub);
383 transitioned_maps.Add(transitioned_map); 392 transitioned_maps->Add(transitioned_map);
384 } 393 }
394 }
395
396
397 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic(
398 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode) {
399 // Collect MONOMORPHIC stubs for all |receiver_maps|.
400 CodeHandleList handlers(receiver_maps->length());
401 MapHandleList transitioned_maps(receiver_maps->length());
402 CompileKeyedStorePolymorphicHandlers(receiver_maps, &transitioned_maps,
403 &handlers, store_mode);
385 404
386 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers, 405 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers,
387 &transitioned_maps); 406 &transitioned_maps);
388 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); 407 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment();
389 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0)); 408 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0));
390 return code; 409 return code;
391 } 410 }
392 411
393 412
394 #define __ ACCESS_MASM(masm()) 413 #define __ ACCESS_MASM(masm())
395 414
396 415
397 Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic( 416 Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphicHandler(
398 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { 417 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
399 ElementsKind elements_kind = receiver_map->elements_kind(); 418 ElementsKind elements_kind = receiver_map->elements_kind();
400 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; 419 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE;
401 Handle<Code> stub; 420 Handle<Code> stub;
402 if (receiver_map->has_sloppy_arguments_elements()) { 421 if (receiver_map->has_sloppy_arguments_elements()) {
403 stub = KeyedStoreSloppyArgumentsStub(isolate(), store_mode).GetCode(); 422 stub = KeyedStoreSloppyArgumentsStub(isolate(), store_mode).GetCode();
404 } else if (receiver_map->has_fast_elements() || 423 } else if (receiver_map->has_fast_elements() ||
405 receiver_map->has_fixed_typed_array_elements()) { 424 receiver_map->has_fixed_typed_array_elements()) {
406 stub = StoreFastElementStub(isolate(), is_jsarray, elements_kind, 425 stub = StoreFastElementStub(isolate(), is_jsarray, elements_kind,
407 store_mode).GetCode(); 426 store_mode).GetCode();
408 } else { 427 } else {
409 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); 428 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode();
410 } 429 }
430 return stub;
431 }
432
433
434 Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic(
435 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) {
436 Handle<Code> stub =
437 CompileKeyedStoreMonomorphicHandler(receiver_map, store_mode);
411 438
412 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); 439 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map);
413 440
414 __ DispatchWeakMap(receiver(), scratch1(), scratch2(), cell, stub, 441 __ DispatchWeakMap(receiver(), scratch1(), scratch2(), cell, stub,
415 DO_SMI_CHECK); 442 DO_SMI_CHECK);
416 443
417 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); 444 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss);
418 445
419 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); 446 return GetCode(kind(), Code::NORMAL, factory()->empty_string());
420 } 447 }
421 448
422 449
423 #undef __ 450 #undef __
424 } // namespace internal 451 } // namespace internal
425 } // namespace v8 452 } // namespace v8
OLDNEW
« no previous file with comments | « src/ic/ic-compiler.h ('k') | src/type-feedback-vector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698