| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
| 6 | 6 |
| 7 #include "src/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
| 8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
| 9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
| 10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
| (...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 __ CallRuntime(Runtime::kStackGuard, 0); | 1346 __ CallRuntime(Runtime::kStackGuard, 0); |
| 1347 } | 1347 } |
| 1348 __ Jump(masm->isolate()->builtins()->OnStackReplacement(), | 1348 __ Jump(masm->isolate()->builtins()->OnStackReplacement(), |
| 1349 RelocInfo::CODE_TARGET); | 1349 RelocInfo::CODE_TARGET); |
| 1350 | 1350 |
| 1351 __ Bind(&ok); | 1351 __ Bind(&ok); |
| 1352 __ Ret(); | 1352 __ Ret(); |
| 1353 } | 1353 } |
| 1354 | 1354 |
| 1355 | 1355 |
| 1356 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { | 1356 // static |
| 1357 Register argc = x0; | 1357 void Builtins::Generate_FunctionPrototypeApply(MacroAssembler* masm) { |
| 1358 Register function = x1; | |
| 1359 Register scratch1 = x10; | |
| 1360 Register scratch2 = x11; | |
| 1361 | |
| 1362 ASM_LOCATION("Builtins::Generate_FunctionCall"); | |
| 1363 // 1. Make sure we have at least one argument. | |
| 1364 { | |
| 1365 Label done; | |
| 1366 __ Cbnz(argc, &done); | |
| 1367 __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex); | |
| 1368 __ Push(scratch1); | |
| 1369 __ Mov(argc, 1); | |
| 1370 __ Bind(&done); | |
| 1371 } | |
| 1372 | |
| 1373 // 2. Get the callable to call (passed as receiver) from the stack. | |
| 1374 __ Peek(function, Operand(argc, LSL, kXRegSizeLog2)); | |
| 1375 | |
| 1376 // 3. Shift arguments and return address one slot down on the stack | |
| 1377 // (overwriting the original receiver). Adjust argument count to make | |
| 1378 // the original first argument the new receiver. | |
| 1379 { | |
| 1380 Label loop; | |
| 1381 // Calculate the copy start address (destination). Copy end address is jssp. | |
| 1382 __ Add(scratch2, jssp, Operand(argc, LSL, kPointerSizeLog2)); | |
| 1383 __ Sub(scratch1, scratch2, kPointerSize); | |
| 1384 | |
| 1385 __ Bind(&loop); | |
| 1386 __ Ldr(x12, MemOperand(scratch1, -kPointerSize, PostIndex)); | |
| 1387 __ Str(x12, MemOperand(scratch2, -kPointerSize, PostIndex)); | |
| 1388 __ Cmp(scratch1, jssp); | |
| 1389 __ B(ge, &loop); | |
| 1390 // Adjust the actual number of arguments and remove the top element | |
| 1391 // (which is a copy of the last argument). | |
| 1392 __ Sub(argc, argc, 1); | |
| 1393 __ Drop(1); | |
| 1394 } | |
| 1395 | |
| 1396 // 4. Call the callable. | |
| 1397 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); | |
| 1398 } | |
| 1399 | |
| 1400 | |
| 1401 void Builtins::Generate_FunctionApply(MacroAssembler* masm) { | |
| 1402 // ----------- S t a t e ------------- | 1358 // ----------- S t a t e ------------- |
| 1403 // -- r0 : argc | 1359 // -- r0 : argc |
| 1404 // -- sp[0] : argArray | 1360 // -- sp[0] : argArray |
| 1405 // -- sp[8] : thisArg | 1361 // -- sp[8] : thisArg |
| 1406 // -- sp[16] : receiver | 1362 // -- sp[16] : receiver |
| 1407 // ----------------------------------- | 1363 // ----------------------------------- |
| 1408 ASM_LOCATION("Builtins::Generate_FunctionApply"); | 1364 ASM_LOCATION("Builtins::Generate_FunctionPrototypeApply"); |
| 1409 | 1365 |
| 1410 // 1. Load receiver into x1, argArray into x0 (if present), remove all | 1366 // 1. Load receiver into x1, argArray into x0 (if present), remove all |
| 1411 // arguments from the stack (including the receiver), and push thisArg (if | 1367 // arguments from the stack (including the receiver), and push thisArg (if |
| 1412 // present) instead. | 1368 // present) instead. |
| 1413 { | 1369 { |
| 1414 Label done; | 1370 Label done; |
| 1415 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); | 1371 __ LoadRoot(x2, Heap::kUndefinedValueRootIndex); |
| 1416 __ Mov(x3, x2); | 1372 __ Mov(x3, x2); |
| 1417 __ Peek(x1, Operand(x0, LSL, kPointerSizeLog2)); // receiver | 1373 __ Peek(x1, Operand(x0, LSL, kPointerSizeLog2)); // receiver |
| 1418 __ Subs(x4, x0, 1); | 1374 __ Subs(x4, x0, 1); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1460 | 1416 |
| 1461 // 4c. The receiver is not callable, throw an appropriate TypeError. | 1417 // 4c. The receiver is not callable, throw an appropriate TypeError. |
| 1462 __ Bind(&receiver_not_callable); | 1418 __ Bind(&receiver_not_callable); |
| 1463 { | 1419 { |
| 1464 __ Poke(x1, 0); | 1420 __ Poke(x1, 0); |
| 1465 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); | 1421 __ TailCallRuntime(Runtime::kThrowApplyNonFunction, 1, 1); |
| 1466 } | 1422 } |
| 1467 } | 1423 } |
| 1468 | 1424 |
| 1469 | 1425 |
| 1426 // static |
| 1427 void Builtins::Generate_FunctionPrototypeCall(MacroAssembler* masm) { |
| 1428 Register argc = x0; |
| 1429 Register function = x1; |
| 1430 Register scratch1 = x10; |
| 1431 Register scratch2 = x11; |
| 1432 |
| 1433 ASM_LOCATION("Builtins::Generate_FunctionPrototypeCall"); |
| 1434 |
| 1435 // 1. Make sure we have at least one argument. |
| 1436 { |
| 1437 Label done; |
| 1438 __ Cbnz(argc, &done); |
| 1439 __ LoadRoot(scratch1, Heap::kUndefinedValueRootIndex); |
| 1440 __ Push(scratch1); |
| 1441 __ Mov(argc, 1); |
| 1442 __ Bind(&done); |
| 1443 } |
| 1444 |
| 1445 // 2. Get the callable to call (passed as receiver) from the stack. |
| 1446 __ Peek(function, Operand(argc, LSL, kXRegSizeLog2)); |
| 1447 |
| 1448 // 3. Shift arguments and return address one slot down on the stack |
| 1449 // (overwriting the original receiver). Adjust argument count to make |
| 1450 // the original first argument the new receiver. |
| 1451 { |
| 1452 Label loop; |
| 1453 // Calculate the copy start address (destination). Copy end address is jssp. |
| 1454 __ Add(scratch2, jssp, Operand(argc, LSL, kPointerSizeLog2)); |
| 1455 __ Sub(scratch1, scratch2, kPointerSize); |
| 1456 |
| 1457 __ Bind(&loop); |
| 1458 __ Ldr(x12, MemOperand(scratch1, -kPointerSize, PostIndex)); |
| 1459 __ Str(x12, MemOperand(scratch2, -kPointerSize, PostIndex)); |
| 1460 __ Cmp(scratch1, jssp); |
| 1461 __ B(ge, &loop); |
| 1462 // Adjust the actual number of arguments and remove the top element |
| 1463 // (which is a copy of the last argument). |
| 1464 __ Sub(argc, argc, 1); |
| 1465 __ Drop(1); |
| 1466 } |
| 1467 |
| 1468 // 4. Call the callable. |
| 1469 __ Jump(masm->isolate()->builtins()->Call(), RelocInfo::CODE_TARGET); |
| 1470 } |
| 1471 |
| 1472 |
| 1470 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { | 1473 void Builtins::Generate_ReflectApply(MacroAssembler* masm) { |
| 1471 // ----------- S t a t e ------------- | 1474 // ----------- S t a t e ------------- |
| 1472 // -- x0 : argc | 1475 // -- x0 : argc |
| 1473 // -- sp[0] : argumentsList | 1476 // -- sp[0] : argumentsList |
| 1474 // -- sp[8] : thisArgument | 1477 // -- sp[8] : thisArgument |
| 1475 // -- sp[16] : target | 1478 // -- sp[16] : target |
| 1476 // -- sp[24] : receiver | 1479 // -- sp[24] : receiver |
| 1477 // ----------------------------------- | 1480 // ----------------------------------- |
| 1478 ASM_LOCATION("Builtins::Generate_ReflectApply"); | 1481 ASM_LOCATION("Builtins::Generate_ReflectApply"); |
| 1479 | 1482 |
| (...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2253 } | 2256 } |
| 2254 } | 2257 } |
| 2255 | 2258 |
| 2256 | 2259 |
| 2257 #undef __ | 2260 #undef __ |
| 2258 | 2261 |
| 2259 } // namespace internal | 2262 } // namespace internal |
| 2260 } // namespace v8 | 2263 } // namespace v8 |
| 2261 | 2264 |
| 2262 #endif // V8_TARGET_ARCH_ARM | 2265 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |