OLD | NEW |
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 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 // to be. Not all the elements are in place yet, pessimistic elements | 355 // to be. Not all the elements are in place yet, pessimistic elements |
356 // transitions are still important for performance. | 356 // transitions are still important for performance. |
357 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | 357 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; |
358 ElementsKind elements_kind = receiver_map->elements_kind(); | 358 ElementsKind elements_kind = receiver_map->elements_kind(); |
359 if (!transitioned_map.is_null()) { | 359 if (!transitioned_map.is_null()) { |
360 cached_stub = | 360 cached_stub = |
361 ElementsTransitionAndStoreStub(isolate(), elements_kind, | 361 ElementsTransitionAndStoreStub(isolate(), elements_kind, |
362 transitioned_map->elements_kind(), | 362 transitioned_map->elements_kind(), |
363 is_js_array, store_mode).GetCode(); | 363 is_js_array, store_mode).GetCode(); |
364 } else if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE) { | 364 } else if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE) { |
| 365 // TODO(mvstanton): Consider embedding store_mode in the state of the slow |
| 366 // keyed store ic for uniformity. |
365 cached_stub = isolate()->builtins()->KeyedStoreIC_Slow(); | 367 cached_stub = isolate()->builtins()->KeyedStoreIC_Slow(); |
366 } else { | 368 } else { |
367 if (IsSloppyArgumentsElements(elements_kind)) { | 369 if (IsSloppyArgumentsElements(elements_kind)) { |
368 cached_stub = KeyedStoreSloppyArgumentsStub(isolate()).GetCode(); | 370 cached_stub = |
| 371 KeyedStoreSloppyArgumentsStub(isolate(), store_mode).GetCode(); |
369 } else if (receiver_map->has_fast_elements() || | 372 } else if (receiver_map->has_fast_elements() || |
370 receiver_map->has_fixed_typed_array_elements()) { | 373 receiver_map->has_fixed_typed_array_elements()) { |
371 cached_stub = StoreFastElementStub(isolate(), is_js_array, | 374 cached_stub = StoreFastElementStub(isolate(), is_js_array, |
372 elements_kind, store_mode).GetCode(); | 375 elements_kind, store_mode).GetCode(); |
373 } else { | 376 } else { |
374 cached_stub = StoreElementStub(isolate(), elements_kind).GetCode(); | 377 cached_stub = |
| 378 StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); |
375 } | 379 } |
376 } | 380 } |
377 DCHECK(!cached_stub.is_null()); | 381 DCHECK(!cached_stub.is_null()); |
378 handlers.Add(cached_stub); | 382 handlers.Add(cached_stub); |
379 transitioned_maps.Add(transitioned_map); | 383 transitioned_maps.Add(transitioned_map); |
380 } | 384 } |
381 | 385 |
382 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers, | 386 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers, |
383 &transitioned_maps); | 387 &transitioned_maps); |
384 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); | 388 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); |
385 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0)); | 389 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0)); |
386 return code; | 390 return code; |
387 } | 391 } |
388 | 392 |
389 | 393 |
390 #define __ ACCESS_MASM(masm()) | 394 #define __ ACCESS_MASM(masm()) |
391 | 395 |
392 | 396 |
393 Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic( | 397 Handle<Code> PropertyICCompiler::CompileKeyedStoreMonomorphic( |
394 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { | 398 Handle<Map> receiver_map, KeyedAccessStoreMode store_mode) { |
395 ElementsKind elements_kind = receiver_map->elements_kind(); | 399 ElementsKind elements_kind = receiver_map->elements_kind(); |
396 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; | 400 bool is_jsarray = receiver_map->instance_type() == JS_ARRAY_TYPE; |
397 Handle<Code> stub; | 401 Handle<Code> stub; |
398 if (receiver_map->has_sloppy_arguments_elements()) { | 402 if (receiver_map->has_sloppy_arguments_elements()) { |
399 stub = KeyedStoreSloppyArgumentsStub(isolate()).GetCode(); | 403 stub = KeyedStoreSloppyArgumentsStub(isolate(), store_mode).GetCode(); |
400 } else if (receiver_map->has_fast_elements() || | 404 } else if (receiver_map->has_fast_elements() || |
401 receiver_map->has_fixed_typed_array_elements()) { | 405 receiver_map->has_fixed_typed_array_elements()) { |
402 stub = StoreFastElementStub(isolate(), is_jsarray, elements_kind, | 406 stub = StoreFastElementStub(isolate(), is_jsarray, elements_kind, |
403 store_mode).GetCode(); | 407 store_mode).GetCode(); |
404 } else { | 408 } else { |
405 stub = StoreElementStub(isolate(), elements_kind).GetCode(); | 409 stub = StoreElementStub(isolate(), elements_kind, store_mode).GetCode(); |
406 } | 410 } |
407 | 411 |
408 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); | 412 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_map); |
409 | 413 |
410 __ DispatchWeakMap(receiver(), scratch1(), scratch2(), cell, stub, | 414 __ DispatchWeakMap(receiver(), scratch1(), scratch2(), cell, stub, |
411 DO_SMI_CHECK); | 415 DO_SMI_CHECK); |
412 | 416 |
413 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); | 417 TailCallBuiltin(masm(), Builtins::kKeyedStoreIC_Miss); |
414 | 418 |
415 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); | 419 return GetCode(kind(), Code::NORMAL, factory()->empty_string()); |
416 } | 420 } |
417 | 421 |
418 | 422 |
419 #undef __ | 423 #undef __ |
420 } // namespace internal | 424 } // namespace internal |
421 } // namespace v8 | 425 } // namespace v8 |
OLD | NEW |