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_X87 | 5 #if V8_TARGET_ARCH_X87 |
6 | 6 |
7 #include "src/ic/call-optimization.h" | 7 #include "src/ic/call-optimization.h" |
8 #include "src/ic/handler-compiler.h" | 8 #include "src/ic/handler-compiler.h" |
9 #include "src/ic/ic.h" | 9 #include "src/ic/ic.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
587 GenerateRestoreName(miss, name); | 587 GenerateRestoreName(miss, name); |
588 if (IC::ICUseVector(kind())) PopVectorAndSlot(); | 588 if (IC::ICUseVector(kind())) PopVectorAndSlot(); |
589 TailCallBuiltin(masm(), MissBuiltin(kind())); | 589 TailCallBuiltin(masm(), MissBuiltin(kind())); |
590 __ bind(&success); | 590 __ bind(&success); |
591 } | 591 } |
592 } | 592 } |
593 | 593 |
594 | 594 |
595 void NamedLoadHandlerCompiler::GenerateLoadCallback( | 595 void NamedLoadHandlerCompiler::GenerateLoadCallback( |
596 Register reg, Handle<AccessorInfo> callback) { | 596 Register reg, Handle<AccessorInfo> callback) { |
597 DCHECK(!AreAliased(scratch2(), scratch3(), receiver())); | |
598 DCHECK(!AreAliased(scratch2(), scratch3(), reg)); | |
599 | |
600 // Insert additional parameters into the stack frame above return address. | 597 // Insert additional parameters into the stack frame above return address. |
| 598 DCHECK(!scratch3().is(reg)); |
601 __ pop(scratch3()); // Get return address to place it below. | 599 __ pop(scratch3()); // Get return address to place it below. |
602 | 600 |
603 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | 601 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
604 // name below the exit frame to make GC aware of them. | 602 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
605 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); | 603 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); |
606 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); | 604 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); |
607 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); | 605 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); |
608 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); | 606 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); |
609 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); | |
610 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); | |
611 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); | |
612 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); | |
613 | |
614 __ push(receiver()); // receiver | 607 __ push(receiver()); // receiver |
615 // Push data from AccessorInfo. | 608 // Push data from AccessorInfo. |
616 Handle<Object> data(callback->data(), isolate()); | 609 Handle<Object> data(callback->data(), isolate()); |
617 if (data->IsUndefined() || data->IsSmi()) { | 610 if (data->IsUndefined() || data->IsSmi()) { |
618 __ push(Immediate(data)); | 611 __ push(Immediate(data)); |
619 } else { | 612 } else { |
| 613 DCHECK(!scratch2().is(reg)); |
620 Handle<WeakCell> cell = | 614 Handle<WeakCell> cell = |
621 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data)); | 615 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data)); |
622 // The callback is alive if this instruction is executed, | 616 // The callback is alive if this instruction is executed, |
623 // so the weak cell is not cleared and points to data. | 617 // so the weak cell is not cleared and points to data. |
624 __ GetWeakValue(scratch2(), cell); | 618 __ GetWeakValue(scratch2(), cell); |
625 __ push(scratch2()); | 619 __ push(scratch2()); |
626 } | 620 } |
627 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue | 621 __ push(Immediate(isolate()->factory()->undefined_value())); // ReturnValue |
628 // ReturnValue default value | 622 // ReturnValue default value |
629 __ push(Immediate(isolate()->factory()->undefined_value())); | 623 __ push(Immediate(isolate()->factory()->undefined_value())); |
630 __ push(Immediate(reinterpret_cast<int>(isolate()))); | 624 __ push(Immediate(reinterpret_cast<int>(isolate()))); |
631 __ push(reg); // holder | 625 __ push(reg); // holder |
632 __ push(Immediate(Smi::FromInt(0))); // should_throw_on_error -> false | 626 |
| 627 // Save a pointer to where we pushed the arguments. This will be |
| 628 // passed as the const PropertyAccessorInfo& to the C++ callback. |
| 629 __ push(esp); |
633 | 630 |
634 __ push(name()); // name | 631 __ push(name()); // name |
| 632 |
635 __ push(scratch3()); // Restore return address. | 633 __ push(scratch3()); // Restore return address. |
636 | 634 |
637 // Abi for CallApiGetter | 635 // Abi for CallApiGetter |
638 Register getter_address = ApiGetterDescriptor::function_address(); | 636 Register getter_address = ApiGetterDescriptor::function_address(); |
639 Address function_address = v8::ToCData<Address>(callback->getter()); | 637 Address function_address = v8::ToCData<Address>(callback->getter()); |
640 __ mov(getter_address, Immediate(function_address)); | 638 __ mov(getter_address, Immediate(function_address)); |
641 | 639 |
642 CallApiGetterStub stub(isolate()); | 640 CallApiGetterStub stub(isolate()); |
643 __ TailCallStub(&stub); | 641 __ TailCallStub(&stub); |
644 } | 642 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 __ pop(scratch2()); // save old return address | 724 __ pop(scratch2()); // save old return address |
727 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 725 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
728 holder()); | 726 holder()); |
729 __ push(scratch2()); // restore old return address | 727 __ push(scratch2()); // restore old return address |
730 | 728 |
731 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); | 729 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); |
732 } | 730 } |
733 | 731 |
734 | 732 |
735 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 733 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
736 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback, | 734 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback) { |
737 LanguageMode language_mode) { | |
738 Register holder_reg = Frontend(name); | 735 Register holder_reg = Frontend(name); |
739 | 736 |
740 __ pop(scratch1()); // remove the return address | 737 __ pop(scratch1()); // remove the return address |
741 __ push(receiver()); | 738 __ push(receiver()); |
742 __ push(holder_reg); | 739 __ push(holder_reg); |
743 // If the callback cannot leak, then push the callback directly, | 740 // If the callback cannot leak, then push the callback directly, |
744 // otherwise wrap it in a weak cell. | 741 // otherwise wrap it in a weak cell. |
745 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 742 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { |
746 __ Push(callback); | 743 __ Push(callback); |
747 } else { | 744 } else { |
748 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 745 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
749 __ Push(cell); | 746 __ Push(cell); |
750 } | 747 } |
751 __ Push(name); | 748 __ Push(name); |
752 __ push(value()); | 749 __ push(value()); |
753 __ push(Immediate(Smi::FromInt(language_mode))); | |
754 __ push(scratch1()); // restore return address | 750 __ push(scratch1()); // restore return address |
755 | 751 |
756 // Do tail-call to the runtime system. | 752 // Do tail-call to the runtime system. |
757 __ TailCallRuntime(Runtime::kStoreCallbackProperty); | 753 __ TailCallRuntime(Runtime::kStoreCallbackProperty); |
758 | 754 |
759 // Return the generated code. | 755 // Return the generated code. |
760 return GetCode(kind(), Code::FAST, name); | 756 return GetCode(kind(), Code::FAST, name); |
761 } | 757 } |
762 | 758 |
763 | 759 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 // Return the generated code. | 813 // Return the generated code. |
818 return GetCode(kind(), Code::NORMAL, name); | 814 return GetCode(kind(), Code::NORMAL, name); |
819 } | 815 } |
820 | 816 |
821 | 817 |
822 #undef __ | 818 #undef __ |
823 } // namespace internal | 819 } // namespace internal |
824 } // namespace v8 | 820 } // namespace v8 |
825 | 821 |
826 #endif // V8_TARGET_ARCH_X87 | 822 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |