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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/ic/call-optimization.h" | 9 #include "src/ic/call-optimization.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2); | 108 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2); |
109 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3); | 109 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3); |
110 __ Push(name); | 110 __ Push(name); |
111 __ Push(receiver); | 111 __ Push(receiver); |
112 __ Push(holder); | 112 __ Push(holder); |
113 } | 113 } |
114 | 114 |
115 | 115 |
116 static void CompileCallLoadPropertyWithInterceptor( | 116 static void CompileCallLoadPropertyWithInterceptor( |
117 MacroAssembler* masm, Register receiver, Register holder, Register name, | 117 MacroAssembler* masm, Register receiver, Register holder, Register name, |
118 Handle<JSObject> holder_obj, IC::UtilityId id) { | 118 Handle<JSObject> holder_obj, Runtime::FunctionId id) { |
119 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 119 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
120 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), | 120 __ CallExternalReference( |
121 NamedLoadHandlerCompiler::kInterceptorArgsLength); | 121 ExternalReference(Runtime::FunctionForId(id), masm->isolate()), |
| 122 NamedLoadHandlerCompiler::kInterceptorArgsLength); |
122 } | 123 } |
123 | 124 |
124 | 125 |
125 // Generate call to api function. | 126 // Generate call to api function. |
126 void PropertyHandlerCompiler::GenerateApiAccessorCall( | 127 void PropertyHandlerCompiler::GenerateApiAccessorCall( |
127 MacroAssembler* masm, const CallOptimization& optimization, | 128 MacroAssembler* masm, const CallOptimization& optimization, |
128 Handle<Map> receiver_map, Register receiver, Register scratch, | 129 Handle<Map> receiver_map, Register receiver, Register scratch, |
129 bool is_store, Register store_parameter, Register accessor_holder, | 130 bool is_store, Register store_parameter, Register accessor_holder, |
130 int accessor_index) { | 131 int accessor_index) { |
131 DCHECK(!accessor_holder.is(scratch)); | 132 DCHECK(!accessor_holder.is(scratch)); |
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 __ Push(value); | 315 __ Push(value); |
315 __ PushReturnAddressFrom(rbx); | 316 __ PushReturnAddressFrom(rbx); |
316 } | 317 } |
317 | 318 |
318 | 319 |
319 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { | 320 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { |
320 // Return address is on the stack. | 321 // Return address is on the stack. |
321 StoreIC_PushArgs(masm); | 322 StoreIC_PushArgs(masm); |
322 | 323 |
323 // Do tail-call to runtime routine. | 324 // Do tail-call to runtime routine. |
324 ExternalReference ref(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); | 325 ExternalReference ref(Runtime::FunctionForId(Runtime::kStoreIC_Slow), |
| 326 masm->isolate()); |
325 __ TailCallExternalReference(ref, 3, 1); | 327 __ TailCallExternalReference(ref, 3, 1); |
326 } | 328 } |
327 | 329 |
328 | 330 |
329 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { | 331 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { |
330 // Return address is on the stack. | 332 // Return address is on the stack. |
331 StoreIC_PushArgs(masm); | 333 StoreIC_PushArgs(masm); |
332 | 334 |
333 // Do tail-call to runtime routine. | 335 // Do tail-call to runtime routine. |
334 ExternalReference ref(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); | 336 ExternalReference ref(Runtime::FunctionForId(Runtime::kKeyedStoreIC_Slow), |
| 337 masm->isolate()); |
335 __ TailCallExternalReference(ref, 3, 1); | 338 __ TailCallExternalReference(ref, 3, 1); |
336 } | 339 } |
337 | 340 |
338 | 341 |
339 #undef __ | 342 #undef __ |
340 #define __ ACCESS_MASM((masm())) | 343 #define __ ACCESS_MASM((masm())) |
341 | 344 |
342 | 345 |
343 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, | 346 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, |
344 Handle<Name> name) { | 347 Handle<Name> name) { |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 } | 667 } |
665 __ Push(holder_reg); | 668 __ Push(holder_reg); |
666 __ Push(this->name()); | 669 __ Push(this->name()); |
667 InterceptorVectorSlotPush(holder_reg); | 670 InterceptorVectorSlotPush(holder_reg); |
668 | 671 |
669 // Invoke an interceptor. Note: map checks from receiver to | 672 // Invoke an interceptor. Note: map checks from receiver to |
670 // interceptor's holder has been compiled before (see a caller | 673 // interceptor's holder has been compiled before (see a caller |
671 // of this method.) | 674 // of this method.) |
672 CompileCallLoadPropertyWithInterceptor( | 675 CompileCallLoadPropertyWithInterceptor( |
673 masm(), receiver(), holder_reg, this->name(), holder(), | 676 masm(), receiver(), holder_reg, this->name(), holder(), |
674 IC::kLoadPropertyWithInterceptorOnly); | 677 Runtime::kLoadPropertyWithInterceptorOnly); |
675 | 678 |
676 // Check if interceptor provided a value for property. If it's | 679 // Check if interceptor provided a value for property. If it's |
677 // the case, return immediately. | 680 // the case, return immediately. |
678 Label interceptor_failed; | 681 Label interceptor_failed; |
679 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex); | 682 __ CompareRoot(rax, Heap::kNoInterceptorResultSentinelRootIndex); |
680 __ j(equal, &interceptor_failed); | 683 __ j(equal, &interceptor_failed); |
681 frame_scope.GenerateLeaveFrame(); | 684 frame_scope.GenerateLeaveFrame(); |
682 __ ret(0); | 685 __ ret(0); |
683 | 686 |
684 __ bind(&interceptor_failed); | 687 __ bind(&interceptor_failed); |
(...skipping 14 matching lines...) Expand all Loading... |
699 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { | 702 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { |
700 // Call the runtime system to load the interceptor. | 703 // Call the runtime system to load the interceptor. |
701 DCHECK(holder()->HasNamedInterceptor()); | 704 DCHECK(holder()->HasNamedInterceptor()); |
702 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 705 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); |
703 __ PopReturnAddressTo(scratch2()); | 706 __ PopReturnAddressTo(scratch2()); |
704 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 707 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
705 holder()); | 708 holder()); |
706 __ PushReturnAddressFrom(scratch2()); | 709 __ PushReturnAddressFrom(scratch2()); |
707 | 710 |
708 ExternalReference ref = ExternalReference( | 711 ExternalReference ref = ExternalReference( |
709 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); | 712 Runtime::FunctionForId(Runtime::kLoadPropertyWithInterceptor), isolate()); |
710 __ TailCallExternalReference( | 713 __ TailCallExternalReference( |
711 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); | 714 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); |
712 } | 715 } |
713 | 716 |
714 | 717 |
715 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 718 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
716 Handle<JSObject> object, Handle<Name> name, | 719 Handle<JSObject> object, Handle<Name> name, |
717 Handle<ExecutableAccessorInfo> callback) { | 720 Handle<ExecutableAccessorInfo> callback) { |
718 Register holder_reg = Frontend(name); | 721 Register holder_reg = Frontend(name); |
719 | 722 |
720 __ PopReturnAddressTo(scratch1()); | 723 __ PopReturnAddressTo(scratch1()); |
721 __ Push(receiver()); | 724 __ Push(receiver()); |
722 __ Push(holder_reg); | 725 __ Push(holder_reg); |
723 // If the callback cannot leak, then push the callback directly, | 726 // If the callback cannot leak, then push the callback directly, |
724 // otherwise wrap it in a weak cell. | 727 // otherwise wrap it in a weak cell. |
725 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 728 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { |
726 __ Push(callback); | 729 __ Push(callback); |
727 } else { | 730 } else { |
728 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 731 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
729 __ Push(cell); | 732 __ Push(cell); |
730 } | 733 } |
731 __ Push(name); | 734 __ Push(name); |
732 __ Push(value()); | 735 __ Push(value()); |
733 __ PushReturnAddressFrom(scratch1()); | 736 __ PushReturnAddressFrom(scratch1()); |
734 | 737 |
735 // Do tail-call to the runtime system. | 738 // Do tail-call to the runtime system. |
736 ExternalReference store_callback_property = | 739 ExternalReference store_callback_property = ExternalReference( |
737 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | 740 Runtime::FunctionForId(Runtime::kStoreCallbackProperty), isolate()); |
738 __ TailCallExternalReference(store_callback_property, 5, 1); | 741 __ TailCallExternalReference(store_callback_property, 5, 1); |
739 | 742 |
740 // Return the generated code. | 743 // Return the generated code. |
741 return GetCode(kind(), Code::FAST, name); | 744 return GetCode(kind(), Code::FAST, name); |
742 } | 745 } |
743 | 746 |
744 | 747 |
745 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( | 748 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( |
746 Handle<Name> name) { | 749 Handle<Name> name) { |
747 __ PopReturnAddressTo(scratch1()); | 750 __ PopReturnAddressTo(scratch1()); |
748 __ Push(receiver()); | 751 __ Push(receiver()); |
749 __ Push(this->name()); | 752 __ Push(this->name()); |
750 __ Push(value()); | 753 __ Push(value()); |
751 __ PushReturnAddressFrom(scratch1()); | 754 __ PushReturnAddressFrom(scratch1()); |
752 | 755 |
753 // Do tail-call to the runtime system. | 756 // Do tail-call to the runtime system. |
754 ExternalReference store_ic_property = ExternalReference( | 757 ExternalReference store_ic_property = ExternalReference( |
755 IC_Utility(IC::kStorePropertyWithInterceptor), isolate()); | 758 Runtime::FunctionForId(Runtime::kStorePropertyWithInterceptor), |
| 759 isolate()); |
756 __ TailCallExternalReference(store_ic_property, 3, 1); | 760 __ TailCallExternalReference(store_ic_property, 3, 1); |
757 | 761 |
758 // Return the generated code. | 762 // Return the generated code. |
759 return GetCode(kind(), Code::FAST, name); | 763 return GetCode(kind(), Code::FAST, name); |
760 } | 764 } |
761 | 765 |
762 | 766 |
763 Register NamedStoreHandlerCompiler::value() { | 767 Register NamedStoreHandlerCompiler::value() { |
764 return StoreDescriptor::ValueRegister(); | 768 return StoreDescriptor::ValueRegister(); |
765 } | 769 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
800 // Return the generated code. | 804 // Return the generated code. |
801 return GetCode(kind(), Code::NORMAL, name); | 805 return GetCode(kind(), Code::NORMAL, name); |
802 } | 806 } |
803 | 807 |
804 | 808 |
805 #undef __ | 809 #undef __ |
806 } // namespace internal | 810 } // namespace internal |
807 } // namespace v8 | 811 } // namespace v8 |
808 | 812 |
809 #endif // V8_TARGET_ARCH_X64 | 813 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |