OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 Register name, | 775 Register name, |
776 Handle<JSObject> holder_obj, | 776 Handle<JSObject> holder_obj, |
777 IC::UtilityId id) { | 777 IC::UtilityId id) { |
778 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); | 778 PushInterceptorArguments(masm, receiver, holder, name, holder_obj); |
779 __ CallExternalReference( | 779 __ CallExternalReference( |
780 ExternalReference(IC_Utility(id), masm->isolate()), | 780 ExternalReference(IC_Utility(id), masm->isolate()), |
781 StubCache::kInterceptorArgsLength); | 781 StubCache::kInterceptorArgsLength); |
782 } | 782 } |
783 | 783 |
784 | 784 |
785 static void GenerateFastApiCallBody(MacroAssembler* masm, | 785 // Generate call to api function. |
786 const CallOptimization& optimization, | 786 static void GenerateFastApiCall(MacroAssembler* masm, |
787 int argc, | 787 const CallOptimization& optimization, |
788 Register holder_in, | 788 Handle<Map> receiver_map, |
789 bool restore_context) { | 789 Register receiver, |
| 790 Register scratch_in, |
| 791 int argc, |
| 792 Register* values) { |
| 793 ASSERT(!receiver.is(scratch_in)); |
| 794 __ push(receiver); |
| 795 // Write the arguments to stack frame. |
| 796 for (int i = 0; i < argc; i++) { |
| 797 Register arg = values[argc-1-i]; |
| 798 ASSERT(!receiver.is(arg)); |
| 799 ASSERT(!scratch_in.is(arg)); |
| 800 __ push(arg); |
| 801 } |
790 ASSERT(optimization.is_simple_api_call()); | 802 ASSERT(optimization.is_simple_api_call()); |
791 | 803 |
792 // Abi for CallApiFunctionStub. | 804 // Abi for CallApiFunctionStub. |
793 Register callee = r0; | 805 Register callee = r0; |
794 Register call_data = r4; | 806 Register call_data = r4; |
795 Register holder = r2; | 807 Register holder = r2; |
796 Register api_function_address = r1; | 808 Register api_function_address = r1; |
797 | 809 |
798 // Put holder in place. | 810 // Put holder in place. |
799 __ Move(holder, holder_in); | 811 CallOptimization::HolderLookup holder_lookup; |
| 812 Handle<JSObject> api_holder = optimization.LookupHolderOfExpectedType( |
| 813 receiver_map, |
| 814 &holder_lookup); |
| 815 switch (holder_lookup) { |
| 816 case CallOptimization::kHolderIsReceiver: |
| 817 __ Move(holder, receiver); |
| 818 break; |
| 819 case CallOptimization::kHolderFound: |
| 820 __ Move(holder, api_holder); |
| 821 break; |
| 822 case CallOptimization::kHolderNotFound: |
| 823 UNREACHABLE(); |
| 824 break; |
| 825 } |
800 | 826 |
801 Isolate* isolate = masm->isolate(); | 827 Isolate* isolate = masm->isolate(); |
802 Handle<JSFunction> function = optimization.constant_function(); | 828 Handle<JSFunction> function = optimization.constant_function(); |
803 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 829 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
804 Handle<Object> call_data_obj(api_call_info->data(), isolate); | 830 Handle<Object> call_data_obj(api_call_info->data(), isolate); |
805 | 831 |
806 // Put callee in place. | 832 // Put callee in place. |
807 __ Move(callee, function); | 833 __ Move(callee, function); |
808 | 834 |
809 bool call_data_undefined = false; | 835 bool call_data_undefined = false; |
(...skipping 11 matching lines...) Expand all Loading... |
821 // Put api_function_address in place. | 847 // Put api_function_address in place. |
822 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 848 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
823 ApiFunction fun(function_address); | 849 ApiFunction fun(function_address); |
824 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; | 850 ExternalReference::Type type = ExternalReference::DIRECT_API_CALL; |
825 ExternalReference ref = ExternalReference(&fun, | 851 ExternalReference ref = ExternalReference(&fun, |
826 type, | 852 type, |
827 masm->isolate()); | 853 masm->isolate()); |
828 __ mov(api_function_address, Operand(ref)); | 854 __ mov(api_function_address, Operand(ref)); |
829 | 855 |
830 // Jump to stub. | 856 // Jump to stub. |
831 CallApiFunctionStub stub(restore_context, call_data_undefined, argc); | 857 CallApiFunctionStub stub(true, call_data_undefined, argc); |
832 __ TailCallStub(&stub); | 858 __ TailCallStub(&stub); |
833 } | 859 } |
834 | 860 |
835 | 861 |
836 // Generate call to api function. | |
837 static void GenerateFastApiCall(MacroAssembler* masm, | |
838 const CallOptimization& optimization, | |
839 Register receiver, | |
840 Register scratch, | |
841 int argc, | |
842 Register* values) { | |
843 ASSERT(!receiver.is(scratch)); | |
844 __ push(receiver); | |
845 // Write the arguments to stack frame. | |
846 for (int i = 0; i < argc; i++) { | |
847 Register arg = values[argc-1-i]; | |
848 ASSERT(!receiver.is(arg)); | |
849 ASSERT(!scratch.is(arg)); | |
850 __ push(arg); | |
851 } | |
852 // Stack now matches JSFunction abi. | |
853 GenerateFastApiCallBody(masm, | |
854 optimization, | |
855 argc, | |
856 receiver, | |
857 true); | |
858 } | |
859 | |
860 | |
861 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { | 862 void StubCompiler::GenerateTailCall(MacroAssembler* masm, Handle<Code> code) { |
862 __ Jump(code, RelocInfo::CODE_TARGET); | 863 __ Jump(code, RelocInfo::CODE_TARGET); |
863 } | 864 } |
864 | 865 |
865 | 866 |
866 #undef __ | 867 #undef __ |
867 #define __ ACCESS_MASM(masm()) | 868 #define __ ACCESS_MASM(masm()) |
868 | 869 |
869 | 870 |
870 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, | 871 Register StubCompiler::CheckPrototypes(Handle<HeapType> type, |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1068 | 1069 |
1069 | 1070 |
1070 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { | 1071 void LoadStubCompiler::GenerateLoadConstant(Handle<Object> value) { |
1071 // Return the constant value. | 1072 // Return the constant value. |
1072 __ Move(r0, value); | 1073 __ Move(r0, value); |
1073 __ Ret(); | 1074 __ Ret(); |
1074 } | 1075 } |
1075 | 1076 |
1076 | 1077 |
1077 void LoadStubCompiler::GenerateLoadCallback( | 1078 void LoadStubCompiler::GenerateLoadCallback( |
1078 const CallOptimization& call_optimization) { | 1079 const CallOptimization& call_optimization, |
| 1080 Handle<Map> receiver_map) { |
1079 GenerateFastApiCall( | 1081 GenerateFastApiCall( |
1080 masm(), call_optimization, receiver(), scratch3(), 0, NULL); | 1082 masm(), call_optimization, receiver_map, |
| 1083 receiver(), scratch3(), 0, NULL); |
1081 } | 1084 } |
1082 | 1085 |
1083 | 1086 |
1084 void LoadStubCompiler::GenerateLoadCallback( | 1087 void LoadStubCompiler::GenerateLoadCallback( |
1085 Register reg, | 1088 Register reg, |
1086 Handle<ExecutableAccessorInfo> callback) { | 1089 Handle<ExecutableAccessorInfo> callback) { |
1087 // Build AccessorInfo::args_ list on the stack and push property name below | 1090 // Build AccessorInfo::args_ list on the stack and push property name below |
1088 // the exit frame to make GC aware of them and store pointers to them. | 1091 // the exit frame to make GC aware of them and store pointers to them. |
1089 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); | 1092 STATIC_ASSERT(PropertyCallbackArguments::kHolderIndex == 0); |
1090 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); | 1093 STATIC_ASSERT(PropertyCallbackArguments::kIsolateIndex == 1); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1260 Handle<Code> StoreStubCompiler::CompileStoreCallback( | 1263 Handle<Code> StoreStubCompiler::CompileStoreCallback( |
1261 Handle<JSObject> object, | 1264 Handle<JSObject> object, |
1262 Handle<JSObject> holder, | 1265 Handle<JSObject> holder, |
1263 Handle<Name> name, | 1266 Handle<Name> name, |
1264 const CallOptimization& call_optimization) { | 1267 const CallOptimization& call_optimization) { |
1265 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), | 1268 HandlerFrontend(IC::CurrentTypeOf(object, isolate()), |
1266 receiver(), holder, name); | 1269 receiver(), holder, name); |
1267 | 1270 |
1268 Register values[] = { value() }; | 1271 Register values[] = { value() }; |
1269 GenerateFastApiCall( | 1272 GenerateFastApiCall( |
1270 masm(), call_optimization, receiver(), scratch3(), 1, values); | 1273 masm(), call_optimization, handle(object->map()), |
| 1274 receiver(), scratch3(), 1, values); |
1271 | 1275 |
1272 // Return the generated code. | 1276 // Return the generated code. |
1273 return GetCode(kind(), Code::FAST, name); | 1277 return GetCode(kind(), Code::FAST, name); |
1274 } | 1278 } |
1275 | 1279 |
1276 | 1280 |
1277 #undef __ | 1281 #undef __ |
1278 #define __ ACCESS_MASM(masm) | 1282 #define __ ACCESS_MASM(masm) |
1279 | 1283 |
1280 | 1284 |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 // ----------------------------------- | 1596 // ----------------------------------- |
1593 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1597 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
1594 } | 1598 } |
1595 | 1599 |
1596 | 1600 |
1597 #undef __ | 1601 #undef __ |
1598 | 1602 |
1599 } } // namespace v8::internal | 1603 } } // namespace v8::internal |
1600 | 1604 |
1601 #endif // V8_TARGET_ARCH_ARM | 1605 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |