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