Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalRuntime.cpp @ 9596:aa8f3fc0a9a9
removed infrastructure for Graal assembler stubs (GRAAL-81)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 07 May 2013 01:58:11 +0200 |
parents | db2125285960 |
children | 1b60f639ac4b |
comparison
equal
deleted
inserted
replaced
9595:db2125285960 | 9596:aa8f3fc0a9a9 |
---|---|
28 #include "memory/oopFactory.hpp" | 28 #include "memory/oopFactory.hpp" |
29 #include "prims/jvm.h" | 29 #include "prims/jvm.h" |
30 #include "runtime/biasedLocking.hpp" | 30 #include "runtime/biasedLocking.hpp" |
31 #include "runtime/interfaceSupport.hpp" | 31 #include "runtime/interfaceSupport.hpp" |
32 #include "utilities/debug.hpp" | 32 #include "utilities/debug.hpp" |
33 // Implementation of GraalStubAssembler | |
34 | |
35 GraalStubAssembler::GraalStubAssembler(CodeBuffer* code, const char * name, int stub_id) : MacroAssembler(code) { | |
36 _name = name; | |
37 _must_gc_arguments = false; | |
38 _frame_size = no_frame_size; | |
39 _num_rt_args = 0; | |
40 _stub_id = stub_id; | |
41 } | |
42 | |
43 | |
44 void GraalStubAssembler::set_info(const char* name, bool must_gc_arguments) { | |
45 _name = name; | |
46 _must_gc_arguments = must_gc_arguments; | |
47 } | |
48 | |
49 | |
50 void GraalStubAssembler::set_frame_size(int size) { | |
51 if (_frame_size == no_frame_size) { | |
52 _frame_size = size; | |
53 } | |
54 assert(_frame_size == size, "can't change the frame size"); | |
55 } | |
56 | |
57 | |
58 void GraalStubAssembler::set_num_rt_args(int args) { | |
59 if (_num_rt_args == 0) { | |
60 _num_rt_args = args; | |
61 } | |
62 assert(_num_rt_args == args, "can't change the number of args"); | |
63 } | |
64 | |
65 // Implementation of GraalRuntime | |
66 | |
67 CodeBlob* GraalRuntime::_blobs[GraalRuntime::number_of_ids]; | |
68 const char *GraalRuntime::_blob_names[] = { | |
69 GRAAL_STUBS(STUB_NAME, LAST_STUB_NAME) | |
70 }; | |
71 | 33 |
72 // Simple helper to see if the caller of a runtime stub which | 34 // Simple helper to see if the caller of a runtime stub which |
73 // entered the VM has been deoptimized | 35 // entered the VM has been deoptimized |
74 | 36 |
75 static bool caller_is_deopted() { | 37 static bool caller_is_deopted() { |
90 frame caller_frame = runtime_frame.sender(®_map); | 52 frame caller_frame = runtime_frame.sender(®_map); |
91 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); | 53 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint); |
92 assert(caller_is_deopted(), "Must be deoptimized"); | 54 assert(caller_is_deopted(), "Must be deoptimized"); |
93 } | 55 } |
94 } | 56 } |
95 | |
96 static bool setup_code_buffer(CodeBuffer* code) { | |
97 // Preinitialize the consts section to some large size: | |
98 int locs_buffer_size = 1 * (relocInfo::length_limit + sizeof(relocInfo)); | |
99 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); | |
100 code->insts()->initialize_shared_locs((relocInfo*)locs_buffer, | |
101 locs_buffer_size / sizeof(relocInfo)); | |
102 | |
103 // Global stubs have neither constants nor local stubs | |
104 code->initialize_consts_size(0); | |
105 code->initialize_stubs_size(0); | |
106 | |
107 return true; | |
108 } | |
109 | |
110 void GraalRuntime::generate_blob_for(BufferBlob* buffer_blob, StubID id) { | |
111 assert(0 <= id && id < number_of_ids, "illegal stub id"); | |
112 ResourceMark rm; | |
113 // create code buffer for code storage | |
114 CodeBuffer code(buffer_blob); | |
115 | |
116 setup_code_buffer(&code); | |
117 | |
118 // create assembler for code generation | |
119 GraalStubAssembler* sasm = new GraalStubAssembler(&code, name_for(id), id); | |
120 // generate code for runtime stub | |
121 OopMapSet* oop_maps; | |
122 oop_maps = generate_code_for(id, sasm); | |
123 assert(oop_maps == NULL || sasm->frame_size() != GraalStubAssembler::no_frame_size, | |
124 "if stub has an oop map it must have a valid frame size"); | |
125 | |
126 #ifdef ASSERT | |
127 // Make sure that stubs that need oopmaps have them | |
128 assert(oop_maps != NULL, "must have an oopmap"); | |
129 #endif | |
130 | |
131 // align so printing shows nop's instead of random code at the end (SimpleStubs are aligned) | |
132 sasm->align(BytesPerWord); | |
133 // make sure all code is in code buffer | |
134 sasm->flush(); | |
135 // create blob - distinguish a few special cases | |
136 CodeBlob* blob = RuntimeStub::new_runtime_stub(name_for(id), | |
137 &code, | |
138 CodeOffsets::frame_never_safe, | |
139 sasm->frame_size(), | |
140 oop_maps, | |
141 sasm->must_gc_arguments()); | |
142 // install blob | |
143 assert(blob != NULL, "blob must exist"); | |
144 _blobs[id] = blob; | |
145 } | |
146 | |
147 | |
148 void GraalRuntime::initialize(BufferBlob* blob) { | |
149 // generate stubs | |
150 for (int id = 0; id < number_of_ids; id++) generate_blob_for(blob, (StubID)id); | |
151 // printing | |
152 #ifndef PRODUCT | |
153 if (GraalPrintSimpleStubs) { | |
154 ResourceMark rm; | |
155 for (int id = 0; id < number_of_ids; id++) { | |
156 _blobs[id]->print(); | |
157 if (_blobs[id]->oop_maps() != NULL) { | |
158 _blobs[id]->oop_maps()->print(); | |
159 } | |
160 } | |
161 } | |
162 #endif | |
163 } | |
164 | |
165 | |
166 CodeBlob* GraalRuntime::blob_for(StubID id) { | |
167 assert(0 <= id && id < number_of_ids, "illegal stub id"); | |
168 return _blobs[id]; | |
169 } | |
170 | |
171 | |
172 const char* GraalRuntime::name_for(StubID id) { | |
173 assert(0 <= id && id < number_of_ids, "illegal stub id"); | |
174 return _blob_names[id]; | |
175 } | |
176 | |
177 const char* GraalRuntime::name_for_address(address entry) { | |
178 for (int id = 0; id < number_of_ids; id++) { | |
179 if (entry == entry_for((StubID)id)) return name_for((StubID)id); | |
180 } | |
181 | |
182 #define FUNCTION_CASE(a, f) \ | |
183 if ((intptr_t)a == CAST_FROM_FN_PTR(intptr_t, f)) return #f | |
184 | |
185 FUNCTION_CASE(entry, os::javaTimeMillis); | |
186 FUNCTION_CASE(entry, os::javaTimeNanos); | |
187 FUNCTION_CASE(entry, SharedRuntime::OSR_migration_end); | |
188 FUNCTION_CASE(entry, SharedRuntime::d2f); | |
189 FUNCTION_CASE(entry, SharedRuntime::d2i); | |
190 FUNCTION_CASE(entry, SharedRuntime::d2l); | |
191 FUNCTION_CASE(entry, SharedRuntime::dcos); | |
192 FUNCTION_CASE(entry, SharedRuntime::dexp); | |
193 FUNCTION_CASE(entry, SharedRuntime::dlog); | |
194 FUNCTION_CASE(entry, SharedRuntime::dlog10); | |
195 FUNCTION_CASE(entry, SharedRuntime::dpow); | |
196 FUNCTION_CASE(entry, SharedRuntime::drem); | |
197 FUNCTION_CASE(entry, SharedRuntime::dsin); | |
198 FUNCTION_CASE(entry, SharedRuntime::dtan); | |
199 FUNCTION_CASE(entry, SharedRuntime::f2i); | |
200 FUNCTION_CASE(entry, SharedRuntime::f2l); | |
201 FUNCTION_CASE(entry, SharedRuntime::frem); | |
202 FUNCTION_CASE(entry, SharedRuntime::l2d); | |
203 FUNCTION_CASE(entry, SharedRuntime::l2f); | |
204 FUNCTION_CASE(entry, SharedRuntime::ldiv); | |
205 FUNCTION_CASE(entry, SharedRuntime::lmul); | |
206 FUNCTION_CASE(entry, SharedRuntime::lrem); | |
207 FUNCTION_CASE(entry, SharedRuntime::lrem); | |
208 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_entry); | |
209 FUNCTION_CASE(entry, SharedRuntime::dtrace_method_exit); | |
210 #ifdef TRACE_HAVE_INTRINSICS | |
211 FUNCTION_CASE(entry, TRACE_TIME_METHOD); | |
212 #endif | |
213 | |
214 ShouldNotReachHere(); | |
215 return NULL; | |
216 | |
217 #undef FUNCTION_CASE | |
218 } | |
219 | |
220 | 57 |
221 JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) | 58 JRT_ENTRY(void, GraalRuntime::new_instance(JavaThread* thread, Klass* klass)) |
222 assert(klass->is_klass(), "not a class"); | 59 assert(klass->is_klass(), "not a class"); |
223 instanceKlassHandle h(thread, klass); | 60 instanceKlassHandle h(thread, klass); |
224 h->check_valid_for_instantiation(true, CHECK); | 61 h->check_valid_for_instantiation(true, CHECK); |
260 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) | 97 JRT_ENTRY(void, GraalRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims)) |
261 assert(klass->is_klass(), "not a class"); | 98 assert(klass->is_klass(), "not a class"); |
262 assert(rank >= 1, "rank must be nonzero"); | 99 assert(rank >= 1, "rank must be nonzero"); |
263 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); | 100 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK); |
264 thread->set_vm_result(obj); | 101 thread->set_vm_result(obj); |
265 JRT_END | |
266 | |
267 JRT_ENTRY(void, GraalRuntime::unimplemented_entry(JavaThread* thread, StubID id)) | |
268 tty->print_cr("GraalRuntime::entry_for(%d) returned unimplemented entry point", id); | |
269 JRT_END | 102 JRT_END |
270 | 103 |
271 extern void vm_exit(int code); | 104 extern void vm_exit(int code); |
272 | 105 |
273 // Enter this method from compiled code handler below. This is where we transition | 106 // Enter this method from compiled code handler below. This is where we transition |