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 1518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1529 void MacroAssembler::PopTryHandler() { | 1529 void MacroAssembler::PopTryHandler() { |
1530 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); | 1530 ASSERT_EQ(0, StackHandlerConstants::kNextOffset); |
1531 // Unlink this handler. | 1531 // Unlink this handler. |
1532 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); | 1532 movq(kScratchRegister, ExternalReference(Top::k_handler_address)); |
1533 pop(Operand(kScratchRegister, 0)); | 1533 pop(Operand(kScratchRegister, 0)); |
1534 // Remove the remaining fields. | 1534 // Remove the remaining fields. |
1535 addq(rsp, Immediate(StackHandlerConstants::kSize - kPointerSize)); | 1535 addq(rsp, Immediate(StackHandlerConstants::kSize - kPointerSize)); |
1536 } | 1536 } |
1537 | 1537 |
1538 | 1538 |
| 1539 void MacroAssembler::Throw(Register value) { |
| 1540 // Check that stack should contain next handler, frame pointer, state and |
| 1541 // return address in that order. |
| 1542 STATIC_ASSERT(StackHandlerConstants::kFPOffset + kPointerSize == |
| 1543 StackHandlerConstants::kStateOffset); |
| 1544 STATIC_ASSERT(StackHandlerConstants::kStateOffset + kPointerSize == |
| 1545 StackHandlerConstants::kPCOffset); |
| 1546 // Keep thrown value in rax. |
| 1547 if (!value.is(rax)) { |
| 1548 movq(rax, value); |
| 1549 } |
| 1550 |
| 1551 ExternalReference handler_address(Top::k_handler_address); |
| 1552 movq(kScratchRegister, handler_address); |
| 1553 movq(rsp, Operand(kScratchRegister, 0)); |
| 1554 // get next in chain |
| 1555 pop(rcx); |
| 1556 movq(Operand(kScratchRegister, 0), rcx); |
| 1557 pop(rbp); // pop frame pointer |
| 1558 pop(rdx); // remove state |
| 1559 |
| 1560 // Before returning we restore the context from the frame pointer if not NULL. |
| 1561 // The frame pointer is NULL in the exception handler of a JS entry frame. |
| 1562 Set(rsi, 0); // Tentatively set context pointer to NULL |
| 1563 NearLabel skip; |
| 1564 cmpq(rbp, Immediate(0)); |
| 1565 j(equal, &skip); |
| 1566 movq(rsi, Operand(rbp, StandardFrameConstants::kContextOffset)); |
| 1567 bind(&skip); |
| 1568 ret(0); |
| 1569 } |
| 1570 |
| 1571 |
| 1572 void MacroAssembler::ThrowUncatchable(UncatchableExceptionType type, |
| 1573 Register value) { |
| 1574 // Keep thrown value in rax. |
| 1575 if (!value.is(rax)) { |
| 1576 movq(rax, value); |
| 1577 } |
| 1578 // Fetch top stack handler. |
| 1579 ExternalReference handler_address(Top::k_handler_address); |
| 1580 movq(kScratchRegister, handler_address); |
| 1581 movq(rsp, Operand(kScratchRegister, 0)); |
| 1582 |
| 1583 // Unwind the handlers until the ENTRY handler is found. |
| 1584 NearLabel loop, done; |
| 1585 bind(&loop); |
| 1586 // Load the type of the current stack handler. |
| 1587 const int kStateOffset = StackHandlerConstants::kStateOffset; |
| 1588 cmpq(Operand(rsp, kStateOffset), Immediate(StackHandler::ENTRY)); |
| 1589 j(equal, &done); |
| 1590 // Fetch the next handler in the list. |
| 1591 const int kNextOffset = StackHandlerConstants::kNextOffset; |
| 1592 movq(rsp, Operand(rsp, kNextOffset)); |
| 1593 jmp(&loop); |
| 1594 bind(&done); |
| 1595 |
| 1596 // Set the top handler address to next handler past the current ENTRY handler. |
| 1597 movq(kScratchRegister, handler_address); |
| 1598 pop(Operand(kScratchRegister, 0)); |
| 1599 |
| 1600 if (type == OUT_OF_MEMORY) { |
| 1601 // Set external caught exception to false. |
| 1602 ExternalReference external_caught(Top::k_external_caught_exception_address); |
| 1603 movq(rax, Immediate(false)); |
| 1604 store_rax(external_caught); |
| 1605 |
| 1606 // Set pending exception and rax to out of memory exception. |
| 1607 ExternalReference pending_exception(Top::k_pending_exception_address); |
| 1608 movq(rax, Failure::OutOfMemoryException(), RelocInfo::NONE); |
| 1609 store_rax(pending_exception); |
| 1610 } |
| 1611 |
| 1612 // Clear the context pointer. |
| 1613 Set(rsi, 0); |
| 1614 |
| 1615 // Restore registers from handler. |
| 1616 STATIC_ASSERT(StackHandlerConstants::kNextOffset + kPointerSize == |
| 1617 StackHandlerConstants::kFPOffset); |
| 1618 pop(rbp); // FP |
| 1619 STATIC_ASSERT(StackHandlerConstants::kFPOffset + kPointerSize == |
| 1620 StackHandlerConstants::kStateOffset); |
| 1621 pop(rdx); // State |
| 1622 |
| 1623 STATIC_ASSERT(StackHandlerConstants::kStateOffset + kPointerSize == |
| 1624 StackHandlerConstants::kPCOffset); |
| 1625 ret(0); |
| 1626 } |
| 1627 |
| 1628 |
1539 void MacroAssembler::Ret() { | 1629 void MacroAssembler::Ret() { |
1540 ret(0); | 1630 ret(0); |
1541 } | 1631 } |
1542 | 1632 |
1543 | 1633 |
1544 void MacroAssembler::Ret(int bytes_dropped, Register scratch) { | 1634 void MacroAssembler::Ret(int bytes_dropped, Register scratch) { |
1545 if (is_uint16(bytes_dropped)) { | 1635 if (is_uint16(bytes_dropped)) { |
1546 ret(bytes_dropped); | 1636 ret(bytes_dropped); |
1547 } else { | 1637 } else { |
1548 pop(scratch); | 1638 pop(scratch); |
(...skipping 941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2490 CPU::FlushICache(address_, size_); | 2580 CPU::FlushICache(address_, size_); |
2491 | 2581 |
2492 // Check that the code was patched as expected. | 2582 // Check that the code was patched as expected. |
2493 ASSERT(masm_.pc_ == address_ + size_); | 2583 ASSERT(masm_.pc_ == address_ + size_); |
2494 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); | 2584 ASSERT(masm_.reloc_info_writer.pos() == address_ + size_ + Assembler::kGap); |
2495 } | 2585 } |
2496 | 2586 |
2497 } } // namespace v8::internal | 2587 } } // namespace v8::internal |
2498 | 2588 |
2499 #endif // V8_TARGET_ARCH_X64 | 2589 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |