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 999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 // Make rdx the space we need for the array when it is unrolled onto the | 1010 // Make rdx the space we need for the array when it is unrolled onto the |
1011 // stack. | 1011 // stack. |
1012 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rax, kPointerSizeLog2); | 1012 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rax, kPointerSizeLog2); |
1013 // Check if the arguments will overflow the stack. | 1013 // Check if the arguments will overflow the stack. |
1014 __ cmpp(rcx, rdx); | 1014 __ cmpp(rcx, rdx); |
1015 __ j(greater, &okay); // Signed comparison. | 1015 __ j(greater, &okay); // Signed comparison. |
1016 | 1016 |
1017 // Out of stack space. | 1017 // Out of stack space. |
1018 __ Push(Operand(rbp, kFunctionOffset)); | 1018 __ Push(Operand(rbp, kFunctionOffset)); |
1019 __ Push(rax); | 1019 __ Push(rax); |
1020 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, CALL_FUNCTION); | 1020 __ InvokeBuiltin(Builtins::APPLY_OVERFLOW, CALL_FUNCTION); |
1021 __ bind(&okay); | 1021 __ bind(&okay); |
1022 // End of stack check. | 1022 // End of stack check. |
1023 | 1023 |
1024 // Push current index and limit. | 1024 // Push current index and limit. |
1025 const int kLimitOffset = | 1025 const int kLimitOffset = |
1026 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; | 1026 StandardFrameConstants::kExpressionsOffset - 1 * kPointerSize; |
1027 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; | 1027 const int kIndexOffset = kLimitOffset - 1 * kPointerSize; |
1028 __ Push(rax); // limit | 1028 __ Push(rax); // limit |
1029 __ Push(Immediate(0)); // index | 1029 __ Push(Immediate(0)); // index |
1030 | 1030 |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1315 __ IncrementCounter(counters->string_ctor_gc_required(), 1); | 1315 __ IncrementCounter(counters->string_ctor_gc_required(), 1); |
1316 { | 1316 { |
1317 FrameScope scope(masm, StackFrame::INTERNAL); | 1317 FrameScope scope(masm, StackFrame::INTERNAL); |
1318 __ Push(rbx); | 1318 __ Push(rbx); |
1319 __ CallRuntime(Runtime::kNewStringWrapper, 1); | 1319 __ CallRuntime(Runtime::kNewStringWrapper, 1); |
1320 } | 1320 } |
1321 __ ret(0); | 1321 __ ret(0); |
1322 } | 1322 } |
1323 | 1323 |
1324 | 1324 |
1325 static void ArgumentsAdaptorStackCheck(MacroAssembler* masm, | |
1326 Label* stack_overflow) { | |
1327 // ----------- S t a t e ------------- | |
1328 // -- rax : actual number of arguments | |
1329 // -- rbx : expected number of arguments | |
1330 // -- rdi: function (passed through to callee) | |
1331 // ----------------------------------- | |
1332 // Check the stack for overflow. We are not trying to catch | |
1333 // interruptions (e.g. debug break and preemption) here, so the "real stack | |
1334 // limit" is checked. | |
1335 Label okay; | |
1336 __ LoadRoot(rdx, Heap::kRealStackLimitRootIndex); | |
1337 __ movp(rcx, rsp); | |
1338 // Make rcx the space we have left. The stack might already be overflowed | |
1339 // here which will cause rcx to become negative. | |
1340 __ subp(rcx, rdx); | |
1341 // Make rdx the space we need for the array when it is unrolled onto the | |
1342 // stack. | |
1343 __ PositiveSmiTimesPowerOfTwoToInteger64(rdx, rax, kPointerSizeLog2); | |
1344 // Check if the arguments will overflow the stack. | |
1345 __ cmpp(rcx, rdx); | |
1346 __ j(less_equal, stack_overflow); // Signed comparison. | |
1347 } | |
1348 | |
1349 | |
1350 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { | 1325 static void EnterArgumentsAdaptorFrame(MacroAssembler* masm) { |
1351 __ pushq(rbp); | 1326 __ pushq(rbp); |
1352 __ movp(rbp, rsp); | 1327 __ movp(rbp, rsp); |
1353 | 1328 |
1354 // Store the arguments adaptor context sentinel. | 1329 // Store the arguments adaptor context sentinel. |
1355 __ Push(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); | 1330 __ Push(Smi::FromInt(StackFrame::ARGUMENTS_ADAPTOR)); |
1356 | 1331 |
1357 // Push the function on the stack. | 1332 // Push the function on the stack. |
1358 __ Push(rdi); | 1333 __ Push(rdi); |
1359 | 1334 |
(...skipping 25 matching lines...) Expand all Loading... |
1385 // ----------- S t a t e ------------- | 1360 // ----------- S t a t e ------------- |
1386 // -- rax : actual number of arguments | 1361 // -- rax : actual number of arguments |
1387 // -- rbx : expected number of arguments | 1362 // -- rbx : expected number of arguments |
1388 // -- rdi: function (passed through to callee) | 1363 // -- rdi: function (passed through to callee) |
1389 // ----------------------------------- | 1364 // ----------------------------------- |
1390 | 1365 |
1391 Label invoke, dont_adapt_arguments; | 1366 Label invoke, dont_adapt_arguments; |
1392 Counters* counters = masm->isolate()->counters(); | 1367 Counters* counters = masm->isolate()->counters(); |
1393 __ IncrementCounter(counters->arguments_adaptors(), 1); | 1368 __ IncrementCounter(counters->arguments_adaptors(), 1); |
1394 | 1369 |
1395 Label stack_overflow; | |
1396 ArgumentsAdaptorStackCheck(masm, &stack_overflow); | |
1397 | |
1398 Label enough, too_few; | 1370 Label enough, too_few; |
1399 __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); | 1371 __ movp(rdx, FieldOperand(rdi, JSFunction::kCodeEntryOffset)); |
1400 __ cmpp(rax, rbx); | 1372 __ cmpp(rax, rbx); |
1401 __ j(less, &too_few); | 1373 __ j(less, &too_few); |
1402 __ cmpp(rbx, Immediate(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); | 1374 __ cmpp(rbx, Immediate(SharedFunctionInfo::kDontAdaptArgumentsSentinel)); |
1403 __ j(equal, &dont_adapt_arguments); | 1375 __ j(equal, &dont_adapt_arguments); |
1404 | 1376 |
1405 { // Enough parameters: Actual >= expected. | 1377 { // Enough parameters: Actual >= expected. |
1406 __ bind(&enough); | 1378 __ bind(&enough); |
1407 EnterArgumentsAdaptorFrame(masm); | 1379 EnterArgumentsAdaptorFrame(masm); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1460 | 1432 |
1461 // Leave frame and return. | 1433 // Leave frame and return. |
1462 LeaveArgumentsAdaptorFrame(masm); | 1434 LeaveArgumentsAdaptorFrame(masm); |
1463 __ ret(0); | 1435 __ ret(0); |
1464 | 1436 |
1465 // ------------------------------------------- | 1437 // ------------------------------------------- |
1466 // Dont adapt arguments. | 1438 // Dont adapt arguments. |
1467 // ------------------------------------------- | 1439 // ------------------------------------------- |
1468 __ bind(&dont_adapt_arguments); | 1440 __ bind(&dont_adapt_arguments); |
1469 __ jmp(rdx); | 1441 __ jmp(rdx); |
1470 | |
1471 __ bind(&stack_overflow); | |
1472 EnterArgumentsAdaptorFrame(masm); | |
1473 __ InvokeBuiltin(Builtins::STACK_OVERFLOW, JUMP_FUNCTION); | |
1474 __ int3(); | |
1475 } | 1442 } |
1476 | 1443 |
1477 | 1444 |
1478 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1445 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1479 // Lookup the function in the JavaScript frame. | 1446 // Lookup the function in the JavaScript frame. |
1480 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | 1447 __ movp(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); |
1481 { | 1448 { |
1482 FrameScope scope(masm, StackFrame::INTERNAL); | 1449 FrameScope scope(masm, StackFrame::INTERNAL); |
1483 // Pass function as argument. | 1450 // Pass function as argument. |
1484 __ Push(rax); | 1451 __ Push(rax); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 __ bind(&ok); | 1493 __ bind(&ok); |
1527 __ ret(0); | 1494 __ ret(0); |
1528 } | 1495 } |
1529 | 1496 |
1530 | 1497 |
1531 #undef __ | 1498 #undef __ |
1532 | 1499 |
1533 } } // namespace v8::internal | 1500 } } // namespace v8::internal |
1534 | 1501 |
1535 #endif // V8_TARGET_ARCH_X64 | 1502 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |