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 1266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1277 // Make r2 the space we have left. The stack might already be overflowed | 1277 // Make r2 the space we have left. The stack might already be overflowed |
1278 // here which will cause r2 to become negative. | 1278 // here which will cause r2 to become negative. |
1279 __ sub(r2, sp, r2); | 1279 __ sub(r2, sp, r2); |
1280 // Check if the arguments will overflow the stack. | 1280 // Check if the arguments will overflow the stack. |
1281 __ cmp(r2, Operand::PointerOffsetFromSmiKey(r0)); | 1281 __ cmp(r2, Operand::PointerOffsetFromSmiKey(r0)); |
1282 __ b(gt, &okay); // Signed comparison. | 1282 __ b(gt, &okay); // Signed comparison. |
1283 | 1283 |
1284 // Out of stack space. | 1284 // Out of stack space. |
1285 __ ldr(r1, MemOperand(fp, kFunctionOffset)); | 1285 __ ldr(r1, MemOperand(fp, kFunctionOffset)); |
1286 __ Push(r1, r0); | 1286 __ Push(r1, r0); |
1287 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 1287 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); |
1288 // End of stack check. | 1288 // End of stack check. |
1289 | 1289 |
1290 // Push current limit and index. | 1290 // Push current limit and index. |
1291 __ bind(&okay); | 1291 __ bind(&okay); |
1292 __ push(r0); // limit | 1292 __ push(r0); // limit |
1293 __ mov(r1, Operand::Zero()); // initial index | 1293 __ mov(r1, Operand::Zero()); // initial index |
1294 __ push(r1); | 1294 __ push(r1); |
1295 | 1295 |
1296 // Get the receiver. | 1296 // Get the receiver. |
1297 __ ldr(r0, MemOperand(fp, kRecvOffset)); | 1297 __ ldr(r0, MemOperand(fp, kRecvOffset)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1400 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), | 1400 __ Call(masm->isolate()->builtins()->ArgumentsAdaptorTrampoline(), |
1401 RelocInfo::CODE_TARGET); | 1401 RelocInfo::CODE_TARGET); |
1402 | 1402 |
1403 // Tear down the internal frame and remove function, receiver and args. | 1403 // Tear down the internal frame and remove function, receiver and args. |
1404 } | 1404 } |
1405 __ add(sp, sp, Operand(3 * kPointerSize)); | 1405 __ add(sp, sp, Operand(3 * kPointerSize)); |
1406 __ Jump(lr); | 1406 __ Jump(lr); |
1407 } | 1407 } |
1408 | 1408 |
1409 | 1409 |
1410 static void ArgumentAdaptorStackCheck(MacroAssembler* masm, | |
1411 Label* stack_overflow) { | |
1412 // ----------- S t a t e ------------- | |
1413 // -- r0 : actual number of arguments | |
1414 // -- r1 : function (passed through to callee) | |
1415 // -- r2 : expected number of arguments | |
1416 // ----------------------------------- | |
1417 // Check the stack for overflow. We are not trying to catch | |
1418 // interruptions (e.g. debug break and preemption) here, so the "real stack | |
1419 // limit" is checked. | |
1420 __ LoadRoot(r5, Heap::kRealStackLimitRootIndex); | |
1421 // Make r5 the space we have left. The stack might already be overflowed | |
1422 // here which will cause r5 to become negative. | |
1423 __ sub(r5, sp, r5); | |
1424 // Check if the arguments will overflow the stack. | |
1425 __ cmp(r5, Operand(r2, LSL, kPointerSizeLog2)); | |
1426 __ b(le, stack_overflow); // Signed comparison. | |
1427 } | |
1428 | |
1429 | |
1430 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1410 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
1431 __ SmiTag(r0); | 1411 __ SmiTag(r0); |
1432 __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); | 1412 __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); |
1433 __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | | 1413 __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | |
1434 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) | | 1414 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) | |
1435 fp.bit() | lr.bit()); | 1415 fp.bit() | lr.bit()); |
1436 __ add(fp, sp, | 1416 __ add(fp, sp, |
1437 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); | 1417 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); |
1438 } | 1418 } |
1439 | 1419 |
(...skipping 19 matching lines...) Expand all Loading... |
1459 } | 1439 } |
1460 | 1440 |
1461 | 1441 |
1462 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { | 1442 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { |
1463 // ----------- S t a t e ------------- | 1443 // ----------- S t a t e ------------- |
1464 // -- r0 : actual number of arguments | 1444 // -- r0 : actual number of arguments |
1465 // -- r1 : function (passed through to callee) | 1445 // -- r1 : function (passed through to callee) |
1466 // -- r2 : expected number of arguments | 1446 // -- r2 : expected number of arguments |
1467 // ----------------------------------- | 1447 // ----------------------------------- |
1468 | 1448 |
1469 Label stack_overflow; | |
1470 ArgumentAdaptorStackCheck(masm, &stack_overflow); | |
1471 Label invoke, dont_adapt_arguments; | 1449 Label invoke, dont_adapt_arguments; |
1472 | 1450 |
1473 Label enough, too_few; | 1451 Label enough, too_few; |
1474 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); | 1452 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); |
1475 __ cmp(r0, r2); | 1453 __ cmp(r0, r2); |
1476 __ b(lt, &too_few); | 1454 __ b(lt, &too_few); |
1477 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 1455 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
1478 __ b(eq, &dont_adapt_arguments); | 1456 __ b(eq, &dont_adapt_arguments); |
1479 | 1457 |
1480 { // Enough parameters: actual >= expected | 1458 { // Enough parameters: actual >= expected |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1560 // Exit frame and return. | 1538 // Exit frame and return. |
1561 LeaveArgumentsAdaptorFrame(masm); | 1539 LeaveArgumentsAdaptorFrame(masm); |
1562 __ Jump(lr); | 1540 __ Jump(lr); |
1563 | 1541 |
1564 | 1542 |
1565 // ------------------------------------------- | 1543 // ------------------------------------------- |
1566 // Dont adapt arguments. | 1544 // Dont adapt arguments. |
1567 // ------------------------------------------- | 1545 // ------------------------------------------- |
1568 __ bind(&dont_adapt_arguments); | 1546 __ bind(&dont_adapt_arguments); |
1569 __ Jump(r3); | 1547 __ Jump(r3); |
1570 | |
1571 __ bind(&stack_overflow); | |
1572 EnterArgumentsAdaptorFrame(masm); | |
1573 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION); | |
1574 __ bkpt(0); | |
1575 } | 1548 } |
1576 | 1549 |
1577 | 1550 |
1578 #undef __ | 1551 #undef __ |
1579 | 1552 |
1580 } } // namespace v8::internal | 1553 } } // namespace v8::internal |
1581 | 1554 |
1582 #endif // V8_TARGET_ARCH_ARM | 1555 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |