OLD | NEW |
---|---|
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
594 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); | 594 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::EAGER); |
595 } | 595 } |
596 | 596 |
597 | 597 |
598 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { | 598 void Builtins::Generate_NotifyLazyDeoptimized(MacroAssembler* masm) { |
599 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); | 599 Generate_NotifyDeoptimizedHelper(masm, Deoptimizer::LAZY); |
600 } | 600 } |
601 | 601 |
602 | 602 |
603 void Builtins::Generate_NotifyOSR(MacroAssembler* masm) { | 603 void Builtins::Generate_NotifyOSR(MacroAssembler* masm) { |
604 __ int3(); | 604 // For now, we are relying on the fact that Runtime::NotifyOSR |
605 // doesn't do any garbage collection which allows us to save/restore | |
606 // the registers without worrying about which of them contain | |
607 // pointers. This seems a bit fragile. | |
608 __ Pushad(); | |
609 __ EnterInternalFrame(); | |
610 __ CallRuntime(Runtime::kNotifyOSR, 0); | |
611 __ LeaveInternalFrame(); | |
612 __ Popad(); | |
613 __ ret(0); | |
605 } | 614 } |
606 | 615 |
607 | 616 |
608 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { | 617 void Builtins::Generate_FunctionCall(MacroAssembler* masm) { |
609 // Stack Layout: | 618 // Stack Layout: |
610 // rsp[0]: Return address | 619 // rsp[0]: Return address |
611 // rsp[1]: Argument n | 620 // rsp[1]: Argument n |
612 // rsp[2]: Argument n-1 | 621 // rsp[2]: Argument n-1 |
613 // ... | 622 // ... |
614 // rsp[n]: Argument 1 | 623 // rsp[n]: Argument 1 |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1399 | 1408 |
1400 // ------------------------------------------- | 1409 // ------------------------------------------- |
1401 // Dont adapt arguments. | 1410 // Dont adapt arguments. |
1402 // ------------------------------------------- | 1411 // ------------------------------------------- |
1403 __ bind(&dont_adapt_arguments); | 1412 __ bind(&dont_adapt_arguments); |
1404 __ jmp(rdx); | 1413 __ jmp(rdx); |
1405 } | 1414 } |
1406 | 1415 |
1407 | 1416 |
1408 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { | 1417 void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
1409 __ int3(); | 1418 // Get the loop depth of the stack guard check. This is recorded in |
1419 // a test(eax, depth) instruction right after the call. | |
Kevin Millikin (Chromium)
2011/02/14 16:02:30
eax ==> rax
Rico
2011/02/15 13:37:06
Done.
| |
1420 Label stack_check; | |
1421 __ movq(rbx, Operand(rsp, 0)); // return address | |
1422 __ movzxbq(rbx, Operand(rbx, 1)); // depth | |
1423 | |
1424 // Get the loop nesting level at which we allow OSR from the | |
1425 // unoptimized code and check if we want to do OSR yet. If not we | |
1426 // should perform a stack guard check so we can get interrupts while | |
1427 // waiting for on-stack replacement. | |
1428 __ movq(rax, Operand(rbp, JavaScriptFrameConstants::kFunctionOffset)); | |
1429 __ movq(rcx, FieldOperand(rax, JSFunction::kSharedFunctionInfoOffset)); | |
1430 __ movq(rcx, FieldOperand(rcx, SharedFunctionInfo::kCodeOffset)); | |
1431 __ cmpb(rbx, FieldOperand(rcx, Code::kAllowOSRAtLoopNestingLevelOffset)); | |
1432 __ j(greater, &stack_check); | |
1433 | |
1434 // Pass the function to optimize as the argument to the on-stack | |
1435 // replacement runtime function. | |
1436 __ EnterInternalFrame(); | |
1437 __ push(rax); | |
1438 __ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); | |
1439 __ LeaveInternalFrame(); | |
1440 | |
1441 // If the result was -1 it means that we couldn't optimize the | |
1442 // function. Just return and continue in the unoptimized version. | |
1443 NearLabel skip; | |
1444 __ SmiCompare(rax, Smi::FromInt(-1)); | |
1445 __ j(not_equal, &skip); | |
1446 __ ret(0); | |
1447 | |
1448 // If we decide not to perform on-stack replacement we perform a | |
1449 // stack guard check to enable interrupts. | |
1450 __ bind(&stack_check); | |
1451 NearLabel ok; | |
1452 __ CompareRoot(rsp, Heap::kStackLimitRootIndex); | |
1453 __ j(above_equal, &ok); | |
1454 | |
1455 StackCheckStub stub; | |
1456 __ TailCallStub(&stub); | |
1457 __ Abort("Unreachable code: returned from tail call."); | |
1458 __ bind(&ok); | |
1459 __ ret(0); | |
1460 | |
1461 __ bind(&skip); | |
1462 // Untag the AST id and push it on the stack. | |
1463 __ SmiToInteger32(rax, rax); | |
1464 __ push(rax); | |
1465 | |
1466 // Generate the code for doing the frame-to-frame translation using | |
1467 // the deoptimizer infrastructure. | |
1468 Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); | |
1469 generator.Generate(); | |
1410 } | 1470 } |
1411 | 1471 |
1412 | 1472 |
1413 #undef __ | 1473 #undef __ |
1414 | 1474 |
1415 } } // namespace v8::internal | 1475 } } // namespace v8::internal |
1416 | 1476 |
1417 #endif // V8_TARGET_ARCH_X64 | 1477 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |