hotspot/src/cpu/aarch64/vm/frame_aarch64.cpp
changeset 38133 78b95467b9f1
parent 35232 76aed99c0ddd
child 40332 a52d1e719c4d
equal deleted inserted replaced
38132:ba888a4f352a 38133:78b95467b9f1
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     3  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
     3  * Copyright (c) 2014, Red Hat Inc. 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
   219       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > (address)sender.fp());
   219       bool jcw_safe = (jcw < thread->stack_base()) && ( jcw > (address)sender.fp());
   220 
   220 
   221       return jcw_safe;
   221       return jcw_safe;
   222     }
   222     }
   223 
   223 
   224     if (sender_blob->is_nmethod()) {
   224     CompiledMethod* nm = sender_blob->as_compiled_method_or_null();
   225         nmethod* nm = sender_blob->as_nmethod_or_null();
   225     if (nm != NULL) {
   226         if (nm != NULL) {
   226       if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
   227             if (nm->is_deopt_mh_entry(sender_pc) || nm->is_deopt_entry(sender_pc) ||
   227           nm->method()->is_method_handle_intrinsic()) {
   228                 nm->method()->is_method_handle_intrinsic()) {
   228         return false;
   229                 return false;
   229       }
   230             }
       
   231         }
       
   232     }
   230     }
   233 
   231 
   234     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
   232     // If the frame size is 0 something (or less) is bad because every nmethod has a non-zero frame size
   235     // because the return address counts against the callee's frame.
   233     // because the return address counts against the callee's frame.
   236 
   234 
   237     if (sender_blob->frame_size() <= 0) {
   235     if (sender_blob->frame_size() <= 0) {
   238       assert(!sender_blob->is_nmethod(), "should count return address at least");
   236       assert(!sender_blob->is_compiled(), "should count return address at least");
   239       return false;
   237       return false;
   240     }
   238     }
   241 
   239 
   242     // We should never be able to see anything here except an nmethod. If something in the
   240     // We should never be able to see anything here except an nmethod. If something in the
   243     // code cache (current frame) is called by an entity within the code cache that entity
   241     // code cache (current frame) is called by an entity within the code cache that entity
   244     // should not be anything but the call stub (already covered), the interpreter (already covered)
   242     // should not be anything but the call stub (already covered), the interpreter (already covered)
   245     // or an nmethod.
   243     // or an nmethod.
   246 
   244 
   247     if (!sender_blob->is_nmethod()) {
   245     if (!sender_blob->is_compiled()) {
   248         return false;
   246         return false;
   249     }
   247     }
   250 
   248 
   251     // Could put some more validation for the potential non-interpreted sender
   249     // Could put some more validation for the potential non-interpreted sender
   252     // frame we'd create by calling sender if I could think of any. Wait for next crash in forte...
   250     // frame we'd create by calling sender if I could think of any. Wait for next crash in forte...
   284   // Either the return address is the original one or we are going to
   282   // Either the return address is the original one or we are going to
   285   // patch in the same address that's already there.
   283   // patch in the same address that's already there.
   286   assert(_pc == *pc_addr || pc == *pc_addr, "must be");
   284   assert(_pc == *pc_addr || pc == *pc_addr, "must be");
   287   *pc_addr = pc;
   285   *pc_addr = pc;
   288   _cb = CodeCache::find_blob(pc);
   286   _cb = CodeCache::find_blob(pc);
   289   address original_pc = nmethod::get_deopt_original_pc(this);
   287   address original_pc = CompiledMethod::get_deopt_original_pc(this);
   290   if (original_pc != NULL) {
   288   if (original_pc != NULL) {
   291     assert(original_pc == _pc, "expected original PC to be stored before patching");
   289     assert(original_pc == _pc, "expected original PC to be stored before patching");
   292     _deopt_state = is_deoptimized;
   290     _deopt_state = is_deoptimized;
   293     // leave _pc as is
   291     // leave _pc as is
   294   } else {
   292   } else {
   369 // frame::verify_deopt_original_pc
   367 // frame::verify_deopt_original_pc
   370 //
   368 //
   371 // Verifies the calculated original PC of a deoptimization PC for the
   369 // Verifies the calculated original PC of a deoptimization PC for the
   372 // given unextended SP.
   370 // given unextended SP.
   373 #ifdef ASSERT
   371 #ifdef ASSERT
   374 void frame::verify_deopt_original_pc(nmethod* nm, intptr_t* unextended_sp) {
   372 void frame::verify_deopt_original_pc(CompiledMethod* nm, intptr_t* unextended_sp) {
   375   frame fr;
   373   frame fr;
   376 
   374 
   377   // This is ugly but it's better than to change {get,set}_original_pc
   375   // This is ugly but it's better than to change {get,set}_original_pc
   378   // to take an SP value as argument.  And it's only a debugging
   376   // to take an SP value as argument.  And it's only a debugging
   379   // method anyway.
   377   // method anyway.
   389 void frame::adjust_unextended_sp() {
   387 void frame::adjust_unextended_sp() {
   390   // On aarch64, sites calling method handle intrinsics and lambda forms are treated
   388   // On aarch64, sites calling method handle intrinsics and lambda forms are treated
   391   // as any other call site. Therefore, no special action is needed when we are
   389   // as any other call site. Therefore, no special action is needed when we are
   392   // returning to any of these call sites.
   390   // returning to any of these call sites.
   393 
   391 
   394   nmethod* sender_nm = (_cb == NULL) ? NULL : _cb->as_nmethod_or_null();
   392   if (_cb != NULL) {
   395   if (sender_nm != NULL) {
   393     CompiledMethod* sender_cm = _cb->as_compiled_method_or_null();
   396     // If the sender PC is a deoptimization point, get the original PC.
   394     if (sender_cm != NULL) {
   397     if (sender_nm->is_deopt_entry(_pc) ||
   395       // If the sender PC is a deoptimization point, get the original PC.
   398         sender_nm->is_deopt_mh_entry(_pc)) {
   396       if (sender_cm->is_deopt_entry(_pc) ||
   399       DEBUG_ONLY(verify_deopt_original_pc(sender_nm, _unextended_sp));
   397           sender_cm->is_deopt_mh_entry(_pc)) {
       
   398         DEBUG_ONLY(verify_deopt_original_pc(sender_cm, _unextended_sp));
       
   399       }
   400     }
   400     }
   401   }
   401   }
   402 }
   402 }
   403 
   403 
   404 //------------------------------------------------------------------------------
   404 //------------------------------------------------------------------------------