| 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_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
| 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 __ CallExternalReference( |
| 300 NamedLoadHandlerCompiler::kInterceptorArgsLength); | 300 ExternalReference(Runtime::FunctionForId(id), masm->isolate()), |
| 301 NamedLoadHandlerCompiler::kInterceptorArgsLength); |
| 301 } | 302 } |
| 302 | 303 |
| 303 | 304 |
| 304 static void StoreIC_PushArgs(MacroAssembler* masm) { | 305 static void StoreIC_PushArgs(MacroAssembler* masm) { |
| 305 Register receiver = StoreDescriptor::ReceiverRegister(); | 306 Register receiver = StoreDescriptor::ReceiverRegister(); |
| 306 Register name = StoreDescriptor::NameRegister(); | 307 Register name = StoreDescriptor::NameRegister(); |
| 307 Register value = StoreDescriptor::ValueRegister(); | 308 Register value = StoreDescriptor::ValueRegister(); |
| 308 | 309 |
| 309 DCHECK(!ebx.is(receiver) && !ebx.is(name) && !ebx.is(value)); | 310 DCHECK(!ebx.is(receiver) && !ebx.is(name) && !ebx.is(value)); |
| 310 | 311 |
| 311 __ pop(ebx); | 312 __ pop(ebx); |
| 312 __ push(receiver); | 313 __ push(receiver); |
| 313 __ push(name); | 314 __ push(name); |
| 314 __ push(value); | 315 __ push(value); |
| 315 __ push(ebx); | 316 __ push(ebx); |
| 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 662 __ push(receiver()); | 665 __ push(receiver()); |
| 663 } | 666 } |
| 664 __ push(holder_reg); | 667 __ push(holder_reg); |
| 665 __ push(this->name()); | 668 __ push(this->name()); |
| 666 InterceptorVectorSlotPush(holder_reg); | 669 InterceptorVectorSlotPush(holder_reg); |
| 667 // Invoke an interceptor. Note: map checks from receiver to | 670 // Invoke an interceptor. Note: map checks from receiver to |
| 668 // interceptor's holder has been compiled before (see a caller | 671 // interceptor's holder has been compiled before (see a caller |
| 669 // of this method.) | 672 // of this method.) |
| 670 CompileCallLoadPropertyWithInterceptor( | 673 CompileCallLoadPropertyWithInterceptor( |
| 671 masm(), receiver(), holder_reg, this->name(), holder(), | 674 masm(), receiver(), holder_reg, this->name(), holder(), |
| 672 IC::kLoadPropertyWithInterceptorOnly); | 675 Runtime::kLoadPropertyWithInterceptorOnly); |
| 673 | 676 |
| 674 // Check if interceptor provided a value for property. If it's | 677 // Check if interceptor provided a value for property. If it's |
| 675 // the case, return immediately. | 678 // the case, return immediately. |
| 676 Label interceptor_failed; | 679 Label interceptor_failed; |
| 677 __ cmp(eax, factory()->no_interceptor_result_sentinel()); | 680 __ cmp(eax, factory()->no_interceptor_result_sentinel()); |
| 678 __ j(equal, &interceptor_failed); | 681 __ j(equal, &interceptor_failed); |
| 679 frame_scope.GenerateLeaveFrame(); | 682 frame_scope.GenerateLeaveFrame(); |
| 680 __ ret(0); | 683 __ ret(0); |
| 681 | 684 |
| 682 // Clobber registers when generating debug-code to provoke errors. | 685 // Clobber registers when generating debug-code to provoke errors. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 704 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { | 707 void NamedLoadHandlerCompiler::GenerateLoadInterceptor(Register holder_reg) { |
| 705 DCHECK(holder()->HasNamedInterceptor()); | 708 DCHECK(holder()->HasNamedInterceptor()); |
| 706 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); | 709 DCHECK(!holder()->GetNamedInterceptor()->getter()->IsUndefined()); |
| 707 // Call the runtime system to load the interceptor. | 710 // Call the runtime system to load the interceptor. |
| 708 __ pop(scratch2()); // save old return address | 711 __ pop(scratch2()); // save old return address |
| 709 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), | 712 PushInterceptorArguments(masm(), receiver(), holder_reg, this->name(), |
| 710 holder()); | 713 holder()); |
| 711 __ push(scratch2()); // restore old return address | 714 __ push(scratch2()); // restore old return address |
| 712 | 715 |
| 713 ExternalReference ref = ExternalReference( | 716 ExternalReference ref = ExternalReference( |
| 714 IC_Utility(IC::kLoadPropertyWithInterceptor), isolate()); | 717 Runtime::FunctionForId(Runtime::kLoadPropertyWithInterceptor), isolate()); |
| 715 __ TailCallExternalReference( | 718 __ TailCallExternalReference( |
| 716 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); | 719 ref, NamedLoadHandlerCompiler::kInterceptorArgsLength, 1); |
| 717 } | 720 } |
| 718 | 721 |
| 719 | 722 |
| 720 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( | 723 Handle<Code> NamedStoreHandlerCompiler::CompileStoreCallback( |
| 721 Handle<JSObject> object, Handle<Name> name, | 724 Handle<JSObject> object, Handle<Name> name, |
| 722 Handle<ExecutableAccessorInfo> callback) { | 725 Handle<ExecutableAccessorInfo> callback) { |
| 723 Register holder_reg = Frontend(name); | 726 Register holder_reg = Frontend(name); |
| 724 | 727 |
| 725 __ pop(scratch1()); // remove the return address | 728 __ pop(scratch1()); // remove the return address |
| 726 __ push(receiver()); | 729 __ push(receiver()); |
| 727 __ push(holder_reg); | 730 __ push(holder_reg); |
| 728 // If the callback cannot leak, then push the callback directly, | 731 // If the callback cannot leak, then push the callback directly, |
| 729 // otherwise wrap it in a weak cell. | 732 // otherwise wrap it in a weak cell. |
| 730 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { | 733 if (callback->data()->IsUndefined() || callback->data()->IsSmi()) { |
| 731 __ Push(callback); | 734 __ Push(callback); |
| 732 } else { | 735 } else { |
| 733 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); | 736 Handle<WeakCell> cell = isolate()->factory()->NewWeakCell(callback); |
| 734 __ Push(cell); | 737 __ Push(cell); |
| 735 } | 738 } |
| 736 __ Push(name); | 739 __ Push(name); |
| 737 __ push(value()); | 740 __ push(value()); |
| 738 __ push(scratch1()); // restore return address | 741 __ push(scratch1()); // restore return address |
| 739 | 742 |
| 740 // Do tail-call to the runtime system. | 743 // Do tail-call to the runtime system. |
| 741 ExternalReference store_callback_property = | 744 ExternalReference store_callback_property = ExternalReference( |
| 742 ExternalReference(IC_Utility(IC::kStoreCallbackProperty), isolate()); | 745 Runtime::FunctionForId(Runtime::kStoreCallbackProperty), isolate()); |
| 743 __ TailCallExternalReference(store_callback_property, 5, 1); | 746 __ TailCallExternalReference(store_callback_property, 5, 1); |
| 744 | 747 |
| 745 // Return the generated code. | 748 // Return the generated code. |
| 746 return GetCode(kind(), Code::FAST, name); | 749 return GetCode(kind(), Code::FAST, name); |
| 747 } | 750 } |
| 748 | 751 |
| 749 | 752 |
| 750 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( | 753 Handle<Code> NamedStoreHandlerCompiler::CompileStoreInterceptor( |
| 751 Handle<Name> name) { | 754 Handle<Name> name) { |
| 752 __ pop(scratch1()); // remove the return address | 755 __ pop(scratch1()); // remove the return address |
| 753 __ push(receiver()); | 756 __ push(receiver()); |
| 754 __ push(this->name()); | 757 __ push(this->name()); |
| 755 __ push(value()); | 758 __ push(value()); |
| 756 __ push(scratch1()); // restore return address | 759 __ push(scratch1()); // restore return address |
| 757 | 760 |
| 758 // Do tail-call to the runtime system. | 761 // Do tail-call to the runtime system. |
| 759 ExternalReference store_ic_property = ExternalReference( | 762 ExternalReference store_ic_property = ExternalReference( |
| 760 IC_Utility(IC::kStorePropertyWithInterceptor), isolate()); | 763 Runtime::FunctionForId(Runtime::kStorePropertyWithInterceptor), |
| 764 isolate()); |
| 761 __ TailCallExternalReference(store_ic_property, 3, 1); | 765 __ TailCallExternalReference(store_ic_property, 3, 1); |
| 762 | 766 |
| 763 // Return the generated code. | 767 // Return the generated code. |
| 764 return GetCode(kind(), Code::FAST, name); | 768 return GetCode(kind(), Code::FAST, name); |
| 765 } | 769 } |
| 766 | 770 |
| 767 | 771 |
| 768 Register NamedStoreHandlerCompiler::value() { | 772 Register NamedStoreHandlerCompiler::value() { |
| 769 return StoreDescriptor::ValueRegister(); | 773 return StoreDescriptor::ValueRegister(); |
| 770 } | 774 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 // Return the generated code. | 809 // Return the generated code. |
| 806 return GetCode(kind(), Code::NORMAL, name); | 810 return GetCode(kind(), Code::NORMAL, name); |
| 807 } | 811 } |
| 808 | 812 |
| 809 | 813 |
| 810 #undef __ | 814 #undef __ |
| 811 } // namespace internal | 815 } // namespace internal |
| 812 } // namespace v8 | 816 } // namespace v8 |
| 813 | 817 |
| 814 #endif // V8_TARGET_ARCH_IA32 | 818 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |