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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2); | 287 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsHolderIndex == 2); |
288 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3); | 288 STATIC_ASSERT(NamedLoadHandlerCompiler::kInterceptorArgsLength == 3); |
289 __ push(name); | 289 __ push(name); |
290 __ push(receiver); | 290 __ push(receiver); |
291 __ push(holder); | 291 __ push(holder); |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 static void CompileCallLoadPropertyWithInterceptor( | 295 static void CompileCallLoadPropertyWithInterceptor( |
296 MacroAssembler* masm, Register receiver, Register holder, Register name, | 296 MacroAssembler* masm, Register receiver, Register holder, Register name, |
297 Handle<JSObject> holder_obj, IC::UtilityId id) { | 297 Handle<JSObject> holder_obj, Runtime::FunctionId id) { |
298 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 298 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
299 __ CallExternalReference(ExternalReference(IC_Utility(id), masm->isolate()), | 299 __ CallRuntime(id, NamedLoadHandlerCompiler::kInterceptorArgsLength); |
300 NamedLoadHandlerCompiler::kInterceptorArgsLength); | |
301 } | 300 } |
302 | 301 |
303 | 302 |
304 static void StoreIC_PushArgs(MacroAssembler* masm) { | 303 static void StoreIC_PushArgs(MacroAssembler* masm) { |
305 Register receiver = StoreDescriptor::ReceiverRegister(); | 304 Register receiver = StoreDescriptor::ReceiverRegister(); |
306 Register name = StoreDescriptor::NameRegister(); | 305 Register name = StoreDescriptor::NameRegister(); |
307 Register value = StoreDescriptor::ValueRegister(); | 306 Register value = StoreDescriptor::ValueRegister(); |
308 | 307 |
309 DCHECK(!ebx.is(receiver) && !ebx.is(name) && !ebx.is(value)); | 308 DCHECK(!ebx.is(receiver) && !ebx.is(name) && !ebx.is(value)); |
310 | 309 |
311 __ pop(ebx); | 310 __ pop(ebx); |
312 __ push(receiver); | 311 __ push(receiver); |
313 __ push(name); | 312 __ push(name); |
314 __ push(value); | 313 __ push(value); |
315 __ push(ebx); | 314 __ push(ebx); |
316 } | 315 } |
317 | 316 |
318 | 317 |
319 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { | 318 void NamedStoreHandlerCompiler::GenerateSlow(MacroAssembler* masm) { |
320 // Return address is on the stack. | 319 // Return address is on the stack. |
321 StoreIC_PushArgs(masm); | 320 StoreIC_PushArgs(masm); |
322 | 321 |
323 // Do tail-call to runtime routine. | 322 // Do tail-call to runtime routine. |
324 ExternalReference ref(IC_Utility(IC::kStoreIC_Slow), masm->isolate()); | 323 __ TailCallRuntime(Runtime::kStoreIC_Slow, 3, 1); |
325 __ TailCallExternalReference(ref, 3, 1); | |
326 } | 324 } |
327 | 325 |
328 | 326 |
329 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { | 327 void ElementHandlerCompiler::GenerateStoreSlow(MacroAssembler* masm) { |
330 // Return address is on the stack. | 328 // Return address is on the stack. |
331 StoreIC_PushArgs(masm); | 329 StoreIC_PushArgs(masm); |
332 | 330 |
333 // Do tail-call to runtime routine. | 331 // Do tail-call to runtime routine. |
334 ExternalReference ref(IC_Utility(IC::kKeyedStoreIC_Slow), masm->isolate()); | 332 __ TailCallRuntime(Runtime::kKeyedStoreIC_Slow, 3, 1); |
335 __ TailCallExternalReference(ref, 3, 1); | |
336 } | 333 } |
337 | 334 |
338 | 335 |
339 #undef __ | 336 #undef __ |
340 #define __ ACCESS_MASM(masm()) | 337 #define __ ACCESS_MASM(masm()) |
341 | 338 |
342 | 339 |
343 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, | 340 void NamedStoreHandlerCompiler::GenerateRestoreName(Label* label, |
344 Handle<Name> name) { | 341 Handle<Name> name) { |
345 if (!label->is_unused()) { | 342 if (!label->is_unused()) { |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
662 __ push(receiver()); | 659 __ push(receiver()); |
663 } | 660 } |
664 __ push(holder_reg); | 661 __ push(holder_reg); |
665 __ push(this->name()); | 662 __ push(this->name()); |
666 InterceptorVectorSlotPush(holder_reg); | 663 InterceptorVectorSlotPush(holder_reg); |
667 // Invoke an interceptor. Note: map checks from receiver to | 664 // Invoke an interceptor. Note: map checks from receiver to |
668 // interceptor's holder has been compiled before (see a caller | 665 // interceptor's holder has been compiled before (see a caller |
669 // of this method.) | 666 // of this method.) |
670 CompileCallLoadPropertyWithInterceptor( | 667 CompileCallLoadPropertyWithInterceptor( |
671 masm(), receiver(), holder_reg, this->name(), holder(), | 668 masm(), receiver(), holder_reg, this->name(), holder(), |
672 IC::kLoadPropertyWithInterceptorOnly); | 669 Runtime::kLoadPropertyWithInterceptorOnly); |
673 | 670 |
674 // Check if interceptor provided a value for property. If it's | 671 // Check if interceptor provided a value for property. If it's |
675 // the case, return immediately. | 672 // the case, return immediately. |
676 Label interceptor_failed; | 673 Label interceptor_failed; |
677 __ cmp(eax, factory()->no_interceptor_result_sentinel()); | 674 __ cmp(eax, factory()->no_interceptor_result_sentinel()); |
678 __ j(equal, &interceptor_failed); | 675 __ j(equal, &interceptor_failed); |
679 frame_scope.GenerateLeaveFrame(); | 676 frame_scope.GenerateLeaveFrame(); |
680 __ ret(0); | 677 __ ret(0); |
681 | 678 |
682 // Clobber registers when generating debug-code to provoke errors. | 679 // Clobber registers when generating debug-code to provoke errors. |
(...skipping 20 matching lines...) Expand all Loading... |
703 | 700 |
704 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { | 701 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { |
705 DCHECK(holder()->HasNamedInterceptor()); | 702 DCHECK(holder()->HasNamedInterceptor()); |
706 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 703 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); |
707 // Call the runtime system to load the interceptor. | 704 // Call the runtime system to load the interceptor. |
708 __ pop(scratch2()); // save old return address | 705 __ pop(scratch2()); // save old return address |
709 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 706 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
710 holder()); | 707 holder()); |
711 __ push(scratch2()); // restore old return address | 708 __ push(scratch2()); // restore old return address |
712 | 709 |
713 ExternalReference ref = ExternalReference( | 710 __ TailCallRuntime(Runtime::kLoadPropertyWithInterceptor, |
714 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); | 711 NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); |
715 __ TailCallExternalReference( | |
716 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); | |
717 } | 712 } |
718 | 713 |
719 | 714 |
720 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 715 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
721 Handle<JSObject> object, Handle<Name> name, | 716 Handle<JSObject> object, Handle<Name> name, |
722 Handle<ExecutableAccessorInfo> callback) { | 717 Handle<ExecutableAccessorInfo> callback) { |
723 Register holder_reg = Frontend(name); | 718 Register holder_reg = Frontend(name); |
724 | 719 |
725 __ pop(scratch1()); // remove the return address | 720 __ pop(scratch1()); // remove the return address |
726 __ push(receiver()); | 721 __ push(receiver()); |
727 __ push(holder_reg); | 722 __ push(holder_reg); |
728 // If the callback cannot leak, then push the callback directly, | 723 // If the callback cannot leak, then push the callback directly, |
729 // otherwise wrap it in a weak cell. | 724 // otherwise wrap it in a weak cell. |
730 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 725 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { |
731 __ Push(callback); | 726 __ Push(callback); |
732 } else { | 727 } else { |
733 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 728 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
734 __ Push(cell); | 729 __ Push(cell); |
735 } | 730 } |
736 __ Push(name); | 731 __ Push(name); |
737 __ push(value()); | 732 __ push(value()); |
738 __ push(scratch1()); // restore return address | 733 __ push(scratch1()); // restore return address |
739 | 734 |
740 // Do tail-call to the runtime system. | 735 // Do tail-call to the runtime system. |
741 ExternalReference store_callback_property = | 736 __ TailCallRuntime(Runtime::kStoreCallbackProperty, 5, 1); |
742 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | |
743 __ TailCallExternalReference(store_callback_property, 5, 1); | |
744 | 737 |
745 // Return the generated code. | 738 // Return the generated code. |
746 return GetCode(kind(), Code::FAST, name); | 739 return GetCode(kind(), Code::FAST, name); |
747 } | 740 } |
748 | 741 |
749 | 742 |
750 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( | 743 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( |
751 Handle<Name> name) { | 744 Handle<Name> name) { |
752 __ pop(scratch1()); // remove the return address | 745 __ pop(scratch1()); // remove the return address |
753 __ push(receiver()); | 746 __ push(receiver()); |
754 __ push(this->name()); | 747 __ push(this->name()); |
755 __ push(value()); | 748 __ push(value()); |
756 __ push(scratch1()); // restore return address | 749 __ push(scratch1()); // restore return address |
757 | 750 |
758 // Do tail-call to the runtime system. | 751 // Do tail-call to the runtime system. |
759 ExternalReference store_ic_property = ExternalReference( | 752 __ TailCallRuntime(Runtime::kStorePropertyWithInterceptor, 3, 1); |
760 IC_Utility(IC::kStorePropertyWithInterceptor), isolate()); | |
761 __ TailCallExternalReference(store_ic_property, 3, 1); | |
762 | 753 |
763 // Return the generated code. | 754 // Return the generated code. |
764 return GetCode(kind(), Code::FAST, name); | 755 return GetCode(kind(), Code::FAST, name); |
765 } | 756 } |
766 | 757 |
767 | 758 |
768 Register NamedStoreHandlerCompiler::value() { | 759 Register NamedStoreHandlerCompiler::value() { |
769 return StoreDescriptor::ValueRegister(); | 760 return StoreDescriptor::ValueRegister(); |
770 } | 761 } |
771 | 762 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 // Return the generated code. | 796 // Return the generated code. |
806 return GetCode(kind(), Code::NORMAL, name); | 797 return GetCode(kind(), Code::NORMAL, name); |
807 } | 798 } |
808 | 799 |
809 | 800 |
810 #undef __ | 801 #undef __ |
811 } // namespace internal | 802 } // namespace internal |
812 } // namespace v8 | 803 } // namespace v8 |
813 | 804 |
814 #endif // V8_TARGET_ARCH_X87 | 805 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |