Mercurial > hg > truffle
comparison src/share/vm/shark/sharkInvariants.hpp @ 1692:d2ede61b7a12
6976186: integrate Shark HotSpot changes
Summary: Shark is a JIT compiler for Zero that uses the LLVM compiler infrastructure.
Reviewed-by: kvn, twisti
Contributed-by: Gary Benson <gbenson@redhat.com>
author | twisti |
---|---|
date | Wed, 11 Aug 2010 05:51:21 -0700 |
parents | |
children | f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1691:4a665be40fd3 | 1692:d2ede61b7a12 |
---|---|
1 /* | |
2 * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. | |
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 | |
26 // Base classes used to track various values through the compilation. | |
27 // SharkCompileInvariants is used to track values which remain the | |
28 // same for the top-level method and any inlined methods it may have | |
29 // (ie for the whole compilation). SharkTargetInvariants is used to | |
30 // track values which differ between methods. | |
31 | |
32 class SharkCompileInvariants : public ResourceObj { | |
33 protected: | |
34 SharkCompileInvariants(ciEnv* env, SharkBuilder* builder) | |
35 : _env(env), | |
36 _builder(builder), | |
37 _thread(NULL) {} | |
38 | |
39 SharkCompileInvariants(const SharkCompileInvariants* parent) | |
40 : _env(parent->_env), | |
41 _builder(parent->_builder), | |
42 _thread(parent->_thread) {} | |
43 | |
44 private: | |
45 ciEnv* _env; | |
46 SharkBuilder* _builder; | |
47 llvm::Value* _thread; | |
48 | |
49 // Top-level broker for HotSpot's Compiler Interface. | |
50 // | |
51 // Its main purpose is to allow the various CI classes to access | |
52 // oops in the VM without having to worry about safepointing. In | |
53 // addition to this it acts as a holder for various recorders and | |
54 // memory allocators. | |
55 // | |
56 // Accessing this directly is kind of ugly, so it's private. Add | |
57 // new accessors below if you need something from it. | |
58 private: | |
59 ciEnv* env() const { | |
60 assert(_env != NULL, "env not available"); | |
61 return _env; | |
62 } | |
63 | |
64 // The SharkBuilder that is used to build LLVM IR. | |
65 protected: | |
66 SharkBuilder* builder() const { | |
67 return _builder; | |
68 } | |
69 | |
70 // Pointer to this thread's JavaThread object. This is not | |
71 // available until a short way into SharkFunction creation | |
72 // so a setter is required. Assertions are used to enforce | |
73 // invariance. | |
74 protected: | |
75 llvm::Value* thread() const { | |
76 assert(_thread != NULL, "thread not available"); | |
77 return _thread; | |
78 } | |
79 void set_thread(llvm::Value* thread) { | |
80 assert(_thread == NULL, "thread already set"); | |
81 _thread = thread; | |
82 } | |
83 | |
84 // Objects that handle various aspects of the compilation. | |
85 protected: | |
86 DebugInformationRecorder* debug_info() const { | |
87 return env()->debug_info(); | |
88 } | |
89 Dependencies* dependencies() const { | |
90 return env()->dependencies(); | |
91 } | |
92 SharkCodeBuffer* code_buffer() const { | |
93 return builder()->code_buffer(); | |
94 } | |
95 | |
96 // Commonly used classes | |
97 protected: | |
98 ciInstanceKlass* java_lang_Object_klass() const { | |
99 return env()->Object_klass(); | |
100 } | |
101 ciInstanceKlass* java_lang_Throwable_klass() const { | |
102 return env()->Throwable_klass(); | |
103 } | |
104 }; | |
105 | |
106 class SharkTargetInvariants : public SharkCompileInvariants { | |
107 protected: | |
108 SharkTargetInvariants(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow) | |
109 : SharkCompileInvariants(env, builder), | |
110 _target(flow->method()), | |
111 _flow(flow), | |
112 _max_monitors(count_monitors()) {} | |
113 | |
114 SharkTargetInvariants(const SharkCompileInvariants* parent, ciMethod* target) | |
115 : SharkCompileInvariants(parent), | |
116 _target(target), | |
117 _flow(NULL), | |
118 _max_monitors(count_monitors()) {} | |
119 | |
120 SharkTargetInvariants(const SharkTargetInvariants* parent) | |
121 : SharkCompileInvariants(parent), | |
122 _target(parent->_target), | |
123 _flow(parent->_flow), | |
124 _max_monitors(parent->_max_monitors) {} | |
125 | |
126 private: | |
127 int count_monitors(); | |
128 | |
129 private: | |
130 ciMethod* _target; | |
131 ciTypeFlow* _flow; | |
132 int _max_monitors; | |
133 | |
134 // The method being compiled. | |
135 protected: | |
136 ciMethod* target() const { | |
137 return _target; | |
138 } | |
139 | |
140 // Typeflow analysis of the method being compiled. | |
141 protected: | |
142 ciTypeFlow* flow() const { | |
143 assert(_flow != NULL, "typeflow not available"); | |
144 return _flow; | |
145 } | |
146 | |
147 // Properties of the method. | |
148 protected: | |
149 int max_locals() const { | |
150 return target()->max_locals(); | |
151 } | |
152 int max_stack() const { | |
153 return target()->max_stack(); | |
154 } | |
155 int max_monitors() const { | |
156 return _max_monitors; | |
157 } | |
158 int arg_size() const { | |
159 return target()->arg_size(); | |
160 } | |
161 bool is_static() const { | |
162 return target()->is_static(); | |
163 } | |
164 bool is_synchronized() const { | |
165 return target()->is_synchronized(); | |
166 } | |
167 }; |