43 p = p->_next;
44 }
45 return p;
46 }
47
48 const char* StubCodeDesc::name_for(address pc) {
49 StubCodeDesc* p = desc_for(pc);
50 return p == NULL ? NULL : p->name();
51 }
52
53
54 void StubCodeDesc::freeze() {
55 assert(!_frozen, "repeated freeze operation");
56 _frozen = true;
57 }
58
59 void StubCodeDesc::print_on(outputStream* st) const {
60 st->print("%s", group());
61 st->print("::");
62 st->print("%s", name());
63 st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", p2i(begin()), p2i(end()), size_in_bytes());
64 }
65
66 // Implementation of StubCodeGenerator
67
68 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {
69 _masm = new MacroAssembler(code );
70 _print_code = PrintStubCode || print_code;
71 }
72
73 StubCodeGenerator::~StubCodeGenerator() {
74 if (PRODUCT_ONLY(_print_code) NOT_PRODUCT(true)) {
75 CodeBuffer* cbuf = _masm->code();
76 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
77 if (blob != NULL) {
78 blob->set_strings(cbuf->strings());
79 }
80 }
81 }
82
83 void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) {
84 // default implementation - do nothing
85 }
86
87 void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) {
88 if (_print_code) {
89 CodeStrings cs;
90 ptrdiff_t offset = 0;
91 #ifndef PRODUCT
92 // Find the code strings in the outer CodeBuffer.
93 CodeBuffer *outer_cbuf = _masm->code_section()->outer();
94 cs = outer_cbuf->strings();
95 // The offset from the start of the outer CodeBuffer to the start
96 // of this stub.
97 offset = cdesc->begin() - outer_cbuf->insts()->start();
98 #endif
99 cdesc->print();
100 tty->cr();
101 Disassembler::decode(cdesc->begin(), cdesc->end(), NULL, cs, offset);
102 tty->cr();
103 }
104 }
105
106
107 // Implementation of CodeMark
108
109 StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) {
110 _cgen = cgen;
111 _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc());
112 _cgen->stub_prolog(_cdesc);
113 // define the stub's beginning (= entry point) to be after the prolog:
114 _cdesc->set_begin(_cgen->assembler()->pc());
115 }
116
117 StubCodeMark::~StubCodeMark() {
118 _cgen->assembler()->flush();
119 _cdesc->set_end(_cgen->assembler()->pc());
120 assert(StubCodeDesc::_list == _cdesc, "expected order on list");
121 _cgen->stub_epilog(_cdesc);
|
43 p = p->_next;
44 }
45 return p;
46 }
47
48 const char* StubCodeDesc::name_for(address pc) {
49 StubCodeDesc* p = desc_for(pc);
50 return p == NULL ? NULL : p->name();
51 }
52
53
54 void StubCodeDesc::freeze() {
55 assert(!_frozen, "repeated freeze operation");
56 _frozen = true;
57 }
58
59 void StubCodeDesc::print_on(outputStream* st) const {
60 st->print("%s", group());
61 st->print("::");
62 st->print("%s", name());
63 st->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "] (%d bytes)", p2i(begin()), p2i(end()), size_in_bytes());
64 }
65
66 // Implementation of StubCodeGenerator
67
68 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code, bool print_code) {
69 _masm = new MacroAssembler(code );
70 _print_code = PrintStubCode || print_code;
71 }
72
73 StubCodeGenerator::~StubCodeGenerator() {
74 if (PRODUCT_ONLY(_print_code) NOT_PRODUCT(true)) {
75 CodeBuffer* cbuf = _masm->code();
76 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
77 if (blob != NULL) {
78 blob->set_strings(cbuf->strings());
79 }
80 }
81 }
82
83 void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) {
84 // default implementation - do nothing
85 }
86
87 void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) {
88 if (_print_code) {
89 CodeStrings cs;
90 ptrdiff_t offset = 0;
91 #ifndef PRODUCT
92 // Find the code strings in the outer CodeBuffer.
93 CodeBuffer *outer_cbuf = _masm->code_section()->outer();
94 cs = outer_cbuf->strings();
95 // The offset from the start of the outer CodeBuffer to the start
96 // of this stub.
97 offset = cdesc->begin() - outer_cbuf->insts()->start();
98 #endif
99 ttyLocker ttyl;
100 tty->print_cr("- - - [BEGIN] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
101 cdesc->print_on(tty);
102 tty->cr();
103 Disassembler::decode(cdesc->begin(), cdesc->end(), tty, cs /*, offset */);
104 tty->print_cr("- - - [END] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -");
105 tty->cr();
106 }
107 }
108
109
110 // Implementation of CodeMark
111
112 StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) {
113 _cgen = cgen;
114 _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc());
115 _cgen->stub_prolog(_cdesc);
116 // define the stub's beginning (= entry point) to be after the prolog:
117 _cdesc->set_begin(_cgen->assembler()->pc());
118 }
119
120 StubCodeMark::~StubCodeMark() {
121 _cgen->assembler()->flush();
122 _cdesc->set_end(_cgen->assembler()->pc());
123 assert(StubCodeDesc::_list == _cdesc, "expected order on list");
124 _cgen->stub_epilog(_cdesc);
|