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 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 // Make x10 the space we have left. The stack might already be overflowed | 1273 // Make x10 the space we have left. The stack might already be overflowed |
1274 // here which will cause x10 to become negative. | 1274 // here which will cause x10 to become negative. |
1275 // TODO(jbramley): Check that the stack usage here is safe. | 1275 // TODO(jbramley): Check that the stack usage here is safe. |
1276 __ Sub(x10, jssp, x10); | 1276 __ Sub(x10, jssp, x10); |
1277 // Check if the arguments will overflow the stack. | 1277 // Check if the arguments will overflow the stack. |
1278 __ Cmp(x10, Operand(argc, LSR, kSmiShift - kPointerSizeLog2)); | 1278 __ Cmp(x10, Operand(argc, LSR, kSmiShift - kPointerSizeLog2)); |
1279 __ B(gt, &enough_stack_space); | 1279 __ B(gt, &enough_stack_space); |
1280 // There is not enough stack space, so use a builtin to throw an appropriate | 1280 // There is not enough stack space, so use a builtin to throw an appropriate |
1281 // error. | 1281 // error. |
1282 __ Push(function, argc); | 1282 __ Push(function, argc); |
1283 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 1283 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); |
1284 // We should never return from the APPLY_OVERFLOW builtin. | 1284 // We should never return from the APPLY_OVERFLOW builtin. |
1285 if (__ emit_debug_code()) { | 1285 if (__ emit_debug_code()) { |
1286 __ Unreachable(); | 1286 __ Unreachable(); |
1287 } | 1287 } |
1288 | 1288 |
1289 __ Bind(&enough_stack_space); | 1289 __ Bind(&enough_stack_space); |
1290 // Push current limit and index. | 1290 // Push current limit and index. |
1291 __ Mov(x1, 0); // Initial index. | 1291 __ Mov(x1, 0); // Initial index. |
1292 __ Push(argc, x1); | 1292 __ Push(argc, x1); |
1293 | 1293 |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1393 __ Mov(x2, 0); | 1393 __ Mov(x2, 0); |
1394 __ GetBuiltinFunction(x1, Builtins::CALL_FUNCTION_PROXY); | 1394 __ GetBuiltinFunction(x1, Builtins::CALL_FUNCTION_PROXY); |
1395 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1395 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1396 RelocInfo::CODE_TARGET); | 1396 RelocInfo::CODE_TARGET); |
1397 } | 1397 } |
1398 __ Drop(3); | 1398 __ Drop(3); |
1399 __ Ret(); | 1399 __ Ret(); |
1400 } | 1400 } |
1401 | 1401 |
1402 | 1402 |
1403 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | |
1404 Label* stack_overflow) { | |
1405 // ----------- S t a t e ------------- | |
1406 // -- x0 : actual number of arguments | |
1407 // -- x1 : function (passed through to callee) | |
1408 // -- x2 : expected number of arguments | |
1409 // ----------------------------------- | |
1410 // Check the stack for overflow. | |
1411 // We are not trying to catch interruptions (e.g. debug break and | |
1412 // preemption) here, so the "real stack limit" is checked. | |
1413 Label enough_stack_space; | |
1414 __ LoadRoot(x10, Heap::kRealStackLimitRootIndex); | |
1415 // Make x10 the space we have left. The stack might already be overflowed | |
1416 // here which will cause x10 to become negative. | |
1417 __ Sub(x10, jssp, x10); | |
1418 __ Mov(x11, jssp); | |
1419 // Check if the arguments will overflow the stack. | |
1420 __ Cmp(x10, Operand(x2, LSL, kPointerSizeLog2)); | |
1421 __ B(le, stack_overflow); | |
1422 } | |
1423 | |
1424 | |
1425 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1403 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
1426 __ SmiTag(x10, x0); | 1404 __ SmiTag(x10, x0); |
1427 __ Mov(x11, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 1405 __ Mov(x11, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
1428 __ Push(lr, fp); | 1406 __ Push(lr, fp); |
1429 __ Push(x11, x1, x10); | 1407 __ Push(x11, x1, x10); |
1430 __ Add(fp, jssp, | 1408 __ Add(fp, jssp, |
1431 StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); | 1409 StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); |
1432 } | 1410 } |
1433 | 1411 |
1434 | 1412 |
(...skipping 13 matching lines...) Expand all Loading... |
1448 | 1426 |
1449 | 1427 |
1450 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1428 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
1451 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); | 1429 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); |
1452 // ----------- S t a t e ------------- | 1430 // ----------- S t a t e ------------- |
1453 // -- x0 : actual number of arguments | 1431 // -- x0 : actual number of arguments |
1454 // -- x1 : function (passed through to callee) | 1432 // -- x1 : function (passed through to callee) |
1455 // -- x2 : expected number of arguments | 1433 // -- x2 : expected number of arguments |
1456 // ----------------------------------- | 1434 // ----------------------------------- |
1457 | 1435 |
1458 Label stack_overflow; | |
1459 ArgumentAdaptorStackCheck(masm, &stack_overflow); | |
1460 | |
1461 Register argc_actual = x0; // Excluding the receiver. | 1436 Register argc_actual = x0; // Excluding the receiver. |
1462 Register argc_expected = x2; // Excluding the receiver. | 1437 Register argc_expected = x2; // Excluding the receiver. |
1463 Register function = x1; | 1438 Register function = x1; |
1464 Register code_entry = x3; | 1439 Register code_entry = x3; |
1465 | 1440 |
1466 Label invoke, dont_adapt_arguments; | 1441 Label invoke, dont_adapt_arguments; |
1467 | 1442 |
1468 Label enough, too_few; | 1443 Label enough, too_few; |
1469 __ Ldr(code_entry, FieldMemOperand(function, JSFunction::kCodeEntryOffset)); | 1444 __ Ldr(code_entry, FieldMemOperand(function, JSFunction::kCodeEntryOffset)); |
1470 __ Cmp(argc_actual, argc_expected); | 1445 __ Cmp(argc_actual, argc_expected); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 // Store offset of return address for deoptimizer. | 1545 // Store offset of return address for deoptimizer. |
1571 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 1546 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
1572 | 1547 |
1573 // Exit frame and return. | 1548 // Exit frame and return. |
1574 LeaveArgumentsAdaptorFrame(masm); | 1549 LeaveArgumentsAdaptorFrame(masm); |
1575 __ Ret(); | 1550 __ Ret(); |
1576 | 1551 |
1577 // Call the entry point without adapting the arguments. | 1552 // Call the entry point without adapting the arguments. |
1578 __ Bind(&dont_adapt_arguments); | 1553 __ Bind(&dont_adapt_arguments); |
1579 __ Jump(code_entry); | 1554 __ Jump(code_entry); |
1580 | |
1581 __ Bind(&stack_overflow); | |
1582 EnterArgumentsAdaptorFrame(masm); | |
1583 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION); | |
1584 __ Brk(0); | |
1585 } | 1555 } |
1586 | 1556 |
1587 | 1557 |
1588 #undef __ | 1558 #undef __ |
1589 | 1559 |
1590 } } // namespace v8::internal | 1560 } } // namespace v8::internal |
1591 | 1561 |
1592 #endif // V8_TARGET_ARCH_ARM | 1562 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |