src/share/vm/runtime/stubCodeGenerator.cpp

Wed, 01 Dec 2010 15:04:06 +0100

author
stefank
date
Wed, 01 Dec 2010 15:04:06 +0100
changeset 2325
c760f78e0a53
parent 2314
f95d63e2154a
child 2508
b92c45f2bc75
permissions
-rw-r--r--

7003125: precompiled.hpp is included when precompiled headers are not used
Summary: Added an ifndef DONT_USE_PRECOMPILED_HEADER to precompiled.hpp. Set up DONT_USE_PRECOMPILED_HEADER when compiling with Sun Studio or when the user specifies USE_PRECOMPILED_HEADER=0. Fixed broken include dependencies.
Reviewed-by: coleenp, kvn

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

mercurial