| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 __ CallRuntime(Runtime::kNewStringWrapper, 1); | 278 __ CallRuntime(Runtime::kNewStringWrapper, 1); |
| 279 } | 279 } |
| 280 __ Ret(); | 280 __ Ret(); |
| 281 } | 281 } |
| 282 | 282 |
| 283 | 283 |
| 284 static void CallRuntimePassFunction(MacroAssembler* masm, | 284 static void CallRuntimePassFunction(MacroAssembler* masm, |
| 285 Runtime::FunctionId function_id) { | 285 Runtime::FunctionId function_id) { |
| 286 FrameScope scope(masm, StackFrame::INTERNAL); | 286 FrameScope scope(masm, StackFrame::INTERNAL); |
| 287 // - Push a copy of the function onto the stack. | 287 // - Push a copy of the function onto the stack. |
| 288 // - Push call kind information. | 288 // - Push another copy as a parameter to the runtime call. |
| 289 // - Function is also the parameter to the runtime call. | 289 __ Push(x1, x1); |
| 290 __ Push(x1, x5, x1); | |
| 291 | 290 |
| 292 __ CallRuntime(function_id, 1); | 291 __ CallRuntime(function_id, 1); |
| 293 | 292 |
| 294 // - Restore call kind information. | |
| 295 // - Restore receiver. | 293 // - Restore receiver. |
| 296 __ Pop(x5, x1); | 294 __ Pop(x1); |
| 297 } | 295 } |
| 298 | 296 |
| 299 | 297 |
| 300 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { | 298 static void GenerateTailCallToSharedCode(MacroAssembler* masm) { |
| 301 __ Ldr(x2, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 299 __ Ldr(x2, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
| 302 __ Ldr(x2, FieldMemOperand(x2, SharedFunctionInfo::kCodeOffset)); | 300 __ Ldr(x2, FieldMemOperand(x2, SharedFunctionInfo::kCodeOffset)); |
| 303 __ Add(x2, x2, Code::kHeaderSize - kHeapObjectTag); | 301 __ Add(x2, x2, Code::kHeaderSize - kHeapObjectTag); |
| 304 __ Br(x2); | 302 __ Br(x2); |
| 305 } | 303 } |
| 306 | 304 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 __ Drop(1); | 564 __ Drop(1); |
| 567 __ Bind(&done_copying_arguments); | 565 __ Bind(&done_copying_arguments); |
| 568 | 566 |
| 569 // Call the function. | 567 // Call the function. |
| 570 // x0: number of arguments | 568 // x0: number of arguments |
| 571 // x1: constructor function | 569 // x1: constructor function |
| 572 if (is_api_function) { | 570 if (is_api_function) { |
| 573 __ Ldr(cp, FieldMemOperand(constructor, JSFunction::kContextOffset)); | 571 __ Ldr(cp, FieldMemOperand(constructor, JSFunction::kContextOffset)); |
| 574 Handle<Code> code = | 572 Handle<Code> code = |
| 575 masm->isolate()->builtins()->HandleApiCallConstruct(); | 573 masm->isolate()->builtins()->HandleApiCallConstruct(); |
| 576 ParameterCount expected(0); | 574 __ Call(code, RelocInfo::CODE_TARGET); |
| 577 __ InvokeCode(code, expected, expected, | |
| 578 RelocInfo::CODE_TARGET, CALL_FUNCTION, CALL_AS_METHOD); | |
| 579 } else { | 575 } else { |
| 580 ParameterCount actual(argc); | 576 ParameterCount actual(argc); |
| 581 __ InvokeFunction(constructor, actual, CALL_FUNCTION, | 577 __ InvokeFunction(constructor, actual, CALL_FUNCTION, NullCallWrapper()); |
| 582 NullCallWrapper(), CALL_AS_METHOD); | |
| 583 } | 578 } |
| 584 | 579 |
| 585 // Store offset of return address for deoptimizer. | 580 // Store offset of return address for deoptimizer. |
| 586 if (!is_api_function && !count_constructions) { | 581 if (!is_api_function && !count_constructions) { |
| 587 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); | 582 masm->isolate()->heap()->SetConstructStubDeoptPCOffset(masm->pc_offset()); |
| 588 } | 583 } |
| 589 | 584 |
| 590 // Restore the context from the frame. | 585 // Restore the context from the frame. |
| 591 // x0: result | 586 // x0: result |
| 592 // jssp[0]: receiver | 587 // jssp[0]: receiver |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 if (is_construct) { | 718 if (is_construct) { |
| 724 // No type feedback cell is available. | 719 // No type feedback cell is available. |
| 725 Handle<Object> undefined_sentinel( | 720 Handle<Object> undefined_sentinel( |
| 726 masm->isolate()->heap()->undefined_value(), masm->isolate()); | 721 masm->isolate()->heap()->undefined_value(), masm->isolate()); |
| 727 __ Mov(x2, Operand(undefined_sentinel)); | 722 __ Mov(x2, Operand(undefined_sentinel)); |
| 728 | 723 |
| 729 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); | 724 CallConstructStub stub(NO_CALL_FUNCTION_FLAGS); |
| 730 __ CallStub(&stub); | 725 __ CallStub(&stub); |
| 731 } else { | 726 } else { |
| 732 ParameterCount actual(x0); | 727 ParameterCount actual(x0); |
| 733 __ InvokeFunction(function, actual, CALL_FUNCTION, | 728 __ InvokeFunction(function, actual, CALL_FUNCTION, NullCallWrapper()); |
| 734 NullCallWrapper(), CALL_AS_METHOD); | |
| 735 } | 729 } |
| 736 // Exit the JS internal frame and remove the parameters (except function), | 730 // Exit the JS internal frame and remove the parameters (except function), |
| 737 // and return. | 731 // and return. |
| 738 } | 732 } |
| 739 | 733 |
| 740 // Result is in x0. Return. | 734 // Result is in x0. Return. |
| 741 __ Ret(); | 735 __ Ret(); |
| 742 } | 736 } |
| 743 | 737 |
| 744 | 738 |
| 745 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { | 739 void Builtins::Generate_JSEntryTrampoline(MacroAssembler* masm) { |
| 746 Generate_JSEntryTrampolineHelper(masm, false); | 740 Generate_JSEntryTrampolineHelper(masm, false); |
| 747 } | 741 } |
| 748 | 742 |
| 749 | 743 |
| 750 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { | 744 void Builtins::Generate_JSConstructEntryTrampoline(MacroAssembler* masm) { |
| 751 Generate_JSEntryTrampolineHelper(masm, true); | 745 Generate_JSEntryTrampolineHelper(masm, true); |
| 752 } | 746 } |
| 753 | 747 |
| 754 | 748 |
| 755 void Builtins::Generate_CompileUnoptimized(MacroAssembler* masm) { | 749 void Builtins::Generate_CompileUnoptimized(MacroAssembler* masm) { |
| 756 CallRuntimePassFunction(masm, Runtime::kCompileUnoptimized); | 750 CallRuntimePassFunction(masm, Runtime::kCompileUnoptimized); |
| 757 GenerateTailCallToReturnedCode(masm); | 751 GenerateTailCallToReturnedCode(masm); |
| 758 } | 752 } |
| 759 | 753 |
| 760 | 754 |
| 761 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { | 755 static void CallCompileOptimized(MacroAssembler* masm, bool concurrent) { |
| 762 FrameScope scope(masm, StackFrame::INTERNAL); | 756 FrameScope scope(masm, StackFrame::INTERNAL); |
| 763 Register function = x1; | 757 Register function = x1; |
| 764 Register call_kind = x5; | |
| 765 | 758 |
| 766 // Preserve function and call kind. At the same time, push arguments for | 759 // Preserve function. At the same time, push arguments for |
| 767 // kCompileOptimized. | 760 // kCompileOptimized. |
| 768 __ LoadObject(x10, masm->isolate()->factory()->ToBoolean(concurrent)); | 761 __ LoadObject(x10, masm->isolate()->factory()->ToBoolean(concurrent)); |
| 769 __ Push(function, call_kind, function, x10); | 762 __ Push(function, function, x10); |
| 770 | 763 |
| 771 __ CallRuntime(Runtime::kCompileOptimized, 2); | 764 __ CallRuntime(Runtime::kCompileOptimized, 2); |
| 772 | 765 |
| 773 // Restore preserved call kind and function. | 766 // Restore receiver. |
| 774 __ Pop(call_kind, function); | 767 __ Pop(function); |
| 775 } | 768 } |
| 776 | 769 |
| 777 | 770 |
| 778 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { | 771 void Builtins::Generate_CompileOptimized(MacroAssembler* masm) { |
| 779 CallCompileOptimized(masm, false); | 772 CallCompileOptimized(masm, false); |
| 780 GenerateTailCallToReturnedCode(masm); | 773 GenerateTailCallToReturnedCode(masm); |
| 781 } | 774 } |
| 782 | 775 |
| 783 | 776 |
| 784 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { | 777 void Builtins::Generate_CompileOptimizedConcurrent(MacroAssembler* masm) { |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 | 1131 |
| 1139 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, | 1132 // 5a. Call non-function via tail call to CALL_NON_FUNCTION builtin, |
| 1140 // or a function proxy via CALL_FUNCTION_PROXY. | 1133 // or a function proxy via CALL_FUNCTION_PROXY. |
| 1141 // x0: actual number of arguments | 1134 // x0: actual number of arguments |
| 1142 // x1: function | 1135 // x1: function |
| 1143 // x4: call type (0: JS function, 1: function proxy, 2: non-function) | 1136 // x4: call type (0: JS function, 1: function proxy, 2: non-function) |
| 1144 { Label function, non_proxy; | 1137 { Label function, non_proxy; |
| 1145 __ Cbz(x4, &function); | 1138 __ Cbz(x4, &function); |
| 1146 // Expected number of arguments is 0 for CALL_NON_FUNCTION. | 1139 // Expected number of arguments is 0 for CALL_NON_FUNCTION. |
| 1147 __ Mov(x2, 0); | 1140 __ Mov(x2, 0); |
| 1148 __ SetCallKind(x5, CALL_AS_METHOD); | |
| 1149 __ Cmp(x4, 1); | 1141 __ Cmp(x4, 1); |
| 1150 __ B(ne, &non_proxy); | 1142 __ B(ne, &non_proxy); |
| 1151 | 1143 |
| 1152 __ Push(x1); // Re-add proxy object as additional argument. | 1144 __ Push(x1); // Re-add proxy object as additional argument. |
| 1153 __ Add(x0, x0, 1); | 1145 __ Add(x0, x0, 1); |
| 1154 __ GetBuiltinEntry(x3, Builtins::CALL_FUNCTION_PROXY); | 1146 __ GetBuiltinFunction(x1, Builtins::CALL_FUNCTION_PROXY); |
| 1155 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1147 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 1156 RelocInfo::CODE_TARGET); | 1148 RelocInfo::CODE_TARGET); |
| 1157 | 1149 |
| 1158 __ Bind(&non_proxy); | 1150 __ Bind(&non_proxy); |
| 1159 __ GetBuiltinEntry(x3, Builtins::CALL_NON_FUNCTION); | 1151 __ GetBuiltinFunction(x1, Builtins::CALL_NON_FUNCTION); |
| 1160 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1152 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 1161 RelocInfo::CODE_TARGET); | 1153 RelocInfo::CODE_TARGET); |
| 1162 __ Bind(&function); | 1154 __ Bind(&function); |
| 1163 } | 1155 } |
| 1164 | 1156 |
| 1165 // 5b. Get the code to call from the function and check that the number of | 1157 // 5b. Get the code to call from the function and check that the number of |
| 1166 // expected arguments matches what we're providing. If so, jump | 1158 // expected arguments matches what we're providing. If so, jump |
| 1167 // (tail-call) to the code in register edx without checking arguments. | 1159 // (tail-call) to the code in register edx without checking arguments. |
| 1168 // x0: actual number of arguments | 1160 // x0: actual number of arguments |
| 1169 // x1: function | 1161 // x1: function |
| 1170 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | 1162 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
| 1171 __ Ldrsw(x2, | 1163 __ Ldrsw(x2, |
| 1172 FieldMemOperand(x3, | 1164 FieldMemOperand(x3, |
| 1173 SharedFunctionInfo::kFormalParameterCountOffset)); | 1165 SharedFunctionInfo::kFormalParameterCountOffset)); |
| 1174 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); | |
| 1175 __ SetCallKind(x5, CALL_AS_FUNCTION); | |
| 1176 Label dont_adapt_args; | 1166 Label dont_adapt_args; |
| 1177 __ Cmp(x2, x0); // Check formal and actual parameter counts. | 1167 __ Cmp(x2, x0); // Check formal and actual parameter counts. |
| 1178 __ B(eq, &dont_adapt_args); | 1168 __ B(eq, &dont_adapt_args); |
| 1179 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1169 __ Jump(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 1180 RelocInfo::CODE_TARGET); | 1170 RelocInfo::CODE_TARGET); |
| 1171 __ Bind(&dont_adapt_args); |
| 1181 | 1172 |
| 1182 __ Bind(&dont_adapt_args); | 1173 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); |
| 1183 ParameterCount expected(0); | 1174 ParameterCount expected(0); |
| 1184 __ InvokeCode(x3, expected, expected, JUMP_FUNCTION, | 1175 __ InvokeCode(x3, expected, expected, JUMP_FUNCTION, NullCallWrapper()); |
| 1185 NullCallWrapper(), CALL_AS_FUNCTION); | |
| 1186 } | 1176 } |
| 1187 | 1177 |
| 1188 | 1178 |
| 1189 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | 1179 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { |
| 1190 ASM_LOCATION("Builtins::Generate_FunctionApply"); | 1180 ASM_LOCATION("Builtins::Generate_FunctionApply"); |
| 1191 const int kIndexOffset = | 1181 const int kIndexOffset = |
| 1192 StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize); | 1182 StandardFrameConstants::kExpressionsOffset - (2 * kPointerSize); |
| 1193 const int kLimitOffset = | 1183 const int kLimitOffset = |
| 1194 StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize); | 1184 StandardFrameConstants::kExpressionsOffset - (1 * kPointerSize); |
| 1195 const int kArgsOffset = 2 * kPointerSize; | 1185 const int kArgsOffset = 2 * kPointerSize; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 // represented as a smi. | 1308 // represented as a smi. |
| 1319 | 1309 |
| 1320 function = x1; // From now on we want the function to be kept in x1; | 1310 function = x1; // From now on we want the function to be kept in x1; |
| 1321 __ Ldr(function, MemOperand(fp, kFunctionOffset)); | 1311 __ Ldr(function, MemOperand(fp, kFunctionOffset)); |
| 1322 | 1312 |
| 1323 // Call the function. | 1313 // Call the function. |
| 1324 Label call_proxy; | 1314 Label call_proxy; |
| 1325 ParameterCount actual(current); | 1315 ParameterCount actual(current); |
| 1326 __ SmiUntag(current); | 1316 __ SmiUntag(current); |
| 1327 __ JumpIfNotObjectType(function, x10, x11, JS_FUNCTION_TYPE, &call_proxy); | 1317 __ JumpIfNotObjectType(function, x10, x11, JS_FUNCTION_TYPE, &call_proxy); |
| 1328 __ InvokeFunction(function, actual, CALL_FUNCTION, | 1318 __ InvokeFunction(function, actual, CALL_FUNCTION, NullCallWrapper()); |
| 1329 NullCallWrapper(), CALL_AS_FUNCTION); | |
| 1330 frame_scope.GenerateLeaveFrame(); | 1319 frame_scope.GenerateLeaveFrame(); |
| 1331 __ Drop(3); | 1320 __ Drop(3); |
| 1332 __ Ret(); | 1321 __ Ret(); |
| 1333 | 1322 |
| 1334 // Call the function proxy. | 1323 // Call the function proxy. |
| 1335 __ Bind(&call_proxy); | 1324 __ Bind(&call_proxy); |
| 1336 // x0 : argc | 1325 // x0 : argc |
| 1337 // x1 : function | 1326 // x1 : function |
| 1338 __ Push(function); // Add function proxy as last argument. | 1327 __ Push(function); // Add function proxy as last argument. |
| 1339 __ Add(x0, x0, 1); | 1328 __ Add(x0, x0, 1); |
| 1340 __ Mov(x2, 0); | 1329 __ Mov(x2, 0); |
| 1341 __ SetCallKind(x5, CALL_AS_FUNCTION); | 1330 __ GetBuiltinFunction(x1, Builtins::CALL_FUNCTION_PROXY); |
| 1342 __ GetBuiltinEntry(x3, Builtins::CALL_FUNCTION_PROXY); | |
| 1343 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1331 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
| 1344 RelocInfo::CODE_TARGET); | 1332 RelocInfo::CODE_TARGET); |
| 1345 } | 1333 } |
| 1346 __ Drop(3); | 1334 __ Drop(3); |
| 1347 __ Ret(); | 1335 __ Ret(); |
| 1348 } | 1336 } |
| 1349 | 1337 |
| 1350 | 1338 |
| 1351 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1339 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
| 1352 __ SmiTag(x10, x0); | 1340 __ SmiTag(x10, x0); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1372 __ Drop(1); | 1360 __ Drop(1); |
| 1373 } | 1361 } |
| 1374 | 1362 |
| 1375 | 1363 |
| 1376 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1364 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
| 1377 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); | 1365 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); |
| 1378 // ----------- S t a t e ------------- | 1366 // ----------- S t a t e ------------- |
| 1379 // -- x0 : actual number of arguments | 1367 // -- x0 : actual number of arguments |
| 1380 // -- x1 : function (passed through to callee) | 1368 // -- x1 : function (passed through to callee) |
| 1381 // -- x2 : expected number of arguments | 1369 // -- x2 : expected number of arguments |
| 1382 // -- x3 : code entry to call | |
| 1383 // -- x5 : call kind information | |
| 1384 // ----------------------------------- | 1370 // ----------------------------------- |
| 1385 | 1371 |
| 1386 Label invoke, dont_adapt_arguments; | 1372 Label invoke, dont_adapt_arguments; |
| 1387 | 1373 |
| 1388 Label enough, too_few; | 1374 Label enough, too_few; |
| 1375 __ Ldr(x3, FieldMemOperand(x1, JSFunction::kCodeEntryOffset)); |
| 1389 __ Cmp(x0, x2); | 1376 __ Cmp(x0, x2); |
| 1390 __ B(lt, &too_few); | 1377 __ B(lt, &too_few); |
| 1391 __ Cmp(x2, SharedFunctionInfo::kDontAdaptArgumentsSentinel); | 1378 __ Cmp(x2, SharedFunctionInfo::kDontAdaptArgumentsSentinel); |
| 1392 __ B(eq, &dont_adapt_arguments); | 1379 __ B(eq, &dont_adapt_arguments); |
| 1393 | 1380 |
| 1394 { // Enough parameters: actual >= expected | 1381 { // Enough parameters: actual >= expected |
| 1395 EnterArgumentsAdaptorFrame(masm); | 1382 EnterArgumentsAdaptorFrame(masm); |
| 1396 | 1383 |
| 1397 // Calculate copy start address into x10 and end address into x11. | 1384 // Calculate copy start address into x10 and end address into x11. |
| 1398 // x0: actual number of arguments | 1385 // x0: actual number of arguments |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1485 __ Bind(&dont_adapt_arguments); | 1472 __ Bind(&dont_adapt_arguments); |
| 1486 __ Jump(x3); | 1473 __ Jump(x3); |
| 1487 } | 1474 } |
| 1488 | 1475 |
| 1489 | 1476 |
| 1490 #undef __ | 1477 #undef __ |
| 1491 | 1478 |
| 1492 } } // namespace v8::internal | 1479 } } // namespace v8::internal |
| 1493 | 1480 |
| 1494 #endif // V8_TARGET_ARCH_ARM | 1481 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |