src/cpu/sparc/vm/templateTable_sparc.cpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial