| 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 2863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2874 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. | 2874 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. |
| 2875 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { | 2875 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { |
| 2876 NoHandleAllocation na(isolate); | 2876 NoHandleAllocation na(isolate); |
| 2877 ASSERT(args.length() == 3); | 2877 ASSERT(args.length() == 3); |
| 2878 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); | 2878 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); |
| 2879 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); | 2879 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); |
| 2880 return ic.target(); | 2880 return ic.target(); |
| 2881 } | 2881 } |
| 2882 | 2882 |
| 2883 | 2883 |
| 2884 Code* CompareNilIC::GetRawUninitialized(EqualityKind kind, | |
| 2885 NilValue nil) { | |
| 2886 CompareNilICStub stub(kind, nil); | |
| 2887 Code* code = NULL; | |
| 2888 CHECK(stub.FindCodeInCache(&code, Isolate::Current())); | |
| 2889 return code; | |
| 2890 } | |
| 2891 | |
| 2892 | |
| 2893 void CompareNilIC::Clear(Address address, Code* target) { | 2884 void CompareNilIC::Clear(Address address, Code* target) { |
| 2894 if (target->ic_state() == UNINITIALIZED) return; | 2885 if (target->ic_state() == UNINITIALIZED) return; |
| 2895 Code::ExtraICState state = target->extended_extra_ic_state(); | 2886 Code::ExtraICState state = target->extended_extra_ic_state(); |
| 2896 | 2887 |
| 2897 EqualityKind kind = | 2888 CompareNilICStub stub(state, CompareNilICStub::CODE_STUB_IS_MISS); |
| 2898 CompareNilICStub::EqualityKindFromExtraICState(state); | 2889 stub.ClearTypes(); |
| 2899 NilValue nil = | |
| 2900 CompareNilICStub::NilValueFromExtraICState(state); | |
| 2901 | 2890 |
| 2902 SetTargetAtAddress(address, GetRawUninitialized(kind, nil)); | 2891 Code* code = NULL; |
| 2892 CHECK(stub.FindCodeInCache(&code, target->GetIsolate())); |
| 2893 |
| 2894 SetTargetAtAddress(address, code); |
| 2903 } | 2895 } |
| 2904 | 2896 |
| 2905 | 2897 |
| 2906 MaybeObject* CompareNilIC::DoCompareNilSlow(EqualityKind kind, | 2898 MaybeObject* CompareNilIC::DoCompareNilSlow(EqualityKind kind, |
| 2907 NilValue nil, | 2899 NilValue nil, |
| 2908 Handle<Object> object) { | 2900 Handle<Object> object) { |
| 2909 if (kind == kStrictEquality) { | 2901 if (kind == kStrictEquality) { |
| 2910 if (nil == kNullValue) { | 2902 if (nil == kNullValue) { |
| 2911 return Smi::FromInt(object->IsNull()); | 2903 return Smi::FromInt(object->IsNull()); |
| 2912 } else { | 2904 } else { |
| 2913 return Smi::FromInt(object->IsUndefined()); | 2905 return Smi::FromInt(object->IsUndefined()); |
| 2914 } | 2906 } |
| 2915 } | 2907 } |
| 2916 if (object->IsNull() || object->IsUndefined()) { | 2908 if (object->IsNull() || object->IsUndefined()) { |
| 2917 return Smi::FromInt(true); | 2909 return Smi::FromInt(true); |
| 2918 } | 2910 } |
| 2919 return Smi::FromInt(object->IsUndetectableObject()); | 2911 return Smi::FromInt(object->IsUndetectableObject()); |
| 2920 } | 2912 } |
| 2921 | 2913 |
| 2922 | 2914 |
| 2923 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { | 2915 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { |
| 2924 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state(); | 2916 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state(); |
| 2925 | 2917 |
| 2918 CompareNilICStub stub(extra_ic_state); |
| 2919 |
| 2926 // Extract the current supported types from the patched IC and calculate what | 2920 // Extract the current supported types from the patched IC and calculate what |
| 2927 // types must be supported as a result of the miss. | 2921 // types must be supported as a result of the miss. |
| 2928 bool already_monomorphic; | 2922 bool already_monomorphic = stub.IsMonomorphic(); |
| 2929 CompareNilICStub::Types types = | |
| 2930 CompareNilICStub::GetPatchedICFlags(extra_ic_state, | |
| 2931 object, &already_monomorphic); | |
| 2932 | 2923 |
| 2933 EqualityKind kind = | 2924 stub.Record(object); |
| 2934 CompareNilICStub::EqualityKindFromExtraICState(extra_ic_state); | 2925 |
| 2935 NilValue nil = | 2926 EqualityKind kind = stub.GetKind(); |
| 2936 CompareNilICStub::NilValueFromExtraICState(extra_ic_state); | 2927 NilValue nil = stub.GetNilValue(); |
| 2937 | 2928 |
| 2938 // Find or create the specialized stub to support the new set of types. | 2929 // Find or create the specialized stub to support the new set of types. |
| 2939 CompareNilICStub stub(kind, nil, types); | |
| 2940 Handle<Code> code; | 2930 Handle<Code> code; |
| 2941 if ((types & CompareNilICStub::kCompareAgainstMonomorphicMap) != 0) { | 2931 if (stub.IsMonomorphic()) { |
| 2942 Handle<Map> monomorphic_map(already_monomorphic | 2932 Handle<Map> monomorphic_map(already_monomorphic |
| 2943 ? target()->FindFirstMap() | 2933 ? target()->FindFirstMap() |
| 2944 : HeapObject::cast(*object)->map()); | 2934 : HeapObject::cast(*object)->map()); |
| 2945 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, | 2935 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, stub); |
| 2946 nil, | |
| 2947 stub.GetTypes()); | |
| 2948 } else { | 2936 } else { |
| 2949 code = stub.GetCode(isolate()); | 2937 code = stub.GetCode(isolate()); |
| 2950 } | 2938 } |
| 2951 | 2939 |
| 2952 patch(*code); | 2940 patch(*code); |
| 2953 | 2941 |
| 2954 return DoCompareNilSlow(kind, nil, object); | 2942 return DoCompareNilSlow(kind, nil, object); |
| 2955 } | 2943 } |
| 2956 | 2944 |
| 2957 | 2945 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3007 #undef ADDR | 2995 #undef ADDR |
| 3008 }; | 2996 }; |
| 3009 | 2997 |
| 3010 | 2998 |
| 3011 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2999 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3012 return IC_utilities[id]; | 3000 return IC_utilities[id]; |
| 3013 } | 3001 } |
| 3014 | 3002 |
| 3015 | 3003 |
| 3016 } } // namespace v8::internal | 3004 } } // namespace v8::internal |
| OLD | NEW |