comparison src/share/vm/graal/graalRuntime.hpp @ 7125:1baf7f1e3f23

decoupled C++ Graal runtime from C1
author Doug Simon <doug.simon@oracle.com>
date Mon, 03 Dec 2012 15:32:17 +0100
parents d5f7e737827f
children 6c46172c04bf fcae6d960acd
comparison
equal deleted inserted replaced
7124:ab65fa23f8e9 7125:1baf7f1e3f23
22 */ 22 */
23 23
24 #ifndef SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP 24 #ifndef SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP
25 #define SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP 25 #define SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP
26 26
27 #include "code/stubs.hpp"
28 #include "interpreter/interpreter.hpp"
29 #include "memory/allocation.hpp"
30 #include "runtime/deoptimization.hpp"
31
32 // A GraalStubAssembler is a MacroAssembler w/ extra functionality for runtime
33 // stubs. Currently it 'knows' some stub info. Eventually, the information
34 // may be set automatically or can be asserted when using specialised
35 // GraalStubAssembler functions.
36
37 class GraalStubAssembler: public MacroAssembler {
38 private:
39 const char* _name;
40 bool _must_gc_arguments;
41 int _frame_size;
42 int _num_rt_args;
43 int _stub_id;
44
45 public:
46 // creation
47 GraalStubAssembler(CodeBuffer* code, const char * name, int stub_id);
48 void set_info(const char* name, bool must_gc_arguments);
49
50 void set_frame_size(int size);
51 void set_num_rt_args(int args);
52
53 // accessors
54 const char* name() const { return _name; }
55 bool must_gc_arguments() const { return _must_gc_arguments; }
56 int frame_size() const { return _frame_size; }
57 int num_rt_args() const { return _num_rt_args; }
58 int stub_id() const { return _stub_id; }
59
60 void verify_stack_oop(int offset) PRODUCT_RETURN;
61 void verify_not_null_oop(Register r) PRODUCT_RETURN;
62
63 // runtime calls (return offset of call to be used by GC map)
64 int call_RT(Register oop_result1, Register metadata_result, address entry, int args_size = 0);
65 int call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1);
66 int call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2);
67 int call_RT(Register oop_result1, Register metadata_result, address entry, Register arg1, Register arg2, Register arg3);
68 };
69
70 // set frame size and return address offset to these values in blobs
71 // (if the compiled frame uses ebp as link pointer on IA; otherwise,
72 // the frame size must be fixed)
73 enum {
74 no_frame_size = -1
75 };
76
77 // Holds all assembly stubs and VM
78 // runtime routines needed by code code generated
79 // by Graal.
80 #define GRAAL_STUBS(stub, last_entry) \
81 stub(graal_register_finalizer) \
82 stub(graal_new_instance) \
83 stub(graal_new_type_array) \
84 stub(graal_new_object_array) \
85 stub(graal_new_multi_array) \
86 stub(graal_handle_exception_nofpu) /* optimized version that does not preserve fpu registers */ \
87 stub(graal_slow_subtype_check) \
88 stub(graal_unwind_exception_call) \
89 stub(graal_OSR_migration_end) \
90 stub(graal_arithmetic_frem) \
91 stub(graal_arithmetic_drem) \
92 stub(graal_monitorenter) \
93 stub(graal_monitorexit) \
94 stub(graal_verify_oop) \
95 stub(graal_vm_error) \
96 stub(graal_set_deopt_info) \
97 stub(graal_create_null_pointer_exception) \
98 stub(graal_create_out_of_bounds_exception) \
99 stub(graal_log_object) \
100 stub(graal_log_printf) \
101 stub(graal_log_primitive) \
102 last_entry(number_of_ids)
103
104 #define DECLARE_STUB_ID(x) x ## _id ,
105 #define DECLARE_LAST_STUB_ID(x) x
106 #define STUB_NAME(x) #x " GraalRuntime stub",
107 #define LAST_STUB_NAME(x) #x " GraalRuntime stub"
108
109 class GraalRuntime: public AllStatic {
110 friend class VMStructs;
111
112 public:
113 enum StubID {
114 GRAAL_STUBS(DECLARE_STUB_ID, DECLARE_LAST_STUB_ID)
115 };
116
117 private:
118 static CodeBlob* _blobs[number_of_ids];
119 static const char* _blob_names[];
120
121 // stub generation
122 static void generate_blob_for(BufferBlob* blob, StubID id);
123 static OopMapSet* generate_code_for(StubID id, GraalStubAssembler* sasm);
124 static OopMapSet* generate_handle_exception(StubID id, GraalStubAssembler* sasm);
125 static void generate_unwind_exception(GraalStubAssembler *sasm);
126
127 static OopMapSet* generate_stub_call(GraalStubAssembler* sasm, Register result, address entry,
128 Register arg1 = noreg, Register arg2 = noreg, Register arg3 = noreg);
129
130 // runtime entry points
131 static void new_instance (JavaThread* thread, Klass* klass);
132 static void new_type_array (JavaThread* thread, Klass* klass, jint length);
133 static void new_object_array(JavaThread* thread, Klass* klass, jint length);
134 static void new_multi_array (JavaThread* thread, Klass* klass, int rank, jint* dims);
135
136 static void unimplemented_entry (JavaThread* thread, StubID id);
137
138 static address exception_handler_for_pc(JavaThread* thread);
139
140 static void graal_create_null_exception(JavaThread* thread);
141 static void graal_create_out_of_bounds_exception(JavaThread* thread, jint index);
142 static void graal_monitorenter(JavaThread* thread, oopDesc* obj, BasicLock* lock);
143 static void graal_monitorexit (JavaThread* thread, oopDesc* obj, BasicLock* lock);
144 static void graal_vm_error(JavaThread* thread, oop where, oop format, jlong value);
145 static void graal_log_printf(JavaThread* thread, oop format, jlong value);
146 static void graal_log_primitive(JavaThread* thread, jchar typeChar, jlong value, jboolean newline);
147
148 // Note: Must be kept in sync with constants in com.oracle.graal.snippets.Log
149 enum {
150 LOG_OBJECT_NEWLINE = 0x01,
151 LOG_OBJECT_STRING = 0x02,
152 LOG_OBJECT_ADDRESS = 0x04
153 };
154 static void graal_log_object(JavaThread* thread, oop msg, jint flags);
155
156 public:
157 // initialization
158 static void initialize(BufferBlob* blob);
159
160 // stubs
161 static CodeBlob* blob_for (StubID id);
162 static address entry_for(StubID id) { return blob_for(id)->code_begin(); }
163 static const char* name_for (StubID id);
164 static const char* name_for_address(address entry);
165 };
166
27 #endif // SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP 167 #endif // SHARE_VM_GRAAL_GRAAL_RUNTIME_HPP