6187
|
1 |
/*
|
7397
|
2 |
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
|
6187
|
3 |
* Copyright 2008, 2009 Red Hat, Inc.
|
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5 |
*
|
|
6 |
* This code is free software; you can redistribute it and/or modify it
|
|
7 |
* under the terms of the GNU General Public License version 2 only, as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*
|
|
24 |
*/
|
|
25 |
|
7397
|
26 |
#ifndef SHARE_VM_SHARK_SHARKINVARIANTS_HPP
|
|
27 |
#define SHARE_VM_SHARK_SHARKINVARIANTS_HPP
|
|
28 |
|
|
29 |
#include "ci/ciEnv.hpp"
|
|
30 |
#include "ci/ciInstanceKlass.hpp"
|
|
31 |
#include "ci/ciMethod.hpp"
|
|
32 |
#include "ci/ciTypeFlow.hpp"
|
|
33 |
#include "code/debugInfoRec.hpp"
|
|
34 |
#include "code/dependencies.hpp"
|
|
35 |
#include "memory/allocation.hpp"
|
|
36 |
#include "shark/llvmHeaders.hpp"
|
|
37 |
#include "shark/sharkBuilder.hpp"
|
|
38 |
|
6187
|
39 |
// Base classes used to track various values through the compilation.
|
|
40 |
// SharkCompileInvariants is used to track values which remain the
|
|
41 |
// same for the top-level method and any inlined methods it may have
|
|
42 |
// (ie for the whole compilation). SharkTargetInvariants is used to
|
|
43 |
// track values which differ between methods.
|
|
44 |
|
|
45 |
class SharkCompileInvariants : public ResourceObj {
|
|
46 |
protected:
|
|
47 |
SharkCompileInvariants(ciEnv* env, SharkBuilder* builder)
|
|
48 |
: _env(env),
|
|
49 |
_builder(builder),
|
|
50 |
_thread(NULL) {}
|
|
51 |
|
|
52 |
SharkCompileInvariants(const SharkCompileInvariants* parent)
|
|
53 |
: _env(parent->_env),
|
|
54 |
_builder(parent->_builder),
|
|
55 |
_thread(parent->_thread) {}
|
|
56 |
|
|
57 |
private:
|
|
58 |
ciEnv* _env;
|
|
59 |
SharkBuilder* _builder;
|
|
60 |
llvm::Value* _thread;
|
|
61 |
|
|
62 |
// Top-level broker for HotSpot's Compiler Interface.
|
|
63 |
//
|
|
64 |
// Its main purpose is to allow the various CI classes to access
|
|
65 |
// oops in the VM without having to worry about safepointing. In
|
|
66 |
// addition to this it acts as a holder for various recorders and
|
|
67 |
// memory allocators.
|
|
68 |
//
|
|
69 |
// Accessing this directly is kind of ugly, so it's private. Add
|
|
70 |
// new accessors below if you need something from it.
|
|
71 |
private:
|
|
72 |
ciEnv* env() const {
|
|
73 |
assert(_env != NULL, "env not available");
|
|
74 |
return _env;
|
|
75 |
}
|
|
76 |
|
|
77 |
// The SharkBuilder that is used to build LLVM IR.
|
|
78 |
protected:
|
|
79 |
SharkBuilder* builder() const {
|
|
80 |
return _builder;
|
|
81 |
}
|
|
82 |
|
|
83 |
// Pointer to this thread's JavaThread object. This is not
|
|
84 |
// available until a short way into SharkFunction creation
|
|
85 |
// so a setter is required. Assertions are used to enforce
|
|
86 |
// invariance.
|
|
87 |
protected:
|
|
88 |
llvm::Value* thread() const {
|
|
89 |
assert(_thread != NULL, "thread not available");
|
|
90 |
return _thread;
|
|
91 |
}
|
|
92 |
void set_thread(llvm::Value* thread) {
|
|
93 |
assert(_thread == NULL, "thread already set");
|
|
94 |
_thread = thread;
|
|
95 |
}
|
|
96 |
|
|
97 |
// Objects that handle various aspects of the compilation.
|
|
98 |
protected:
|
|
99 |
DebugInformationRecorder* debug_info() const {
|
|
100 |
return env()->debug_info();
|
|
101 |
}
|
|
102 |
Dependencies* dependencies() const {
|
|
103 |
return env()->dependencies();
|
|
104 |
}
|
|
105 |
SharkCodeBuffer* code_buffer() const {
|
|
106 |
return builder()->code_buffer();
|
|
107 |
}
|
|
108 |
|
|
109 |
// Commonly used classes
|
|
110 |
protected:
|
|
111 |
ciInstanceKlass* java_lang_Object_klass() const {
|
|
112 |
return env()->Object_klass();
|
|
113 |
}
|
|
114 |
ciInstanceKlass* java_lang_Throwable_klass() const {
|
|
115 |
return env()->Throwable_klass();
|
|
116 |
}
|
|
117 |
};
|
|
118 |
|
|
119 |
class SharkTargetInvariants : public SharkCompileInvariants {
|
|
120 |
protected:
|
|
121 |
SharkTargetInvariants(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow)
|
|
122 |
: SharkCompileInvariants(env, builder),
|
|
123 |
_target(flow->method()),
|
|
124 |
_flow(flow),
|
|
125 |
_max_monitors(count_monitors()) {}
|
|
126 |
|
|
127 |
SharkTargetInvariants(const SharkCompileInvariants* parent, ciMethod* target)
|
|
128 |
: SharkCompileInvariants(parent),
|
|
129 |
_target(target),
|
|
130 |
_flow(NULL),
|
|
131 |
_max_monitors(count_monitors()) {}
|
|
132 |
|
|
133 |
SharkTargetInvariants(const SharkTargetInvariants* parent)
|
|
134 |
: SharkCompileInvariants(parent),
|
|
135 |
_target(parent->_target),
|
|
136 |
_flow(parent->_flow),
|
|
137 |
_max_monitors(parent->_max_monitors) {}
|
|
138 |
|
|
139 |
private:
|
|
140 |
int count_monitors();
|
|
141 |
|
|
142 |
private:
|
|
143 |
ciMethod* _target;
|
|
144 |
ciTypeFlow* _flow;
|
|
145 |
int _max_monitors;
|
|
146 |
|
|
147 |
// The method being compiled.
|
|
148 |
protected:
|
|
149 |
ciMethod* target() const {
|
|
150 |
return _target;
|
|
151 |
}
|
|
152 |
|
|
153 |
// Typeflow analysis of the method being compiled.
|
|
154 |
protected:
|
|
155 |
ciTypeFlow* flow() const {
|
|
156 |
assert(_flow != NULL, "typeflow not available");
|
|
157 |
return _flow;
|
|
158 |
}
|
|
159 |
|
|
160 |
// Properties of the method.
|
|
161 |
protected:
|
|
162 |
int max_locals() const {
|
|
163 |
return target()->max_locals();
|
|
164 |
}
|
|
165 |
int max_stack() const {
|
|
166 |
return target()->max_stack();
|
|
167 |
}
|
|
168 |
int max_monitors() const {
|
|
169 |
return _max_monitors;
|
|
170 |
}
|
|
171 |
int arg_size() const {
|
|
172 |
return target()->arg_size();
|
|
173 |
}
|
|
174 |
bool is_static() const {
|
|
175 |
return target()->is_static();
|
|
176 |
}
|
|
177 |
bool is_synchronized() const {
|
|
178 |
return target()->is_synchronized();
|
|
179 |
}
|
|
180 |
};
|
7397
|
181 |
|
|
182 |
#endif // SHARE_VM_SHARK_SHARKINVARIANTS_HPP
|