| 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 <iostream> | 7 #include <iostream> |
| 8 | 8 |
| 9 #include "src/accessors.h" | 9 #include "src/accessors.h" |
| 10 #include "src/api-arguments-inl.h" | 10 #include "src/api-arguments-inl.h" |
| (...skipping 1079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1090 LoadGlobalICNexus* nexus = casted_nexus<LoadGlobalICNexus>(); | 1090 LoadGlobalICNexus* nexus = casted_nexus<LoadGlobalICNexus>(); |
| 1091 nexus->ConfigurePropertyCellMode(lookup->GetPropertyCell()); | 1091 nexus->ConfigurePropertyCellMode(lookup->GetPropertyCell()); |
| 1092 TRACE_IC("LoadGlobalIC", lookup->name()); | 1092 TRACE_IC("LoadGlobalIC", lookup->name()); |
| 1093 return; | 1093 return; |
| 1094 } else if (lookup->state() == LookupIterator::ACCESSOR) { | 1094 } else if (lookup->state() == LookupIterator::ACCESSOR) { |
| 1095 if (!IsCompatibleReceiver(lookup, receiver_map())) { | 1095 if (!IsCompatibleReceiver(lookup, receiver_map())) { |
| 1096 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); | 1096 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); |
| 1097 code = slow_stub(); | 1097 code = slow_stub(); |
| 1098 } | 1098 } |
| 1099 } else if (lookup->state() == LookupIterator::INTERCEPTOR) { | 1099 } else if (lookup->state() == LookupIterator::INTERCEPTOR) { |
| 1100 if (kind() == Code::LOAD_GLOBAL_IC) { | 1100 // Perform a lookup behind the interceptor. Copy the LookupIterator |
| 1101 // The interceptor handler requires name but it is not passed explicitly | 1101 // since the original iterator will be used to fetch the value. |
| 1102 // to LoadGlobalIC and the LoadGlobalIC dispatcher also does not load | 1102 LookupIterator it = *lookup; |
| 1103 // it so we will just use slow stub. | 1103 it.Next(); |
| 1104 LookupForRead(&it); |
| 1105 if (it.state() == LookupIterator::ACCESSOR && |
| 1106 !IsCompatibleReceiver(&it, receiver_map())) { |
| 1107 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); |
| 1104 code = slow_stub(); | 1108 code = slow_stub(); |
| 1105 } else { | |
| 1106 // Perform a lookup behind the interceptor. Copy the LookupIterator | |
| 1107 // since the original iterator will be used to fetch the value. | |
| 1108 LookupIterator it = *lookup; | |
| 1109 it.Next(); | |
| 1110 LookupForRead(&it); | |
| 1111 if (it.state() == LookupIterator::ACCESSOR && | |
| 1112 !IsCompatibleReceiver(&it, receiver_map())) { | |
| 1113 TRACE_GENERIC_IC(isolate(), "LoadIC", "incompatible receiver type"); | |
| 1114 code = slow_stub(); | |
| 1115 } | |
| 1116 } | 1109 } |
| 1117 } | 1110 } |
| 1118 if (code.is_null()) code = ComputeHandler(lookup); | 1111 if (code.is_null()) code = ComputeHandler(lookup); |
| 1119 } | 1112 } |
| 1120 | 1113 |
| 1121 PatchCache(lookup->name(), code); | 1114 PatchCache(lookup->name(), code); |
| 1122 TRACE_IC("LoadIC", lookup->name()); | 1115 TRACE_IC("LoadIC", lookup->name()); |
| 1123 } | 1116 } |
| 1124 | 1117 |
| 1125 StubCache* IC::stub_cache() { | 1118 StubCache* IC::stub_cache() { |
| (...skipping 2034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3160 !it.GetHolder<JSObject>().is_identical_to(holder)) { | 3153 !it.GetHolder<JSObject>().is_identical_to(holder)) { |
| 3161 DCHECK(it.state() != LookupIterator::ACCESS_CHECK || it.HasAccess()); | 3154 DCHECK(it.state() != LookupIterator::ACCESS_CHECK || it.HasAccess()); |
| 3162 it.Next(); | 3155 it.Next(); |
| 3163 } | 3156 } |
| 3164 // Skip past the interceptor. | 3157 // Skip past the interceptor. |
| 3165 it.Next(); | 3158 it.Next(); |
| 3166 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); | 3159 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, Object::GetProperty(&it)); |
| 3167 | 3160 |
| 3168 if (it.IsFound()) return *result; | 3161 if (it.IsFound()) return *result; |
| 3169 | 3162 |
| 3170 #ifdef DEBUG | |
| 3171 LoadICNexus nexus(isolate); | 3163 LoadICNexus nexus(isolate); |
| 3172 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); | 3164 LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); |
| 3173 // It could actually be any kind of LoadICs here but the predicate handles | 3165 // It could actually be any kind of LoadICs here but the predicate handles |
| 3174 // all the cases properly. | 3166 // all the cases properly. |
| 3175 DCHECK(!ic.ShouldThrowReferenceError()); | 3167 if (!ic.ShouldThrowReferenceError()) { |
| 3176 #endif | 3168 return isolate->heap()->undefined_value(); |
| 3169 } |
| 3177 | 3170 |
| 3178 return isolate->heap()->undefined_value(); | 3171 // Throw a reference error. |
| 3172 THROW_NEW_ERROR_RETURN_FAILURE( |
| 3173 isolate, NewReferenceError(MessageTemplate::kNotDefined, it.name())); |
| 3179 } | 3174 } |
| 3180 | 3175 |
| 3181 | 3176 |
| 3182 RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { | 3177 RUNTIME_FUNCTION(Runtime_StorePropertyWithInterceptor) { |
| 3183 HandleScope scope(isolate); | 3178 HandleScope scope(isolate); |
| 3184 DCHECK(args.length() == 3); | 3179 DCHECK(args.length() == 3); |
| 3185 StoreICNexus nexus(isolate); | 3180 StoreICNexus nexus(isolate); |
| 3186 StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); | 3181 StoreIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); |
| 3187 Handle<JSObject> receiver = args.at<JSObject>(0); | 3182 Handle<JSObject> receiver = args.at<JSObject>(0); |
| 3188 Handle<Name> name = args.at<Name>(1); | 3183 Handle<Name> name = args.at<Name>(1); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3240 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); | 3235 DCHECK_EQ(LookupIterator::INTERCEPTOR, it.state()); |
| 3241 it.Next(); | 3236 it.Next(); |
| 3242 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, | 3237 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, |
| 3243 Object::GetProperty(&it)); | 3238 Object::GetProperty(&it)); |
| 3244 } | 3239 } |
| 3245 | 3240 |
| 3246 return *result; | 3241 return *result; |
| 3247 } | 3242 } |
| 3248 } // namespace internal | 3243 } // namespace internal |
| 3249 } // namespace v8 | 3244 } // namespace v8 |
| OLD | NEW |