| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 if (target->is_debug_break()) return; | 340 if (target->is_debug_break()) return; |
| 341 | 341 |
| 342 switch (target->kind()) { | 342 switch (target->kind()) { |
| 343 case Code::LOAD_IC: return LoadIC::Clear(address, target); | 343 case Code::LOAD_IC: return LoadIC::Clear(address, target); |
| 344 case Code::KEYED_LOAD_IC: return KeyedLoadIC::Clear(address, target); | 344 case Code::KEYED_LOAD_IC: return KeyedLoadIC::Clear(address, target); |
| 345 case Code::STORE_IC: return StoreIC::Clear(address, target); | 345 case Code::STORE_IC: return StoreIC::Clear(address, target); |
| 346 case Code::KEYED_STORE_IC: return KeyedStoreIC::Clear(address, target); | 346 case Code::KEYED_STORE_IC: return KeyedStoreIC::Clear(address, target); |
| 347 case Code::CALL_IC: return CallIC::Clear(address, target); | 347 case Code::CALL_IC: return CallIC::Clear(address, target); |
| 348 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); | 348 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); |
| 349 case Code::COMPARE_IC: return CompareIC::Clear(address, target); | 349 case Code::COMPARE_IC: return CompareIC::Clear(address, target); |
| 350 case Code::COMPARE_NIL_IC: return CompareNilIC::Clear(address, target); |
| 350 case Code::UNARY_OP_IC: | 351 case Code::UNARY_OP_IC: |
| 351 case Code::BINARY_OP_IC: | 352 case Code::BINARY_OP_IC: |
| 352 case Code::TO_BOOLEAN_IC: | 353 case Code::TO_BOOLEAN_IC: |
| 353 // Clearing these is tricky and does not | 354 // Clearing these is tricky and does not |
| 354 // make any performance difference. | 355 // make any performance difference. |
| 355 return; | 356 return; |
| 356 default: UNREACHABLE(); | 357 default: UNREACHABLE(); |
| 357 } | 358 } |
| 358 } | 359 } |
| 359 | 360 |
| (...skipping 2399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2759 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. | 2760 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. |
| 2760 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { | 2761 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { |
| 2761 NoHandleAllocation na(isolate); | 2762 NoHandleAllocation na(isolate); |
| 2762 ASSERT(args.length() == 3); | 2763 ASSERT(args.length() == 3); |
| 2763 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); | 2764 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); |
| 2764 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); | 2765 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); |
| 2765 return ic.target(); | 2766 return ic.target(); |
| 2766 } | 2767 } |
| 2767 | 2768 |
| 2768 | 2769 |
| 2770 Handle<Code> CompareNilIC::GetUninitialized() { |
| 2771 CompareNilICStub stub; |
| 2772 return stub.GetCode(Isolate::Current()); |
| 2773 } |
| 2774 |
| 2775 |
| 2776 Code* CompareNilIC::GetRawUninitialized() { |
| 2777 CompareNilICStub stub; |
| 2778 Code* code = NULL; |
| 2779 CHECK(stub.FindCodeInCache(&code, Isolate::Current())); |
| 2780 return code; |
| 2781 } |
| 2782 |
| 2783 |
| 2784 void CompareNilIC::Clear(Address address, Code* target) { |
| 2785 if (target->ic_state() == UNINITIALIZED) return; |
| 2786 SetTargetAtAddress(address, GetRawUninitialized()); |
| 2787 } |
| 2788 |
| 2789 |
| 2790 MaybeObject* CompareNilIC::DoCompareNilSlow(EqualityKind kind, |
| 2791 NilValue nil, |
| 2792 Handle<Object> object) { |
| 2793 if (kind == kStrictEquality) { |
| 2794 if (nil == kNullValue) { |
| 2795 return Smi::FromInt(object->IsNull()); |
| 2796 } else { |
| 2797 return Smi::FromInt(object->IsUndefined()); |
| 2798 } |
| 2799 } |
| 2800 if (Smi::FromInt(object->IsNull() || object->IsUndefined())) { |
| 2801 return Smi::FromInt(true); |
| 2802 } |
| 2803 return Smi::FromInt(object->IsUndetectableObject()); |
| 2804 } |
| 2805 |
| 2806 |
| 2807 MaybeObject* CompareNilIC::CompareNil(EqualityKind kind, |
| 2808 NilValue nil, |
| 2809 Handle<Object> object) { |
| 2810 // Extract the current supported types from the patched IC and calculate what |
| 2811 // types must be supported as a result of the miss. |
| 2812 bool already_monomorphic; |
| 2813 CompareNilICStub::Types types = |
| 2814 CompareNilICStub::GetPatchedICFlags(target(), kind, nil, |
| 2815 object, &already_monomorphic); |
| 2816 |
| 2817 // Find or create the specialized stub to support the new set of types. |
| 2818 CompareNilICStub stub(kind, types); |
| 2819 Handle<Code> code; |
| 2820 if ((types & CompareNilICStub::kCompareAgainstMonomorphicMap) != 0) { |
| 2821 Handle<Map> monomorphic_map(already_monomorphic |
| 2822 ? target()->FindFirstMap() |
| 2823 : HeapObject::cast(*object)->map()); |
| 2824 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, |
| 2825 stub.GetTypes()); |
| 2826 } else { |
| 2827 code = stub.GetCode(isolate()); |
| 2828 } |
| 2829 |
| 2830 patch(*code); |
| 2831 |
| 2832 return DoCompareNilSlow(kind, nil, object); |
| 2833 } |
| 2834 |
| 2835 |
| 2836 void CompareNilIC::patch(Code* code) { |
| 2837 set_target(code); |
| 2838 } |
| 2839 |
| 2840 |
| 2841 RUNTIME_FUNCTION(MaybeObject*, CompareNilIC_Miss) { |
| 2842 HandleScope scope(isolate); |
| 2843 EqualityKind kind = static_cast<EqualityKind>(args.smi_at(0)); |
| 2844 NilValue nil = static_cast<NilValue>(args.smi_at(1)); |
| 2845 Handle<Object> object = args.at<Object>(2); |
| 2846 CompareNilIC ic(isolate); |
| 2847 return ic.CompareNil(kind, nil, object); |
| 2848 } |
| 2849 |
| 2850 |
| 2769 RUNTIME_FUNCTION(MaybeObject*, Unreachable) { | 2851 RUNTIME_FUNCTION(MaybeObject*, Unreachable) { |
| 2770 UNREACHABLE(); | 2852 UNREACHABLE(); |
| 2771 CHECK(false); | 2853 CHECK(false); |
| 2772 return isolate->heap()->undefined_value(); | 2854 return isolate->heap()->undefined_value(); |
| 2773 } | 2855 } |
| 2774 | 2856 |
| 2775 | 2857 |
| 2776 RUNTIME_FUNCTION(MaybeObject*, ToBoolean_Patch) { | 2858 RUNTIME_FUNCTION(MaybeObject*, ToBoolean_Patch) { |
| 2777 ASSERT(args.length() == 3); | 2859 ASSERT(args.length() == 3); |
| 2778 | 2860 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2805 #undef ADDR | 2887 #undef ADDR |
| 2806 }; | 2888 }; |
| 2807 | 2889 |
| 2808 | 2890 |
| 2809 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2891 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2810 return IC_utilities[id]; | 2892 return IC_utilities[id]; |
| 2811 } | 2893 } |
| 2812 | 2894 |
| 2813 | 2895 |
| 2814 } } // namespace v8::internal | 2896 } } // namespace v8::internal |
| OLD | NEW |