Chromium Code Reviews| 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::APPLY_OVERFLOW, CALL_FUNCTION); | 1283 __ InvokeBuiltin(Builtins::STACK_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); | |
|
jbramley
2014/04/24 08:39:45
This move doesn't look necessary.
| |
| 1419 // Check if the arguments will overflow the stack. | |
| 1420 __ Cmp(x10, Operand(x2, LSL, kPointerSizeLog2)); | |
| 1421 __ B(le, stack_overflow); | |
| 1422 } | |
| 1423 | |
| 1424 | |
| 1403 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1425 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
| 1404 __ SmiTag(x10, x0); | 1426 __ SmiTag(x10, x0); |
| 1405 __ Mov(x11, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 1427 __ Mov(x11, Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
| 1406 __ Push(lr, fp); | 1428 __ Push(lr, fp); |
| 1407 __ Push(x11, x1, x10); | 1429 __ Push(x11, x1, x10); |
| 1408 __ Add(fp, jssp, | 1430 __ Add(fp, jssp, |
| 1409 StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); | 1431 StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize); |
| 1410 } | 1432 } |
| 1411 | 1433 |
| 1412 | 1434 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1426 | 1448 |
| 1427 | 1449 |
| 1428 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1450 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
| 1429 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); | 1451 ASM_LOCATION("Builtins::Generate_ArgumentsAdaptorTrampoline"); |
| 1430 // ----------- S t a t e ------------- | 1452 // ----------- S t a t e ------------- |
| 1431 // -- x0 : actual number of arguments | 1453 // -- x0 : actual number of arguments |
| 1432 // -- x1 : function (passed through to callee) | 1454 // -- x1 : function (passed through to callee) |
| 1433 // -- x2 : expected number of arguments | 1455 // -- x2 : expected number of arguments |
| 1434 // ----------------------------------- | 1456 // ----------------------------------- |
| 1435 | 1457 |
| 1458 Label stack_overflow; | |
| 1459 ArgumentAdaptorStackCheck(masm, &stack_overflow); | |
| 1460 | |
| 1436 Register argc_actual = x0; // Excluding the receiver. | 1461 Register argc_actual = x0; // Excluding the receiver. |
| 1437 Register argc_expected = x2; // Excluding the receiver. | 1462 Register argc_expected = x2; // Excluding the receiver. |
| 1438 Register function = x1; | 1463 Register function = x1; |
| 1439 Register code_entry = x3; | 1464 Register code_entry = x3; |
| 1440 | 1465 |
| 1441 Label invoke, dont_adapt_arguments; | 1466 Label invoke, dont_adapt_arguments; |
| 1442 | 1467 |
| 1443 Label enough, too_few; | 1468 Label enough, too_few; |
| 1444 __ Ldr(code_entry, FieldMemOperand(function, JSFunction::kCodeEntryOffset)); | 1469 __ Ldr(code_entry, FieldMemOperand(function, JSFunction::kCodeEntryOffset)); |
| 1445 __ Cmp(argc_actual, argc_expected); | 1470 __ Cmp(argc_actual, argc_expected); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1545 // Store offset of return address for deoptimizer. | 1570 // Store offset of return address for deoptimizer. |
| 1546 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); | 1571 masm->isolate()->heap()->SetArgumentsAdaptorDeoptPCOffset(masm->pc_offset()); |
| 1547 | 1572 |
| 1548 // Exit frame and return. | 1573 // Exit frame and return. |
| 1549 LeaveArgumentsAdaptorFrame(masm); | 1574 LeaveArgumentsAdaptorFrame(masm); |
| 1550 __ Ret(); | 1575 __ Ret(); |
| 1551 | 1576 |
| 1552 // Call the entry point without adapting the arguments. | 1577 // Call the entry point without adapting the arguments. |
| 1553 __ Bind(&dont_adapt_arguments); | 1578 __ Bind(&dont_adapt_arguments); |
| 1554 __ Jump(code_entry); | 1579 __ Jump(code_entry); |
| 1580 | |
| 1581 __ Bind(&stack_overflow); | |
| 1582 { | |
| 1583 FrameScope frame(masm, StackFrame::MANUAL); | |
| 1584 EnterArgumentsAdaptorFrame(masm); | |
| 1585 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | |
| 1586 __ Brk(0); | |
|
jbramley
2014/04/24 08:39:45
'__ Unreachable()' may be more appropriate.
| |
| 1587 } | |
| 1555 } | 1588 } |
| 1556 | 1589 |
| 1557 | 1590 |
| 1558 #undef __ | 1591 #undef __ |
| 1559 | 1592 |
| 1560 } } // namespace v8::internal | 1593 } } // namespace v8::internal |
| 1561 | 1594 |
| 1562 #endif // V8_TARGET_ARCH_ARM | 1595 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |