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 #include "runtime/stubRoutines.hpp"
41
42 //--------------------gen_stub-------------------------------
43 void GraphKit::gen_stub(address C_function,
44 const char *name,
45 int is_fancy_jump,
46 bool pass_tls,
47 bool return_pc) {
48 ResourceMark rm;
49
50 const TypeTuple *jdomain = C->tf()->domain();
51 const TypeTuple *jrange = C->tf()->range();
52
53 // The procedure start
54 StartNode* start = new StartNode(root(), jdomain);
55 _gvn.set_type_bottom(start);
56
57 // Make a map, with JVM state
58 uint parm_cnt = jdomain->cnt();
59 uint max_map = MAX2(2*parm_cnt+1, jrange->cnt());
60 // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces
61 assert(SynchronizationEntryBCI == InvocationEntryBci, "");
62 JVMState* jvms = new (C) JVMState(0);
63 jvms->set_bci(InvocationEntryBci);
64 jvms->set_monoff(max_map);
65 jvms->set_scloff(max_map);
66 jvms->set_endoff(max_map);
67 {
68 SafePointNode *map = new SafePointNode( max_map, jvms );
69 jvms->set_map(map);
70 set_jvms(jvms);
71 assert(map == this->map(), "kit.map is set");
252 assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
253 Node *to_exc = new ForwardExceptionNode(if_not_null,
254 i_o(),
255 exit_memory,
256 frameptr(),
257 returnadr());
258 root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live
259 C->verify_start(start);
260
261 //-----------------------------
262 // If this is a normal subroutine return, issue the return and be done.
263 Node *ret = nullptr;
264 switch( is_fancy_jump ) {
265 case 0: // Make a return instruction
266 // Return to caller, free any space for return address
267 ret = new ReturnNode(TypeFunc::Parms, if_null,
268 i_o(),
269 exit_memory,
270 frameptr(),
271 returnadr());
272 if (C->tf()->range()->cnt() > TypeFunc::Parms)
273 ret->add_req( map()->in(TypeFunc::Parms) );
274 break;
275 case 1: // This is a fancy tail-call jump. Jump to computed address.
276 // Jump to new callee; leave old return address alone.
277 ret = new TailCallNode(if_null,
278 i_o(),
279 exit_memory,
280 frameptr(),
281 returnadr(),
282 target, map()->in(TypeFunc::Parms));
283 break;
284 case 2: // Pop return address & jump
285 // Throw away old return address; jump to new computed address
286 //assert(C_function == CAST_FROM_FN_PTR(address, OptoRuntime::rethrow_C), "fancy_jump==2 only for rethrow");
287 ret = new TailJumpNode(if_null,
288 i_o(),
289 exit_memory,
290 frameptr(),
291 target, map()->in(TypeFunc::Parms));
292 break;
|
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 #include "runtime/stubRoutines.hpp"
41
42 //--------------------gen_stub-------------------------------
43 void GraphKit::gen_stub(address C_function,
44 const char *name,
45 int is_fancy_jump,
46 bool pass_tls,
47 bool return_pc) {
48 ResourceMark rm;
49
50 const TypeTuple *jdomain = C->tf()->domain_sig();
51 const TypeTuple *jrange = C->tf()->range_sig();
52
53 // The procedure start
54 StartNode* start = new StartNode(root(), jdomain);
55 _gvn.set_type_bottom(start);
56
57 // Make a map, with JVM state
58 uint parm_cnt = jdomain->cnt();
59 uint max_map = MAX2(2*parm_cnt+1, jrange->cnt());
60 // %%% SynchronizationEntryBCI is redundant; use InvocationEntryBci in interfaces
61 assert(SynchronizationEntryBCI == InvocationEntryBci, "");
62 JVMState* jvms = new (C) JVMState(0);
63 jvms->set_bci(InvocationEntryBci);
64 jvms->set_monoff(max_map);
65 jvms->set_scloff(max_map);
66 jvms->set_endoff(max_map);
67 {
68 SafePointNode *map = new SafePointNode( max_map, jvms );
69 jvms->set_map(map);
70 set_jvms(jvms);
71 assert(map == this->map(), "kit.map is set");
252 assert (StubRoutines::forward_exception_entry() != nullptr, "must be generated before");
253 Node *to_exc = new ForwardExceptionNode(if_not_null,
254 i_o(),
255 exit_memory,
256 frameptr(),
257 returnadr());
258 root()->add_req(_gvn.transform(to_exc)); // bind to root to keep live
259 C->verify_start(start);
260
261 //-----------------------------
262 // If this is a normal subroutine return, issue the return and be done.
263 Node *ret = nullptr;
264 switch( is_fancy_jump ) {
265 case 0: // Make a return instruction
266 // Return to caller, free any space for return address
267 ret = new ReturnNode(TypeFunc::Parms, if_null,
268 i_o(),
269 exit_memory,
270 frameptr(),
271 returnadr());
272 if (C->tf()->range_sig()->cnt() > TypeFunc::Parms)
273 ret->add_req( map()->in(TypeFunc::Parms) );
274 break;
275 case 1: // This is a fancy tail-call jump. Jump to computed address.
276 // Jump to new callee; leave old return address alone.
277 ret = new TailCallNode(if_null,
278 i_o(),
279 exit_memory,
280 frameptr(),
281 returnadr(),
282 target, map()->in(TypeFunc::Parms));
283 break;
284 case 2: // Pop return address & jump
285 // Throw away old return address; jump to new computed address
286 //assert(C_function == CAST_FROM_FN_PTR(address, OptoRuntime::rethrow_C), "fancy_jump==2 only for rethrow");
287 ret = new TailJumpNode(if_null,
288 i_o(),
289 exit_memory,
290 frameptr(),
291 target, map()->in(TypeFunc::Parms));
292 break;
|