Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(812)

Unified Diff: src/x64/assembler-x64.h

Issue 200095: Add near calls (32-bit displacement) to Code objects on X64 platform. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/serialize.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/x64/assembler-x64.h
===================================================================
--- src/x64/assembler-x64.h (revision 3020)
+++ src/x64/assembler-x64.h (working copy)
@@ -440,18 +440,26 @@
// Assembler functions are invoked in between GetCode() calls.
void GetCode(CodeDesc* desc);
- // Read/Modify the code target in the branch/call instruction at pc.
- // On the x64 architecture, the address is absolute, not relative.
+ // Read/Modify the code target in the relative branch/call instruction at pc.
+ // On the x64 architecture, we use relative jumps with a 32-bit displacement
+ // to jump to other Code objects in the Code space in the heap.
+ // Jumps to C functions are done indirectly through a 64-bit register holding
+ // the absolute address of the target.
+ // These functions convert between absolute Addresses of Code objects and
+ // the relative displacements stored in the code.
static inline Address target_address_at(Address pc);
static inline void set_target_address_at(Address pc, Address target);
-
+ inline Handle<Object> code_target_object_handle_at(Address pc);
// Distance between the address of the code target in the call instruction
- // and the return address. Checked in the debug build.
- static const int kCallTargetAddressOffset = 3 + kPointerSize;
- // Distance between start of patched return sequence and the emitted address
- // to jump to (movq = REX.W 0xB8+r.).
- static const int kPatchReturnSequenceAddressOffset = 2;
-
+ // and the return address pushed on the stack.
+ static const int kCallTargetAddressOffset = 4; // Use 32-bit displacement.
+ // Distance between the start of the JS return sequence and where the
+ // 32-bit displacement of a near call would be, relative to the pushed
+ // return address. TODO: Use return sequence length instead.
+ // Should equal Debug::kX64JSReturnSequenceLength - kCallTargetAddressOffset;
+ static const int kPatchReturnSequenceAddressOffset = 13 - 4;
+ // TODO(X64): Rename this, removing the "Real", after changing the above.
+ static const int kRealPatchReturnSequenceAddressOffset = 2;
// ---------------------------------------------------------------------------
// Code generation
//
@@ -923,6 +931,7 @@
// Calls
// Call near relative 32-bit displacement, relative to next instruction.
void call(Label* L);
+ void call(Handle<Code> target, RelocInfo::Mode rmode);
// Call near absolute indirect, address in register
void call(Register adr);
@@ -932,7 +941,9 @@
// Jumps
// Jump short or near relative.
+ // Use a 32-bit signed displacement.
void jmp(Label* L); // unconditional jump to L
+ void jmp(Handle<Code> target, RelocInfo::Mode rmode);
// Jump near absolute indirect (r64)
void jmp(Register adr);
@@ -942,6 +953,7 @@
// Conditional jumps
void j(Condition cc, Label* L);
+ void j(Condition cc, Handle<Code> target, RelocInfo::Mode rmode);
// Floating-point operations
void fld(int i);
@@ -1047,14 +1059,6 @@
void RecordStatementPosition(int pos);
void WriteRecordedPositions();
- // Writes a doubleword of data in the code stream.
- // Used for inline tables, e.g., jump-tables.
- // void dd(uint32_t data);
-
- // Writes a quadword of data in the code stream.
- // Used for inline tables, e.g., jump-tables.
- // void dd(uint64_t data, RelocInfo::Mode reloc_info);
-
int pc_offset() const { return pc_ - buffer_; }
int current_statement_position() const { return current_statement_position_; }
int current_position() const { return current_position_; }
@@ -1096,9 +1100,9 @@
void emit(byte x) { *pc_++ = x; }
inline void emitl(uint32_t x);
- inline void emit(Handle<Object> handle);
inline void emitq(uint64_t x, RelocInfo::Mode rmode);
inline void emitw(uint16_t x);
+ inline void emit_code_target(Handle<Code> target, RelocInfo::Mode rmode);
void emit(Immediate x) { emitl(x.value_); }
// Emits a REX prefix that encodes a 64-bit operand size and
@@ -1276,6 +1280,7 @@
byte* pc_; // the program counter; moves forward
RelocInfoWriter reloc_info_writer;
+ List< Handle<Code> > code_targets_;
// push-pop elimination
byte* last_pc_;
« no previous file with comments | « src/serialize.cc ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698