29 #include "opto/compile.hpp"
30 #include "opto/convertnode.hpp"
31 #include "opto/locknode.hpp"
32 #include "opto/memnode.hpp"
33 #include "opto/mulnode.hpp"
34 #include "opto/node.hpp"
35 #include "opto/parse.hpp"
36 #include "opto/phaseX.hpp"
37 #include "opto/rootnode.hpp"
38 #include "opto/runtime.hpp"
39 #include "opto/type.hpp"
40
41 //--------------------gen_stub-------------------------------
42 void GraphKit::gen_stub(address C_function,
43 const char *name,
44 int is_fancy_jump,
45 bool pass_tls,
46 bool return_pc) {
47 ResourceMark rm;
48
49 const TypeTuple *jdomain = C->tf()->domain();
50 const TypeTuple *jrange = C->tf()->range();
51
52 // The procedure start
53 StartNode* start = new StartNode(root(), jdomain);
54 _gvn.set_type_bottom(start);
55
56 // Make a map, with JVM state
57 uint parm_cnt = jdomain->cnt();
58 uint max_map = MAX2(2*parm_cnt+1, jrange->cnt());
59 // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces
60 assert(SynchronizationEntryBCI == InvocationEntryBci, "");
61 JVMState* jvms = new (C) JVMState(0);
62 jvms->set_bci(InvocationEntryBci);
63 jvms->set_monoff(max_map);
64 jvms->set_scloff(max_map);
65 jvms->set_endoff(max_map);
66 {
67 SafePointNode *map = new SafePointNode( max_map, jvms );
68 jvms->set_map(map);
69 set_jvms(jvms);
149 if (retval_ptr) {
150 assert( pass_tls, "Oop must be returned thru TLS" );
151 // Fancy-jumps return address; others return void
152 rfields[TypeFunc::Parms] = is_fancy_jump ? TypeRawPtr::BOTTOM : Type::TOP;
153
154 } else if (retval->isa_int()) { // Returning any integer subtype?
155 // "Fatten" byte, char & short return types to 'int' to show that
156 // the native C code can return values with junk high order bits.
157 // We'll sign-extend it below later.
158 rfields[TypeFunc::Parms] = TypeInt::INT; // It's "dirty" and needs sign-ext
159
160 } else if (jrange->cnt() >= TypeFunc::Parms+1) { // Else copy other types
161 rfields[TypeFunc::Parms] = jrange->field_at(TypeFunc::Parms);
162 if (jrange->cnt() == TypeFunc::Parms+2) {
163 rfields[TypeFunc::Parms+1] = jrange->field_at(TypeFunc::Parms+1);
164 }
165 }
166 const TypeTuple* range = TypeTuple::make(jrange->cnt(), rfields);
167
168 // Final C signature
169 const TypeFunc *c_sig = TypeFunc::make(domain, range);
170
171 //-----------------------------
172 // Make the call node.
173 CallRuntimeNode *call = new CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM);
174 //-----------------------------
175
176 // Fix-up the debug info for the call.
177 call->set_jvms(new (C) JVMState(0));
178 call->jvms()->set_bci(0);
179 call->jvms()->set_offsets(cnt);
180
181 // Set fixed predefined input arguments.
182 cnt = 0;
183 for (i = 0; i < TypeFunc::Parms; i++) {
184 call->init_req(cnt++, map()->in(i));
185 }
186 // A little too aggressive on the parm copy; return address is not an input.
187 call->set_req(TypeFunc::ReturnAdr, top());
188 for (; i < parm_cnt; i++) { // Regular input arguments.
189 const Type *f = jdomain->field_at(i);
|
29 #include "opto/compile.hpp"
30 #include "opto/convertnode.hpp"
31 #include "opto/locknode.hpp"
32 #include "opto/memnode.hpp"
33 #include "opto/mulnode.hpp"
34 #include "opto/node.hpp"
35 #include "opto/parse.hpp"
36 #include "opto/phaseX.hpp"
37 #include "opto/rootnode.hpp"
38 #include "opto/runtime.hpp"
39 #include "opto/type.hpp"
40
41 //--------------------gen_stub-------------------------------
42 void GraphKit::gen_stub(address C_function,
43 const char *name,
44 int is_fancy_jump,
45 bool pass_tls,
46 bool return_pc) {
47 ResourceMark rm;
48
49 const TypeTuple *jdomain = C->tf()->domain_sig();
50 const TypeTuple *jrange = C->tf()->range();
51
52 // The procedure start
53 StartNode* start = new StartNode(root(), jdomain);
54 _gvn.set_type_bottom(start);
55
56 // Make a map, with JVM state
57 uint parm_cnt = jdomain->cnt();
58 uint max_map = MAX2(2*parm_cnt+1, jrange->cnt());
59 // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces
60 assert(SynchronizationEntryBCI == InvocationEntryBci, "");
61 JVMState* jvms = new (C) JVMState(0);
62 jvms->set_bci(InvocationEntryBci);
63 jvms->set_monoff(max_map);
64 jvms->set_scloff(max_map);
65 jvms->set_endoff(max_map);
66 {
67 SafePointNode *map = new SafePointNode( max_map, jvms );
68 jvms->set_map(map);
69 set_jvms(jvms);
149 if (retval_ptr) {
150 assert( pass_tls, "Oop must be returned thru TLS" );
151 // Fancy-jumps return address; others return void
152 rfields[TypeFunc::Parms] = is_fancy_jump ? TypeRawPtr::BOTTOM : Type::TOP;
153
154 } else if (retval->isa_int()) { // Returning any integer subtype?
155 // "Fatten" byte, char & short return types to 'int' to show that
156 // the native C code can return values with junk high order bits.
157 // We'll sign-extend it below later.
158 rfields[TypeFunc::Parms] = TypeInt::INT; // It's "dirty" and needs sign-ext
159
160 } else if (jrange->cnt() >= TypeFunc::Parms+1) { // Else copy other types
161 rfields[TypeFunc::Parms] = jrange->field_at(TypeFunc::Parms);
162 if (jrange->cnt() == TypeFunc::Parms+2) {
163 rfields[TypeFunc::Parms+1] = jrange->field_at(TypeFunc::Parms+1);
164 }
165 }
166 const TypeTuple* range = TypeTuple::make(jrange->cnt(), rfields);
167
168 // Final C signature
169 const TypeFunc *c_sig = TypeFunc::make(domain, domain, range);
170
171 //-----------------------------
172 // Make the call node.
173 CallRuntimeNode *call = new CallRuntimeNode(c_sig, C_function, name, TypePtr::BOTTOM);
174 //-----------------------------
175
176 // Fix-up the debug info for the call.
177 call->set_jvms(new (C) JVMState(0));
178 call->jvms()->set_bci(0);
179 call->jvms()->set_offsets(cnt);
180
181 // Set fixed predefined input arguments.
182 cnt = 0;
183 for (i = 0; i < TypeFunc::Parms; i++) {
184 call->init_req(cnt++, map()->in(i));
185 }
186 // A little too aggressive on the parm copy; return address is not an input.
187 call->set_req(TypeFunc::ReturnAdr, top());
188 for (; i < parm_cnt; i++) { // Regular input arguments.
189 const Type *f = jdomain->field_at(i);
|