annotate src/share/vm/runtime/stubCodeGenerator.hpp @ 1972:f95d63e2154a

6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
author stefank
date Tue, 23 Nov 2010 13:22:55 -0800
parents 126ea7725993
children a9b8b43b115f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
25 #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "asm/assembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // All the basic framework for stubcode generation/debugging/printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // A StubCodeDesc describes a piece of generated code (usually stubs).
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // This information is mainly useful for debugging and printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Currently, code descriptors are simply chained in a linked list,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // this may have to change if searching becomes too slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
38
a61af66fc99e Initial load
duke
parents:
diff changeset
39 class StubCodeDesc: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
40 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static StubCodeDesc* _list; // the list of all descriptors
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static int _count; // length of list
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 StubCodeDesc* _next; // the next element in the linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
45 const char* _group; // the group to which the stub code belongs
a61af66fc99e Initial load
duke
parents:
diff changeset
46 const char* _name; // the name assigned to the stub code
a61af66fc99e Initial load
duke
parents:
diff changeset
47 int _index; // serial number assigned to the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
48 address _begin; // points to the first byte of the stub code (included)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 address _end; // points to the first byte after the stub code (excluded)
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void set_end(address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 assert(_begin <= end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _end = end;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void set_begin(address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(begin >= _begin, "begin may not decrease");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 friend class StubCodeMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 friend class StubCodeGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static StubCodeDesc* desc_for(address pc); // returns the code descriptor for the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static StubCodeDesc* desc_for_index(int); // returns the code descriptor for the index or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static const char* name_for(address pc); // returns the name of the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 StubCodeDesc(const char* group, const char* name, address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(name != NULL, "no name specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _next = _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _group = group;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _index = ++_count; // (never zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _end = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _list = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 };
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 const char* group() const { return _group; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 const char* name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int index() const { return _index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 address begin() const { return _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 address end() const { return _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 int size_in_bytes() const { return _end - _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 bool contains(address pc) const { return _begin <= pc && pc < _end; }
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
88 void print_on(outputStream* st) const;
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
89 void print() const { print_on(tty); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 };
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // The base class for all stub-generating code generators.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Provides utility functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 class StubCodeGenerator: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 MacroAssembler* _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 StubCodeDesc* _first_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 StubCodeDesc* _last_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
103 StubCodeGenerator(CodeBuffer* code);
a61af66fc99e Initial load
duke
parents:
diff changeset
104 ~StubCodeGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 MacroAssembler* assembler() const { return _masm; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
109 virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor
a61af66fc99e Initial load
duke
parents:
diff changeset
110 };
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // Stack-allocated helper class used to assciate a stub code with a name.
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // All stub code generating functions that use a StubCodeMark will be registered
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // in the global StubCodeDesc list and the generated stub code can be identified
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // later via an address pointing into it.
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 class StubCodeMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
119 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
120 StubCodeGenerator* _cgen;
a61af66fc99e Initial load
duke
parents:
diff changeset
121 StubCodeDesc* _cdesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
124 StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
125 ~StubCodeMark();
a61af66fc99e Initial load
duke
parents:
diff changeset
126
a61af66fc99e Initial load
duke
parents:
diff changeset
127 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
128
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
129 #endif // SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP