OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_X64 | 5 #if V8_TARGET_ARCH_X64 |
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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 GenerateRestoreName(miss, name); | 586 GenerateRestoreName(miss, name); |
587 if (IC::ICUseVector(kind())) PopVectorAndSlot(); | 587 if (IC::ICUseVector(kind())) PopVectorAndSlot(); |
588 TailCallBuiltin(masm(), MissBuiltin(kind())); | 588 TailCallBuiltin(masm(), MissBuiltin(kind())); |
589 __ bind(&success); | 589 __ bind(&success); |
590 } | 590 } |
591 } | 591 } |
592 | 592 |
593 | 593 |
594 void NamedLoadHandlerCompiler::GenerateLoadCallback( | 594 void NamedLoadHandlerCompiler::GenerateLoadCallback( |
595 Register reg, Handle<AccessorInfo> callback) { | 595 Register reg, Handle<AccessorInfo> callback) { |
| 596 DCHECK(!AreAliased(kScratchRegister, scratch2(), scratch3(), receiver())); |
| 597 DCHECK(!AreAliased(kScratchRegister, scratch2(), scratch3(), reg)); |
| 598 |
596 // Insert additional parameters into the stack frame above return address. | 599 // Insert additional parameters into the stack frame above return address. |
597 DCHECK(!scratch4().is(reg)); | 600 __ PopReturnAddressTo(scratch3()); |
598 __ PopReturnAddressTo(scratch4()); | |
599 | 601 |
600 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | 602 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property |
601 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | 603 // name below the exit frame to make GC aware of them. |
602 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 2); | 604 STATIC_ASSERT(PropertyCallbackArguments::kShouldThrowOnErrorIndex == 0); |
603 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 3); | 605 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 1); |
604 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 4); | 606 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 2); |
605 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 5); | 607 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueDefaultValueIndex == 3); |
606 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 6); | 608 STATIC_ASSERT(PropertyCallbackArguments::kReturnValueOffset == 4); |
| 609 STATIC_ASSERT(PropertyCallbackArguments::kDataIndex == 5); |
| 610 STATIC_ASSERT(PropertyCallbackArguments::kThisIndex == 6); |
| 611 STATIC_ASSERT(PropertyCallbackArguments::kArgsLength == 7); |
| 612 |
607 __ Push(receiver()); // receiver | 613 __ Push(receiver()); // receiver |
608 Handle<Object> data(callback->data(), isolate()); | 614 Handle<Object> data(callback->data(), isolate()); |
609 if (data->IsUndefined() || data->IsSmi()) { | 615 if (data->IsUndefined() || data->IsSmi()) { |
610 __ Push(data); | 616 __ Push(data); |
611 } else { | 617 } else { |
612 DCHECK(!scratch2().is(reg)); | |
613 Handle<WeakCell> cell = | 618 Handle<WeakCell> cell = |
614 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data)); | 619 isolate()->factory()->NewWeakCell(Handle<HeapObject>::cast(data)); |
615 // The callback is alive if this instruction is executed, | 620 // The callback is alive if this instruction is executed, |
616 // so the weak cell is not cleared and points to data. | 621 // so the weak cell is not cleared and points to data. |
617 __ GetWeakValue(scratch2(), cell); | 622 __ GetWeakValue(scratch2(), cell); |
618 __ Push(scratch2()); | 623 __ Push(scratch2()); |
619 } | 624 } |
620 DCHECK(!kScratchRegister.is(reg)); | |
621 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); | 625 __ LoadRoot(kScratchRegister, Heap::kUndefinedValueRootIndex); |
622 __ Push(kScratchRegister); // return value | 626 __ Push(kScratchRegister); // return value |
623 __ Push(kScratchRegister); // return value default | 627 __ Push(kScratchRegister); // return value default |
624 __ PushAddress(ExternalReference::isolate_address(isolate())); | 628 __ PushAddress(ExternalReference::isolate_address(isolate())); |
625 __ Push(reg); // holder | 629 __ Push(reg); // holder |
| 630 __ Push(Smi::FromInt(0)); // should_throw_on_error -> false |
| 631 |
626 __ Push(name()); // name | 632 __ Push(name()); // name |
627 // Save a pointer to where we pushed the arguments pointer. This will be | 633 __ PushReturnAddressFrom(scratch3()); |
628 // passed as the const PropertyAccessorInfo& to the C++ callback. | |
629 | |
630 __ PushReturnAddressFrom(scratch4()); | |
631 | 634 |
632 // Abi for CallApiGetter | 635 // Abi for CallApiGetter |
633 Register api_function_address = ApiGetterDescriptor::function_address(); | 636 Register api_function_address = ApiGetterDescriptor::function_address(); |
634 Address getter_address = v8::ToCData<Address>(callback->getter()); | 637 Address getter_address = v8::ToCData<Address>(callback->getter()); |
635 __ Move(api_function_address, getter_address, RelocInfo::EXTERNAL_REFERENCE); | 638 __ Move(api_function_address, getter_address, RelocInfo::EXTERNAL_REFERENCE); |
636 | 639 |
637 CallApiGetterStub stub(isolate()); | 640 CallApiGetterStub stub(isolate()); |
638 __ TailCallStub(&stub); | 641 __ TailCallStub(&stub); |
639 } | 642 } |
640 | 643 |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 __ PopReturnAddressTo(scratch2()); | 718 __ PopReturnAddressTo(scratch2()); |
716 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 719 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
717 holder()); | 720 holder()); |
718 __ PushReturnAddressFrom(scratch2()); | 721 __ PushReturnAddressFrom(scratch2()); |
719 | 722 |
720 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); | 723 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor); |
721 } | 724 } |
722 | 725 |
723 | 726 |
724 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 727 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
725 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback) { | 728 Handle<JSObject> object, Handle<Name> name, Handle<AccessorInfo> callback, |
| 729 LanguageMode language_mode) { |
726 Register holder_reg = Frontend(name); | 730 Register holder_reg = Frontend(name); |
727 | 731 |
728 __ PopReturnAddressTo(scratch1()); | 732 __ PopReturnAddressTo(scratch1()); |
729 __ Push(receiver()); | 733 __ Push(receiver()); |
730 __ Push(holder_reg); | 734 __ Push(holder_reg); |
731 // If the callback cannot leak, then push the callback directly, | 735 // If the callback cannot leak, then push the callback directly, |
732 // otherwise wrap it in a weak cell. | 736 // otherwise wrap it in a weak cell. |
733 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 737 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { |
734 __ Push(callback); | 738 __ Push(callback); |
735 } else { | 739 } else { |
736 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 740 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
737 __ Push(cell); | 741 __ Push(cell); |
738 } | 742 } |
739 __ Push(name); | 743 __ Push(name); |
740 __ Push(value()); | 744 __ Push(value()); |
| 745 __ Push(Smi::FromInt(language_mode)); |
741 __ PushReturnAddressFrom(scratch1()); | 746 __ PushReturnAddressFrom(scratch1()); |
742 | 747 |
743 // Do tail-call to the runtime system. | 748 // Do tail-call to the runtime system. |
744 __ TailCallRuntime(Runtime::kStoreCallbackProperty); | 749 __ TailCallRuntime(Runtime::kStoreCallbackProperty); |
745 | 750 |
746 // Return the generated code. | 751 // Return the generated code. |
747 return GetCode(kind(), Code::FAST, name); | 752 return GetCode(kind(), Code::FAST, name); |
748 } | 753 } |
749 | 754 |
750 | 755 |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
804 // Return the generated code. | 809 // Return the generated code. |
805 return GetCode(kind(), Code::NORMAL, name); | 810 return GetCode(kind(), Code::NORMAL, name); |
806 } | 811 } |
807 | 812 |
808 | 813 |
809 #undef __ | 814 #undef __ |
810 } // namespace internal | 815 } // namespace internal |
811 } // namespace v8 | 816 } // namespace v8 |
812 | 817 |
813 #endif // V8_TARGET_ARCH_X64 | 818 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |