< prev index next >

src/hotspot/cpu/aarch64/vtableStubs_aarch64.cpp

Print this page


   1 /*
   2  * Copyright (c) 2003, 2020, Oracle and/or its affiliates. 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.
   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.


  53   VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
  54   // Can be NULL if there is no free space in the code cache.
  55   if (s == NULL) {
  56     return NULL;
  57   }
  58 
  59   // Count unused bytes in instruction sequences of variable size.
  60   // We add them to the computed buffer size in order to avoid
  61   // overflow in subsequently generated stubs.
  62   address   start_pc;
  63   int       slop_bytes = 0;
  64   int       slop_delta = 0;
  65 
  66   ResourceMark    rm;
  67   CodeBuffer      cb(s->entry_point(), stub_code_length);
  68   MacroAssembler* masm = new MacroAssembler(&cb);
  69 
  70 #if (!defined(PRODUCT) && defined(COMPILER2))
  71   if (CountCompiledCalls) {
  72     __ lea(r16, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
  73     __ incrementw(Address(r16));
  74   }
  75 #endif
  76 
  77   // get receiver (need to skip return address on top of stack)
  78   assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
  79 
  80   // get receiver klass
  81   address npe_addr = __ pc();
  82   __ load_klass(r16, j_rarg0);
  83 
  84 #ifndef PRODUCT
  85   if (DebugVtables) {
  86     Label L;
  87     // TODO: find upper bound for this debug code.
  88     start_pc = __ pc();
  89 
  90     // check offset vs vtable length
  91     __ ldrw(rscratch1, Address(r16, Klass::vtable_length_offset()));
  92     __ cmpw(rscratch1, vtable_index * vtableEntry::size());
  93     __ br(Assembler::GT, L);


 128   // r2: receiver
 129   address ame_addr = __ pc();
 130   __ ldr(rscratch1, Address(rmethod, Method::from_compiled_offset()));
 131   __ br(rscratch1);
 132 
 133   masm->flush();
 134   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 135 
 136   return s;
 137 }
 138 
 139 
 140 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
 141   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 142   const int stub_code_length = code_size_limit(false);
 143   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
 144   // Can be NULL if there is no free space in the code cache.
 145   if (s == NULL) {
 146     return NULL;
 147   }

 148   // Count unused bytes in instruction sequences of variable size.
 149   // We add them to the computed buffer size in order to avoid
 150   // overflow in subsequently generated stubs.
 151   address   start_pc;
 152   int       slop_bytes = 0;
 153   int       slop_delta = 0;
 154 
 155   ResourceMark    rm;
 156   CodeBuffer      cb(s->entry_point(), stub_code_length);
 157   MacroAssembler* masm = new MacroAssembler(&cb);
 158 
 159 #if (!defined(PRODUCT) && defined(COMPILER2))
 160   if (CountCompiledCalls) {
 161     __ lea(r10, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
 162     __ incrementw(Address(r10));
 163   }
 164 #endif
 165 
 166   // get receiver (need to skip return address on top of stack)
 167   assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
 168 
 169   // Entry arguments:
 170   //  rscratch2: CompiledICHolder
 171   //  j_rarg0: Receiver
 172 
 173   // This stub is called from compiled code which has no callee-saved registers,
 174   // so all registers except arguments are free at this point.
 175   const Register recv_klass_reg     = r10;
 176   const Register holder_klass_reg   = r16; // declaring interface klass (DECC)
 177   const Register resolved_klass_reg = rmethod; // resolved interface klass (REFC)
 178   const Register temp_reg           = r11;
 179   const Register temp_reg2          = r15;
 180   const Register icholder_reg       = rscratch2;
 181 
 182   Label L_no_such_interface;


   1 /*
   2  * Copyright (c) 2003, 2021, Oracle and/or its affiliates. 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.
   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.


  53   VtableStub* s = new(stub_code_length) VtableStub(true, vtable_index);
  54   // Can be NULL if there is no free space in the code cache.
  55   if (s == NULL) {
  56     return NULL;
  57   }
  58 
  59   // Count unused bytes in instruction sequences of variable size.
  60   // We add them to the computed buffer size in order to avoid
  61   // overflow in subsequently generated stubs.
  62   address   start_pc;
  63   int       slop_bytes = 0;
  64   int       slop_delta = 0;
  65 
  66   ResourceMark    rm;
  67   CodeBuffer      cb(s->entry_point(), stub_code_length);
  68   MacroAssembler* masm = new MacroAssembler(&cb);
  69 
  70 #if (!defined(PRODUCT) && defined(COMPILER2))
  71   if (CountCompiledCalls) {
  72     __ lea(r16, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
  73     __ increment(Address(r16));
  74   }
  75 #endif
  76 
  77   // get receiver (need to skip return address on top of stack)
  78   assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
  79 
  80   // get receiver klass
  81   address npe_addr = __ pc();
  82   __ load_klass(r16, j_rarg0);
  83 
  84 #ifndef PRODUCT
  85   if (DebugVtables) {
  86     Label L;
  87     // TODO: find upper bound for this debug code.
  88     start_pc = __ pc();
  89 
  90     // check offset vs vtable length
  91     __ ldrw(rscratch1, Address(r16, Klass::vtable_length_offset()));
  92     __ cmpw(rscratch1, vtable_index * vtableEntry::size());
  93     __ br(Assembler::GT, L);


 128   // r2: receiver
 129   address ame_addr = __ pc();
 130   __ ldr(rscratch1, Address(rmethod, Method::from_compiled_offset()));
 131   __ br(rscratch1);
 132 
 133   masm->flush();
 134   bookkeeping(masm, tty, s, npe_addr, ame_addr, true, vtable_index, slop_bytes, 0);
 135 
 136   return s;
 137 }
 138 
 139 
 140 VtableStub* VtableStubs::create_itable_stub(int itable_index) {
 141   // Read "A word on VtableStub sizing" in share/code/vtableStubs.hpp for details on stub sizing.
 142   const int stub_code_length = code_size_limit(false);
 143   VtableStub* s = new(stub_code_length) VtableStub(false, itable_index);
 144   // Can be NULL if there is no free space in the code cache.
 145   if (s == NULL) {
 146     return NULL;
 147   }
 148 
 149   // Count unused bytes in instruction sequences of variable size.
 150   // We add them to the computed buffer size in order to avoid
 151   // overflow in subsequently generated stubs.
 152   address   start_pc;
 153   int       slop_bytes = 0;
 154   int       slop_delta = 0;
 155 
 156   ResourceMark    rm;
 157   CodeBuffer      cb(s->entry_point(), stub_code_length);
 158   MacroAssembler* masm = new MacroAssembler(&cb);
 159 
 160 #if (!defined(PRODUCT) && defined(COMPILER2))
 161   if (CountCompiledCalls) {
 162     __ lea(r10, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr()));
 163     __ increment(Address(r10));
 164   }
 165 #endif
 166 
 167   // get receiver (need to skip return address on top of stack)
 168   assert(VtableStub::receiver_location() == j_rarg0->as_VMReg(), "receiver expected in j_rarg0");
 169 
 170   // Entry arguments:
 171   //  rscratch2: CompiledICHolder
 172   //  j_rarg0: Receiver
 173 
 174   // This stub is called from compiled code which has no callee-saved registers,
 175   // so all registers except arguments are free at this point.
 176   const Register recv_klass_reg     = r10;
 177   const Register holder_klass_reg   = r16; // declaring interface klass (DECC)
 178   const Register resolved_klass_reg = rmethod; // resolved interface klass (REFC)
 179   const Register temp_reg           = r11;
 180   const Register temp_reg2          = r15;
 181   const Register icholder_reg       = rscratch2;
 182 
 183   Label L_no_such_interface;


< prev index next >