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-arguments-inl.h" | 8 #include "src/api-arguments-inl.h" |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/arguments.h" | 10 #include "src/arguments.h" |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 LoadGlobalICNexus* nexus = casted_nexus<LoadGlobalICNexus>(); | 931 LoadGlobalICNexus* nexus = casted_nexus<LoadGlobalICNexus>(); |
932 nexus->ConfigurePropertyCellMode(lookup->GetPropertyCell()); | 932 nexus->ConfigurePropertyCellMode(lookup->GetPropertyCell()); |
933 TRACE_IC("LoadGlobalIC", lookup->name()); | 933 TRACE_IC("LoadGlobalIC", lookup->name()); |
934 return; | 934 return; |
935 } else if (lookup->state() == LookupIterator::ACCESSOR) { | 935 } else if (lookup->state() == LookupIterator::ACCESSOR) { |
936 if (!IsCompatibleReceiver(lookup, receiver_map())) { | 936 if (!IsCompatibleReceiver(lookup, receiver_map())) { |
937 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); | 937 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); |
938 code = slow_stub(); | 938 code = slow_stub(); |
939 } | 939 } |
940 } else if (lookup->state() == LookupIterator::INTERCEPTOR) { | 940 } else if (lookup->state() == LookupIterator::INTERCEPTOR) { |
941 // Perform a lookup behind the interceptor. Copy the LookupIterator since | 941 if (kind() == Code::LOAD_GLOBAL_IC) { |
942 // the original iterator will be used to fetch the value. | 942 // The interceptor handler requires name but it is not passed explicitly |
943 LookupIterator it = *lookup; | 943 // to LoadGlobalIC and the LoadGlobalIC dispatcher also does not load |
944 it.Next(); | 944 // it so we will just use slow stub. |
945 LookupForRead(&it); | |
946 if (it.state() == LookupIterator::ACCESSOR && | |
947 !IsCompatibleReceiver(&it, receiver_map())) { | |
948 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); | |
949 code = slow_stub(); | 945 code = slow_stub(); |
| 946 } else { |
| 947 // Perform a lookup behind the interceptor. Copy the LookupIterator |
| 948 // since the original iterator will be used to fetch the value. |
| 949 LookupIterator it = *lookup; |
| 950 it.Next(); |
| 951 LookupForRead(&it); |
| 952 if (it.state() == LookupIterator::ACCESSOR && |
| 953 !IsCompatibleReceiver(&it, receiver_map())) { |
| 954 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); |
| 955 code = slow_stub(); |
| 956 } |
950 } | 957 } |
951 } | 958 } |
952 if (code.is_null()) code = ComputeHandler(lookup); | 959 if (code.is_null()) code = ComputeHandler(lookup); |
953 } | 960 } |
954 | 961 |
955 PatchCache(lookup->name(), code); | 962 PatchCache(lookup->name(), code); |
956 TRACE_IC("LoadIC", lookup->name()); | 963 TRACE_IC("LoadIC", lookup->name()); |
957 } | 964 } |
958 | 965 |
959 | 966 |
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2872 !it.GetHolder<JSObject>().is_identical_to(holder)) { | 2879 !it.GetHolder<JSObject>().is_identical_to(holder)) { |
2873 DCHECK(it.state() != LookupIterator::ACCESS_CHECK || it.HasAccess()); | 2880 DCHECK(it.state() != LookupIterator::ACCESS_CHECK || it.HasAccess()); |
2874 it.Next(); | 2881 it.Next(); |
2875 } | 2882 } |
2876 // Skip past the interceptor. | 2883 // Skip past the interceptor. |
2877 it.Next(); | 2884 it.Next(); |
2878 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 2885 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
2879 | 2886 |
2880 if (it.IsFound()) return *result; | 2887 if (it.IsFound()) return *result; |
2881 | 2888 |
| 2889 #ifdef DEBUG |
2882 LoadICNexus nexus(isolate); | 2890 LoadICNexus nexus(isolate); |
2883 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); | 2891 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); |
2884 // It could actually be any kind of LoadICs here but the predicate handles | 2892 // It could actually be any kind of LoadICs here but the predicate handles |
2885 // all the cases properly. | 2893 // all the cases properly. |
2886 if (!ic.ShouldThrowReferenceError()) { | 2894 DCHECK(!ic.ShouldThrowReferenceError()); |
2887 return isolate->heap()->undefined_value(); | 2895 #endif |
2888 } | |
2889 | 2896 |
2890 // Throw a reference error. | 2897 return isolate->heap()->undefined_value(); |
2891 THROW_NEW_ERROR_RETURN_FAILURE( | |
2892 isolate, NewReferenceError(MessageTemplate::kNotDefined, it.name())); | |
2893 } | 2898 } |
2894 | 2899 |
2895 | 2900 |
2896 RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { | 2901 RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { |
2897 HandleScope scope(isolate); | 2902 HandleScope scope(isolate); |
2898 DCHECK(args.length() == 3); | 2903 DCHECK(args.length() == 3); |
2899 StoreICNexus nexus(isolate); | 2904 StoreICNexus nexus(isolate); |
2900 StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); | 2905 StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); |
2901 Handle<JSObject> receiver = args.at<JSObject>(0); | 2906 Handle<JSObject> receiver = args.at<JSObject>(0); |
2902 Handle<Name> name = args.at<Name>(1); | 2907 Handle<Name> name = args.at<Name>(1); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2984 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, | 2989 DCHECK_EQ(FeedbackVectorSlotKind::KEYED_LOAD_IC, |
2985 vector->GetKind(vector_slot)); | 2990 vector->GetKind(vector_slot)); |
2986 KeyedLoadICNexus nexus(vector, vector_slot); | 2991 KeyedLoadICNexus nexus(vector, vector_slot); |
2987 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 2992 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
2988 ic.UpdateState(receiver, key); | 2993 ic.UpdateState(receiver, key); |
2989 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); | 2994 RETURN_RESULT_OR_FAILURE(isolate, ic.Load(receiver, key)); |
2990 } | 2995 } |
2991 } | 2996 } |
2992 } // namespace internal | 2997 } // namespace internal |
2993 } // namespace v8 | 2998 } // namespace v8 |
OLD | NEW |