< prev index next >

src/hotspot/cpu/ppc/nativeInst_ppc.cpp

Print this page




  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "nativeInst_ppc.hpp"
  30 #include "oops/oop.inline.hpp"

  31 #include "runtime/handles.hpp"
  32 #include "runtime/sharedRuntime.hpp"
  33 #include "runtime/stubRoutines.hpp"
  34 #include "utilities/ostream.hpp"
  35 #ifdef COMPILER1
  36 #include "c1/c1_Runtime1.hpp"
  37 #endif
  38 
  39 // We use an illtrap for marking a method as not_entrant or zombie iff !UseSIGTRAP
  40 // Work around a C++ compiler bug which changes 'this'
  41 bool NativeInstruction::is_sigill_zombie_not_entrant_at(address addr) {
  42   assert(!UseSIGTRAP, "precondition");
  43   if (*(int*)addr != 0 /*illtrap*/) return false;
  44   CodeBlob* cb = CodeCache::find_blob_unsafe(addr);
  45   if (cb == NULL || !cb->is_nmethod()) return false;
  46   nmethod *nm = (nmethod *)cb;
  47   // This method is not_entrant or zombie iff the illtrap instruction is
  48   // located at the verified entry point.
  49   return nm->verified_entry_point() == addr;
  50 }


 177   assert(!MacroAssembler::is_set_narrow_oop(addr_at(0), nm->content_begin()), "Should not patch narrow oop here");
 178 #endif
 179 
 180   if (MacroAssembler::is_load_const_from_method_toc_at(addr_at(0))) {
 181     return addr_at(load_const_from_method_toc_instruction_size);
 182   } else {
 183     return addr_at(load_const_instruction_size);
 184   }
 185 }
 186 
 187 intptr_t NativeMovConstReg::data() const {
 188   address   addr = addr_at(0);
 189 
 190   if (MacroAssembler::is_load_const_at(addr)) {
 191     return MacroAssembler::get_const(addr);
 192   }
 193 
 194   CodeBlob* cb = CodeCache::find_blob_unsafe(addr);
 195   if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) {
 196     narrowOop no = (narrowOop)MacroAssembler::get_narrow_oop(addr, cb->content_begin());
 197     return cast_from_oop<intptr_t>(oopDesc::decode_heap_oop(no));
 198   } else {
 199     assert(MacroAssembler::is_load_const_from_method_toc_at(addr), "must be load_const_from_pool");
 200 
 201     address ctable = cb->content_begin();
 202     int offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr);
 203     return *(intptr_t *)(ctable + offset);
 204   }
 205 }
 206 
 207 address NativeMovConstReg::set_data_plain(intptr_t data, CodeBlob *cb) {
 208   address addr         = instruction_address();
 209   address next_address = NULL;
 210   if (!cb) cb = CodeCache::find_blob(addr);
 211 
 212   if (cb != NULL && MacroAssembler::is_load_const_from_method_toc_at(addr)) {
 213     // A load from the method's TOC (ctable).
 214     assert(cb->is_nmethod(), "must be nmethod");
 215     const address ctable = cb->content_begin();
 216     const int toc_offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr);
 217     *(intptr_t *)(ctable + toc_offset) = data;


 398   return instruction_addr;
 399 }
 400 
 401 address NativeCallTrampolineStub::destination(nmethod *nm) const {
 402   CodeBlob* cb = nm ? nm : CodeCache::find_blob_unsafe(addr_at(0));
 403   address ctable = cb->content_begin();
 404 
 405   return *(address*)(ctable + destination_toc_offset());
 406 }
 407 
 408 int NativeCallTrampolineStub::destination_toc_offset() const {
 409   return MacroAssembler::get_ld_largeoffset_offset(encoded_destination_addr());
 410 }
 411 
 412 void NativeCallTrampolineStub::set_destination(address new_destination) {
 413   CodeBlob* cb = CodeCache::find_blob(addr_at(0));
 414   address ctable = cb->content_begin();
 415 
 416   *(address*)(ctable + destination_toc_offset()) = new_destination;
 417 }
 418 


  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.
  23  *
  24  */
  25 
  26 #include "precompiled.hpp"
  27 #include "asm/macroAssembler.inline.hpp"
  28 #include "memory/resourceArea.hpp"
  29 #include "nativeInst_ppc.hpp"
  30 #include "oops/compressedOops.inline.hpp"
  31 #include "oops/oop.hpp"
  32 #include "runtime/handles.hpp"
  33 #include "runtime/sharedRuntime.hpp"
  34 #include "runtime/stubRoutines.hpp"
  35 #include "utilities/ostream.hpp"
  36 #ifdef COMPILER1
  37 #include "c1/c1_Runtime1.hpp"
  38 #endif
  39 
  40 // We use an illtrap for marking a method as not_entrant or zombie iff !UseSIGTRAP
  41 // Work around a C++ compiler bug which changes 'this'
  42 bool NativeInstruction::is_sigill_zombie_not_entrant_at(address addr) {
  43   assert(!UseSIGTRAP, "precondition");
  44   if (*(int*)addr != 0 /*illtrap*/) return false;
  45   CodeBlob* cb = CodeCache::find_blob_unsafe(addr);
  46   if (cb == NULL || !cb->is_nmethod()) return false;
  47   nmethod *nm = (nmethod *)cb;
  48   // This method is not_entrant or zombie iff the illtrap instruction is
  49   // located at the verified entry point.
  50   return nm->verified_entry_point() == addr;
  51 }


 178   assert(!MacroAssembler::is_set_narrow_oop(addr_at(0), nm->content_begin()), "Should not patch narrow oop here");
 179 #endif
 180 
 181   if (MacroAssembler::is_load_const_from_method_toc_at(addr_at(0))) {
 182     return addr_at(load_const_from_method_toc_instruction_size);
 183   } else {
 184     return addr_at(load_const_instruction_size);
 185   }
 186 }
 187 
 188 intptr_t NativeMovConstReg::data() const {
 189   address   addr = addr_at(0);
 190 
 191   if (MacroAssembler::is_load_const_at(addr)) {
 192     return MacroAssembler::get_const(addr);
 193   }
 194 
 195   CodeBlob* cb = CodeCache::find_blob_unsafe(addr);
 196   if (MacroAssembler::is_set_narrow_oop(addr, cb->content_begin())) {
 197     narrowOop no = (narrowOop)MacroAssembler::get_narrow_oop(addr, cb->content_begin());
 198     return cast_from_oop<intptr_t>(CompressedOops::decode(no));
 199   } else {
 200     assert(MacroAssembler::is_load_const_from_method_toc_at(addr), "must be load_const_from_pool");
 201 
 202     address ctable = cb->content_begin();
 203     int offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr);
 204     return *(intptr_t *)(ctable + offset);
 205   }
 206 }
 207 
 208 address NativeMovConstReg::set_data_plain(intptr_t data, CodeBlob *cb) {
 209   address addr         = instruction_address();
 210   address next_address = NULL;
 211   if (!cb) cb = CodeCache::find_blob(addr);
 212 
 213   if (cb != NULL && MacroAssembler::is_load_const_from_method_toc_at(addr)) {
 214     // A load from the method's TOC (ctable).
 215     assert(cb->is_nmethod(), "must be nmethod");
 216     const address ctable = cb->content_begin();
 217     const int toc_offset = MacroAssembler::get_offset_of_load_const_from_method_toc_at(addr);
 218     *(intptr_t *)(ctable + toc_offset) = data;


 399   return instruction_addr;
 400 }
 401 
 402 address NativeCallTrampolineStub::destination(nmethod *nm) const {
 403   CodeBlob* cb = nm ? nm : CodeCache::find_blob_unsafe(addr_at(0));
 404   address ctable = cb->content_begin();
 405 
 406   return *(address*)(ctable + destination_toc_offset());
 407 }
 408 
 409 int NativeCallTrampolineStub::destination_toc_offset() const {
 410   return MacroAssembler::get_ld_largeoffset_offset(encoded_destination_addr());
 411 }
 412 
 413 void NativeCallTrampolineStub::set_destination(address new_destination) {
 414   CodeBlob* cb = CodeCache::find_blob(addr_at(0));
 415   address ctable = cb->content_begin();
 416 
 417   *(address*)(ctable + destination_toc_offset()) = new_destination;
 418 }

< prev index next >