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/v8.h" | 5 #include "src/v8.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/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 SetTargetAtAddress( | 540 SetTargetAtAddress( |
541 address, *pre_monomorphic_stub( | 541 address, *pre_monomorphic_stub( |
542 isolate, StoreIC::GetStrictMode(target->extra_ic_state())), | 542 isolate, StoreIC::GetStrictMode(target->extra_ic_state())), |
543 constant_pool); | 543 constant_pool); |
544 } | 544 } |
545 | 545 |
546 | 546 |
547 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, | 547 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, |
548 ConstantPoolArray* constant_pool) { | 548 ConstantPoolArray* constant_pool) { |
549 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); | 549 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); |
550 CompareIC::State handler_state; | 550 ICCompareStub stub(target->stub_key()); |
551 Token::Value op; | |
552 ICCompareStub::DecodeKey(target->stub_key(), NULL, NULL, &handler_state, &op); | |
553 // Only clear CompareICs that can retain objects. | 551 // Only clear CompareICs that can retain objects. |
554 if (handler_state != KNOWN_OBJECT) return; | 552 if (stub.state() != KNOWN_OBJECT) return; |
555 SetTargetAtAddress(address, GetRawUninitialized(isolate, op), constant_pool); | 553 SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), |
| 554 constant_pool); |
556 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); | 555 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); |
557 } | 556 } |
558 | 557 |
559 | 558 |
560 // static | 559 // static |
561 Handle<Code> KeyedLoadIC::generic_stub(Isolate* isolate) { | 560 Handle<Code> KeyedLoadIC::generic_stub(Isolate* isolate) { |
562 if (FLAG_compiled_keyed_generic_loads) { | 561 if (FLAG_compiled_keyed_generic_loads) { |
563 return KeyedLoadGenericStub(isolate).GetCode(); | 562 return KeyedLoadGenericStub(isolate).GetCode(); |
564 } else { | 563 } else { |
565 return isolate->builtins()->KeyedLoadIC_Generic(); | 564 return isolate->builtins()->KeyedLoadIC_Generic(); |
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 return Type::Any(zone); | 2736 return Type::Any(zone); |
2738 } | 2737 } |
2739 UNREACHABLE(); | 2738 UNREACHABLE(); |
2740 return NULL; | 2739 return NULL; |
2741 } | 2740 } |
2742 | 2741 |
2743 | 2742 |
2744 void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type, | 2743 void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type, |
2745 Type** right_type, Type** overall_type, | 2744 Type** right_type, Type** overall_type, |
2746 Handle<Map> map, Zone* zone) { | 2745 Handle<Map> map, Zone* zone) { |
2747 State left_state, right_state, handler_state; | 2746 ICCompareStub stub(stub_key); |
2748 ICCompareStub::DecodeKey(stub_key, &left_state, &right_state, &handler_state, | 2747 *left_type = StateToType(zone, stub.left()); |
2749 NULL); | 2748 *right_type = StateToType(zone, stub.right()); |
2750 *left_type = StateToType(zone, left_state); | 2749 *overall_type = StateToType(zone, stub.state(), map); |
2751 *right_type = StateToType(zone, right_state); | |
2752 *overall_type = StateToType(zone, handler_state, map); | |
2753 } | 2750 } |
2754 | 2751 |
2755 | 2752 |
2756 CompareIC::State CompareIC::NewInputState(State old_state, | 2753 CompareIC::State CompareIC::NewInputState(State old_state, |
2757 Handle<Object> value) { | 2754 Handle<Object> value) { |
2758 switch (old_state) { | 2755 switch (old_state) { |
2759 case UNINITIALIZED: | 2756 case UNINITIALIZED: |
2760 if (value->IsSmi()) return SMI; | 2757 if (value->IsSmi()) return SMI; |
2761 if (value->IsHeapNumber()) return NUMBER; | 2758 if (value->IsHeapNumber()) return NUMBER; |
2762 if (value->IsInternalizedString()) return INTERNALIZED_STRING; | 2759 if (value->IsInternalizedString()) return INTERNALIZED_STRING; |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2852 case GENERIC: | 2849 case GENERIC: |
2853 return GENERIC; | 2850 return GENERIC; |
2854 } | 2851 } |
2855 UNREACHABLE(); | 2852 UNREACHABLE(); |
2856 return GENERIC; // Make the compiler happy. | 2853 return GENERIC; // Make the compiler happy. |
2857 } | 2854 } |
2858 | 2855 |
2859 | 2856 |
2860 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { | 2857 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
2861 HandleScope scope(isolate()); | 2858 HandleScope scope(isolate()); |
2862 State previous_left, previous_right, previous_state; | 2859 ICCompareStub old_stub(target()->stub_key()); |
2863 ICCompareStub::DecodeKey(target()->stub_key(), &previous_left, | 2860 State new_left = NewInputState(old_stub.left(), x); |
2864 &previous_right, &previous_state, NULL); | 2861 State new_right = NewInputState(old_stub.right(), y); |
2865 State new_left = NewInputState(previous_left, x); | 2862 State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(), |
2866 State new_right = NewInputState(previous_right, y); | |
2867 State state = TargetState(previous_state, previous_left, previous_right, | |
2868 HasInlinedSmiCode(address()), x, y); | 2863 HasInlinedSmiCode(address()), x, y); |
2869 ICCompareStub stub(isolate(), op_, new_left, new_right, state); | 2864 ICCompareStub stub(isolate(), op_, new_left, new_right, state); |
2870 if (state == KNOWN_OBJECT) { | 2865 if (state == KNOWN_OBJECT) { |
2871 stub.set_known_map( | 2866 stub.set_known_map( |
2872 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); | 2867 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); |
2873 } | 2868 } |
2874 Handle<Code> new_target = stub.GetCode(); | 2869 Handle<Code> new_target = stub.GetCode(); |
2875 set_target(*new_target); | 2870 set_target(*new_target); |
2876 | 2871 |
2877 if (FLAG_trace_ic) { | 2872 if (FLAG_trace_ic) { |
2878 PrintF("[CompareIC in "); | 2873 PrintF("[CompareIC in "); |
2879 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); | 2874 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); |
2880 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", GetStateName(previous_left), | 2875 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", |
2881 GetStateName(previous_right), GetStateName(previous_state), | 2876 GetStateName(old_stub.left()), GetStateName(old_stub.right()), |
2882 GetStateName(new_left), GetStateName(new_right), GetStateName(state), | 2877 GetStateName(old_stub.state()), GetStateName(new_left), |
2883 Token::Name(op_), static_cast<void*>(*stub.GetCode())); | 2878 GetStateName(new_right), GetStateName(state), Token::Name(op_), |
| 2879 static_cast<void*>(*stub.GetCode())); |
2884 } | 2880 } |
2885 | 2881 |
2886 // Activate inlined smi code. | 2882 // Activate inlined smi code. |
2887 if (previous_state == UNINITIALIZED) { | 2883 if (old_stub.state() == UNINITIALIZED) { |
2888 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); | 2884 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
2889 } | 2885 } |
2890 | 2886 |
2891 return *new_target; | 2887 return *new_target; |
2892 } | 2888 } |
2893 | 2889 |
2894 | 2890 |
2895 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. | 2891 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. |
2896 RUNTIME_FUNCTION(CompareIC_Miss) { | 2892 RUNTIME_FUNCTION(CompareIC_Miss) { |
2897 TimerEventScope<TimerEventIcMiss> timer(isolate); | 2893 TimerEventScope<TimerEventIcMiss> timer(isolate); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2931 ExtraICState extra_ic_state = target()->extra_ic_state(); | 2927 ExtraICState extra_ic_state = target()->extra_ic_state(); |
2932 | 2928 |
2933 CompareNilICStub stub(isolate(), extra_ic_state); | 2929 CompareNilICStub stub(isolate(), extra_ic_state); |
2934 | 2930 |
2935 // Extract the current supported types from the patched IC and calculate what | 2931 // Extract the current supported types from the patched IC and calculate what |
2936 // types must be supported as a result of the miss. | 2932 // types must be supported as a result of the miss. |
2937 bool already_monomorphic = stub.IsMonomorphic(); | 2933 bool already_monomorphic = stub.IsMonomorphic(); |
2938 | 2934 |
2939 stub.UpdateStatus(object); | 2935 stub.UpdateStatus(object); |
2940 | 2936 |
2941 NilValue nil = stub.GetNilValue(); | 2937 NilValue nil = stub.nil_value(); |
2942 | 2938 |
2943 // Find or create the specialized stub to support the new set of types. | 2939 // Find or create the specialized stub to support the new set of types. |
2944 Handle<Code> code; | 2940 Handle<Code> code; |
2945 if (stub.IsMonomorphic()) { | 2941 if (stub.IsMonomorphic()) { |
2946 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL | 2942 Handle<Map> monomorphic_map(already_monomorphic && FirstTargetMap() != NULL |
2947 ? FirstTargetMap() | 2943 ? FirstTargetMap() |
2948 : HeapObject::cast(*object)->map()); | 2944 : HeapObject::cast(*object)->map()); |
2949 code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub); | 2945 code = PropertyICCompiler::ComputeCompareNil(monomorphic_map, &stub); |
2950 } else { | 2946 } else { |
2951 code = stub.GetCode(); | 2947 code = stub.GetCode(); |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3200 static const Address IC_utilities[] = { | 3196 static const Address IC_utilities[] = { |
3201 #define ADDR(name) FUNCTION_ADDR(name), | 3197 #define ADDR(name) FUNCTION_ADDR(name), |
3202 IC_UTIL_LIST(ADDR) NULL | 3198 IC_UTIL_LIST(ADDR) NULL |
3203 #undef ADDR | 3199 #undef ADDR |
3204 }; | 3200 }; |
3205 | 3201 |
3206 | 3202 |
3207 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3203 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3208 } | 3204 } |
3209 } // namespace v8::internal | 3205 } // namespace v8::internal |
OLD | NEW |