| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 // If the provided buffer is not NULL, the assembler uses the provided buffer | 554 // If the provided buffer is not NULL, the assembler uses the provided buffer |
| 555 // for code generation and assumes its size to be buffer_size. If the buffer | 555 // for code generation and assumes its size to be buffer_size. If the buffer |
| 556 // is too small, a fatal error occurs. No deallocation of the buffer is done | 556 // is too small, a fatal error occurs. No deallocation of the buffer is done |
| 557 // upon destruction of the assembler. | 557 // upon destruction of the assembler. |
| 558 Assembler(Isolate* isolate, void* buffer, int buffer_size); | 558 Assembler(Isolate* isolate, void* buffer, int buffer_size); |
| 559 ~Assembler(); | 559 ~Assembler(); |
| 560 | 560 |
| 561 // Overrides the default provided by FLAG_debug_code. | 561 // Overrides the default provided by FLAG_debug_code. |
| 562 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } | 562 void set_emit_debug_code(bool value) { emit_debug_code_ = value; } |
| 563 | 563 |
| 564 // Avoids using instructions that vary in size in unpredictable ways between | |
| 565 // the snapshot and the running VM. This is needed by the full compiler so | |
| 566 // that it can recompile code with debug support and fix the PC. | |
| 567 void set_predictable_code_size(bool value) { predictable_code_size_ = value; } | |
| 568 | |
| 569 // GetCode emits any pending (non-emitted) code and fills the descriptor | 564 // GetCode emits any pending (non-emitted) code and fills the descriptor |
| 570 // desc. GetCode() is idempotent; it returns the same result if no other | 565 // desc. GetCode() is idempotent; it returns the same result if no other |
| 571 // Assembler functions are invoked in between GetCode() calls. | 566 // Assembler functions are invoked in between GetCode() calls. |
| 572 void GetCode(CodeDesc* desc); | 567 void GetCode(CodeDesc* desc); |
| 573 | 568 |
| 574 // Read/Modify the code target in the relative branch/call instruction at pc. | 569 // Read/Modify the code target in the relative branch/call instruction at pc. |
| 575 // On the x64 architecture, we use relative jumps with a 32-bit displacement | 570 // On the x64 architecture, we use relative jumps with a 32-bit displacement |
| 576 // to jump to other Code objects in the Code space in the heap. | 571 // to jump to other Code objects in the Code space in the heap. |
| 577 // Jumps to C functions are done indirectly through a 64-bit register holding | 572 // Jumps to C functions are done indirectly through a 64-bit register holding |
| 578 // the absolute address of the target. | 573 // the absolute address of the target. |
| (...skipping 865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1439 |
| 1445 // Avoid overflows for displacements etc. | 1440 // Avoid overflows for displacements etc. |
| 1446 static const int kMaximalBufferSize = 512*MB; | 1441 static const int kMaximalBufferSize = 512*MB; |
| 1447 static const int kMinimalBufferSize = 4*KB; | 1442 static const int kMinimalBufferSize = 4*KB; |
| 1448 | 1443 |
| 1449 byte byte_at(int pos) { return buffer_[pos]; } | 1444 byte byte_at(int pos) { return buffer_[pos]; } |
| 1450 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } | 1445 void set_byte_at(int pos, byte value) { buffer_[pos] = value; } |
| 1451 | 1446 |
| 1452 protected: | 1447 protected: |
| 1453 bool emit_debug_code() const { return emit_debug_code_; } | 1448 bool emit_debug_code() const { return emit_debug_code_; } |
| 1454 bool predictable_code_size() const { return predictable_code_size_; } | |
| 1455 | 1449 |
| 1456 private: | 1450 private: |
| 1457 byte* addr_at(int pos) { return buffer_ + pos; } | 1451 byte* addr_at(int pos) { return buffer_ + pos; } |
| 1458 uint32_t long_at(int pos) { | 1452 uint32_t long_at(int pos) { |
| 1459 return *reinterpret_cast<uint32_t*>(addr_at(pos)); | 1453 return *reinterpret_cast<uint32_t*>(addr_at(pos)); |
| 1460 } | 1454 } |
| 1461 void long_at_put(int pos, uint32_t x) { | 1455 void long_at_put(int pos, uint32_t x) { |
| 1462 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; | 1456 *reinterpret_cast<uint32_t*>(addr_at(pos)) = x; |
| 1463 } | 1457 } |
| 1464 | 1458 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 | 1643 |
| 1650 // code generation | 1644 // code generation |
| 1651 byte* pc_; // the program counter; moves forward | 1645 byte* pc_; // the program counter; moves forward |
| 1652 RelocInfoWriter reloc_info_writer; | 1646 RelocInfoWriter reloc_info_writer; |
| 1653 | 1647 |
| 1654 List< Handle<Code> > code_targets_; | 1648 List< Handle<Code> > code_targets_; |
| 1655 | 1649 |
| 1656 PositionsRecorder positions_recorder_; | 1650 PositionsRecorder positions_recorder_; |
| 1657 | 1651 |
| 1658 bool emit_debug_code_; | 1652 bool emit_debug_code_; |
| 1659 bool predictable_code_size_; | |
| 1660 | 1653 |
| 1661 friend class PositionsRecorder; | 1654 friend class PositionsRecorder; |
| 1662 }; | 1655 }; |
| 1663 | 1656 |
| 1664 | 1657 |
| 1665 // Helper class that ensures that there is enough space for generating | 1658 // Helper class that ensures that there is enough space for generating |
| 1666 // instructions and relocation information. The constructor makes | 1659 // instructions and relocation information. The constructor makes |
| 1667 // sure that there is enough space and (in debug mode) the destructor | 1660 // sure that there is enough space and (in debug mode) the destructor |
| 1668 // checks that we did not generate too much. | 1661 // checks that we did not generate too much. |
| 1669 class EnsureSpace BASE_EMBEDDED { | 1662 class EnsureSpace BASE_EMBEDDED { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1685 private: | 1678 private: |
| 1686 Assembler* assembler_; | 1679 Assembler* assembler_; |
| 1687 #ifdef DEBUG | 1680 #ifdef DEBUG |
| 1688 int space_before_; | 1681 int space_before_; |
| 1689 #endif | 1682 #endif |
| 1690 }; | 1683 }; |
| 1691 | 1684 |
| 1692 } } // namespace v8::internal | 1685 } } // namespace v8::internal |
| 1693 | 1686 |
| 1694 #endif // V8_X64_ASSEMBLER_X64_H_ | 1687 #endif // V8_X64_ASSEMBLER_X64_H_ |
| OLD | NEW |