hotspot/src/cpu/ppc/vm/runtime_ppc.cpp
changeset 35085 839c8ba29724
parent 25715 d5a8dbdc5150
child 35594 cc13089c6327
equal deleted inserted replaced
35084:5b34a4ae0f58 35085:839c8ba29724
     1 /*
     1 /*
     2  * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright 2012, 2014 SAP AG. All rights reserved.
     3  * Copyright 2012, 2015 SAP AG. All rights reserved.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     5  *
     5  *
     6  * This code is free software; you can redistribute it and/or modify it
     6  * This code is free software; you can redistribute it and/or modify it
     7  * under the terms of the GNU General Public License version 2 only, as
     7  * under the terms of the GNU General Public License version 2 only, as
     8  * published by the Free Software Foundation.
     8  * published by the Free Software Foundation.
    42 
    42 
    43 #define __ masm->
    43 #define __ masm->
    44 
    44 
    45 
    45 
    46 #ifdef COMPILER2
    46 #ifdef COMPILER2
    47 
       
    48 // SP adjustment (must use unextended SP) for method handle call sites
       
    49 // during exception handling.
       
    50 static intptr_t adjust_SP_for_methodhandle_callsite(JavaThread *thread) {
       
    51   RegisterMap map(thread, false);
       
    52   // The frame constructor will do the correction for us (see frame::adjust_unextended_SP).
       
    53   frame mh_caller_frame = thread->last_frame().sender(&map);
       
    54   assert(mh_caller_frame.is_compiled_frame(), "Only may reach here for compiled MH call sites");
       
    55   return (intptr_t) mh_caller_frame.unextended_sp();
       
    56 }
       
    57 
    47 
    58 //------------------------------generate_exception_blob---------------------------
    48 //------------------------------generate_exception_blob---------------------------
    59 // Creates exception blob at the end.
    49 // Creates exception blob at the end.
    60 // Using exception blob, this code is jumped from a compiled method.
    50 // Using exception blob, this code is jumped from a compiled method.
    61 //
    51 //
   127   // handle_exception_stub), since they were restored when we got the
   117   // handle_exception_stub), since they were restored when we got the
   128   // exception.
   118   // exception.
   129   OopMapSet* oop_maps = new OopMapSet();
   119   OopMapSet* oop_maps = new OopMapSet();
   130   oop_maps->add_gc_map(calls_return_pc - start, map);
   120   oop_maps->add_gc_map(calls_return_pc - start, map);
   131 
   121 
   132   // Get unextended_sp for method handle call sites.
       
   133   Label mh_callsite, mh_done; // Use a 2nd c call if it's a method handle call site.
       
   134   __ lwa(R4_ARG2, in_bytes(JavaThread::is_method_handle_return_offset()), R16_thread);
       
   135   __ cmpwi(CCR0, R4_ARG2, 0);
       
   136   __ bne(CCR0, mh_callsite);
       
   137 
       
   138   __ mtctr(R3_RET); // Move address of exception handler to SR_CTR.
   122   __ mtctr(R3_RET); // Move address of exception handler to SR_CTR.
   139   __ reset_last_Java_frame();
   123   __ reset_last_Java_frame();
   140   __ pop_frame();
   124   __ pop_frame();
   141 
   125 
   142   __ bind(mh_done);
       
   143   // We have a handler in register SR_CTR (could be deopt blob).
   126   // We have a handler in register SR_CTR (could be deopt blob).
   144 
   127 
   145   // Get the exception oop.
   128   // Get the exception oop.
   146   __ ld(R3_ARG1, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
   129   __ ld(R3_ARG1, in_bytes(JavaThread::exception_oop_offset()), R16_thread);
   147 
   130 
   159 
   142 
   160   // Move exception pc into SR_LR.
   143   // Move exception pc into SR_LR.
   161   __ mtlr(R4_ARG2);
   144   __ mtlr(R4_ARG2);
   162   __ bctr();
   145   __ bctr();
   163 
   146 
   164 
       
   165   // Same as above, but also set sp to unextended_sp.
       
   166   __ bind(mh_callsite);
       
   167   __ mr(R31, R3_RET); // Save branch address.
       
   168   __ mr(R3_ARG1, R16_thread);
       
   169 #if defined(ABI_ELFv2)
       
   170   __ call_c((address) adjust_SP_for_methodhandle_callsite, relocInfo::none);
       
   171 #else
       
   172   __ call_c(CAST_FROM_FN_PTR(FunctionDescriptor*, adjust_SP_for_methodhandle_callsite), relocInfo::none);
       
   173 #endif
       
   174   // Returns unextended_sp in R3_RET.
       
   175 
       
   176   __ mtctr(R31); // Move address of exception handler to SR_CTR.
       
   177   __ reset_last_Java_frame();
       
   178 
       
   179   __ mr(R1_SP, R3_RET); // Set sp to unextended_sp.
       
   180   __ b(mh_done);
       
   181 
       
   182 
       
   183   // Make sure all code is generated.
   147   // Make sure all code is generated.
   184   masm->flush();
   148   masm->flush();
   185 
   149 
   186   // Set exception blob.
   150   // Set exception blob.
   187   _exception_blob = ExceptionBlob::create(&buffer, oop_maps,
   151   _exception_blob = ExceptionBlob::create(&buffer, oop_maps,