comparison src/share/vm/graal/graalEnv.hpp @ 3635:cb1181db8bec

Initial port of ciEnv to graalEnv.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 15 Nov 2011 21:15:26 +0100
parents
children 6aef50c6d967
comparison
equal deleted inserted replaced
3634:076542d505cd 3635:cb1181db8bec
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_GRAAL_GRAALENV_HPP
26 #define SHARE_VM_GRAAL_GRAALENV_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 // ciEnv
38 //
39 // This class is the top level broker for requests from the compiler
40 // to the VM.
41 class GraalEnv : AllStatic {
42 CI_PACKAGE_ACCESS_TO
43
44 friend class CompileBroker;
45 friend class Dependencies; // for get_object, during logging
46
47 public:
48
49 // Look up a klass by name from a particular class loader (the accessor's).
50 // If require_local, result must be defined in that class loader, or NULL.
51 // If !require_local, a result from remote class loader may be reported,
52 // if sufficient class loader constraints exist such that initiating
53 // a class loading request from the given loader is bound to return
54 // the class defined in the remote loader (or throw an error).
55 //
56 // Return an unloaded klass if !require_local and no class at all is found.
57 //
58 // The CI treats a klass as loaded if it is consistently defined in
59 // another loader, even if it hasn't yet been loaded in all loaders
60 // that could potentially see it via delegation.
61 static KlassHandle get_klass_by_name(KlassHandle accessing_klass,
62 Symbol* klass_name,
63 bool require_local);
64
65 // Constant pool access.
66 static KlassHandle get_klass_by_index(constantPoolHandle cpool,
67 int klass_index,
68 bool& is_accessible,
69 KlassHandle loading_klass);
70 static void get_field_by_index(instanceKlassHandle loading_klass, fieldDescriptor& fd,
71 int field_index);
72 static methodHandle get_method_by_index(constantPoolHandle cpool,
73 int method_index, Bytecodes::Code bc,
74 instanceKlass* loading_klass);
75
76 private:
77
78 // Implementation methods for loading and constant pool access.
79 static klassOop get_klass_by_name_impl(KlassHandle accessing_klass,
80 constantPoolHandle cpool,
81 Symbol* klass_name,
82 bool require_local);
83 static klassOop get_klass_by_index_impl(constantPoolHandle cpool,
84 int klass_index,
85 bool& is_accessible,
86 KlassHandle loading_klass);
87 static void get_field_by_index_impl(instanceKlassHandle loading_klass, fieldDescriptor& fd,
88 int field_index);
89 static methodHandle get_method_by_index_impl(constantPoolHandle cpool,
90 int method_index, Bytecodes::Code bc,
91 instanceKlass* loading_klass);
92
93 // Helper methods
94 static bool check_klass_accessibility(klassOop accessing_klass, klassOop resolved_klassOop);
95 static methodOop lookup_method(instanceKlass* accessor,
96 instanceKlass* holder,
97 Symbol* name,
98 Symbol* sig,
99 Bytecodes::Code bc);
100
101 private:
102
103 // Is this thread currently in the VM state?
104 static bool is_in_vm();
105
106 // Helper routine for determining the validity of a compilation
107 // with respect to concurrent class loading.
108 static bool check_for_system_dictionary_modification(Dependencies* target);
109
110 public:
111 // Register the result of a compilation.
112 static nmethod* register_method(methodHandle target,
113 int entry_bci,
114 CodeOffsets* offsets,
115 int orig_pc_offset,
116 CodeBuffer* code_buffer,
117 int frame_words,
118 OopMapSet* oop_map_set,
119 ExceptionHandlerTable* handler_table,
120 ImplicitExceptionTable* inc_table,
121 AbstractCompiler* compiler,
122 DebugInformationRecorder* debug_info,
123 Dependencies* dependencies,
124 CompileTask* task,
125 int compile_id,
126 bool has_debug_info = true,
127 bool has_unsafe_access = false,
128 bool install_code = true);
129
130 static ciKlass* find_system_klass(ciSymbol* klass_name);
131 // Note: To find a class from its name string, use ciSymbol::make,
132 // but consider adding to vmSymbols.hpp instead.
133
134 // converts the ciKlass* representing the holder of a method into a
135 // ciInstanceKlass*. This is needed since the holder of a method in
136 // the bytecodes could be an array type. Basically this converts
137 // array types into java/lang/Object and other types stay as they are.
138 static instanceKlass* get_instance_klass_for_declared_method_holder(KlassHandle klass);
139 };
140
141 #endif // SHARE_VM_GRAAL_GRAALENV_HPP