changeset 5840:f565e8d4d200

parsing and patching of variable sized NativeCallReg instructions now works properly
author Doug Simon <doug.simon@oracle.com>
date Mon, 16 Jul 2012 15:19:25 +0200
parents 58a607307306
children f84d11672a86
files src/cpu/x86/vm/nativeInst_x86.hpp
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/x86/vm/nativeInst_x86.hpp	Mon Jul 16 15:18:38 2012 +0200
+++ b/src/cpu/x86/vm/nativeInst_x86.hpp	Mon Jul 16 15:19:25 2012 +0200
@@ -186,21 +186,17 @@
  public:
   enum Intel_specific_constants {
     instruction_code            = 0xFF,
-    instruction_size            =    2,
     instruction_offset          =    0,
-    return_address_offset       =    2
+    return_address_offset_norex =    2,
+    return_address_offset_rex   =    3
   };
 
-  address instruction_address() const       { return addr_at(instruction_offset); }
-  address next_instruction_address() const  { return addr_at(return_address_offset); }
-
-
-  static bool is_call_reg_at(address instr) {
-    return ((*instr) & 0xFF) == NativeCallReg::instruction_code;
-  }
-
-  static bool is_call_reg_before(address return_address) {
-    return is_call_reg_at(return_address - NativeCallReg::return_address_offset);
+  int next_instruction_offset() const  {
+    if (ubyte_at(0) == NativeCallReg::instruction_code) {
+      return return_address_offset_norex;
+    } else {
+      return return_address_offset_rex;
+    }
   }
 };
 
@@ -555,7 +551,9 @@
 
 inline bool NativeInstruction::is_illegal()      { return (short)int_at(0) == (short)NativeIllegalInstruction::instruction_code; }
 inline bool NativeInstruction::is_call()         { return ubyte_at(0) == NativeCall::instruction_code; }
-inline bool NativeInstruction::is_call_reg()     { return ubyte_at(0) == NativeCallReg::instruction_code; }
+inline bool NativeInstruction::is_call_reg()     { return ubyte_at(0) == NativeCallReg::instruction_code ||
+                                                          (ubyte_at(1) == NativeCallReg::instruction_code &&
+                                                           (ubyte_at(0) == Assembler::REX || ubyte_at(0) == Assembler::REX_B)); }
 inline bool NativeInstruction::is_return()       { return ubyte_at(0) == NativeReturn::instruction_code ||
                                                           ubyte_at(0) == NativeReturnX::instruction_code; }
 inline bool NativeInstruction::is_jump()         { return ubyte_at(0) == NativeJump::instruction_code ||