comparison src/share/vm/opto/compile.hpp @ 7421:ad5dd04754ee

8005031: Some cleanup in c2 to prepare for incremental inlining support Summary: collection of small changes to prepare for incremental inlining. Reviewed-by: twisti, kvn
author roland
date Tue, 18 Dec 2012 14:55:25 +0100
parents 2aff40cb4703
children d092d1b31229
comparison
equal deleted inserted replaced
7420:18d56ca3e901 7421:ad5dd04754ee
28 #include "asm/codeBuffer.hpp" 28 #include "asm/codeBuffer.hpp"
29 #include "ci/compilerInterface.hpp" 29 #include "ci/compilerInterface.hpp"
30 #include "code/debugInfoRec.hpp" 30 #include "code/debugInfoRec.hpp"
31 #include "code/exceptionHandlerTable.hpp" 31 #include "code/exceptionHandlerTable.hpp"
32 #include "compiler/compilerOracle.hpp" 32 #include "compiler/compilerOracle.hpp"
33 #include "compiler/compileBroker.hpp"
33 #include "libadt/dict.hpp" 34 #include "libadt/dict.hpp"
34 #include "libadt/port.hpp" 35 #include "libadt/port.hpp"
35 #include "libadt/vectset.hpp" 36 #include "libadt/vectset.hpp"
36 #include "memory/resourceArea.hpp" 37 #include "memory/resourceArea.hpp"
37 #include "opto/idealGraphPrinter.hpp" 38 #include "opto/idealGraphPrinter.hpp"
367 WarmCallInfo* _warm_calls; // Sorted work-list for heat-based inlining. 368 WarmCallInfo* _warm_calls; // Sorted work-list for heat-based inlining.
368 369
369 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after 370 GrowableArray<CallGenerator*> _late_inlines; // List of CallGenerators to be revisited after
370 // main parsing has finished. 371 // main parsing has finished.
371 372
373 // Inlining may not happen in parse order which would make
374 // PrintInlining output confusing. Keep track of PrintInlining
375 // pieces in order.
376 class PrintInliningBuffer : public ResourceObj {
377 private:
378 CallGenerator* _cg;
379 stringStream* _ss;
380
381 public:
382 PrintInliningBuffer()
383 : _cg(NULL) { _ss = new stringStream(); }
384
385 stringStream* ss() const { return _ss; }
386 CallGenerator* cg() const { return _cg; }
387 void set_cg(CallGenerator* cg) { _cg = cg; }
388 };
389
390 GrowableArray<PrintInliningBuffer>* _print_inlining_list;
391 int _print_inlining;
392
393 public:
394
395 outputStream* print_inlining_stream() const {
396 return _print_inlining_list->at(_print_inlining).ss();
397 }
398
399 void print_inlining_skip(CallGenerator* cg) {
400 if (PrintInlining) {
401 _print_inlining_list->at(_print_inlining).set_cg(cg);
402 _print_inlining++;
403 _print_inlining_list->insert_before(_print_inlining, PrintInliningBuffer());
404 }
405 }
406
407 void print_inlining_insert(CallGenerator* cg) {
408 if (PrintInlining) {
409 for (int i = 0; i < _print_inlining_list->length(); i++) {
410 if (_print_inlining_list->at(i).cg() == cg) {
411 _print_inlining_list->insert_before(i+1, PrintInliningBuffer());
412 _print_inlining = i+1;
413 _print_inlining_list->at(i).set_cg(NULL);
414 return;
415 }
416 }
417 ShouldNotReachHere();
418 }
419 }
420
421 void print_inlining(ciMethod* method, int inline_level, int bci, const char* msg = NULL) {
422 stringStream ss;
423 CompileTask::print_inlining(&ss, method, inline_level, bci, msg);
424 print_inlining_stream()->print(ss.as_string());
425 }
426
427 private:
372 // Matching, CFG layout, allocation, code generation 428 // Matching, CFG layout, allocation, code generation
373 PhaseCFG* _cfg; // Results of CFG finding 429 PhaseCFG* _cfg; // Results of CFG finding
374 bool _select_24_bit_instr; // We selected an instruction with a 24-bit result 430 bool _select_24_bit_instr; // We selected an instruction with a 24-bit result
375 bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results 431 bool _in_24_bit_fp_mode; // We are emitting instructions with 24-bit results
376 int _java_calls; // Number of java calls in the method 432 int _java_calls; // Number of java calls in the method
589 } 645 }
590 uint dead_node_count() { return _dead_node_count; } 646 uint dead_node_count() { return _dead_node_count; }
591 void reset_dead_node_list() { _dead_node_list.Reset(); 647 void reset_dead_node_list() { _dead_node_list.Reset();
592 _dead_node_count = 0; 648 _dead_node_count = 0;
593 } 649 }
594 uint live_nodes() { 650 uint live_nodes() const {
595 int val = _unique - _dead_node_count; 651 int val = _unique - _dead_node_count;
596 assert (val >= 0, err_msg_res("number of tracked dead nodes %d more than created nodes %d", _unique, _dead_node_count)); 652 assert (val >= 0, err_msg_res("number of tracked dead nodes %d more than created nodes %d", _unique, _dead_node_count));
597 return (uint) val; 653 return (uint) val;
598 } 654 }
599 #ifdef ASSERT 655 #ifdef ASSERT
700 void gvn_replace_by(Node* n, Node* nn); 756 void gvn_replace_by(Node* n, Node* nn);
701 757
702 758
703 void identify_useful_nodes(Unique_Node_List &useful); 759 void identify_useful_nodes(Unique_Node_List &useful);
704 void update_dead_node_list(Unique_Node_List &useful); 760 void update_dead_node_list(Unique_Node_List &useful);
705 void remove_useless_nodes (Unique_Node_List &useful); 761 void remove_useless_nodes (Unique_Node_List &useful);
706 762
707 WarmCallInfo* warm_calls() const { return _warm_calls; } 763 WarmCallInfo* warm_calls() const { return _warm_calls; }
708 void set_warm_calls(WarmCallInfo* l) { _warm_calls = l; } 764 void set_warm_calls(WarmCallInfo* l) { _warm_calls = l; }
709 WarmCallInfo* pop_warm_call(); 765 WarmCallInfo* pop_warm_call();
710 766
711 // Record this CallGenerator for inlining at the end of parsing. 767 // Record this CallGenerator for inlining at the end of parsing.
712 void add_late_inline(CallGenerator* cg) { _late_inlines.push(cg); } 768 void add_late_inline(CallGenerator* cg) { _late_inlines.push(cg); }
769
770 void dump_inlining();
713 771
714 // Matching, CFG layout, allocation, code generation 772 // Matching, CFG layout, allocation, code generation
715 PhaseCFG* cfg() { return _cfg; } 773 PhaseCFG* cfg() { return _cfg; }
716 bool select_24_bit_instr() const { return _select_24_bit_instr; } 774 bool select_24_bit_instr() const { return _select_24_bit_instr; }
717 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; } 775 bool in_24_bit_fp_mode() const { return _in_24_bit_fp_mode; }