Mercurial > hg > graal-compiler
comparison src/share/vm/asm/assembler.cpp @ 7206:d2f8c38e543d
Merge
author | roland |
---|---|
date | Fri, 07 Dec 2012 01:09:03 -0800 |
parents | cd3d6a6b95d9 |
children | 18d56ca3e901 |
comparison
equal
deleted
inserted
replaced
7191:816b7e5bf2ed | 7206:d2f8c38e543d |
---|---|
21 * questions. | 21 * questions. |
22 * | 22 * |
23 */ | 23 */ |
24 | 24 |
25 #include "precompiled.hpp" | 25 #include "precompiled.hpp" |
26 #include "asm/assembler.hpp" | 26 #include "asm/macroAssembler.hpp" |
27 #include "asm/assembler.inline.hpp" | 27 #include "asm/macroAssembler.inline.hpp" |
28 #include "asm/codeBuffer.hpp" | 28 #include "asm/codeBuffer.hpp" |
29 #include "runtime/atomic.hpp" | |
30 #include "runtime/atomic.inline.hpp" | |
29 #include "runtime/icache.hpp" | 31 #include "runtime/icache.hpp" |
30 #include "runtime/os.hpp" | 32 #include "runtime/os.hpp" |
31 #ifdef TARGET_ARCH_x86 | |
32 # include "assembler_x86.inline.hpp" | |
33 #endif | |
34 #ifdef TARGET_ARCH_sparc | |
35 # include "assembler_sparc.inline.hpp" | |
36 #endif | |
37 #ifdef TARGET_ARCH_zero | |
38 # include "assembler_zero.inline.hpp" | |
39 #endif | |
40 #ifdef TARGET_ARCH_arm | |
41 # include "assembler_arm.inline.hpp" | |
42 #endif | |
43 #ifdef TARGET_ARCH_ppc | |
44 # include "assembler_ppc.inline.hpp" | |
45 #endif | |
46 | 33 |
47 | 34 |
48 // Implementation of AbstractAssembler | 35 // Implementation of AbstractAssembler |
49 // | 36 // |
50 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster, | 37 // The AbstractAssembler is generating code into a CodeBuffer. To make code generation faster, |
54 | 41 |
55 AbstractAssembler::AbstractAssembler(CodeBuffer* code) { | 42 AbstractAssembler::AbstractAssembler(CodeBuffer* code) { |
56 if (code == NULL) return; | 43 if (code == NULL) return; |
57 CodeSection* cs = code->insts(); | 44 CodeSection* cs = code->insts(); |
58 cs->clear_mark(); // new assembler kills old mark | 45 cs->clear_mark(); // new assembler kills old mark |
46 if (cs->start() == NULL) { | |
47 vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", | |
48 code->name())); | |
49 } | |
59 _code_section = cs; | 50 _code_section = cs; |
60 _code_begin = cs->start(); | |
61 _code_limit = cs->limit(); | |
62 _code_pos = cs->end(); | |
63 _oop_recorder= code->oop_recorder(); | 51 _oop_recorder= code->oop_recorder(); |
64 DEBUG_ONLY( _short_branch_delta = 0; ) | 52 DEBUG_ONLY( _short_branch_delta = 0; ) |
65 if (_code_begin == NULL) { | |
66 vm_exit_out_of_memory(0, err_msg("CodeCache: no room for %s", | |
67 code->name())); | |
68 } | |
69 } | 53 } |
70 | 54 |
71 void AbstractAssembler::set_code_section(CodeSection* cs) { | 55 void AbstractAssembler::set_code_section(CodeSection* cs) { |
72 assert(cs->outer() == code_section()->outer(), "sanity"); | 56 assert(cs->outer() == code_section()->outer(), "sanity"); |
73 assert(cs->is_allocated(), "need to pre-allocate this section"); | 57 assert(cs->is_allocated(), "need to pre-allocate this section"); |
74 cs->clear_mark(); // new assembly into this section kills old mark | 58 cs->clear_mark(); // new assembly into this section kills old mark |
75 _code_section = cs; | 59 _code_section = cs; |
76 _code_begin = cs->start(); | |
77 _code_limit = cs->limit(); | |
78 _code_pos = cs->end(); | |
79 } | 60 } |
80 | 61 |
81 // Inform CodeBuffer that incoming code and relocation will be for stubs | 62 // Inform CodeBuffer that incoming code and relocation will be for stubs |
82 address AbstractAssembler::start_a_stub(int required_space) { | 63 address AbstractAssembler::start_a_stub(int required_space) { |
83 CodeBuffer* cb = code(); | 64 CodeBuffer* cb = code(); |
84 CodeSection* cs = cb->stubs(); | 65 CodeSection* cs = cb->stubs(); |
85 assert(_code_section == cb->insts(), "not in insts?"); | 66 assert(_code_section == cb->insts(), "not in insts?"); |
86 sync(); | |
87 if (cs->maybe_expand_to_ensure_remaining(required_space) | 67 if (cs->maybe_expand_to_ensure_remaining(required_space) |
88 && cb->blob() == NULL) { | 68 && cb->blob() == NULL) { |
89 return NULL; | 69 return NULL; |
90 } | 70 } |
91 set_code_section(cs); | 71 set_code_section(cs); |
94 | 74 |
95 // Inform CodeBuffer that incoming code and relocation will be code | 75 // Inform CodeBuffer that incoming code and relocation will be code |
96 // Should not be called if start_a_stub() returned NULL | 76 // Should not be called if start_a_stub() returned NULL |
97 void AbstractAssembler::end_a_stub() { | 77 void AbstractAssembler::end_a_stub() { |
98 assert(_code_section == code()->stubs(), "not in stubs?"); | 78 assert(_code_section == code()->stubs(), "not in stubs?"); |
99 sync(); | |
100 set_code_section(code()->insts()); | 79 set_code_section(code()->insts()); |
101 } | 80 } |
102 | 81 |
103 // Inform CodeBuffer that incoming code and relocation will be for stubs | 82 // Inform CodeBuffer that incoming code and relocation will be for stubs |
104 address AbstractAssembler::start_a_const(int required_space, int required_align) { | 83 address AbstractAssembler::start_a_const(int required_space, int required_align) { |
105 CodeBuffer* cb = code(); | 84 CodeBuffer* cb = code(); |
106 CodeSection* cs = cb->consts(); | 85 CodeSection* cs = cb->consts(); |
107 assert(_code_section == cb->insts(), "not in insts?"); | 86 assert(_code_section == cb->insts() || _code_section == cb->stubs(), "not in insts/stubs?"); |
108 sync(); | |
109 address end = cs->end(); | 87 address end = cs->end(); |
110 int pad = -(intptr_t)end & (required_align-1); | 88 int pad = -(intptr_t)end & (required_align-1); |
111 if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { | 89 if (cs->maybe_expand_to_ensure_remaining(pad + required_space)) { |
112 if (cb->blob() == NULL) return NULL; | 90 if (cb->blob() == NULL) return NULL; |
113 end = cs->end(); // refresh pointer | 91 end = cs->end(); // refresh pointer |
119 set_code_section(cs); | 97 set_code_section(cs); |
120 return end; | 98 return end; |
121 } | 99 } |
122 | 100 |
123 // Inform CodeBuffer that incoming code and relocation will be code | 101 // Inform CodeBuffer that incoming code and relocation will be code |
124 // Should not be called if start_a_const() returned NULL | 102 // in section cs (insts or stubs). |
125 void AbstractAssembler::end_a_const() { | 103 void AbstractAssembler::end_a_const(CodeSection* cs) { |
126 assert(_code_section == code()->consts(), "not in consts?"); | 104 assert(_code_section == code()->consts(), "not in consts?"); |
127 sync(); | 105 set_code_section(cs); |
128 set_code_section(code()->insts()); | 106 } |
129 } | |
130 | |
131 | 107 |
132 void AbstractAssembler::flush() { | 108 void AbstractAssembler::flush() { |
133 sync(); | |
134 ICache::invalidate_range(addr_at(0), offset()); | 109 ICache::invalidate_range(addr_at(0), offset()); |
135 } | 110 } |
136 | 111 |
137 | 112 |
138 void AbstractAssembler::a_byte(int x) { | 113 void AbstractAssembler::a_byte(int x) { |