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/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 SetTargetAtAddress( | 541 SetTargetAtAddress( |
542 address, *pre_monomorphic_stub( | 542 address, *pre_monomorphic_stub( |
543 isolate, StoreIC::GetStrictMode(target->extra_ic_state())), | 543 isolate, StoreIC::GetStrictMode(target->extra_ic_state())), |
544 constant_pool); | 544 constant_pool); |
545 } | 545 } |
546 | 546 |
547 | 547 |
548 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, | 548 void CompareIC::Clear(Isolate* isolate, Address address, Code* target, |
549 ConstantPoolArray* constant_pool) { | 549 ConstantPoolArray* constant_pool) { |
550 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); | 550 DCHECK(CodeStub::GetMajorKey(target) == CodeStub::CompareIC); |
551 ICCompareStub stub(target->stub_key()); | 551 CompareICStub stub(target->stub_key()); |
552 // Only clear CompareICs that can retain objects. | 552 // Only clear CompareICs that can retain objects. |
553 if (stub.state() != KNOWN_OBJECT) return; | 553 if (stub.state() != KNOWN_OBJECT) return; |
554 SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), | 554 SetTargetAtAddress(address, GetRawUninitialized(isolate, stub.op()), |
555 constant_pool); | 555 constant_pool); |
556 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); | 556 PatchInlinedSmiCode(address, DISABLE_INLINED_SMI_CHECK); |
557 } | 557 } |
558 | 558 |
559 | 559 |
560 // static | 560 // static |
561 Handle<Code> KeyedLoadIC::generic_stub(Isolate* isolate) { | 561 Handle<Code> KeyedLoadIC::generic_stub(Isolate* isolate) { |
(...skipping 2107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2669 args.at<Object>(BinaryOpWithAllocationSiteStub::kRight); | 2669 args.at<Object>(BinaryOpWithAllocationSiteStub::kRight); |
2670 BinaryOpIC ic(isolate); | 2670 BinaryOpIC ic(isolate); |
2671 Handle<Object> result; | 2671 Handle<Object> result; |
2672 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 2672 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
2673 isolate, result, ic.Transition(allocation_site, left, right)); | 2673 isolate, result, ic.Transition(allocation_site, left, right)); |
2674 return *result; | 2674 return *result; |
2675 } | 2675 } |
2676 | 2676 |
2677 | 2677 |
2678 Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op) { | 2678 Code* CompareIC::GetRawUninitialized(Isolate* isolate, Token::Value op) { |
2679 ICCompareStub stub(isolate, op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); | 2679 CompareICStub stub(isolate, op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); |
2680 Code* code = NULL; | 2680 Code* code = NULL; |
2681 CHECK(stub.FindCodeInCache(&code)); | 2681 CHECK(stub.FindCodeInCache(&code)); |
2682 return code; | 2682 return code; |
2683 } | 2683 } |
2684 | 2684 |
2685 | 2685 |
2686 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op) { | 2686 Handle<Code> CompareIC::GetUninitialized(Isolate* isolate, Token::Value op) { |
2687 ICCompareStub stub(isolate, op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); | 2687 CompareICStub stub(isolate, op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED); |
2688 return stub.GetCode(); | 2688 return stub.GetCode(); |
2689 } | 2689 } |
2690 | 2690 |
2691 | 2691 |
2692 const char* CompareIC::GetStateName(State state) { | 2692 const char* CompareIC::GetStateName(State state) { |
2693 switch (state) { | 2693 switch (state) { |
2694 case UNINITIALIZED: | 2694 case UNINITIALIZED: |
2695 return "UNINITIALIZED"; | 2695 return "UNINITIALIZED"; |
2696 case SMI: | 2696 case SMI: |
2697 return "SMI"; | 2697 return "SMI"; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2738 return Type::Any(zone); | 2738 return Type::Any(zone); |
2739 } | 2739 } |
2740 UNREACHABLE(); | 2740 UNREACHABLE(); |
2741 return NULL; | 2741 return NULL; |
2742 } | 2742 } |
2743 | 2743 |
2744 | 2744 |
2745 void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type, | 2745 void CompareIC::StubInfoToType(uint32_t stub_key, Type** left_type, |
2746 Type** right_type, Type** overall_type, | 2746 Type** right_type, Type** overall_type, |
2747 Handle<Map> map, Zone* zone) { | 2747 Handle<Map> map, Zone* zone) { |
2748 ICCompareStub stub(stub_key); | 2748 CompareICStub stub(stub_key); |
2749 *left_type = StateToType(zone, stub.left()); | 2749 *left_type = StateToType(zone, stub.left()); |
2750 *right_type = StateToType(zone, stub.right()); | 2750 *right_type = StateToType(zone, stub.right()); |
2751 *overall_type = StateToType(zone, stub.state(), map); | 2751 *overall_type = StateToType(zone, stub.state(), map); |
2752 } | 2752 } |
2753 | 2753 |
2754 | 2754 |
2755 CompareIC::State CompareIC::NewInputState(State old_state, | 2755 CompareIC::State CompareIC::NewInputState(State old_state, |
2756 Handle<Object> value) { | 2756 Handle<Object> value) { |
2757 switch (old_state) { | 2757 switch (old_state) { |
2758 case UNINITIALIZED: | 2758 case UNINITIALIZED: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2851 case GENERIC: | 2851 case GENERIC: |
2852 return GENERIC; | 2852 return GENERIC; |
2853 } | 2853 } |
2854 UNREACHABLE(); | 2854 UNREACHABLE(); |
2855 return GENERIC; // Make the compiler happy. | 2855 return GENERIC; // Make the compiler happy. |
2856 } | 2856 } |
2857 | 2857 |
2858 | 2858 |
2859 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { | 2859 Code* CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
2860 HandleScope scope(isolate()); | 2860 HandleScope scope(isolate()); |
2861 ICCompareStub old_stub(target()->stub_key()); | 2861 CompareICStub old_stub(target()->stub_key()); |
2862 State new_left = NewInputState(old_stub.left(), x); | 2862 State new_left = NewInputState(old_stub.left(), x); |
2863 State new_right = NewInputState(old_stub.right(), y); | 2863 State new_right = NewInputState(old_stub.right(), y); |
2864 State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(), | 2864 State state = TargetState(old_stub.state(), old_stub.left(), old_stub.right(), |
2865 HasInlinedSmiCode(address()), x, y); | 2865 HasInlinedSmiCode(address()), x, y); |
2866 ICCompareStub stub(isolate(), op_, new_left, new_right, state); | 2866 CompareICStub stub(isolate(), op_, new_left, new_right, state); |
2867 if (state == KNOWN_OBJECT) { | 2867 if (state == KNOWN_OBJECT) { |
2868 stub.set_known_map( | 2868 stub.set_known_map( |
2869 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); | 2869 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); |
2870 } | 2870 } |
2871 Handle<Code> new_target = stub.GetCode(); | 2871 Handle<Code> new_target = stub.GetCode(); |
2872 set_target(*new_target); | 2872 set_target(*new_target); |
2873 | 2873 |
2874 if (FLAG_trace_ic) { | 2874 if (FLAG_trace_ic) { |
2875 PrintF("[CompareIC in "); | 2875 PrintF("[CompareIC in "); |
2876 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); | 2876 JavaScriptFrame::PrintTop(isolate(), stdout, false, true); |
2877 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", | 2877 PrintF(" ((%s+%s=%s)->(%s+%s=%s))#%s @ %p]\n", |
2878 GetStateName(old_stub.left()), GetStateName(old_stub.right()), | 2878 GetStateName(old_stub.left()), GetStateName(old_stub.right()), |
2879 GetStateName(old_stub.state()), GetStateName(new_left), | 2879 GetStateName(old_stub.state()), GetStateName(new_left), |
2880 GetStateName(new_right), GetStateName(state), Token::Name(op_), | 2880 GetStateName(new_right), GetStateName(state), Token::Name(op_), |
2881 static_cast<void*>(*stub.GetCode())); | 2881 static_cast<void*>(*stub.GetCode())); |
2882 } | 2882 } |
2883 | 2883 |
2884 // Activate inlined smi code. | 2884 // Activate inlined smi code. |
2885 if (old_stub.state() == UNINITIALIZED) { | 2885 if (old_stub.state() == UNINITIALIZED) { |
2886 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); | 2886 PatchInlinedSmiCode(address(), ENABLE_INLINED_SMI_CHECK); |
2887 } | 2887 } |
2888 | 2888 |
2889 return *new_target; | 2889 return *new_target; |
2890 } | 2890 } |
2891 | 2891 |
2892 | 2892 |
2893 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. | 2893 // Used from CompareICStub::GenerateMiss in code-stubs-<arch>.cc. |
2894 RUNTIME_FUNCTION(CompareIC_Miss) { | 2894 RUNTIME_FUNCTION(CompareIC_Miss) { |
2895 TimerEventScope<TimerEventIcMiss> timer(isolate); | 2895 TimerEventScope<TimerEventIcMiss> timer(isolate); |
2896 HandleScope scope(isolate); | 2896 HandleScope scope(isolate); |
2897 DCHECK(args.length() == 3); | 2897 DCHECK(args.length() == 3); |
2898 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); | 2898 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); |
2899 return ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); | 2899 return ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); |
2900 } | 2900 } |
2901 | 2901 |
2902 | 2902 |
2903 void CompareNilIC::Clear(Address address, Code* target, | 2903 void CompareNilIC::Clear(Address address, Code* target, |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3198 static const Address IC_utilities[] = { | 3198 static const Address IC_utilities[] = { |
3199 #define ADDR(name) FUNCTION_ADDR(name), | 3199 #define ADDR(name) FUNCTION_ADDR(name), |
3200 IC_UTIL_LIST(ADDR) NULL | 3200 IC_UTIL_LIST(ADDR) NULL |
3201 #undef ADDR | 3201 #undef ADDR |
3202 }; | 3202 }; |
3203 | 3203 |
3204 | 3204 |
3205 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3205 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3206 } | 3206 } |
3207 } // namespace v8::internal | 3207 } // namespace v8::internal |
OLD | NEW |