Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: src/arm/builtins-arm.cc

Issue 215853005: Check stack limit in ArgumentAdaptorTrampoline. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix ws Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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::APPLY_OVERFLOW, CALL_FUNCTION); 1287 __ InvokeBuiltin(Builtins::STACK_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
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
1410 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { 1430 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) {
1411 __ SmiTag(r0); 1431 __ SmiTag(r0);
1412 __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR))); 1432 __ mov(r4, Operand(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)));
1413 __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() | 1433 __ stm(db_w, sp, r0.bit() | r1.bit() | r4.bit() |
1414 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) | 1434 (FLAG_enable_ool_constant_pool ? pp.bit() : 0) |
1415 fp.bit() | lr.bit()); 1435 fp.bit() | lr.bit());
1416 __ add(fp, sp, 1436 __ add(fp, sp,
1417 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize)); 1437 Operand(StandardFrameConstants::kFixedFrameSizeFromFp + kPointerSize));
1418 } 1438 }
1419 1439
(...skipping 19 matching lines...) Expand all
1439 } 1459 }
1440 1460
1441 1461
1442 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) { 1462 void Builtins::Generate_ArgumentsAdaptorTrampoline(MacroAssembler* masm) {
1443 // ----------- S t a t e ------------- 1463 // ----------- S t a t e -------------
1444 // -- r0 : actual number of arguments 1464 // -- r0 : actual number of arguments
1445 // -- r1 : function (passed through to callee) 1465 // -- r1 : function (passed through to callee)
1446 // -- r2 : expected number of arguments 1466 // -- r2 : expected number of arguments
1447 // ----------------------------------- 1467 // -----------------------------------
1448 1468
1469 Label stack_overflow;
1470 ArgumentAdaptorStackCheck(masm, &stack_overflow);
1449 Label invoke, dont_adapt_arguments; 1471 Label invoke, dont_adapt_arguments;
1450 1472
1451 Label enough, too_few; 1473 Label enough, too_few;
1452 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset)); 1474 __ ldr(r3, FieldMemOperand(r1, JSFunction::kCodeEntryOffset));
1453 __ cmp(r0, r2); 1475 __ cmp(r0, r2);
1454 __ b(lt, &too_few); 1476 __ b(lt, &too_few);
1455 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); 1477 __ cmp(r2, Operand(SharedFunctionInfo::kDontAdaptArgumentsSentinel));
1456 __ b(eq, &dont_adapt_arguments); 1478 __ b(eq, &dont_adapt_arguments);
1457 1479
1458 { // Enough parameters: actual >= expected 1480 { // Enough parameters: actual >= expected
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 // Exit frame and return. 1560 // Exit frame and return.
1539 LeaveArgumentsAdaptorFrame(masm); 1561 LeaveArgumentsAdaptorFrame(masm);
1540 __ Jump(lr); 1562 __ Jump(lr);
1541 1563
1542 1564
1543 // ------------------------------------------- 1565 // -------------------------------------------
1544 // Dont adapt arguments. 1566 // Dont adapt arguments.
1545 // ------------------------------------------- 1567 // -------------------------------------------
1546 __ bind(&dont_adapt_arguments); 1568 __ bind(&dont_adapt_arguments);
1547 __ Jump(r3); 1569 __ Jump(r3);
1570
1571 __ bind(&stack_overflow);
1572 EnterArgumentsAdaptorFrame(masm);
1573 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION);
1574 __ bkpt(0);
1548 } 1575 }
1549 1576
1550 1577
1551 #undef __ 1578 #undef __
1552 1579
1553 } } // namespace v8::internal 1580 } } // namespace v8::internal
1554 1581
1555 #endif // V8_TARGET_ARCH_ARM 1582 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | src/arm64/builtins-arm64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698