Mercurial > hg > graal-compiler
comparison src/share/vm/jvmci/jvmciEnv.hpp @ 21559:be896a1983c0
recast all Graal native code as JVMCI code (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Thu, 28 May 2015 15:36:48 +0200 |
parents | src/share/vm/graal/graalEnv.hpp@29916dcee0b8 |
children | df9d2375512a |
comparison
equal
deleted
inserted
replaced
21558:d563baeca9df | 21559:be896a1983c0 |
---|---|
1 /* | |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 * | |
23 */ | |
24 | |
25 #ifndef SHARE_VM_JVMCI_JVMCIENV_HPP | |
26 #define SHARE_VM_JVMCI_JVMCIENV_HPP | |
27 | |
28 #include "classfile/systemDictionary.hpp" | |
29 #include "code/debugInfoRec.hpp" | |
30 #include "code/dependencies.hpp" | |
31 #include "code/exceptionHandlerTable.hpp" | |
32 #include "compiler/oopMap.hpp" | |
33 #include "runtime/thread.hpp" | |
34 | |
35 class CompileTask; | |
36 | |
37 // Bring the JVMCI compiler thread into the VM state. | |
38 #define JVMCI_VM_ENTRY_MARK \ | |
39 JavaThread* thread = JavaThread::current(); \ | |
40 ThreadInVMfromNative __tiv(thread); \ | |
41 ResetNoHandleMark rnhm; \ | |
42 HandleMarkCleaner __hm(thread); \ | |
43 Thread* THREAD = thread; \ | |
44 debug_only(VMNativeEntryWrapper __vew;) | |
45 | |
46 #define JVMCI_EXCEPTION_CONTEXT \ | |
47 JavaThread* thread=JavaThread::current(); \ | |
48 Thread* THREAD = thread; | |
49 | |
50 // | |
51 // This class is the top level broker for requests from the compiler | |
52 // to the VM. | |
53 class JVMCIEnv : StackObj { | |
54 CI_PACKAGE_ACCESS_TO | |
55 | |
56 friend class CompileBroker; | |
57 friend class Dependencies; // for get_object, during logging | |
58 | |
59 public: | |
60 | |
61 enum CodeInstallResult { | |
62 ok, | |
63 dependencies_failed, | |
64 dependencies_invalid, | |
65 cache_full, | |
66 code_too_large | |
67 }; | |
68 | |
69 // Look up a klass by name from a particular class loader (the accessor's). | |
70 // If require_local, result must be defined in that class loader, or NULL. | |
71 // If !require_local, a result from remote class loader may be reported, | |
72 // if sufficient class loader constraints exist such that initiating | |
73 // a class loading request from the given loader is bound to return | |
74 // the class defined in the remote loader (or throw an error). | |
75 // | |
76 // Return an unloaded klass if !require_local and no class at all is found. | |
77 // | |
78 // The CI treats a klass as loaded if it is consistently defined in | |
79 // another loader, even if it hasn't yet been loaded in all loaders | |
80 // that could potentially see it via delegation. | |
81 static KlassHandle get_klass_by_name(KlassHandle& accessing_klass, | |
82 Symbol* klass_name, | |
83 bool require_local); | |
84 | |
85 // Constant pool access. | |
86 static KlassHandle get_klass_by_index(constantPoolHandle& cpool, | |
87 int klass_index, | |
88 bool& is_accessible, | |
89 KlassHandle& loading_klass); | |
90 static void get_field_by_index(instanceKlassHandle& loading_klass, fieldDescriptor& fd, | |
91 int field_index); | |
92 static methodHandle get_method_by_index(constantPoolHandle& cpool, | |
93 int method_index, Bytecodes::Code bc, | |
94 instanceKlassHandle& loading_klass); | |
95 | |
96 JVMCIEnv(CompileTask* task, int system_dictionary_modification_counter); | |
97 | |
98 private: | |
99 CompileTask* _task; | |
100 int _system_dictionary_modification_counter; | |
101 | |
102 // Cache JVMTI state | |
103 bool _jvmti_can_hotswap_or_post_breakpoint; | |
104 bool _jvmti_can_access_local_variables; | |
105 bool _jvmti_can_post_on_exceptions; | |
106 | |
107 // Implementation methods for loading and constant pool access. | |
108 static KlassHandle get_klass_by_name_impl(KlassHandle& accessing_klass, | |
109 constantPoolHandle& cpool, | |
110 Symbol* klass_name, | |
111 bool require_local); | |
112 static KlassHandle get_klass_by_index_impl(constantPoolHandle& cpool, | |
113 int klass_index, | |
114 bool& is_accessible, | |
115 KlassHandle& loading_klass); | |
116 static void get_field_by_index_impl(instanceKlassHandle& loading_klass, fieldDescriptor& fd, | |
117 int field_index); | |
118 static methodHandle get_method_by_index_impl(constantPoolHandle& cpool, | |
119 int method_index, Bytecodes::Code bc, | |
120 instanceKlassHandle& loading_klass); | |
121 | |
122 // Helper methods | |
123 static bool check_klass_accessibility(KlassHandle accessing_klass, KlassHandle resolved_klass); | |
124 static methodHandle lookup_method(instanceKlassHandle& accessor, | |
125 instanceKlassHandle& holder, | |
126 Symbol* name, | |
127 Symbol* sig, | |
128 Bytecodes::Code bc); | |
129 | |
130 private: | |
131 | |
132 // Is this thread currently in the VM state? | |
133 static bool is_in_vm(); | |
134 | |
135 // Helper routine for determining the validity of a compilation | |
136 // with respect to concurrent class loading. | |
137 static JVMCIEnv::CodeInstallResult check_for_system_dictionary_modification(Dependencies* target, Handle compiled_code, | |
138 JVMCIEnv* env, char** failure_detail); | |
139 | |
140 public: | |
141 CompileTask* task() { return _task; } | |
142 | |
143 // Register the result of a compilation. | |
144 static JVMCIEnv::CodeInstallResult register_method( | |
145 methodHandle& target, | |
146 nmethod*& nm, | |
147 int entry_bci, | |
148 CodeOffsets* offsets, | |
149 int orig_pc_offset, | |
150 CodeBuffer* code_buffer, | |
151 int frame_words, | |
152 OopMapSet* oop_map_set, | |
153 ExceptionHandlerTable* handler_table, | |
154 AbstractCompiler* compiler, | |
155 DebugInformationRecorder* debug_info, | |
156 Dependencies* dependencies, | |
157 JVMCIEnv* env, | |
158 int compile_id, | |
159 bool has_unsafe_access, | |
160 Handle installed_code, | |
161 Handle compiled_code, | |
162 Handle speculation_log); | |
163 | |
164 // converts the Klass* representing the holder of a method into a | |
165 // InstanceKlass*. This is needed since the holder of a method in | |
166 // the bytecodes could be an array type. Basically this converts | |
167 // array types into java/lang/Object and other types stay as they are. | |
168 static instanceKlassHandle get_instance_klass_for_declared_method_holder(KlassHandle& klass); | |
169 }; | |
170 | |
171 #endif // SHARE_VM_JVMCI_JVMCIENV_HPP |