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