| 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 |
| 1281 void StoreStubCompiler::GenerateStoreViaSetter( | 1285 void StoreStubCompiler::GenerateStoreViaSetter( |
| 1282 MacroAssembler* masm, | 1286 MacroAssembler* masm, |
| 1287 Handle<HeapType> type, |
| 1283 Handle<JSFunction> setter) { | 1288 Handle<JSFunction> setter) { |
| 1284 // ----------- S t a t e ------------- | 1289 // ----------- S t a t e ------------- |
| 1285 // -- r0 : value | 1290 // -- r0 : value |
| 1286 // -- r1 : receiver | 1291 // -- r1 : receiver |
| 1287 // -- r2 : name | 1292 // -- r2 : name |
| 1288 // -- lr : return address | 1293 // -- lr : return address |
| 1289 // ----------------------------------- | 1294 // ----------------------------------- |
| 1290 { | 1295 { |
| 1291 FrameScope scope(masm, StackFrame::INTERNAL); | 1296 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1297 Register receiver = r1; |
| 1298 Register value = r0; |
| 1292 | 1299 |
| 1293 // Save value register, so we can restore it later. | 1300 // Save value register, so we can restore it later. |
| 1294 __ push(r0); | 1301 __ push(value); |
| 1295 | 1302 |
| 1296 if (!setter.is_null()) { | 1303 if (!setter.is_null()) { |
| 1297 // Call the JavaScript setter with receiver and value on the stack. | 1304 // Call the JavaScript setter with receiver and value on the stack. |
| 1298 __ Push(r1, r0); | 1305 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
| 1306 // Swap in the global receiver. |
| 1307 __ ldr(receiver, |
| 1308 FieldMemOperand( |
| 1309 receiver, JSGlobalObject::kGlobalReceiverOffset)); |
| 1310 } |
| 1311 __ Push(receiver, value); |
| 1299 ParameterCount actual(1); | 1312 ParameterCount actual(1); |
| 1300 ParameterCount expected(setter); | 1313 ParameterCount expected(setter); |
| 1301 __ InvokeFunction(setter, expected, actual, | 1314 __ InvokeFunction(setter, expected, actual, |
| 1302 CALL_FUNCTION, NullCallWrapper()); | 1315 CALL_FUNCTION, NullCallWrapper()); |
| 1303 } else { | 1316 } else { |
| 1304 // If we generate a global code snippet for deoptimization only, remember | 1317 // If we generate a global code snippet for deoptimization only, remember |
| 1305 // the place to continue after deoptimization. | 1318 // the place to continue after deoptimization. |
| 1306 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); | 1319 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); |
| 1307 } | 1320 } |
| 1308 | 1321 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1395 static Register registers[] = { r2, r1, r0, r3, r4, r5 }; | 1408 static Register registers[] = { r2, r1, r0, r3, r4, r5 }; |
| 1396 return registers; | 1409 return registers; |
| 1397 } | 1410 } |
| 1398 | 1411 |
| 1399 | 1412 |
| 1400 #undef __ | 1413 #undef __ |
| 1401 #define __ ACCESS_MASM(masm) | 1414 #define __ ACCESS_MASM(masm) |
| 1402 | 1415 |
| 1403 | 1416 |
| 1404 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, | 1417 void LoadStubCompiler::GenerateLoadViaGetter(MacroAssembler* masm, |
| 1418 Handle<HeapType> type, |
| 1405 Register receiver, | 1419 Register receiver, |
| 1406 Handle<JSFunction> getter) { | 1420 Handle<JSFunction> getter) { |
| 1407 // ----------- S t a t e ------------- | 1421 // ----------- S t a t e ------------- |
| 1408 // -- r0 : receiver | 1422 // -- r0 : receiver |
| 1409 // -- r2 : name | 1423 // -- r2 : name |
| 1410 // -- lr : return address | 1424 // -- lr : return address |
| 1411 // ----------------------------------- | 1425 // ----------------------------------- |
| 1412 { | 1426 { |
| 1413 FrameScope scope(masm, StackFrame::INTERNAL); | 1427 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1414 | 1428 |
| 1415 if (!getter.is_null()) { | 1429 if (!getter.is_null()) { |
| 1416 // Call the JavaScript getter with the receiver on the stack. | 1430 // Call the JavaScript getter with the receiver on the stack. |
| 1431 if (IC::TypeToMap(*type, masm->isolate())->IsJSGlobalObjectMap()) { |
| 1432 // Swap in the global receiver. |
| 1433 __ ldr(receiver, |
| 1434 FieldMemOperand( |
| 1435 receiver, JSGlobalObject::kGlobalReceiverOffset)); |
| 1436 } |
| 1417 __ push(receiver); | 1437 __ push(receiver); |
| 1418 ParameterCount actual(0); | 1438 ParameterCount actual(0); |
| 1419 ParameterCount expected(getter); | 1439 ParameterCount expected(getter); |
| 1420 __ InvokeFunction(getter, expected, actual, | 1440 __ InvokeFunction(getter, expected, actual, |
| 1421 CALL_FUNCTION, NullCallWrapper()); | 1441 CALL_FUNCTION, NullCallWrapper()); |
| 1422 } else { | 1442 } else { |
| 1423 // If we generate a global code snippet for deoptimization only, remember | 1443 // If we generate a global code snippet for deoptimization only, remember |
| 1424 // the place to continue after deoptimization. | 1444 // the place to continue after deoptimization. |
| 1425 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); | 1445 masm->isolate()->heap()->SetGetterStubDeoptPCOffset(masm->pc_offset()); |
| 1426 } | 1446 } |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 // ----------------------------------- | 1612 // ----------------------------------- |
| 1593 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1613 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1594 } | 1614 } |
| 1595 | 1615 |
| 1596 | 1616 |
| 1597 #undef __ | 1617 #undef __ |
| 1598 | 1618 |
| 1599 } } // namespace v8::internal | 1619 } } // namespace v8::internal |
| 1600 | 1620 |
| 1601 #endif // V8_TARGET_ARCH_ARM | 1621 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |