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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 } | 592 } |
593 | 593 |
594 // This sets the branch destination (which is a load instruction on x64). | 594 // This sets the branch destination (which is a load instruction on x64). |
595 // This is for calls and branches to runtime code. | 595 // This is for calls and branches to runtime code. |
596 inline static void set_external_target_at(Address instruction_payload, | 596 inline static void set_external_target_at(Address instruction_payload, |
597 Address target) { | 597 Address target) { |
598 *reinterpret_cast<Address*>(instruction_payload) = target; | 598 *reinterpret_cast<Address*>(instruction_payload) = target; |
599 } | 599 } |
600 | 600 |
601 inline Handle<Object> code_target_object_handle_at(Address pc); | 601 inline Handle<Object> code_target_object_handle_at(Address pc); |
| 602 inline Address runtime_entry_at(Address pc); |
602 // Number of bytes taken up by the branch target in the code. | 603 // Number of bytes taken up by the branch target in the code. |
603 static const int kSpecialTargetSize = 4; // Use 32-bit displacement. | 604 static const int kSpecialTargetSize = 4; // Use 32-bit displacement. |
604 // Distance between the address of the code target in the call instruction | 605 // Distance between the address of the code target in the call instruction |
605 // and the return address pushed on the stack. | 606 // and the return address pushed on the stack. |
606 static const int kCallTargetAddressOffset = 4; // Use 32-bit displacement. | 607 static const int kCallTargetAddressOffset = 4; // Use 32-bit displacement. |
607 // Distance between the start of the JS return sequence and where the | 608 // Distance between the start of the JS return sequence and where the |
608 // 32-bit displacement of a near call would be, relative to the pushed | 609 // 32-bit displacement of a near call would be, relative to the pushed |
609 // return address. TODO: Use return sequence length instead. | 610 // return address. TODO: Use return sequence length instead. |
610 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset; | 611 // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset; |
611 static const int kPatchReturnSequenceAddressOffset = 13 - 4; | 612 static const int kPatchReturnSequenceAddressOffset = 13 - 4; |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1211 // bind(&L); // illegal: a label may be bound only once | 1212 // bind(&L); // illegal: a label may be bound only once |
1212 // | 1213 // |
1213 // Note: The same Label can be used for forward and backward branches | 1214 // Note: The same Label can be used for forward and backward branches |
1214 // but it may be bound only once. | 1215 // but it may be bound only once. |
1215 | 1216 |
1216 void bind(Label* L); // binds an unbound label L to the current code position | 1217 void bind(Label* L); // binds an unbound label L to the current code position |
1217 | 1218 |
1218 // Calls | 1219 // Calls |
1219 // Call near relative 32-bit displacement, relative to next instruction. | 1220 // Call near relative 32-bit displacement, relative to next instruction. |
1220 void call(Label* L); | 1221 void call(Label* L); |
| 1222 void call(Address entry, RelocInfo::Mode rmode); |
1221 void call(Handle<Code> target, | 1223 void call(Handle<Code> target, |
1222 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, | 1224 RelocInfo::Mode rmode = RelocInfo::CODE_TARGET, |
1223 TypeFeedbackId ast_id = TypeFeedbackId::None()); | 1225 TypeFeedbackId ast_id = TypeFeedbackId::None()); |
1224 | 1226 |
1225 // Calls directly to the given address using a relative offset. | 1227 // Calls directly to the given address using a relative offset. |
1226 // Should only ever be used in Code objects for calls within the | 1228 // Should only ever be used in Code objects for calls within the |
1227 // same Code object. Should not be used when generating new code (use labels), | 1229 // same Code object. Should not be used when generating new code (use labels), |
1228 // but only when patching existing code. | 1230 // but only when patching existing code. |
1229 void call(Address target); | 1231 void call(Address target); |
1230 | 1232 |
1231 // Call near absolute indirect, address in register | 1233 // Call near absolute indirect, address in register |
1232 void call(Register adr); | 1234 void call(Register adr); |
1233 | 1235 |
1234 // Call near indirect | 1236 // Call near indirect |
1235 void call(const Operand& operand); | 1237 void call(const Operand& operand); |
1236 | 1238 |
1237 // Jumps | 1239 // Jumps |
1238 // Jump short or near relative. | 1240 // Jump short or near relative. |
1239 // Use a 32-bit signed displacement. | 1241 // Use a 32-bit signed displacement. |
1240 // Unconditional jump to L | 1242 // Unconditional jump to L |
1241 void jmp(Label* L, Label::Distance distance = Label::kFar); | 1243 void jmp(Label* L, Label::Distance distance = Label::kFar); |
| 1244 void jmp(Address entry, RelocInfo::Mode rmode); |
1242 void jmp(Handle<Code> target, RelocInfo::Mode rmode); | 1245 void jmp(Handle<Code> target, RelocInfo::Mode rmode); |
1243 | 1246 |
1244 // Jump near absolute indirect (r64) | 1247 // Jump near absolute indirect (r64) |
1245 void jmp(Register adr); | 1248 void jmp(Register adr); |
1246 | 1249 |
1247 // Jump near absolute indirect (m64) | 1250 // Jump near absolute indirect (m64) |
1248 void jmp(const Operand& src); | 1251 void jmp(const Operand& src); |
1249 | 1252 |
1250 // Conditional jumps | 1253 // Conditional jumps |
1251 void j(Condition cc, | 1254 void j(Condition cc, |
1252 Label* L, | 1255 Label* L, |
1253 Label::Distance distance = Label::kFar); | 1256 Label::Distance distance = Label::kFar); |
| 1257 void j(Condition cc, Address entry, RelocInfo::Mode rmode); |
1254 void j(Condition cc, Handle<Code> target, RelocInfo::Mode rmode); | 1258 void j(Condition cc, Handle<Code> target, RelocInfo::Mode rmode); |
1255 | 1259 |
1256 // Floating-point operations | 1260 // Floating-point operations |
1257 void fld(int i); | 1261 void fld(int i); |
1258 | 1262 |
1259 void fld1(); | 1263 void fld1(); |
1260 void fldz(); | 1264 void fldz(); |
1261 void fldpi(); | 1265 void fldpi(); |
1262 void fldln2(); | 1266 void fldln2(); |
1263 | 1267 |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1461 // code emission | 1465 // code emission |
1462 void GrowBuffer(); | 1466 void GrowBuffer(); |
1463 | 1467 |
1464 void emit(byte x) { *pc_++ = x; } | 1468 void emit(byte x) { *pc_++ = x; } |
1465 inline void emitl(uint32_t x); | 1469 inline void emitl(uint32_t x); |
1466 inline void emitq(uint64_t x, RelocInfo::Mode rmode); | 1470 inline void emitq(uint64_t x, RelocInfo::Mode rmode); |
1467 inline void emitw(uint16_t x); | 1471 inline void emitw(uint16_t x); |
1468 inline void emit_code_target(Handle<Code> target, | 1472 inline void emit_code_target(Handle<Code> target, |
1469 RelocInfo::Mode rmode, | 1473 RelocInfo::Mode rmode, |
1470 TypeFeedbackId ast_id = TypeFeedbackId::None()); | 1474 TypeFeedbackId ast_id = TypeFeedbackId::None()); |
| 1475 inline void emit_runtime_entry(Address entry, RelocInfo::Mode rmode); |
1471 void emit(Immediate x) { emitl(x.value_); } | 1476 void emit(Immediate x) { emitl(x.value_); } |
1472 | 1477 |
1473 // Emits a REX prefix that encodes a 64-bit operand size and | 1478 // Emits a REX prefix that encodes a 64-bit operand size and |
1474 // the top bit of both register codes. | 1479 // the top bit of both register codes. |
1475 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. | 1480 // High bit of reg goes to REX.R, high bit of rm_reg goes to REX.B. |
1476 // REX.W is set. | 1481 // REX.W is set. |
1477 inline void emit_rex_64(XMMRegister reg, Register rm_reg); | 1482 inline void emit_rex_64(XMMRegister reg, Register rm_reg); |
1478 inline void emit_rex_64(Register reg, XMMRegister rm_reg); | 1483 inline void emit_rex_64(Register reg, XMMRegister rm_reg); |
1479 inline void emit_rex_64(Register reg, Register rm_reg); | 1484 inline void emit_rex_64(Register reg, Register rm_reg); |
1480 | 1485 |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1633 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); | 1638 void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data = 0); |
1634 | 1639 |
1635 friend class CodePatcher; | 1640 friend class CodePatcher; |
1636 friend class EnsureSpace; | 1641 friend class EnsureSpace; |
1637 friend class RegExpMacroAssemblerX64; | 1642 friend class RegExpMacroAssemblerX64; |
1638 | 1643 |
1639 // code generation | 1644 // code generation |
1640 RelocInfoWriter reloc_info_writer; | 1645 RelocInfoWriter reloc_info_writer; |
1641 | 1646 |
1642 List< Handle<Code> > code_targets_; | 1647 List< Handle<Code> > code_targets_; |
| 1648 List<Address> runtime_entries_; |
1643 | 1649 |
1644 PositionsRecorder positions_recorder_; | 1650 PositionsRecorder positions_recorder_; |
1645 friend class PositionsRecorder; | 1651 friend class PositionsRecorder; |
1646 }; | 1652 }; |
1647 | 1653 |
1648 | 1654 |
1649 // Helper class that ensures that there is enough space for generating | 1655 // Helper class that ensures that there is enough space for generating |
1650 // instructions and relocation information. The constructor makes | 1656 // instructions and relocation information. The constructor makes |
1651 // sure that there is enough space and (in debug mode) the destructor | 1657 // sure that there is enough space and (in debug mode) the destructor |
1652 // checks that we did not generate too much. | 1658 // checks that we did not generate too much. |
(...skipping 16 matching lines...) Expand all Loading... |
1669 private: | 1675 private: |
1670 Assembler* assembler_; | 1676 Assembler* assembler_; |
1671 #ifdef DEBUG | 1677 #ifdef DEBUG |
1672 int space_before_; | 1678 int space_before_; |
1673 #endif | 1679 #endif |
1674 }; | 1680 }; |
1675 | 1681 |
1676 } } // namespace v8::internal | 1682 } } // namespace v8::internal |
1677 | 1683 |
1678 #endif // V8_X64_ASSEMBLER_X64_H_ | 1684 #endif // V8_X64_ASSEMBLER_X64_H_ |
OLD | NEW |