src/cpu/sparc/vm/templateTable_sparc.cpp

Thu, 24 May 2018 17:06:56 +0800

author
aoqi
date
Thu, 24 May 2018 17:06:56 +0800
changeset 8604
04d83ba48607
parent 8368
32b682649973
parent 6876
710a3c8b516e
child 9041
95a08233f46c
permissions
-rw-r--r--

Merge

aoqi@0 1 /*
kevinw@8368 2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "interpreter/interpreter.hpp"
aoqi@0 27 #include "interpreter/interpreterRuntime.hpp"
aoqi@0 28 #include "interpreter/templateTable.hpp"
aoqi@0 29 #include "memory/universe.inline.hpp"
aoqi@0 30 #include "oops/methodData.hpp"
aoqi@0 31 #include "oops/objArrayKlass.hpp"
aoqi@0 32 #include "oops/oop.inline.hpp"
aoqi@0 33 #include "prims/methodHandles.hpp"
aoqi@0 34 #include "runtime/sharedRuntime.hpp"
aoqi@0 35 #include "runtime/stubRoutines.hpp"
aoqi@0 36 #include "runtime/synchronizer.hpp"
aoqi@0 37 #include "utilities/macros.hpp"
aoqi@0 38
aoqi@0 39 #ifndef CC_INTERP
aoqi@0 40 #define __ _masm->
aoqi@0 41
aoqi@0 42 // Misc helpers
aoqi@0 43
aoqi@0 44 // Do an oop store like *(base + index + offset) = val
aoqi@0 45 // index can be noreg,
aoqi@0 46 static void do_oop_store(InterpreterMacroAssembler* _masm,
aoqi@0 47 Register base,
aoqi@0 48 Register index,
aoqi@0 49 int offset,
aoqi@0 50 Register val,
aoqi@0 51 Register tmp,
aoqi@0 52 BarrierSet::Name barrier,
aoqi@0 53 bool precise) {
aoqi@0 54 assert(tmp != val && tmp != base && tmp != index, "register collision");
aoqi@0 55 assert(index == noreg || offset == 0, "only one offset");
aoqi@0 56 switch (barrier) {
aoqi@0 57 #if INCLUDE_ALL_GCS
aoqi@0 58 case BarrierSet::G1SATBCT:
aoqi@0 59 case BarrierSet::G1SATBCTLogging:
aoqi@0 60 {
aoqi@0 61 // Load and record the previous value.
aoqi@0 62 __ g1_write_barrier_pre(base, index, offset,
aoqi@0 63 noreg /* pre_val */,
aoqi@0 64 tmp, true /*preserve_o_regs*/);
aoqi@0 65
aoqi@0 66 // G1 barrier needs uncompressed oop for region cross check.
aoqi@0 67 Register new_val = val;
aoqi@0 68 if (UseCompressedOops && val != G0) {
aoqi@0 69 new_val = tmp;
aoqi@0 70 __ mov(val, new_val);
aoqi@0 71 }
aoqi@0 72
aoqi@0 73 if (index == noreg ) {
aoqi@0 74 assert(Assembler::is_simm13(offset), "fix this code");
aoqi@0 75 __ store_heap_oop(val, base, offset);
aoqi@0 76 } else {
aoqi@0 77 __ store_heap_oop(val, base, index);
aoqi@0 78 }
aoqi@0 79
aoqi@0 80 // No need for post barrier if storing NULL
aoqi@0 81 if (val != G0) {
aoqi@0 82 if (precise) {
aoqi@0 83 if (index == noreg) {
aoqi@0 84 __ add(base, offset, base);
aoqi@0 85 } else {
aoqi@0 86 __ add(base, index, base);
aoqi@0 87 }
aoqi@0 88 }
aoqi@0 89 __ g1_write_barrier_post(base, new_val, tmp);
aoqi@0 90 }
aoqi@0 91 }
aoqi@0 92 break;
aoqi@0 93 #endif // INCLUDE_ALL_GCS
aoqi@0 94 case BarrierSet::CardTableModRef:
aoqi@0 95 case BarrierSet::CardTableExtension:
aoqi@0 96 {
aoqi@0 97 if (index == noreg ) {
aoqi@0 98 assert(Assembler::is_simm13(offset), "fix this code");
aoqi@0 99 __ store_heap_oop(val, base, offset);
aoqi@0 100 } else {
aoqi@0 101 __ store_heap_oop(val, base, index);
aoqi@0 102 }
aoqi@0 103 // No need for post barrier if storing NULL
aoqi@0 104 if (val != G0) {
aoqi@0 105 if (precise) {
aoqi@0 106 if (index == noreg) {
aoqi@0 107 __ add(base, offset, base);
aoqi@0 108 } else {
aoqi@0 109 __ add(base, index, base);
aoqi@0 110 }
aoqi@0 111 }
aoqi@0 112 __ card_write_barrier_post(base, val, tmp);
aoqi@0 113 }
aoqi@0 114 }
aoqi@0 115 break;
aoqi@0 116 case BarrierSet::ModRef:
aoqi@0 117 case BarrierSet::Other:
aoqi@0 118 ShouldNotReachHere();
aoqi@0 119 break;
aoqi@0 120 default :
aoqi@0 121 ShouldNotReachHere();
aoqi@0 122
aoqi@0 123 }
aoqi@0 124 }
aoqi@0 125
aoqi@0 126
aoqi@0 127 //----------------------------------------------------------------------------------------------------
aoqi@0 128 // Platform-dependent initialization
aoqi@0 129
aoqi@0 130 void TemplateTable::pd_initialize() {
aoqi@0 131 // (none)
aoqi@0 132 }
aoqi@0 133
aoqi@0 134
aoqi@0 135 //----------------------------------------------------------------------------------------------------
aoqi@0 136 // Condition conversion
aoqi@0 137 Assembler::Condition ccNot(TemplateTable::Condition cc) {
aoqi@0 138 switch (cc) {
aoqi@0 139 case TemplateTable::equal : return Assembler::notEqual;
aoqi@0 140 case TemplateTable::not_equal : return Assembler::equal;
aoqi@0 141 case TemplateTable::less : return Assembler::greaterEqual;
aoqi@0 142 case TemplateTable::less_equal : return Assembler::greater;
aoqi@0 143 case TemplateTable::greater : return Assembler::lessEqual;
aoqi@0 144 case TemplateTable::greater_equal: return Assembler::less;
aoqi@0 145 }
aoqi@0 146 ShouldNotReachHere();
aoqi@0 147 return Assembler::zero;
aoqi@0 148 }
aoqi@0 149
aoqi@0 150 //----------------------------------------------------------------------------------------------------
aoqi@0 151 // Miscelaneous helper routines
aoqi@0 152
aoqi@0 153
aoqi@0 154 Address TemplateTable::at_bcp(int offset) {
aoqi@0 155 assert(_desc->uses_bcp(), "inconsistent uses_bcp information");
aoqi@0 156 return Address(Lbcp, offset);
aoqi@0 157 }
aoqi@0 158
aoqi@0 159
aoqi@0 160 void TemplateTable::patch_bytecode(Bytecodes::Code bc, Register bc_reg,
aoqi@0 161 Register temp_reg, bool load_bc_into_bc_reg/*=true*/,
aoqi@0 162 int byte_no) {
aoqi@0 163 // With sharing on, may need to test Method* flag.
aoqi@0 164 if (!RewriteBytecodes) return;
aoqi@0 165 Label L_patch_done;
aoqi@0 166
aoqi@0 167 switch (bc) {
aoqi@0 168 case Bytecodes::_fast_aputfield:
aoqi@0 169 case Bytecodes::_fast_bputfield:
kevinw@8368 170 case Bytecodes::_fast_zputfield:
aoqi@0 171 case Bytecodes::_fast_cputfield:
aoqi@0 172 case Bytecodes::_fast_dputfield:
aoqi@0 173 case Bytecodes::_fast_fputfield:
aoqi@0 174 case Bytecodes::_fast_iputfield:
aoqi@0 175 case Bytecodes::_fast_lputfield:
aoqi@0 176 case Bytecodes::_fast_sputfield:
aoqi@0 177 {
aoqi@0 178 // We skip bytecode quickening for putfield instructions when
aoqi@0 179 // the put_code written to the constant pool cache is zero.
aoqi@0 180 // This is required so that every execution of this instruction
aoqi@0 181 // calls out to InterpreterRuntime::resolve_get_put to do
aoqi@0 182 // additional, required work.
aoqi@0 183 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
aoqi@0 184 assert(load_bc_into_bc_reg, "we use bc_reg as temp");
aoqi@0 185 __ get_cache_and_index_and_bytecode_at_bcp(bc_reg, temp_reg, temp_reg, byte_no, 1);
aoqi@0 186 __ set(bc, bc_reg);
aoqi@0 187 __ cmp_and_br_short(temp_reg, 0, Assembler::equal, Assembler::pn, L_patch_done); // don't patch
aoqi@0 188 }
aoqi@0 189 break;
aoqi@0 190 default:
aoqi@0 191 assert(byte_no == -1, "sanity");
aoqi@0 192 if (load_bc_into_bc_reg) {
aoqi@0 193 __ set(bc, bc_reg);
aoqi@0 194 }
aoqi@0 195 }
aoqi@0 196
aoqi@0 197 if (JvmtiExport::can_post_breakpoint()) {
aoqi@0 198 Label L_fast_patch;
aoqi@0 199 __ ldub(at_bcp(0), temp_reg);
aoqi@0 200 __ cmp_and_br_short(temp_reg, Bytecodes::_breakpoint, Assembler::notEqual, Assembler::pt, L_fast_patch);
aoqi@0 201 // perform the quickening, slowly, in the bowels of the breakpoint table
aoqi@0 202 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), Lmethod, Lbcp, bc_reg);
aoqi@0 203 __ ba_short(L_patch_done);
aoqi@0 204 __ bind(L_fast_patch);
aoqi@0 205 }
aoqi@0 206
aoqi@0 207 #ifdef ASSERT
aoqi@0 208 Bytecodes::Code orig_bytecode = Bytecodes::java_code(bc);
aoqi@0 209 Label L_okay;
aoqi@0 210 __ ldub(at_bcp(0), temp_reg);
aoqi@0 211 __ cmp(temp_reg, orig_bytecode);
aoqi@0 212 __ br(Assembler::equal, false, Assembler::pt, L_okay);
aoqi@0 213 __ delayed()->cmp(temp_reg, bc_reg);
aoqi@0 214 __ br(Assembler::equal, false, Assembler::pt, L_okay);
aoqi@0 215 __ delayed()->nop();
aoqi@0 216 __ stop("patching the wrong bytecode");
aoqi@0 217 __ bind(L_okay);
aoqi@0 218 #endif
aoqi@0 219
aoqi@0 220 // patch bytecode
aoqi@0 221 __ stb(bc_reg, at_bcp(0));
aoqi@0 222 __ bind(L_patch_done);
aoqi@0 223 }
aoqi@0 224
aoqi@0 225 //----------------------------------------------------------------------------------------------------
aoqi@0 226 // Individual instructions
aoqi@0 227
aoqi@0 228 void TemplateTable::nop() {
aoqi@0 229 transition(vtos, vtos);
aoqi@0 230 // nothing to do
aoqi@0 231 }
aoqi@0 232
aoqi@0 233 void TemplateTable::shouldnotreachhere() {
aoqi@0 234 transition(vtos, vtos);
aoqi@0 235 __ stop("shouldnotreachhere bytecode");
aoqi@0 236 }
aoqi@0 237
aoqi@0 238 void TemplateTable::aconst_null() {
aoqi@0 239 transition(vtos, atos);
aoqi@0 240 __ clr(Otos_i);
aoqi@0 241 }
aoqi@0 242
aoqi@0 243
aoqi@0 244 void TemplateTable::iconst(int value) {
aoqi@0 245 transition(vtos, itos);
aoqi@0 246 __ set(value, Otos_i);
aoqi@0 247 }
aoqi@0 248
aoqi@0 249
aoqi@0 250 void TemplateTable::lconst(int value) {
aoqi@0 251 transition(vtos, ltos);
aoqi@0 252 assert(value >= 0, "check this code");
aoqi@0 253 #ifdef _LP64
aoqi@0 254 __ set(value, Otos_l);
aoqi@0 255 #else
aoqi@0 256 __ set(value, Otos_l2);
aoqi@0 257 __ clr( Otos_l1);
aoqi@0 258 #endif
aoqi@0 259 }
aoqi@0 260
aoqi@0 261
aoqi@0 262 void TemplateTable::fconst(int value) {
aoqi@0 263 transition(vtos, ftos);
aoqi@0 264 static float zero = 0.0, one = 1.0, two = 2.0;
aoqi@0 265 float* p;
aoqi@0 266 switch( value ) {
aoqi@0 267 default: ShouldNotReachHere();
aoqi@0 268 case 0: p = &zero; break;
aoqi@0 269 case 1: p = &one; break;
aoqi@0 270 case 2: p = &two; break;
aoqi@0 271 }
aoqi@0 272 AddressLiteral a(p);
aoqi@0 273 __ sethi(a, G3_scratch);
aoqi@0 274 __ ldf(FloatRegisterImpl::S, G3_scratch, a.low10(), Ftos_f);
aoqi@0 275 }
aoqi@0 276
aoqi@0 277
aoqi@0 278 void TemplateTable::dconst(int value) {
aoqi@0 279 transition(vtos, dtos);
aoqi@0 280 static double zero = 0.0, one = 1.0;
aoqi@0 281 double* p;
aoqi@0 282 switch( value ) {
aoqi@0 283 default: ShouldNotReachHere();
aoqi@0 284 case 0: p = &zero; break;
aoqi@0 285 case 1: p = &one; break;
aoqi@0 286 }
aoqi@0 287 AddressLiteral a(p);
aoqi@0 288 __ sethi(a, G3_scratch);
aoqi@0 289 __ ldf(FloatRegisterImpl::D, G3_scratch, a.low10(), Ftos_d);
aoqi@0 290 }
aoqi@0 291
aoqi@0 292
aoqi@0 293 // %%%%% Should factore most snippet templates across platforms
aoqi@0 294
aoqi@0 295 void TemplateTable::bipush() {
aoqi@0 296 transition(vtos, itos);
aoqi@0 297 __ ldsb( at_bcp(1), Otos_i );
aoqi@0 298 }
aoqi@0 299
aoqi@0 300 void TemplateTable::sipush() {
aoqi@0 301 transition(vtos, itos);
aoqi@0 302 __ get_2_byte_integer_at_bcp(1, G3_scratch, Otos_i, InterpreterMacroAssembler::Signed);
aoqi@0 303 }
aoqi@0 304
aoqi@0 305 void TemplateTable::ldc(bool wide) {
aoqi@0 306 transition(vtos, vtos);
aoqi@0 307 Label call_ldc, notInt, isString, notString, notClass, exit;
aoqi@0 308
aoqi@0 309 if (wide) {
aoqi@0 310 __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned);
aoqi@0 311 } else {
aoqi@0 312 __ ldub(Lbcp, 1, O1);
aoqi@0 313 }
aoqi@0 314 __ get_cpool_and_tags(O0, O2);
aoqi@0 315
aoqi@0 316 const int base_offset = ConstantPool::header_size() * wordSize;
aoqi@0 317 const int tags_offset = Array<u1>::base_offset_in_bytes();
aoqi@0 318
aoqi@0 319 // get type from tags
aoqi@0 320 __ add(O2, tags_offset, O2);
aoqi@0 321 __ ldub(O2, O1, O2);
aoqi@0 322
aoqi@0 323 // unresolved class? If so, must resolve
aoqi@0 324 __ cmp_and_brx_short(O2, JVM_CONSTANT_UnresolvedClass, Assembler::equal, Assembler::pt, call_ldc);
aoqi@0 325
aoqi@0 326 // unresolved class in error state
aoqi@0 327 __ cmp_and_brx_short(O2, JVM_CONSTANT_UnresolvedClassInError, Assembler::equal, Assembler::pn, call_ldc);
aoqi@0 328
aoqi@0 329 __ cmp(O2, JVM_CONSTANT_Class); // need to call vm to get java mirror of the class
aoqi@0 330 __ brx(Assembler::notEqual, true, Assembler::pt, notClass);
aoqi@0 331 __ delayed()->add(O0, base_offset, O0);
aoqi@0 332
aoqi@0 333 __ bind(call_ldc);
aoqi@0 334 __ set(wide, O1);
aoqi@0 335 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), O1);
aoqi@0 336 __ push(atos);
aoqi@0 337 __ ba_short(exit);
aoqi@0 338
aoqi@0 339 __ bind(notClass);
aoqi@0 340 // __ add(O0, base_offset, O0);
aoqi@0 341 __ sll(O1, LogBytesPerWord, O1);
aoqi@0 342 __ cmp(O2, JVM_CONSTANT_Integer);
aoqi@0 343 __ brx(Assembler::notEqual, true, Assembler::pt, notInt);
aoqi@0 344 __ delayed()->cmp(O2, JVM_CONSTANT_String);
aoqi@0 345 __ ld(O0, O1, Otos_i);
aoqi@0 346 __ push(itos);
aoqi@0 347 __ ba_short(exit);
aoqi@0 348
aoqi@0 349 __ bind(notInt);
aoqi@0 350 // __ cmp(O2, JVM_CONSTANT_String);
aoqi@0 351 __ brx(Assembler::notEqual, true, Assembler::pt, notString);
aoqi@0 352 __ delayed()->ldf(FloatRegisterImpl::S, O0, O1, Ftos_f);
aoqi@0 353 __ bind(isString);
aoqi@0 354 __ stop("string should be rewritten to fast_aldc");
aoqi@0 355 __ ba_short(exit);
aoqi@0 356
aoqi@0 357 __ bind(notString);
aoqi@0 358 // __ ldf(FloatRegisterImpl::S, O0, O1, Ftos_f);
aoqi@0 359 __ push(ftos);
aoqi@0 360
aoqi@0 361 __ bind(exit);
aoqi@0 362 }
aoqi@0 363
aoqi@0 364 // Fast path for caching oop constants.
aoqi@0 365 // %%% We should use this to handle Class and String constants also.
aoqi@0 366 // %%% It will simplify the ldc/primitive path considerably.
aoqi@0 367 void TemplateTable::fast_aldc(bool wide) {
aoqi@0 368 transition(vtos, atos);
aoqi@0 369
aoqi@0 370 int index_size = wide ? sizeof(u2) : sizeof(u1);
aoqi@0 371 Label resolved;
aoqi@0 372
aoqi@0 373 // We are resolved if the resolved reference cache entry contains a
aoqi@0 374 // non-null object (CallSite, etc.)
aoqi@0 375 assert_different_registers(Otos_i, G3_scratch);
aoqi@0 376 __ get_cache_index_at_bcp(Otos_i, G3_scratch, 1, index_size); // load index => G3_scratch
aoqi@0 377 __ load_resolved_reference_at_index(Otos_i, G3_scratch);
aoqi@0 378 __ tst(Otos_i);
aoqi@0 379 __ br(Assembler::notEqual, false, Assembler::pt, resolved);
aoqi@0 380 __ delayed()->set((int)bytecode(), O1);
aoqi@0 381
aoqi@0 382 address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
aoqi@0 383
aoqi@0 384 // first time invocation - must resolve first
aoqi@0 385 __ call_VM(Otos_i, entry, O1);
aoqi@0 386 __ bind(resolved);
aoqi@0 387 __ verify_oop(Otos_i);
aoqi@0 388 }
aoqi@0 389
aoqi@0 390
aoqi@0 391 void TemplateTable::ldc2_w() {
aoqi@0 392 transition(vtos, vtos);
aoqi@0 393 Label Long, exit;
aoqi@0 394
aoqi@0 395 __ get_2_byte_integer_at_bcp(1, G3_scratch, O1, InterpreterMacroAssembler::Unsigned);
aoqi@0 396 __ get_cpool_and_tags(O0, O2);
aoqi@0 397
aoqi@0 398 const int base_offset = ConstantPool::header_size() * wordSize;
aoqi@0 399 const int tags_offset = Array<u1>::base_offset_in_bytes();
aoqi@0 400 // get type from tags
aoqi@0 401 __ add(O2, tags_offset, O2);
aoqi@0 402 __ ldub(O2, O1, O2);
aoqi@0 403
aoqi@0 404 __ sll(O1, LogBytesPerWord, O1);
aoqi@0 405 __ add(O0, O1, G3_scratch);
aoqi@0 406
aoqi@0 407 __ cmp_and_brx_short(O2, JVM_CONSTANT_Double, Assembler::notEqual, Assembler::pt, Long);
aoqi@0 408 // A double can be placed at word-aligned locations in the constant pool.
aoqi@0 409 // Check out Conversions.java for an example.
aoqi@0 410 // Also ConstantPool::header_size() is 20, which makes it very difficult
aoqi@0 411 // to double-align double on the constant pool. SG, 11/7/97
aoqi@0 412 #ifdef _LP64
aoqi@0 413 __ ldf(FloatRegisterImpl::D, G3_scratch, base_offset, Ftos_d);
aoqi@0 414 #else
aoqi@0 415 FloatRegister f = Ftos_d;
aoqi@0 416 __ ldf(FloatRegisterImpl::S, G3_scratch, base_offset, f);
aoqi@0 417 __ ldf(FloatRegisterImpl::S, G3_scratch, base_offset + sizeof(jdouble)/2,
aoqi@0 418 f->successor());
aoqi@0 419 #endif
aoqi@0 420 __ push(dtos);
aoqi@0 421 __ ba_short(exit);
aoqi@0 422
aoqi@0 423 __ bind(Long);
aoqi@0 424 #ifdef _LP64
aoqi@0 425 __ ldx(G3_scratch, base_offset, Otos_l);
aoqi@0 426 #else
aoqi@0 427 __ ld(G3_scratch, base_offset, Otos_l);
aoqi@0 428 __ ld(G3_scratch, base_offset + sizeof(jlong)/2, Otos_l->successor());
aoqi@0 429 #endif
aoqi@0 430 __ push(ltos);
aoqi@0 431
aoqi@0 432 __ bind(exit);
aoqi@0 433 }
aoqi@0 434
aoqi@0 435
aoqi@0 436 void TemplateTable::locals_index(Register reg, int offset) {
aoqi@0 437 __ ldub( at_bcp(offset), reg );
aoqi@0 438 }
aoqi@0 439
aoqi@0 440
aoqi@0 441 void TemplateTable::locals_index_wide(Register reg) {
aoqi@0 442 // offset is 2, not 1, because Lbcp points to wide prefix code
aoqi@0 443 __ get_2_byte_integer_at_bcp(2, G4_scratch, reg, InterpreterMacroAssembler::Unsigned);
aoqi@0 444 }
aoqi@0 445
aoqi@0 446 void TemplateTable::iload() {
aoqi@0 447 transition(vtos, itos);
aoqi@0 448 // Rewrite iload,iload pair into fast_iload2
aoqi@0 449 // iload,caload pair into fast_icaload
aoqi@0 450 if (RewriteFrequentPairs) {
aoqi@0 451 Label rewrite, done;
aoqi@0 452
aoqi@0 453 // get next byte
aoqi@0 454 __ ldub(at_bcp(Bytecodes::length_for(Bytecodes::_iload)), G3_scratch);
aoqi@0 455
aoqi@0 456 // if _iload, wait to rewrite to iload2. We only want to rewrite the
aoqi@0 457 // last two iloads in a pair. Comparing against fast_iload means that
aoqi@0 458 // the next bytecode is neither an iload or a caload, and therefore
aoqi@0 459 // an iload pair.
aoqi@0 460 __ cmp_and_br_short(G3_scratch, (int)Bytecodes::_iload, Assembler::equal, Assembler::pn, done);
aoqi@0 461
aoqi@0 462 __ cmp(G3_scratch, (int)Bytecodes::_fast_iload);
aoqi@0 463 __ br(Assembler::equal, false, Assembler::pn, rewrite);
aoqi@0 464 __ delayed()->set(Bytecodes::_fast_iload2, G4_scratch);
aoqi@0 465
aoqi@0 466 __ cmp(G3_scratch, (int)Bytecodes::_caload);
aoqi@0 467 __ br(Assembler::equal, false, Assembler::pn, rewrite);
aoqi@0 468 __ delayed()->set(Bytecodes::_fast_icaload, G4_scratch);
aoqi@0 469
aoqi@0 470 __ set(Bytecodes::_fast_iload, G4_scratch); // don't check again
aoqi@0 471 // rewrite
aoqi@0 472 // G4_scratch: fast bytecode
aoqi@0 473 __ bind(rewrite);
aoqi@0 474 patch_bytecode(Bytecodes::_iload, G4_scratch, G3_scratch, false);
aoqi@0 475 __ bind(done);
aoqi@0 476 }
aoqi@0 477
aoqi@0 478 // Get the local value into tos
aoqi@0 479 locals_index(G3_scratch);
aoqi@0 480 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 481 }
aoqi@0 482
aoqi@0 483 void TemplateTable::fast_iload2() {
aoqi@0 484 transition(vtos, itos);
aoqi@0 485 locals_index(G3_scratch);
aoqi@0 486 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 487 __ push_i();
aoqi@0 488 locals_index(G3_scratch, 3); // get next bytecode's local index.
aoqi@0 489 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 490 }
aoqi@0 491
aoqi@0 492 void TemplateTable::fast_iload() {
aoqi@0 493 transition(vtos, itos);
aoqi@0 494 locals_index(G3_scratch);
aoqi@0 495 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 496 }
aoqi@0 497
aoqi@0 498 void TemplateTable::lload() {
aoqi@0 499 transition(vtos, ltos);
aoqi@0 500 locals_index(G3_scratch);
aoqi@0 501 __ access_local_long( G3_scratch, Otos_l );
aoqi@0 502 }
aoqi@0 503
aoqi@0 504
aoqi@0 505 void TemplateTable::fload() {
aoqi@0 506 transition(vtos, ftos);
aoqi@0 507 locals_index(G3_scratch);
aoqi@0 508 __ access_local_float( G3_scratch, Ftos_f );
aoqi@0 509 }
aoqi@0 510
aoqi@0 511
aoqi@0 512 void TemplateTable::dload() {
aoqi@0 513 transition(vtos, dtos);
aoqi@0 514 locals_index(G3_scratch);
aoqi@0 515 __ access_local_double( G3_scratch, Ftos_d );
aoqi@0 516 }
aoqi@0 517
aoqi@0 518
aoqi@0 519 void TemplateTable::aload() {
aoqi@0 520 transition(vtos, atos);
aoqi@0 521 locals_index(G3_scratch);
aoqi@0 522 __ access_local_ptr( G3_scratch, Otos_i);
aoqi@0 523 }
aoqi@0 524
aoqi@0 525
aoqi@0 526 void TemplateTable::wide_iload() {
aoqi@0 527 transition(vtos, itos);
aoqi@0 528 locals_index_wide(G3_scratch);
aoqi@0 529 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 530 }
aoqi@0 531
aoqi@0 532
aoqi@0 533 void TemplateTable::wide_lload() {
aoqi@0 534 transition(vtos, ltos);
aoqi@0 535 locals_index_wide(G3_scratch);
aoqi@0 536 __ access_local_long( G3_scratch, Otos_l );
aoqi@0 537 }
aoqi@0 538
aoqi@0 539
aoqi@0 540 void TemplateTable::wide_fload() {
aoqi@0 541 transition(vtos, ftos);
aoqi@0 542 locals_index_wide(G3_scratch);
aoqi@0 543 __ access_local_float( G3_scratch, Ftos_f );
aoqi@0 544 }
aoqi@0 545
aoqi@0 546
aoqi@0 547 void TemplateTable::wide_dload() {
aoqi@0 548 transition(vtos, dtos);
aoqi@0 549 locals_index_wide(G3_scratch);
aoqi@0 550 __ access_local_double( G3_scratch, Ftos_d );
aoqi@0 551 }
aoqi@0 552
aoqi@0 553
aoqi@0 554 void TemplateTable::wide_aload() {
aoqi@0 555 transition(vtos, atos);
aoqi@0 556 locals_index_wide(G3_scratch);
aoqi@0 557 __ access_local_ptr( G3_scratch, Otos_i );
aoqi@0 558 __ verify_oop(Otos_i);
aoqi@0 559 }
aoqi@0 560
aoqi@0 561
aoqi@0 562 void TemplateTable::iaload() {
aoqi@0 563 transition(itos, itos);
aoqi@0 564 // Otos_i: index
aoqi@0 565 // tos: array
aoqi@0 566 __ index_check(O2, Otos_i, LogBytesPerInt, G3_scratch, O3);
aoqi@0 567 __ ld(O3, arrayOopDesc::base_offset_in_bytes(T_INT), Otos_i);
aoqi@0 568 }
aoqi@0 569
aoqi@0 570
aoqi@0 571 void TemplateTable::laload() {
aoqi@0 572 transition(itos, ltos);
aoqi@0 573 // Otos_i: index
aoqi@0 574 // O2: array
aoqi@0 575 __ index_check(O2, Otos_i, LogBytesPerLong, G3_scratch, O3);
aoqi@0 576 __ ld_long(O3, arrayOopDesc::base_offset_in_bytes(T_LONG), Otos_l);
aoqi@0 577 }
aoqi@0 578
aoqi@0 579
aoqi@0 580 void TemplateTable::faload() {
aoqi@0 581 transition(itos, ftos);
aoqi@0 582 // Otos_i: index
aoqi@0 583 // O2: array
aoqi@0 584 __ index_check(O2, Otos_i, LogBytesPerInt, G3_scratch, O3);
aoqi@0 585 __ ldf(FloatRegisterImpl::S, O3, arrayOopDesc::base_offset_in_bytes(T_FLOAT), Ftos_f);
aoqi@0 586 }
aoqi@0 587
aoqi@0 588
aoqi@0 589 void TemplateTable::daload() {
aoqi@0 590 transition(itos, dtos);
aoqi@0 591 // Otos_i: index
aoqi@0 592 // O2: array
aoqi@0 593 __ index_check(O2, Otos_i, LogBytesPerLong, G3_scratch, O3);
aoqi@0 594 __ ldf(FloatRegisterImpl::D, O3, arrayOopDesc::base_offset_in_bytes(T_DOUBLE), Ftos_d);
aoqi@0 595 }
aoqi@0 596
aoqi@0 597
aoqi@0 598 void TemplateTable::aaload() {
aoqi@0 599 transition(itos, atos);
aoqi@0 600 // Otos_i: index
aoqi@0 601 // tos: array
aoqi@0 602 __ index_check(O2, Otos_i, UseCompressedOops ? 2 : LogBytesPerWord, G3_scratch, O3);
aoqi@0 603 __ load_heap_oop(O3, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Otos_i);
aoqi@0 604 __ verify_oop(Otos_i);
aoqi@0 605 }
aoqi@0 606
aoqi@0 607
aoqi@0 608 void TemplateTable::baload() {
aoqi@0 609 transition(itos, itos);
aoqi@0 610 // Otos_i: index
aoqi@0 611 // tos: array
aoqi@0 612 __ index_check(O2, Otos_i, 0, G3_scratch, O3);
aoqi@0 613 __ ldsb(O3, arrayOopDesc::base_offset_in_bytes(T_BYTE), Otos_i);
aoqi@0 614 }
aoqi@0 615
aoqi@0 616
aoqi@0 617 void TemplateTable::caload() {
aoqi@0 618 transition(itos, itos);
aoqi@0 619 // Otos_i: index
aoqi@0 620 // tos: array
aoqi@0 621 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3);
aoqi@0 622 __ lduh(O3, arrayOopDesc::base_offset_in_bytes(T_CHAR), Otos_i);
aoqi@0 623 }
aoqi@0 624
aoqi@0 625 void TemplateTable::fast_icaload() {
aoqi@0 626 transition(vtos, itos);
aoqi@0 627 // Otos_i: index
aoqi@0 628 // tos: array
aoqi@0 629 locals_index(G3_scratch);
aoqi@0 630 __ access_local_int( G3_scratch, Otos_i );
aoqi@0 631 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3);
aoqi@0 632 __ lduh(O3, arrayOopDesc::base_offset_in_bytes(T_CHAR), Otos_i);
aoqi@0 633 }
aoqi@0 634
aoqi@0 635
aoqi@0 636 void TemplateTable::saload() {
aoqi@0 637 transition(itos, itos);
aoqi@0 638 // Otos_i: index
aoqi@0 639 // tos: array
aoqi@0 640 __ index_check(O2, Otos_i, LogBytesPerShort, G3_scratch, O3);
aoqi@0 641 __ ldsh(O3, arrayOopDesc::base_offset_in_bytes(T_SHORT), Otos_i);
aoqi@0 642 }
aoqi@0 643
aoqi@0 644
aoqi@0 645 void TemplateTable::iload(int n) {
aoqi@0 646 transition(vtos, itos);
aoqi@0 647 __ ld( Llocals, Interpreter::local_offset_in_bytes(n), Otos_i );
aoqi@0 648 }
aoqi@0 649
aoqi@0 650
aoqi@0 651 void TemplateTable::lload(int n) {
aoqi@0 652 transition(vtos, ltos);
aoqi@0 653 assert(n+1 < Argument::n_register_parameters, "would need more code");
aoqi@0 654 __ load_unaligned_long(Llocals, Interpreter::local_offset_in_bytes(n+1), Otos_l);
aoqi@0 655 }
aoqi@0 656
aoqi@0 657
aoqi@0 658 void TemplateTable::fload(int n) {
aoqi@0 659 transition(vtos, ftos);
aoqi@0 660 assert(n < Argument::n_register_parameters, "would need more code");
aoqi@0 661 __ ldf( FloatRegisterImpl::S, Llocals, Interpreter::local_offset_in_bytes(n), Ftos_f );
aoqi@0 662 }
aoqi@0 663
aoqi@0 664
aoqi@0 665 void TemplateTable::dload(int n) {
aoqi@0 666 transition(vtos, dtos);
aoqi@0 667 FloatRegister dst = Ftos_d;
aoqi@0 668 __ load_unaligned_double(Llocals, Interpreter::local_offset_in_bytes(n+1), dst);
aoqi@0 669 }
aoqi@0 670
aoqi@0 671
aoqi@0 672 void TemplateTable::aload(int n) {
aoqi@0 673 transition(vtos, atos);
aoqi@0 674 __ ld_ptr( Llocals, Interpreter::local_offset_in_bytes(n), Otos_i );
aoqi@0 675 }
aoqi@0 676
aoqi@0 677
aoqi@0 678 void TemplateTable::aload_0() {
aoqi@0 679 transition(vtos, atos);
aoqi@0 680
aoqi@0 681 // According to bytecode histograms, the pairs:
aoqi@0 682 //
aoqi@0 683 // _aload_0, _fast_igetfield (itos)
aoqi@0 684 // _aload_0, _fast_agetfield (atos)
aoqi@0 685 // _aload_0, _fast_fgetfield (ftos)
aoqi@0 686 //
aoqi@0 687 // occur frequently. If RewriteFrequentPairs is set, the (slow) _aload_0
aoqi@0 688 // bytecode checks the next bytecode and then rewrites the current
aoqi@0 689 // bytecode into a pair bytecode; otherwise it rewrites the current
aoqi@0 690 // bytecode into _fast_aload_0 that doesn't do the pair check anymore.
aoqi@0 691 //
aoqi@0 692 if (RewriteFrequentPairs) {
aoqi@0 693 Label rewrite, done;
aoqi@0 694
aoqi@0 695 // get next byte
aoqi@0 696 __ ldub(at_bcp(Bytecodes::length_for(Bytecodes::_aload_0)), G3_scratch);
aoqi@0 697
aoqi@0 698 // do actual aload_0
aoqi@0 699 aload(0);
aoqi@0 700
aoqi@0 701 // if _getfield then wait with rewrite
aoqi@0 702 __ cmp_and_br_short(G3_scratch, (int)Bytecodes::_getfield, Assembler::equal, Assembler::pn, done);
aoqi@0 703
aoqi@0 704 // if _igetfield then rewrite to _fast_iaccess_0
aoqi@0 705 assert(Bytecodes::java_code(Bytecodes::_fast_iaccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def");
aoqi@0 706 __ cmp(G3_scratch, (int)Bytecodes::_fast_igetfield);
aoqi@0 707 __ br(Assembler::equal, false, Assembler::pn, rewrite);
aoqi@0 708 __ delayed()->set(Bytecodes::_fast_iaccess_0, G4_scratch);
aoqi@0 709
aoqi@0 710 // if _agetfield then rewrite to _fast_aaccess_0
aoqi@0 711 assert(Bytecodes::java_code(Bytecodes::_fast_aaccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def");
aoqi@0 712 __ cmp(G3_scratch, (int)Bytecodes::_fast_agetfield);
aoqi@0 713 __ br(Assembler::equal, false, Assembler::pn, rewrite);
aoqi@0 714 __ delayed()->set(Bytecodes::_fast_aaccess_0, G4_scratch);
aoqi@0 715
aoqi@0 716 // if _fgetfield then rewrite to _fast_faccess_0
aoqi@0 717 assert(Bytecodes::java_code(Bytecodes::_fast_faccess_0) == Bytecodes::_aload_0, "adjust fast bytecode def");
aoqi@0 718 __ cmp(G3_scratch, (int)Bytecodes::_fast_fgetfield);
aoqi@0 719 __ br(Assembler::equal, false, Assembler::pn, rewrite);
aoqi@0 720 __ delayed()->set(Bytecodes::_fast_faccess_0, G4_scratch);
aoqi@0 721
aoqi@0 722 // else rewrite to _fast_aload0
aoqi@0 723 assert(Bytecodes::java_code(Bytecodes::_fast_aload_0) == Bytecodes::_aload_0, "adjust fast bytecode def");
aoqi@0 724 __ set(Bytecodes::_fast_aload_0, G4_scratch);
aoqi@0 725
aoqi@0 726 // rewrite
aoqi@0 727 // G4_scratch: fast bytecode
aoqi@0 728 __ bind(rewrite);
aoqi@0 729 patch_bytecode(Bytecodes::_aload_0, G4_scratch, G3_scratch, false);
aoqi@0 730 __ bind(done);
aoqi@0 731 } else {
aoqi@0 732 aload(0);
aoqi@0 733 }
aoqi@0 734 }
aoqi@0 735
aoqi@0 736
aoqi@0 737 void TemplateTable::istore() {
aoqi@0 738 transition(itos, vtos);
aoqi@0 739 locals_index(G3_scratch);
aoqi@0 740 __ store_local_int( G3_scratch, Otos_i );
aoqi@0 741 }
aoqi@0 742
aoqi@0 743
aoqi@0 744 void TemplateTable::lstore() {
aoqi@0 745 transition(ltos, vtos);
aoqi@0 746 locals_index(G3_scratch);
aoqi@0 747 __ store_local_long( G3_scratch, Otos_l );
aoqi@0 748 }
aoqi@0 749
aoqi@0 750
aoqi@0 751 void TemplateTable::fstore() {
aoqi@0 752 transition(ftos, vtos);
aoqi@0 753 locals_index(G3_scratch);
aoqi@0 754 __ store_local_float( G3_scratch, Ftos_f );
aoqi@0 755 }
aoqi@0 756
aoqi@0 757
aoqi@0 758 void TemplateTable::dstore() {
aoqi@0 759 transition(dtos, vtos);
aoqi@0 760 locals_index(G3_scratch);
aoqi@0 761 __ store_local_double( G3_scratch, Ftos_d );
aoqi@0 762 }
aoqi@0 763
aoqi@0 764
aoqi@0 765 void TemplateTable::astore() {
aoqi@0 766 transition(vtos, vtos);
aoqi@0 767 __ load_ptr(0, Otos_i);
aoqi@0 768 __ inc(Lesp, Interpreter::stackElementSize);
aoqi@0 769 __ verify_oop_or_return_address(Otos_i, G3_scratch);
aoqi@0 770 locals_index(G3_scratch);
aoqi@0 771 __ store_local_ptr(G3_scratch, Otos_i);
aoqi@0 772 }
aoqi@0 773
aoqi@0 774
aoqi@0 775 void TemplateTable::wide_istore() {
aoqi@0 776 transition(vtos, vtos);
aoqi@0 777 __ pop_i();
aoqi@0 778 locals_index_wide(G3_scratch);
aoqi@0 779 __ store_local_int( G3_scratch, Otos_i );
aoqi@0 780 }
aoqi@0 781
aoqi@0 782
aoqi@0 783 void TemplateTable::wide_lstore() {
aoqi@0 784 transition(vtos, vtos);
aoqi@0 785 __ pop_l();
aoqi@0 786 locals_index_wide(G3_scratch);
aoqi@0 787 __ store_local_long( G3_scratch, Otos_l );
aoqi@0 788 }
aoqi@0 789
aoqi@0 790
aoqi@0 791 void TemplateTable::wide_fstore() {
aoqi@0 792 transition(vtos, vtos);
aoqi@0 793 __ pop_f();
aoqi@0 794 locals_index_wide(G3_scratch);
aoqi@0 795 __ store_local_float( G3_scratch, Ftos_f );
aoqi@0 796 }
aoqi@0 797
aoqi@0 798
aoqi@0 799 void TemplateTable::wide_dstore() {
aoqi@0 800 transition(vtos, vtos);
aoqi@0 801 __ pop_d();
aoqi@0 802 locals_index_wide(G3_scratch);
aoqi@0 803 __ store_local_double( G3_scratch, Ftos_d );
aoqi@0 804 }
aoqi@0 805
aoqi@0 806
aoqi@0 807 void TemplateTable::wide_astore() {
aoqi@0 808 transition(vtos, vtos);
aoqi@0 809 __ load_ptr(0, Otos_i);
aoqi@0 810 __ inc(Lesp, Interpreter::stackElementSize);
aoqi@0 811 __ verify_oop_or_return_address(Otos_i, G3_scratch);
aoqi@0 812 locals_index_wide(G3_scratch);
aoqi@0 813 __ store_local_ptr(G3_scratch, Otos_i);
aoqi@0 814 }
aoqi@0 815
aoqi@0 816
aoqi@0 817 void TemplateTable::iastore() {
aoqi@0 818 transition(itos, vtos);
aoqi@0 819 __ pop_i(O2); // index
aoqi@0 820 // Otos_i: val
aoqi@0 821 // O3: array
aoqi@0 822 __ index_check(O3, O2, LogBytesPerInt, G3_scratch, O2);
aoqi@0 823 __ st(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_INT));
aoqi@0 824 }
aoqi@0 825
aoqi@0 826
aoqi@0 827 void TemplateTable::lastore() {
aoqi@0 828 transition(ltos, vtos);
aoqi@0 829 __ pop_i(O2); // index
aoqi@0 830 // Otos_l: val
aoqi@0 831 // O3: array
aoqi@0 832 __ index_check(O3, O2, LogBytesPerLong, G3_scratch, O2);
aoqi@0 833 __ st_long(Otos_l, O2, arrayOopDesc::base_offset_in_bytes(T_LONG));
aoqi@0 834 }
aoqi@0 835
aoqi@0 836
aoqi@0 837 void TemplateTable::fastore() {
aoqi@0 838 transition(ftos, vtos);
aoqi@0 839 __ pop_i(O2); // index
aoqi@0 840 // Ftos_f: val
aoqi@0 841 // O3: array
aoqi@0 842 __ index_check(O3, O2, LogBytesPerInt, G3_scratch, O2);
aoqi@0 843 __ stf(FloatRegisterImpl::S, Ftos_f, O2, arrayOopDesc::base_offset_in_bytes(T_FLOAT));
aoqi@0 844 }
aoqi@0 845
aoqi@0 846
aoqi@0 847 void TemplateTable::dastore() {
aoqi@0 848 transition(dtos, vtos);
aoqi@0 849 __ pop_i(O2); // index
aoqi@0 850 // Fos_d: val
aoqi@0 851 // O3: array
aoqi@0 852 __ index_check(O3, O2, LogBytesPerLong, G3_scratch, O2);
aoqi@0 853 __ stf(FloatRegisterImpl::D, Ftos_d, O2, arrayOopDesc::base_offset_in_bytes(T_DOUBLE));
aoqi@0 854 }
aoqi@0 855
aoqi@0 856
aoqi@0 857 void TemplateTable::aastore() {
aoqi@0 858 Label store_ok, is_null, done;
aoqi@0 859 transition(vtos, vtos);
aoqi@0 860 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(0), Otos_i);
aoqi@0 861 __ ld(Lesp, Interpreter::expr_offset_in_bytes(1), O2); // get index
aoqi@0 862 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(2), O3); // get array
aoqi@0 863 // Otos_i: val
aoqi@0 864 // O2: index
aoqi@0 865 // O3: array
aoqi@0 866 __ verify_oop(Otos_i);
aoqi@0 867 __ index_check_without_pop(O3, O2, UseCompressedOops ? 2 : LogBytesPerWord, G3_scratch, O1);
aoqi@0 868
aoqi@0 869 // do array store check - check for NULL value first
aoqi@0 870 __ br_null_short( Otos_i, Assembler::pn, is_null );
aoqi@0 871
aoqi@0 872 __ load_klass(O3, O4); // get array klass
aoqi@0 873 __ load_klass(Otos_i, O5); // get value klass
aoqi@0 874
aoqi@0 875 // do fast instanceof cache test
aoqi@0 876
aoqi@0 877 __ ld_ptr(O4, in_bytes(ObjArrayKlass::element_klass_offset()), O4);
aoqi@0 878
aoqi@0 879 assert(Otos_i == O0, "just checking");
aoqi@0 880
aoqi@0 881 // Otos_i: value
aoqi@0 882 // O1: addr - offset
aoqi@0 883 // O2: index
aoqi@0 884 // O3: array
aoqi@0 885 // O4: array element klass
aoqi@0 886 // O5: value klass
aoqi@0 887
aoqi@0 888 // Address element(O1, 0, arrayOopDesc::base_offset_in_bytes(T_OBJECT));
aoqi@0 889
aoqi@0 890 // Generate a fast subtype check. Branch to store_ok if no
aoqi@0 891 // failure. Throw if failure.
aoqi@0 892 __ gen_subtype_check( O5, O4, G3_scratch, G4_scratch, G1_scratch, store_ok );
aoqi@0 893
aoqi@0 894 // Not a subtype; so must throw exception
aoqi@0 895 __ throw_if_not_x( Assembler::never, Interpreter::_throw_ArrayStoreException_entry, G3_scratch );
aoqi@0 896
aoqi@0 897 // Store is OK.
aoqi@0 898 __ bind(store_ok);
aoqi@0 899 do_oop_store(_masm, O1, noreg, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Otos_i, G3_scratch, _bs->kind(), true);
aoqi@0 900
aoqi@0 901 __ ba(done);
aoqi@0 902 __ delayed()->inc(Lesp, 3* Interpreter::stackElementSize); // adj sp (pops array, index and value)
aoqi@0 903
aoqi@0 904 __ bind(is_null);
aoqi@0 905 do_oop_store(_masm, O1, noreg, arrayOopDesc::base_offset_in_bytes(T_OBJECT), G0, G4_scratch, _bs->kind(), true);
aoqi@0 906
aoqi@0 907 __ profile_null_seen(G3_scratch);
aoqi@0 908 __ inc(Lesp, 3* Interpreter::stackElementSize); // adj sp (pops array, index and value)
aoqi@0 909 __ bind(done);
aoqi@0 910 }
aoqi@0 911
aoqi@0 912
aoqi@0 913 void TemplateTable::bastore() {
aoqi@0 914 transition(itos, vtos);
aoqi@0 915 __ pop_i(O2); // index
aoqi@0 916 // Otos_i: val
kevinw@8368 917 // O2: index
aoqi@0 918 // O3: array
aoqi@0 919 __ index_check(O3, O2, 0, G3_scratch, O2);
kevinw@8368 920 // Need to check whether array is boolean or byte
kevinw@8368 921 // since both types share the bastore bytecode.
kevinw@8368 922 __ load_klass(O3, G4_scratch);
kevinw@8368 923 __ ld(G4_scratch, in_bytes(Klass::layout_helper_offset()), G4_scratch);
kevinw@8368 924 __ set(Klass::layout_helper_boolean_diffbit(), G3_scratch);
kevinw@8368 925 __ andcc(G3_scratch, G4_scratch, G0);
kevinw@8368 926 Label L_skip;
kevinw@8368 927 __ br(Assembler::zero, false, Assembler::pn, L_skip);
kevinw@8368 928 __ delayed()->nop();
kevinw@8368 929 __ and3(Otos_i, 1, Otos_i); // if it is a T_BOOLEAN array, mask the stored value to 0/1
kevinw@8368 930 __ bind(L_skip);
aoqi@0 931 __ stb(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_BYTE));
aoqi@0 932 }
aoqi@0 933
aoqi@0 934
aoqi@0 935 void TemplateTable::castore() {
aoqi@0 936 transition(itos, vtos);
aoqi@0 937 __ pop_i(O2); // index
aoqi@0 938 // Otos_i: val
aoqi@0 939 // O3: array
aoqi@0 940 __ index_check(O3, O2, LogBytesPerShort, G3_scratch, O2);
aoqi@0 941 __ sth(Otos_i, O2, arrayOopDesc::base_offset_in_bytes(T_CHAR));
aoqi@0 942 }
aoqi@0 943
aoqi@0 944
aoqi@0 945 void TemplateTable::sastore() {
aoqi@0 946 // %%%%% Factor across platform
aoqi@0 947 castore();
aoqi@0 948 }
aoqi@0 949
aoqi@0 950
aoqi@0 951 void TemplateTable::istore(int n) {
aoqi@0 952 transition(itos, vtos);
aoqi@0 953 __ st(Otos_i, Llocals, Interpreter::local_offset_in_bytes(n));
aoqi@0 954 }
aoqi@0 955
aoqi@0 956
aoqi@0 957 void TemplateTable::lstore(int n) {
aoqi@0 958 transition(ltos, vtos);
aoqi@0 959 assert(n+1 < Argument::n_register_parameters, "only handle register cases");
aoqi@0 960 __ store_unaligned_long(Otos_l, Llocals, Interpreter::local_offset_in_bytes(n+1));
aoqi@0 961
aoqi@0 962 }
aoqi@0 963
aoqi@0 964
aoqi@0 965 void TemplateTable::fstore(int n) {
aoqi@0 966 transition(ftos, vtos);
aoqi@0 967 assert(n < Argument::n_register_parameters, "only handle register cases");
aoqi@0 968 __ stf(FloatRegisterImpl::S, Ftos_f, Llocals, Interpreter::local_offset_in_bytes(n));
aoqi@0 969 }
aoqi@0 970
aoqi@0 971
aoqi@0 972 void TemplateTable::dstore(int n) {
aoqi@0 973 transition(dtos, vtos);
aoqi@0 974 FloatRegister src = Ftos_d;
aoqi@0 975 __ store_unaligned_double(src, Llocals, Interpreter::local_offset_in_bytes(n+1));
aoqi@0 976 }
aoqi@0 977
aoqi@0 978
aoqi@0 979 void TemplateTable::astore(int n) {
aoqi@0 980 transition(vtos, vtos);
aoqi@0 981 __ load_ptr(0, Otos_i);
aoqi@0 982 __ inc(Lesp, Interpreter::stackElementSize);
aoqi@0 983 __ verify_oop_or_return_address(Otos_i, G3_scratch);
aoqi@0 984 __ store_local_ptr(n, Otos_i);
aoqi@0 985 }
aoqi@0 986
aoqi@0 987
aoqi@0 988 void TemplateTable::pop() {
aoqi@0 989 transition(vtos, vtos);
aoqi@0 990 __ inc(Lesp, Interpreter::stackElementSize);
aoqi@0 991 }
aoqi@0 992
aoqi@0 993
aoqi@0 994 void TemplateTable::pop2() {
aoqi@0 995 transition(vtos, vtos);
aoqi@0 996 __ inc(Lesp, 2 * Interpreter::stackElementSize);
aoqi@0 997 }
aoqi@0 998
aoqi@0 999
aoqi@0 1000 void TemplateTable::dup() {
aoqi@0 1001 transition(vtos, vtos);
aoqi@0 1002 // stack: ..., a
aoqi@0 1003 // load a and tag
aoqi@0 1004 __ load_ptr(0, Otos_i);
aoqi@0 1005 __ push_ptr(Otos_i);
aoqi@0 1006 // stack: ..., a, a
aoqi@0 1007 }
aoqi@0 1008
aoqi@0 1009
aoqi@0 1010 void TemplateTable::dup_x1() {
aoqi@0 1011 transition(vtos, vtos);
aoqi@0 1012 // stack: ..., a, b
aoqi@0 1013 __ load_ptr( 1, G3_scratch); // get a
aoqi@0 1014 __ load_ptr( 0, Otos_l1); // get b
aoqi@0 1015 __ store_ptr(1, Otos_l1); // put b
aoqi@0 1016 __ store_ptr(0, G3_scratch); // put a - like swap
aoqi@0 1017 __ push_ptr(Otos_l1); // push b
aoqi@0 1018 // stack: ..., b, a, b
aoqi@0 1019 }
aoqi@0 1020
aoqi@0 1021
aoqi@0 1022 void TemplateTable::dup_x2() {
aoqi@0 1023 transition(vtos, vtos);
aoqi@0 1024 // stack: ..., a, b, c
aoqi@0 1025 // get c and push on stack, reuse registers
aoqi@0 1026 __ load_ptr( 0, G3_scratch); // get c
aoqi@0 1027 __ push_ptr(G3_scratch); // push c with tag
aoqi@0 1028 // stack: ..., a, b, c, c (c in reg) (Lesp - 4)
aoqi@0 1029 // (stack offsets n+1 now)
aoqi@0 1030 __ load_ptr( 3, Otos_l1); // get a
aoqi@0 1031 __ store_ptr(3, G3_scratch); // put c at 3
aoqi@0 1032 // stack: ..., c, b, c, c (a in reg)
aoqi@0 1033 __ load_ptr( 2, G3_scratch); // get b
aoqi@0 1034 __ store_ptr(2, Otos_l1); // put a at 2
aoqi@0 1035 // stack: ..., c, a, c, c (b in reg)
aoqi@0 1036 __ store_ptr(1, G3_scratch); // put b at 1
aoqi@0 1037 // stack: ..., c, a, b, c
aoqi@0 1038 }
aoqi@0 1039
aoqi@0 1040
aoqi@0 1041 void TemplateTable::dup2() {
aoqi@0 1042 transition(vtos, vtos);
aoqi@0 1043 __ load_ptr(1, G3_scratch); // get a
aoqi@0 1044 __ load_ptr(0, Otos_l1); // get b
aoqi@0 1045 __ push_ptr(G3_scratch); // push a
aoqi@0 1046 __ push_ptr(Otos_l1); // push b
aoqi@0 1047 // stack: ..., a, b, a, b
aoqi@0 1048 }
aoqi@0 1049
aoqi@0 1050
aoqi@0 1051 void TemplateTable::dup2_x1() {
aoqi@0 1052 transition(vtos, vtos);
aoqi@0 1053 // stack: ..., a, b, c
aoqi@0 1054 __ load_ptr( 1, Lscratch); // get b
aoqi@0 1055 __ load_ptr( 2, Otos_l1); // get a
aoqi@0 1056 __ store_ptr(2, Lscratch); // put b at a
aoqi@0 1057 // stack: ..., b, b, c
aoqi@0 1058 __ load_ptr( 0, G3_scratch); // get c
aoqi@0 1059 __ store_ptr(1, G3_scratch); // put c at b
aoqi@0 1060 // stack: ..., b, c, c
aoqi@0 1061 __ store_ptr(0, Otos_l1); // put a at c
aoqi@0 1062 // stack: ..., b, c, a
aoqi@0 1063 __ push_ptr(Lscratch); // push b
aoqi@0 1064 __ push_ptr(G3_scratch); // push c
aoqi@0 1065 // stack: ..., b, c, a, b, c
aoqi@0 1066 }
aoqi@0 1067
aoqi@0 1068
aoqi@0 1069 // The spec says that these types can be a mixture of category 1 (1 word)
aoqi@0 1070 // types and/or category 2 types (long and doubles)
aoqi@0 1071 void TemplateTable::dup2_x2() {
aoqi@0 1072 transition(vtos, vtos);
aoqi@0 1073 // stack: ..., a, b, c, d
aoqi@0 1074 __ load_ptr( 1, Lscratch); // get c
aoqi@0 1075 __ load_ptr( 3, Otos_l1); // get a
aoqi@0 1076 __ store_ptr(3, Lscratch); // put c at 3
aoqi@0 1077 __ store_ptr(1, Otos_l1); // put a at 1
aoqi@0 1078 // stack: ..., c, b, a, d
aoqi@0 1079 __ load_ptr( 2, G3_scratch); // get b
aoqi@0 1080 __ load_ptr( 0, Otos_l1); // get d
aoqi@0 1081 __ store_ptr(0, G3_scratch); // put b at 0
aoqi@0 1082 __ store_ptr(2, Otos_l1); // put d at 2
aoqi@0 1083 // stack: ..., c, d, a, b
aoqi@0 1084 __ push_ptr(Lscratch); // push c
aoqi@0 1085 __ push_ptr(Otos_l1); // push d
aoqi@0 1086 // stack: ..., c, d, a, b, c, d
aoqi@0 1087 }
aoqi@0 1088
aoqi@0 1089
aoqi@0 1090 void TemplateTable::swap() {
aoqi@0 1091 transition(vtos, vtos);
aoqi@0 1092 // stack: ..., a, b
aoqi@0 1093 __ load_ptr( 1, G3_scratch); // get a
aoqi@0 1094 __ load_ptr( 0, Otos_l1); // get b
aoqi@0 1095 __ store_ptr(0, G3_scratch); // put b
aoqi@0 1096 __ store_ptr(1, Otos_l1); // put a
aoqi@0 1097 // stack: ..., b, a
aoqi@0 1098 }
aoqi@0 1099
aoqi@0 1100
aoqi@0 1101 void TemplateTable::iop2(Operation op) {
aoqi@0 1102 transition(itos, itos);
aoqi@0 1103 __ pop_i(O1);
aoqi@0 1104 switch (op) {
aoqi@0 1105 case add: __ add(O1, Otos_i, Otos_i); break;
aoqi@0 1106 case sub: __ sub(O1, Otos_i, Otos_i); break;
aoqi@0 1107 // %%%%% Mul may not exist: better to call .mul?
aoqi@0 1108 case mul: __ smul(O1, Otos_i, Otos_i); break;
aoqi@0 1109 case _and: __ and3(O1, Otos_i, Otos_i); break;
aoqi@0 1110 case _or: __ or3(O1, Otos_i, Otos_i); break;
aoqi@0 1111 case _xor: __ xor3(O1, Otos_i, Otos_i); break;
aoqi@0 1112 case shl: __ sll(O1, Otos_i, Otos_i); break;
aoqi@0 1113 case shr: __ sra(O1, Otos_i, Otos_i); break;
aoqi@0 1114 case ushr: __ srl(O1, Otos_i, Otos_i); break;
aoqi@0 1115 default: ShouldNotReachHere();
aoqi@0 1116 }
aoqi@0 1117 }
aoqi@0 1118
aoqi@0 1119
aoqi@0 1120 void TemplateTable::lop2(Operation op) {
aoqi@0 1121 transition(ltos, ltos);
aoqi@0 1122 __ pop_l(O2);
aoqi@0 1123 switch (op) {
aoqi@0 1124 #ifdef _LP64
aoqi@0 1125 case add: __ add(O2, Otos_l, Otos_l); break;
aoqi@0 1126 case sub: __ sub(O2, Otos_l, Otos_l); break;
aoqi@0 1127 case _and: __ and3(O2, Otos_l, Otos_l); break;
aoqi@0 1128 case _or: __ or3(O2, Otos_l, Otos_l); break;
aoqi@0 1129 case _xor: __ xor3(O2, Otos_l, Otos_l); break;
aoqi@0 1130 #else
aoqi@0 1131 case add: __ addcc(O3, Otos_l2, Otos_l2); __ addc(O2, Otos_l1, Otos_l1); break;
aoqi@0 1132 case sub: __ subcc(O3, Otos_l2, Otos_l2); __ subc(O2, Otos_l1, Otos_l1); break;
aoqi@0 1133 case _and: __ and3(O3, Otos_l2, Otos_l2); __ and3(O2, Otos_l1, Otos_l1); break;
aoqi@0 1134 case _or: __ or3(O3, Otos_l2, Otos_l2); __ or3(O2, Otos_l1, Otos_l1); break;
aoqi@0 1135 case _xor: __ xor3(O3, Otos_l2, Otos_l2); __ xor3(O2, Otos_l1, Otos_l1); break;
aoqi@0 1136 #endif
aoqi@0 1137 default: ShouldNotReachHere();
aoqi@0 1138 }
aoqi@0 1139 }
aoqi@0 1140
aoqi@0 1141
aoqi@0 1142 void TemplateTable::idiv() {
aoqi@0 1143 // %%%%% Later: ForSPARC/V7 call .sdiv library routine,
aoqi@0 1144 // %%%%% Use ldsw...sdivx on pure V9 ABI. 64 bit safe.
aoqi@0 1145
aoqi@0 1146 transition(itos, itos);
aoqi@0 1147 __ pop_i(O1); // get 1st op
aoqi@0 1148
aoqi@0 1149 // Y contains upper 32 bits of result, set it to 0 or all ones
aoqi@0 1150 __ wry(G0);
aoqi@0 1151 __ mov(~0, G3_scratch);
aoqi@0 1152
aoqi@0 1153 __ tst(O1);
aoqi@0 1154 Label neg;
aoqi@0 1155 __ br(Assembler::negative, true, Assembler::pn, neg);
aoqi@0 1156 __ delayed()->wry(G3_scratch);
aoqi@0 1157 __ bind(neg);
aoqi@0 1158
aoqi@0 1159 Label ok;
aoqi@0 1160 __ tst(Otos_i);
aoqi@0 1161 __ throw_if_not_icc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch );
aoqi@0 1162
aoqi@0 1163 const int min_int = 0x80000000;
aoqi@0 1164 Label regular;
aoqi@0 1165 __ cmp(Otos_i, -1);
aoqi@0 1166 __ br(Assembler::notEqual, false, Assembler::pt, regular);
aoqi@0 1167 #ifdef _LP64
aoqi@0 1168 // Don't put set in delay slot
aoqi@0 1169 // Set will turn into multiple instructions in 64 bit mode
aoqi@0 1170 __ delayed()->nop();
aoqi@0 1171 __ set(min_int, G4_scratch);
aoqi@0 1172 #else
aoqi@0 1173 __ delayed()->set(min_int, G4_scratch);
aoqi@0 1174 #endif
aoqi@0 1175 Label done;
aoqi@0 1176 __ cmp(O1, G4_scratch);
aoqi@0 1177 __ br(Assembler::equal, true, Assembler::pt, done);
aoqi@0 1178 __ delayed()->mov(O1, Otos_i); // (mov only executed if branch taken)
aoqi@0 1179
aoqi@0 1180 __ bind(regular);
aoqi@0 1181 __ sdiv(O1, Otos_i, Otos_i); // note: irem uses O1 after this instruction!
aoqi@0 1182 __ bind(done);
aoqi@0 1183 }
aoqi@0 1184
aoqi@0 1185
aoqi@0 1186 void TemplateTable::irem() {
aoqi@0 1187 transition(itos, itos);
aoqi@0 1188 __ mov(Otos_i, O2); // save divisor
aoqi@0 1189 idiv(); // %%%% Hack: exploits fact that idiv leaves dividend in O1
aoqi@0 1190 __ smul(Otos_i, O2, Otos_i);
aoqi@0 1191 __ sub(O1, Otos_i, Otos_i);
aoqi@0 1192 }
aoqi@0 1193
aoqi@0 1194
aoqi@0 1195 void TemplateTable::lmul() {
aoqi@0 1196 transition(ltos, ltos);
aoqi@0 1197 __ pop_l(O2);
aoqi@0 1198 #ifdef _LP64
aoqi@0 1199 __ mulx(Otos_l, O2, Otos_l);
aoqi@0 1200 #else
aoqi@0 1201 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::lmul));
aoqi@0 1202 #endif
aoqi@0 1203
aoqi@0 1204 }
aoqi@0 1205
aoqi@0 1206
aoqi@0 1207 void TemplateTable::ldiv() {
aoqi@0 1208 transition(ltos, ltos);
aoqi@0 1209
aoqi@0 1210 // check for zero
aoqi@0 1211 __ pop_l(O2);
aoqi@0 1212 #ifdef _LP64
aoqi@0 1213 __ tst(Otos_l);
aoqi@0 1214 __ throw_if_not_xcc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch);
aoqi@0 1215 __ sdivx(O2, Otos_l, Otos_l);
aoqi@0 1216 #else
aoqi@0 1217 __ orcc(Otos_l1, Otos_l2, G0);
aoqi@0 1218 __ throw_if_not_icc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch);
aoqi@0 1219 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::ldiv));
aoqi@0 1220 #endif
aoqi@0 1221 }
aoqi@0 1222
aoqi@0 1223
aoqi@0 1224 void TemplateTable::lrem() {
aoqi@0 1225 transition(ltos, ltos);
aoqi@0 1226
aoqi@0 1227 // check for zero
aoqi@0 1228 __ pop_l(O2);
aoqi@0 1229 #ifdef _LP64
aoqi@0 1230 __ tst(Otos_l);
aoqi@0 1231 __ throw_if_not_xcc( Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch);
aoqi@0 1232 __ sdivx(O2, Otos_l, Otos_l2);
aoqi@0 1233 __ mulx (Otos_l2, Otos_l, Otos_l2);
aoqi@0 1234 __ sub (O2, Otos_l2, Otos_l);
aoqi@0 1235 #else
aoqi@0 1236 __ orcc(Otos_l1, Otos_l2, G0);
aoqi@0 1237 __ throw_if_not_icc(Assembler::notZero, Interpreter::_throw_ArithmeticException_entry, G3_scratch);
aoqi@0 1238 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::lrem));
aoqi@0 1239 #endif
aoqi@0 1240 }
aoqi@0 1241
aoqi@0 1242
aoqi@0 1243 void TemplateTable::lshl() {
aoqi@0 1244 transition(itos, ltos); // %%%% could optimize, fill delay slot or opt for ultra
aoqi@0 1245
aoqi@0 1246 __ pop_l(O2); // shift value in O2, O3
aoqi@0 1247 #ifdef _LP64
aoqi@0 1248 __ sllx(O2, Otos_i, Otos_l);
aoqi@0 1249 #else
aoqi@0 1250 __ lshl(O2, O3, Otos_i, Otos_l1, Otos_l2, O4);
aoqi@0 1251 #endif
aoqi@0 1252 }
aoqi@0 1253
aoqi@0 1254
aoqi@0 1255 void TemplateTable::lshr() {
aoqi@0 1256 transition(itos, ltos); // %%%% see lshl comment
aoqi@0 1257
aoqi@0 1258 __ pop_l(O2); // shift value in O2, O3
aoqi@0 1259 #ifdef _LP64
aoqi@0 1260 __ srax(O2, Otos_i, Otos_l);
aoqi@0 1261 #else
aoqi@0 1262 __ lshr(O2, O3, Otos_i, Otos_l1, Otos_l2, O4);
aoqi@0 1263 #endif
aoqi@0 1264 }
aoqi@0 1265
aoqi@0 1266
aoqi@0 1267
aoqi@0 1268 void TemplateTable::lushr() {
aoqi@0 1269 transition(itos, ltos); // %%%% see lshl comment
aoqi@0 1270
aoqi@0 1271 __ pop_l(O2); // shift value in O2, O3
aoqi@0 1272 #ifdef _LP64
aoqi@0 1273 __ srlx(O2, Otos_i, Otos_l);
aoqi@0 1274 #else
aoqi@0 1275 __ lushr(O2, O3, Otos_i, Otos_l1, Otos_l2, O4);
aoqi@0 1276 #endif
aoqi@0 1277 }
aoqi@0 1278
aoqi@0 1279
aoqi@0 1280 void TemplateTable::fop2(Operation op) {
aoqi@0 1281 transition(ftos, ftos);
aoqi@0 1282 switch (op) {
aoqi@0 1283 case add: __ pop_f(F4); __ fadd(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break;
aoqi@0 1284 case sub: __ pop_f(F4); __ fsub(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break;
aoqi@0 1285 case mul: __ pop_f(F4); __ fmul(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break;
aoqi@0 1286 case div: __ pop_f(F4); __ fdiv(FloatRegisterImpl::S, F4, Ftos_f, Ftos_f); break;
aoqi@0 1287 case rem:
aoqi@0 1288 assert(Ftos_f == F0, "just checking");
aoqi@0 1289 #ifdef _LP64
aoqi@0 1290 // LP64 calling conventions use F1, F3 for passing 2 floats
aoqi@0 1291 __ pop_f(F1);
aoqi@0 1292 __ fmov(FloatRegisterImpl::S, Ftos_f, F3);
aoqi@0 1293 #else
aoqi@0 1294 __ pop_i(O0);
aoqi@0 1295 __ stf(FloatRegisterImpl::S, Ftos_f, __ d_tmp);
aoqi@0 1296 __ ld( __ d_tmp, O1 );
aoqi@0 1297 #endif
aoqi@0 1298 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::frem));
aoqi@0 1299 assert( Ftos_f == F0, "fix this code" );
aoqi@0 1300 break;
aoqi@0 1301
aoqi@0 1302 default: ShouldNotReachHere();
aoqi@0 1303 }
aoqi@0 1304 }
aoqi@0 1305
aoqi@0 1306
aoqi@0 1307 void TemplateTable::dop2(Operation op) {
aoqi@0 1308 transition(dtos, dtos);
aoqi@0 1309 switch (op) {
aoqi@0 1310 case add: __ pop_d(F4); __ fadd(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break;
aoqi@0 1311 case sub: __ pop_d(F4); __ fsub(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break;
aoqi@0 1312 case mul: __ pop_d(F4); __ fmul(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break;
aoqi@0 1313 case div: __ pop_d(F4); __ fdiv(FloatRegisterImpl::D, F4, Ftos_d, Ftos_d); break;
aoqi@0 1314 case rem:
aoqi@0 1315 #ifdef _LP64
aoqi@0 1316 // Pass arguments in D0, D2
aoqi@0 1317 __ fmov(FloatRegisterImpl::D, Ftos_f, F2 );
aoqi@0 1318 __ pop_d( F0 );
aoqi@0 1319 #else
aoqi@0 1320 // Pass arguments in O0O1, O2O3
aoqi@0 1321 __ stf(FloatRegisterImpl::D, Ftos_f, __ d_tmp);
aoqi@0 1322 __ ldd( __ d_tmp, O2 );
aoqi@0 1323 __ pop_d(Ftos_f);
aoqi@0 1324 __ stf(FloatRegisterImpl::D, Ftos_f, __ d_tmp);
aoqi@0 1325 __ ldd( __ d_tmp, O0 );
aoqi@0 1326 #endif
aoqi@0 1327 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::drem));
aoqi@0 1328 assert( Ftos_d == F0, "fix this code" );
aoqi@0 1329 break;
aoqi@0 1330
aoqi@0 1331 default: ShouldNotReachHere();
aoqi@0 1332 }
aoqi@0 1333 }
aoqi@0 1334
aoqi@0 1335
aoqi@0 1336 void TemplateTable::ineg() {
aoqi@0 1337 transition(itos, itos);
aoqi@0 1338 __ neg(Otos_i);
aoqi@0 1339 }
aoqi@0 1340
aoqi@0 1341
aoqi@0 1342 void TemplateTable::lneg() {
aoqi@0 1343 transition(ltos, ltos);
aoqi@0 1344 #ifdef _LP64
aoqi@0 1345 __ sub(G0, Otos_l, Otos_l);
aoqi@0 1346 #else
aoqi@0 1347 __ lneg(Otos_l1, Otos_l2);
aoqi@0 1348 #endif
aoqi@0 1349 }
aoqi@0 1350
aoqi@0 1351
aoqi@0 1352 void TemplateTable::fneg() {
aoqi@0 1353 transition(ftos, ftos);
aoqi@0 1354 __ fneg(FloatRegisterImpl::S, Ftos_f, Ftos_f);
aoqi@0 1355 }
aoqi@0 1356
aoqi@0 1357
aoqi@0 1358 void TemplateTable::dneg() {
aoqi@0 1359 transition(dtos, dtos);
aoqi@0 1360 __ fneg(FloatRegisterImpl::D, Ftos_f, Ftos_f);
aoqi@0 1361 }
aoqi@0 1362
aoqi@0 1363
aoqi@0 1364 void TemplateTable::iinc() {
aoqi@0 1365 transition(vtos, vtos);
aoqi@0 1366 locals_index(G3_scratch);
aoqi@0 1367 __ ldsb(Lbcp, 2, O2); // load constant
aoqi@0 1368 __ access_local_int(G3_scratch, Otos_i);
aoqi@0 1369 __ add(Otos_i, O2, Otos_i);
aoqi@0 1370 __ st(Otos_i, G3_scratch, 0); // access_local_int puts E.A. in G3_scratch
aoqi@0 1371 }
aoqi@0 1372
aoqi@0 1373
aoqi@0 1374 void TemplateTable::wide_iinc() {
aoqi@0 1375 transition(vtos, vtos);
aoqi@0 1376 locals_index_wide(G3_scratch);
aoqi@0 1377 __ get_2_byte_integer_at_bcp( 4, O2, O3, InterpreterMacroAssembler::Signed);
aoqi@0 1378 __ access_local_int(G3_scratch, Otos_i);
aoqi@0 1379 __ add(Otos_i, O3, Otos_i);
aoqi@0 1380 __ st(Otos_i, G3_scratch, 0); // access_local_int puts E.A. in G3_scratch
aoqi@0 1381 }
aoqi@0 1382
aoqi@0 1383
aoqi@0 1384 void TemplateTable::convert() {
aoqi@0 1385 // %%%%% Factor this first part accross platforms
aoqi@0 1386 #ifdef ASSERT
aoqi@0 1387 TosState tos_in = ilgl;
aoqi@0 1388 TosState tos_out = ilgl;
aoqi@0 1389 switch (bytecode()) {
aoqi@0 1390 case Bytecodes::_i2l: // fall through
aoqi@0 1391 case Bytecodes::_i2f: // fall through
aoqi@0 1392 case Bytecodes::_i2d: // fall through
aoqi@0 1393 case Bytecodes::_i2b: // fall through
aoqi@0 1394 case Bytecodes::_i2c: // fall through
aoqi@0 1395 case Bytecodes::_i2s: tos_in = itos; break;
aoqi@0 1396 case Bytecodes::_l2i: // fall through
aoqi@0 1397 case Bytecodes::_l2f: // fall through
aoqi@0 1398 case Bytecodes::_l2d: tos_in = ltos; break;
aoqi@0 1399 case Bytecodes::_f2i: // fall through
aoqi@0 1400 case Bytecodes::_f2l: // fall through
aoqi@0 1401 case Bytecodes::_f2d: tos_in = ftos; break;
aoqi@0 1402 case Bytecodes::_d2i: // fall through
aoqi@0 1403 case Bytecodes::_d2l: // fall through
aoqi@0 1404 case Bytecodes::_d2f: tos_in = dtos; break;
aoqi@0 1405 default : ShouldNotReachHere();
aoqi@0 1406 }
aoqi@0 1407 switch (bytecode()) {
aoqi@0 1408 case Bytecodes::_l2i: // fall through
aoqi@0 1409 case Bytecodes::_f2i: // fall through
aoqi@0 1410 case Bytecodes::_d2i: // fall through
aoqi@0 1411 case Bytecodes::_i2b: // fall through
aoqi@0 1412 case Bytecodes::_i2c: // fall through
aoqi@0 1413 case Bytecodes::_i2s: tos_out = itos; break;
aoqi@0 1414 case Bytecodes::_i2l: // fall through
aoqi@0 1415 case Bytecodes::_f2l: // fall through
aoqi@0 1416 case Bytecodes::_d2l: tos_out = ltos; break;
aoqi@0 1417 case Bytecodes::_i2f: // fall through
aoqi@0 1418 case Bytecodes::_l2f: // fall through
aoqi@0 1419 case Bytecodes::_d2f: tos_out = ftos; break;
aoqi@0 1420 case Bytecodes::_i2d: // fall through
aoqi@0 1421 case Bytecodes::_l2d: // fall through
aoqi@0 1422 case Bytecodes::_f2d: tos_out = dtos; break;
aoqi@0 1423 default : ShouldNotReachHere();
aoqi@0 1424 }
aoqi@0 1425 transition(tos_in, tos_out);
aoqi@0 1426 #endif
aoqi@0 1427
aoqi@0 1428
aoqi@0 1429 // Conversion
aoqi@0 1430 Label done;
aoqi@0 1431 switch (bytecode()) {
aoqi@0 1432 case Bytecodes::_i2l:
aoqi@0 1433 #ifdef _LP64
aoqi@0 1434 // Sign extend the 32 bits
aoqi@0 1435 __ sra ( Otos_i, 0, Otos_l );
aoqi@0 1436 #else
aoqi@0 1437 __ addcc(Otos_i, 0, Otos_l2);
aoqi@0 1438 __ br(Assembler::greaterEqual, true, Assembler::pt, done);
aoqi@0 1439 __ delayed()->clr(Otos_l1);
aoqi@0 1440 __ set(~0, Otos_l1);
aoqi@0 1441 #endif
aoqi@0 1442 break;
aoqi@0 1443
aoqi@0 1444 case Bytecodes::_i2f:
aoqi@0 1445 __ st(Otos_i, __ d_tmp );
aoqi@0 1446 __ ldf(FloatRegisterImpl::S, __ d_tmp, F0);
aoqi@0 1447 __ fitof(FloatRegisterImpl::S, F0, Ftos_f);
aoqi@0 1448 break;
aoqi@0 1449
aoqi@0 1450 case Bytecodes::_i2d:
aoqi@0 1451 __ st(Otos_i, __ d_tmp);
aoqi@0 1452 __ ldf(FloatRegisterImpl::S, __ d_tmp, F0);
aoqi@0 1453 __ fitof(FloatRegisterImpl::D, F0, Ftos_f);
aoqi@0 1454 break;
aoqi@0 1455
aoqi@0 1456 case Bytecodes::_i2b:
aoqi@0 1457 __ sll(Otos_i, 24, Otos_i);
aoqi@0 1458 __ sra(Otos_i, 24, Otos_i);
aoqi@0 1459 break;
aoqi@0 1460
aoqi@0 1461 case Bytecodes::_i2c:
aoqi@0 1462 __ sll(Otos_i, 16, Otos_i);
aoqi@0 1463 __ srl(Otos_i, 16, Otos_i);
aoqi@0 1464 break;
aoqi@0 1465
aoqi@0 1466 case Bytecodes::_i2s:
aoqi@0 1467 __ sll(Otos_i, 16, Otos_i);
aoqi@0 1468 __ sra(Otos_i, 16, Otos_i);
aoqi@0 1469 break;
aoqi@0 1470
aoqi@0 1471 case Bytecodes::_l2i:
aoqi@0 1472 #ifndef _LP64
aoqi@0 1473 __ mov(Otos_l2, Otos_i);
aoqi@0 1474 #else
aoqi@0 1475 // Sign-extend into the high 32 bits
aoqi@0 1476 __ sra(Otos_l, 0, Otos_i);
aoqi@0 1477 #endif
aoqi@0 1478 break;
aoqi@0 1479
aoqi@0 1480 case Bytecodes::_l2f:
aoqi@0 1481 case Bytecodes::_l2d:
aoqi@0 1482 __ st_long(Otos_l, __ d_tmp);
aoqi@0 1483 __ ldf(FloatRegisterImpl::D, __ d_tmp, Ftos_d);
aoqi@0 1484
aoqi@0 1485 if (bytecode() == Bytecodes::_l2f) {
aoqi@0 1486 __ fxtof(FloatRegisterImpl::S, Ftos_d, Ftos_f);
aoqi@0 1487 } else {
aoqi@0 1488 __ fxtof(FloatRegisterImpl::D, Ftos_d, Ftos_d);
aoqi@0 1489 }
aoqi@0 1490 break;
aoqi@0 1491
aoqi@0 1492 case Bytecodes::_f2i: {
aoqi@0 1493 Label isNaN;
aoqi@0 1494 // result must be 0 if value is NaN; test by comparing value to itself
aoqi@0 1495 __ fcmp(FloatRegisterImpl::S, Assembler::fcc0, Ftos_f, Ftos_f);
aoqi@0 1496 __ fb(Assembler::f_unordered, true, Assembler::pn, isNaN);
aoqi@0 1497 __ delayed()->clr(Otos_i); // NaN
aoqi@0 1498 __ ftoi(FloatRegisterImpl::S, Ftos_f, F30);
aoqi@0 1499 __ stf(FloatRegisterImpl::S, F30, __ d_tmp);
aoqi@0 1500 __ ld(__ d_tmp, Otos_i);
aoqi@0 1501 __ bind(isNaN);
aoqi@0 1502 }
aoqi@0 1503 break;
aoqi@0 1504
aoqi@0 1505 case Bytecodes::_f2l:
aoqi@0 1506 // must uncache tos
aoqi@0 1507 __ push_f();
aoqi@0 1508 #ifdef _LP64
aoqi@0 1509 __ pop_f(F1);
aoqi@0 1510 #else
aoqi@0 1511 __ pop_i(O0);
aoqi@0 1512 #endif
aoqi@0 1513 __ call_VM_leaf(Lscratch, CAST_FROM_FN_PTR(address, SharedRuntime::f2l));
aoqi@0 1514 break;
aoqi@0 1515
aoqi@0 1516 case Bytecodes::_f2d:
aoqi@0 1517 __ ftof( FloatRegisterImpl::S, FloatRegisterImpl::D, Ftos_f, Ftos_f);
aoqi@0 1518 break;
aoqi@0 1519
aoqi@0 1520 case Bytecodes::_d2i:
aoqi@0 1521 case Bytecodes::_d2l:
aoqi@0 1522 // must uncache tos
aoqi@0 1523 __ push_d();
aoqi@0 1524 #ifdef _LP64
aoqi@0 1525 // LP64 calling conventions pass first double arg in D0
aoqi@0 1526 __ pop_d( Ftos_d );
aoqi@0 1527 #else
aoqi@0 1528 __ pop_i( O0 );
aoqi@0 1529 __ pop_i( O1 );
aoqi@0 1530 #endif
aoqi@0 1531 __ call_VM_leaf(Lscratch,
aoqi@0 1532 bytecode() == Bytecodes::_d2i
aoqi@0 1533 ? CAST_FROM_FN_PTR(address, SharedRuntime::d2i)
aoqi@0 1534 : CAST_FROM_FN_PTR(address, SharedRuntime::d2l));
aoqi@0 1535 break;
aoqi@0 1536
aoqi@0 1537 case Bytecodes::_d2f:
aoqi@0 1538 __ ftof( FloatRegisterImpl::D, FloatRegisterImpl::S, Ftos_d, Ftos_f);
aoqi@0 1539 break;
aoqi@0 1540
aoqi@0 1541 default: ShouldNotReachHere();
aoqi@0 1542 }
aoqi@0 1543 __ bind(done);
aoqi@0 1544 }
aoqi@0 1545
aoqi@0 1546
aoqi@0 1547 void TemplateTable::lcmp() {
aoqi@0 1548 transition(ltos, itos);
aoqi@0 1549
aoqi@0 1550 #ifdef _LP64
aoqi@0 1551 __ pop_l(O1); // pop off value 1, value 2 is in O0
aoqi@0 1552 __ lcmp( O1, Otos_l, Otos_i );
aoqi@0 1553 #else
aoqi@0 1554 __ pop_l(O2); // cmp O2,3 to O0,1
aoqi@0 1555 __ lcmp( O2, O3, Otos_l1, Otos_l2, Otos_i );
aoqi@0 1556 #endif
aoqi@0 1557 }
aoqi@0 1558
aoqi@0 1559
aoqi@0 1560 void TemplateTable::float_cmp(bool is_float, int unordered_result) {
aoqi@0 1561
aoqi@0 1562 if (is_float) __ pop_f(F2);
aoqi@0 1563 else __ pop_d(F2);
aoqi@0 1564
aoqi@0 1565 assert(Ftos_f == F0 && Ftos_d == F0, "alias checking:");
aoqi@0 1566
aoqi@0 1567 __ float_cmp( is_float, unordered_result, F2, F0, Otos_i );
aoqi@0 1568 }
aoqi@0 1569
aoqi@0 1570 void TemplateTable::branch(bool is_jsr, bool is_wide) {
aoqi@0 1571 // Note: on SPARC, we use InterpreterMacroAssembler::if_cmp also.
aoqi@0 1572 __ verify_thread();
aoqi@0 1573
aoqi@0 1574 const Register O2_bumped_count = O2;
aoqi@0 1575 __ profile_taken_branch(G3_scratch, O2_bumped_count);
aoqi@0 1576
aoqi@0 1577 // get (wide) offset to O1_disp
aoqi@0 1578 const Register O1_disp = O1;
aoqi@0 1579 if (is_wide) __ get_4_byte_integer_at_bcp( 1, G4_scratch, O1_disp, InterpreterMacroAssembler::set_CC);
aoqi@0 1580 else __ get_2_byte_integer_at_bcp( 1, G4_scratch, O1_disp, InterpreterMacroAssembler::Signed, InterpreterMacroAssembler::set_CC);
aoqi@0 1581
aoqi@0 1582 // Handle all the JSR stuff here, then exit.
aoqi@0 1583 // It's much shorter and cleaner than intermingling with the
aoqi@0 1584 // non-JSR normal-branch stuff occurring below.
aoqi@0 1585 if( is_jsr ) {
aoqi@0 1586 // compute return address as bci in Otos_i
aoqi@0 1587 __ ld_ptr(Lmethod, Method::const_offset(), G3_scratch);
aoqi@0 1588 __ sub(Lbcp, G3_scratch, G3_scratch);
aoqi@0 1589 __ sub(G3_scratch, in_bytes(ConstMethod::codes_offset()) - (is_wide ? 5 : 3), Otos_i);
aoqi@0 1590
aoqi@0 1591 // Bump Lbcp to target of JSR
aoqi@0 1592 __ add(Lbcp, O1_disp, Lbcp);
aoqi@0 1593 // Push returnAddress for "ret" on stack
aoqi@0 1594 __ push_ptr(Otos_i);
aoqi@0 1595 // And away we go!
aoqi@0 1596 __ dispatch_next(vtos);
aoqi@0 1597 return;
aoqi@0 1598 }
aoqi@0 1599
aoqi@0 1600 // Normal (non-jsr) branch handling
aoqi@0 1601
aoqi@0 1602 // Save the current Lbcp
aoqi@0 1603 const Register l_cur_bcp = Lscratch;
aoqi@0 1604 __ mov( Lbcp, l_cur_bcp );
aoqi@0 1605
aoqi@0 1606 bool increment_invocation_counter_for_backward_branches = UseCompiler && UseLoopCounter;
aoqi@0 1607 if ( increment_invocation_counter_for_backward_branches ) {
aoqi@0 1608 Label Lforward;
aoqi@0 1609 // check branch direction
aoqi@0 1610 __ br( Assembler::positive, false, Assembler::pn, Lforward );
aoqi@0 1611 // Bump bytecode pointer by displacement (take the branch)
aoqi@0 1612 __ delayed()->add( O1_disp, Lbcp, Lbcp ); // add to bc addr
aoqi@0 1613
aoqi@0 1614 const Register Rcounters = G3_scratch;
aoqi@0 1615 __ get_method_counters(Lmethod, Rcounters, Lforward);
aoqi@0 1616
aoqi@0 1617 if (TieredCompilation) {
aoqi@0 1618 Label Lno_mdo, Loverflow;
aoqi@0 1619 int increment = InvocationCounter::count_increment;
aoqi@0 1620 int mask = ((1 << Tier0BackedgeNotifyFreqLog) - 1) << InvocationCounter::count_shift;
aoqi@0 1621 if (ProfileInterpreter) {
aoqi@0 1622 // If no method data exists, go to profile_continue.
aoqi@0 1623 __ ld_ptr(Lmethod, Method::method_data_offset(), G4_scratch);
aoqi@0 1624 __ br_null_short(G4_scratch, Assembler::pn, Lno_mdo);
aoqi@0 1625
aoqi@0 1626 // Increment backedge counter in the MDO
aoqi@0 1627 Address mdo_backedge_counter(G4_scratch, in_bytes(MethodData::backedge_counter_offset()) +
aoqi@0 1628 in_bytes(InvocationCounter::counter_offset()));
aoqi@0 1629 __ increment_mask_and_jump(mdo_backedge_counter, increment, mask, G3_scratch, O0,
aoqi@0 1630 Assembler::notZero, &Lforward);
aoqi@0 1631 __ ba_short(Loverflow);
aoqi@0 1632 }
aoqi@0 1633
aoqi@0 1634 // If there's no MDO, increment counter in MethodCounters*
aoqi@0 1635 __ bind(Lno_mdo);
aoqi@0 1636 Address backedge_counter(Rcounters,
aoqi@0 1637 in_bytes(MethodCounters::backedge_counter_offset()) +
aoqi@0 1638 in_bytes(InvocationCounter::counter_offset()));
aoqi@0 1639 __ increment_mask_and_jump(backedge_counter, increment, mask, G4_scratch, O0,
aoqi@0 1640 Assembler::notZero, &Lforward);
aoqi@0 1641 __ bind(Loverflow);
aoqi@0 1642
aoqi@0 1643 // notify point for loop, pass branch bytecode
aoqi@0 1644 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), l_cur_bcp);
aoqi@0 1645
aoqi@0 1646 // Was an OSR adapter generated?
aoqi@0 1647 // O0 = osr nmethod
aoqi@0 1648 __ br_null_short(O0, Assembler::pn, Lforward);
aoqi@0 1649
aoqi@0 1650 // Has the nmethod been invalidated already?
aoqi@0 1651 __ ld(O0, nmethod::entry_bci_offset(), O2);
aoqi@0 1652 __ cmp_and_br_short(O2, InvalidOSREntryBci, Assembler::equal, Assembler::pn, Lforward);
aoqi@0 1653
aoqi@0 1654 // migrate the interpreter frame off of the stack
aoqi@0 1655
aoqi@0 1656 __ mov(G2_thread, L7);
aoqi@0 1657 // save nmethod
aoqi@0 1658 __ mov(O0, L6);
aoqi@0 1659 __ set_last_Java_frame(SP, noreg);
aoqi@0 1660 __ call_VM_leaf(noreg, CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin), L7);
aoqi@0 1661 __ reset_last_Java_frame();
aoqi@0 1662 __ mov(L7, G2_thread);
aoqi@0 1663
aoqi@0 1664 // move OSR nmethod to I1
aoqi@0 1665 __ mov(L6, I1);
aoqi@0 1666
aoqi@0 1667 // OSR buffer to I0
aoqi@0 1668 __ mov(O0, I0);
aoqi@0 1669
aoqi@0 1670 // remove the interpreter frame
aoqi@0 1671 __ restore(I5_savedSP, 0, SP);
aoqi@0 1672
aoqi@0 1673 // Jump to the osr code.
aoqi@0 1674 __ ld_ptr(O1, nmethod::osr_entry_point_offset(), O2);
aoqi@0 1675 __ jmp(O2, G0);
aoqi@0 1676 __ delayed()->nop();
aoqi@0 1677
aoqi@0 1678 } else {
aoqi@0 1679 // Update Backedge branch separately from invocations
aoqi@0 1680 const Register G4_invoke_ctr = G4;
aoqi@0 1681 __ increment_backedge_counter(Rcounters, G4_invoke_ctr, G1_scratch);
aoqi@0 1682 if (ProfileInterpreter) {
aoqi@0 1683 __ test_invocation_counter_for_mdp(G4_invoke_ctr, G3_scratch, Lforward);
aoqi@0 1684 if (UseOnStackReplacement) {
aoqi@0 1685 __ test_backedge_count_for_osr(O2_bumped_count, l_cur_bcp, G3_scratch);
aoqi@0 1686 }
aoqi@0 1687 } else {
aoqi@0 1688 if (UseOnStackReplacement) {
aoqi@0 1689 __ test_backedge_count_for_osr(G4_invoke_ctr, l_cur_bcp, G3_scratch);
aoqi@0 1690 }
aoqi@0 1691 }
aoqi@0 1692 }
aoqi@0 1693
aoqi@0 1694 __ bind(Lforward);
aoqi@0 1695 } else
aoqi@0 1696 // Bump bytecode pointer by displacement (take the branch)
aoqi@0 1697 __ add( O1_disp, Lbcp, Lbcp );// add to bc addr
aoqi@0 1698
aoqi@0 1699 // continue with bytecode @ target
aoqi@0 1700 // %%%%% Like Intel, could speed things up by moving bytecode fetch to code above,
aoqi@0 1701 // %%%%% and changing dispatch_next to dispatch_only
aoqi@0 1702 __ dispatch_next(vtos);
aoqi@0 1703 }
aoqi@0 1704
aoqi@0 1705
aoqi@0 1706 // Note Condition in argument is TemplateTable::Condition
aoqi@0 1707 // arg scope is within class scope
aoqi@0 1708
aoqi@0 1709 void TemplateTable::if_0cmp(Condition cc) {
aoqi@0 1710 // no pointers, integer only!
aoqi@0 1711 transition(itos, vtos);
aoqi@0 1712 // assume branch is more often taken than not (loops use backward branches)
aoqi@0 1713 __ cmp( Otos_i, 0);
aoqi@0 1714 __ if_cmp(ccNot(cc), false);
aoqi@0 1715 }
aoqi@0 1716
aoqi@0 1717
aoqi@0 1718 void TemplateTable::if_icmp(Condition cc) {
aoqi@0 1719 transition(itos, vtos);
aoqi@0 1720 __ pop_i(O1);
aoqi@0 1721 __ cmp(O1, Otos_i);
aoqi@0 1722 __ if_cmp(ccNot(cc), false);
aoqi@0 1723 }
aoqi@0 1724
aoqi@0 1725
aoqi@0 1726 void TemplateTable::if_nullcmp(Condition cc) {
aoqi@0 1727 transition(atos, vtos);
aoqi@0 1728 __ tst(Otos_i);
aoqi@0 1729 __ if_cmp(ccNot(cc), true);
aoqi@0 1730 }
aoqi@0 1731
aoqi@0 1732
aoqi@0 1733 void TemplateTable::if_acmp(Condition cc) {
aoqi@0 1734 transition(atos, vtos);
aoqi@0 1735 __ pop_ptr(O1);
aoqi@0 1736 __ verify_oop(O1);
aoqi@0 1737 __ verify_oop(Otos_i);
aoqi@0 1738 __ cmp(O1, Otos_i);
aoqi@0 1739 __ if_cmp(ccNot(cc), true);
aoqi@0 1740 }
aoqi@0 1741
aoqi@0 1742
aoqi@0 1743
aoqi@0 1744 void TemplateTable::ret() {
aoqi@0 1745 transition(vtos, vtos);
aoqi@0 1746 locals_index(G3_scratch);
aoqi@0 1747 __ access_local_returnAddress(G3_scratch, Otos_i);
aoqi@0 1748 // Otos_i contains the bci, compute the bcp from that
aoqi@0 1749
aoqi@0 1750 #ifdef _LP64
aoqi@0 1751 #ifdef ASSERT
aoqi@0 1752 // jsr result was labeled as an 'itos' not an 'atos' because we cannot GC
aoqi@0 1753 // the result. The return address (really a BCI) was stored with an
aoqi@0 1754 // 'astore' because JVM specs claim it's a pointer-sized thing. Hence in
aoqi@0 1755 // the 64-bit build the 32-bit BCI is actually in the low bits of a 64-bit
aoqi@0 1756 // loaded value.
aoqi@0 1757 { Label zzz ;
aoqi@0 1758 __ set (65536, G3_scratch) ;
aoqi@0 1759 __ cmp (Otos_i, G3_scratch) ;
aoqi@0 1760 __ bp( Assembler::lessEqualUnsigned, false, Assembler::xcc, Assembler::pn, zzz);
aoqi@0 1761 __ delayed()->nop();
aoqi@0 1762 __ stop("BCI is in the wrong register half?");
aoqi@0 1763 __ bind (zzz) ;
aoqi@0 1764 }
aoqi@0 1765 #endif
aoqi@0 1766 #endif
aoqi@0 1767
aoqi@0 1768 __ profile_ret(vtos, Otos_i, G4_scratch);
aoqi@0 1769
aoqi@0 1770 __ ld_ptr(Lmethod, Method::const_offset(), G3_scratch);
aoqi@0 1771 __ add(G3_scratch, Otos_i, G3_scratch);
aoqi@0 1772 __ add(G3_scratch, in_bytes(ConstMethod::codes_offset()), Lbcp);
aoqi@0 1773 __ dispatch_next(vtos);
aoqi@0 1774 }
aoqi@0 1775
aoqi@0 1776
aoqi@0 1777 void TemplateTable::wide_ret() {
aoqi@0 1778 transition(vtos, vtos);
aoqi@0 1779 locals_index_wide(G3_scratch);
aoqi@0 1780 __ access_local_returnAddress(G3_scratch, Otos_i);
aoqi@0 1781 // Otos_i contains the bci, compute the bcp from that
aoqi@0 1782
aoqi@0 1783 __ profile_ret(vtos, Otos_i, G4_scratch);
aoqi@0 1784
aoqi@0 1785 __ ld_ptr(Lmethod, Method::const_offset(), G3_scratch);
aoqi@0 1786 __ add(G3_scratch, Otos_i, G3_scratch);
aoqi@0 1787 __ add(G3_scratch, in_bytes(ConstMethod::codes_offset()), Lbcp);
aoqi@0 1788 __ dispatch_next(vtos);
aoqi@0 1789 }
aoqi@0 1790
aoqi@0 1791
aoqi@0 1792 void TemplateTable::tableswitch() {
aoqi@0 1793 transition(itos, vtos);
aoqi@0 1794 Label default_case, continue_execution;
aoqi@0 1795
aoqi@0 1796 // align bcp
aoqi@0 1797 __ add(Lbcp, BytesPerInt, O1);
aoqi@0 1798 __ and3(O1, -BytesPerInt, O1);
aoqi@0 1799 // load lo, hi
aoqi@0 1800 __ ld(O1, 1 * BytesPerInt, O2); // Low Byte
aoqi@0 1801 __ ld(O1, 2 * BytesPerInt, O3); // High Byte
aoqi@0 1802 #ifdef _LP64
aoqi@0 1803 // Sign extend the 32 bits
aoqi@0 1804 __ sra ( Otos_i, 0, Otos_i );
aoqi@0 1805 #endif /* _LP64 */
aoqi@0 1806
aoqi@0 1807 // check against lo & hi
aoqi@0 1808 __ cmp( Otos_i, O2);
aoqi@0 1809 __ br( Assembler::less, false, Assembler::pn, default_case);
aoqi@0 1810 __ delayed()->cmp( Otos_i, O3 );
aoqi@0 1811 __ br( Assembler::greater, false, Assembler::pn, default_case);
aoqi@0 1812 // lookup dispatch offset
aoqi@0 1813 __ delayed()->sub(Otos_i, O2, O2);
aoqi@0 1814 __ profile_switch_case(O2, O3, G3_scratch, G4_scratch);
aoqi@0 1815 __ sll(O2, LogBytesPerInt, O2);
aoqi@0 1816 __ add(O2, 3 * BytesPerInt, O2);
aoqi@0 1817 __ ba(continue_execution);
aoqi@0 1818 __ delayed()->ld(O1, O2, O2);
aoqi@0 1819 // handle default
aoqi@0 1820 __ bind(default_case);
aoqi@0 1821 __ profile_switch_default(O3);
aoqi@0 1822 __ ld(O1, 0, O2); // get default offset
aoqi@0 1823 // continue execution
aoqi@0 1824 __ bind(continue_execution);
aoqi@0 1825 __ add(Lbcp, O2, Lbcp);
aoqi@0 1826 __ dispatch_next(vtos);
aoqi@0 1827 }
aoqi@0 1828
aoqi@0 1829
aoqi@0 1830 void TemplateTable::lookupswitch() {
aoqi@0 1831 transition(itos, itos);
aoqi@0 1832 __ stop("lookupswitch bytecode should have been rewritten");
aoqi@0 1833 }
aoqi@0 1834
aoqi@0 1835 void TemplateTable::fast_linearswitch() {
aoqi@0 1836 transition(itos, vtos);
aoqi@0 1837 Label loop_entry, loop, found, continue_execution;
aoqi@0 1838 // align bcp
aoqi@0 1839 __ add(Lbcp, BytesPerInt, O1);
aoqi@0 1840 __ and3(O1, -BytesPerInt, O1);
aoqi@0 1841 // set counter
aoqi@0 1842 __ ld(O1, BytesPerInt, O2);
aoqi@0 1843 __ sll(O2, LogBytesPerInt + 1, O2); // in word-pairs
aoqi@0 1844 __ add(O1, 2 * BytesPerInt, O3); // set first pair addr
aoqi@0 1845 __ ba(loop_entry);
aoqi@0 1846 __ delayed()->add(O3, O2, O2); // counter now points past last pair
aoqi@0 1847
aoqi@0 1848 // table search
aoqi@0 1849 __ bind(loop);
aoqi@0 1850 __ cmp(O4, Otos_i);
aoqi@0 1851 __ br(Assembler::equal, true, Assembler::pn, found);
aoqi@0 1852 __ delayed()->ld(O3, BytesPerInt, O4); // offset -> O4
aoqi@0 1853 __ inc(O3, 2 * BytesPerInt);
aoqi@0 1854
aoqi@0 1855 __ bind(loop_entry);
aoqi@0 1856 __ cmp(O2, O3);
aoqi@0 1857 __ brx(Assembler::greaterUnsigned, true, Assembler::pt, loop);
aoqi@0 1858 __ delayed()->ld(O3, 0, O4);
aoqi@0 1859
aoqi@0 1860 // default case
aoqi@0 1861 __ ld(O1, 0, O4); // get default offset
aoqi@0 1862 if (ProfileInterpreter) {
aoqi@0 1863 __ profile_switch_default(O3);
aoqi@0 1864 __ ba_short(continue_execution);
aoqi@0 1865 }
aoqi@0 1866
aoqi@0 1867 // entry found -> get offset
aoqi@0 1868 __ bind(found);
aoqi@0 1869 if (ProfileInterpreter) {
aoqi@0 1870 __ sub(O3, O1, O3);
aoqi@0 1871 __ sub(O3, 2*BytesPerInt, O3);
aoqi@0 1872 __ srl(O3, LogBytesPerInt + 1, O3); // in word-pairs
aoqi@0 1873 __ profile_switch_case(O3, O1, O2, G3_scratch);
aoqi@0 1874
aoqi@0 1875 __ bind(continue_execution);
aoqi@0 1876 }
aoqi@0 1877 __ add(Lbcp, O4, Lbcp);
aoqi@0 1878 __ dispatch_next(vtos);
aoqi@0 1879 }
aoqi@0 1880
aoqi@0 1881
aoqi@0 1882 void TemplateTable::fast_binaryswitch() {
aoqi@0 1883 transition(itos, vtos);
aoqi@0 1884 // Implementation using the following core algorithm: (copied from Intel)
aoqi@0 1885 //
aoqi@0 1886 // int binary_search(int key, LookupswitchPair* array, int n) {
aoqi@0 1887 // // Binary search according to "Methodik des Programmierens" by
aoqi@0 1888 // // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
aoqi@0 1889 // int i = 0;
aoqi@0 1890 // int j = n;
aoqi@0 1891 // while (i+1 < j) {
aoqi@0 1892 // // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
aoqi@0 1893 // // with Q: for all i: 0 <= i < n: key < a[i]
aoqi@0 1894 // // where a stands for the array and assuming that the (inexisting)
aoqi@0 1895 // // element a[n] is infinitely big.
aoqi@0 1896 // int h = (i + j) >> 1;
aoqi@0 1897 // // i < h < j
aoqi@0 1898 // if (key < array[h].fast_match()) {
aoqi@0 1899 // j = h;
aoqi@0 1900 // } else {
aoqi@0 1901 // i = h;
aoqi@0 1902 // }
aoqi@0 1903 // }
aoqi@0 1904 // // R: a[i] <= key < a[i+1] or Q
aoqi@0 1905 // // (i.e., if key is within array, i is the correct index)
aoqi@0 1906 // return i;
aoqi@0 1907 // }
aoqi@0 1908
aoqi@0 1909 // register allocation
aoqi@0 1910 assert(Otos_i == O0, "alias checking");
aoqi@0 1911 const Register Rkey = Otos_i; // already set (tosca)
aoqi@0 1912 const Register Rarray = O1;
aoqi@0 1913 const Register Ri = O2;
aoqi@0 1914 const Register Rj = O3;
aoqi@0 1915 const Register Rh = O4;
aoqi@0 1916 const Register Rscratch = O5;
aoqi@0 1917
aoqi@0 1918 const int log_entry_size = 3;
aoqi@0 1919 const int entry_size = 1 << log_entry_size;
aoqi@0 1920
aoqi@0 1921 Label found;
aoqi@0 1922 // Find Array start
aoqi@0 1923 __ add(Lbcp, 3 * BytesPerInt, Rarray);
aoqi@0 1924 __ and3(Rarray, -BytesPerInt, Rarray);
aoqi@0 1925 // initialize i & j (in delay slot)
aoqi@0 1926 __ clr( Ri );
aoqi@0 1927
aoqi@0 1928 // and start
aoqi@0 1929 Label entry;
aoqi@0 1930 __ ba(entry);
aoqi@0 1931 __ delayed()->ld( Rarray, -BytesPerInt, Rj);
aoqi@0 1932 // (Rj is already in the native byte-ordering.)
aoqi@0 1933
aoqi@0 1934 // binary search loop
aoqi@0 1935 { Label loop;
aoqi@0 1936 __ bind( loop );
aoqi@0 1937 // int h = (i + j) >> 1;
aoqi@0 1938 __ sra( Rh, 1, Rh );
aoqi@0 1939 // if (key < array[h].fast_match()) {
aoqi@0 1940 // j = h;
aoqi@0 1941 // } else {
aoqi@0 1942 // i = h;
aoqi@0 1943 // }
aoqi@0 1944 __ sll( Rh, log_entry_size, Rscratch );
aoqi@0 1945 __ ld( Rarray, Rscratch, Rscratch );
aoqi@0 1946 // (Rscratch is already in the native byte-ordering.)
aoqi@0 1947 __ cmp( Rkey, Rscratch );
aoqi@0 1948 __ movcc( Assembler::less, false, Assembler::icc, Rh, Rj ); // j = h if (key < array[h].fast_match())
aoqi@0 1949 __ movcc( Assembler::greaterEqual, false, Assembler::icc, Rh, Ri ); // i = h if (key >= array[h].fast_match())
aoqi@0 1950
aoqi@0 1951 // while (i+1 < j)
aoqi@0 1952 __ bind( entry );
aoqi@0 1953 __ add( Ri, 1, Rscratch );
aoqi@0 1954 __ cmp(Rscratch, Rj);
aoqi@0 1955 __ br( Assembler::less, true, Assembler::pt, loop );
aoqi@0 1956 __ delayed()->add( Ri, Rj, Rh ); // start h = i + j >> 1;
aoqi@0 1957 }
aoqi@0 1958
aoqi@0 1959 // end of binary search, result index is i (must check again!)
aoqi@0 1960 Label default_case;
aoqi@0 1961 Label continue_execution;
aoqi@0 1962 if (ProfileInterpreter) {
aoqi@0 1963 __ mov( Ri, Rh ); // Save index in i for profiling
aoqi@0 1964 }
aoqi@0 1965 __ sll( Ri, log_entry_size, Ri );
aoqi@0 1966 __ ld( Rarray, Ri, Rscratch );
aoqi@0 1967 // (Rscratch is already in the native byte-ordering.)
aoqi@0 1968 __ cmp( Rkey, Rscratch );
aoqi@0 1969 __ br( Assembler::notEqual, true, Assembler::pn, default_case );
aoqi@0 1970 __ delayed()->ld( Rarray, -2 * BytesPerInt, Rj ); // load default offset -> j
aoqi@0 1971
aoqi@0 1972 // entry found -> j = offset
aoqi@0 1973 __ inc( Ri, BytesPerInt );
aoqi@0 1974 __ profile_switch_case(Rh, Rj, Rscratch, Rkey);
aoqi@0 1975 __ ld( Rarray, Ri, Rj );
aoqi@0 1976 // (Rj is already in the native byte-ordering.)
aoqi@0 1977
aoqi@0 1978 if (ProfileInterpreter) {
aoqi@0 1979 __ ba_short(continue_execution);
aoqi@0 1980 }
aoqi@0 1981
aoqi@0 1982 __ bind(default_case); // fall through (if not profiling)
aoqi@0 1983 __ profile_switch_default(Ri);
aoqi@0 1984
aoqi@0 1985 __ bind(continue_execution);
aoqi@0 1986 __ add( Lbcp, Rj, Lbcp );
aoqi@0 1987 __ dispatch_next( vtos );
aoqi@0 1988 }
aoqi@0 1989
aoqi@0 1990
aoqi@0 1991 void TemplateTable::_return(TosState state) {
aoqi@0 1992 transition(state, state);
aoqi@0 1993 assert(_desc->calls_vm(), "inconsistent calls_vm information");
aoqi@0 1994
aoqi@0 1995 if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
aoqi@0 1996 assert(state == vtos, "only valid state");
aoqi@0 1997 __ mov(G0, G3_scratch);
aoqi@0 1998 __ access_local_ptr(G3_scratch, Otos_i);
aoqi@0 1999 __ load_klass(Otos_i, O2);
aoqi@0 2000 __ set(JVM_ACC_HAS_FINALIZER, G3);
aoqi@0 2001 __ ld(O2, in_bytes(Klass::access_flags_offset()), O2);
aoqi@0 2002 __ andcc(G3, O2, G0);
aoqi@0 2003 Label skip_register_finalizer;
aoqi@0 2004 __ br(Assembler::zero, false, Assembler::pn, skip_register_finalizer);
aoqi@0 2005 __ delayed()->nop();
aoqi@0 2006
aoqi@0 2007 // Call out to do finalizer registration
aoqi@0 2008 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), Otos_i);
aoqi@0 2009
aoqi@0 2010 __ bind(skip_register_finalizer);
aoqi@0 2011 }
aoqi@0 2012
kevinw@8368 2013 // Narrow result if state is itos but result type is smaller.
kevinw@8368 2014 // Need to narrow in the return bytecode rather than in generate_return_entry
kevinw@8368 2015 // since compiled code callers expect the result to already be narrowed.
kevinw@8368 2016 if (state == itos) {
kevinw@8368 2017 __ narrow(Otos_i);
kevinw@8368 2018 }
aoqi@0 2019 __ remove_activation(state, /* throw_monitor_exception */ true);
aoqi@0 2020
aoqi@0 2021 // The caller's SP was adjusted upon method entry to accomodate
aoqi@0 2022 // the callee's non-argument locals. Undo that adjustment.
aoqi@0 2023 __ ret(); // return to caller
aoqi@0 2024 __ delayed()->restore(I5_savedSP, G0, SP);
aoqi@0 2025 }
aoqi@0 2026
aoqi@0 2027
aoqi@0 2028 // ----------------------------------------------------------------------------
aoqi@0 2029 // Volatile variables demand their effects be made known to all CPU's in
aoqi@0 2030 // order. Store buffers on most chips allow reads & writes to reorder; the
aoqi@0 2031 // JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
aoqi@0 2032 // memory barrier (i.e., it's not sufficient that the interpreter does not
aoqi@0 2033 // reorder volatile references, the hardware also must not reorder them).
aoqi@0 2034 //
aoqi@0 2035 // According to the new Java Memory Model (JMM):
aoqi@0 2036 // (1) All volatiles are serialized wrt to each other.
aoqi@0 2037 // ALSO reads & writes act as aquire & release, so:
aoqi@0 2038 // (2) A read cannot let unrelated NON-volatile memory refs that happen after
aoqi@0 2039 // the read float up to before the read. It's OK for non-volatile memory refs
aoqi@0 2040 // that happen before the volatile read to float down below it.
aoqi@0 2041 // (3) Similar a volatile write cannot let unrelated NON-volatile memory refs
aoqi@0 2042 // that happen BEFORE the write float down to after the write. It's OK for
aoqi@0 2043 // non-volatile memory refs that happen after the volatile write to float up
aoqi@0 2044 // before it.
aoqi@0 2045 //
aoqi@0 2046 // We only put in barriers around volatile refs (they are expensive), not
aoqi@0 2047 // _between_ memory refs (that would require us to track the flavor of the
aoqi@0 2048 // previous memory refs). Requirements (2) and (3) require some barriers
aoqi@0 2049 // before volatile stores and after volatile loads. These nearly cover
aoqi@0 2050 // requirement (1) but miss the volatile-store-volatile-load case. This final
aoqi@0 2051 // case is placed after volatile-stores although it could just as well go
aoqi@0 2052 // before volatile-loads.
aoqi@0 2053 void TemplateTable::volatile_barrier(Assembler::Membar_mask_bits order_constraint) {
aoqi@0 2054 // Helper function to insert a is-volatile test and memory barrier
aoqi@0 2055 // All current sparc implementations run in TSO, needing only StoreLoad
aoqi@0 2056 if ((order_constraint & Assembler::StoreLoad) == 0) return;
aoqi@0 2057 __ membar( order_constraint );
aoqi@0 2058 }
aoqi@0 2059
aoqi@0 2060 // ----------------------------------------------------------------------------
aoqi@0 2061 void TemplateTable::resolve_cache_and_index(int byte_no,
aoqi@0 2062 Register Rcache,
aoqi@0 2063 Register index,
aoqi@0 2064 size_t index_size) {
aoqi@0 2065 // Depends on cpCacheOop layout!
aoqi@0 2066 Label resolved;
aoqi@0 2067
aoqi@0 2068 assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
aoqi@0 2069 __ get_cache_and_index_and_bytecode_at_bcp(Rcache, index, Lbyte_code, byte_no, 1, index_size);
aoqi@0 2070 __ cmp(Lbyte_code, (int) bytecode()); // have we resolved this bytecode?
aoqi@0 2071 __ br(Assembler::equal, false, Assembler::pt, resolved);
aoqi@0 2072 __ delayed()->set((int)bytecode(), O1);
aoqi@0 2073
aoqi@0 2074 address entry;
aoqi@0 2075 switch (bytecode()) {
aoqi@0 2076 case Bytecodes::_getstatic : // fall through
aoqi@0 2077 case Bytecodes::_putstatic : // fall through
aoqi@0 2078 case Bytecodes::_getfield : // fall through
aoqi@0 2079 case Bytecodes::_putfield : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_get_put); break;
aoqi@0 2080 case Bytecodes::_invokevirtual : // fall through
aoqi@0 2081 case Bytecodes::_invokespecial : // fall through
aoqi@0 2082 case Bytecodes::_invokestatic : // fall through
aoqi@0 2083 case Bytecodes::_invokeinterface: entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invoke); break;
aoqi@0 2084 case Bytecodes::_invokehandle : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokehandle); break;
aoqi@0 2085 case Bytecodes::_invokedynamic : entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_invokedynamic); break;
aoqi@0 2086 default:
aoqi@0 2087 fatal(err_msg("unexpected bytecode: %s", Bytecodes::name(bytecode())));
aoqi@0 2088 break;
aoqi@0 2089 }
aoqi@0 2090 // first time invocation - must resolve first
aoqi@0 2091 __ call_VM(noreg, entry, O1);
aoqi@0 2092 // Update registers with resolved info
aoqi@0 2093 __ get_cache_and_index_at_bcp(Rcache, index, 1, index_size);
aoqi@0 2094 __ bind(resolved);
aoqi@0 2095 }
aoqi@0 2096
aoqi@0 2097 void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
aoqi@0 2098 Register method,
aoqi@0 2099 Register itable_index,
aoqi@0 2100 Register flags,
aoqi@0 2101 bool is_invokevirtual,
aoqi@0 2102 bool is_invokevfinal,
aoqi@0 2103 bool is_invokedynamic) {
aoqi@0 2104 // Uses both G3_scratch and G4_scratch
aoqi@0 2105 Register cache = G3_scratch;
aoqi@0 2106 Register index = G4_scratch;
aoqi@0 2107 assert_different_registers(cache, method, itable_index);
aoqi@0 2108
aoqi@0 2109 // determine constant pool cache field offsets
aoqi@0 2110 assert(is_invokevirtual == (byte_no == f2_byte), "is_invokevirtual flag redundant");
aoqi@0 2111 const int method_offset = in_bytes(
aoqi@0 2112 ConstantPoolCache::base_offset() +
aoqi@0 2113 ((byte_no == f2_byte)
aoqi@0 2114 ? ConstantPoolCacheEntry::f2_offset()
aoqi@0 2115 : ConstantPoolCacheEntry::f1_offset()
aoqi@0 2116 )
aoqi@0 2117 );
aoqi@0 2118 const int flags_offset = in_bytes(ConstantPoolCache::base_offset() +
aoqi@0 2119 ConstantPoolCacheEntry::flags_offset());
aoqi@0 2120 // access constant pool cache fields
aoqi@0 2121 const int index_offset = in_bytes(ConstantPoolCache::base_offset() +
aoqi@0 2122 ConstantPoolCacheEntry::f2_offset());
aoqi@0 2123
aoqi@0 2124 if (is_invokevfinal) {
aoqi@0 2125 __ get_cache_and_index_at_bcp(cache, index, 1);
aoqi@0 2126 __ ld_ptr(Address(cache, method_offset), method);
aoqi@0 2127 } else {
aoqi@0 2128 size_t index_size = (is_invokedynamic ? sizeof(u4) : sizeof(u2));
aoqi@0 2129 resolve_cache_and_index(byte_no, cache, index, index_size);
aoqi@0 2130 __ ld_ptr(Address(cache, method_offset), method);
aoqi@0 2131 }
aoqi@0 2132
aoqi@0 2133 if (itable_index != noreg) {
aoqi@0 2134 // pick up itable or appendix index from f2 also:
aoqi@0 2135 __ ld_ptr(Address(cache, index_offset), itable_index);
aoqi@0 2136 }
aoqi@0 2137 __ ld_ptr(Address(cache, flags_offset), flags);
aoqi@0 2138 }
aoqi@0 2139
aoqi@0 2140 // The Rcache register must be set before call
aoqi@0 2141 void TemplateTable::load_field_cp_cache_entry(Register Robj,
aoqi@0 2142 Register Rcache,
aoqi@0 2143 Register index,
aoqi@0 2144 Register Roffset,
aoqi@0 2145 Register Rflags,
aoqi@0 2146 bool is_static) {
aoqi@0 2147 assert_different_registers(Rcache, Rflags, Roffset);
aoqi@0 2148
aoqi@0 2149 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2150
aoqi@0 2151 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags);
aoqi@0 2152 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset);
aoqi@0 2153 if (is_static) {
aoqi@0 2154 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f1_offset(), Robj);
aoqi@0 2155 const int mirror_offset = in_bytes(Klass::java_mirror_offset());
aoqi@0 2156 __ ld_ptr( Robj, mirror_offset, Robj);
aoqi@0 2157 }
aoqi@0 2158 }
aoqi@0 2159
aoqi@0 2160 // The registers Rcache and index expected to be set before call.
aoqi@0 2161 // Correct values of the Rcache and index registers are preserved.
aoqi@0 2162 void TemplateTable::jvmti_post_field_access(Register Rcache,
aoqi@0 2163 Register index,
aoqi@0 2164 bool is_static,
aoqi@0 2165 bool has_tos) {
aoqi@0 2166 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2167
aoqi@0 2168 if (JvmtiExport::can_post_field_access()) {
aoqi@0 2169 // Check to see if a field access watch has been set before we take
aoqi@0 2170 // the time to call into the VM.
aoqi@0 2171 Label Label1;
aoqi@0 2172 assert_different_registers(Rcache, index, G1_scratch);
aoqi@0 2173 AddressLiteral get_field_access_count_addr(JvmtiExport::get_field_access_count_addr());
aoqi@0 2174 __ load_contents(get_field_access_count_addr, G1_scratch);
aoqi@0 2175 __ cmp_and_br_short(G1_scratch, 0, Assembler::equal, Assembler::pt, Label1);
aoqi@0 2176
aoqi@0 2177 __ add(Rcache, in_bytes(cp_base_offset), Rcache);
aoqi@0 2178
aoqi@0 2179 if (is_static) {
aoqi@0 2180 __ clr(Otos_i);
aoqi@0 2181 } else {
aoqi@0 2182 if (has_tos) {
aoqi@0 2183 // save object pointer before call_VM() clobbers it
aoqi@0 2184 __ push_ptr(Otos_i); // put object on tos where GC wants it.
aoqi@0 2185 } else {
aoqi@0 2186 // Load top of stack (do not pop the value off the stack);
aoqi@0 2187 __ ld_ptr(Lesp, Interpreter::expr_offset_in_bytes(0), Otos_i);
aoqi@0 2188 }
aoqi@0 2189 __ verify_oop(Otos_i);
aoqi@0 2190 }
aoqi@0 2191 // Otos_i: object pointer or NULL if static
aoqi@0 2192 // Rcache: cache entry pointer
aoqi@0 2193 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access),
aoqi@0 2194 Otos_i, Rcache);
aoqi@0 2195 if (!is_static && has_tos) {
aoqi@0 2196 __ pop_ptr(Otos_i); // restore object pointer
aoqi@0 2197 __ verify_oop(Otos_i);
aoqi@0 2198 }
aoqi@0 2199 __ get_cache_and_index_at_bcp(Rcache, index, 1);
aoqi@0 2200 __ bind(Label1);
aoqi@0 2201 }
aoqi@0 2202 }
aoqi@0 2203
aoqi@0 2204 void TemplateTable::getfield_or_static(int byte_no, bool is_static) {
aoqi@0 2205 transition(vtos, vtos);
aoqi@0 2206
aoqi@0 2207 Register Rcache = G3_scratch;
aoqi@0 2208 Register index = G4_scratch;
aoqi@0 2209 Register Rclass = Rcache;
aoqi@0 2210 Register Roffset= G4_scratch;
aoqi@0 2211 Register Rflags = G1_scratch;
aoqi@0 2212 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2213
aoqi@0 2214 resolve_cache_and_index(byte_no, Rcache, index, sizeof(u2));
aoqi@0 2215 jvmti_post_field_access(Rcache, index, is_static, false);
aoqi@0 2216 load_field_cp_cache_entry(Rclass, Rcache, index, Roffset, Rflags, is_static);
aoqi@0 2217
aoqi@0 2218 if (!is_static) {
aoqi@0 2219 pop_and_check_object(Rclass);
aoqi@0 2220 } else {
aoqi@0 2221 __ verify_oop(Rclass);
aoqi@0 2222 }
aoqi@0 2223
aoqi@0 2224 Label exit;
aoqi@0 2225
aoqi@0 2226 Assembler::Membar_mask_bits membar_bits =
aoqi@0 2227 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore);
aoqi@0 2228
aoqi@0 2229 if (__ membar_has_effect(membar_bits)) {
aoqi@0 2230 // Get volatile flag
aoqi@0 2231 __ set((1 << ConstantPoolCacheEntry::is_volatile_shift), Lscratch);
aoqi@0 2232 __ and3(Rflags, Lscratch, Lscratch);
aoqi@0 2233 }
aoqi@0 2234
aoqi@0 2235 Label checkVolatile;
aoqi@0 2236
aoqi@0 2237 // compute field type
kevinw@8368 2238 Label notByte, notBool, notInt, notShort, notChar, notLong, notFloat, notObj;
aoqi@0 2239 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags);
aoqi@0 2240 // Make sure we don't need to mask Rflags after the above shift
aoqi@0 2241 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 2242
aoqi@0 2243 // Check atos before itos for getstatic, more likely (in Queens at least)
aoqi@0 2244 __ cmp(Rflags, atos);
aoqi@0 2245 __ br(Assembler::notEqual, false, Assembler::pt, notObj);
aoqi@0 2246 __ delayed() ->cmp(Rflags, itos);
aoqi@0 2247
aoqi@0 2248 // atos
aoqi@0 2249 __ load_heap_oop(Rclass, Roffset, Otos_i);
aoqi@0 2250 __ verify_oop(Otos_i);
aoqi@0 2251 __ push(atos);
aoqi@0 2252 if (!is_static) {
aoqi@0 2253 patch_bytecode(Bytecodes::_fast_agetfield, G3_scratch, G4_scratch);
aoqi@0 2254 }
aoqi@0 2255 __ ba(checkVolatile);
aoqi@0 2256 __ delayed()->tst(Lscratch);
aoqi@0 2257
aoqi@0 2258 __ bind(notObj);
aoqi@0 2259
aoqi@0 2260 // cmp(Rflags, itos);
aoqi@0 2261 __ br(Assembler::notEqual, false, Assembler::pt, notInt);
aoqi@0 2262 __ delayed() ->cmp(Rflags, ltos);
aoqi@0 2263
aoqi@0 2264 // itos
aoqi@0 2265 __ ld(Rclass, Roffset, Otos_i);
aoqi@0 2266 __ push(itos);
aoqi@0 2267 if (!is_static) {
aoqi@0 2268 patch_bytecode(Bytecodes::_fast_igetfield, G3_scratch, G4_scratch);
aoqi@0 2269 }
aoqi@0 2270 __ ba(checkVolatile);
aoqi@0 2271 __ delayed()->tst(Lscratch);
aoqi@0 2272
aoqi@0 2273 __ bind(notInt);
aoqi@0 2274
aoqi@0 2275 // cmp(Rflags, ltos);
aoqi@0 2276 __ br(Assembler::notEqual, false, Assembler::pt, notLong);
aoqi@0 2277 __ delayed() ->cmp(Rflags, btos);
aoqi@0 2278
aoqi@0 2279 // ltos
aoqi@0 2280 // load must be atomic
aoqi@0 2281 __ ld_long(Rclass, Roffset, Otos_l);
aoqi@0 2282 __ push(ltos);
aoqi@0 2283 if (!is_static) {
aoqi@0 2284 patch_bytecode(Bytecodes::_fast_lgetfield, G3_scratch, G4_scratch);
aoqi@0 2285 }
aoqi@0 2286 __ ba(checkVolatile);
aoqi@0 2287 __ delayed()->tst(Lscratch);
aoqi@0 2288
aoqi@0 2289 __ bind(notLong);
aoqi@0 2290
aoqi@0 2291 // cmp(Rflags, btos);
aoqi@0 2292 __ br(Assembler::notEqual, false, Assembler::pt, notByte);
kevinw@8368 2293 __ delayed() ->cmp(Rflags, ztos);
aoqi@0 2294
aoqi@0 2295 // btos
aoqi@0 2296 __ ldsb(Rclass, Roffset, Otos_i);
aoqi@0 2297 __ push(itos);
aoqi@0 2298 if (!is_static) {
aoqi@0 2299 patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch);
aoqi@0 2300 }
aoqi@0 2301 __ ba(checkVolatile);
aoqi@0 2302 __ delayed()->tst(Lscratch);
aoqi@0 2303
aoqi@0 2304 __ bind(notByte);
aoqi@0 2305
kevinw@8368 2306 // cmp(Rflags, ztos);
kevinw@8368 2307 __ br(Assembler::notEqual, false, Assembler::pt, notBool);
kevinw@8368 2308 __ delayed() ->cmp(Rflags, ctos);
kevinw@8368 2309
kevinw@8368 2310 // ztos
kevinw@8368 2311 __ ldsb(Rclass, Roffset, Otos_i);
kevinw@8368 2312 __ push(itos);
kevinw@8368 2313 if (!is_static) {
kevinw@8368 2314 // use btos rewriting, no truncating to t/f bit is needed for getfield.
kevinw@8368 2315 patch_bytecode(Bytecodes::_fast_bgetfield, G3_scratch, G4_scratch);
kevinw@8368 2316 }
kevinw@8368 2317 __ ba(checkVolatile);
kevinw@8368 2318 __ delayed()->tst(Lscratch);
kevinw@8368 2319
kevinw@8368 2320 __ bind(notBool);
kevinw@8368 2321
aoqi@0 2322 // cmp(Rflags, ctos);
aoqi@0 2323 __ br(Assembler::notEqual, false, Assembler::pt, notChar);
aoqi@0 2324 __ delayed() ->cmp(Rflags, stos);
aoqi@0 2325
aoqi@0 2326 // ctos
aoqi@0 2327 __ lduh(Rclass, Roffset, Otos_i);
aoqi@0 2328 __ push(itos);
aoqi@0 2329 if (!is_static) {
aoqi@0 2330 patch_bytecode(Bytecodes::_fast_cgetfield, G3_scratch, G4_scratch);
aoqi@0 2331 }
aoqi@0 2332 __ ba(checkVolatile);
aoqi@0 2333 __ delayed()->tst(Lscratch);
aoqi@0 2334
aoqi@0 2335 __ bind(notChar);
aoqi@0 2336
aoqi@0 2337 // cmp(Rflags, stos);
aoqi@0 2338 __ br(Assembler::notEqual, false, Assembler::pt, notShort);
aoqi@0 2339 __ delayed() ->cmp(Rflags, ftos);
aoqi@0 2340
aoqi@0 2341 // stos
aoqi@0 2342 __ ldsh(Rclass, Roffset, Otos_i);
aoqi@0 2343 __ push(itos);
aoqi@0 2344 if (!is_static) {
aoqi@0 2345 patch_bytecode(Bytecodes::_fast_sgetfield, G3_scratch, G4_scratch);
aoqi@0 2346 }
aoqi@0 2347 __ ba(checkVolatile);
aoqi@0 2348 __ delayed()->tst(Lscratch);
aoqi@0 2349
aoqi@0 2350 __ bind(notShort);
aoqi@0 2351
aoqi@0 2352
aoqi@0 2353 // cmp(Rflags, ftos);
aoqi@0 2354 __ br(Assembler::notEqual, false, Assembler::pt, notFloat);
aoqi@0 2355 __ delayed() ->tst(Lscratch);
aoqi@0 2356
aoqi@0 2357 // ftos
aoqi@0 2358 __ ldf(FloatRegisterImpl::S, Rclass, Roffset, Ftos_f);
aoqi@0 2359 __ push(ftos);
aoqi@0 2360 if (!is_static) {
aoqi@0 2361 patch_bytecode(Bytecodes::_fast_fgetfield, G3_scratch, G4_scratch);
aoqi@0 2362 }
aoqi@0 2363 __ ba(checkVolatile);
aoqi@0 2364 __ delayed()->tst(Lscratch);
aoqi@0 2365
aoqi@0 2366 __ bind(notFloat);
aoqi@0 2367
aoqi@0 2368
aoqi@0 2369 // dtos
aoqi@0 2370 __ ldf(FloatRegisterImpl::D, Rclass, Roffset, Ftos_d);
aoqi@0 2371 __ push(dtos);
aoqi@0 2372 if (!is_static) {
aoqi@0 2373 patch_bytecode(Bytecodes::_fast_dgetfield, G3_scratch, G4_scratch);
aoqi@0 2374 }
aoqi@0 2375
aoqi@0 2376 __ bind(checkVolatile);
aoqi@0 2377 if (__ membar_has_effect(membar_bits)) {
aoqi@0 2378 // __ tst(Lscratch); executed in delay slot
aoqi@0 2379 __ br(Assembler::zero, false, Assembler::pt, exit);
aoqi@0 2380 __ delayed()->nop();
aoqi@0 2381 volatile_barrier(membar_bits);
aoqi@0 2382 }
aoqi@0 2383
aoqi@0 2384 __ bind(exit);
aoqi@0 2385 }
aoqi@0 2386
aoqi@0 2387
aoqi@0 2388 void TemplateTable::getfield(int byte_no) {
aoqi@0 2389 getfield_or_static(byte_no, false);
aoqi@0 2390 }
aoqi@0 2391
aoqi@0 2392 void TemplateTable::getstatic(int byte_no) {
aoqi@0 2393 getfield_or_static(byte_no, true);
aoqi@0 2394 }
aoqi@0 2395
aoqi@0 2396
aoqi@0 2397 void TemplateTable::fast_accessfield(TosState state) {
aoqi@0 2398 transition(atos, state);
aoqi@0 2399 Register Rcache = G3_scratch;
aoqi@0 2400 Register index = G4_scratch;
aoqi@0 2401 Register Roffset = G4_scratch;
aoqi@0 2402 Register Rflags = Rcache;
aoqi@0 2403 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2404
aoqi@0 2405 __ get_cache_and_index_at_bcp(Rcache, index, 1);
aoqi@0 2406 jvmti_post_field_access(Rcache, index, /*is_static*/false, /*has_tos*/true);
aoqi@0 2407
aoqi@0 2408 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset);
aoqi@0 2409
aoqi@0 2410 __ null_check(Otos_i);
aoqi@0 2411 __ verify_oop(Otos_i);
aoqi@0 2412
aoqi@0 2413 Label exit;
aoqi@0 2414
aoqi@0 2415 Assembler::Membar_mask_bits membar_bits =
aoqi@0 2416 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore);
aoqi@0 2417 if (__ membar_has_effect(membar_bits)) {
aoqi@0 2418 // Get volatile flag
aoqi@0 2419 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Rflags);
aoqi@0 2420 __ set((1 << ConstantPoolCacheEntry::is_volatile_shift), Lscratch);
aoqi@0 2421 }
aoqi@0 2422
aoqi@0 2423 switch (bytecode()) {
aoqi@0 2424 case Bytecodes::_fast_bgetfield:
aoqi@0 2425 __ ldsb(Otos_i, Roffset, Otos_i);
aoqi@0 2426 break;
aoqi@0 2427 case Bytecodes::_fast_cgetfield:
aoqi@0 2428 __ lduh(Otos_i, Roffset, Otos_i);
aoqi@0 2429 break;
aoqi@0 2430 case Bytecodes::_fast_sgetfield:
aoqi@0 2431 __ ldsh(Otos_i, Roffset, Otos_i);
aoqi@0 2432 break;
aoqi@0 2433 case Bytecodes::_fast_igetfield:
aoqi@0 2434 __ ld(Otos_i, Roffset, Otos_i);
aoqi@0 2435 break;
aoqi@0 2436 case Bytecodes::_fast_lgetfield:
aoqi@0 2437 __ ld_long(Otos_i, Roffset, Otos_l);
aoqi@0 2438 break;
aoqi@0 2439 case Bytecodes::_fast_fgetfield:
aoqi@0 2440 __ ldf(FloatRegisterImpl::S, Otos_i, Roffset, Ftos_f);
aoqi@0 2441 break;
aoqi@0 2442 case Bytecodes::_fast_dgetfield:
aoqi@0 2443 __ ldf(FloatRegisterImpl::D, Otos_i, Roffset, Ftos_d);
aoqi@0 2444 break;
aoqi@0 2445 case Bytecodes::_fast_agetfield:
aoqi@0 2446 __ load_heap_oop(Otos_i, Roffset, Otos_i);
aoqi@0 2447 break;
aoqi@0 2448 default:
aoqi@0 2449 ShouldNotReachHere();
aoqi@0 2450 }
aoqi@0 2451
aoqi@0 2452 if (__ membar_has_effect(membar_bits)) {
aoqi@0 2453 __ btst(Lscratch, Rflags);
aoqi@0 2454 __ br(Assembler::zero, false, Assembler::pt, exit);
aoqi@0 2455 __ delayed()->nop();
aoqi@0 2456 volatile_barrier(membar_bits);
aoqi@0 2457 __ bind(exit);
aoqi@0 2458 }
aoqi@0 2459
aoqi@0 2460 if (state == atos) {
aoqi@0 2461 __ verify_oop(Otos_i); // does not blow flags!
aoqi@0 2462 }
aoqi@0 2463 }
aoqi@0 2464
aoqi@0 2465 void TemplateTable::jvmti_post_fast_field_mod() {
aoqi@0 2466 if (JvmtiExport::can_post_field_modification()) {
aoqi@0 2467 // Check to see if a field modification watch has been set before we take
aoqi@0 2468 // the time to call into the VM.
aoqi@0 2469 Label done;
aoqi@0 2470 AddressLiteral get_field_modification_count_addr(JvmtiExport::get_field_modification_count_addr());
aoqi@0 2471 __ load_contents(get_field_modification_count_addr, G4_scratch);
aoqi@0 2472 __ cmp_and_br_short(G4_scratch, 0, Assembler::equal, Assembler::pt, done);
aoqi@0 2473 __ pop_ptr(G4_scratch); // copy the object pointer from tos
aoqi@0 2474 __ verify_oop(G4_scratch);
aoqi@0 2475 __ push_ptr(G4_scratch); // put the object pointer back on tos
aoqi@0 2476 __ get_cache_entry_pointer_at_bcp(G1_scratch, G3_scratch, 1);
aoqi@0 2477 // Save tos values before call_VM() clobbers them. Since we have
aoqi@0 2478 // to do it for every data type, we use the saved values as the
aoqi@0 2479 // jvalue object.
aoqi@0 2480 switch (bytecode()) { // save tos values before call_VM() clobbers them
aoqi@0 2481 case Bytecodes::_fast_aputfield: __ push_ptr(Otos_i); break;
aoqi@0 2482 case Bytecodes::_fast_bputfield: // fall through
kevinw@8368 2483 case Bytecodes::_fast_zputfield: // fall through
aoqi@0 2484 case Bytecodes::_fast_sputfield: // fall through
aoqi@0 2485 case Bytecodes::_fast_cputfield: // fall through
aoqi@0 2486 case Bytecodes::_fast_iputfield: __ push_i(Otos_i); break;
aoqi@0 2487 case Bytecodes::_fast_dputfield: __ push_d(Ftos_d); break;
aoqi@0 2488 case Bytecodes::_fast_fputfield: __ push_f(Ftos_f); break;
aoqi@0 2489 // get words in right order for use as jvalue object
aoqi@0 2490 case Bytecodes::_fast_lputfield: __ push_l(Otos_l); break;
aoqi@0 2491 }
aoqi@0 2492 // setup pointer to jvalue object
aoqi@0 2493 __ mov(Lesp, G3_scratch); __ inc(G3_scratch, wordSize);
aoqi@0 2494 // G4_scratch: object pointer
aoqi@0 2495 // G1_scratch: cache entry pointer
aoqi@0 2496 // G3_scratch: jvalue object on the stack
aoqi@0 2497 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), G4_scratch, G1_scratch, G3_scratch);
aoqi@0 2498 switch (bytecode()) { // restore tos values
aoqi@0 2499 case Bytecodes::_fast_aputfield: __ pop_ptr(Otos_i); break;
aoqi@0 2500 case Bytecodes::_fast_bputfield: // fall through
kevinw@8368 2501 case Bytecodes::_fast_zputfield: // fall through
aoqi@0 2502 case Bytecodes::_fast_sputfield: // fall through
aoqi@0 2503 case Bytecodes::_fast_cputfield: // fall through
aoqi@0 2504 case Bytecodes::_fast_iputfield: __ pop_i(Otos_i); break;
aoqi@0 2505 case Bytecodes::_fast_dputfield: __ pop_d(Ftos_d); break;
aoqi@0 2506 case Bytecodes::_fast_fputfield: __ pop_f(Ftos_f); break;
aoqi@0 2507 case Bytecodes::_fast_lputfield: __ pop_l(Otos_l); break;
aoqi@0 2508 }
aoqi@0 2509 __ bind(done);
aoqi@0 2510 }
aoqi@0 2511 }
aoqi@0 2512
aoqi@0 2513 // The registers Rcache and index expected to be set before call.
aoqi@0 2514 // The function may destroy various registers, just not the Rcache and index registers.
aoqi@0 2515 void TemplateTable::jvmti_post_field_mod(Register Rcache, Register index, bool is_static) {
aoqi@0 2516 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2517
aoqi@0 2518 if (JvmtiExport::can_post_field_modification()) {
aoqi@0 2519 // Check to see if a field modification watch has been set before we take
aoqi@0 2520 // the time to call into the VM.
aoqi@0 2521 Label Label1;
aoqi@0 2522 assert_different_registers(Rcache, index, G1_scratch);
aoqi@0 2523 AddressLiteral get_field_modification_count_addr(JvmtiExport::get_field_modification_count_addr());
aoqi@0 2524 __ load_contents(get_field_modification_count_addr, G1_scratch);
aoqi@0 2525 __ cmp_and_br_short(G1_scratch, 0, Assembler::zero, Assembler::pt, Label1);
aoqi@0 2526
aoqi@0 2527 // The Rcache and index registers have been already set.
aoqi@0 2528 // This allows to eliminate this call but the Rcache and index
aoqi@0 2529 // registers must be correspondingly used after this line.
aoqi@0 2530 __ get_cache_and_index_at_bcp(G1_scratch, G4_scratch, 1);
aoqi@0 2531
aoqi@0 2532 __ add(G1_scratch, in_bytes(cp_base_offset), G3_scratch);
aoqi@0 2533 if (is_static) {
aoqi@0 2534 // Life is simple. Null out the object pointer.
aoqi@0 2535 __ clr(G4_scratch);
aoqi@0 2536 } else {
aoqi@0 2537 Register Rflags = G1_scratch;
aoqi@0 2538 // Life is harder. The stack holds the value on top, followed by the
aoqi@0 2539 // object. We don't know the size of the value, though; it could be
aoqi@0 2540 // one or two words depending on its type. As a result, we must find
aoqi@0 2541 // the type to determine where the object is.
aoqi@0 2542
aoqi@0 2543 Label two_word, valsizeknown;
aoqi@0 2544 __ ld_ptr(G1_scratch, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags);
aoqi@0 2545 __ mov(Lesp, G4_scratch);
aoqi@0 2546 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags);
aoqi@0 2547 // Make sure we don't need to mask Rflags after the above shift
aoqi@0 2548 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 2549 __ cmp(Rflags, ltos);
aoqi@0 2550 __ br(Assembler::equal, false, Assembler::pt, two_word);
aoqi@0 2551 __ delayed()->cmp(Rflags, dtos);
aoqi@0 2552 __ br(Assembler::equal, false, Assembler::pt, two_word);
aoqi@0 2553 __ delayed()->nop();
aoqi@0 2554 __ inc(G4_scratch, Interpreter::expr_offset_in_bytes(1));
aoqi@0 2555 __ ba_short(valsizeknown);
aoqi@0 2556 __ bind(two_word);
aoqi@0 2557
aoqi@0 2558 __ inc(G4_scratch, Interpreter::expr_offset_in_bytes(2));
aoqi@0 2559
aoqi@0 2560 __ bind(valsizeknown);
aoqi@0 2561 // setup object pointer
aoqi@0 2562 __ ld_ptr(G4_scratch, 0, G4_scratch);
aoqi@0 2563 __ verify_oop(G4_scratch);
aoqi@0 2564 }
aoqi@0 2565 // setup pointer to jvalue object
aoqi@0 2566 __ mov(Lesp, G1_scratch); __ inc(G1_scratch, wordSize);
aoqi@0 2567 // G4_scratch: object pointer or NULL if static
aoqi@0 2568 // G3_scratch: cache entry pointer
aoqi@0 2569 // G1_scratch: jvalue object on the stack
aoqi@0 2570 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification),
aoqi@0 2571 G4_scratch, G3_scratch, G1_scratch);
aoqi@0 2572 __ get_cache_and_index_at_bcp(Rcache, index, 1);
aoqi@0 2573 __ bind(Label1);
aoqi@0 2574 }
aoqi@0 2575 }
aoqi@0 2576
aoqi@0 2577 void TemplateTable::pop_and_check_object(Register r) {
aoqi@0 2578 __ pop_ptr(r);
aoqi@0 2579 __ null_check(r); // for field access must check obj.
aoqi@0 2580 __ verify_oop(r);
aoqi@0 2581 }
aoqi@0 2582
aoqi@0 2583 void TemplateTable::putfield_or_static(int byte_no, bool is_static) {
aoqi@0 2584 transition(vtos, vtos);
aoqi@0 2585 Register Rcache = G3_scratch;
aoqi@0 2586 Register index = G4_scratch;
aoqi@0 2587 Register Rclass = Rcache;
aoqi@0 2588 Register Roffset= G4_scratch;
aoqi@0 2589 Register Rflags = G1_scratch;
aoqi@0 2590 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2591
aoqi@0 2592 resolve_cache_and_index(byte_no, Rcache, index, sizeof(u2));
aoqi@0 2593 jvmti_post_field_mod(Rcache, index, is_static);
aoqi@0 2594 load_field_cp_cache_entry(Rclass, Rcache, index, Roffset, Rflags, is_static);
aoqi@0 2595
aoqi@0 2596 Assembler::Membar_mask_bits read_bits =
aoqi@0 2597 Assembler::Membar_mask_bits(Assembler::LoadStore | Assembler::StoreStore);
aoqi@0 2598 Assembler::Membar_mask_bits write_bits = Assembler::StoreLoad;
aoqi@0 2599
aoqi@0 2600 Label notVolatile, checkVolatile, exit;
aoqi@0 2601 if (__ membar_has_effect(read_bits) || __ membar_has_effect(write_bits)) {
aoqi@0 2602 __ set((1 << ConstantPoolCacheEntry::is_volatile_shift), Lscratch);
aoqi@0 2603 __ and3(Rflags, Lscratch, Lscratch);
aoqi@0 2604
aoqi@0 2605 if (__ membar_has_effect(read_bits)) {
aoqi@0 2606 __ cmp_and_br_short(Lscratch, 0, Assembler::equal, Assembler::pt, notVolatile);
aoqi@0 2607 volatile_barrier(read_bits);
aoqi@0 2608 __ bind(notVolatile);
aoqi@0 2609 }
aoqi@0 2610 }
aoqi@0 2611
aoqi@0 2612 __ srl(Rflags, ConstantPoolCacheEntry::tos_state_shift, Rflags);
aoqi@0 2613 // Make sure we don't need to mask Rflags after the above shift
aoqi@0 2614 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 2615
aoqi@0 2616 // compute field type
kevinw@8368 2617 Label notInt, notShort, notChar, notObj, notByte, notBool, notLong, notFloat;
aoqi@0 2618
aoqi@0 2619 if (is_static) {
aoqi@0 2620 // putstatic with object type most likely, check that first
aoqi@0 2621 __ cmp(Rflags, atos);
aoqi@0 2622 __ br(Assembler::notEqual, false, Assembler::pt, notObj);
aoqi@0 2623 __ delayed()->cmp(Rflags, itos);
aoqi@0 2624
aoqi@0 2625 // atos
aoqi@0 2626 {
aoqi@0 2627 __ pop_ptr();
aoqi@0 2628 __ verify_oop(Otos_i);
aoqi@0 2629 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false);
aoqi@0 2630 __ ba(checkVolatile);
aoqi@0 2631 __ delayed()->tst(Lscratch);
aoqi@0 2632 }
aoqi@0 2633
aoqi@0 2634 __ bind(notObj);
aoqi@0 2635 // cmp(Rflags, itos);
aoqi@0 2636 __ br(Assembler::notEqual, false, Assembler::pt, notInt);
aoqi@0 2637 __ delayed()->cmp(Rflags, btos);
aoqi@0 2638
aoqi@0 2639 // itos
aoqi@0 2640 {
aoqi@0 2641 __ pop_i();
aoqi@0 2642 __ st(Otos_i, Rclass, Roffset);
aoqi@0 2643 __ ba(checkVolatile);
aoqi@0 2644 __ delayed()->tst(Lscratch);
aoqi@0 2645 }
aoqi@0 2646
aoqi@0 2647 __ bind(notInt);
aoqi@0 2648 } else {
aoqi@0 2649 // putfield with int type most likely, check that first
aoqi@0 2650 __ cmp(Rflags, itos);
aoqi@0 2651 __ br(Assembler::notEqual, false, Assembler::pt, notInt);
aoqi@0 2652 __ delayed()->cmp(Rflags, atos);
aoqi@0 2653
aoqi@0 2654 // itos
aoqi@0 2655 {
aoqi@0 2656 __ pop_i();
aoqi@0 2657 pop_and_check_object(Rclass);
aoqi@0 2658 __ st(Otos_i, Rclass, Roffset);
aoqi@0 2659 patch_bytecode(Bytecodes::_fast_iputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2660 __ ba(checkVolatile);
aoqi@0 2661 __ delayed()->tst(Lscratch);
aoqi@0 2662 }
aoqi@0 2663
aoqi@0 2664 __ bind(notInt);
aoqi@0 2665 // cmp(Rflags, atos);
aoqi@0 2666 __ br(Assembler::notEqual, false, Assembler::pt, notObj);
aoqi@0 2667 __ delayed()->cmp(Rflags, btos);
aoqi@0 2668
aoqi@0 2669 // atos
aoqi@0 2670 {
aoqi@0 2671 __ pop_ptr();
aoqi@0 2672 pop_and_check_object(Rclass);
aoqi@0 2673 __ verify_oop(Otos_i);
aoqi@0 2674 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false);
aoqi@0 2675 patch_bytecode(Bytecodes::_fast_aputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2676 __ ba(checkVolatile);
aoqi@0 2677 __ delayed()->tst(Lscratch);
aoqi@0 2678 }
aoqi@0 2679
aoqi@0 2680 __ bind(notObj);
aoqi@0 2681 }
aoqi@0 2682
aoqi@0 2683 // cmp(Rflags, btos);
aoqi@0 2684 __ br(Assembler::notEqual, false, Assembler::pt, notByte);
kevinw@8368 2685 __ delayed()->cmp(Rflags, ztos);
aoqi@0 2686
aoqi@0 2687 // btos
aoqi@0 2688 {
aoqi@0 2689 __ pop_i();
aoqi@0 2690 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2691 __ stb(Otos_i, Rclass, Roffset);
aoqi@0 2692 if (!is_static) {
aoqi@0 2693 patch_bytecode(Bytecodes::_fast_bputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2694 }
aoqi@0 2695 __ ba(checkVolatile);
aoqi@0 2696 __ delayed()->tst(Lscratch);
aoqi@0 2697 }
aoqi@0 2698
aoqi@0 2699 __ bind(notByte);
kevinw@8368 2700
kevinw@8368 2701 // cmp(Rflags, btos);
kevinw@8368 2702 __ br(Assembler::notEqual, false, Assembler::pt, notBool);
kevinw@8368 2703 __ delayed()->cmp(Rflags, ltos);
kevinw@8368 2704
kevinw@8368 2705 // ztos
kevinw@8368 2706 {
kevinw@8368 2707 __ pop_i();
kevinw@8368 2708 if (!is_static) pop_and_check_object(Rclass);
kevinw@8368 2709 __ and3(Otos_i, 1, Otos_i);
kevinw@8368 2710 __ stb(Otos_i, Rclass, Roffset);
kevinw@8368 2711 if (!is_static) {
kevinw@8368 2712 patch_bytecode(Bytecodes::_fast_zputfield, G3_scratch, G4_scratch, true, byte_no);
kevinw@8368 2713 }
kevinw@8368 2714 __ ba(checkVolatile);
kevinw@8368 2715 __ delayed()->tst(Lscratch);
kevinw@8368 2716 }
kevinw@8368 2717
kevinw@8368 2718 __ bind(notBool);
aoqi@0 2719 // cmp(Rflags, ltos);
aoqi@0 2720 __ br(Assembler::notEqual, false, Assembler::pt, notLong);
aoqi@0 2721 __ delayed()->cmp(Rflags, ctos);
aoqi@0 2722
aoqi@0 2723 // ltos
aoqi@0 2724 {
aoqi@0 2725 __ pop_l();
aoqi@0 2726 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2727 __ st_long(Otos_l, Rclass, Roffset);
aoqi@0 2728 if (!is_static) {
aoqi@0 2729 patch_bytecode(Bytecodes::_fast_lputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2730 }
aoqi@0 2731 __ ba(checkVolatile);
aoqi@0 2732 __ delayed()->tst(Lscratch);
aoqi@0 2733 }
aoqi@0 2734
aoqi@0 2735 __ bind(notLong);
aoqi@0 2736 // cmp(Rflags, ctos);
aoqi@0 2737 __ br(Assembler::notEqual, false, Assembler::pt, notChar);
aoqi@0 2738 __ delayed()->cmp(Rflags, stos);
aoqi@0 2739
aoqi@0 2740 // ctos (char)
aoqi@0 2741 {
aoqi@0 2742 __ pop_i();
aoqi@0 2743 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2744 __ sth(Otos_i, Rclass, Roffset);
aoqi@0 2745 if (!is_static) {
aoqi@0 2746 patch_bytecode(Bytecodes::_fast_cputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2747 }
aoqi@0 2748 __ ba(checkVolatile);
aoqi@0 2749 __ delayed()->tst(Lscratch);
aoqi@0 2750 }
aoqi@0 2751
aoqi@0 2752 __ bind(notChar);
aoqi@0 2753 // cmp(Rflags, stos);
aoqi@0 2754 __ br(Assembler::notEqual, false, Assembler::pt, notShort);
aoqi@0 2755 __ delayed()->cmp(Rflags, ftos);
aoqi@0 2756
aoqi@0 2757 // stos (short)
aoqi@0 2758 {
aoqi@0 2759 __ pop_i();
aoqi@0 2760 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2761 __ sth(Otos_i, Rclass, Roffset);
aoqi@0 2762 if (!is_static) {
aoqi@0 2763 patch_bytecode(Bytecodes::_fast_sputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2764 }
aoqi@0 2765 __ ba(checkVolatile);
aoqi@0 2766 __ delayed()->tst(Lscratch);
aoqi@0 2767 }
aoqi@0 2768
aoqi@0 2769 __ bind(notShort);
aoqi@0 2770 // cmp(Rflags, ftos);
aoqi@0 2771 __ br(Assembler::notZero, false, Assembler::pt, notFloat);
aoqi@0 2772 __ delayed()->nop();
aoqi@0 2773
aoqi@0 2774 // ftos
aoqi@0 2775 {
aoqi@0 2776 __ pop_f();
aoqi@0 2777 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2778 __ stf(FloatRegisterImpl::S, Ftos_f, Rclass, Roffset);
aoqi@0 2779 if (!is_static) {
aoqi@0 2780 patch_bytecode(Bytecodes::_fast_fputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2781 }
aoqi@0 2782 __ ba(checkVolatile);
aoqi@0 2783 __ delayed()->tst(Lscratch);
aoqi@0 2784 }
aoqi@0 2785
aoqi@0 2786 __ bind(notFloat);
aoqi@0 2787
aoqi@0 2788 // dtos
aoqi@0 2789 {
aoqi@0 2790 __ pop_d();
aoqi@0 2791 if (!is_static) pop_and_check_object(Rclass);
aoqi@0 2792 __ stf(FloatRegisterImpl::D, Ftos_d, Rclass, Roffset);
aoqi@0 2793 if (!is_static) {
aoqi@0 2794 patch_bytecode(Bytecodes::_fast_dputfield, G3_scratch, G4_scratch, true, byte_no);
aoqi@0 2795 }
aoqi@0 2796 }
aoqi@0 2797
aoqi@0 2798 __ bind(checkVolatile);
aoqi@0 2799 __ tst(Lscratch);
aoqi@0 2800
aoqi@0 2801 if (__ membar_has_effect(write_bits)) {
aoqi@0 2802 // __ tst(Lscratch); in delay slot
aoqi@0 2803 __ br(Assembler::zero, false, Assembler::pt, exit);
aoqi@0 2804 __ delayed()->nop();
aoqi@0 2805 volatile_barrier(Assembler::StoreLoad);
aoqi@0 2806 __ bind(exit);
aoqi@0 2807 }
aoqi@0 2808 }
aoqi@0 2809
aoqi@0 2810 void TemplateTable::fast_storefield(TosState state) {
aoqi@0 2811 transition(state, vtos);
aoqi@0 2812 Register Rcache = G3_scratch;
aoqi@0 2813 Register Rclass = Rcache;
aoqi@0 2814 Register Roffset= G4_scratch;
aoqi@0 2815 Register Rflags = G1_scratch;
aoqi@0 2816 ByteSize cp_base_offset = ConstantPoolCache::base_offset();
aoqi@0 2817
aoqi@0 2818 jvmti_post_fast_field_mod();
aoqi@0 2819
aoqi@0 2820 __ get_cache_and_index_at_bcp(Rcache, G4_scratch, 1);
aoqi@0 2821
aoqi@0 2822 Assembler::Membar_mask_bits read_bits =
aoqi@0 2823 Assembler::Membar_mask_bits(Assembler::LoadStore | Assembler::StoreStore);
aoqi@0 2824 Assembler::Membar_mask_bits write_bits = Assembler::StoreLoad;
aoqi@0 2825
aoqi@0 2826 Label notVolatile, checkVolatile, exit;
aoqi@0 2827 if (__ membar_has_effect(read_bits) || __ membar_has_effect(write_bits)) {
aoqi@0 2828 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::flags_offset(), Rflags);
aoqi@0 2829 __ set((1 << ConstantPoolCacheEntry::is_volatile_shift), Lscratch);
aoqi@0 2830 __ and3(Rflags, Lscratch, Lscratch);
aoqi@0 2831 if (__ membar_has_effect(read_bits)) {
aoqi@0 2832 __ cmp_and_br_short(Lscratch, 0, Assembler::equal, Assembler::pt, notVolatile);
aoqi@0 2833 volatile_barrier(read_bits);
aoqi@0 2834 __ bind(notVolatile);
aoqi@0 2835 }
aoqi@0 2836 }
aoqi@0 2837
aoqi@0 2838 __ ld_ptr(Rcache, cp_base_offset + ConstantPoolCacheEntry::f2_offset(), Roffset);
aoqi@0 2839 pop_and_check_object(Rclass);
aoqi@0 2840
aoqi@0 2841 switch (bytecode()) {
kevinw@8368 2842 case Bytecodes::_fast_zputfield: __ and3(Otos_i, 1, Otos_i); // fall through to bputfield
aoqi@0 2843 case Bytecodes::_fast_bputfield: __ stb(Otos_i, Rclass, Roffset); break;
aoqi@0 2844 case Bytecodes::_fast_cputfield: /* fall through */
aoqi@0 2845 case Bytecodes::_fast_sputfield: __ sth(Otos_i, Rclass, Roffset); break;
aoqi@0 2846 case Bytecodes::_fast_iputfield: __ st(Otos_i, Rclass, Roffset); break;
aoqi@0 2847 case Bytecodes::_fast_lputfield: __ st_long(Otos_l, Rclass, Roffset); break;
aoqi@0 2848 case Bytecodes::_fast_fputfield:
aoqi@0 2849 __ stf(FloatRegisterImpl::S, Ftos_f, Rclass, Roffset);
aoqi@0 2850 break;
aoqi@0 2851 case Bytecodes::_fast_dputfield:
aoqi@0 2852 __ stf(FloatRegisterImpl::D, Ftos_d, Rclass, Roffset);
aoqi@0 2853 break;
aoqi@0 2854 case Bytecodes::_fast_aputfield:
aoqi@0 2855 do_oop_store(_masm, Rclass, Roffset, 0, Otos_i, G1_scratch, _bs->kind(), false);
aoqi@0 2856 break;
aoqi@0 2857 default:
aoqi@0 2858 ShouldNotReachHere();
aoqi@0 2859 }
aoqi@0 2860
aoqi@0 2861 if (__ membar_has_effect(write_bits)) {
aoqi@0 2862 __ cmp_and_br_short(Lscratch, 0, Assembler::equal, Assembler::pt, exit);
aoqi@0 2863 volatile_barrier(Assembler::StoreLoad);
aoqi@0 2864 __ bind(exit);
aoqi@0 2865 }
aoqi@0 2866 }
aoqi@0 2867
aoqi@0 2868
aoqi@0 2869 void TemplateTable::putfield(int byte_no) {
aoqi@0 2870 putfield_or_static(byte_no, false);
aoqi@0 2871 }
aoqi@0 2872
aoqi@0 2873 void TemplateTable::putstatic(int byte_no) {
aoqi@0 2874 putfield_or_static(byte_no, true);
aoqi@0 2875 }
aoqi@0 2876
aoqi@0 2877
aoqi@0 2878 void TemplateTable::fast_xaccess(TosState state) {
aoqi@0 2879 transition(vtos, state);
aoqi@0 2880 Register Rcache = G3_scratch;
aoqi@0 2881 Register Roffset = G4_scratch;
aoqi@0 2882 Register Rflags = G4_scratch;
aoqi@0 2883 Register Rreceiver = Lscratch;
aoqi@0 2884
aoqi@0 2885 __ ld_ptr(Llocals, 0, Rreceiver);
aoqi@0 2886
aoqi@0 2887 // access constant pool cache (is resolved)
aoqi@0 2888 __ get_cache_and_index_at_bcp(Rcache, G4_scratch, 2);
aoqi@0 2889 __ ld_ptr(Rcache, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::f2_offset(), Roffset);
aoqi@0 2890 __ add(Lbcp, 1, Lbcp); // needed to report exception at the correct bcp
aoqi@0 2891
aoqi@0 2892 __ verify_oop(Rreceiver);
aoqi@0 2893 __ null_check(Rreceiver);
aoqi@0 2894 if (state == atos) {
aoqi@0 2895 __ load_heap_oop(Rreceiver, Roffset, Otos_i);
aoqi@0 2896 } else if (state == itos) {
aoqi@0 2897 __ ld (Rreceiver, Roffset, Otos_i) ;
aoqi@0 2898 } else if (state == ftos) {
aoqi@0 2899 __ ldf(FloatRegisterImpl::S, Rreceiver, Roffset, Ftos_f);
aoqi@0 2900 } else {
aoqi@0 2901 ShouldNotReachHere();
aoqi@0 2902 }
aoqi@0 2903
aoqi@0 2904 Assembler::Membar_mask_bits membar_bits =
aoqi@0 2905 Assembler::Membar_mask_bits(Assembler::LoadLoad | Assembler::LoadStore);
aoqi@0 2906 if (__ membar_has_effect(membar_bits)) {
aoqi@0 2907
aoqi@0 2908 // Get is_volatile value in Rflags and check if membar is needed
aoqi@0 2909 __ ld_ptr(Rcache, ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::flags_offset(), Rflags);
aoqi@0 2910
aoqi@0 2911 // Test volatile
aoqi@0 2912 Label notVolatile;
aoqi@0 2913 __ set((1 << ConstantPoolCacheEntry::is_volatile_shift), Lscratch);
aoqi@0 2914 __ btst(Rflags, Lscratch);
aoqi@0 2915 __ br(Assembler::zero, false, Assembler::pt, notVolatile);
aoqi@0 2916 __ delayed()->nop();
aoqi@0 2917 volatile_barrier(membar_bits);
aoqi@0 2918 __ bind(notVolatile);
aoqi@0 2919 }
aoqi@0 2920
aoqi@0 2921 __ interp_verify_oop(Otos_i, state, __FILE__, __LINE__);
aoqi@0 2922 __ sub(Lbcp, 1, Lbcp);
aoqi@0 2923 }
aoqi@0 2924
aoqi@0 2925 //----------------------------------------------------------------------------------------------------
aoqi@0 2926 // Calls
aoqi@0 2927
aoqi@0 2928 void TemplateTable::count_calls(Register method, Register temp) {
aoqi@0 2929 // implemented elsewhere
aoqi@0 2930 ShouldNotReachHere();
aoqi@0 2931 }
aoqi@0 2932
aoqi@0 2933 void TemplateTable::prepare_invoke(int byte_no,
aoqi@0 2934 Register method, // linked method (or i-klass)
aoqi@0 2935 Register ra, // return address
aoqi@0 2936 Register index, // itable index, MethodType, etc.
aoqi@0 2937 Register recv, // if caller wants to see it
aoqi@0 2938 Register flags // if caller wants to test it
aoqi@0 2939 ) {
aoqi@0 2940 // determine flags
aoqi@0 2941 const Bytecodes::Code code = bytecode();
aoqi@0 2942 const bool is_invokeinterface = code == Bytecodes::_invokeinterface;
aoqi@0 2943 const bool is_invokedynamic = code == Bytecodes::_invokedynamic;
aoqi@0 2944 const bool is_invokehandle = code == Bytecodes::_invokehandle;
aoqi@0 2945 const bool is_invokevirtual = code == Bytecodes::_invokevirtual;
aoqi@0 2946 const bool is_invokespecial = code == Bytecodes::_invokespecial;
aoqi@0 2947 const bool load_receiver = (recv != noreg);
aoqi@0 2948 assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), "");
aoqi@0 2949 assert(recv == noreg || recv == O0, "");
aoqi@0 2950 assert(flags == noreg || flags == O1, "");
aoqi@0 2951
aoqi@0 2952 // setup registers & access constant pool cache
aoqi@0 2953 if (recv == noreg) recv = O0;
aoqi@0 2954 if (flags == noreg) flags = O1;
aoqi@0 2955 const Register temp = O2;
aoqi@0 2956 assert_different_registers(method, ra, index, recv, flags, temp);
aoqi@0 2957
aoqi@0 2958 load_invoke_cp_cache_entry(byte_no, method, index, flags, is_invokevirtual, false, is_invokedynamic);
aoqi@0 2959
aoqi@0 2960 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore
aoqi@0 2961
aoqi@0 2962 // maybe push appendix to arguments
aoqi@0 2963 if (is_invokedynamic || is_invokehandle) {
aoqi@0 2964 Label L_no_push;
aoqi@0 2965 __ set((1 << ConstantPoolCacheEntry::has_appendix_shift), temp);
aoqi@0 2966 __ btst(flags, temp);
aoqi@0 2967 __ br(Assembler::zero, false, Assembler::pt, L_no_push);
aoqi@0 2968 __ delayed()->nop();
aoqi@0 2969 // Push the appendix as a trailing parameter.
aoqi@0 2970 // This must be done before we get the receiver,
aoqi@0 2971 // since the parameter_size includes it.
aoqi@0 2972 assert(ConstantPoolCacheEntry::_indy_resolved_references_appendix_offset == 0, "appendix expected at index+0");
aoqi@0 2973 __ load_resolved_reference_at_index(temp, index);
aoqi@0 2974 __ verify_oop(temp);
aoqi@0 2975 __ push_ptr(temp); // push appendix (MethodType, CallSite, etc.)
aoqi@0 2976 __ bind(L_no_push);
aoqi@0 2977 }
aoqi@0 2978
aoqi@0 2979 // load receiver if needed (after appendix is pushed so parameter size is correct)
aoqi@0 2980 if (load_receiver) {
aoqi@0 2981 __ and3(flags, ConstantPoolCacheEntry::parameter_size_mask, temp); // get parameter size
aoqi@0 2982 __ load_receiver(temp, recv); // __ argument_address uses Gargs but we need Lesp
aoqi@0 2983 __ verify_oop(recv);
aoqi@0 2984 }
aoqi@0 2985
aoqi@0 2986 // compute return type
aoqi@0 2987 __ srl(flags, ConstantPoolCacheEntry::tos_state_shift, ra);
aoqi@0 2988 // Make sure we don't need to mask flags after the above shift
aoqi@0 2989 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 2990 // load return address
aoqi@0 2991 {
aoqi@0 2992 const address table_addr = (address) Interpreter::invoke_return_entry_table_for(code);
aoqi@0 2993 AddressLiteral table(table_addr);
aoqi@0 2994 __ set(table, temp);
aoqi@0 2995 __ sll(ra, LogBytesPerWord, ra);
aoqi@0 2996 __ ld_ptr(Address(temp, ra), ra);
aoqi@0 2997 }
aoqi@0 2998 }
aoqi@0 2999
aoqi@0 3000
aoqi@0 3001 void TemplateTable::generate_vtable_call(Register Rrecv, Register Rindex, Register Rret) {
aoqi@0 3002 Register Rcall = Rindex;
aoqi@0 3003 assert_different_registers(Rcall, G5_method, Gargs, Rret);
aoqi@0 3004
aoqi@0 3005 // get target Method* & entry point
aoqi@0 3006 __ lookup_virtual_method(Rrecv, Rindex, G5_method);
aoqi@0 3007 __ profile_arguments_type(G5_method, Rcall, Gargs, true);
aoqi@0 3008 __ call_from_interpreter(Rcall, Gargs, Rret);
aoqi@0 3009 }
aoqi@0 3010
aoqi@0 3011 void TemplateTable::invokevirtual(int byte_no) {
aoqi@0 3012 transition(vtos, vtos);
aoqi@0 3013 assert(byte_no == f2_byte, "use this argument");
aoqi@0 3014
aoqi@0 3015 Register Rscratch = G3_scratch;
aoqi@0 3016 Register Rtemp = G4_scratch;
aoqi@0 3017 Register Rret = Lscratch;
aoqi@0 3018 Register O0_recv = O0;
aoqi@0 3019 Label notFinal;
aoqi@0 3020
aoqi@0 3021 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Rret, true, false, false);
aoqi@0 3022 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore
aoqi@0 3023
aoqi@0 3024 // Check for vfinal
aoqi@0 3025 __ set((1 << ConstantPoolCacheEntry::is_vfinal_shift), G4_scratch);
aoqi@0 3026 __ btst(Rret, G4_scratch);
aoqi@0 3027 __ br(Assembler::zero, false, Assembler::pt, notFinal);
aoqi@0 3028 __ delayed()->and3(Rret, 0xFF, G4_scratch); // gets number of parameters
aoqi@0 3029
aoqi@0 3030 patch_bytecode(Bytecodes::_fast_invokevfinal, Rscratch, Rtemp);
aoqi@0 3031
aoqi@0 3032 invokevfinal_helper(Rscratch, Rret);
aoqi@0 3033
aoqi@0 3034 __ bind(notFinal);
aoqi@0 3035
aoqi@0 3036 __ mov(G5_method, Rscratch); // better scratch register
aoqi@0 3037 __ load_receiver(G4_scratch, O0_recv); // gets receiverOop
aoqi@0 3038 // receiver is in O0_recv
aoqi@0 3039 __ verify_oop(O0_recv);
aoqi@0 3040
aoqi@0 3041 // get return address
aoqi@0 3042 AddressLiteral table(Interpreter::invoke_return_entry_table());
aoqi@0 3043 __ set(table, Rtemp);
aoqi@0 3044 __ srl(Rret, ConstantPoolCacheEntry::tos_state_shift, Rret); // get return type
aoqi@0 3045 // Make sure we don't need to mask Rret after the above shift
aoqi@0 3046 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 3047 __ sll(Rret, LogBytesPerWord, Rret);
aoqi@0 3048 __ ld_ptr(Rtemp, Rret, Rret); // get return address
aoqi@0 3049
aoqi@0 3050 // get receiver klass
aoqi@0 3051 __ null_check(O0_recv, oopDesc::klass_offset_in_bytes());
aoqi@0 3052 __ load_klass(O0_recv, O0_recv);
aoqi@0 3053 __ verify_klass_ptr(O0_recv);
aoqi@0 3054
aoqi@0 3055 __ profile_virtual_call(O0_recv, O4);
aoqi@0 3056
aoqi@0 3057 generate_vtable_call(O0_recv, Rscratch, Rret);
aoqi@0 3058 }
aoqi@0 3059
aoqi@0 3060 void TemplateTable::fast_invokevfinal(int byte_no) {
aoqi@0 3061 transition(vtos, vtos);
aoqi@0 3062 assert(byte_no == f2_byte, "use this argument");
aoqi@0 3063
aoqi@0 3064 load_invoke_cp_cache_entry(byte_no, G5_method, noreg, Lscratch, true,
aoqi@0 3065 /*is_invokevfinal*/true, false);
aoqi@0 3066 __ mov(SP, O5_savedSP); // record SP that we wanted the callee to restore
aoqi@0 3067 invokevfinal_helper(G3_scratch, Lscratch);
aoqi@0 3068 }
aoqi@0 3069
aoqi@0 3070 void TemplateTable::invokevfinal_helper(Register Rscratch, Register Rret) {
aoqi@0 3071 Register Rtemp = G4_scratch;
aoqi@0 3072
aoqi@0 3073 // Load receiver from stack slot
aoqi@0 3074 __ ld_ptr(G5_method, in_bytes(Method::const_offset()), G4_scratch);
aoqi@0 3075 __ lduh(G4_scratch, in_bytes(ConstMethod::size_of_parameters_offset()), G4_scratch);
aoqi@0 3076 __ load_receiver(G4_scratch, O0);
aoqi@0 3077
aoqi@0 3078 // receiver NULL check
aoqi@0 3079 __ null_check(O0);
aoqi@0 3080
aoqi@0 3081 __ profile_final_call(O4);
aoqi@0 3082 __ profile_arguments_type(G5_method, Rscratch, Gargs, true);
aoqi@0 3083
aoqi@0 3084 // get return address
aoqi@0 3085 AddressLiteral table(Interpreter::invoke_return_entry_table());
aoqi@0 3086 __ set(table, Rtemp);
aoqi@0 3087 __ srl(Rret, ConstantPoolCacheEntry::tos_state_shift, Rret); // get return type
aoqi@0 3088 // Make sure we don't need to mask Rret after the above shift
aoqi@0 3089 ConstantPoolCacheEntry::verify_tos_state_shift();
aoqi@0 3090 __ sll(Rret, LogBytesPerWord, Rret);
aoqi@0 3091 __ ld_ptr(Rtemp, Rret, Rret); // get return address
aoqi@0 3092
aoqi@0 3093
aoqi@0 3094 // do the call
aoqi@0 3095 __ call_from_interpreter(Rscratch, Gargs, Rret);
aoqi@0 3096 }
aoqi@0 3097
aoqi@0 3098
aoqi@0 3099 void TemplateTable::invokespecial(int byte_no) {
aoqi@0 3100 transition(vtos, vtos);
aoqi@0 3101 assert(byte_no == f1_byte, "use this argument");
aoqi@0 3102
aoqi@0 3103 const Register Rret = Lscratch;
aoqi@0 3104 const Register O0_recv = O0;
aoqi@0 3105 const Register Rscratch = G3_scratch;
aoqi@0 3106
aoqi@0 3107 prepare_invoke(byte_no, G5_method, Rret, noreg, O0_recv); // get receiver also for null check
aoqi@0 3108 __ null_check(O0_recv);
aoqi@0 3109
aoqi@0 3110 // do the call
aoqi@0 3111 __ profile_call(O4);
aoqi@0 3112 __ profile_arguments_type(G5_method, Rscratch, Gargs, false);
aoqi@0 3113 __ call_from_interpreter(Rscratch, Gargs, Rret);
aoqi@0 3114 }
aoqi@0 3115
aoqi@0 3116
aoqi@0 3117 void TemplateTable::invokestatic(int byte_no) {
aoqi@0 3118 transition(vtos, vtos);
aoqi@0 3119 assert(byte_no == f1_byte, "use this argument");
aoqi@0 3120
aoqi@0 3121 const Register Rret = Lscratch;
aoqi@0 3122 const Register Rscratch = G3_scratch;
aoqi@0 3123
aoqi@0 3124 prepare_invoke(byte_no, G5_method, Rret); // get f1 Method*
aoqi@0 3125
aoqi@0 3126 // do the call
aoqi@0 3127 __ profile_call(O4);
aoqi@0 3128 __ profile_arguments_type(G5_method, Rscratch, Gargs, false);
aoqi@0 3129 __ call_from_interpreter(Rscratch, Gargs, Rret);
aoqi@0 3130 }
aoqi@0 3131
aoqi@0 3132 void TemplateTable::invokeinterface_object_method(Register RKlass,
aoqi@0 3133 Register Rcall,
aoqi@0 3134 Register Rret,
aoqi@0 3135 Register Rflags) {
aoqi@0 3136 Register Rscratch = G4_scratch;
aoqi@0 3137 Register Rindex = Lscratch;
aoqi@0 3138
aoqi@0 3139 assert_different_registers(Rscratch, Rindex, Rret);
aoqi@0 3140
aoqi@0 3141 Label notFinal;
aoqi@0 3142
aoqi@0 3143 // Check for vfinal
aoqi@0 3144 __ set((1 << ConstantPoolCacheEntry::is_vfinal_shift), Rscratch);
aoqi@0 3145 __ btst(Rflags, Rscratch);
aoqi@0 3146 __ br(Assembler::zero, false, Assembler::pt, notFinal);
aoqi@0 3147 __ delayed()->nop();
aoqi@0 3148
aoqi@0 3149 __ profile_final_call(O4);
aoqi@0 3150
aoqi@0 3151 // do the call - the index (f2) contains the Method*
aoqi@0 3152 assert_different_registers(G5_method, Gargs, Rcall);
aoqi@0 3153 __ mov(Rindex, G5_method);
aoqi@0 3154 __ profile_arguments_type(G5_method, Rcall, Gargs, true);
aoqi@0 3155 __ call_from_interpreter(Rcall, Gargs, Rret);
aoqi@0 3156 __ bind(notFinal);
aoqi@0 3157
aoqi@0 3158 __ profile_virtual_call(RKlass, O4);
aoqi@0 3159 generate_vtable_call(RKlass, Rindex, Rret);
aoqi@0 3160 }
aoqi@0 3161
aoqi@0 3162
aoqi@0 3163 void TemplateTable::invokeinterface(int byte_no) {
aoqi@0 3164 transition(vtos, vtos);
aoqi@0 3165 assert(byte_no == f1_byte, "use this argument");
aoqi@0 3166
aoqi@0 3167 const Register Rinterface = G1_scratch;
aoqi@0 3168 const Register Rret = G3_scratch;
aoqi@0 3169 const Register Rindex = Lscratch;
aoqi@0 3170 const Register O0_recv = O0;
aoqi@0 3171 const Register O1_flags = O1;
aoqi@0 3172 const Register O2_Klass = O2;
aoqi@0 3173 const Register Rscratch = G4_scratch;
aoqi@0 3174 assert_different_registers(Rscratch, G5_method);
aoqi@0 3175
aoqi@0 3176 prepare_invoke(byte_no, Rinterface, Rret, Rindex, O0_recv, O1_flags);
aoqi@0 3177
aoqi@0 3178 // get receiver klass
aoqi@0 3179 __ null_check(O0_recv, oopDesc::klass_offset_in_bytes());
aoqi@0 3180 __ load_klass(O0_recv, O2_Klass);
aoqi@0 3181
aoqi@0 3182 // Special case of invokeinterface called for virtual method of
aoqi@0 3183 // java.lang.Object. See cpCacheOop.cpp for details.
aoqi@0 3184 // This code isn't produced by javac, but could be produced by
aoqi@0 3185 // another compliant java compiler.
aoqi@0 3186 Label notMethod;
aoqi@0 3187 __ set((1 << ConstantPoolCacheEntry::is_forced_virtual_shift), Rscratch);
aoqi@0 3188 __ btst(O1_flags, Rscratch);
aoqi@0 3189 __ br(Assembler::zero, false, Assembler::pt, notMethod);
aoqi@0 3190 __ delayed()->nop();
aoqi@0 3191
aoqi@0 3192 invokeinterface_object_method(O2_Klass, Rinterface, Rret, O1_flags);
aoqi@0 3193
aoqi@0 3194 __ bind(notMethod);
aoqi@0 3195
aoqi@0 3196 __ profile_virtual_call(O2_Klass, O4);
aoqi@0 3197
aoqi@0 3198 //
aoqi@0 3199 // find entry point to call
aoqi@0 3200 //
aoqi@0 3201
aoqi@0 3202 // compute start of first itableOffsetEntry (which is at end of vtable)
aoqi@0 3203 const int base = InstanceKlass::vtable_start_offset() * wordSize;
aoqi@0 3204 Label search;
aoqi@0 3205 Register Rtemp = O1_flags;
aoqi@0 3206
aoqi@0 3207 __ ld(O2_Klass, InstanceKlass::vtable_length_offset() * wordSize, Rtemp);
aoqi@0 3208 if (align_object_offset(1) > 1) {
aoqi@0 3209 __ round_to(Rtemp, align_object_offset(1));
aoqi@0 3210 }
aoqi@0 3211 __ sll(Rtemp, LogBytesPerWord, Rtemp); // Rscratch *= 4;
aoqi@0 3212 if (Assembler::is_simm13(base)) {
aoqi@0 3213 __ add(Rtemp, base, Rtemp);
aoqi@0 3214 } else {
aoqi@0 3215 __ set(base, Rscratch);
aoqi@0 3216 __ add(Rscratch, Rtemp, Rtemp);
aoqi@0 3217 }
aoqi@0 3218 __ add(O2_Klass, Rtemp, Rscratch);
aoqi@0 3219
aoqi@0 3220 __ bind(search);
aoqi@0 3221
aoqi@0 3222 __ ld_ptr(Rscratch, itableOffsetEntry::interface_offset_in_bytes(), Rtemp);
aoqi@0 3223 {
aoqi@0 3224 Label ok;
aoqi@0 3225
aoqi@0 3226 // Check that entry is non-null. Null entries are probably a bytecode
aoqi@0 3227 // problem. If the interface isn't implemented by the receiver class,
aoqi@0 3228 // the VM should throw IncompatibleClassChangeError. linkResolver checks
aoqi@0 3229 // this too but that's only if the entry isn't already resolved, so we
aoqi@0 3230 // need to check again.
aoqi@0 3231 __ br_notnull_short( Rtemp, Assembler::pt, ok);
aoqi@0 3232 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_IncompatibleClassChangeError));
aoqi@0 3233 __ should_not_reach_here();
aoqi@0 3234 __ bind(ok);
aoqi@0 3235 }
aoqi@0 3236
aoqi@0 3237 __ cmp(Rinterface, Rtemp);
aoqi@0 3238 __ brx(Assembler::notEqual, true, Assembler::pn, search);
aoqi@0 3239 __ delayed()->add(Rscratch, itableOffsetEntry::size() * wordSize, Rscratch);
aoqi@0 3240
aoqi@0 3241 // entry found and Rscratch points to it
aoqi@0 3242 __ ld(Rscratch, itableOffsetEntry::offset_offset_in_bytes(), Rscratch);
aoqi@0 3243
aoqi@0 3244 assert(itableMethodEntry::method_offset_in_bytes() == 0, "adjust instruction below");
aoqi@0 3245 __ sll(Rindex, exact_log2(itableMethodEntry::size() * wordSize), Rindex); // Rindex *= 8;
aoqi@0 3246 __ add(Rscratch, Rindex, Rscratch);
aoqi@0 3247 __ ld_ptr(O2_Klass, Rscratch, G5_method);
aoqi@0 3248
aoqi@0 3249 // Check for abstract method error.
aoqi@0 3250 {
aoqi@0 3251 Label ok;
aoqi@0 3252 __ br_notnull_short(G5_method, Assembler::pt, ok);
aoqi@0 3253 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodError));
aoqi@0 3254 __ should_not_reach_here();
aoqi@0 3255 __ bind(ok);
aoqi@0 3256 }
aoqi@0 3257
aoqi@0 3258 Register Rcall = Rinterface;
aoqi@0 3259 assert_different_registers(Rcall, G5_method, Gargs, Rret);
aoqi@0 3260
aoqi@0 3261 __ profile_arguments_type(G5_method, Rcall, Gargs, true);
aoqi@0 3262 __ call_from_interpreter(Rcall, Gargs, Rret);
aoqi@0 3263 }
aoqi@0 3264
aoqi@0 3265 void TemplateTable::invokehandle(int byte_no) {
aoqi@0 3266 transition(vtos, vtos);
aoqi@0 3267 assert(byte_no == f1_byte, "use this argument");
aoqi@0 3268
aoqi@0 3269 if (!EnableInvokeDynamic) {
aoqi@0 3270 // rewriter does not generate this bytecode
aoqi@0 3271 __ should_not_reach_here();
aoqi@0 3272 return;
aoqi@0 3273 }
aoqi@0 3274
aoqi@0 3275 const Register Rret = Lscratch;
aoqi@0 3276 const Register G4_mtype = G4_scratch;
aoqi@0 3277 const Register O0_recv = O0;
aoqi@0 3278 const Register Rscratch = G3_scratch;
aoqi@0 3279
aoqi@0 3280 prepare_invoke(byte_no, G5_method, Rret, G4_mtype, O0_recv);
aoqi@0 3281 __ null_check(O0_recv);
aoqi@0 3282
aoqi@0 3283 // G4: MethodType object (from cpool->resolved_references[f1], if necessary)
aoqi@0 3284 // G5: MH.invokeExact_MT method (from f2)
aoqi@0 3285
aoqi@0 3286 // Note: G4_mtype is already pushed (if necessary) by prepare_invoke
aoqi@0 3287
aoqi@0 3288 // do the call
aoqi@0 3289 __ verify_oop(G4_mtype);
aoqi@0 3290 __ profile_final_call(O4); // FIXME: profile the LambdaForm also
aoqi@0 3291 __ profile_arguments_type(G5_method, Rscratch, Gargs, true);
aoqi@0 3292 __ call_from_interpreter(Rscratch, Gargs, Rret);
aoqi@0 3293 }
aoqi@0 3294
aoqi@0 3295
aoqi@0 3296 void TemplateTable::invokedynamic(int byte_no) {
aoqi@0 3297 transition(vtos, vtos);
aoqi@0 3298 assert(byte_no == f1_byte, "use this argument");
aoqi@0 3299
aoqi@0 3300 if (!EnableInvokeDynamic) {
aoqi@0 3301 // We should not encounter this bytecode if !EnableInvokeDynamic.
aoqi@0 3302 // The verifier will stop it. However, if we get past the verifier,
aoqi@0 3303 // this will stop the thread in a reasonable way, without crashing the JVM.
aoqi@0 3304 __ call_VM(noreg, CAST_FROM_FN_PTR(address,
aoqi@0 3305 InterpreterRuntime::throw_IncompatibleClassChangeError));
aoqi@0 3306 // the call_VM checks for exception, so we should never return here.
aoqi@0 3307 __ should_not_reach_here();
aoqi@0 3308 return;
aoqi@0 3309 }
aoqi@0 3310
aoqi@0 3311 const Register Rret = Lscratch;
aoqi@0 3312 const Register G4_callsite = G4_scratch;
aoqi@0 3313 const Register Rscratch = G3_scratch;
aoqi@0 3314
aoqi@0 3315 prepare_invoke(byte_no, G5_method, Rret, G4_callsite);
aoqi@0 3316
aoqi@0 3317 // G4: CallSite object (from cpool->resolved_references[f1])
aoqi@0 3318 // G5: MH.linkToCallSite method (from f2)
aoqi@0 3319
aoqi@0 3320 // Note: G4_callsite is already pushed by prepare_invoke
aoqi@0 3321
aoqi@0 3322 // %%% should make a type profile for any invokedynamic that takes a ref argument
aoqi@0 3323 // profile this call
aoqi@0 3324 __ profile_call(O4);
aoqi@0 3325
aoqi@0 3326 // do the call
aoqi@0 3327 __ verify_oop(G4_callsite);
aoqi@0 3328 __ profile_arguments_type(G5_method, Rscratch, Gargs, false);
aoqi@0 3329 __ call_from_interpreter(Rscratch, Gargs, Rret);
aoqi@0 3330 }
aoqi@0 3331
aoqi@0 3332
aoqi@0 3333 //----------------------------------------------------------------------------------------------------
aoqi@0 3334 // Allocation
aoqi@0 3335
aoqi@0 3336 void TemplateTable::_new() {
aoqi@0 3337 transition(vtos, atos);
aoqi@0 3338
aoqi@0 3339 Label slow_case;
aoqi@0 3340 Label done;
aoqi@0 3341 Label initialize_header;
aoqi@0 3342 Label initialize_object; // including clearing the fields
aoqi@0 3343
aoqi@0 3344 Register RallocatedObject = Otos_i;
aoqi@0 3345 Register RinstanceKlass = O1;
aoqi@0 3346 Register Roffset = O3;
aoqi@0 3347 Register Rscratch = O4;
aoqi@0 3348
aoqi@0 3349 __ get_2_byte_integer_at_bcp(1, Rscratch, Roffset, InterpreterMacroAssembler::Unsigned);
aoqi@0 3350 __ get_cpool_and_tags(Rscratch, G3_scratch);
aoqi@0 3351 // make sure the class we're about to instantiate has been resolved
aoqi@0 3352 // This is done before loading InstanceKlass to be consistent with the order
aoqi@0 3353 // how Constant Pool is updated (see ConstantPool::klass_at_put)
aoqi@0 3354 __ add(G3_scratch, Array<u1>::base_offset_in_bytes(), G3_scratch);
aoqi@0 3355 __ ldub(G3_scratch, Roffset, G3_scratch);
aoqi@0 3356 __ cmp(G3_scratch, JVM_CONSTANT_Class);
aoqi@0 3357 __ br(Assembler::notEqual, false, Assembler::pn, slow_case);
aoqi@0 3358 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset);
aoqi@0 3359 // get InstanceKlass
aoqi@0 3360 //__ sll(Roffset, LogBytesPerWord, Roffset); // executed in delay slot
aoqi@0 3361 __ add(Roffset, sizeof(ConstantPool), Roffset);
aoqi@0 3362 __ ld_ptr(Rscratch, Roffset, RinstanceKlass);
aoqi@0 3363
aoqi@0 3364 // make sure klass is fully initialized:
aoqi@0 3365 __ ldub(RinstanceKlass, in_bytes(InstanceKlass::init_state_offset()), G3_scratch);
aoqi@0 3366 __ cmp(G3_scratch, InstanceKlass::fully_initialized);
aoqi@0 3367 __ br(Assembler::notEqual, false, Assembler::pn, slow_case);
aoqi@0 3368 __ delayed()->ld(RinstanceKlass, in_bytes(Klass::layout_helper_offset()), Roffset);
aoqi@0 3369
aoqi@0 3370 // get instance_size in InstanceKlass (already aligned)
aoqi@0 3371 //__ ld(RinstanceKlass, in_bytes(Klass::layout_helper_offset()), Roffset);
aoqi@0 3372
aoqi@0 3373 // make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class
aoqi@0 3374 __ btst(Klass::_lh_instance_slow_path_bit, Roffset);
aoqi@0 3375 __ br(Assembler::notZero, false, Assembler::pn, slow_case);
aoqi@0 3376 __ delayed()->nop();
aoqi@0 3377
aoqi@0 3378 // allocate the instance
aoqi@0 3379 // 1) Try to allocate in the TLAB
aoqi@0 3380 // 2) if fail, and the TLAB is not full enough to discard, allocate in the shared Eden
aoqi@0 3381 // 3) if the above fails (or is not applicable), go to a slow case
aoqi@0 3382 // (creates a new TLAB, etc.)
aoqi@0 3383
aoqi@0 3384 const bool allow_shared_alloc =
aoqi@0 3385 Universe::heap()->supports_inline_contig_alloc() && !CMSIncrementalMode;
aoqi@0 3386
aoqi@0 3387 if(UseTLAB) {
aoqi@0 3388 Register RoldTopValue = RallocatedObject;
aoqi@0 3389 Register RtlabWasteLimitValue = G3_scratch;
aoqi@0 3390 Register RnewTopValue = G1_scratch;
aoqi@0 3391 Register RendValue = Rscratch;
aoqi@0 3392 Register RfreeValue = RnewTopValue;
aoqi@0 3393
aoqi@0 3394 // check if we can allocate in the TLAB
aoqi@0 3395 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_top_offset()), RoldTopValue); // sets up RalocatedObject
aoqi@0 3396 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_end_offset()), RendValue);
aoqi@0 3397 __ add(RoldTopValue, Roffset, RnewTopValue);
aoqi@0 3398
aoqi@0 3399 // if there is enough space, we do not CAS and do not clear
aoqi@0 3400 __ cmp(RnewTopValue, RendValue);
aoqi@0 3401 if(ZeroTLAB) {
aoqi@0 3402 // the fields have already been cleared
aoqi@0 3403 __ brx(Assembler::lessEqualUnsigned, true, Assembler::pt, initialize_header);
aoqi@0 3404 } else {
aoqi@0 3405 // initialize both the header and fields
aoqi@0 3406 __ brx(Assembler::lessEqualUnsigned, true, Assembler::pt, initialize_object);
aoqi@0 3407 }
aoqi@0 3408 __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
aoqi@0 3409
aoqi@0 3410 if (allow_shared_alloc) {
aoqi@0 3411 // Check if tlab should be discarded (refill_waste_limit >= free)
aoqi@0 3412 __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue);
aoqi@0 3413 __ sub(RendValue, RoldTopValue, RfreeValue);
aoqi@0 3414 #ifdef _LP64
aoqi@0 3415 __ srlx(RfreeValue, LogHeapWordSize, RfreeValue);
aoqi@0 3416 #else
aoqi@0 3417 __ srl(RfreeValue, LogHeapWordSize, RfreeValue);
aoqi@0 3418 #endif
aoqi@0 3419 __ cmp_and_brx_short(RtlabWasteLimitValue, RfreeValue, Assembler::greaterEqualUnsigned, Assembler::pt, slow_case); // tlab waste is small
aoqi@0 3420
aoqi@0 3421 // increment waste limit to prevent getting stuck on this slow path
aoqi@0 3422 __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
aoqi@0 3423 __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
aoqi@0 3424 } else {
aoqi@0 3425 // No allocation in the shared eden.
aoqi@0 3426 __ ba_short(slow_case);
aoqi@0 3427 }
aoqi@0 3428 }
aoqi@0 3429
aoqi@0 3430 // Allocation in the shared Eden
aoqi@0 3431 if (allow_shared_alloc) {
aoqi@0 3432 Register RoldTopValue = G1_scratch;
aoqi@0 3433 Register RtopAddr = G3_scratch;
aoqi@0 3434 Register RnewTopValue = RallocatedObject;
aoqi@0 3435 Register RendValue = Rscratch;
aoqi@0 3436
aoqi@0 3437 __ set((intptr_t)Universe::heap()->top_addr(), RtopAddr);
aoqi@0 3438
aoqi@0 3439 Label retry;
aoqi@0 3440 __ bind(retry);
aoqi@0 3441 __ set((intptr_t)Universe::heap()->end_addr(), RendValue);
aoqi@0 3442 __ ld_ptr(RendValue, 0, RendValue);
aoqi@0 3443 __ ld_ptr(RtopAddr, 0, RoldTopValue);
aoqi@0 3444 __ add(RoldTopValue, Roffset, RnewTopValue);
aoqi@0 3445
aoqi@0 3446 // RnewTopValue contains the top address after the new object
aoqi@0 3447 // has been allocated.
aoqi@0 3448 __ cmp_and_brx_short(RnewTopValue, RendValue, Assembler::greaterUnsigned, Assembler::pn, slow_case);
aoqi@0 3449
aoqi@0 3450 __ cas_ptr(RtopAddr, RoldTopValue, RnewTopValue);
aoqi@0 3451
aoqi@0 3452 // if someone beat us on the allocation, try again, otherwise continue
aoqi@0 3453 __ cmp_and_brx_short(RoldTopValue, RnewTopValue, Assembler::notEqual, Assembler::pn, retry);
aoqi@0 3454
aoqi@0 3455 // bump total bytes allocated by this thread
aoqi@0 3456 // RoldTopValue and RtopAddr are dead, so can use G1 and G3
aoqi@0 3457 __ incr_allocated_bytes(Roffset, G1_scratch, G3_scratch);
aoqi@0 3458 }
aoqi@0 3459
aoqi@0 3460 if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
aoqi@0 3461 // clear object fields
aoqi@0 3462 __ bind(initialize_object);
aoqi@0 3463 __ deccc(Roffset, sizeof(oopDesc));
aoqi@0 3464 __ br(Assembler::zero, false, Assembler::pt, initialize_header);
aoqi@0 3465 __ delayed()->add(RallocatedObject, sizeof(oopDesc), G3_scratch);
aoqi@0 3466
aoqi@0 3467 // initialize remaining object fields
aoqi@0 3468 if (UseBlockZeroing) {
aoqi@0 3469 // Use BIS for zeroing
aoqi@0 3470 __ bis_zeroing(G3_scratch, Roffset, G1_scratch, initialize_header);
aoqi@0 3471 } else {
aoqi@0 3472 Label loop;
aoqi@0 3473 __ subcc(Roffset, wordSize, Roffset);
aoqi@0 3474 __ bind(loop);
aoqi@0 3475 //__ subcc(Roffset, wordSize, Roffset); // executed above loop or in delay slot
aoqi@0 3476 __ st_ptr(G0, G3_scratch, Roffset);
aoqi@0 3477 __ br(Assembler::notEqual, false, Assembler::pt, loop);
aoqi@0 3478 __ delayed()->subcc(Roffset, wordSize, Roffset);
aoqi@0 3479 }
aoqi@0 3480 __ ba_short(initialize_header);
aoqi@0 3481 }
aoqi@0 3482
aoqi@0 3483 // slow case
aoqi@0 3484 __ bind(slow_case);
aoqi@0 3485 __ get_2_byte_integer_at_bcp(1, G3_scratch, O2, InterpreterMacroAssembler::Unsigned);
aoqi@0 3486 __ get_constant_pool(O1);
aoqi@0 3487
aoqi@0 3488 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), O1, O2);
aoqi@0 3489
aoqi@0 3490 __ ba_short(done);
aoqi@0 3491
aoqi@0 3492 // Initialize the header: mark, klass
aoqi@0 3493 __ bind(initialize_header);
aoqi@0 3494
aoqi@0 3495 if (UseBiasedLocking) {
aoqi@0 3496 __ ld_ptr(RinstanceKlass, in_bytes(Klass::prototype_header_offset()), G4_scratch);
aoqi@0 3497 } else {
aoqi@0 3498 __ set((intptr_t)markOopDesc::prototype(), G4_scratch);
aoqi@0 3499 }
aoqi@0 3500 __ st_ptr(G4_scratch, RallocatedObject, oopDesc::mark_offset_in_bytes()); // mark
aoqi@0 3501 __ store_klass_gap(G0, RallocatedObject); // klass gap if compressed
aoqi@0 3502 __ store_klass(RinstanceKlass, RallocatedObject); // klass (last for cms)
aoqi@0 3503
aoqi@0 3504 {
aoqi@0 3505 SkipIfEqual skip_if(
aoqi@0 3506 _masm, G4_scratch, &DTraceAllocProbes, Assembler::zero);
aoqi@0 3507 // Trigger dtrace event
aoqi@0 3508 __ push(atos);
aoqi@0 3509 __ call_VM_leaf(noreg,
aoqi@0 3510 CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc), O0);
aoqi@0 3511 __ pop(atos);
aoqi@0 3512 }
aoqi@0 3513
aoqi@0 3514 // continue
aoqi@0 3515 __ bind(done);
aoqi@0 3516 }
aoqi@0 3517
aoqi@0 3518
aoqi@0 3519
aoqi@0 3520 void TemplateTable::newarray() {
aoqi@0 3521 transition(itos, atos);
aoqi@0 3522 __ ldub(Lbcp, 1, O1);
aoqi@0 3523 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), O1, Otos_i);
aoqi@0 3524 }
aoqi@0 3525
aoqi@0 3526
aoqi@0 3527 void TemplateTable::anewarray() {
aoqi@0 3528 transition(itos, atos);
aoqi@0 3529 __ get_constant_pool(O1);
aoqi@0 3530 __ get_2_byte_integer_at_bcp(1, G4_scratch, O2, InterpreterMacroAssembler::Unsigned);
aoqi@0 3531 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), O1, O2, Otos_i);
aoqi@0 3532 }
aoqi@0 3533
aoqi@0 3534
aoqi@0 3535 void TemplateTable::arraylength() {
aoqi@0 3536 transition(atos, itos);
aoqi@0 3537 Label ok;
aoqi@0 3538 __ verify_oop(Otos_i);
aoqi@0 3539 __ tst(Otos_i);
aoqi@0 3540 __ throw_if_not_1_x( Assembler::notZero, ok );
aoqi@0 3541 __ delayed()->ld(Otos_i, arrayOopDesc::length_offset_in_bytes(), Otos_i);
aoqi@0 3542 __ throw_if_not_2( Interpreter::_throw_NullPointerException_entry, G3_scratch, ok);
aoqi@0 3543 }
aoqi@0 3544
aoqi@0 3545
aoqi@0 3546 void TemplateTable::checkcast() {
aoqi@0 3547 transition(atos, atos);
aoqi@0 3548 Label done, is_null, quicked, cast_ok, resolved;
aoqi@0 3549 Register Roffset = G1_scratch;
aoqi@0 3550 Register RobjKlass = O5;
aoqi@0 3551 Register RspecifiedKlass = O4;
aoqi@0 3552
aoqi@0 3553 // Check for casting a NULL
aoqi@0 3554 __ br_null_short(Otos_i, Assembler::pn, is_null);
aoqi@0 3555
aoqi@0 3556 // Get value klass in RobjKlass
aoqi@0 3557 __ load_klass(Otos_i, RobjKlass); // get value klass
aoqi@0 3558
aoqi@0 3559 // Get constant pool tag
aoqi@0 3560 __ get_2_byte_integer_at_bcp(1, Lscratch, Roffset, InterpreterMacroAssembler::Unsigned);
aoqi@0 3561
aoqi@0 3562 // See if the checkcast has been quickened
aoqi@0 3563 __ get_cpool_and_tags(Lscratch, G3_scratch);
aoqi@0 3564 __ add(G3_scratch, Array<u1>::base_offset_in_bytes(), G3_scratch);
aoqi@0 3565 __ ldub(G3_scratch, Roffset, G3_scratch);
aoqi@0 3566 __ cmp(G3_scratch, JVM_CONSTANT_Class);
aoqi@0 3567 __ br(Assembler::equal, true, Assembler::pt, quicked);
aoqi@0 3568 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset);
aoqi@0 3569
aoqi@0 3570 __ push_ptr(); // save receiver for result, and for GC
aoqi@0 3571 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) );
aoqi@0 3572 __ get_vm_result_2(RspecifiedKlass);
aoqi@0 3573 __ pop_ptr(Otos_i, G3_scratch); // restore receiver
aoqi@0 3574
aoqi@0 3575 __ ba_short(resolved);
aoqi@0 3576
aoqi@0 3577 // Extract target class from constant pool
aoqi@0 3578 __ bind(quicked);
aoqi@0 3579 __ add(Roffset, sizeof(ConstantPool), Roffset);
aoqi@0 3580 __ ld_ptr(Lscratch, Roffset, RspecifiedKlass);
aoqi@0 3581 __ bind(resolved);
aoqi@0 3582 __ load_klass(Otos_i, RobjKlass); // get value klass
aoqi@0 3583
aoqi@0 3584 // Generate a fast subtype check. Branch to cast_ok if no
aoqi@0 3585 // failure. Throw exception if failure.
aoqi@0 3586 __ gen_subtype_check( RobjKlass, RspecifiedKlass, G3_scratch, G4_scratch, G1_scratch, cast_ok );
aoqi@0 3587
aoqi@0 3588 // Not a subtype; so must throw exception
aoqi@0 3589 __ throw_if_not_x( Assembler::never, Interpreter::_throw_ClassCastException_entry, G3_scratch );
aoqi@0 3590
aoqi@0 3591 __ bind(cast_ok);
aoqi@0 3592
aoqi@0 3593 if (ProfileInterpreter) {
aoqi@0 3594 __ ba_short(done);
aoqi@0 3595 }
aoqi@0 3596 __ bind(is_null);
aoqi@0 3597 __ profile_null_seen(G3_scratch);
aoqi@0 3598 __ bind(done);
aoqi@0 3599 }
aoqi@0 3600
aoqi@0 3601
aoqi@0 3602 void TemplateTable::instanceof() {
aoqi@0 3603 Label done, is_null, quicked, resolved;
aoqi@0 3604 transition(atos, itos);
aoqi@0 3605 Register Roffset = G1_scratch;
aoqi@0 3606 Register RobjKlass = O5;
aoqi@0 3607 Register RspecifiedKlass = O4;
aoqi@0 3608
aoqi@0 3609 // Check for casting a NULL
aoqi@0 3610 __ br_null_short(Otos_i, Assembler::pt, is_null);
aoqi@0 3611
aoqi@0 3612 // Get value klass in RobjKlass
aoqi@0 3613 __ load_klass(Otos_i, RobjKlass); // get value klass
aoqi@0 3614
aoqi@0 3615 // Get constant pool tag
aoqi@0 3616 __ get_2_byte_integer_at_bcp(1, Lscratch, Roffset, InterpreterMacroAssembler::Unsigned);
aoqi@0 3617
aoqi@0 3618 // See if the checkcast has been quickened
aoqi@0 3619 __ get_cpool_and_tags(Lscratch, G3_scratch);
aoqi@0 3620 __ add(G3_scratch, Array<u1>::base_offset_in_bytes(), G3_scratch);
aoqi@0 3621 __ ldub(G3_scratch, Roffset, G3_scratch);
aoqi@0 3622 __ cmp(G3_scratch, JVM_CONSTANT_Class);
aoqi@0 3623 __ br(Assembler::equal, true, Assembler::pt, quicked);
aoqi@0 3624 __ delayed()->sll(Roffset, LogBytesPerWord, Roffset);
aoqi@0 3625
aoqi@0 3626 __ push_ptr(); // save receiver for result, and for GC
aoqi@0 3627 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc) );
aoqi@0 3628 __ get_vm_result_2(RspecifiedKlass);
aoqi@0 3629 __ pop_ptr(Otos_i, G3_scratch); // restore receiver
aoqi@0 3630
aoqi@0 3631 __ ba_short(resolved);
aoqi@0 3632
aoqi@0 3633 // Extract target class from constant pool
aoqi@0 3634 __ bind(quicked);
aoqi@0 3635 __ add(Roffset, sizeof(ConstantPool), Roffset);
aoqi@0 3636 __ get_constant_pool(Lscratch);
aoqi@0 3637 __ ld_ptr(Lscratch, Roffset, RspecifiedKlass);
aoqi@0 3638 __ bind(resolved);
aoqi@0 3639 __ load_klass(Otos_i, RobjKlass); // get value klass
aoqi@0 3640
aoqi@0 3641 // Generate a fast subtype check. Branch to cast_ok if no
aoqi@0 3642 // failure. Return 0 if failure.
aoqi@0 3643 __ or3(G0, 1, Otos_i); // set result assuming quick tests succeed
aoqi@0 3644 __ gen_subtype_check( RobjKlass, RspecifiedKlass, G3_scratch, G4_scratch, G1_scratch, done );
aoqi@0 3645 // Not a subtype; return 0;
aoqi@0 3646 __ clr( Otos_i );
aoqi@0 3647
aoqi@0 3648 if (ProfileInterpreter) {
aoqi@0 3649 __ ba_short(done);
aoqi@0 3650 }
aoqi@0 3651 __ bind(is_null);
aoqi@0 3652 __ profile_null_seen(G3_scratch);
aoqi@0 3653 __ bind(done);
aoqi@0 3654 }
aoqi@0 3655
aoqi@0 3656 void TemplateTable::_breakpoint() {
aoqi@0 3657
aoqi@0 3658 // Note: We get here even if we are single stepping..
aoqi@0 3659 // jbug inists on setting breakpoints at every bytecode
aoqi@0 3660 // even if we are in single step mode.
aoqi@0 3661
aoqi@0 3662 transition(vtos, vtos);
aoqi@0 3663 // get the unpatched byte code
aoqi@0 3664 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::get_original_bytecode_at), Lmethod, Lbcp);
aoqi@0 3665 __ mov(O0, Lbyte_code);
aoqi@0 3666
aoqi@0 3667 // post the breakpoint event
aoqi@0 3668 __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), Lmethod, Lbcp);
aoqi@0 3669
aoqi@0 3670 // complete the execution of original bytecode
aoqi@0 3671 __ dispatch_normal(vtos);
aoqi@0 3672 }
aoqi@0 3673
aoqi@0 3674
aoqi@0 3675 //----------------------------------------------------------------------------------------------------
aoqi@0 3676 // Exceptions
aoqi@0 3677
aoqi@0 3678 void TemplateTable::athrow() {
aoqi@0 3679 transition(atos, vtos);
aoqi@0 3680
aoqi@0 3681 // This works because exception is cached in Otos_i which is same as O0,
aoqi@0 3682 // which is same as what throw_exception_entry_expects
aoqi@0 3683 assert(Otos_i == Oexception, "see explanation above");
aoqi@0 3684
aoqi@0 3685 __ verify_oop(Otos_i);
aoqi@0 3686 __ null_check(Otos_i);
aoqi@0 3687 __ throw_if_not_x(Assembler::never, Interpreter::throw_exception_entry(), G3_scratch);
aoqi@0 3688 }
aoqi@0 3689
aoqi@0 3690
aoqi@0 3691 //----------------------------------------------------------------------------------------------------
aoqi@0 3692 // Synchronization
aoqi@0 3693
aoqi@0 3694
aoqi@0 3695 // See frame_sparc.hpp for monitor block layout.
aoqi@0 3696 // Monitor elements are dynamically allocated by growing stack as needed.
aoqi@0 3697
aoqi@0 3698 void TemplateTable::monitorenter() {
aoqi@0 3699 transition(atos, vtos);
aoqi@0 3700 __ verify_oop(Otos_i);
aoqi@0 3701 // Try to acquire a lock on the object
aoqi@0 3702 // Repeat until succeeded (i.e., until
aoqi@0 3703 // monitorenter returns true).
aoqi@0 3704
aoqi@0 3705 { Label ok;
aoqi@0 3706 __ tst(Otos_i);
aoqi@0 3707 __ throw_if_not_1_x( Assembler::notZero, ok);
aoqi@0 3708 __ delayed()->mov(Otos_i, Lscratch); // save obj
aoqi@0 3709 __ throw_if_not_2( Interpreter::_throw_NullPointerException_entry, G3_scratch, ok);
aoqi@0 3710 }
aoqi@0 3711
aoqi@0 3712 assert(O0 == Otos_i, "Be sure where the object to lock is");
aoqi@0 3713
aoqi@0 3714 // find a free slot in the monitor block
aoqi@0 3715
aoqi@0 3716
aoqi@0 3717 // initialize entry pointer
aoqi@0 3718 __ clr(O1); // points to free slot or NULL
aoqi@0 3719
aoqi@0 3720 {
aoqi@0 3721 Label entry, loop, exit;
aoqi@0 3722 __ add( __ top_most_monitor(), O2 ); // last one to check
aoqi@0 3723 __ ba( entry );
aoqi@0 3724 __ delayed()->mov( Lmonitors, O3 ); // first one to check
aoqi@0 3725
aoqi@0 3726
aoqi@0 3727 __ bind( loop );
aoqi@0 3728
aoqi@0 3729 __ verify_oop(O4); // verify each monitor's oop
aoqi@0 3730 __ tst(O4); // is this entry unused?
aoqi@0 3731 __ movcc( Assembler::zero, false, Assembler::ptr_cc, O3, O1);
aoqi@0 3732
aoqi@0 3733 __ cmp(O4, O0); // check if current entry is for same object
aoqi@0 3734 __ brx( Assembler::equal, false, Assembler::pn, exit );
aoqi@0 3735 __ delayed()->inc( O3, frame::interpreter_frame_monitor_size() * wordSize ); // check next one
aoqi@0 3736
aoqi@0 3737 __ bind( entry );
aoqi@0 3738
aoqi@0 3739 __ cmp( O3, O2 );
aoqi@0 3740 __ brx( Assembler::lessEqualUnsigned, true, Assembler::pt, loop );
aoqi@0 3741 __ delayed()->ld_ptr(O3, BasicObjectLock::obj_offset_in_bytes(), O4);
aoqi@0 3742
aoqi@0 3743 __ bind( exit );
aoqi@0 3744 }
aoqi@0 3745
aoqi@0 3746 { Label allocated;
aoqi@0 3747
aoqi@0 3748 // found free slot?
aoqi@0 3749 __ br_notnull_short(O1, Assembler::pn, allocated);
aoqi@0 3750
aoqi@0 3751 __ add_monitor_to_stack( false, O2, O3 );
aoqi@0 3752 __ mov(Lmonitors, O1);
aoqi@0 3753
aoqi@0 3754 __ bind(allocated);
aoqi@0 3755 }
aoqi@0 3756
aoqi@0 3757 // Increment bcp to point to the next bytecode, so exception handling for async. exceptions work correctly.
aoqi@0 3758 // The object has already been poped from the stack, so the expression stack looks correct.
aoqi@0 3759 __ inc(Lbcp);
aoqi@0 3760
aoqi@0 3761 __ st_ptr(O0, O1, BasicObjectLock::obj_offset_in_bytes()); // store object
aoqi@0 3762 __ lock_object(O1, O0);
aoqi@0 3763
aoqi@0 3764 // check if there's enough space on the stack for the monitors after locking
aoqi@0 3765 __ generate_stack_overflow_check(0);
aoqi@0 3766
aoqi@0 3767 // The bcp has already been incremented. Just need to dispatch to next instruction.
aoqi@0 3768 __ dispatch_next(vtos);
aoqi@0 3769 }
aoqi@0 3770
aoqi@0 3771
aoqi@0 3772 void TemplateTable::monitorexit() {
aoqi@0 3773 transition(atos, vtos);
aoqi@0 3774 __ verify_oop(Otos_i);
aoqi@0 3775 __ tst(Otos_i);
aoqi@0 3776 __ throw_if_not_x( Assembler::notZero, Interpreter::_throw_NullPointerException_entry, G3_scratch );
aoqi@0 3777
aoqi@0 3778 assert(O0 == Otos_i, "just checking");
aoqi@0 3779
aoqi@0 3780 { Label entry, loop, found;
aoqi@0 3781 __ add( __ top_most_monitor(), O2 ); // last one to check
aoqi@0 3782 __ ba(entry);
aoqi@0 3783 // use Lscratch to hold monitor elem to check, start with most recent monitor,
aoqi@0 3784 // By using a local it survives the call to the C routine.
aoqi@0 3785 __ delayed()->mov( Lmonitors, Lscratch );
aoqi@0 3786
aoqi@0 3787 __ bind( loop );
aoqi@0 3788
aoqi@0 3789 __ verify_oop(O4); // verify each monitor's oop
aoqi@0 3790 __ cmp(O4, O0); // check if current entry is for desired object
aoqi@0 3791 __ brx( Assembler::equal, true, Assembler::pt, found );
aoqi@0 3792 __ delayed()->mov(Lscratch, O1); // pass found entry as argument to monitorexit
aoqi@0 3793
aoqi@0 3794 __ inc( Lscratch, frame::interpreter_frame_monitor_size() * wordSize ); // advance to next
aoqi@0 3795
aoqi@0 3796 __ bind( entry );
aoqi@0 3797
aoqi@0 3798 __ cmp( Lscratch, O2 );
aoqi@0 3799 __ brx( Assembler::lessEqualUnsigned, true, Assembler::pt, loop );
aoqi@0 3800 __ delayed()->ld_ptr(Lscratch, BasicObjectLock::obj_offset_in_bytes(), O4);
aoqi@0 3801
aoqi@0 3802 call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
aoqi@0 3803 __ should_not_reach_here();
aoqi@0 3804
aoqi@0 3805 __ bind(found);
aoqi@0 3806 }
aoqi@0 3807 __ unlock_object(O1);
aoqi@0 3808 }
aoqi@0 3809
aoqi@0 3810
aoqi@0 3811 //----------------------------------------------------------------------------------------------------
aoqi@0 3812 // Wide instructions
aoqi@0 3813
aoqi@0 3814 void TemplateTable::wide() {
aoqi@0 3815 transition(vtos, vtos);
aoqi@0 3816 __ ldub(Lbcp, 1, G3_scratch);// get next bc
aoqi@0 3817 __ sll(G3_scratch, LogBytesPerWord, G3_scratch);
aoqi@0 3818 AddressLiteral ep(Interpreter::_wentry_point);
aoqi@0 3819 __ set(ep, G4_scratch);
aoqi@0 3820 __ ld_ptr(G4_scratch, G3_scratch, G3_scratch);
aoqi@0 3821 __ jmp(G3_scratch, G0);
aoqi@0 3822 __ delayed()->nop();
aoqi@0 3823 // Note: the Lbcp increment step is part of the individual wide bytecode implementations
aoqi@0 3824 }
aoqi@0 3825
aoqi@0 3826
aoqi@0 3827 //----------------------------------------------------------------------------------------------------
aoqi@0 3828 // Multi arrays
aoqi@0 3829
aoqi@0 3830 void TemplateTable::multianewarray() {
aoqi@0 3831 transition(vtos, atos);
aoqi@0 3832 // put ndims * wordSize into Lscratch
aoqi@0 3833 __ ldub( Lbcp, 3, Lscratch);
aoqi@0 3834 __ sll( Lscratch, Interpreter::logStackElementSize, Lscratch);
aoqi@0 3835 // Lesp points past last_dim, so set to O1 to first_dim address
aoqi@0 3836 __ add( Lesp, Lscratch, O1);
aoqi@0 3837 call_VM(Otos_i, CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), O1);
aoqi@0 3838 __ add( Lesp, Lscratch, Lesp); // pop all dimensions off the stack
aoqi@0 3839 }
aoqi@0 3840 #endif /* !CC_INTERP */

mercurial