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/handler-compiler.h" | 5 #include "src/ic/handler-compiler.h" |
6 | 6 |
7 #include "src/field-type.h" | 7 #include "src/field-type.h" |
8 #include "src/ic/call-optimization.h" | 8 #include "src/ic/call-optimization.h" |
9 #include "src/ic/ic-inl.h" | 9 #include "src/ic/ic-inl.h" |
10 #include "src/ic/ic.h" | 10 #include "src/ic/ic.h" |
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 Register holder = Frontend(name); | 569 Register holder = Frontend(name); |
570 GenerateApiAccessorCall(masm(), call_optimization, handle(object->map()), | 570 GenerateApiAccessorCall(masm(), call_optimization, handle(object->map()), |
571 receiver(), scratch2(), true, value(), holder, | 571 receiver(), scratch2(), true, value(), holder, |
572 accessor_index); | 572 accessor_index); |
573 return GetCode(kind(), name); | 573 return GetCode(kind(), name); |
574 } | 574 } |
575 | 575 |
576 | 576 |
577 #undef __ | 577 #undef __ |
578 | 578 |
| 579 // static |
| 580 Handle<Code> ElementHandlerCompiler::GetKeyedLoadHandler( |
| 581 Handle<Map> receiver_map, Isolate* isolate) { |
| 582 if (receiver_map->has_indexed_interceptor() && |
| 583 !receiver_map->GetIndexedInterceptor()->getter()->IsUndefined(isolate) && |
| 584 !receiver_map->GetIndexedInterceptor()->non_masking()) { |
| 585 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadIndexedInterceptorStub); |
| 586 return LoadIndexedInterceptorStub(isolate).GetCode(); |
| 587 } |
| 588 if (receiver_map->IsStringMap()) { |
| 589 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadIndexedStringStub); |
| 590 return LoadIndexedStringStub(isolate).GetCode(); |
| 591 } |
| 592 InstanceType instance_type = receiver_map->instance_type(); |
| 593 if (instance_type < FIRST_JS_RECEIVER_TYPE) { |
| 594 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_SlowStub); |
| 595 return isolate->builtins()->KeyedLoadIC_Slow(); |
| 596 } |
| 597 |
| 598 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 599 if (IsSloppyArgumentsElements(elements_kind)) { |
| 600 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_KeyedLoadSloppyArgumentsStub); |
| 601 return KeyedLoadSloppyArgumentsStub(isolate).GetCode(); |
| 602 } |
| 603 if (elements_kind == DICTIONARY_ELEMENTS) { |
| 604 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadDictionaryElementStub); |
| 605 return LoadDictionaryElementStub(isolate).GetCode(); |
| 606 } |
| 607 DCHECK(IsFastElementsKind(elements_kind) || |
| 608 IsFixedTypedArrayElementsKind(elements_kind)); |
| 609 bool is_js_array = instance_type == JS_ARRAY_TYPE; |
| 610 bool convert_hole_to_undefined = |
| 611 is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && |
| 612 *receiver_map == isolate->get_initial_js_array_map(elements_kind); |
| 613 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadFastElementStub); |
| 614 return LoadFastElementStub(isolate, is_js_array, elements_kind, |
| 615 convert_hole_to_undefined) |
| 616 .GetCode(); |
| 617 } |
| 618 |
579 void ElementHandlerCompiler::CompileElementHandlers( | 619 void ElementHandlerCompiler::CompileElementHandlers( |
580 MapHandleList* receiver_maps, List<Handle<Object>>* handlers) { | 620 MapHandleList* receiver_maps, List<Handle<Object>>* handlers) { |
581 for (int i = 0; i < receiver_maps->length(); ++i) { | 621 for (int i = 0; i < receiver_maps->length(); ++i) { |
582 Handle<Map> receiver_map = receiver_maps->at(i); | 622 handlers->Add(GetKeyedLoadHandler(receiver_maps->at(i), isolate())); |
583 Handle<Code> cached_stub; | |
584 | |
585 if (receiver_map->IsStringMap()) { | |
586 cached_stub = LoadIndexedStringStub(isolate()).GetCode(); | |
587 } else if (receiver_map->instance_type() < FIRST_JS_RECEIVER_TYPE) { | |
588 cached_stub = isolate()->builtins()->KeyedLoadIC_Slow(); | |
589 } else { | |
590 bool is_js_array = receiver_map->instance_type() == JS_ARRAY_TYPE; | |
591 ElementsKind elements_kind = receiver_map->elements_kind(); | |
592 | |
593 // No need to check for an elements-free prototype chain here, the | |
594 // generated stub code needs to check that dynamically anyway. | |
595 bool convert_hole_to_undefined = | |
596 (is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && | |
597 *receiver_map == isolate()->get_initial_js_array_map(elements_kind)); | |
598 | |
599 if (receiver_map->has_indexed_interceptor() && | |
600 !receiver_map->GetIndexedInterceptor()->getter()->IsUndefined( | |
601 isolate()) && | |
602 !receiver_map->GetIndexedInterceptor()->non_masking()) { | |
603 cached_stub = LoadIndexedInterceptorStub(isolate()).GetCode(); | |
604 } else if (IsSloppyArgumentsElements(elements_kind)) { | |
605 cached_stub = KeyedLoadSloppyArgumentsStub(isolate()).GetCode(); | |
606 } else if (IsFastElementsKind(elements_kind) || | |
607 IsFixedTypedArrayElementsKind(elements_kind)) { | |
608 cached_stub = LoadFastElementStub(isolate(), is_js_array, elements_kind, | |
609 convert_hole_to_undefined).GetCode(); | |
610 } else { | |
611 DCHECK(elements_kind == DICTIONARY_ELEMENTS); | |
612 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); | |
613 } | |
614 } | |
615 | |
616 handlers->Add(cached_stub); | |
617 } | 623 } |
618 } | 624 } |
619 } // namespace internal | 625 } // namespace internal |
620 } // namespace v8 | 626 } // namespace v8 |
OLD | NEW |