70
71 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {
72 _masm = new MacroAssembler(code);
73 _first_stub = _last_stub = NULL;
74 _print_code = print_code;
75 }
76
77 extern "C" {
78 static int compare_cdesc(const void* void_a, const void* void_b) {
79 int ai = (*((StubCodeDesc**) void_a))->index();
80 int bi = (*((StubCodeDesc**) void_b))->index();
81 return ai - bi;
82 }
83 }
84
85 StubCodeGenerator::~StubCodeGenerator() {
86 if (PrintStubCode || _print_code) {
87 CodeBuffer* cbuf = _masm->code();
88 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
89 if (blob != NULL) {
90 blob->set_comments(cbuf->comments());
91 }
92 bool saw_first = false;
93 StubCodeDesc* toprint[1000];
94 int toprint_len = 0;
95 for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) {
96 toprint[toprint_len++] = cdesc;
97 if (cdesc == _first_stub) { saw_first = true; break; }
98 }
99 assert(saw_first, "must get both first & last");
100 // Print in reverse order:
101 qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc);
102 for (int i = 0; i < toprint_len; i++) {
103 StubCodeDesc* cdesc = toprint[i];
104 cdesc->print();
105 tty->cr();
106 Disassembler::decode(cdesc->begin(), cdesc->end());
107 tty->cr();
108 }
109 }
110 }
|
70
71 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {
72 _masm = new MacroAssembler(code);
73 _first_stub = _last_stub = NULL;
74 _print_code = print_code;
75 }
76
77 extern "C" {
78 static int compare_cdesc(const void* void_a, const void* void_b) {
79 int ai = (*((StubCodeDesc**) void_a))->index();
80 int bi = (*((StubCodeDesc**) void_b))->index();
81 return ai - bi;
82 }
83 }
84
85 StubCodeGenerator::~StubCodeGenerator() {
86 if (PrintStubCode || _print_code) {
87 CodeBuffer* cbuf = _masm->code();
88 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
89 if (blob != NULL) {
90 blob->set_strings(cbuf->strings());
91 }
92 bool saw_first = false;
93 StubCodeDesc* toprint[1000];
94 int toprint_len = 0;
95 for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) {
96 toprint[toprint_len++] = cdesc;
97 if (cdesc == _first_stub) { saw_first = true; break; }
98 }
99 assert(saw_first, "must get both first & last");
100 // Print in reverse order:
101 qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc);
102 for (int i = 0; i < toprint_len; i++) {
103 StubCodeDesc* cdesc = toprint[i];
104 cdesc->print();
105 tty->cr();
106 Disassembler::decode(cdesc->begin(), cdesc->end());
107 tty->cr();
108 }
109 }
110 }
|