annotate src/share/vm/runtime/stubCodeGenerator.cpp @ 61:5a76ab815e34

6667833: Remove CacheTimeMillis Summary: Remove -XX:+CacheTimeMillis option and associated functionality Reviewed-by: acorn, never
author sbohne
date Wed, 19 Mar 2008 09:58:01 -0400
parents
children c7c777385a15
rev   line source
duke@0 1 /*
duke@0 2 * Copyright 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
duke@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@0 4 *
duke@0 5 * This code is free software; you can redistribute it and/or modify it
duke@0 6 * under the terms of the GNU General Public License version 2 only, as
duke@0 7 * published by the Free Software Foundation.
duke@0 8 *
duke@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@0 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@0 13 * accompanied this code).
duke@0 14 *
duke@0 15 * You should have received a copy of the GNU General Public License version
duke@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@0 18 *
duke@0 19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
duke@0 20 * CA 95054 USA or visit www.sun.com if you need additional information or
duke@0 21 * have any questions.
duke@0 22 *
duke@0 23 */
duke@0 24
duke@0 25 #include "incls/_precompiled.incl"
duke@0 26 #include "incls/_stubCodeGenerator.cpp.incl"
duke@0 27
duke@0 28
duke@0 29 // Implementation of StubCodeDesc
duke@0 30
duke@0 31 StubCodeDesc* StubCodeDesc::_list = NULL;
duke@0 32 int StubCodeDesc::_count = 0;
duke@0 33
duke@0 34
duke@0 35 StubCodeDesc* StubCodeDesc::desc_for(address pc) {
duke@0 36 StubCodeDesc* p = _list;
duke@0 37 while (p != NULL && !p->contains(pc)) p = p->_next;
duke@0 38 // p == NULL || p->contains(pc)
duke@0 39 return p;
duke@0 40 }
duke@0 41
duke@0 42
duke@0 43 StubCodeDesc* StubCodeDesc::desc_for_index(int index) {
duke@0 44 StubCodeDesc* p = _list;
duke@0 45 while (p != NULL && p->index() != index) p = p->_next;
duke@0 46 return p;
duke@0 47 }
duke@0 48
duke@0 49
duke@0 50 const char* StubCodeDesc::name_for(address pc) {
duke@0 51 StubCodeDesc* p = desc_for(pc);
duke@0 52 return p == NULL ? NULL : p->name();
duke@0 53 }
duke@0 54
duke@0 55
duke@0 56 void StubCodeDesc::print() {
duke@0 57 tty->print(group());
duke@0 58 tty->print("::");
duke@0 59 tty->print(name());
duke@0 60 tty->print(" [" INTPTR_FORMAT ", " INTPTR_FORMAT "[ (%d bytes)", begin(), end(), size_in_bytes());
duke@0 61 }
duke@0 62
duke@0 63
duke@0 64
duke@0 65 // Implementation of StubCodeGenerator
duke@0 66
duke@0 67 StubCodeGenerator::StubCodeGenerator(CodeBuffer* code) {
duke@0 68 _masm = new MacroAssembler(code);
duke@0 69 _first_stub = _last_stub = NULL;
duke@0 70 }
duke@0 71
duke@0 72 #ifndef PRODUCT
duke@0 73 extern "C" {
duke@0 74 static int compare_cdesc(const void* void_a, const void* void_b) {
duke@0 75 int ai = (*((StubCodeDesc**) void_a))->index();
duke@0 76 int bi = (*((StubCodeDesc**) void_b))->index();
duke@0 77 return ai - bi;
duke@0 78 }
duke@0 79 }
duke@0 80 #endif
duke@0 81
duke@0 82 StubCodeGenerator::~StubCodeGenerator() {
duke@0 83 #ifndef PRODUCT
duke@0 84 if (PrintStubCode) {
duke@0 85 CodeBuffer* cbuf = _masm->code();
duke@0 86 CodeBlob* blob = CodeCache::find_blob_unsafe(cbuf->insts()->start());
duke@0 87 if (blob != NULL) {
duke@0 88 blob->set_comments(cbuf->comments());
duke@0 89 }
duke@0 90 bool saw_first = false;
duke@0 91 StubCodeDesc* toprint[1000];
duke@0 92 int toprint_len = 0;
duke@0 93 for (StubCodeDesc* cdesc = _last_stub; cdesc != NULL; cdesc = cdesc->_next) {
duke@0 94 toprint[toprint_len++] = cdesc;
duke@0 95 if (cdesc == _first_stub) { saw_first = true; break; }
duke@0 96 }
duke@0 97 assert(saw_first, "must get both first & last");
duke@0 98 // Print in reverse order:
duke@0 99 qsort(toprint, toprint_len, sizeof(toprint[0]), compare_cdesc);
duke@0 100 for (int i = 0; i < toprint_len; i++) {
duke@0 101 StubCodeDesc* cdesc = toprint[i];
duke@0 102 cdesc->print();
duke@0 103 tty->cr();
duke@0 104 Disassembler::decode(cdesc->begin(), cdesc->end());
duke@0 105 tty->cr();
duke@0 106 }
duke@0 107 }
duke@0 108 #endif //PRODUCT
duke@0 109 }
duke@0 110
duke@0 111
duke@0 112 void StubCodeGenerator::stub_prolog(StubCodeDesc* cdesc) {
duke@0 113 // default implementation - do nothing
duke@0 114 }
duke@0 115
duke@0 116
duke@0 117 void StubCodeGenerator::stub_epilog(StubCodeDesc* cdesc) {
duke@0 118 // default implementation - record the cdesc
duke@0 119 if (_first_stub == NULL) _first_stub = cdesc;
duke@0 120 _last_stub = cdesc;
duke@0 121 }
duke@0 122
duke@0 123
duke@0 124 // Implementation of CodeMark
duke@0 125
duke@0 126 StubCodeMark::StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name) {
duke@0 127 _cgen = cgen;
duke@0 128 _cdesc = new StubCodeDesc(group, name, _cgen->assembler()->pc());
duke@0 129 _cgen->stub_prolog(_cdesc);
duke@0 130 // define the stub's beginning (= entry point) to be after the prolog:
duke@0 131 _cdesc->set_begin(_cgen->assembler()->pc());
duke@0 132 }
duke@0 133
duke@0 134 StubCodeMark::~StubCodeMark() {
duke@0 135 _cgen->assembler()->flush();
duke@0 136 _cdesc->set_end(_cgen->assembler()->pc());
duke@0 137 assert(StubCodeDesc::_list == _cdesc, "expected order on list");
duke@0 138 _cgen->stub_epilog(_cdesc);
duke@0 139 VTune::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end());
duke@0 140 Forte::register_stub(_cdesc->name(), _cdesc->begin(), _cdesc->end());
duke@0 141
duke@0 142 if (JvmtiExport::should_post_dynamic_code_generated()) {
duke@0 143 JvmtiExport::post_dynamic_code_generated(_cdesc->name(), _cdesc->begin(), _cdesc->end());
duke@0 144 }
duke@0 145 }