OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #if V8_TARGET_ARCH_X64 | 5 #if V8_TARGET_ARCH_X64 |
6 | 6 |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/counters.h" | 9 #include "src/counters.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1418 } | 1418 } |
1419 | 1419 |
1420 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { | 1420 void Builtins::Generate_NotifyStubFailure(MacroAssembler* masm) { |
1421 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); | 1421 Generate_NotifyStubFailureHelper(masm, kDontSaveFPRegs); |
1422 } | 1422 } |
1423 | 1423 |
1424 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { | 1424 void Builtins::Generate_NotifyStubFailureSaveDoubles(MacroAssembler* masm) { |
1425 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); | 1425 Generate_NotifyStubFailureHelper(masm, kSaveFPRegs); |
1426 } | 1426 } |
1427 | 1427 |
| 1428 void Builtins::Generate_NotifyBuiltinContinuation(MacroAssembler* masm) { |
| 1429 // Enter an internal frame. |
| 1430 { |
| 1431 FrameScope scope(masm, StackFrame::INTERNAL); |
| 1432 // Preserve possible return result from lazy deopt. |
| 1433 __ pushq(rax); |
| 1434 __ CallRuntime(Runtime::kNotifyStubFailure, false); |
| 1435 __ popq(rax); |
| 1436 // Tear down internal frame. |
| 1437 } |
| 1438 |
| 1439 __ DropUnderReturnAddress(1); // Ignore state offset |
| 1440 __ ret(0); // Return to ContinueToBuiltin stub still on stack. |
| 1441 } |
| 1442 |
| 1443 namespace { |
| 1444 void Generate_ContinueToBuiltinHelper(MacroAssembler* masm, |
| 1445 bool java_script_builtin, |
| 1446 bool with_result) { |
| 1447 const RegisterConfiguration* config(RegisterConfiguration::Turbofan()); |
| 1448 int allocatable_register_count = config->num_allocatable_general_registers(); |
| 1449 if (with_result) { |
| 1450 // Overwrite the hole inserted by the deoptimizer with the return value from |
| 1451 // the LAZY deopt point. |
| 1452 __ movq(Operand(rsp, |
| 1453 config->num_allocatable_general_registers() * kPointerSize + |
| 1454 BuiltinContinuationFrameConstants::kFixedFrameSize), |
| 1455 rax); |
| 1456 } |
| 1457 for (int i = allocatable_register_count - 1; i >= 0; --i) { |
| 1458 int code = config->GetAllocatableGeneralCode(i); |
| 1459 __ popq(Register::from_code(code)); |
| 1460 if (java_script_builtin && code == kJavaScriptCallArgCountRegister.code()) { |
| 1461 __ SmiToInteger32(Register::from_code(code), Register::from_code(code)); |
| 1462 } |
| 1463 } |
| 1464 __ movq( |
| 1465 rbp, |
| 1466 Operand(rsp, BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp)); |
| 1467 const int offsetToPC = |
| 1468 BuiltinContinuationFrameConstants::kFixedFrameSizeFromFp - kPointerSize; |
| 1469 __ popq(Operand(rsp, offsetToPC)); |
| 1470 __ Drop(offsetToPC / kPointerSize); |
| 1471 __ addq(Operand(rsp, 0), Immediate(Code::kHeaderSize - kHeapObjectTag)); |
| 1472 __ Ret(); |
| 1473 } |
| 1474 } // namespace |
| 1475 |
| 1476 void Builtins::Generate_ContinueToCodeStubBuiltin(MacroAssembler* masm) { |
| 1477 Generate_ContinueToBuiltinHelper(masm, false, false); |
| 1478 } |
| 1479 |
| 1480 void Builtins::Generate_ContinueToCodeStubBuiltinWithResult( |
| 1481 MacroAssembler* masm) { |
| 1482 Generate_ContinueToBuiltinHelper(masm, false, true); |
| 1483 } |
| 1484 |
| 1485 void Builtins::Generate_ContinueToJavaScriptBuiltin(MacroAssembler* masm) { |
| 1486 Generate_ContinueToBuiltinHelper(masm, true, false); |
| 1487 } |
| 1488 |
| 1489 void Builtins::Generate_ContinueToJavaScriptBuiltinWithResult( |
| 1490 MacroAssembler* masm) { |
| 1491 Generate_ContinueToBuiltinHelper(masm, true, true); |
| 1492 } |
| 1493 |
1428 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, | 1494 static void Generate_NotifyDeoptimizedHelper(MacroAssembler* masm, |
1429 Deoptimizer::BailoutType type) { | 1495 Deoptimizer::BailoutType type) { |
1430 // Enter an internal frame. | 1496 // Enter an internal frame. |
1431 { | 1497 { |
1432 FrameScope scope(masm, StackFrame::INTERNAL); | 1498 FrameScope scope(masm, StackFrame::INTERNAL); |
1433 | 1499 |
1434 // Pass the deoptimization type to the runtime system. | 1500 // Pass the deoptimization type to the runtime system. |
1435 __ Push(Smi::FromInt(static_cast<int>(type))); | 1501 __ Push(Smi::FromInt(static_cast<int>(type))); |
1436 | 1502 |
1437 __ CallRuntime(Runtime::kNotifyDeoptimized); | 1503 __ CallRuntime(Runtime::kNotifyDeoptimized); |
(...skipping 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3235 // Now jump to the instructions of the returned code object. | 3301 // Now jump to the instructions of the returned code object. |
3236 __ jmp(r11); | 3302 __ jmp(r11); |
3237 } | 3303 } |
3238 | 3304 |
3239 #undef __ | 3305 #undef __ |
3240 | 3306 |
3241 } // namespace internal | 3307 } // namespace internal |
3242 } // namespace v8 | 3308 } // namespace v8 |
3243 | 3309 |
3244 #endif // V8_TARGET_ARCH_X64 | 3310 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |