28 #include "asm/assembler.hpp" |
28 #include "asm/assembler.hpp" |
29 #include "asm/codeBuffer.hpp" |
29 #include "asm/codeBuffer.hpp" |
30 #include "compiler/disassembler.hpp" |
30 #include "compiler/disassembler.hpp" |
31 #include "runtime/threadLocalStorage.hpp" |
31 #include "runtime/threadLocalStorage.hpp" |
32 |
32 |
33 inline void AbstractAssembler::sync() { |
33 inline address AbstractAssembler::addr_at(int pos) const { |
34 CodeSection* cs = code_section(); |
34 return code_section()->start() + pos; |
35 guarantee(cs->start() == _code_begin, "must not shift code buffer"); |
|
36 cs->set_end(_code_pos); |
|
37 } |
35 } |
38 |
36 |
39 inline void AbstractAssembler::emit_byte(int x) { |
37 void AbstractAssembler::emit_int8(int8_t x) { code_section()->emit_int8 (x); } |
40 assert(isByte(x), "not a byte"); |
38 void AbstractAssembler::emit_int16(int16_t x) { code_section()->emit_int16(x); } |
41 *(unsigned char*)_code_pos = (unsigned char)x; |
39 void AbstractAssembler::emit_int32(int32_t x) { code_section()->emit_int32(x); } |
42 _code_pos += sizeof(unsigned char); |
40 void AbstractAssembler::emit_int64(int64_t x) { code_section()->emit_int64(x); } |
43 sync(); |
|
44 } |
|
45 |
41 |
46 |
42 void AbstractAssembler::emit_float(jfloat x) { code_section()->emit_float(x); } |
47 inline void AbstractAssembler::emit_word(int x) { |
43 void AbstractAssembler::emit_double(jdouble x) { code_section()->emit_double(x); } |
48 *(short*)_code_pos = (short)x; |
44 void AbstractAssembler::emit_address(address x) { code_section()->emit_address(x); } |
49 _code_pos += sizeof(short); |
|
50 sync(); |
|
51 } |
|
52 |
|
53 |
|
54 inline void AbstractAssembler::emit_long(jint x) { |
|
55 *(jint*)_code_pos = x; |
|
56 _code_pos += sizeof(jint); |
|
57 sync(); |
|
58 } |
|
59 |
|
60 inline void AbstractAssembler::emit_address(address x) { |
|
61 *(address*)_code_pos = x; |
|
62 _code_pos += sizeof(address); |
|
63 sync(); |
|
64 } |
|
65 |
45 |
66 inline address AbstractAssembler::inst_mark() const { |
46 inline address AbstractAssembler::inst_mark() const { |
67 return code_section()->mark(); |
47 return code_section()->mark(); |
68 } |
48 } |
69 |
49 |
70 |
|
71 inline void AbstractAssembler::set_inst_mark() { |
50 inline void AbstractAssembler::set_inst_mark() { |
72 code_section()->set_mark(); |
51 code_section()->set_mark(); |
73 } |
52 } |
74 |
|
75 |
53 |
76 inline void AbstractAssembler::clear_inst_mark() { |
54 inline void AbstractAssembler::clear_inst_mark() { |
77 code_section()->clear_mark(); |
55 code_section()->clear_mark(); |
78 } |
56 } |
79 |
57 |
80 |
58 |
81 inline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) { |
59 inline void AbstractAssembler::relocate(RelocationHolder const& rspec, int format) { |
82 assert(!pd_check_instruction_mark() |
60 assert(!pd_check_instruction_mark() |
83 || inst_mark() == NULL || inst_mark() == _code_pos, |
61 || inst_mark() == NULL || inst_mark() == code_section()->end(), |
84 "call relocate() between instructions"); |
62 "call relocate() between instructions"); |
85 code_section()->relocate(_code_pos, rspec, format); |
63 code_section()->relocate(code_section()->end(), rspec, format); |
86 } |
64 } |
87 |
65 |
88 |
66 |
89 inline CodeBuffer* AbstractAssembler::code() const { |
67 inline CodeBuffer* AbstractAssembler::code() const { |
90 return code_section()->outer(); |
68 return code_section()->outer(); |
91 } |
69 } |
92 |
70 |
93 inline int AbstractAssembler::sect() const { |
71 inline int AbstractAssembler::sect() const { |
94 return code_section()->index(); |
72 return code_section()->index(); |
|
73 } |
|
74 |
|
75 inline address AbstractAssembler::pc() const { |
|
76 return code_section()->end(); |
|
77 } |
|
78 |
|
79 inline int AbstractAssembler::offset() const { |
|
80 return code_section()->size(); |
95 } |
81 } |
96 |
82 |
97 inline int AbstractAssembler::locator() const { |
83 inline int AbstractAssembler::locator() const { |
98 return CodeBuffer::locator(offset(), sect()); |
84 return CodeBuffer::locator(offset(), sect()); |
99 } |
85 } |