00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 class NativeInstruction: ValueObj {
00029 protected:
00030 char* addr_at(int offset) const { return (char*)this + offset; }
00031
00032 char char_at(int offset) const { return *addr_at(offset); }
00033 int long_at(int offset) const { return *(int*)addr_at(offset); }
00034 oop oop_at (int offset) const { return *(oop*)addr_at(offset); }
00035
00036 void set_char_at(int offset, char c) { *addr_at(offset) = c; }
00037 void set_long_at(int offset, int i) { *(int*)addr_at(offset) = i; }
00038 void set_oop_at (int offset, oop o) { *(oop*)addr_at(offset) = o; }
00039 };
00040
00041
00042
00043
00044
00045 class NativeCall: public NativeInstruction {
00046 public:
00047 enum Intel_specific_constants {
00048 instruction_code = 0xE8,
00049 instruction_size = 5,
00050 instruction_offset = -5,
00051 displacement_offset = -4,
00052 return_address_offset = 0,
00053 };
00054
00055 char* instruction_address() const { return addr_at(instruction_offset); }
00056 char* next_instruction_address() const { return addr_at(return_address_offset); }
00057 int displacement() const { return long_at(displacement_offset); }
00058 char* return_address() const { return addr_at(return_address_offset); }
00059 char* destination() const { return return_address() + displacement(); }
00060 void set_destination(char* dest) { set_long_at(displacement_offset, dest - return_address()); }
00061
00062 void verify();
00063 void print();
00064
00065
00066 friend NativeCall* nativeCall_at(char* address);
00067 friend NativeCall* nativeCall_from_return_address(char* return_address);
00068 friend NativeCall* nativeCall_from_relocInfo(char* displacement_address);
00069 };
00070
00071
00072
00073
00074
00075 class NativeMov: public NativeInstruction {
00076 public:
00077 enum Intel_specific_constants {
00078 instruction_code = 0xB8,
00079 instruction_size = 5,
00080 instruction_offset = 0,
00081 data_offset = 1,
00082 next_instruction_offset = 5,
00083 register_mask = 0x07,
00084 };
00085
00086 char* instruction_address() const { return addr_at(instruction_offset); }
00087 char* next_instruction_address() const { return addr_at(next_instruction_offset); }
00088 int data() const { return long_at(data_offset); }
00089 void set_data(int x) { set_long_at(data_offset, x); }
00090
00091 void verify();
00092 void print();
00093
00094
00095 friend NativeMov* nativeMov_at(char* address);
00096 };
00097
00098
00099
00100
00101
00102
00103 class NativeTest: public NativeInstruction {
00104 public:
00105 enum Intel_specific_constants {
00106 instruction_code = 0xA9,
00107 instruction_size = 5,
00108 instruction_offset = 0,
00109 data_offset = 1,
00110 next_instruction_offset = 5,
00111 };
00112
00113 char* instruction_address() const { return addr_at(instruction_offset); }
00114 char* next_instruction_address() const { return addr_at(next_instruction_offset); }
00115 int data() const { return long_at(data_offset); }
00116 void set_data(int x) { set_long_at(data_offset, x); }
00117
00118 void verify();
00119 void print();
00120
00121
00122 friend NativeTest* nativeTest_at(char* address);
00123
00124 };
00125
00126
00127
00128
00129 class IC_Info: public NativeTest {
00130 public:
00131 enum IC_Info_specific_constants {
00132 info_offset = data_offset,
00133 number_of_flags = 8,
00134 flags_mask = (1 << number_of_flags) - 1,
00135 };
00136
00137 char* NLR_target() const { return instruction_address() + (data() >> number_of_flags); }
00138 int flags() const { return data() & flags_mask; }
00139 void set_flags(int flags) { set_data((data() & ~flags_mask) | (flags & flags_mask)); }
00140
00141
00142 friend IC_Info* ic_info_at(char* address);
00143 };
00144
00145