| 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 #if V8_TARGET_ARCH_IA32 | 5 #if V8_TARGET_ARCH_IA32 |
| 6 | 6 |
| 7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
| 8 #include "src/bootstrapper.h" | 8 #include "src/bootstrapper.h" |
| 9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 2546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2557 __ bind(&function_prototype_valid); | 2557 __ bind(&function_prototype_valid); |
| 2558 __ AssertNotSmi(function_prototype); | 2558 __ AssertNotSmi(function_prototype); |
| 2559 | 2559 |
| 2560 // Update the global instanceof cache with the current {object} map and | 2560 // Update the global instanceof cache with the current {object} map and |
| 2561 // {function}. The cached answer will be set when it is known below. | 2561 // {function}. The cached answer will be set when it is known below. |
| 2562 __ StoreRoot(function, scratch, Heap::kInstanceofCacheFunctionRootIndex); | 2562 __ StoreRoot(function, scratch, Heap::kInstanceofCacheFunctionRootIndex); |
| 2563 __ StoreRoot(object_map, scratch, Heap::kInstanceofCacheMapRootIndex); | 2563 __ StoreRoot(object_map, scratch, Heap::kInstanceofCacheMapRootIndex); |
| 2564 | 2564 |
| 2565 // Loop through the prototype chain looking for the {function} prototype. | 2565 // Loop through the prototype chain looking for the {function} prototype. |
| 2566 // Assume true, and change to false if not found. | 2566 // Assume true, and change to false if not found. |
| 2567 Label done, loop, proxy_case; | 2567 Label done, loop, proxy_case, global_object_case; |
| 2568 __ mov(eax, isolate()->factory()->true_value()); | 2568 __ mov(eax, isolate()->factory()->true_value()); |
| 2569 __ bind(&loop); | 2569 __ bind(&loop); |
| 2570 __ CmpInstanceType(object_map, JS_GLOBAL_OBJECT_TYPE); |
| 2571 __ j(equal, &global_object_case); |
| 2572 __ CmpInstanceType(object_map, JS_GLOBAL_PROXY_TYPE); |
| 2573 __ j(equal, &global_object_case); |
| 2570 __ CmpInstanceType(object_map, JS_PROXY_TYPE); | 2574 __ CmpInstanceType(object_map, JS_PROXY_TYPE); |
| 2571 __ j(equal, &proxy_case, Label::kNear); | 2575 __ j(equal, &proxy_case, Label::kNear); |
| 2572 __ mov(object, FieldOperand(object_map, Map::kPrototypeOffset)); | 2576 __ mov(object, FieldOperand(object_map, Map::kPrototypeOffset)); |
| 2573 __ cmp(object, function_prototype); | 2577 __ cmp(object, function_prototype); |
| 2574 __ j(equal, &done, Label::kNear); | 2578 __ j(equal, &done, Label::kNear); |
| 2579 __ mov(object_map, FieldOperand(object, HeapObject::kMapOffset)); |
| 2575 __ cmp(object, isolate()->factory()->null_value()); | 2580 __ cmp(object, isolate()->factory()->null_value()); |
| 2576 __ mov(object_map, FieldOperand(object, HeapObject::kMapOffset)); | |
| 2577 __ j(not_equal, &loop); | 2581 __ j(not_equal, &loop); |
| 2578 __ mov(eax, isolate()->factory()->false_value()); | 2582 __ mov(eax, isolate()->factory()->false_value()); |
| 2583 |
| 2579 __ bind(&done); | 2584 __ bind(&done); |
| 2580 __ StoreRoot(eax, scratch, Heap::kInstanceofCacheAnswerRootIndex); | 2585 __ StoreRoot(eax, scratch, Heap::kInstanceofCacheAnswerRootIndex); |
| 2581 __ ret(0); | 2586 __ ret(0); |
| 2582 | 2587 |
| 2588 // Global object needs access checks, jump to the runtime. |
| 2589 __ bind(&global_object_case); |
| 2590 __ PopReturnAddressTo(scratch); |
| 2591 __ Push(object); |
| 2592 __ Push(function_prototype); |
| 2593 __ PushReturnAddressFrom(scratch); |
| 2594 // Invalidate the instanceof cache. |
| 2595 __ Move(eax, Immediate(Smi::FromInt(0))); |
| 2596 __ StoreRoot(eax, scratch, Heap::kInstanceofCacheFunctionRootIndex); |
| 2597 __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1); |
| 2598 |
| 2583 // Proxy-case: Call the %HasInPrototypeChain runtime function. | 2599 // Proxy-case: Call the %HasInPrototypeChain runtime function. |
| 2584 __ bind(&proxy_case); | 2600 __ bind(&proxy_case); |
| 2585 __ PopReturnAddressTo(scratch); | 2601 __ PopReturnAddressTo(scratch); |
| 2586 __ Push(object); | 2602 __ Push(object); |
| 2587 __ Push(function_prototype); | 2603 __ Push(function_prototype); |
| 2588 __ PushReturnAddressFrom(scratch); | 2604 __ PushReturnAddressFrom(scratch); |
| 2589 // Invalidate the instanceof cache. | 2605 // Invalidate the instanceof cache. |
| 2590 __ Move(eax, Immediate(Smi::FromInt(0))); | 2606 __ Move(eax, Immediate(Smi::FromInt(0))); |
| 2591 __ StoreRoot(eax, scratch, Heap::kInstanceofCacheFunctionRootIndex); | 2607 __ StoreRoot(eax, scratch, Heap::kInstanceofCacheFunctionRootIndex); |
| 2592 __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1); | 2608 __ TailCallRuntime(Runtime::kHasInPrototypeChain, 2, 1); |
| (...skipping 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5640 Operand(ebp, 7 * kPointerSize), NULL); | 5656 Operand(ebp, 7 * kPointerSize), NULL); |
| 5641 } | 5657 } |
| 5642 | 5658 |
| 5643 | 5659 |
| 5644 #undef __ | 5660 #undef __ |
| 5645 | 5661 |
| 5646 } // namespace internal | 5662 } // namespace internal |
| 5647 } // namespace v8 | 5663 } // namespace v8 |
| 5648 | 5664 |
| 5649 #endif // V8_TARGET_ARCH_IA32 | 5665 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |