OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 HydrogenCodeStub::UNINITIALIZED); | 2731 HydrogenCodeStub::UNINITIALIZED); |
2732 stub.ClearState(); | 2732 stub.ClearState(); |
2733 | 2733 |
2734 Code* code = NULL; | 2734 Code* code = NULL; |
2735 CHECK(stub.FindCodeInCache(&code)); | 2735 CHECK(stub.FindCodeInCache(&code)); |
2736 | 2736 |
2737 SetTargetAtAddress(address, code, constant_pool); | 2737 SetTargetAtAddress(address, code, constant_pool); |
2738 } | 2738 } |
2739 | 2739 |
2740 | 2740 |
2741 Handle<Object> CompareNilIC::DoCompareNilSlow(Isolate* isolate, NilValue nil, | |
2742 Handle<Object> object) { | |
2743 if (object->IsNull() || object->IsUndefined()) { | |
2744 return isolate->factory()->true_value(); | |
2745 } | |
2746 return isolate->factory()->ToBoolean(object->IsUndetectableObject()); | |
2747 } | |
2748 | |
2749 | |
2750 Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) { | 2741 Handle<Object> CompareNilIC::CompareNil(Handle<Object> object) { |
2751 ExtraICState extra_ic_state = target()->extra_ic_state(); | 2742 ExtraICState extra_ic_state = target()->extra_ic_state(); |
2752 | 2743 |
2753 CompareNilICStub stub(isolate(), extra_ic_state); | 2744 CompareNilICStub stub(isolate(), extra_ic_state); |
2754 | 2745 |
2755 // Extract the current supported types from the patched IC and calculate what | 2746 // Extract the current supported types from the patched IC and calculate what |
2756 // types must be supported as a result of the miss. | 2747 // types must be supported as a result of the miss. |
2757 bool already_monomorphic = stub.IsMonomorphic(); | 2748 bool already_monomorphic = stub.IsMonomorphic(); |
2758 | 2749 |
2759 stub.UpdateStatus(object); | 2750 stub.UpdateStatus(object); |
2760 | 2751 |
2761 NilValue nil = stub.nil_value(); | |
2762 | |
2763 // Find or create the specialized stub to support the new set of types. | 2752 // Find or create the specialized stub to support the new set of types. |
2764 Handle<Code> code; | 2753 Handle<Code> code; |
2765 if (stub.IsMonomorphic()) { | 2754 if (stub.IsMonomorphic()) { |
2766 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL | 2755 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL |
2767 ? FirstTargetMap() | 2756 ? FirstTargetMap() |
2768 : HeapObject::cast(*object)->map()); | 2757 : HeapObject::cast(*object)->map()); |
2769 code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub); | 2758 code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub); |
2770 } else { | 2759 } else { |
2771 code = stub.GetCode(); | 2760 code = stub.GetCode(); |
2772 } | 2761 } |
2773 set_target(*code); | 2762 set_target(*code); |
2774 return DoCompareNilSlow(isolate(), nil, object); | 2763 return isolate()->factory()->ToBoolean(object->IsUndetectableObject()); |
2775 } | 2764 } |
2776 | 2765 |
2777 | 2766 |
2778 RUNTIME_FUNCTION(Runtime_CompareNilIC_Miss) { | 2767 RUNTIME_FUNCTION(Runtime_CompareNilIC_Miss) { |
2779 TimerEventScope<TimerEventIcMiss> timer(isolate); | 2768 TimerEventScope<TimerEventIcMiss> timer(isolate); |
2780 HandleScope scope(isolate); | 2769 HandleScope scope(isolate); |
2781 Handle<Object> object = args.at<Object>(0); | 2770 Handle<Object> object = args.at<Object>(0); |
2782 CompareNilIC ic(isolate); | 2771 CompareNilIC ic(isolate); |
2783 return *ic.CompareNil(object); | 2772 return *ic.CompareNil(object); |
2784 } | 2773 } |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2976 KeyedLoadICNexus nexus(vector, vector_slot); | 2965 KeyedLoadICNexus nexus(vector, vector_slot); |
2977 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2966 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2978 ic.UpdateState(receiver, key); | 2967 ic.UpdateState(receiver, key); |
2979 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 2968 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
2980 } | 2969 } |
2981 | 2970 |
2982 return *result; | 2971 return *result; |
2983 } | 2972 } |
2984 } // namespace internal | 2973 } // namespace internal |
2985 } // namespace v8 | 2974 } // namespace v8 |
OLD | NEW |