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