128 if (!execution_engine()) {
129 if (!ErrorMsg.empty())
130 printf("Error while creating Shark JIT: %s\n",ErrorMsg.c_str());
131 else
132 printf("Unknown error while creating Shark JIT\n");
133 exit(1);
134 }
135
136 execution_engine()->addModule(_native_context->module());
137
138 // All done
139 set_state(initialized);
140 }
141
142 void SharkCompiler::initialize() {
143 ShouldNotCallThis();
144 }
145
146 void SharkCompiler::compile_method(ciEnv* env,
147 ciMethod* target,
148 int entry_bci) {
149 assert(is_initialized(), "should be");
150 ResourceMark rm;
151 const char *name = methodname(
152 target->holder()->name()->as_utf8(), target->name()->as_utf8());
153
154 // Do the typeflow analysis
155 ciTypeFlow *flow;
156 if (entry_bci == InvocationEntryBci)
157 flow = target->get_flow_analysis();
158 else
159 flow = target->get_osr_flow_analysis(entry_bci);
160 if (flow->failing())
161 return;
162 if (SharkPrintTypeflowOf != NULL) {
163 if (!fnmatch(SharkPrintTypeflowOf, name, 0))
164 flow->print_on(tty);
165 }
166
167 // Create the recorders
168 Arena arena;
199 // Install the method into the VM
200 CodeOffsets offsets;
201 offsets.set_value(CodeOffsets::Deopt, 0);
202 offsets.set_value(CodeOffsets::Exceptions, 0);
203 offsets.set_value(CodeOffsets::Verified_Entry,
204 target->is_static() ? 0 : wordSize);
205
206 ExceptionHandlerTable handler_table;
207 ImplicitExceptionTable inc_table;
208
209 env->register_method(target,
210 entry_bci,
211 &offsets,
212 0,
213 &hscb,
214 0,
215 &oopmaps,
216 &handler_table,
217 &inc_table,
218 this,
219 env->comp_level(),
220 false,
221 false);
222 }
223
224 nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm,
225 methodHandle target,
226 int compile_id,
227 BasicType* arg_types,
228 BasicType return_type) {
229 assert(is_initialized(), "should be");
230 ResourceMark rm;
231 const char *name = methodname(
232 target->klass_name()->as_utf8(), target->name()->as_utf8());
233
234 // Create the code buffer and builder
235 SharkCodeBuffer cb(masm);
236 SharkBuilder builder(&cb);
237
238 // Emit the entry point
239 SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
240
|
128 if (!execution_engine()) {
129 if (!ErrorMsg.empty())
130 printf("Error while creating Shark JIT: %s\n",ErrorMsg.c_str());
131 else
132 printf("Unknown error while creating Shark JIT\n");
133 exit(1);
134 }
135
136 execution_engine()->addModule(_native_context->module());
137
138 // All done
139 set_state(initialized);
140 }
141
142 void SharkCompiler::initialize() {
143 ShouldNotCallThis();
144 }
145
146 void SharkCompiler::compile_method(ciEnv* env,
147 ciMethod* target,
148 int entry_bci,
149 DirectiveSet* dirset) {
150 assert(is_initialized(), "should be");
151 ResourceMark rm;
152 const char *name = methodname(
153 target->holder()->name()->as_utf8(), target->name()->as_utf8());
154
155 // Do the typeflow analysis
156 ciTypeFlow *flow;
157 if (entry_bci == InvocationEntryBci)
158 flow = target->get_flow_analysis();
159 else
160 flow = target->get_osr_flow_analysis(entry_bci);
161 if (flow->failing())
162 return;
163 if (SharkPrintTypeflowOf != NULL) {
164 if (!fnmatch(SharkPrintTypeflowOf, name, 0))
165 flow->print_on(tty);
166 }
167
168 // Create the recorders
169 Arena arena;
200 // Install the method into the VM
201 CodeOffsets offsets;
202 offsets.set_value(CodeOffsets::Deopt, 0);
203 offsets.set_value(CodeOffsets::Exceptions, 0);
204 offsets.set_value(CodeOffsets::Verified_Entry,
205 target->is_static() ? 0 : wordSize);
206
207 ExceptionHandlerTable handler_table;
208 ImplicitExceptionTable inc_table;
209
210 env->register_method(target,
211 entry_bci,
212 &offsets,
213 0,
214 &hscb,
215 0,
216 &oopmaps,
217 &handler_table,
218 &inc_table,
219 this,
220 false,
221 dirset(),
222 false);
223 }
224
225 nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm,
226 methodHandle target,
227 int compile_id,
228 BasicType* arg_types,
229 BasicType return_type) {
230 assert(is_initialized(), "should be");
231 ResourceMark rm;
232 const char *name = methodname(
233 target->klass_name()->as_utf8(), target->name()->as_utf8());
234
235 // Create the code buffer and builder
236 SharkCodeBuffer cb(masm);
237 SharkBuilder builder(&cb);
238
239 // Emit the entry point
240 SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
241
|