| 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/api.h" | 7 #include "src/api.h" |
| 8 #include "src/arguments.h" | 8 #include "src/arguments.h" |
| 9 #include "src/ast.h" | 9 #include "src/ast.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| 11 #include "src/cpu-profiler.h" | 11 #include "src/cpu-profiler.h" |
| 12 #include "src/gdb-jit.h" | 12 #include "src/gdb-jit.h" |
| 13 #include "src/ic-inl.h" | 13 #include "src/ic-inl.h" |
| 14 #include "src/stub-cache.h" | 14 #include "src/stub-cache.h" |
| 15 #include "src/type-info.h" | 15 #include "src/type-info.h" |
| 16 #include "src/vm-state-inl.h" | 16 #include "src/vm-state-inl.h" |
| 17 | 17 |
| 18 namespace v8 { | 18 namespace v8 { |
| 19 namespace internal { | 19 namespace internal { |
| 20 | 20 |
| 21 // ----------------------------------------------------------------------- | 21 // ----------------------------------------------------------------------- |
| 22 // StubCache implementation. | 22 // StubCache implementation. |
| 23 | 23 |
| 24 | 24 |
| 25 StubCache::StubCache(Isolate* isolate) | 25 StubCache::StubCache(Isolate* isolate) |
| 26 : isolate_(isolate) { } | 26 : isolate_(isolate) { } |
| 27 | 27 |
| 28 | 28 |
| 29 void StubCache::Initialize() { | 29 void StubCache::Initialize() { |
| 30 ASSERT(IsPowerOf2(kPrimaryTableSize)); | 30 DCHECK(IsPowerOf2(kPrimaryTableSize)); |
| 31 ASSERT(IsPowerOf2(kSecondaryTableSize)); | 31 DCHECK(IsPowerOf2(kSecondaryTableSize)); |
| 32 Clear(); | 32 Clear(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 | 35 |
| 36 static Code::Flags CommonStubCacheChecks(Name* name, Map* map, | 36 static Code::Flags CommonStubCacheChecks(Name* name, Map* map, |
| 37 Code::Flags flags) { | 37 Code::Flags flags) { |
| 38 flags = Code::RemoveTypeAndHolderFromFlags(flags); | 38 flags = Code::RemoveTypeAndHolderFromFlags(flags); |
| 39 | 39 |
| 40 // Validate that the name does not move on scavenge, and that we | 40 // Validate that the name does not move on scavenge, and that we |
| 41 // can use identity checks instead of structural equality checks. | 41 // can use identity checks instead of structural equality checks. |
| 42 ASSERT(!name->GetHeap()->InNewSpace(name)); | 42 DCHECK(!name->GetHeap()->InNewSpace(name)); |
| 43 ASSERT(name->IsUniqueName()); | 43 DCHECK(name->IsUniqueName()); |
| 44 | 44 |
| 45 // The state bits are not important to the hash function because the stub | 45 // The state bits are not important to the hash function because the stub |
| 46 // cache only contains handlers. Make sure that the bits are the least | 46 // cache only contains handlers. Make sure that the bits are the least |
| 47 // significant so they will be the ones masked out. | 47 // significant so they will be the ones masked out. |
| 48 ASSERT_EQ(Code::HANDLER, Code::ExtractKindFromFlags(flags)); | 48 DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(flags)); |
| 49 STATIC_ASSERT((Code::ICStateField::kMask & 1) == 1); | 49 STATIC_ASSERT((Code::ICStateField::kMask & 1) == 1); |
| 50 | 50 |
| 51 // Make sure that the code type and cache holder are not included in the hash. | 51 // Make sure that the code type and cache holder are not included in the hash. |
| 52 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); | 52 DCHECK(Code::ExtractTypeFromFlags(flags) == 0); |
| 53 ASSERT(Code::ExtractCacheHolderFromFlags(flags) == 0); | 53 DCHECK(Code::ExtractCacheHolderFromFlags(flags) == 0); |
| 54 | 54 |
| 55 return flags; | 55 return flags; |
| 56 } | 56 } |
| 57 | 57 |
| 58 | 58 |
| 59 Code* StubCache::Set(Name* name, Map* map, Code* code) { | 59 Code* StubCache::Set(Name* name, Map* map, Code* code) { |
| 60 Code::Flags flags = CommonStubCacheChecks(name, map, code->flags()); | 60 Code::Flags flags = CommonStubCacheChecks(name, map, code->flags()); |
| 61 | 61 |
| 62 // Compute the primary entry. | 62 // Compute the primary entry. |
| 63 int primary_offset = PrimaryOffset(name, flags, map); | 63 int primary_offset = PrimaryOffset(name, flags, map); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 // prototype cannot hold multiple handlers, one for each of the string maps, | 142 // prototype cannot hold multiple handlers, one for each of the string maps, |
| 143 // for a single name. Hence, turn off caching of the IC. | 143 // for a single name. Hence, turn off caching of the IC. |
| 144 bool can_be_cached = !type->Is(HeapType::String()); | 144 bool can_be_cached = !type->Is(HeapType::String()); |
| 145 if (can_be_cached) { | 145 if (can_be_cached) { |
| 146 ic = Find(name, stub_holder, kind, extra_ic_state, flag); | 146 ic = Find(name, stub_holder, kind, extra_ic_state, flag); |
| 147 if (!ic.is_null()) return ic; | 147 if (!ic.is_null()) return ic; |
| 148 } | 148 } |
| 149 | 149 |
| 150 #ifdef DEBUG | 150 #ifdef DEBUG |
| 151 if (kind == Code::KEYED_STORE_IC) { | 151 if (kind == Code::KEYED_STORE_IC) { |
| 152 ASSERT(STANDARD_STORE == | 152 DCHECK(STANDARD_STORE == |
| 153 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state)); | 153 KeyedStoreIC::GetKeyedAccessStoreMode(extra_ic_state)); |
| 154 } | 154 } |
| 155 #endif | 155 #endif |
| 156 | 156 |
| 157 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); | 157 PropertyICCompiler ic_compiler(isolate, kind, extra_ic_state, flag); |
| 158 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY); | 158 ic = ic_compiler.CompileMonomorphic(type, handler, name, PROPERTY); |
| 159 | 159 |
| 160 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); | 160 if (can_be_cached) Map::UpdateCodeCache(stub_holder, name, ic); |
| 161 return ic; | 161 return ic; |
| 162 } | 162 } |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 | 240 |
| 241 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( | 241 Handle<Code> PropertyICCompiler::ComputeKeyedStoreMonomorphic( |
| 242 Handle<Map> receiver_map, StrictMode strict_mode, | 242 Handle<Map> receiver_map, StrictMode strict_mode, |
| 243 KeyedAccessStoreMode store_mode) { | 243 KeyedAccessStoreMode store_mode) { |
| 244 Isolate* isolate = receiver_map->GetIsolate(); | 244 Isolate* isolate = receiver_map->GetIsolate(); |
| 245 ExtraICState extra_state = | 245 ExtraICState extra_state = |
| 246 KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); | 246 KeyedStoreIC::ComputeExtraICState(strict_mode, store_mode); |
| 247 Code::Flags flags = | 247 Code::Flags flags = |
| 248 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, extra_state); | 248 Code::ComputeMonomorphicFlags(Code::KEYED_STORE_IC, extra_state); |
| 249 | 249 |
| 250 ASSERT(store_mode == STANDARD_STORE || | 250 DCHECK(store_mode == STANDARD_STORE || |
| 251 store_mode == STORE_AND_GROW_NO_TRANSITION || | 251 store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 252 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 252 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 253 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 253 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
| 254 | 254 |
| 255 Handle<String> name = isolate->factory()->KeyedStoreMonomorphic_string(); | 255 Handle<String> name = isolate->factory()->KeyedStoreMonomorphic_string(); |
| 256 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); | 256 Handle<Object> probe(receiver_map->FindInCodeCache(*name, flags), isolate); |
| 257 if (probe->IsCode()) return Handle<Code>::cast(probe); | 257 if (probe->IsCode()) return Handle<Code>::cast(probe); |
| 258 | 258 |
| 259 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); | 259 PropertyICCompiler compiler(isolate, Code::KEYED_STORE_IC, extra_state); |
| 260 Handle<Code> code = | 260 Handle<Code> code = |
| 261 compiler.CompileKeyedStoreMonomorphic(receiver_map, store_mode); | 261 compiler.CompileKeyedStoreMonomorphic(receiver_map, store_mode); |
| 262 | 262 |
| 263 Map::UpdateCodeCache(receiver_map, name, code); | 263 Map::UpdateCodeCache(receiver_map, name, code); |
| 264 ASSERT(KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()) | 264 DCHECK(KeyedStoreIC::GetKeyedAccessStoreMode(code->extra_ic_state()) |
| 265 == store_mode); | 265 == store_mode); |
| 266 return code; | 266 return code; |
| 267 } | 267 } |
| 268 | 268 |
| 269 | 269 |
| 270 #define CALL_LOGGER_TAG(kind, type) (Logger::KEYED_##type) | 270 #define CALL_LOGGER_TAG(kind, type) (Logger::KEYED_##type) |
| 271 | 271 |
| 272 static void FillCache(Isolate* isolate, Handle<Code> code) { | 272 static void FillCache(Isolate* isolate, Handle<Code> code) { |
| 273 Handle<UnseededNumberDictionary> dictionary = | 273 Handle<UnseededNumberDictionary> dictionary = |
| 274 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), | 274 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), |
| 275 code->flags(), | 275 code->flags(), |
| 276 code); | 276 code); |
| 277 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 277 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
| 278 } | 278 } |
| 279 | 279 |
| 280 | 280 |
| 281 Code* PropertyICCompiler::FindPreMonomorphic(Isolate* isolate, Code::Kind kind, | 281 Code* PropertyICCompiler::FindPreMonomorphic(Isolate* isolate, Code::Kind kind, |
| 282 ExtraICState state) { | 282 ExtraICState state) { |
| 283 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); | 283 Code::Flags flags = Code::ComputeFlags(kind, PREMONOMORPHIC, state); |
| 284 UnseededNumberDictionary* dictionary = | 284 UnseededNumberDictionary* dictionary = |
| 285 isolate->heap()->non_monomorphic_cache(); | 285 isolate->heap()->non_monomorphic_cache(); |
| 286 int entry = dictionary->FindEntry(isolate, flags); | 286 int entry = dictionary->FindEntry(isolate, flags); |
| 287 ASSERT(entry != -1); | 287 DCHECK(entry != -1); |
| 288 Object* code = dictionary->ValueAt(entry); | 288 Object* code = dictionary->ValueAt(entry); |
| 289 // This might be called during the marking phase of the collector | 289 // This might be called during the marking phase of the collector |
| 290 // hence the unchecked cast. | 290 // hence the unchecked cast. |
| 291 return reinterpret_cast<Code*>(code); | 291 return reinterpret_cast<Code*>(code); |
| 292 } | 292 } |
| 293 | 293 |
| 294 | 294 |
| 295 Handle<Code> PropertyICCompiler::ComputeLoad(Isolate* isolate, | 295 Handle<Code> PropertyICCompiler::ComputeLoad(Isolate* isolate, |
| 296 InlineCacheState ic_state, | 296 InlineCacheState ic_state, |
| 297 ExtraICState extra_state) { | 297 ExtraICState extra_state) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); | 394 PolymorphicCodeCache::Update(cache, receiver_maps, flags, code); |
| 395 return code; | 395 return code; |
| 396 } | 396 } |
| 397 | 397 |
| 398 | 398 |
| 399 Handle<Code> PropertyICCompiler::ComputePolymorphic( | 399 Handle<Code> PropertyICCompiler::ComputePolymorphic( |
| 400 Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers, | 400 Code::Kind kind, TypeHandleList* types, CodeHandleList* handlers, |
| 401 int valid_types, Handle<Name> name, ExtraICState extra_ic_state) { | 401 int valid_types, Handle<Name> name, ExtraICState extra_ic_state) { |
| 402 Handle<Code> handler = handlers->at(0); | 402 Handle<Code> handler = handlers->at(0); |
| 403 Code::StubType type = valid_types == 1 ? handler->type() : Code::NORMAL; | 403 Code::StubType type = valid_types == 1 ? handler->type() : Code::NORMAL; |
| 404 ASSERT(kind == Code::LOAD_IC || kind == Code::STORE_IC); | 404 DCHECK(kind == Code::LOAD_IC || kind == Code::STORE_IC); |
| 405 PropertyICCompiler ic_compiler(name->GetIsolate(), kind, extra_ic_state); | 405 PropertyICCompiler ic_compiler(name->GetIsolate(), kind, extra_ic_state); |
| 406 return ic_compiler.CompilePolymorphic(types, handlers, name, type, PROPERTY); | 406 return ic_compiler.CompilePolymorphic(types, handlers, name, type, PROPERTY); |
| 407 } | 407 } |
| 408 | 408 |
| 409 | 409 |
| 410 Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic( | 410 Handle<Code> PropertyICCompiler::ComputeKeyedStorePolymorphic( |
| 411 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode, | 411 MapHandleList* receiver_maps, KeyedAccessStoreMode store_mode, |
| 412 StrictMode strict_mode) { | 412 StrictMode strict_mode) { |
| 413 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); | 413 Isolate* isolate = receiver_maps->at(0)->GetIsolate(); |
| 414 ASSERT(store_mode == STANDARD_STORE || | 414 DCHECK(store_mode == STANDARD_STORE || |
| 415 store_mode == STORE_AND_GROW_NO_TRANSITION || | 415 store_mode == STORE_AND_GROW_NO_TRANSITION || |
| 416 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || | 416 store_mode == STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS || |
| 417 store_mode == STORE_NO_TRANSITION_HANDLE_COW); | 417 store_mode == STORE_NO_TRANSITION_HANDLE_COW); |
| 418 Handle<PolymorphicCodeCache> cache = | 418 Handle<PolymorphicCodeCache> cache = |
| 419 isolate->factory()->polymorphic_code_cache(); | 419 isolate->factory()->polymorphic_code_cache(); |
| 420 ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState( | 420 ExtraICState extra_state = KeyedStoreIC::ComputeExtraICState( |
| 421 strict_mode, store_mode); | 421 strict_mode, store_mode); |
| 422 Code::Flags flags = | 422 Code::Flags flags = |
| 423 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); | 423 Code::ComputeFlags(Code::KEYED_STORE_IC, POLYMORPHIC, extra_state); |
| 424 Handle<Object> probe = cache->Lookup(receiver_maps, flags); | 424 Handle<Object> probe = cache->Lookup(receiver_maps, flags); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 493 |
| 494 | 494 |
| 495 RUNTIME_FUNCTION(StoreCallbackProperty) { | 495 RUNTIME_FUNCTION(StoreCallbackProperty) { |
| 496 Handle<JSObject> receiver = args.at<JSObject>(0); | 496 Handle<JSObject> receiver = args.at<JSObject>(0); |
| 497 Handle<JSObject> holder = args.at<JSObject>(1); | 497 Handle<JSObject> holder = args.at<JSObject>(1); |
| 498 Handle<ExecutableAccessorInfo> callback = args.at<ExecutableAccessorInfo>(2); | 498 Handle<ExecutableAccessorInfo> callback = args.at<ExecutableAccessorInfo>(2); |
| 499 Handle<Name> name = args.at<Name>(3); | 499 Handle<Name> name = args.at<Name>(3); |
| 500 Handle<Object> value = args.at<Object>(4); | 500 Handle<Object> value = args.at<Object>(4); |
| 501 HandleScope scope(isolate); | 501 HandleScope scope(isolate); |
| 502 | 502 |
| 503 ASSERT(callback->IsCompatibleReceiver(*receiver)); | 503 DCHECK(callback->IsCompatibleReceiver(*receiver)); |
| 504 | 504 |
| 505 Address setter_address = v8::ToCData<Address>(callback->setter()); | 505 Address setter_address = v8::ToCData<Address>(callback->setter()); |
| 506 v8::AccessorSetterCallback fun = | 506 v8::AccessorSetterCallback fun = |
| 507 FUNCTION_CAST<v8::AccessorSetterCallback>(setter_address); | 507 FUNCTION_CAST<v8::AccessorSetterCallback>(setter_address); |
| 508 ASSERT(fun != NULL); | 508 DCHECK(fun != NULL); |
| 509 | 509 |
| 510 // TODO(rossberg): Support symbols in the API. | 510 // TODO(rossberg): Support symbols in the API. |
| 511 if (name->IsSymbol()) return *value; | 511 if (name->IsSymbol()) return *value; |
| 512 Handle<String> str = Handle<String>::cast(name); | 512 Handle<String> str = Handle<String>::cast(name); |
| 513 | 513 |
| 514 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); | 514 LOG(isolate, ApiNamedPropertyAccess("store", *receiver, *name)); |
| 515 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, | 515 PropertyCallbackArguments custom_args(isolate, callback->data(), *receiver, |
| 516 *holder); | 516 *holder); |
| 517 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); | 517 custom_args.Call(fun, v8::Utils::ToLocal(str), v8::Utils::ToLocal(value)); |
| 518 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); | 518 RETURN_FAILURE_IF_SCHEDULED_EXCEPTION(isolate); |
| 519 return *value; | 519 return *value; |
| 520 } | 520 } |
| 521 | 521 |
| 522 | 522 |
| 523 /** | 523 /** |
| 524 * Attempts to load a property with an interceptor (which must be present), | 524 * Attempts to load a property with an interceptor (which must be present), |
| 525 * but doesn't search the prototype chain. | 525 * but doesn't search the prototype chain. |
| 526 * | 526 * |
| 527 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't | 527 * Returns |Heap::no_interceptor_result_sentinel()| if interceptor doesn't |
| 528 * provide any value for the given name. | 528 * provide any value for the given name. |
| 529 */ | 529 */ |
| 530 RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) { | 530 RUNTIME_FUNCTION(LoadPropertyWithInterceptorOnly) { |
| 531 ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 531 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
| 532 Handle<Name> name_handle = | 532 Handle<Name> name_handle = |
| 533 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); | 533 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); |
| 534 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>( | 534 Handle<InterceptorInfo> interceptor_info = args.at<InterceptorInfo>( |
| 535 NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex); | 535 NamedLoadHandlerCompiler::kInterceptorArgsInfoIndex); |
| 536 | 536 |
| 537 // TODO(rossberg): Support symbols in the API. | 537 // TODO(rossberg): Support symbols in the API. |
| 538 if (name_handle->IsSymbol()) | 538 if (name_handle->IsSymbol()) |
| 539 return isolate->heap()->no_interceptor_result_sentinel(); | 539 return isolate->heap()->no_interceptor_result_sentinel(); |
| 540 Handle<String> name = Handle<String>::cast(name_handle); | 540 Handle<String> name = Handle<String>::cast(name_handle); |
| 541 | 541 |
| 542 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); | 542 Address getter_address = v8::ToCData<Address>(interceptor_info->getter()); |
| 543 v8::NamedPropertyGetterCallback getter = | 543 v8::NamedPropertyGetterCallback getter = |
| 544 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); | 544 FUNCTION_CAST<v8::NamedPropertyGetterCallback>(getter_address); |
| 545 ASSERT(getter != NULL); | 545 DCHECK(getter != NULL); |
| 546 | 546 |
| 547 Handle<JSObject> receiver = | 547 Handle<JSObject> receiver = |
| 548 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); | 548 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); |
| 549 Handle<JSObject> holder = | 549 Handle<JSObject> holder = |
| 550 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); | 550 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); |
| 551 PropertyCallbackArguments callback_args( | 551 PropertyCallbackArguments callback_args( |
| 552 isolate, interceptor_info->data(), *receiver, *holder); | 552 isolate, interceptor_info->data(), *receiver, *holder); |
| 553 { | 553 { |
| 554 // Use the interceptor getter. | 554 // Use the interceptor getter. |
| 555 HandleScope scope(isolate); | 555 HandleScope scope(isolate); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 584 return isolate->Throw(*error); | 584 return isolate->Throw(*error); |
| 585 } | 585 } |
| 586 | 586 |
| 587 | 587 |
| 588 /** | 588 /** |
| 589 * Loads a property with an interceptor performing post interceptor | 589 * Loads a property with an interceptor performing post interceptor |
| 590 * lookup if interceptor failed. | 590 * lookup if interceptor failed. |
| 591 */ | 591 */ |
| 592 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { | 592 RUNTIME_FUNCTION(LoadPropertyWithInterceptor) { |
| 593 HandleScope scope(isolate); | 593 HandleScope scope(isolate); |
| 594 ASSERT(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); | 594 DCHECK(args.length() == NamedLoadHandlerCompiler::kInterceptorArgsLength); |
| 595 Handle<Name> name = | 595 Handle<Name> name = |
| 596 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); | 596 args.at<Name>(NamedLoadHandlerCompiler::kInterceptorArgsNameIndex); |
| 597 Handle<JSObject> receiver = | 597 Handle<JSObject> receiver = |
| 598 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); | 598 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsThisIndex); |
| 599 Handle<JSObject> holder = | 599 Handle<JSObject> holder = |
| 600 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); | 600 args.at<JSObject>(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex); |
| 601 | 601 |
| 602 Handle<Object> result; | 602 Handle<Object> result; |
| 603 LookupIterator it(receiver, name, holder); | 603 LookupIterator it(receiver, name, holder); |
| 604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 604 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 605 isolate, result, JSObject::GetProperty(&it)); | 605 isolate, result, JSObject::GetProperty(&it)); |
| 606 | 606 |
| 607 if (it.IsFound()) return *result; | 607 if (it.IsFound()) return *result; |
| 608 | 608 |
| 609 return ThrowReferenceError(isolate, Name::cast(args[0])); | 609 return ThrowReferenceError(isolate, Name::cast(args[0])); |
| 610 } | 610 } |
| 611 | 611 |
| 612 | 612 |
| 613 RUNTIME_FUNCTION(StorePropertyWithInterceptor) { | 613 RUNTIME_FUNCTION(StorePropertyWithInterceptor) { |
| 614 HandleScope scope(isolate); | 614 HandleScope scope(isolate); |
| 615 ASSERT(args.length() == 3); | 615 DCHECK(args.length() == 3); |
| 616 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); | 616 StoreIC ic(IC::NO_EXTRA_FRAME, isolate); |
| 617 Handle<JSObject> receiver = args.at<JSObject>(0); | 617 Handle<JSObject> receiver = args.at<JSObject>(0); |
| 618 Handle<Name> name = args.at<Name>(1); | 618 Handle<Name> name = args.at<Name>(1); |
| 619 Handle<Object> value = args.at<Object>(2); | 619 Handle<Object> value = args.at<Object>(2); |
| 620 #ifdef DEBUG | 620 #ifdef DEBUG |
| 621 if (receiver->IsJSGlobalProxy()) { | 621 if (receiver->IsJSGlobalProxy()) { |
| 622 PrototypeIterator iter(isolate, receiver); | 622 PrototypeIterator iter(isolate, receiver); |
| 623 ASSERT(iter.IsAtEnd() || | 623 DCHECK(iter.IsAtEnd() || |
| 624 Handle<JSGlobalObject>::cast(PrototypeIterator::GetCurrent(iter)) | 624 Handle<JSGlobalObject>::cast(PrototypeIterator::GetCurrent(iter)) |
| 625 ->HasNamedInterceptor()); | 625 ->HasNamedInterceptor()); |
| 626 } else { | 626 } else { |
| 627 ASSERT(receiver->HasNamedInterceptor()); | 627 DCHECK(receiver->HasNamedInterceptor()); |
| 628 } | 628 } |
| 629 #endif | 629 #endif |
| 630 Handle<Object> result; | 630 Handle<Object> result; |
| 631 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 631 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 632 isolate, result, | 632 isolate, result, |
| 633 JSObject::SetProperty(receiver, name, value, ic.strict_mode())); | 633 JSObject::SetProperty(receiver, name, value, ic.strict_mode())); |
| 634 return *result; | 634 return *result; |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 RUNTIME_FUNCTION(LoadElementWithInterceptor) { | 638 RUNTIME_FUNCTION(LoadElementWithInterceptor) { |
| 639 HandleScope scope(isolate); | 639 HandleScope scope(isolate); |
| 640 Handle<JSObject> receiver = args.at<JSObject>(0); | 640 Handle<JSObject> receiver = args.at<JSObject>(0); |
| 641 ASSERT(args.smi_at(1) >= 0); | 641 DCHECK(args.smi_at(1) >= 0); |
| 642 uint32_t index = args.smi_at(1); | 642 uint32_t index = args.smi_at(1); |
| 643 Handle<Object> result; | 643 Handle<Object> result; |
| 644 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 644 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
| 645 isolate, result, | 645 isolate, result, |
| 646 JSObject::GetElementWithInterceptor(receiver, receiver, index)); | 646 JSObject::GetElementWithInterceptor(receiver, receiver, index)); |
| 647 return *result; | 647 return *result; |
| 648 } | 648 } |
| 649 | 649 |
| 650 | 650 |
| 651 Handle<Code> PropertyICCompiler::CompileLoadInitialize(Code::Flags flags) { | 651 Handle<Code> PropertyICCompiler::CompileLoadInitialize(Code::Flags flags) { |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 807 Label* miss, | 807 Label* miss, |
| 808 Register scratch1, | 808 Register scratch1, |
| 809 Register scratch2) { | 809 Register scratch2) { |
| 810 Register holder_reg; | 810 Register holder_reg; |
| 811 Handle<Map> last_map; | 811 Handle<Map> last_map; |
| 812 if (holder().is_null()) { | 812 if (holder().is_null()) { |
| 813 holder_reg = receiver(); | 813 holder_reg = receiver(); |
| 814 last_map = IC::TypeToMap(*type(), isolate()); | 814 last_map = IC::TypeToMap(*type(), isolate()); |
| 815 // If |type| has null as its prototype, |holder()| is | 815 // If |type| has null as its prototype, |holder()| is |
| 816 // Handle<JSObject>::null(). | 816 // Handle<JSObject>::null(). |
| 817 ASSERT(last_map->prototype() == isolate()->heap()->null_value()); | 817 DCHECK(last_map->prototype() == isolate()->heap()->null_value()); |
| 818 } else { | 818 } else { |
| 819 holder_reg = FrontendHeader(receiver(), name, miss); | 819 holder_reg = FrontendHeader(receiver(), name, miss); |
| 820 last_map = handle(holder()->map()); | 820 last_map = handle(holder()->map()); |
| 821 } | 821 } |
| 822 | 822 |
| 823 if (last_map->is_dictionary_map()) { | 823 if (last_map->is_dictionary_map()) { |
| 824 if (last_map->IsJSGlobalObjectMap()) { | 824 if (last_map->IsJSGlobalObjectMap()) { |
| 825 Handle<JSGlobalObject> global = | 825 Handle<JSGlobalObject> global = |
| 826 holder().is_null() | 826 holder().is_null() |
| 827 ? Handle<JSGlobalObject>::cast(type()->AsConstant()->Value()) | 827 ? Handle<JSGlobalObject>::cast(type()->AsConstant()->Value()) |
| 828 : Handle<JSGlobalObject>::cast(holder()); | 828 : Handle<JSGlobalObject>::cast(holder()); |
| 829 GenerateCheckPropertyCell(masm(), global, name, scratch1, miss); | 829 GenerateCheckPropertyCell(masm(), global, name, scratch1, miss); |
| 830 } else { | 830 } else { |
| 831 if (!name->IsUniqueName()) { | 831 if (!name->IsUniqueName()) { |
| 832 ASSERT(name->IsString()); | 832 DCHECK(name->IsString()); |
| 833 name = factory()->InternalizeString(Handle<String>::cast(name)); | 833 name = factory()->InternalizeString(Handle<String>::cast(name)); |
| 834 } | 834 } |
| 835 ASSERT(holder().is_null() || | 835 DCHECK(holder().is_null() || |
| 836 holder()->property_dictionary()->FindEntry(name) == | 836 holder()->property_dictionary()->FindEntry(name) == |
| 837 NameDictionary::kNotFound); | 837 NameDictionary::kNotFound); |
| 838 GenerateDictionaryNegativeLookup(masm(), miss, holder_reg, name, scratch1, | 838 GenerateDictionaryNegativeLookup(masm(), miss, holder_reg, name, scratch1, |
| 839 scratch2); | 839 scratch2); |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 } | 842 } |
| 843 | 843 |
| 844 | 844 |
| 845 Handle<Code> NamedLoadHandlerCompiler::CompileLoadField( | 845 Handle<Code> NamedLoadHandlerCompiler::CompileLoadField( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 871 Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback( | 871 Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback( |
| 872 Handle<Name> name, Handle<ExecutableAccessorInfo> callback) { | 872 Handle<Name> name, Handle<ExecutableAccessorInfo> callback) { |
| 873 Register reg = CallbackFrontend(receiver(), name, callback); | 873 Register reg = CallbackFrontend(receiver(), name, callback); |
| 874 GenerateLoadCallback(reg, callback); | 874 GenerateLoadCallback(reg, callback); |
| 875 return GetCode(kind(), Code::FAST, name); | 875 return GetCode(kind(), Code::FAST, name); |
| 876 } | 876 } |
| 877 | 877 |
| 878 | 878 |
| 879 Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback( | 879 Handle<Code> NamedLoadHandlerCompiler::CompileLoadCallback( |
| 880 Handle<Name> name, const CallOptimization& call_optimization) { | 880 Handle<Name> name, const CallOptimization& call_optimization) { |
| 881 ASSERT(call_optimization.is_simple_api_call()); | 881 DCHECK(call_optimization.is_simple_api_call()); |
| 882 Handle<JSFunction> callback = call_optimization.constant_function(); | 882 Handle<JSFunction> callback = call_optimization.constant_function(); |
| 883 CallbackFrontend(receiver(), name, callback); | 883 CallbackFrontend(receiver(), name, callback); |
| 884 Handle<Map> receiver_map = IC::TypeToMap(*type(), isolate()); | 884 Handle<Map> receiver_map = IC::TypeToMap(*type(), isolate()); |
| 885 GenerateFastApiCall( | 885 GenerateFastApiCall( |
| 886 masm(), call_optimization, receiver_map, | 886 masm(), call_optimization, receiver_map, |
| 887 receiver(), scratch1(), false, 0, NULL); | 887 receiver(), scratch1(), false, 0, NULL); |
| 888 return GetCode(kind(), Code::FAST, name); | 888 return GetCode(kind(), Code::FAST, name); |
| 889 } | 889 } |
| 890 | 890 |
| 891 | 891 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 917 if (holder().is_identical_to(real_named_property_holder)) { | 917 if (holder().is_identical_to(real_named_property_holder)) { |
| 918 GenerateLoadField(interceptor_reg, field, lookup->representation()); | 918 GenerateLoadField(interceptor_reg, field, lookup->representation()); |
| 919 } else { | 919 } else { |
| 920 set_type_for_object(holder()); | 920 set_type_for_object(holder()); |
| 921 set_holder(real_named_property_holder); | 921 set_holder(real_named_property_holder); |
| 922 Register reg = Frontend(interceptor_reg, name); | 922 Register reg = Frontend(interceptor_reg, name); |
| 923 GenerateLoadField(reg, field, lookup->representation()); | 923 GenerateLoadField(reg, field, lookup->representation()); |
| 924 } | 924 } |
| 925 } else { | 925 } else { |
| 926 // We found CALLBACKS property in prototype chain of interceptor's holder. | 926 // We found CALLBACKS property in prototype chain of interceptor's holder. |
| 927 ASSERT(lookup->type() == CALLBACKS); | 927 DCHECK(lookup->type() == CALLBACKS); |
| 928 Handle<ExecutableAccessorInfo> callback( | 928 Handle<ExecutableAccessorInfo> callback( |
| 929 ExecutableAccessorInfo::cast(lookup->GetCallbackObject())); | 929 ExecutableAccessorInfo::cast(lookup->GetCallbackObject())); |
| 930 ASSERT(callback->getter() != NULL); | 930 DCHECK(callback->getter() != NULL); |
| 931 | 931 |
| 932 set_type_for_object(holder()); | 932 set_type_for_object(holder()); |
| 933 set_holder(real_named_property_holder); | 933 set_holder(real_named_property_holder); |
| 934 Register reg = CallbackFrontend(interceptor_reg, name, callback); | 934 Register reg = CallbackFrontend(interceptor_reg, name, callback); |
| 935 GenerateLoadCallback(reg, callback); | 935 GenerateLoadCallback(reg, callback); |
| 936 } | 936 } |
| 937 } | 937 } |
| 938 | 938 |
| 939 | 939 |
| 940 Handle<Code> PropertyICCompiler::CompileMonomorphic(Handle<HeapType> type, | 940 Handle<Code> PropertyICCompiler::CompileMonomorphic(Handle<HeapType> type, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 Handle<JSObject> last; | 973 Handle<JSObject> last; |
| 974 PrototypeIterator iter(isolate(), holder()); | 974 PrototypeIterator iter(isolate(), holder()); |
| 975 while (!iter.IsAtEnd()) { | 975 while (!iter.IsAtEnd()) { |
| 976 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); | 976 last = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
| 977 iter.Advance(); | 977 iter.Advance(); |
| 978 } | 978 } |
| 979 if (!last.is_null()) set_holder(last); | 979 if (!last.is_null()) set_holder(last); |
| 980 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2()); | 980 NonexistentFrontendHeader(name, &miss, scratch1(), scratch2()); |
| 981 } else { | 981 } else { |
| 982 FrontendHeader(receiver(), name, &miss); | 982 FrontendHeader(receiver(), name, &miss); |
| 983 ASSERT(holder()->HasFastProperties()); | 983 DCHECK(holder()->HasFastProperties()); |
| 984 } | 984 } |
| 985 | 985 |
| 986 GenerateStoreTransition(transition, name, receiver(), this->name(), value(), | 986 GenerateStoreTransition(transition, name, receiver(), this->name(), value(), |
| 987 scratch1(), scratch2(), scratch3(), &miss, &slow); | 987 scratch1(), scratch2(), scratch3(), &miss, &slow); |
| 988 | 988 |
| 989 GenerateRestoreName(&miss, name); | 989 GenerateRestoreName(&miss, name); |
| 990 TailCallBuiltin(masm(), MissBuiltin(kind())); | 990 TailCallBuiltin(masm(), MissBuiltin(kind())); |
| 991 | 991 |
| 992 GenerateRestoreName(&slow, name); | 992 GenerateRestoreName(&slow, name); |
| 993 TailCallBuiltin(masm(), SlowBuiltin(kind())); | 993 TailCallBuiltin(masm(), SlowBuiltin(kind())); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 Builtins::Name name) { | 1063 Builtins::Name name) { |
| 1064 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); | 1064 Handle<Code> code(masm->isolate()->builtins()->builtin(name)); |
| 1065 GenerateTailCall(masm, code); | 1065 GenerateTailCall(masm, code); |
| 1066 } | 1066 } |
| 1067 | 1067 |
| 1068 | 1068 |
| 1069 Register* PropertyAccessCompiler::GetCallingConvention(Code::Kind kind) { | 1069 Register* PropertyAccessCompiler::GetCallingConvention(Code::Kind kind) { |
| 1070 if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) { | 1070 if (kind == Code::LOAD_IC || kind == Code::KEYED_LOAD_IC) { |
| 1071 return load_calling_convention(); | 1071 return load_calling_convention(); |
| 1072 } | 1072 } |
| 1073 ASSERT(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC); | 1073 DCHECK(kind == Code::STORE_IC || kind == Code::KEYED_STORE_IC); |
| 1074 return store_calling_convention(); | 1074 return store_calling_convention(); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 | 1077 |
| 1078 Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Code::StubType type, | 1078 Handle<Code> PropertyICCompiler::GetCode(Code::Kind kind, Code::StubType type, |
| 1079 Handle<Name> name, | 1079 Handle<Name> name, |
| 1080 InlineCacheState state) { | 1080 InlineCacheState state) { |
| 1081 Code::Flags flags = | 1081 Code::Flags flags = |
| 1082 Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder()); | 1082 Code::ComputeFlags(kind, state, extra_ic_state_, type, cache_holder()); |
| 1083 Handle<Code> code = GetCodeWithFlags(flags, name); | 1083 Handle<Code> code = GetCodeWithFlags(flags, name); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1112 ElementsKind elements_kind = receiver_map->elements_kind(); | 1112 ElementsKind elements_kind = receiver_map->elements_kind(); |
| 1113 | 1113 |
| 1114 if (IsFastElementsKind(elements_kind) || | 1114 if (IsFastElementsKind(elements_kind) || |
| 1115 IsExternalArrayElementsKind(elements_kind) || | 1115 IsExternalArrayElementsKind(elements_kind) || |
| 1116 IsFixedTypedArrayElementsKind(elements_kind)) { | 1116 IsFixedTypedArrayElementsKind(elements_kind)) { |
| 1117 cached_stub = LoadFastElementStub(isolate(), is_js_array, elements_kind) | 1117 cached_stub = LoadFastElementStub(isolate(), is_js_array, elements_kind) |
| 1118 .GetCode(); | 1118 .GetCode(); |
| 1119 } else if (elements_kind == SLOPPY_ARGUMENTS_ELEMENTS) { | 1119 } else if (elements_kind == SLOPPY_ARGUMENTS_ELEMENTS) { |
| 1120 cached_stub = isolate()->builtins()->KeyedLoadIC_SloppyArguments(); | 1120 cached_stub = isolate()->builtins()->KeyedLoadIC_SloppyArguments(); |
| 1121 } else { | 1121 } else { |
| 1122 ASSERT(elements_kind == DICTIONARY_ELEMENTS); | 1122 DCHECK(elements_kind == DICTIONARY_ELEMENTS); |
| 1123 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); | 1123 cached_stub = LoadDictionaryElementStub(isolate()).GetCode(); |
| 1124 } | 1124 } |
| 1125 } | 1125 } |
| 1126 | 1126 |
| 1127 handlers->Add(cached_stub); | 1127 handlers->Add(cached_stub); |
| 1128 } | 1128 } |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 | 1131 |
| 1132 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | 1132 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1158 if (receiver_map->has_fast_elements() || | 1158 if (receiver_map->has_fast_elements() || |
| 1159 receiver_map->has_external_array_elements() || | 1159 receiver_map->has_external_array_elements() || |
| 1160 receiver_map->has_fixed_typed_array_elements()) { | 1160 receiver_map->has_fixed_typed_array_elements()) { |
| 1161 cached_stub = StoreFastElementStub(isolate(), is_js_array, | 1161 cached_stub = StoreFastElementStub(isolate(), is_js_array, |
| 1162 elements_kind, store_mode).GetCode(); | 1162 elements_kind, store_mode).GetCode(); |
| 1163 } else { | 1163 } else { |
| 1164 cached_stub = StoreElementStub(isolate(), is_js_array, elements_kind, | 1164 cached_stub = StoreElementStub(isolate(), is_js_array, elements_kind, |
| 1165 store_mode).GetCode(); | 1165 store_mode).GetCode(); |
| 1166 } | 1166 } |
| 1167 } | 1167 } |
| 1168 ASSERT(!cached_stub.is_null()); | 1168 DCHECK(!cached_stub.is_null()); |
| 1169 handlers.Add(cached_stub); | 1169 handlers.Add(cached_stub); |
| 1170 transitioned_maps.Add(transitioned_map); | 1170 transitioned_maps.Add(transitioned_map); |
| 1171 } | 1171 } |
| 1172 | 1172 |
| 1173 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers, | 1173 Handle<Code> code = CompileKeyedStorePolymorphic(receiver_maps, &handlers, |
| 1174 &transitioned_maps); | 1174 &transitioned_maps); |
| 1175 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); | 1175 isolate()->counters()->keyed_store_polymorphic_stubs()->Increment(); |
| 1176 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0)); | 1176 PROFILE(isolate(), CodeCreateEvent(log_kind(code), *code, 0)); |
| 1177 return code; | 1177 return code; |
| 1178 } | 1178 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1197 | 1197 |
| 1198 | 1198 |
| 1199 CallOptimization::CallOptimization(Handle<JSFunction> function) { | 1199 CallOptimization::CallOptimization(Handle<JSFunction> function) { |
| 1200 Initialize(function); | 1200 Initialize(function); |
| 1201 } | 1201 } |
| 1202 | 1202 |
| 1203 | 1203 |
| 1204 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( | 1204 Handle<JSObject> CallOptimization::LookupHolderOfExpectedType( |
| 1205 Handle<Map> object_map, | 1205 Handle<Map> object_map, |
| 1206 HolderLookup* holder_lookup) const { | 1206 HolderLookup* holder_lookup) const { |
| 1207 ASSERT(is_simple_api_call()); | 1207 DCHECK(is_simple_api_call()); |
| 1208 if (!object_map->IsJSObjectMap()) { | 1208 if (!object_map->IsJSObjectMap()) { |
| 1209 *holder_lookup = kHolderNotFound; | 1209 *holder_lookup = kHolderNotFound; |
| 1210 return Handle<JSObject>::null(); | 1210 return Handle<JSObject>::null(); |
| 1211 } | 1211 } |
| 1212 if (expected_receiver_type_.is_null() || | 1212 if (expected_receiver_type_.is_null() || |
| 1213 expected_receiver_type_->IsTemplateFor(*object_map)) { | 1213 expected_receiver_type_->IsTemplateFor(*object_map)) { |
| 1214 *holder_lookup = kHolderIsReceiver; | 1214 *holder_lookup = kHolderIsReceiver; |
| 1215 return Handle<JSObject>::null(); | 1215 return Handle<JSObject>::null(); |
| 1216 } | 1216 } |
| 1217 while (true) { | 1217 while (true) { |
| 1218 if (!object_map->prototype()->IsJSObject()) break; | 1218 if (!object_map->prototype()->IsJSObject()) break; |
| 1219 Handle<JSObject> prototype(JSObject::cast(object_map->prototype())); | 1219 Handle<JSObject> prototype(JSObject::cast(object_map->prototype())); |
| 1220 if (!prototype->map()->is_hidden_prototype()) break; | 1220 if (!prototype->map()->is_hidden_prototype()) break; |
| 1221 object_map = handle(prototype->map()); | 1221 object_map = handle(prototype->map()); |
| 1222 if (expected_receiver_type_->IsTemplateFor(*object_map)) { | 1222 if (expected_receiver_type_->IsTemplateFor(*object_map)) { |
| 1223 *holder_lookup = kHolderFound; | 1223 *holder_lookup = kHolderFound; |
| 1224 return prototype; | 1224 return prototype; |
| 1225 } | 1225 } |
| 1226 } | 1226 } |
| 1227 *holder_lookup = kHolderNotFound; | 1227 *holder_lookup = kHolderNotFound; |
| 1228 return Handle<JSObject>::null(); | 1228 return Handle<JSObject>::null(); |
| 1229 } | 1229 } |
| 1230 | 1230 |
| 1231 | 1231 |
| 1232 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver, | 1232 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver, |
| 1233 Handle<JSObject> holder) const { | 1233 Handle<JSObject> holder) const { |
| 1234 ASSERT(is_simple_api_call()); | 1234 DCHECK(is_simple_api_call()); |
| 1235 if (!receiver->IsJSObject()) return false; | 1235 if (!receiver->IsJSObject()) return false; |
| 1236 Handle<Map> map(JSObject::cast(*receiver)->map()); | 1236 Handle<Map> map(JSObject::cast(*receiver)->map()); |
| 1237 HolderLookup holder_lookup; | 1237 HolderLookup holder_lookup; |
| 1238 Handle<JSObject> api_holder = | 1238 Handle<JSObject> api_holder = |
| 1239 LookupHolderOfExpectedType(map, &holder_lookup); | 1239 LookupHolderOfExpectedType(map, &holder_lookup); |
| 1240 switch (holder_lookup) { | 1240 switch (holder_lookup) { |
| 1241 case kHolderNotFound: | 1241 case kHolderNotFound: |
| 1242 return false; | 1242 return false; |
| 1243 case kHolderIsReceiver: | 1243 case kHolderIsReceiver: |
| 1244 return true; | 1244 return true; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1294 Handle<FunctionTemplateInfo>( | 1294 Handle<FunctionTemplateInfo>( |
| 1295 FunctionTemplateInfo::cast(signature->receiver())); | 1295 FunctionTemplateInfo::cast(signature->receiver())); |
| 1296 } | 1296 } |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 is_simple_api_call_ = true; | 1299 is_simple_api_call_ = true; |
| 1300 } | 1300 } |
| 1301 | 1301 |
| 1302 | 1302 |
| 1303 } } // namespace v8::internal | 1303 } } // namespace v8::internal |
| OLD | NEW |