62 // a single set (_exception_exit), losing some information but simplifying the
63 // analysis.
64
65
66 # include "incls/_precompiled.incl"
67 # include "incls/_methodLiveness.cpp.incl"
68
69 //--------------------------------------------------------------------------
70 // The BitCounter class is used for counting the number of bits set in
71 // some BitMap. It is only used when collecting liveness statistics.
72
73 #ifndef PRODUCT
74
75 class BitCounter: public BitMapClosure {
76 private:
77 int _count;
78 public:
79 BitCounter() : _count(0) {}
80
81 // Callback when bit in map is set
82 virtual void do_bit(size_t offset) {
83 _count++;
84 }
85
86 int count() {
87 return _count;
88 }
89 };
90
91
92 //--------------------------------------------------------------------------
93
94
95 // Counts
96 long MethodLiveness::_total_bytes = 0;
97 int MethodLiveness::_total_methods = 0;
98
99 long MethodLiveness::_total_blocks = 0;
100 int MethodLiveness::_max_method_blocks = 0;
101
102 long MethodLiveness::_total_edges = 0;
103 int MethodLiveness::_max_block_edges = 0;
453 }
454
455 MethodLiveness::BasicBlock *MethodLiveness::work_list_get() {
456 BasicBlock *block = _work_list;
457 if (block != NULL) {
458 block->set_on_work_list(false);
459 _work_list = block->next();
460 }
461 return block;
462 }
463
464
465 MethodLivenessResult MethodLiveness::get_liveness_at(int entry_bci) {
466 int bci = entry_bci;
467 bool is_entry = false;
468 if (entry_bci == InvocationEntryBci) {
469 is_entry = true;
470 bci = 0;
471 }
472
473 MethodLivenessResult answer(NULL,0);
474
475 if (_block_count > 0) {
476 if (TimeLivenessAnalysis) _time_total.start();
477 if (TimeLivenessAnalysis) _time_query.start();
478
479 assert( 0 <= bci && bci < method()->code_size(), "bci out of range" );
480 BasicBlock *block = _block_map->at(bci);
481 // We may not be at the block start, so search backwards to find the block
482 // containing bci.
483 int t = bci;
484 while (block == NULL && t > 0) {
485 block = _block_map->at(--t);
486 }
487 assert( block != NULL, "invalid bytecode index; must be instruction index" );
488 assert(bci >= block->start_bci() && bci < block->limit_bci(), "block must contain bci.");
489
490 answer = block->get_liveness_at(method(), bci);
491
492 if (is_entry && method()->is_synchronized() && !method()->is_static()) {
493 // Synchronized methods use the receiver once on entry.
|
62 // a single set (_exception_exit), losing some information but simplifying the
63 // analysis.
64
65
66 # include "incls/_precompiled.incl"
67 # include "incls/_methodLiveness.cpp.incl"
68
69 //--------------------------------------------------------------------------
70 // The BitCounter class is used for counting the number of bits set in
71 // some BitMap. It is only used when collecting liveness statistics.
72
73 #ifndef PRODUCT
74
75 class BitCounter: public BitMapClosure {
76 private:
77 int _count;
78 public:
79 BitCounter() : _count(0) {}
80
81 // Callback when bit in map is set
82 virtual bool do_bit(size_t offset) {
83 _count++;
84 return true;
85 }
86
87 int count() {
88 return _count;
89 }
90 };
91
92
93 //--------------------------------------------------------------------------
94
95
96 // Counts
97 long MethodLiveness::_total_bytes = 0;
98 int MethodLiveness::_total_methods = 0;
99
100 long MethodLiveness::_total_blocks = 0;
101 int MethodLiveness::_max_method_blocks = 0;
102
103 long MethodLiveness::_total_edges = 0;
104 int MethodLiveness::_max_block_edges = 0;
454 }
455
456 MethodLiveness::BasicBlock *MethodLiveness::work_list_get() {
457 BasicBlock *block = _work_list;
458 if (block != NULL) {
459 block->set_on_work_list(false);
460 _work_list = block->next();
461 }
462 return block;
463 }
464
465
466 MethodLivenessResult MethodLiveness::get_liveness_at(int entry_bci) {
467 int bci = entry_bci;
468 bool is_entry = false;
469 if (entry_bci == InvocationEntryBci) {
470 is_entry = true;
471 bci = 0;
472 }
473
474 MethodLivenessResult answer((uintptr_t*)NULL,0);
475
476 if (_block_count > 0) {
477 if (TimeLivenessAnalysis) _time_total.start();
478 if (TimeLivenessAnalysis) _time_query.start();
479
480 assert( 0 <= bci && bci < method()->code_size(), "bci out of range" );
481 BasicBlock *block = _block_map->at(bci);
482 // We may not be at the block start, so search backwards to find the block
483 // containing bci.
484 int t = bci;
485 while (block == NULL && t > 0) {
486 block = _block_map->at(--t);
487 }
488 assert( block != NULL, "invalid bytecode index; must be instruction index" );
489 assert(bci >= block->start_bci() && bci < block->limit_bci(), "block must contain bci.");
490
491 answer = block->get_liveness_at(method(), bci);
492
493 if (is_entry && method()->is_synchronized() && !method()->is_static()) {
494 // Synchronized methods use the receiver once on entry.
|