23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_CFGPrinter.hpp"
27 #include "c1/c1_Canonicalizer.hpp"
28 #include "c1/c1_Compilation.hpp"
29 #include "c1/c1_GraphBuilder.hpp"
30 #include "c1/c1_InstructionPrinter.hpp"
31 #include "ci/ciCallSite.hpp"
32 #include "ci/ciField.hpp"
33 #include "ci/ciKlass.hpp"
34 #include "ci/ciMemberName.hpp"
35 #include "compiler/compileBroker.hpp"
36 #include "interpreter/bytecode.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/compilationPolicy.hpp"
41 #include "runtime/vm_version.hpp"
42 #include "utilities/bitMap.inline.hpp"
43
44 class BlockListBuilder VALUE_OBJ_CLASS_SPEC {
45 private:
46 Compilation* _compilation;
47 IRScope* _scope;
48
49 BlockList _blocks; // internal list of all blocks
50 BlockList* _bci2block; // mapping from bci to blocks for GraphBuilder
51
52 // fields used by mark_loops
53 ResourceBitMap _active; // for iteration of control flow graph
54 ResourceBitMap _visited; // for iteration of control flow graph
55 intArray _loop_map; // caches the information if a block is contained in a loop
56 int _next_loop_index; // next free loop number
57 int _next_block_number; // for reverse postorder numbering of blocks
58
59 // accessors
60 Compilation* compilation() const { return _compilation; }
61 IRScope* scope() const { return _scope; }
62 ciMethod* method() const { return scope()->method(); }
4260 assert (type2aelembytes(T_CHAR) == type2aelembytes(T_BYTE)*2,
4261 "sanity: byte[] and char[] scales agree");
4262
4263 ValueStack* state_before = copy_state_indexed_access();
4264 compilation()->set_has_access_indexed(true);
4265 Values* args = state()->pop_arguments(callee->arg_size());
4266 Value array = args->at(0);
4267 Value index = args->at(1);
4268 if (is_store) {
4269 Value value = args->at(2);
4270 Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before, false, true));
4271 store->set_flag(Instruction::NeedsRangeCheckFlag, false);
4272 _memory->store_value(value);
4273 } else {
4274 Instruction* load = append(new LoadIndexed(array, index, NULL, T_CHAR, state_before, true));
4275 load->set_flag(Instruction::NeedsRangeCheckFlag, false);
4276 push(load->type(), load);
4277 }
4278 }
4279
4280 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) {
4281 CompileLog* log = compilation()->log();
4282 if (log != NULL) {
4283 if (success) {
4284 if (msg != NULL)
4285 log->inline_success(msg);
4286 else
4287 log->inline_success("receiver is statically known");
4288 } else {
4289 if (msg != NULL)
4290 log->inline_fail(msg);
4291 else
4292 log->inline_fail("reason unknown");
4293 }
4294 }
4295 #if INCLUDE_TRACE
4296 EventCompilerInlining event;
4297 if (event.should_commit()) {
4298 event.set_compileId(compilation()->env()->task()->compile_id());
4299 event.set_message(msg);
4300 event.set_succeeded(success);
4301 event.set_bci(bci());
4302 event.set_caller(method()->get_Method());
4303 event.set_callee(callee->to_trace_struct());
4304 event.commit();
4305 }
4306 #endif // INCLUDE_TRACE
4307
4308 CompileTask::print_inlining_ul(callee, scope()->level(), bci(), msg);
4309
4310 if (!compilation()->directive()->PrintInliningOption) {
4311 return;
4312 }
4313 CompileTask::print_inlining_tty(callee, scope()->level(), bci(), msg);
4314 if (success && CIPrintMethodCodes) {
4315 callee->print_codes();
4316 }
4317 }
4318
4319 void GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) {
4320 Values* args = state()->pop_arguments(callee->arg_size());
4321 BasicType t = callee->return_type()->basic_type();
4322 null_check(args->at(0));
4323 Instruction* offset = args->at(2);
4324 #ifndef _LP64
4325 offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4326 #endif
|
23 */
24
25 #include "precompiled.hpp"
26 #include "c1/c1_CFGPrinter.hpp"
27 #include "c1/c1_Canonicalizer.hpp"
28 #include "c1/c1_Compilation.hpp"
29 #include "c1/c1_GraphBuilder.hpp"
30 #include "c1/c1_InstructionPrinter.hpp"
31 #include "ci/ciCallSite.hpp"
32 #include "ci/ciField.hpp"
33 #include "ci/ciKlass.hpp"
34 #include "ci/ciMemberName.hpp"
35 #include "compiler/compileBroker.hpp"
36 #include "interpreter/bytecode.hpp"
37 #include "memory/resourceArea.hpp"
38 #include "oops/oop.inline.hpp"
39 #include "runtime/sharedRuntime.hpp"
40 #include "runtime/compilationPolicy.hpp"
41 #include "runtime/vm_version.hpp"
42 #include "utilities/bitMap.inline.hpp"
43 #if INCLUDE_TRACE
44 #include "trace/tracing.hpp"
45 #include "tracefiles/traceEventClasses.hpp"
46 #endif
47
48 class BlockListBuilder VALUE_OBJ_CLASS_SPEC {
49 private:
50 Compilation* _compilation;
51 IRScope* _scope;
52
53 BlockList _blocks; // internal list of all blocks
54 BlockList* _bci2block; // mapping from bci to blocks for GraphBuilder
55
56 // fields used by mark_loops
57 ResourceBitMap _active; // for iteration of control flow graph
58 ResourceBitMap _visited; // for iteration of control flow graph
59 intArray _loop_map; // caches the information if a block is contained in a loop
60 int _next_loop_index; // next free loop number
61 int _next_block_number; // for reverse postorder numbering of blocks
62
63 // accessors
64 Compilation* compilation() const { return _compilation; }
65 IRScope* scope() const { return _scope; }
66 ciMethod* method() const { return scope()->method(); }
4264 assert (type2aelembytes(T_CHAR) == type2aelembytes(T_BYTE)*2,
4265 "sanity: byte[] and char[] scales agree");
4266
4267 ValueStack* state_before = copy_state_indexed_access();
4268 compilation()->set_has_access_indexed(true);
4269 Values* args = state()->pop_arguments(callee->arg_size());
4270 Value array = args->at(0);
4271 Value index = args->at(1);
4272 if (is_store) {
4273 Value value = args->at(2);
4274 Instruction* store = append(new StoreIndexed(array, index, NULL, T_CHAR, value, state_before, false, true));
4275 store->set_flag(Instruction::NeedsRangeCheckFlag, false);
4276 _memory->store_value(value);
4277 } else {
4278 Instruction* load = append(new LoadIndexed(array, index, NULL, T_CHAR, state_before, true));
4279 load->set_flag(Instruction::NeedsRangeCheckFlag, false);
4280 push(load->type(), load);
4281 }
4282 }
4283
4284 #if INCLUDE_TRACE
4285 static void post_inlining_event(int compile_id,
4286 const char* msg,
4287 bool success,
4288 int bci,
4289 ciMethod* caller,
4290 ciMethod* callee) {
4291 assert(caller != NULL, "invariant");
4292 assert(callee != NULL, "invariant");
4293
4294 EventCompilerInlining event;
4295 if (event.should_commit()) {
4296 TraceStructCalleeMethod callee_struct;
4297 callee_struct.set_type(callee->holder()->name()->as_utf8());
4298 callee_struct.set_name(callee->name()->as_utf8());
4299 callee_struct.set_descriptor(callee->signature()->as_symbol()->as_utf8());
4300 event.set_compileId(compile_id);
4301 event.set_message(msg);
4302 event.set_succeeded(success);
4303 event.set_bci(bci);
4304 event.set_caller(caller->get_Method());
4305 event.set_callee(callee_struct);
4306 event.commit();
4307 }
4308 }
4309 #endif // INCLUDE_TRACE
4310
4311 void GraphBuilder::print_inlining(ciMethod* callee, const char* msg, bool success) {
4312 CompileLog* log = compilation()->log();
4313 if (log != NULL) {
4314 if (success) {
4315 if (msg != NULL)
4316 log->inline_success(msg);
4317 else
4318 log->inline_success("receiver is statically known");
4319 } else {
4320 if (msg != NULL)
4321 log->inline_fail(msg);
4322 else
4323 log->inline_fail("reason unknown");
4324 }
4325 }
4326
4327 TRACE_ONLY(post_inlining_event(compilation()->env()->task()->compile_id(),
4328 msg,
4329 success,
4330 bci(),
4331 method(),
4332 callee);)
4333
4334 CompileTask::print_inlining_ul(callee, scope()->level(), bci(), msg);
4335
4336 if (!compilation()->directive()->PrintInliningOption) {
4337 return;
4338 }
4339 CompileTask::print_inlining_tty(callee, scope()->level(), bci(), msg);
4340 if (success && CIPrintMethodCodes) {
4341 callee->print_codes();
4342 }
4343 }
4344
4345 void GraphBuilder::append_unsafe_get_and_set_obj(ciMethod* callee, bool is_add) {
4346 Values* args = state()->pop_arguments(callee->arg_size());
4347 BasicType t = callee->return_type()->basic_type();
4348 null_check(args->at(0));
4349 Instruction* offset = args->at(2);
4350 #ifndef _LP64
4351 offset = append(new Convert(Bytecodes::_l2i, offset, as_ValueType(T_INT)));
4352 #endif
|