Chromium Code Reviews| 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( | |
|
Jakob Kummerow
2016/07/26 14:43:28
This unifies the loop body of CompileElementHandle
Igor Sheludko
2016/07/26 16:25:11
Acknowledged.
| |
| 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) { | |
|
Igor Sheludko
2016/07/26 16:25:11
TRACE_HANDLER_STATS(isolate(), KeyedLoadIC_SlowStu
Jakob Kummerow
2016/07/26 17:10:39
Done.
| |
| 594 return isolate->builtins()->KeyedLoadIC_Slow(); | |
| 595 } | |
| 596 | |
| 597 ElementsKind elements_kind = receiver_map->elements_kind(); | |
| 598 if (IsSloppyArgumentsElements(elements_kind)) { | |
| 599 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_KeyedLoadSloppyArgumentsStub); | |
| 600 return KeyedLoadSloppyArgumentsStub(isolate).GetCode(); | |
| 601 } | |
| 602 if (elements_kind == DICTIONARY_ELEMENTS) { | |
| 603 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadDictionaryElementStub); | |
| 604 return LoadDictionaryElementStub(isolate).GetCode(); | |
| 605 } | |
| 606 DCHECK(IsFastElementsKind(elements_kind) || | |
| 607 IsFixedTypedArrayElementsKind(elements_kind)); | |
| 608 bool is_js_array = instance_type == JS_ARRAY_TYPE; | |
| 609 bool convert_hole_to_undefined = | |
| 610 is_js_array && elements_kind == FAST_HOLEY_ELEMENTS && | |
| 611 *receiver_map == isolate->get_initial_js_array_map(elements_kind); | |
| 612 TRACE_HANDLER_STATS(isolate, KeyedLoadIC_LoadFastElementStub); | |
| 613 return LoadFastElementStub(isolate, is_js_array, elements_kind, | |
| 614 convert_hole_to_undefined) | |
| 615 .GetCode(); | |
| 616 } | |
| 617 | |
| 579 void ElementHandlerCompiler::CompileElementHandlers( | 618 void ElementHandlerCompiler::CompileElementHandlers( |
| 580 MapHandleList* receiver_maps, List<Handle<Object>>* handlers) { | 619 MapHandleList* receiver_maps, List<Handle<Object>>* handlers) { |
| 581 for (int i = 0; i < receiver_maps->length(); ++i) { | 620 for (int i = 0; i < receiver_maps->length(); ++i) { |
| 582 Handle<Map> receiver_map = receiver_maps->at(i); | 621 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 } | 622 } |
| 618 } | 623 } |
| 619 } // namespace internal | 624 } // namespace internal |
| 620 } // namespace v8 | 625 } // namespace v8 |
| OLD | NEW |