| 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/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Code* IC::GetOriginalCode() const { | 202 Code* IC::GetOriginalCode() const { |
| 203 HandleScope scope(isolate()); | 203 HandleScope scope(isolate()); |
| 204 Handle<SharedFunctionInfo> shared(GetSharedFunctionInfo(), isolate()); | 204 Handle<SharedFunctionInfo> shared(GetSharedFunctionInfo(), isolate()); |
| 205 DCHECK(Debug::HasDebugInfo(shared)); | 205 DCHECK(Debug::HasDebugInfo(shared)); |
| 206 Code* original_code = Debug::GetDebugInfo(shared)->original_code(); | 206 Code* original_code = Debug::GetDebugInfo(shared)->original_code(); |
| 207 DCHECK(original_code->IsCode()); | 207 DCHECK(original_code->IsCode()); |
| 208 return original_code; | 208 return original_code; |
| 209 } | 209 } |
| 210 | 210 |
| 211 | 211 |
| 212 static void LookupForRead(LookupIterator* it) { | |
| 213 for (; it->IsFound(); it->Next()) { | |
| 214 switch (it->state()) { | |
| 215 case LookupIterator::NOT_FOUND: | |
| 216 case LookupIterator::TRANSITION: | |
| 217 UNREACHABLE(); | |
| 218 case LookupIterator::JSPROXY: | |
| 219 return; | |
| 220 case LookupIterator::INTERCEPTOR: { | |
| 221 // If there is a getter, return; otherwise loop to perform the lookup. | |
| 222 Handle<JSObject> holder = it->GetHolder<JSObject>(); | |
| 223 if (!holder->GetNamedInterceptor()->getter()->IsUndefined()) { | |
| 224 return; | |
| 225 } | |
| 226 break; | |
| 227 } | |
| 228 case LookupIterator::ACCESS_CHECK: | |
| 229 // PropertyHandlerCompiler::CheckPrototypes() knows how to emit | |
| 230 // access checks for global proxies. | |
| 231 if (it->GetHolder<JSObject>()->IsJSGlobalProxy() && | |
| 232 it->HasAccess(v8::ACCESS_GET)) { | |
| 233 break; | |
| 234 } | |
| 235 return; | |
| 236 case LookupIterator::PROPERTY: | |
| 237 if (it->HasProperty()) return; // Yay! | |
| 238 break; | |
| 239 } | |
| 240 } | |
| 241 } | |
| 242 | |
| 243 | |
| 244 bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, | 212 bool IC::TryRemoveInvalidPrototypeDependentStub(Handle<Object> receiver, |
| 245 Handle<String> name) { | 213 Handle<String> name) { |
| 246 if (!IsNameCompatibleWithPrototypeFailure(name)) return false; | 214 if (!IsNameCompatibleWithPrototypeFailure(name)) return false; |
| 247 Handle<Map> receiver_map = TypeToMap(*receiver_type(), isolate()); | 215 Handle<Map> receiver_map = TypeToMap(*receiver_type(), isolate()); |
| 248 maybe_handler_ = target()->FindHandlerForMap(*receiver_map); | 216 maybe_handler_ = target()->FindHandlerForMap(*receiver_map); |
| 249 | 217 |
| 250 // The current map wasn't handled yet. There's no reason to stay monomorphic, | 218 // The current map wasn't handled yet. There's no reason to stay monomorphic, |
| 251 // *unless* we're moving from a deprecated map to its replacement, or | 219 // *unless* we're moving from a deprecated map to its replacement, or |
| 252 // to a more general elements kind. | 220 // to a more general elements kind. |
| 253 // TODO(verwaest): Check if the current map is actually what the old map | 221 // TODO(verwaest): Check if the current map is actually what the old map |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 ASSIGN_RETURN_ON_EXCEPTION( | 565 ASSIGN_RETURN_ON_EXCEPTION( |
| 598 isolate(), result, | 566 isolate(), result, |
| 599 Runtime::GetElementOrCharAt(isolate(), object, index), Object); | 567 Runtime::GetElementOrCharAt(isolate(), object, index), Object); |
| 600 return result; | 568 return result; |
| 601 } | 569 } |
| 602 | 570 |
| 603 bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic; | 571 bool use_ic = MigrateDeprecated(object) ? false : FLAG_use_ic; |
| 604 | 572 |
| 605 // Named lookup in the object. | 573 // Named lookup in the object. |
| 606 LookupIterator it(object, name); | 574 LookupIterator it(object, name); |
| 607 LookupForRead(&it); | 575 it.LookupForRead(); |
| 608 | 576 |
| 609 if (it.IsFound() || !IsUndeclaredGlobal(object)) { | 577 if (it.IsFound() || !IsUndeclaredGlobal(object)) { |
| 610 // Update inline cache and stub cache. | 578 // Update inline cache and stub cache. |
| 611 if (use_ic) UpdateCaches(&it); | 579 if (use_ic) UpdateCaches(&it); |
| 612 | 580 |
| 613 // Get the property. | 581 // Get the property. |
| 614 Handle<Object> result; | 582 Handle<Object> result; |
| 615 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it), | 583 ASSIGN_RETURN_ON_EXCEPTION(isolate(), result, Object::GetProperty(&it), |
| 616 Object); | 584 Object); |
| 617 if (it.IsFound()) { | 585 if (it.IsFound()) { |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 bool receiver_is_holder = receiver.is_identical_to(holder); | 931 bool receiver_is_holder = receiver.is_identical_to(holder); |
| 964 // -------------- Interceptors -------------- | 932 // -------------- Interceptors -------------- |
| 965 if (lookup->state() == LookupIterator::INTERCEPTOR) { | 933 if (lookup->state() == LookupIterator::INTERCEPTOR) { |
| 966 DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined()); | 934 DCHECK(!holder->GetNamedInterceptor()->getter()->IsUndefined()); |
| 967 NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder, | 935 NamedLoadHandlerCompiler compiler(isolate(), receiver_type(), holder, |
| 968 cache_holder); | 936 cache_holder); |
| 969 // Perform a lookup behind the interceptor. Copy the LookupIterator since | 937 // Perform a lookup behind the interceptor. Copy the LookupIterator since |
| 970 // the original iterator will be used to fetch the value. | 938 // the original iterator will be used to fetch the value. |
| 971 LookupIterator it = *lookup; | 939 LookupIterator it = *lookup; |
| 972 it.Next(); | 940 it.Next(); |
| 973 LookupForRead(&it); | 941 it.LookupForRead(); |
| 974 return compiler.CompileLoadInterceptor(&it); | 942 return compiler.CompileLoadInterceptor(&it); |
| 975 } | 943 } |
| 976 | 944 |
| 977 // -------------- Accessors -------------- | 945 // -------------- Accessors -------------- |
| 978 DCHECK(lookup->state() == LookupIterator::PROPERTY); | 946 DCHECK(lookup->state() == LookupIterator::PROPERTY); |
| 979 if (lookup->property_kind() == LookupIterator::ACCESSOR) { | 947 if (lookup->property_kind() == LookupIterator::ACCESSOR) { |
| 980 // Use simple field loads for some well-known callback properties. | 948 // Use simple field loads for some well-known callback properties. |
| 981 if (receiver_is_holder) { | 949 if (receiver_is_holder) { |
| 982 DCHECK(receiver->IsJSObject()); | 950 DCHECK(receiver->IsJSObject()); |
| 983 Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver); | 951 Handle<JSObject> js_receiver = Handle<JSObject>::cast(receiver); |
| (...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3200 static const Address IC_utilities[] = { | 3168 static const Address IC_utilities[] = { |
| 3201 #define ADDR(name) FUNCTION_ADDR(name), | 3169 #define ADDR(name) FUNCTION_ADDR(name), |
| 3202 IC_UTIL_LIST(ADDR) NULL | 3170 IC_UTIL_LIST(ADDR) NULL |
| 3203 #undef ADDR | 3171 #undef ADDR |
| 3204 }; | 3172 }; |
| 3205 | 3173 |
| 3206 | 3174 |
| 3207 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3175 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 3208 } | 3176 } |
| 3209 } // namespace v8::internal | 3177 } // namespace v8::internal |
| OLD | NEW |