Mercurial > hg > graal-jvmci-8
comparison src/share/vm/jvmci/jvmciCodeInstaller.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/graalCodeInstaller.hpp@0d578aeb2b5e |
children | b9f9b8af17ff |
comparison
equal
deleted
inserted
replaced
21558:d563baeca9df | 21559:be896a1983c0 |
---|---|
1 /* | |
2 * Copyright (c) 2011, 2014, 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 #ifndef SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP | |
25 #define SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP | |
26 | |
27 #include "jvmci/jvmciEnv.hpp" | |
28 | |
29 /* | |
30 * This class handles the conversion from a InstalledCode to a CodeBlob or an nmethod. | |
31 */ | |
32 class CodeInstaller : public StackObj { | |
33 friend class VMStructs; | |
34 private: | |
35 enum MarkId { | |
36 VERIFIED_ENTRY = 1, | |
37 UNVERIFIED_ENTRY = 2, | |
38 OSR_ENTRY = 3, | |
39 EXCEPTION_HANDLER_ENTRY = 4, | |
40 DEOPT_HANDLER_ENTRY = 5, | |
41 INVOKEINTERFACE = 6, | |
42 INVOKEVIRTUAL = 7, | |
43 INVOKESTATIC = 8, | |
44 INVOKESPECIAL = 9, | |
45 INLINE_INVOKE = 10, | |
46 POLL_NEAR = 11, | |
47 POLL_RETURN_NEAR = 12, | |
48 POLL_FAR = 13, | |
49 POLL_RETURN_FAR = 14, | |
50 CARD_TABLE_ADDRESS = 15, | |
51 CARD_TABLE_SHIFT = 16, | |
52 INVOKE_INVALID = -1 | |
53 }; | |
54 | |
55 Arena _arena; | |
56 | |
57 jobject _data_section_handle; | |
58 jobject _data_section_patches_handle; | |
59 jobject _sites_handle; | |
60 jobject _exception_handlers_handle; | |
61 CodeOffsets _offsets; | |
62 | |
63 jobject _code_handle; | |
64 jint _code_size; | |
65 jint _total_frame_size; | |
66 jint _custom_stack_area_offset; | |
67 jint _parameter_count; | |
68 jint _constants_size; | |
69 #ifndef PRODUCT | |
70 jobject _comments_handle; | |
71 #endif | |
72 | |
73 MarkId _next_call_type; | |
74 address _invoke_mark_pc; | |
75 | |
76 CodeSection* _instructions; | |
77 CodeSection* _constants; | |
78 | |
79 OopRecorder* _oop_recorder; | |
80 DebugInformationRecorder* _debug_recorder; | |
81 Dependencies* _dependencies; | |
82 ExceptionHandlerTable _exception_handler_table; | |
83 | |
84 static ConstantOopWriteValue* _oop_null_scope_value; | |
85 static ConstantIntValue* _int_m1_scope_value; | |
86 static ConstantIntValue* _int_0_scope_value; | |
87 static ConstantIntValue* _int_1_scope_value; | |
88 static ConstantIntValue* _int_2_scope_value; | |
89 static LocationValue* _illegal_value; | |
90 | |
91 jint pd_next_offset(NativeInstruction* inst, jint pc_offset, oop method); | |
92 void pd_patch_OopConstant(int pc_offset, Handle& constant); | |
93 void pd_patch_DataSectionReference(int pc_offset, int data_offset); | |
94 void pd_relocate_CodeBlob(CodeBlob* cb, NativeInstruction* inst); | |
95 void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination); | |
96 void pd_relocate_JavaMethod(oop method, jint pc_offset); | |
97 void pd_relocate_poll(address pc, jint mark); | |
98 | |
99 objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); } | |
100 arrayOop code() { return (arrayOop) JNIHandles::resolve(_code_handle); } | |
101 arrayOop data_section() { return (arrayOop) JNIHandles::resolve(_data_section_handle); } | |
102 objArrayOop data_section_patches() { return (objArrayOop) JNIHandles::resolve(_data_section_patches_handle); } | |
103 objArrayOop exception_handlers() { return (objArrayOop) JNIHandles::resolve(_exception_handlers_handle); } | |
104 #ifndef PRODUCT | |
105 objArrayOop comments() { return (objArrayOop) JNIHandles::resolve(_comments_handle); } | |
106 #endif | |
107 | |
108 public: | |
109 | |
110 CodeInstaller() : _arena(mtCompiler) {} | |
111 JVMCIEnv::CodeInstallResult install(Handle& compiled_code, CodeBlob*& cb, Handle installed_code, Handle speculation_log); | |
112 | |
113 static address runtime_call_target_address(oop runtime_call); | |
114 static VMReg get_hotspot_reg(jint jvmciRegisterNumber); | |
115 static bool is_general_purpose_reg(VMReg hotspotRegister); | |
116 | |
117 private: | |
118 ScopeValue* get_scope_value(oop value, GrowableArray<ScopeValue*>* objects, ScopeValue* &second); | |
119 MonitorValue* get_monitor_value(oop value, GrowableArray<ScopeValue*>* objects); | |
120 | |
121 // extract the fields of the CompilationResult | |
122 void initialize_fields(oop target_method); | |
123 void initialize_dependencies(oop target_method); | |
124 | |
125 int estimate_stub_entries(); | |
126 | |
127 // perform data and call relocation on the CodeBuffer | |
128 bool initialize_buffer(CodeBuffer& buffer); | |
129 | |
130 void assumption_NoFinalizableSubclass(Handle assumption); | |
131 void assumption_ConcreteSubtype(Handle assumption); | |
132 void assumption_LeafType(Handle assumption); | |
133 void assumption_ConcreteMethod(Handle assumption); | |
134 void assumption_CallSiteTargetValue(Handle assumption); | |
135 | |
136 void site_Safepoint(CodeBuffer& buffer, jint pc_offset, oop site); | |
137 void site_Infopoint(CodeBuffer& buffer, jint pc_offset, oop site); | |
138 void site_Call(CodeBuffer& buffer, jint pc_offset, oop site); | |
139 void site_DataPatch(CodeBuffer& buffer, jint pc_offset, oop site); | |
140 void site_Mark(CodeBuffer& buffer, jint pc_offset, oop site); | |
141 | |
142 void record_scope(jint pc_offset, oop debug_info); | |
143 void record_scope(jint pc_offset, oop code_pos, GrowableArray<ScopeValue*>* objects); | |
144 void record_object_value(ObjectValue* sv, oop value, GrowableArray<ScopeValue*>* objects); | |
145 | |
146 GrowableArray<ScopeValue*>* record_virtual_objects(oop debug_info); | |
147 | |
148 void process_exception_handlers(); | |
149 int estimateStubSpace(int static_call_stubs); | |
150 }; | |
151 | |
152 /** | |
153 * Gets the Method metaspace object from a HotSpotResolvedJavaMethodImpl Java object. | |
154 */ | |
155 Method* getMethodFromHotSpotMethod(oop hotspot_method); | |
156 | |
157 | |
158 | |
159 #endif // SHARE_VM_JVMCI_JVMCI_CODE_INSTALLER_HPP |