< prev index next >

src/hotspot/cpu/ppc/vtableStubs_ppc_64.cpp

Print this page


   1 /*
   2  * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   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
   8  * published by the Free Software Foundation.
   9  *
  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  *


  55 
  56   // Count unused bytes in instruction sequences of variable size.
  57   // We add them to the computed buffer size in order to avoid
  58   // overflow in subsequently generated stubs.
  59   address   start_pc;
  60   int       slop_bytes = 8; // just a two-instruction safety net
  61   int       slop_delta = 0;
  62 
  63   ResourceMark    rm;
  64   CodeBuffer      cb(s->entry_point(), stub_code_length);
  65   MacroAssembler* masm = new MacroAssembler(&cb);
  66 
  67 #if (!defined(PRODUCT) && defined(COMPILER2))
  68   if (CountCompiledCalls) {
  69     start_pc = __ pc();
  70     int load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
  71     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
  72     slop_delta  = load_const_maxLen - (__ pc() - start_pc);
  73     slop_bytes += slop_delta;
  74     assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
  75     __ lwz(R12_scratch2, offs, R11_scratch1);
  76     __ addi(R12_scratch2, R12_scratch2, 1);
  77     __ stw(R12_scratch2, offs, R11_scratch1);
  78   }
  79 #endif
  80 
  81   assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1");
  82 
  83   const Register rcvr_klass = R11_scratch1;
  84   address npe_addr = __ pc(); // npe = null pointer exception
  85   // check if we must do an explicit check (implicit checks disabled, offset too large).
  86   __ null_check(R3, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL);
  87   // Get receiver klass.
  88   __ load_klass(rcvr_klass, R3);
  89 
  90 #ifndef PRODUCT
  91   if (DebugVtables) {
  92     Label L;
  93     // Check offset vs vtable length.
  94     const Register vtable_len = R12_scratch2;
  95     __ lwz(vtable_len, in_bytes(Klass::vtable_length_offset()), rcvr_klass);
  96     __ cmpwi(CCR0, vtable_len, vtable_index*vtableEntry::size());
  97     __ bge(CCR0, L);


 123 
 124   __ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/NULL);
 125   __ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method);
 126   __ mtctr(R12_scratch2);
 127   __ bctr();
 128 
 129   masm->flush();
 130   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 131 
 132   return s;
 133 }
 134 
 135 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
 136   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 137   const int stub_code_length = code_size_limit(false);
 138   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
 139   // Can be NULL if there is no free space in the code cache.
 140   if (s == NULL) {
 141     return NULL;
 142   }

 143   // Count unused bytes in instruction sequences of variable size.
 144   // We add them to the computed buffer size in order to avoid
 145   // overflow in subsequently generated stubs.
 146   address   start_pc;
 147   int       slop_bytes = 8; // just a two-instruction safety net
 148   int       slop_delta = 0;
 149 
 150   ResourceMark    rm;
 151   CodeBuffer      cb(s->entry_point(), stub_code_length);
 152   MacroAssembler* masm = new MacroAssembler(&cb);
 153   int             load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
 154 
 155 #if (!defined(PRODUCT) && defined(COMPILER2))
 156   if (CountCompiledCalls) {
 157     start_pc = __ pc();
 158     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
 159     slop_delta  = load_const_maxLen - (__ pc() - start_pc);
 160     slop_bytes += slop_delta;
 161     assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 162     __ lwz(R12_scratch2, offs, R11_scratch1);
 163     __ addi(R12_scratch2, R12_scratch2, 1);
 164     __ stw(R12_scratch2, offs, R11_scratch1);
 165   }
 166 #endif
 167 
 168   assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1");
 169 
 170   // Entry arguments:
 171   //  R19_method: Interface
 172   //  R3_ARG1:    Receiver
 173 
 174   Label L_no_such_interface;
 175   const Register rcvr_klass = R11_scratch1,
 176                  interface  = R12_scratch2,
 177                  tmp1       = R21_tmp1,
 178                  tmp2       = R22_tmp2;
 179 
 180   address npe_addr = __ pc(); // npe = null pointer exception
 181   __ null_check(R3_ARG1, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL);
 182   __ load_klass(rcvr_klass, R3_ARG1);
 183 
 184   // Receiver subtype check against REFC.


   1 /*
   2  * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright (c) 2012, 2021 SAP SE. All rights reserved.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   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
   8  * published by the Free Software Foundation.
   9  *
  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  *


  55 
  56   // Count unused bytes in instruction sequences of variable size.
  57   // We add them to the computed buffer size in order to avoid
  58   // overflow in subsequently generated stubs.
  59   address   start_pc;
  60   int       slop_bytes = 8; // just a two-instruction safety net
  61   int       slop_delta = 0;
  62 
  63   ResourceMark    rm;
  64   CodeBuffer      cb(s->entry_point(), stub_code_length);
  65   MacroAssembler* masm = new MacroAssembler(&cb);
  66 
  67 #if (!defined(PRODUCT) && defined(COMPILER2))
  68   if (CountCompiledCalls) {
  69     start_pc = __ pc();
  70     int load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
  71     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
  72     slop_delta  = load_const_maxLen - (__ pc() - start_pc);
  73     slop_bytes += slop_delta;
  74     assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
  75     __ ld(R12_scratch2, offs, R11_scratch1);
  76     __ addi(R12_scratch2, R12_scratch2, 1);
  77     __ std(R12_scratch2, offs, R11_scratch1);
  78   }
  79 #endif
  80 
  81   assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1");
  82 
  83   const Register rcvr_klass = R11_scratch1;
  84   address npe_addr = __ pc(); // npe = null pointer exception
  85   // check if we must do an explicit check (implicit checks disabled, offset too large).
  86   __ null_check(R3, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL);
  87   // Get receiver klass.
  88   __ load_klass(rcvr_klass, R3);
  89 
  90 #ifndef PRODUCT
  91   if (DebugVtables) {
  92     Label L;
  93     // Check offset vs vtable length.
  94     const Register vtable_len = R12_scratch2;
  95     __ lwz(vtable_len, in_bytes(Klass::vtable_length_offset()), rcvr_klass);
  96     __ cmpwi(CCR0, vtable_len, vtable_index*vtableEntry::size());
  97     __ bge(CCR0, L);


 123 
 124   __ null_check(R19_method, in_bytes(Method::from_compiled_offset()), /*implicit only*/NULL);
 125   __ ld(R12_scratch2, in_bytes(Method::from_compiled_offset()), R19_method);
 126   __ mtctr(R12_scratch2);
 127   __ bctr();
 128 
 129   masm->flush();
 130   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 131 
 132   return s;
 133 }
 134 
 135 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
 136   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 137   const int stub_code_length = code_size_limit(false);
 138   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
 139   // Can be NULL if there is no free space in the code cache.
 140   if (s == NULL) {
 141     return NULL;
 142   }
 143 
 144   // Count unused bytes in instruction sequences of variable size.
 145   // We add them to the computed buffer size in order to avoid
 146   // overflow in subsequently generated stubs.
 147   address   start_pc;
 148   int       slop_bytes = 8; // just a two-instruction safety net
 149   int       slop_delta = 0;
 150 
 151   ResourceMark    rm;
 152   CodeBuffer      cb(s->entry_point(), stub_code_length);
 153   MacroAssembler* masm = new MacroAssembler(&cb);
 154   int             load_const_maxLen = 5*BytesPerInstWord;  // load_const generates 5 instructions. Assume that as max size for laod_const_optimized
 155 
 156 #if (!defined(PRODUCT) && defined(COMPILER2))
 157   if (CountCompiledCalls) {
 158     start_pc = __ pc();
 159     int offs = __ load_const_optimized(R11_scratch1, SharedRuntime::nof_megamorphic_calls_addr(), R12_scratch2, true);
 160     slop_delta  = load_const_maxLen - (__ pc() - start_pc);
 161     slop_bytes += slop_delta;
 162     assert(slop_delta >= 0, "negative slop(%d) encountered, adjust code size estimate!", slop_delta);
 163     __ ld(R12_scratch2, offs, R11_scratch1);
 164     __ addi(R12_scratch2, R12_scratch2, 1);
 165     __ std(R12_scratch2, offs, R11_scratch1);
 166   }
 167 #endif
 168 
 169   assert(VtableStub::receiver_location() == R3_ARG1->as_VMReg(), "receiver expected in R3_ARG1");
 170 
 171   // Entry arguments:
 172   //  R19_method: Interface
 173   //  R3_ARG1:    Receiver
 174 
 175   Label L_no_such_interface;
 176   const Register rcvr_klass = R11_scratch1,
 177                  interface  = R12_scratch2,
 178                  tmp1       = R21_tmp1,
 179                  tmp2       = R22_tmp2;
 180 
 181   address npe_addr = __ pc(); // npe = null pointer exception
 182   __ null_check(R3_ARG1, oopDesc::klass_offset_in_bytes(), /*implicit only*/NULL);
 183   __ load_klass(rcvr_klass, R3_ARG1);
 184 
 185   // Receiver subtype check against REFC.


< prev index next >