src/cpu/x86/vm/stubGenerator_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 7055355 Sdiff src/cpu/x86/vm

src/cpu/x86/vm/stubGenerator_x86_32.cpp

Print this page




2134       StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
2135 
2136       __ fld_d(Address(rsp, 4));
2137       __ trigfunc('t');
2138       __ ret(0);
2139     }
2140 
2141     // The intrinsic version of these seem to return the same value as
2142     // the strict version.
2143     StubRoutines::_intrinsic_exp = SharedRuntime::dexp;
2144     StubRoutines::_intrinsic_pow = SharedRuntime::dpow;
2145   }
2146 
2147  public:
2148   // Information about frame layout at time of blocking runtime call.
2149   // Note that we only have to preserve callee-saved registers since
2150   // the compilers are responsible for supplying a continuation point
2151   // if they expect all registers to be preserved.
2152   enum layout {
2153     thread_off,    // last_java_sp


2154     rbp_off,       // callee saved register
2155     ret_pc,
2156     framesize
2157   };
2158 
2159  private:
2160 
2161 #undef  __
2162 #define __ masm->
2163 
2164   //------------------------------------------------------------------------------------------------------------------------
2165   // Continuation point for throwing of implicit exceptions that are not handled in
2166   // the current activation. Fabricates an exception oop and initiates normal
2167   // exception dispatching in this frame.
2168   //
2169   // Previously the compiler (c2) allowed for callee save registers on Java calls.
2170   // This is no longer true after adapter frames were removed but could possibly
2171   // be brought back in the future if the interpreter code was reworked and it
2172   // was deemed worthwhile. The comment below was left to describe what must
2173   // happen here if callee saves were resurrected. As it stands now this stub
2174   // could actually be a vanilla BufferBlob and have now oopMap at all.
2175   // Since it doesn't make much difference we've chosen to leave it the
2176   // way it was in the callee save days and keep the comment.
2177 
2178   // If we need to preserve callee-saved values we need a callee-saved oop map and
2179   // therefore have to make these stubs into RuntimeStubs rather than BufferBlobs.
2180   // If the compiler needs all registers to be preserved between the fault
2181   // point and the exception handler then it must assume responsibility for that in
2182   // AbstractCompiler::continuation_for_implicit_null_exception or
2183   // continuation_for_implicit_division_by_zero_exception. All other implicit
2184   // exceptions (e.g., NullPointerException or AbstractMethodError on entry) are
2185   // either at call sites or otherwise assume that stack unwinding will be initiated,
2186   // so caller saved registers were assumed volatile in the compiler.
2187   address generate_throw_exception(const char* name, address runtime_entry,
2188                                    bool restore_saved_exception_pc) {
2189 
2190     int insts_size = 256;
2191     int locs_size  = 32;
2192 
2193     CodeBuffer code(name, insts_size, locs_size);
2194     OopMapSet* oop_maps  = new OopMapSet();
2195     MacroAssembler* masm = new MacroAssembler(&code);
2196 
2197     address start = __ pc();
2198 
2199     // This is an inlined and slightly modified version of call_VM
2200     // which has the ability to fetch the return PC out of
2201     // thread-local storage and also sets up last_Java_sp slightly
2202     // differently than the real call_VM
2203     Register java_thread = rbx;
2204     __ get_thread(java_thread);
2205     if (restore_saved_exception_pc) {
2206       __ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset())));
2207       __ push(rax);
2208     }
2209 
2210     __ enter(); // required for proper stackwalking of RuntimeStub frame
2211 
2212     // pc and rbp, already pushed
2213     __ subptr(rsp, (framesize-2) * wordSize); // prolog
2214 
2215     // Frame is now completed as far as size and linkage.
2216 
2217     int frame_complete = __ pc() - start;
2218 
2219     // push java thread (becomes first argument of C function)
2220     __ movptr(Address(rsp, thread_off * wordSize), java_thread);







2221 
2222     // Set up last_Java_sp and last_Java_fp
2223     __ set_last_Java_frame(java_thread, rsp, rbp, NULL);
2224 
2225     // Call runtime
2226     BLOCK_COMMENT("call runtime_entry");
2227     __ call(RuntimeAddress(runtime_entry));
2228     // Generate oop map
2229     OopMap* map =  new OopMap(framesize, 0);
2230     oop_maps->add_gc_map(__ pc() - start, map);
2231 
2232     // restore the thread (cannot use the pushed argument since arguments
2233     // may be overwritten by C code generated by an optimizing compiler);
2234     // however can use the register value directly if it is callee saved.
2235     __ get_thread(java_thread);
2236 
2237     __ reset_last_Java_frame(java_thread, true, false);
2238 
2239     __ leave(); // required for proper stackwalking of RuntimeStub frame
2240 


2292     StubRoutines::_call_stub_entry              =
2293       generate_call_stub(StubRoutines::_call_stub_return_address);
2294     // is referenced by megamorphic call
2295     StubRoutines::_catch_exception_entry        = generate_catch_exception();
2296 
2297     // These are currently used by Solaris/Intel
2298     StubRoutines::_atomic_xchg_entry            = generate_atomic_xchg();
2299 
2300     StubRoutines::_handler_for_unsafe_access_entry =
2301       generate_handler_for_unsafe_access();
2302 
2303     // platform dependent
2304     create_control_words();
2305 
2306     StubRoutines::x86::_verify_mxcsr_entry                 = generate_verify_mxcsr();
2307     StubRoutines::x86::_verify_fpu_cntrl_wrd_entry         = generate_verify_fpu_cntrl_wrd();
2308     StubRoutines::_d2i_wrapper                              = generate_d2i_wrapper(T_INT,
2309                                                                                    CAST_FROM_FN_PTR(address, SharedRuntime::d2i));
2310     StubRoutines::_d2l_wrapper                              = generate_d2i_wrapper(T_LONG,
2311                                                                                    CAST_FROM_FN_PTR(address, SharedRuntime::d2l));






2312   }
2313 
2314 
2315   void generate_all() {
2316     // Generates all stubs and initializes the entry points
2317 
2318     // These entry points require SharedInfo::stack0 to be set up in non-core builds
2319     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
2320     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError),  false);
2321     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
2322     StubRoutines::_throw_ArithmeticException_entry         = generate_throw_exception("ArithmeticException throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException),  true);
2323     StubRoutines::_throw_NullPointerException_entry        = generate_throw_exception("NullPointerException throw_exception",         CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true);
2324     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
2325     StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError),   false);
2326 
2327     //------------------------------------------------------------------------------------------------------------------------
2328     // entry points that are platform specific
2329 
2330     // support for verify_oop (must happen after universe_init)
2331     StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop();




2134       StubRoutines::_intrinsic_tan = (double (*)(double)) __ pc();
2135 
2136       __ fld_d(Address(rsp, 4));
2137       __ trigfunc('t');
2138       __ ret(0);
2139     }
2140 
2141     // The intrinsic version of these seem to return the same value as
2142     // the strict version.
2143     StubRoutines::_intrinsic_exp = SharedRuntime::dexp;
2144     StubRoutines::_intrinsic_pow = SharedRuntime::dpow;
2145   }
2146 
2147  public:
2148   // Information about frame layout at time of blocking runtime call.
2149   // Note that we only have to preserve callee-saved registers since
2150   // the compilers are responsible for supplying a continuation point
2151   // if they expect all registers to be preserved.
2152   enum layout {
2153     thread_off,    // last_java_sp
2154     arg1_off,
2155     arg2_off,
2156     rbp_off,       // callee saved register
2157     ret_pc,
2158     framesize
2159   };
2160 
2161  private:
2162 
2163 #undef  __
2164 #define __ masm->
2165 
2166   //------------------------------------------------------------------------------------------------------------------------
2167   // Continuation point for throwing of implicit exceptions that are not handled in
2168   // the current activation. Fabricates an exception oop and initiates normal
2169   // exception dispatching in this frame.
2170   //
2171   // Previously the compiler (c2) allowed for callee save registers on Java calls.
2172   // This is no longer true after adapter frames were removed but could possibly
2173   // be brought back in the future if the interpreter code was reworked and it
2174   // was deemed worthwhile. The comment below was left to describe what must
2175   // happen here if callee saves were resurrected. As it stands now this stub
2176   // could actually be a vanilla BufferBlob and have now oopMap at all.
2177   // Since it doesn't make much difference we've chosen to leave it the
2178   // way it was in the callee save days and keep the comment.
2179 
2180   // If we need to preserve callee-saved values we need a callee-saved oop map and
2181   // therefore have to make these stubs into RuntimeStubs rather than BufferBlobs.
2182   // If the compiler needs all registers to be preserved between the fault
2183   // point and the exception handler then it must assume responsibility for that in
2184   // AbstractCompiler::continuation_for_implicit_null_exception or
2185   // continuation_for_implicit_division_by_zero_exception. All other implicit
2186   // exceptions (e.g., NullPointerException or AbstractMethodError on entry) are
2187   // either at call sites or otherwise assume that stack unwinding will be initiated,
2188   // so caller saved registers were assumed volatile in the compiler.
2189   address generate_throw_exception(const char* name, address runtime_entry,
2190                                    bool restore_saved_exception_pc, Register arg1 = noreg, Register arg2 = noreg) {
2191 
2192     int insts_size = 256;
2193     int locs_size  = 32;
2194 
2195     CodeBuffer code(name, insts_size, locs_size);
2196     OopMapSet* oop_maps  = new OopMapSet();
2197     MacroAssembler* masm = new MacroAssembler(&code);
2198 
2199     address start = __ pc();
2200 
2201     // This is an inlined and slightly modified version of call_VM
2202     // which has the ability to fetch the return PC out of
2203     // thread-local storage and also sets up last_Java_sp slightly
2204     // differently than the real call_VM
2205     Register java_thread = rbx;
2206     __ get_thread(java_thread);
2207     if (restore_saved_exception_pc) {
2208       __ movptr(rax, Address(java_thread, in_bytes(JavaThread::saved_exception_pc_offset())));
2209       __ push(rax);
2210     }
2211 
2212     __ enter(); // required for proper stackwalking of RuntimeStub frame
2213 
2214     // pc and rbp, already pushed
2215     __ subptr(rsp, (framesize-2) * wordSize); // prolog
2216 
2217     // Frame is now completed as far as size and linkage.
2218 
2219     int frame_complete = __ pc() - start;
2220 
2221     // push java thread (becomes first argument of C function)
2222     __ movptr(Address(rsp, thread_off * wordSize), java_thread);
2223     if (arg1 != noreg) {
2224       __ movptr(Address(rsp, arg1_off * wordSize), arg1);
2225     }
2226     if (arg2 != noreg) {
2227       assert(arg1 != noreg, "missing reg arg");
2228       __ movptr(Address(rsp, arg2_off * wordSize), arg2);
2229     }
2230 
2231     // Set up last_Java_sp and last_Java_fp
2232     __ set_last_Java_frame(java_thread, rsp, rbp, NULL);
2233 
2234     // Call runtime
2235     BLOCK_COMMENT("call runtime_entry");
2236     __ call(RuntimeAddress(runtime_entry));
2237     // Generate oop map
2238     OopMap* map =  new OopMap(framesize, 0);
2239     oop_maps->add_gc_map(__ pc() - start, map);
2240 
2241     // restore the thread (cannot use the pushed argument since arguments
2242     // may be overwritten by C code generated by an optimizing compiler);
2243     // however can use the register value directly if it is callee saved.
2244     __ get_thread(java_thread);
2245 
2246     __ reset_last_Java_frame(java_thread, true, false);
2247 
2248     __ leave(); // required for proper stackwalking of RuntimeStub frame
2249 


2301     StubRoutines::_call_stub_entry              =
2302       generate_call_stub(StubRoutines::_call_stub_return_address);
2303     // is referenced by megamorphic call
2304     StubRoutines::_catch_exception_entry        = generate_catch_exception();
2305 
2306     // These are currently used by Solaris/Intel
2307     StubRoutines::_atomic_xchg_entry            = generate_atomic_xchg();
2308 
2309     StubRoutines::_handler_for_unsafe_access_entry =
2310       generate_handler_for_unsafe_access();
2311 
2312     // platform dependent
2313     create_control_words();
2314 
2315     StubRoutines::x86::_verify_mxcsr_entry                 = generate_verify_mxcsr();
2316     StubRoutines::x86::_verify_fpu_cntrl_wrd_entry         = generate_verify_fpu_cntrl_wrd();
2317     StubRoutines::_d2i_wrapper                              = generate_d2i_wrapper(T_INT,
2318                                                                                    CAST_FROM_FN_PTR(address, SharedRuntime::d2i));
2319     StubRoutines::_d2l_wrapper                              = generate_d2i_wrapper(T_LONG,
2320                                                                                    CAST_FROM_FN_PTR(address, SharedRuntime::d2l));
2321 
2322     // Build this early so it's available for the interpreter
2323     StubRoutines::_throw_WrongMethodTypeException_entry =
2324       generate_throw_exception("WrongMethodTypeException throw_exception",
2325                                CAST_FROM_FN_PTR(address, SharedRuntime::throw_WrongMethodTypeException),
2326                                false, rax, rcx);
2327   }
2328 
2329 
2330   void generate_all() {
2331     // Generates all stubs and initializes the entry points
2332 
2333     // These entry points require SharedInfo::stack0 to be set up in non-core builds
2334     // and need to be relocatable, so they each fabricate a RuntimeStub internally.
2335     StubRoutines::_throw_AbstractMethodError_entry         = generate_throw_exception("AbstractMethodError throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_AbstractMethodError),  false);
2336     StubRoutines::_throw_IncompatibleClassChangeError_entry= generate_throw_exception("IncompatibleClassChangeError throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_IncompatibleClassChangeError),  false);
2337     StubRoutines::_throw_ArithmeticException_entry         = generate_throw_exception("ArithmeticException throw_exception",          CAST_FROM_FN_PTR(address, SharedRuntime::throw_ArithmeticException),  true);
2338     StubRoutines::_throw_NullPointerException_entry        = generate_throw_exception("NullPointerException throw_exception",         CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException), true);
2339     StubRoutines::_throw_NullPointerException_at_call_entry= generate_throw_exception("NullPointerException at call throw_exception", CAST_FROM_FN_PTR(address, SharedRuntime::throw_NullPointerException_at_call), false);
2340     StubRoutines::_throw_StackOverflowError_entry          = generate_throw_exception("StackOverflowError throw_exception",           CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError),   false);
2341 
2342     //------------------------------------------------------------------------------------------------------------------------
2343     // entry points that are platform specific
2344 
2345     // support for verify_oop (must happen after universe_init)
2346     StubRoutines::_verify_oop_subroutine_entry     = generate_verify_oop();


src/cpu/x86/vm/stubGenerator_x86_32.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File