src/hotspot/cpu/ppc/templateTable_ppc_64.cpp
author shade
Tue, 10 Apr 2018 11:14:50 +0200
branchepsilon-gc-branch
changeset 56406 e629240491c7
parent 56348 f3b0961adb3c
parent 49480 d7df2dd501ce
child 56448 76d86de267b9
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     1
/*
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 48965
diff changeset
     2
 * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 42068
diff changeset
     3
 * Copyright (c) 2013, 2017 SAP SE. All rights reserved.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     5
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
     9
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    14
 * accompanied this code).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    15
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    19
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    22
 * questions.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    23
 *
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    24
 */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    25
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    26
#include "precompiled.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    28
#include "interpreter/interpreter.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    29
#include "interpreter/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24349
diff changeset
    30
#include "interpreter/interp_masm.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    31
#include "interpreter/templateInterpreter.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    32
#include "interpreter/templateTable.hpp"
49359
59f6547e151f 8199264: Remove universe.inline.hpp to simplify include dependencies
stefank
parents: 49347
diff changeset
    33
#include "memory/universe.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    34
#include "oops/objArrayKlass.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    35
#include "oops/oop.inline.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    36
#include "prims/methodHandles.hpp"
49480
d7df2dd501ce 8199809: Don't include frame.inline.hpp and other.inline.hpp from .hpp files
coleenp
parents: 49455
diff changeset
    37
#include "runtime/frame.inline.hpp"
49449
ef5d5d343e2a 8199263: Split interfaceSupport.hpp to not require including .inline.hpp files
coleenp
parents: 49368
diff changeset
    38
#include "runtime/safepointMechanism.hpp"
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    39
#include "runtime/sharedRuntime.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    40
#include "runtime/stubRoutines.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    41
#include "runtime/synchronizer.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    42
#include "utilities/macros.hpp"
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    43
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    44
#undef __
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    45
#define __ _masm->
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    46
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    47
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    48
// Misc helpers
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    49
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    50
// Do an oop store like *(base + index) = val OR *(base + offset) = val
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    51
// (only one of both variants is possible at the same time).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    52
// Index can be noreg.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    53
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    54
//   Rbase, Rtmp
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    55
static void do_oop_store(InterpreterMacroAssembler* _masm,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    56
                         Register           Rbase,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    57
                         RegisterOrConstant offset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    58
                         Register           Rval,         // Noreg means always null.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    59
                         Register           Rtmp1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    60
                         Register           Rtmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    61
                         Register           Rtmp3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    62
                         BarrierSet::Name   barrier,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    63
                         bool               precise,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    64
                         bool               check_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    65
  assert_different_registers(Rtmp1, Rtmp2, Rtmp3, Rval, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    66
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    67
  switch (barrier) {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
    68
#if INCLUDE_ALL_GCS
49347
edb65305d3ac 8195148: Collapse G1SATBCardTableModRefBS and G1SATBCardTableLoggingModRefBS into a single G1BarrierSet
eosterlund
parents: 49164
diff changeset
    69
    case BarrierSet::G1BarrierSet:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    70
      {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    71
        // Load and record the previous value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    72
        __ g1_write_barrier_pre(Rbase, offset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    73
                                Rtmp3, /* holder of pre_val ? */
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    74
                                Rtmp1, Rtmp2, false /* frame */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    75
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    76
        Label Lnull, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    77
        if (Rval != noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    78
          if (check_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    79
            __ cmpdi(CCR0, Rval, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    80
            __ beq(CCR0, Lnull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    81
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    82
          __ store_heap_oop_not_null(Rval, offset, Rbase, /*Rval must stay uncompressed.*/ Rtmp1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    83
          // Mark the card.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    84
          if (!(offset.is_constant() && offset.as_constant() == 0) && precise) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    85
            __ add(Rbase, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    86
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    87
          __ g1_write_barrier_post(Rbase, Rval, Rtmp1, Rtmp2, Rtmp3, /*filtered (fast path)*/ &Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    88
          if (check_null) { __ b(Ldone); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    89
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    90
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    91
        if (Rval == noreg || check_null) { // Store null oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    92
          Register Rnull = Rval;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    93
          __ bind(Lnull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    94
          if (Rval == noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    95
            Rnull = Rtmp1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    96
            __ li(Rnull, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    97
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    98
          if (UseCompressedOops) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
    99
            __ stw(Rnull, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   100
          } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   101
            __ std(Rnull, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   102
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   103
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   104
        __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   105
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   106
      break;
56279
a4fc9b609b82 Make sure Epsilon barriers are under INCLUDE_ALL_GCS
shade
parents: 56276
diff changeset
   107
    case BarrierSet::Epsilon:
a4fc9b609b82 Make sure Epsilon barriers are under INCLUDE_ALL_GCS
shade
parents: 56276
diff changeset
   108
      Unimplemented(); // Should look like CardTableModRef without card marks?
a4fc9b609b82 Make sure Epsilon barriers are under INCLUDE_ALL_GCS
shade
parents: 56276
diff changeset
   109
      break;
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   110
#endif // INCLUDE_ALL_GCS
49455
848864ed9b17 8199604: Rename CardTableModRefBS to CardTableBarrierSet
eosterlund
parents: 49449
diff changeset
   111
    case BarrierSet::CardTableBarrierSet:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   112
      {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   113
        Label Lnull, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   114
        if (Rval != noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   115
          if (check_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   116
            __ cmpdi(CCR0, Rval, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   117
            __ beq(CCR0, Lnull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   118
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   119
          __ store_heap_oop_not_null(Rval, offset, Rbase, /*Rval should better stay uncompressed.*/ Rtmp1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   120
          // Mark the card.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   121
          if (!(offset.is_constant() && offset.as_constant() == 0) && precise) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   122
            __ add(Rbase, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   123
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   124
          __ card_write_barrier_post(Rbase, Rval, Rtmp1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   125
          if (check_null) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   126
            __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   127
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   128
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   129
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   130
        if (Rval == noreg || check_null) { // Store null oop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   131
          Register Rnull = Rval;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   132
          __ bind(Lnull);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   133
          if (Rval == noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   134
            Rnull = Rtmp1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   135
            __ li(Rnull, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   136
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   137
          if (UseCompressedOops) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   138
            __ stw(Rnull, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   139
          } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   140
            __ std(Rnull, offset, Rbase);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   141
          }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   142
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   143
        __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   144
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   145
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   146
    case BarrierSet::ModRef:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   147
      ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   148
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   149
    default:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   150
      ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   151
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   152
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   153
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   154
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   155
// Platform-dependent initialization
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   156
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   157
void TemplateTable::pd_initialize() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   158
  // No ppc64 specific initialization.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   159
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   160
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   161
Address TemplateTable::at_bcp(int offset) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   162
  // Not used on ppc.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   163
  ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   164
  return Address();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   165
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   166
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   167
// Patches the current bytecode (ptr to it located in bcp)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   168
// in the bytecode stream with a new one.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   169
void TemplateTable::patch_bytecode(Bytecodes::Code new_bc, Register Rnew_bc, Register Rtemp, bool load_bc_into_bc_reg /*=true*/, int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   170
  // With sharing on, may need to test method flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   171
  if (!RewriteBytecodes) return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   172
  Label L_patch_done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   173
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   174
  switch (new_bc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   175
    case Bytecodes::_fast_aputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   176
    case Bytecodes::_fast_bputfield:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
   177
    case Bytecodes::_fast_zputfield:
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   178
    case Bytecodes::_fast_cputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   179
    case Bytecodes::_fast_dputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   180
    case Bytecodes::_fast_fputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   181
    case Bytecodes::_fast_iputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   182
    case Bytecodes::_fast_lputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   183
    case Bytecodes::_fast_sputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   184
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   185
      // We skip bytecode quickening for putfield instructions when
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   186
      // the put_code written to the constant pool cache is zero.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   187
      // This is required so that every execution of this instruction
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   188
      // calls out to InterpreterRuntime::resolve_get_put to do
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   189
      // additional, required work.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   190
      assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   191
      assert(load_bc_into_bc_reg, "we use bc_reg as temp");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   192
      __ get_cache_and_index_at_bcp(Rtemp /* dst = cache */, 1);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   193
      // ((*(cache+indices))>>((1+byte_no)*8))&0xFF:
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   194
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   195
      __ lbz(Rnew_bc, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 1 + byte_no, Rtemp);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   196
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   197
      __ lbz(Rnew_bc, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (1 + byte_no), Rtemp);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
   198
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   199
      __ cmpwi(CCR0, Rnew_bc, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   200
      __ li(Rnew_bc, (unsigned int)(unsigned char)new_bc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   201
      __ beq(CCR0, L_patch_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   202
      // __ isync(); // acquire not needed
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   203
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   204
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   205
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   206
    default:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   207
      assert(byte_no == -1, "sanity");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   208
      if (load_bc_into_bc_reg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   209
        __ li(Rnew_bc, (unsigned int)(unsigned char)new_bc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   210
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   211
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   212
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   213
  if (JvmtiExport::can_post_breakpoint()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   214
    Label L_fast_patch;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   215
    __ lbz(Rtemp, 0, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   216
    __ cmpwi(CCR0, Rtemp, (unsigned int)(unsigned char)Bytecodes::_breakpoint);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   217
    __ bne(CCR0, L_fast_patch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   218
    // Perform the quickening, slowly, in the bowels of the breakpoint table.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   219
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::set_original_bytecode_at), R19_method, R14_bcp, Rnew_bc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   220
    __ b(L_patch_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   221
    __ bind(L_fast_patch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   222
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   223
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   224
  // Patch bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   225
  __ stb(Rnew_bc, 0, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   226
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   227
  __ bind(L_patch_done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   228
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   229
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   230
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   231
// Individual instructions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   232
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   233
void TemplateTable::nop() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   234
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   235
  // Nothing to do.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   236
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   237
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   238
void TemplateTable::shouldnotreachhere() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   239
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   240
  __ stop("shouldnotreachhere bytecode");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   241
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   242
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   243
void TemplateTable::aconst_null() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   244
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   245
  __ li(R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   246
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   247
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   248
void TemplateTable::iconst(int value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   249
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   250
  assert(value >= -1 && value <= 5, "");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   251
  __ li(R17_tos, value);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   252
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   253
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   254
void TemplateTable::lconst(int value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   255
  transition(vtos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   256
  assert(value >= -1 && value <= 5, "");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   257
  __ li(R17_tos, value);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   258
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   259
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   260
void TemplateTable::fconst(int value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   261
  transition(vtos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   262
  static float zero = 0.0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   263
  static float one  = 1.0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   264
  static float two  = 2.0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   265
  switch (value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   266
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   267
    case 0: {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   268
      int simm16_offset = __ load_const_optimized(R11_scratch1, (address*)&zero, R0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   269
      __ lfs(F15_ftos, simm16_offset, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   270
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   271
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   272
    case 1: {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   273
      int simm16_offset = __ load_const_optimized(R11_scratch1, (address*)&one, R0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   274
      __ lfs(F15_ftos, simm16_offset, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   275
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   276
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   277
    case 2: {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   278
      int simm16_offset = __ load_const_optimized(R11_scratch1, (address*)&two, R0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   279
      __ lfs(F15_ftos, simm16_offset, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   280
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   281
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   282
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   283
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   284
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   285
void TemplateTable::dconst(int value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   286
  transition(vtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   287
  static double zero = 0.0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   288
  static double one  = 1.0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   289
  switch (value) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   290
    case 0: {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   291
      int simm16_offset = __ load_const_optimized(R11_scratch1, (address*)&zero, R0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   292
      __ lfd(F15_ftos, simm16_offset, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   293
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   294
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   295
    case 1: {
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
   296
      int simm16_offset = __ load_const_optimized(R11_scratch1, (address*)&one, R0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   297
      __ lfd(F15_ftos, simm16_offset, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   298
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   299
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   300
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   301
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   302
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   303
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   304
void TemplateTable::bipush() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   305
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   306
  __ lbz(R17_tos, 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   307
  __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   308
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   309
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   310
void TemplateTable::sipush() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   311
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   312
  __ get_2_byte_integer_at_bcp(1, R17_tos, InterpreterMacroAssembler::Signed);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   313
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   314
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   315
void TemplateTable::ldc(bool wide) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   316
  Register Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   317
           Rscratch2 = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   318
           Rcpool    = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   319
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   320
  transition(vtos, vtos);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   321
  Label notInt, notFloat, notClass, exit;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   322
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   323
  __ get_cpool_and_tags(Rcpool, Rscratch2); // Set Rscratch2 = &tags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   324
  if (wide) { // Read index.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   325
    __ get_2_byte_integer_at_bcp(1, Rscratch1, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   326
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   327
    __ lbz(Rscratch1, 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   328
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   329
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   330
  const int base_offset = ConstantPool::header_size() * wordSize;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   331
  const int tags_offset = Array<u1>::base_offset_in_bytes();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   332
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   333
  // Get type from tags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   334
  __ addi(Rscratch2, Rscratch2, tags_offset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   335
  __ lbzx(Rscratch2, Rscratch2, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   336
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   337
  __ cmpwi(CCR0, Rscratch2, JVM_CONSTANT_UnresolvedClass); // Unresolved class?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   338
  __ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_UnresolvedClassInError); // Unresolved class in error state?
28492
57fecf138f7b 8068724: ppc64: update assembler: SPR access, CR logic, HTM
mdoerr
parents: 28187
diff changeset
   339
  __ cror(CCR0, Assembler::equal, CCR1, Assembler::equal);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   340
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   341
  // Resolved class - need to call vm to get java mirror of the class.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   342
  __ cmpwi(CCR1, Rscratch2, JVM_CONSTANT_Class);
28492
57fecf138f7b 8068724: ppc64: update assembler: SPR access, CR logic, HTM
mdoerr
parents: 28187
diff changeset
   343
  __ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal); // Neither resolved class nor unresolved case from above?
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   344
  __ beq(CCR0, notClass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   345
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   346
  __ li(R4, wide ? 1 : 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   347
  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::ldc), R4);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   348
  __ push(atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   349
  __ b(exit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   350
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   351
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   352
  __ bind(notClass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   353
  __ addi(Rcpool, Rcpool, base_offset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   354
  __ sldi(Rscratch1, Rscratch1, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   355
  __ cmpdi(CCR0, Rscratch2, JVM_CONSTANT_Integer);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   356
  __ bne(CCR0, notInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   357
  __ lwax(R17_tos, Rcpool, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   358
  __ push(itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   359
  __ b(exit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   360
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   361
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   362
  __ bind(notInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   363
  __ cmpdi(CCR0, Rscratch2, JVM_CONSTANT_Float);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   364
  __ bne(CCR0, notFloat);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   365
  __ lfsx(F15_ftos, Rcpool, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   366
  __ push(ftos);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   367
  __ b(exit);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   368
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   369
  __ align(32, 12);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   370
  // assume the tag is for condy; if not, the VM runtime will tell us
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   371
  __ bind(notFloat);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   372
  condy_helper(exit);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   373
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   374
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   375
  __ bind(exit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   376
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   377
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   378
// Fast path for caching oop constants.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   379
void TemplateTable::fast_aldc(bool wide) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   380
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   381
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   382
  int index_size = wide ? sizeof(u2) : sizeof(u1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   383
  const Register Rscratch = R11_scratch1;
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   384
  Label is_null;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   385
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   386
  // We are resolved if the resolved reference cache entry contains a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   387
  // non-null object (CallSite, etc.)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   388
  __ get_cache_index_at_bcp(Rscratch, 1, index_size);  // Load index.
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   389
  __ load_resolved_reference_at_index(R17_tos, Rscratch, &is_null);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   390
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   391
  // Convert null sentinel to NULL.
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   392
  int simm16_rest = __ load_const_optimized(Rscratch, Universe::the_null_sentinel_addr(), R0, true);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   393
  __ ld(Rscratch, simm16_rest, Rscratch);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   394
  __ cmpld(CCR0, R17_tos, Rscratch);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   395
  if (VM_Version::has_isel()) {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   396
    __ isel_0(R17_tos, CCR0, Assembler::equal);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   397
  } else {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   398
    Label not_sentinel;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   399
    __ bne(CCR0, not_sentinel);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   400
    __ li(R17_tos, 0);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   401
    __ bind(not_sentinel);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   402
  }
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   403
  __ verify_oop(R17_tos);
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   404
  __ dispatch_epilog(atos, Bytecodes::length_for(bytecode()));
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   405
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
   406
  __ bind(is_null);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   407
  __ load_const_optimized(R3_ARG1, (int)bytecode());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   408
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   409
  address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   410
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   411
  // First time invocation - must resolve first.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   412
  __ call_VM(R17_tos, entry, R3_ARG1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   413
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   414
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   415
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   416
void TemplateTable::ldc2_w() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   417
  transition(vtos, vtos);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   418
  Label not_double, not_long, exit;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   419
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   420
  Register Rindex = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   421
           Rcpool = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   422
           Rtag   = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   423
  __ get_cpool_and_tags(Rcpool, Rtag);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   424
  __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   425
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   426
  const int base_offset = ConstantPool::header_size() * wordSize;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   427
  const int tags_offset = Array<u1>::base_offset_in_bytes();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   428
  // Get type from tags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   429
  __ addi(Rcpool, Rcpool, base_offset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   430
  __ addi(Rtag, Rtag, tags_offset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   431
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   432
  __ lbzx(Rtag, Rtag, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   433
  __ sldi(Rindex, Rindex, LogBytesPerWord);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   434
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   435
  __ cmpdi(CCR0, Rtag, JVM_CONSTANT_Double);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   436
  __ bne(CCR0, not_double);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   437
  __ lfdx(F15_ftos, Rcpool, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   438
  __ push(dtos);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   439
  __ b(exit);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   440
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   441
  __ bind(not_double);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   442
  __ cmpdi(CCR0, Rtag, JVM_CONSTANT_Long);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   443
  __ bne(CCR0, not_long);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   444
  __ ldx(R17_tos, Rcpool, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   445
  __ push(ltos);
48965
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   446
  __ b(exit);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   447
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   448
  __ bind(not_long);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   449
  condy_helper(exit);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   450
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   451
  __ align(32, 12);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   452
  __ bind(exit);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   453
}
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   454
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   455
void TemplateTable::condy_helper(Label& Done) {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   456
  const Register obj   = R31;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   457
  const Register off   = R11_scratch1;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   458
  const Register flags = R12_scratch2;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   459
  const Register rarg  = R4_ARG2;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   460
  __ li(rarg, (int)bytecode());
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   461
  call_VM(obj, CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_ldc), rarg);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   462
  __ get_vm_result_2(flags);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   463
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   464
  // VMr = obj = base address to find primitive value to push
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   465
  // VMr2 = flags = (tos, off) using format of CPCE::_flags
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   466
  __ andi(off, flags, ConstantPoolCacheEntry::field_index_mask);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   467
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   468
  // What sort of thing are we loading?
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   469
  __ rldicl(flags, flags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   470
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   471
  switch (bytecode()) {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   472
  case Bytecodes::_ldc:
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   473
  case Bytecodes::_ldc_w:
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   474
    {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   475
      // tos in (itos, ftos, stos, btos, ctos, ztos)
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   476
      Label notInt, notFloat, notShort, notByte, notChar, notBool;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   477
      __ cmplwi(CCR0, flags, itos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   478
      __ bne(CCR0, notInt);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   479
      // itos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   480
      __ lwax(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   481
      __ push(itos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   482
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   483
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   484
      __ bind(notInt);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   485
      __ cmplwi(CCR0, flags, ftos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   486
      __ bne(CCR0, notFloat);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   487
      // ftos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   488
      __ lfsx(F15_ftos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   489
      __ push(ftos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   490
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   491
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   492
      __ bind(notFloat);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   493
      __ cmplwi(CCR0, flags, stos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   494
      __ bne(CCR0, notShort);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   495
      // stos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   496
      __ lhax(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   497
      __ push(stos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   498
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   499
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   500
      __ bind(notShort);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   501
      __ cmplwi(CCR0, flags, btos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   502
      __ bne(CCR0, notByte);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   503
      // btos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   504
      __ lbzx(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   505
      __ extsb(R17_tos, R17_tos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   506
      __ push(btos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   507
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   508
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   509
      __ bind(notByte);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   510
      __ cmplwi(CCR0, flags, ctos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   511
      __ bne(CCR0, notChar);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   512
      // ctos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   513
      __ lhzx(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   514
      __ push(ctos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   515
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   516
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   517
      __ bind(notChar);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   518
      __ cmplwi(CCR0, flags, ztos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   519
      __ bne(CCR0, notBool);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   520
      // ztos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   521
      __ lbzx(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   522
      __ push(ztos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   523
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   524
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   525
      __ bind(notBool);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   526
      break;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   527
    }
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   528
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   529
  case Bytecodes::_ldc2_w:
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   530
    {
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   531
      Label notLong, notDouble;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   532
      __ cmplwi(CCR0, flags, ltos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   533
      __ bne(CCR0, notLong);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   534
      // ltos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   535
      __ ldx(R17_tos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   536
      __ push(ltos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   537
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   538
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   539
      __ bind(notLong);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   540
      __ cmplwi(CCR0, flags, dtos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   541
      __ bne(CCR0, notDouble);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   542
      // dtos
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   543
      __ lfdx(F15_ftos, obj, off);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   544
      __ push(dtos);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   545
      __ b(Done);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   546
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   547
      __ bind(notDouble);
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   548
      break;
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   549
    }
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   550
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   551
  default:
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   552
    ShouldNotReachHere();
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   553
  }
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   554
be873d8c0114 8196786: [PPC64+s390] ConstantDynamic support
mdoerr
parents: 48608
diff changeset
   555
  __ stop("bad ldc/condy");
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   556
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   557
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   558
// Get the locals index located in the bytecode stream at bcp + offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   559
void TemplateTable::locals_index(Register Rdst, int offset) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   560
  __ lbz(Rdst, offset, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   561
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   562
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   563
void TemplateTable::iload() {
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   564
  iload_internal();
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   565
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   566
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   567
void TemplateTable::nofast_iload() {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   568
  iload_internal(may_not_rewrite);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   569
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   570
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   571
void TemplateTable::iload_internal(RewriteControl rc) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   572
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   573
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   574
  // Get the local value into tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   575
  const Register Rindex = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   576
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   577
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   578
  // Rewrite iload,iload  pair into fast_iload2
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   579
  //         iload,caload pair into fast_icaload
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   580
  if (RewriteFrequentPairs && rc == may_rewrite) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   581
    Label Lrewrite, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   582
    Register Rnext_byte  = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   583
             Rrewrite_to = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   584
             Rscratch    = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   585
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   586
    // get next byte
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   587
    __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_iload), R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   588
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   589
    // if _iload, wait to rewrite to iload2. We only want to rewrite the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   590
    // last two iloads in a pair. Comparing against fast_iload means that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   591
    // the next bytecode is neither an iload or a caload, and therefore
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   592
    // an iload pair.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   593
    __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_iload);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   594
    __ beq(CCR0, Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   595
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   596
    __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_iload);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   597
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iload2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   598
    __ beq(CCR1, Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   599
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   600
    __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_caload);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   601
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_icaload);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   602
    __ beq(CCR0, Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   603
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   604
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iload);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   605
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   606
    __ bind(Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   607
    patch_bytecode(Bytecodes::_iload, Rrewrite_to, Rscratch, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   608
    __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   609
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   610
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   611
  __ load_local_int(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   612
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   613
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   614
// Load 2 integers in a row without dispatching
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   615
void TemplateTable::fast_iload2() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   616
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   617
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   618
  __ lbz(R3_ARG1, 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   619
  __ lbz(R17_tos, Bytecodes::length_for(Bytecodes::_iload) + 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   620
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   621
  __ load_local_int(R3_ARG1, R11_scratch1, R3_ARG1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   622
  __ load_local_int(R17_tos, R12_scratch2, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   623
  __ push_i(R3_ARG1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   624
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   625
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   626
void TemplateTable::fast_iload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   627
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   628
  // Get the local value into tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   629
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   630
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   631
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   632
  __ load_local_int(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   633
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   634
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   635
// Load a local variable type long from locals area to TOS cache register.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   636
// Local index resides in bytecodestream.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   637
void TemplateTable::lload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   638
  transition(vtos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   639
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   640
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   641
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   642
  __ load_local_long(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   643
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   644
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   645
void TemplateTable::fload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   646
  transition(vtos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   647
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   648
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   649
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   650
  __ load_local_float(F15_ftos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   651
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   652
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   653
void TemplateTable::dload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   654
  transition(vtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   655
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   656
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   657
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   658
  __ load_local_double(F15_ftos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   659
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   660
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   661
void TemplateTable::aload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   662
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   663
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   664
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   665
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   666
  __ load_local_ptr(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   667
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   668
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   669
void TemplateTable::locals_index_wide(Register Rdst) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   670
  // Offset is 2, not 1, because Lbcp points to wide prefix code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   671
  __ get_2_byte_integer_at_bcp(2, Rdst, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   672
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   673
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   674
void TemplateTable::wide_iload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   675
  // Get the local value into tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   676
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   677
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   678
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   679
  __ load_local_int(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   680
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   681
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   682
void TemplateTable::wide_lload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   683
  transition(vtos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   684
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   685
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   686
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   687
  __ load_local_long(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   688
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   689
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   690
void TemplateTable::wide_fload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   691
  transition(vtos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   692
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   693
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   694
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   695
  __ load_local_float(F15_ftos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   696
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   697
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   698
void TemplateTable::wide_dload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   699
  transition(vtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   700
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   701
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   702
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   703
  __ load_local_double(F15_ftos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   704
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   705
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   706
void TemplateTable::wide_aload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   707
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   708
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   709
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   710
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   711
  __ load_local_ptr(R17_tos, Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   712
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   713
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   714
void TemplateTable::iaload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   715
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   716
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   717
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   718
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   719
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   720
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerInt, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   721
  __ lwa(R17_tos, arrayOopDesc::base_offset_in_bytes(T_INT), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   722
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   723
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   724
void TemplateTable::laload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   725
  transition(itos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   726
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   727
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   728
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   729
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   730
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerLong, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   731
  __ ld(R17_tos, arrayOopDesc::base_offset_in_bytes(T_LONG), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   732
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   733
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   734
void TemplateTable::faload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   735
  transition(itos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   736
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   737
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   738
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   739
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   740
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerInt, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   741
  __ lfs(F15_ftos, arrayOopDesc::base_offset_in_bytes(T_FLOAT), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   742
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   743
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   744
void TemplateTable::daload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   745
  transition(itos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   746
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   747
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   748
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   749
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   750
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerLong, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   751
  __ lfd(F15_ftos, arrayOopDesc::base_offset_in_bytes(T_DOUBLE), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   752
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   753
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   754
void TemplateTable::aaload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   755
  transition(itos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   756
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   757
  // tos: index
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   758
  // result tos: array
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   759
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   760
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   761
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   762
  __ index_check(Rarray, R17_tos /* index */, UseCompressedOops ? 2 : LogBytesPerWord, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   763
  __ load_heap_oop(R17_tos, arrayOopDesc::base_offset_in_bytes(T_OBJECT), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   764
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   765
  //__ dcbt(R17_tos); // prefetch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   766
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   767
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   768
void TemplateTable::baload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   769
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   770
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   771
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   772
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   773
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   774
  __ index_check(Rarray, R17_tos /* index */, 0, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   775
  __ lbz(R17_tos, arrayOopDesc::base_offset_in_bytes(T_BYTE), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   776
  __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   777
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   778
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   779
void TemplateTable::caload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   780
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   781
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   782
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   783
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   784
                 Rtemp      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   785
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerShort, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   786
  __ lhz(R17_tos, arrayOopDesc::base_offset_in_bytes(T_CHAR), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   787
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   788
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   789
// Iload followed by caload frequent pair.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   790
void TemplateTable::fast_icaload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   791
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   792
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   793
  const Register Rload_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   794
                 Rarray     = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   795
                 Rtemp      = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   796
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   797
  locals_index(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   798
  __ load_local_int(R17_tos, Rtemp, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   799
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerShort, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   800
  __ lhz(R17_tos, arrayOopDesc::base_offset_in_bytes(T_CHAR), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   801
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   802
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   803
void TemplateTable::saload() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   804
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   805
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   806
  const Register Rload_addr = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   807
                 Rarray     = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   808
                 Rtemp      = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   809
  __ index_check(Rarray, R17_tos /* index */, LogBytesPerShort, Rtemp, Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   810
  __ lha(R17_tos, arrayOopDesc::base_offset_in_bytes(T_SHORT), Rload_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   811
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   812
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   813
void TemplateTable::iload(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   814
  transition(vtos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   815
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   816
  __ lwz(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   817
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   818
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   819
void TemplateTable::lload(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   820
  transition(vtos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   821
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   822
  __ ld(R17_tos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   823
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   824
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   825
void TemplateTable::fload(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   826
  transition(vtos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   827
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   828
  __ lfs(F15_ftos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   829
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   830
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   831
void TemplateTable::dload(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   832
  transition(vtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   833
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   834
  __ lfd(F15_ftos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   835
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   836
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   837
void TemplateTable::aload(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   838
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   839
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   840
  __ ld(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   841
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   842
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   843
void TemplateTable::aload_0() {
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   844
  aload_0_internal();
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   845
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   846
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   847
void TemplateTable::nofast_aload_0() {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   848
  aload_0_internal(may_not_rewrite);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   849
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   850
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   851
void TemplateTable::aload_0_internal(RewriteControl rc) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   852
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   853
  // According to bytecode histograms, the pairs:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   854
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   855
  // _aload_0, _fast_igetfield
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   856
  // _aload_0, _fast_agetfield
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   857
  // _aload_0, _fast_fgetfield
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   858
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   859
  // occur frequently. If RewriteFrequentPairs is set, the (slow)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   860
  // _aload_0 bytecode checks if the next bytecode is either
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   861
  // _fast_igetfield, _fast_agetfield or _fast_fgetfield and then
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   862
  // rewrites the current bytecode into a pair bytecode; otherwise it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   863
  // rewrites the current bytecode into _0 that doesn't do
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   864
  // the pair check anymore.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   865
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   866
  // Note: If the next bytecode is _getfield, the rewrite must be
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   867
  //       delayed, otherwise we may miss an opportunity for a pair.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   868
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   869
  // Also rewrite frequent pairs
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   870
  //   aload_0, aload_1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   871
  //   aload_0, iload_1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   872
  // These bytecodes with a small amount of code are most profitable
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   873
  // to rewrite.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   874
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
   875
  if (RewriteFrequentPairs && rc == may_rewrite) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   876
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   877
    Label Lrewrite, Ldont_rewrite;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   878
    Register Rnext_byte  = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   879
             Rrewrite_to = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   880
             Rscratch    = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   881
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   882
    // Get next byte.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   883
    __ lbz(Rnext_byte, Bytecodes::length_for(Bytecodes::_aload_0), R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   884
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   885
    // If _getfield, wait to rewrite. We only want to rewrite the last two bytecodes in a pair.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   886
    __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_getfield);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   887
    __ beq(CCR0, Ldont_rewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   888
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   889
    __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_igetfield);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   890
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_iaccess_0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   891
    __ beq(CCR1, Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   892
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   893
    __ cmpwi(CCR0, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_agetfield);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   894
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_aaccess_0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   895
    __ beq(CCR0, Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   896
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   897
    __ cmpwi(CCR1, Rnext_byte, (unsigned int)(unsigned char)Bytecodes::_fast_fgetfield);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   898
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_faccess_0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   899
    __ beq(CCR1, Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   900
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   901
    __ li(Rrewrite_to, (unsigned int)(unsigned char)Bytecodes::_fast_aload_0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   902
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   903
    __ bind(Lrewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   904
    patch_bytecode(Bytecodes::_aload_0, Rrewrite_to, Rscratch, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   905
    __ bind(Ldont_rewrite);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   906
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   907
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   908
  // Do actual aload_0 (must do this after patch_bytecode which might call VM and GC might change oop).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   909
  aload(0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   910
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   911
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   912
void TemplateTable::istore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   913
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   914
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   915
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   916
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   917
  __ store_local_int(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   918
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   919
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   920
void TemplateTable::lstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   921
  transition(ltos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   922
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   923
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   924
  __ store_local_long(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   925
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   926
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   927
void TemplateTable::fstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   928
  transition(ftos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   929
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   930
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   931
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   932
  __ store_local_float(F15_ftos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   933
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   934
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   935
void TemplateTable::dstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   936
  transition(dtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   937
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   938
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   939
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   940
  __ store_local_double(F15_ftos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   941
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   942
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   943
void TemplateTable::astore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   944
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   945
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   946
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   947
  __ pop_ptr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   948
  __ verify_oop_or_return_address(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   949
  locals_index(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   950
  __ store_local_ptr(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   951
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   952
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   953
void TemplateTable::wide_istore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   954
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   955
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   956
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   957
  __ pop_i();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   958
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   959
  __ store_local_int(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   960
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   961
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   962
void TemplateTable::wide_lstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   963
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   964
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   965
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   966
  __ pop_l();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   967
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   968
  __ store_local_long(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   969
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   970
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   971
void TemplateTable::wide_fstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   972
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   973
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   974
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   975
  __ pop_f();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   976
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   977
  __ store_local_float(F15_ftos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   978
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   979
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   980
void TemplateTable::wide_dstore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   981
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   982
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   983
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   984
  __ pop_d();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   985
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   986
  __ store_local_double(F15_ftos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   987
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   988
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   989
void TemplateTable::wide_astore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   990
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   991
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   992
  const Register Rindex = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   993
  __ pop_ptr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   994
  __ verify_oop_or_return_address(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   995
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   996
  __ store_local_ptr(R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   997
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   998
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
   999
void TemplateTable::iastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1000
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1001
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1002
  const Register Rindex      = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1003
                 Rstore_addr = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1004
                 Rarray      = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1005
                 Rtemp       = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1006
  __ pop_i(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1007
  __ index_check(Rarray, Rindex, LogBytesPerInt, Rtemp, Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1008
  __ stw(R17_tos, arrayOopDesc::base_offset_in_bytes(T_INT), Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1009
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1010
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1011
void TemplateTable::lastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1012
  transition(ltos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1013
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1014
  const Register Rindex      = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1015
                 Rstore_addr = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1016
                 Rarray      = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1017
                 Rtemp       = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1018
  __ pop_i(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1019
  __ index_check(Rarray, Rindex, LogBytesPerLong, Rtemp, Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1020
  __ std(R17_tos, arrayOopDesc::base_offset_in_bytes(T_LONG), Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1021
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1022
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1023
void TemplateTable::fastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1024
  transition(ftos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1025
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1026
  const Register Rindex      = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1027
                 Rstore_addr = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1028
                 Rarray      = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1029
                 Rtemp       = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1030
  __ pop_i(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1031
  __ index_check(Rarray, Rindex, LogBytesPerInt, Rtemp, Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1032
  __ stfs(F15_ftos, arrayOopDesc::base_offset_in_bytes(T_FLOAT), Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1033
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1034
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1035
void TemplateTable::dastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1036
  transition(dtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1037
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1038
  const Register Rindex      = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1039
                 Rstore_addr = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1040
                 Rarray      = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1041
                 Rtemp       = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1042
  __ pop_i(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1043
  __ index_check(Rarray, Rindex, LogBytesPerLong, Rtemp, Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1044
  __ stfd(F15_ftos, arrayOopDesc::base_offset_in_bytes(T_DOUBLE), Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1045
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1046
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1047
// Pop 3 values from the stack and...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1048
void TemplateTable::aastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1049
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1050
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1051
  Label Lstore_ok, Lis_null, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1052
  const Register Rindex    = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1053
                 Rarray    = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1054
                 Rscratch  = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1055
                 Rscratch2 = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1056
                 Rarray_klass = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1057
                 Rarray_element_klass = Rarray_klass,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1058
                 Rvalue_klass = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1059
                 Rstore_addr = R31;    // Use register which survives VM call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1060
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1061
  __ ld(R17_tos, Interpreter::expr_offset_in_bytes(0), R15_esp); // Get value to store.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1062
  __ lwz(Rindex, Interpreter::expr_offset_in_bytes(1), R15_esp); // Get index.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1063
  __ ld(Rarray, Interpreter::expr_offset_in_bytes(2), R15_esp);  // Get array.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1064
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1065
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1066
  __ index_check_without_pop(Rarray, Rindex, UseCompressedOops ? 2 : LogBytesPerWord, Rscratch, Rstore_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1067
  // Rindex is dead!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1068
  Register Rscratch3 = Rindex;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1069
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1070
  // Do array store check - check for NULL value first.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1071
  __ cmpdi(CCR0, R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1072
  __ beq(CCR0, Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1073
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1074
  __ load_klass(Rarray_klass, Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1075
  __ load_klass(Rvalue_klass, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1076
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1077
  // Do fast instanceof cache test.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1078
  __ ld(Rarray_element_klass, in_bytes(ObjArrayKlass::element_klass_offset()), Rarray_klass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1079
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1080
  // Generate a fast subtype check. Branch to store_ok if no failure. Throw if failure.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1081
  __ gen_subtype_check(Rvalue_klass /*subklass*/, Rarray_element_klass /*superklass*/, Rscratch, Rscratch2, Rscratch3, Lstore_ok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1082
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1083
  // Fell through: subtype check failed => throw an exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1084
  __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ArrayStoreException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1085
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1086
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1087
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1088
  __ bind(Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1089
  do_oop_store(_masm, Rstore_addr, arrayOopDesc::base_offset_in_bytes(T_OBJECT), noreg /* 0 */,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1090
               Rscratch, Rscratch2, Rscratch3, _bs->kind(), true /* precise */, false /* check_null */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1091
  __ profile_null_seen(Rscratch, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1092
  __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1093
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1094
  // Store is OK.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1095
  __ bind(Lstore_ok);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1096
  do_oop_store(_masm, Rstore_addr, arrayOopDesc::base_offset_in_bytes(T_OBJECT), R17_tos /* value */,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1097
               Rscratch, Rscratch2, Rscratch3, _bs->kind(), true /* precise */, false /* check_null */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1098
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1099
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1100
  // Adjust sp (pops array, index and value).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1101
  __ addi(R15_esp, R15_esp, 3 * Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1102
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1103
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1104
void TemplateTable::bastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1105
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1106
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1107
  const Register Rindex   = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1108
                 Rarray   = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1109
                 Rscratch = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1110
  __ pop_i(Rindex);
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1111
  __ pop_ptr(Rarray);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1112
  // tos: val
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1113
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1114
  // Need to check whether array is boolean or byte
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1115
  // since both types share the bastore bytecode.
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1116
  __ load_klass(Rscratch, Rarray);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1117
  __ lwz(Rscratch, in_bytes(Klass::layout_helper_offset()), Rscratch);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1118
  int diffbit = exact_log2(Klass::layout_helper_boolean_diffbit());
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1119
  __ testbitdi(CCR0, R0, Rscratch, diffbit);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1120
  Label L_skip;
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1121
  __ bfalse(CCR0, L_skip);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1122
  __ andi(R17_tos, R17_tos, 1);  // if it is a T_BOOLEAN array, mask the stored value to 0/1
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1123
  __ bind(L_skip);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1124
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  1125
  __ index_check_without_pop(Rarray, Rindex, 0, Rscratch, Rarray);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1126
  __ stb(R17_tos, arrayOopDesc::base_offset_in_bytes(T_BYTE), Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1127
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1128
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1129
void TemplateTable::castore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1130
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1131
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1132
  const Register Rindex   = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1133
                 Rarray   = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1134
                 Rscratch = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1135
  __ pop_i(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1136
  // tos: val
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1137
  // Rarray: array ptr (popped by index_check)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1138
  __ index_check(Rarray, Rindex, LogBytesPerShort, Rscratch, Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1139
  __ sth(R17_tos, arrayOopDesc::base_offset_in_bytes(T_CHAR), Rarray);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1140
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1141
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1142
void TemplateTable::sastore() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1143
  castore();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1144
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1145
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1146
void TemplateTable::istore(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1147
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1148
  __ stw(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1149
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1150
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1151
void TemplateTable::lstore(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1152
  transition(ltos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1153
  __ std(R17_tos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1154
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1155
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1156
void TemplateTable::fstore(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1157
  transition(ftos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1158
  __ stfs(F15_ftos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1159
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1160
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1161
void TemplateTable::dstore(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1162
  transition(dtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1163
  __ stfd(F15_ftos, Interpreter::local_offset_in_bytes(n + 1), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1164
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1165
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1166
void TemplateTable::astore(int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1167
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1168
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1169
  __ pop_ptr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1170
  __ verify_oop_or_return_address(R17_tos, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1171
  __ std(R17_tos, Interpreter::local_offset_in_bytes(n), R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1172
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1173
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1174
void TemplateTable::pop() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1175
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1176
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1177
  __ addi(R15_esp, R15_esp, Interpreter::stackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1178
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1179
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1180
void TemplateTable::pop2() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1181
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1182
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1183
  __ addi(R15_esp, R15_esp, Interpreter::stackElementSize * 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1184
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1185
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1186
void TemplateTable::dup() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1187
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1188
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1189
  __ ld(R11_scratch1, Interpreter::stackElementSize, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1190
  __ push_ptr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1191
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1192
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1193
void TemplateTable::dup_x1() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1194
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1195
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1196
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1197
           Rb = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1198
  // stack: ..., a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1199
  __ ld(Rb, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1200
  __ ld(Ra, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1201
  __ std(Rb, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1202
  __ std(Ra, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1203
  __ push_ptr(Rb);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1204
  // stack: ..., b, a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1205
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1206
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1207
void TemplateTable::dup_x2() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1208
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1209
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1210
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1211
           Rb = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1212
           Rc = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1213
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1214
  // stack: ..., a, b, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1215
  __ ld(Rc, Interpreter::stackElementSize,     R15_esp);  // load c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1216
  __ ld(Ra, Interpreter::stackElementSize * 3, R15_esp);  // load a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1217
  __ std(Rc, Interpreter::stackElementSize * 3, R15_esp); // store c in a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1218
  __ ld(Rb, Interpreter::stackElementSize * 2, R15_esp);  // load b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1219
  // stack: ..., c, b, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1220
  __ std(Ra, Interpreter::stackElementSize * 2, R15_esp); // store a in b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1221
  // stack: ..., c, a, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1222
  __ std(Rb, Interpreter::stackElementSize,     R15_esp); // store b in c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1223
  __ push_ptr(Rc);                                        // push c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1224
  // stack: ..., c, a, b, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1225
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1226
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1227
void TemplateTable::dup2() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1228
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1229
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1230
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1231
           Rb = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1232
  // stack: ..., a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1233
  __ ld(Rb, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1234
  __ ld(Ra, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1235
  __ push_2ptrs(Ra, Rb);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1236
  // stack: ..., a, b, a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1237
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1238
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1239
void TemplateTable::dup2_x1() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1240
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1241
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1242
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1243
           Rb = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1244
           Rc = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1245
  // stack: ..., a, b, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1246
  __ ld(Rc, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1247
  __ ld(Rb, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1248
  __ std(Rc, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1249
  __ ld(Ra, Interpreter::stackElementSize * 3, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1250
  __ std(Ra, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1251
  __ std(Rb, Interpreter::stackElementSize * 3, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1252
  // stack: ..., b, c, a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1253
  __ push_2ptrs(Rb, Rc);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1254
  // stack: ..., b, c, a, b, c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1255
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1256
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1257
void TemplateTable::dup2_x2() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1258
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1259
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1260
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1261
           Rb = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1262
           Rc = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1263
           Rd = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1264
  // stack: ..., a, b, c, d
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1265
  __ ld(Rb, Interpreter::stackElementSize * 3, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1266
  __ ld(Rd, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1267
  __ std(Rb, Interpreter::stackElementSize,     R15_esp);  // store b in d
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1268
  __ std(Rd, Interpreter::stackElementSize * 3, R15_esp);  // store d in b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1269
  __ ld(Ra, Interpreter::stackElementSize * 4, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1270
  __ ld(Rc, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1271
  __ std(Ra, Interpreter::stackElementSize * 2, R15_esp);  // store a in c
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1272
  __ std(Rc, Interpreter::stackElementSize * 4, R15_esp);  // store c in a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1273
  // stack: ..., c, d, a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1274
  __ push_2ptrs(Rc, Rd);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1275
  // stack: ..., c, d, a, b, c, d
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1276
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1277
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1278
void TemplateTable::swap() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1279
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1280
  // stack: ..., a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1281
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1282
  Register Ra = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1283
           Rb = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1284
  // stack: ..., a, b
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1285
  __ ld(Rb, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1286
  __ ld(Ra, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1287
  __ std(Rb, Interpreter::stackElementSize * 2, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1288
  __ std(Ra, Interpreter::stackElementSize,     R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1289
  // stack: ..., b, a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1290
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1291
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1292
void TemplateTable::iop2(Operation op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1293
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1294
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1295
  Register Rscratch = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1296
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1297
  __ pop_i(Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1298
  // tos  = number of bits to shift
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1299
  // Rscratch = value to shift
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1300
  switch (op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1301
    case  add:   __ add(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1302
    case  sub:   __ sub(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1303
    case  mul:   __ mullw(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1304
    case  _and:  __ andr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1305
    case  _or:   __ orr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1306
    case  _xor:  __ xorr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1307
    case  shl:   __ rldicl(R17_tos, R17_tos, 0, 64-5); __ slw(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1308
    case  shr:   __ rldicl(R17_tos, R17_tos, 0, 64-5); __ sraw(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1309
    case  ushr:  __ rldicl(R17_tos, R17_tos, 0, 64-5); __ srw(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1310
    default:     ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1311
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1312
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1313
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1314
void TemplateTable::lop2(Operation op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1315
  transition(ltos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1316
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1317
  Register Rscratch = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1318
  __ pop_l(Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1319
  switch (op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1320
    case  add:   __ add(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1321
    case  sub:   __ sub(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1322
    case  _and:  __ andr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1323
    case  _or:   __ orr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1324
    case  _xor:  __ xorr(R17_tos, Rscratch, R17_tos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1325
    default:     ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1326
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1327
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1328
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1329
void TemplateTable::idiv() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1330
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1331
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1332
  Label Lnormal, Lexception, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1333
  Register Rdividend = R11_scratch1; // Used by irem.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1334
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1335
  __ addi(R0, R17_tos, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1336
  __ cmplwi(CCR0, R0, 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1337
  __ bgt(CCR0, Lnormal); // divisor <-1 or >1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1338
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1339
  __ cmpwi(CCR1, R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1340
  __ beq(CCR1, Lexception); // divisor == 0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1341
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1342
  __ pop_i(Rdividend);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1343
  __ mullw(R17_tos, Rdividend, R17_tos); // div by +/-1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1344
  __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1345
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1346
  __ bind(Lexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1347
  __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ArithmeticException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1348
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1349
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1350
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1351
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1352
  __ bind(Lnormal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1353
  __ pop_i(Rdividend);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1354
  __ divw(R17_tos, Rdividend, R17_tos); // Can't divide minint/-1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1355
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1356
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1357
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1358
void TemplateTable::irem() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1359
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1360
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1361
  __ mr(R12_scratch2, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1362
  idiv();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1363
  __ mullw(R17_tos, R17_tos, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1364
  __ subf(R17_tos, R17_tos, R11_scratch1); // Dividend set by idiv.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1365
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1366
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1367
void TemplateTable::lmul() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1368
  transition(ltos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1369
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1370
  __ pop_l(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1371
  __ mulld(R17_tos, R11_scratch1, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1372
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1373
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1374
void TemplateTable::ldiv() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1375
  transition(ltos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1376
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1377
  Label Lnormal, Lexception, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1378
  Register Rdividend = R11_scratch1; // Used by lrem.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1379
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1380
  __ addi(R0, R17_tos, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1381
  __ cmpldi(CCR0, R0, 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1382
  __ bgt(CCR0, Lnormal); // divisor <-1 or >1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1383
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1384
  __ cmpdi(CCR1, R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1385
  __ beq(CCR1, Lexception); // divisor == 0
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1386
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1387
  __ pop_l(Rdividend);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1388
  __ mulld(R17_tos, Rdividend, R17_tos); // div by +/-1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1389
  __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1390
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1391
  __ bind(Lexception);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1392
  __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ArithmeticException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1393
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1394
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1395
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1396
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1397
  __ bind(Lnormal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1398
  __ pop_l(Rdividend);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1399
  __ divd(R17_tos, Rdividend, R17_tos); // Can't divide minint/-1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1400
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1401
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1402
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1403
void TemplateTable::lrem() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1404
  transition(ltos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1405
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1406
  __ mr(R12_scratch2, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1407
  ldiv();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1408
  __ mulld(R17_tos, R17_tos, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1409
  __ subf(R17_tos, R17_tos, R11_scratch1); // Dividend set by ldiv.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1410
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1411
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1412
void TemplateTable::lshl() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1413
  transition(itos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1414
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1415
  __ rldicl(R17_tos, R17_tos, 0, 64-6); // Extract least significant bits.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1416
  __ pop_l(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1417
  __ sld(R17_tos, R11_scratch1, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1418
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1419
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1420
void TemplateTable::lshr() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1421
  transition(itos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1422
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1423
  __ rldicl(R17_tos, R17_tos, 0, 64-6); // Extract least significant bits.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1424
  __ pop_l(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1425
  __ srad(R17_tos, R11_scratch1, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1426
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1427
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1428
void TemplateTable::lushr() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1429
  transition(itos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1430
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1431
  __ rldicl(R17_tos, R17_tos, 0, 64-6); // Extract least significant bits.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1432
  __ pop_l(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1433
  __ srd(R17_tos, R11_scratch1, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1434
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1435
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1436
void TemplateTable::fop2(Operation op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1437
  transition(ftos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1438
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1439
  switch (op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1440
    case add: __ pop_f(F0_SCRATCH); __ fadds(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1441
    case sub: __ pop_f(F0_SCRATCH); __ fsubs(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1442
    case mul: __ pop_f(F0_SCRATCH); __ fmuls(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1443
    case div: __ pop_f(F0_SCRATCH); __ fdivs(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1444
    case rem:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1445
      __ pop_f(F1_ARG1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1446
      __ fmr(F2_ARG2, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1447
      __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::frem));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1448
      __ fmr(F15_ftos, F1_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1449
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1450
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1451
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1452
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1453
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1454
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1455
void TemplateTable::dop2(Operation op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1456
  transition(dtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1457
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1458
  switch (op) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1459
    case add: __ pop_d(F0_SCRATCH); __ fadd(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1460
    case sub: __ pop_d(F0_SCRATCH); __ fsub(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1461
    case mul: __ pop_d(F0_SCRATCH); __ fmul(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1462
    case div: __ pop_d(F0_SCRATCH); __ fdiv(F15_ftos, F0_SCRATCH, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1463
    case rem:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1464
      __ pop_d(F1_ARG1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1465
      __ fmr(F2_ARG2, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1466
      __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::drem));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1467
      __ fmr(F15_ftos, F1_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1468
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1469
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1470
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1471
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1472
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1473
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1474
// Negate the value in the TOS cache.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1475
void TemplateTable::ineg() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1476
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1477
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1478
  __ neg(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1479
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1480
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1481
// Negate the value in the TOS cache.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1482
void TemplateTable::lneg() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1483
  transition(ltos, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1484
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1485
  __ neg(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1486
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1487
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1488
void TemplateTable::fneg() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1489
  transition(ftos, ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1490
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1491
  __ fneg(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1492
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1493
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1494
void TemplateTable::dneg() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1495
  transition(dtos, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1496
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1497
  __ fneg(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1498
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1499
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1500
// Increments a local variable in place.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1501
void TemplateTable::iinc() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1502
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1503
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1504
  const Register Rindex     = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1505
                 Rincrement = R0,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1506
                 Rvalue     = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1507
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1508
  locals_index(Rindex);              // Load locals index from bytecode stream.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1509
  __ lbz(Rincrement, 2, R14_bcp);    // Load increment from the bytecode stream.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1510
  __ extsb(Rincrement, Rincrement);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1511
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1512
  __ load_local_int(Rvalue, Rindex, Rindex); // Puts address of local into Rindex.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1513
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1514
  __ add(Rvalue, Rincrement, Rvalue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1515
  __ stw(Rvalue, 0, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1516
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1517
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1518
void TemplateTable::wide_iinc() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1519
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1520
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1521
  Register Rindex       = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1522
           Rlocals_addr = Rindex,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1523
           Rincr        = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1524
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1525
  __ get_2_byte_integer_at_bcp(4, Rincr, InterpreterMacroAssembler::Signed);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1526
  __ load_local_int(R17_tos, Rlocals_addr, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1527
  __ add(R17_tos, Rincr, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1528
  __ stw(R17_tos, 0, Rlocals_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1529
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1530
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1531
void TemplateTable::convert() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1532
  // %%%%% Factor this first part accross platforms
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1533
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1534
  TosState tos_in  = ilgl;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1535
  TosState tos_out = ilgl;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1536
  switch (bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1537
    case Bytecodes::_i2l: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1538
    case Bytecodes::_i2f: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1539
    case Bytecodes::_i2d: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1540
    case Bytecodes::_i2b: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1541
    case Bytecodes::_i2c: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1542
    case Bytecodes::_i2s: tos_in = itos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1543
    case Bytecodes::_l2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1544
    case Bytecodes::_l2f: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1545
    case Bytecodes::_l2d: tos_in = ltos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1546
    case Bytecodes::_f2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1547
    case Bytecodes::_f2l: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1548
    case Bytecodes::_f2d: tos_in = ftos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1549
    case Bytecodes::_d2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1550
    case Bytecodes::_d2l: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1551
    case Bytecodes::_d2f: tos_in = dtos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1552
    default             : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1553
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1554
  switch (bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1555
    case Bytecodes::_l2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1556
    case Bytecodes::_f2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1557
    case Bytecodes::_d2i: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1558
    case Bytecodes::_i2b: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1559
    case Bytecodes::_i2c: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1560
    case Bytecodes::_i2s: tos_out = itos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1561
    case Bytecodes::_i2l: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1562
    case Bytecodes::_f2l: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1563
    case Bytecodes::_d2l: tos_out = ltos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1564
    case Bytecodes::_i2f: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1565
    case Bytecodes::_l2f: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1566
    case Bytecodes::_d2f: tos_out = ftos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1567
    case Bytecodes::_i2d: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1568
    case Bytecodes::_l2d: // fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1569
    case Bytecodes::_f2d: tos_out = dtos; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1570
    default             : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1571
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1572
  transition(tos_in, tos_out);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1573
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1574
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1575
  // Conversion
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1576
  Label done;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1577
  switch (bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1578
    case Bytecodes::_i2l:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1579
      __ extsw(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1580
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1581
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1582
    case Bytecodes::_l2i:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1583
      // Nothing to do, we'll continue to work with the lower bits.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1584
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1585
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1586
    case Bytecodes::_i2b:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1587
      __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1588
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1589
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1590
    case Bytecodes::_i2c:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1591
      __ rldicl(R17_tos, R17_tos, 0, 64-2*8);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1592
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1593
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1594
    case Bytecodes::_i2s:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1595
      __ extsh(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1596
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1597
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1598
    case Bytecodes::_i2d:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1599
      __ extsw(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1600
    case Bytecodes::_l2d:
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46487
diff changeset
  1601
      __ move_l_to_d();
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1602
      __ fcfid(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1603
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1604
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1605
    case Bytecodes::_i2f:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1606
      __ extsw(R17_tos, R17_tos);
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46487
diff changeset
  1607
      __ move_l_to_d();
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1608
      if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1609
        // Comment: alternatively, load with sign extend could be done by lfiwax.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1610
        __ fcfids(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1611
      } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1612
        __ fcfid(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1613
        __ frsp(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1614
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1615
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1616
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1617
    case Bytecodes::_l2f:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1618
      if (VM_Version::has_fcfids()) { // fcfids is >= Power7 only
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46487
diff changeset
  1619
        __ move_l_to_d();
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1620
        __ fcfids(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1621
      } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1622
        // Avoid rounding problem when result should be 0x3f800001: need fixup code before fcfid+frsp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1623
        __ mr(R3_ARG1, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1624
        __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::l2f));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1625
        __ fmr(F15_ftos, F1_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1626
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1627
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1628
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1629
    case Bytecodes::_f2d:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1630
      // empty
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1631
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1632
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1633
    case Bytecodes::_d2f:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1634
      __ frsp(F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1635
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1636
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1637
    case Bytecodes::_d2i:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1638
    case Bytecodes::_f2i:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1639
      __ fcmpu(CCR0, F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1640
      __ li(R17_tos, 0); // 0 in case of NAN
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1641
      __ bso(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1642
      __ fctiwz(F15_ftos, F15_ftos);
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46487
diff changeset
  1643
      __ move_d_to_l();
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1644
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1645
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1646
    case Bytecodes::_d2l:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1647
    case Bytecodes::_f2l:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1648
      __ fcmpu(CCR0, F15_ftos, F15_ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1649
      __ li(R17_tos, 0); // 0 in case of NAN
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1650
      __ bso(CCR0, done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1651
      __ fctidz(F15_ftos, F15_ftos);
46615
3fd9b25850f4 8181809: PPC64: Leverage mtfprd/mffprd on POWER8
mdoerr
parents: 46487
diff changeset
  1652
      __ move_d_to_l();
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1653
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1654
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1655
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1656
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1657
  __ bind(done);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1658
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1659
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1660
// Long compare
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1661
void TemplateTable::lcmp() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1662
  transition(ltos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1663
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1664
  const Register Rscratch = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1665
  __ pop_l(Rscratch); // first operand, deeper in stack
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1666
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1667
  __ cmpd(CCR0, Rscratch, R17_tos); // compare
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1668
  __ mfcr(R17_tos); // set bit 32..33 as follows: <: 0b10, =: 0b00, >: 0b01
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1669
  __ srwi(Rscratch, R17_tos, 30);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1670
  __ srawi(R17_tos, R17_tos, 31);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1671
  __ orr(R17_tos, Rscratch, R17_tos); // set result as follows: <: -1, =: 0, >: 1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1672
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1673
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1674
// fcmpl/fcmpg and dcmpl/dcmpg bytecodes
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1675
// unordered_result == -1 => fcmpl or dcmpl
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1676
// unordered_result ==  1 => fcmpg or dcmpg
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1677
void TemplateTable::float_cmp(bool is_float, int unordered_result) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1678
  const FloatRegister Rfirst  = F0_SCRATCH,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1679
                      Rsecond = F15_ftos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1680
  const Register Rscratch = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1681
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1682
  if (is_float) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1683
    __ pop_f(Rfirst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1684
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1685
    __ pop_d(Rfirst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1686
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1687
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1688
  Label Lunordered, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1689
  __ fcmpu(CCR0, Rfirst, Rsecond); // compare
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1690
  if (unordered_result) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1691
    __ bso(CCR0, Lunordered);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1692
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1693
  __ mfcr(R17_tos); // set bit 32..33 as follows: <: 0b10, =: 0b00, >: 0b01
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1694
  __ srwi(Rscratch, R17_tos, 30);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1695
  __ srawi(R17_tos, R17_tos, 31);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1696
  __ orr(R17_tos, Rscratch, R17_tos); // set result as follows: <: -1, =: 0, >: 1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1697
  if (unordered_result) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1698
    __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1699
    __ bind(Lunordered);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1700
    __ load_const_optimized(R17_tos, unordered_result);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1701
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1702
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1703
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1704
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1705
// Branch_conditional which takes TemplateTable::Condition.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1706
void TemplateTable::branch_conditional(ConditionRegister crx, TemplateTable::Condition cc, Label& L, bool invert) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1707
  bool positive = false;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1708
  Assembler::Condition cond = Assembler::equal;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1709
  switch (cc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1710
    case TemplateTable::equal:         positive = true ; cond = Assembler::equal  ; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1711
    case TemplateTable::not_equal:     positive = false; cond = Assembler::equal  ; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1712
    case TemplateTable::less:          positive = true ; cond = Assembler::less   ; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1713
    case TemplateTable::less_equal:    positive = false; cond = Assembler::greater; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1714
    case TemplateTable::greater:       positive = true ; cond = Assembler::greater; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1715
    case TemplateTable::greater_equal: positive = false; cond = Assembler::less   ; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1716
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1717
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1718
  int bo = (positive != invert) ? Assembler::bcondCRbiIs1 : Assembler::bcondCRbiIs0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1719
  int bi = Assembler::bi0(crx, cond);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1720
  __ bc(bo, bi, L);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1721
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1722
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1723
void TemplateTable::branch(bool is_jsr, bool is_wide) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1724
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1725
  // Note: on SPARC, we use InterpreterMacroAssembler::if_cmp also.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1726
  __ verify_thread();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1727
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1728
  const Register Rscratch1    = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1729
                 Rscratch2    = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1730
                 Rscratch3    = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1731
                 R4_counters  = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1732
                 bumped_count = R31,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1733
                 Rdisp        = R22_tmp2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1734
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1735
  __ profile_taken_branch(Rscratch1, bumped_count);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1736
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1737
  // Get (wide) offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1738
  if (is_wide) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1739
    __ get_4_byte_integer_at_bcp(1, Rdisp, InterpreterMacroAssembler::Signed);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1740
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1741
    __ get_2_byte_integer_at_bcp(1, Rdisp, InterpreterMacroAssembler::Signed);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1742
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1743
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1744
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1745
  // Handle all the JSR stuff here, then exit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1746
  // It's much shorter and cleaner than intermingling with the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1747
  // non-JSR normal-branch stuff occurring below.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1748
  if (is_jsr) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1749
    // Compute return address as bci in Otos_i.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1750
    __ ld(Rscratch1, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1751
    __ addi(Rscratch2, R14_bcp, -in_bytes(ConstMethod::codes_offset()) + (is_wide ? 5 : 3));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1752
    __ subf(R17_tos, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1753
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1754
    // Bump bcp to target of JSR.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1755
    __ add(R14_bcp, Rdisp, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1756
    // Push returnAddress for "ret" on stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1757
    __ push_ptr(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1758
    // And away we go!
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  1759
    __ dispatch_next(vtos, 0 ,true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1760
    return;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1761
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1762
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1763
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1764
  // Normal (non-jsr) branch handling
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1765
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1766
  // Bump bytecode pointer by displacement (take the branch).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1767
  __ add(R14_bcp, Rdisp, R14_bcp); // Add to bc addr.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1768
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1769
  const bool increment_invocation_counter_for_backward_branches = UseCompiler && UseLoopCounter;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1770
  if (increment_invocation_counter_for_backward_branches) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1771
    Label Lforward;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1772
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1773
    // Check branch direction.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1774
    __ cmpdi(CCR0, Rdisp, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1775
    __ bgt(CCR0, Lforward);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1776
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1777
    __ get_method_counters(R19_method, R4_counters, Lforward);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1778
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1779
    if (TieredCompilation) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1780
      Label Lno_mdo, Loverflow;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1781
      const int increment = InvocationCounter::count_increment;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1782
      if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1783
        Register Rmdo = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1784
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1785
        // If no method data exists, go to profile_continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1786
        __ ld(Rmdo, in_bytes(Method::method_data_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1787
        __ cmpdi(CCR0, Rmdo, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1788
        __ beq(CCR0, Lno_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1789
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1790
        // Increment backedge counter in the MDO.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1791
        const int mdo_bc_offs = in_bytes(MethodData::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1792
        __ lwz(Rscratch2, mdo_bc_offs, Rmdo);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1793
        __ lwz(Rscratch3, in_bytes(MethodData::backedge_mask_offset()), Rmdo);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1794
        __ addi(Rscratch2, Rscratch2, increment);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1795
        __ stw(Rscratch2, mdo_bc_offs, Rmdo);
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1796
        if (UseOnStackReplacement) {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1797
          __ and_(Rscratch3, Rscratch2, Rscratch3);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1798
          __ bne(CCR0, Lforward);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1799
          __ b(Loverflow);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1800
        } else {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1801
          __ b(Lforward);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1802
        }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1803
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1804
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1805
      // If there's no MDO, increment counter in method.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1806
      const int mo_bc_offs = in_bytes(MethodCounters::backedge_counter_offset()) + in_bytes(InvocationCounter::counter_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1807
      __ bind(Lno_mdo);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1808
      __ lwz(Rscratch2, mo_bc_offs, R4_counters);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1809
      __ lwz(Rscratch3, in_bytes(MethodCounters::backedge_mask_offset()), R4_counters);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1810
      __ addi(Rscratch2, Rscratch2, increment);
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1811
      __ stw(Rscratch2, mo_bc_offs, R4_counters);
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1812
      if (UseOnStackReplacement) {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1813
        __ and_(Rscratch3, Rscratch2, Rscratch3);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1814
        __ bne(CCR0, Lforward);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1815
      } else {
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1816
        __ b(Lforward);
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 37488
diff changeset
  1817
      }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1818
      __ bind(Loverflow);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1819
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1820
      // Notify point for loop, pass branch bytecode.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1821
      __ subf(R4_ARG2, Rdisp, R14_bcp); // Compute branch bytecode (previous bcp).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1822
      __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::frequency_counter_overflow), R4_ARG2, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1823
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1824
      // Was an OSR adapter generated?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1825
      __ cmpdi(CCR0, R3_RET, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1826
      __ beq(CCR0, Lforward);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1827
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1828
      // Has the nmethod been invalidated already?
26705
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1829
      __ lbz(R0, nmethod::state_offset(), R3_RET);
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1830
      __ cmpwi(CCR0, R0, nmethod::in_use);
fca1785e7084 8048721: -XX:+PrintCompilation prints negative bci for non entrant OSR methods
thartmann
parents: 25916
diff changeset
  1831
      __ bne(CCR0, Lforward);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1832
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1833
      // Migrate the interpreter frame off of the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1834
      // We can use all registers because we will not return to interpreter from this point.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1835
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1836
      // Save nmethod.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1837
      const Register osr_nmethod = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1838
      __ mr(osr_nmethod, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1839
      __ set_top_ijava_frame_at_SP_as_last_Java_frame(R1_SP, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1840
      __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_begin), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1841
      __ reset_last_Java_frame();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1842
      // OSR buffer is in ARG1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1843
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1844
      // Remove the interpreter frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1845
      __ merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1846
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1847
      // Jump to the osr code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1848
      __ ld(R11_scratch1, nmethod::osr_entry_point_offset(), osr_nmethod);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1849
      __ mtlr(R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1850
      __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1851
      __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1852
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1853
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1854
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1855
      const Register invoke_ctr = Rscratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1856
      // Update Backedge branch separately from invocations.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1857
      __ increment_backedge_counter(R4_counters, invoke_ctr, Rscratch2, Rscratch3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1858
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1859
      if (ProfileInterpreter) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1860
        __ test_invocation_counter_for_mdp(invoke_ctr, R4_counters, Rscratch2, Lforward);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1861
        if (UseOnStackReplacement) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1862
          __ test_backedge_count_for_osr(bumped_count, R4_counters, R14_bcp, Rdisp, Rscratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1863
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1864
      } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1865
        if (UseOnStackReplacement) {
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 32596
diff changeset
  1866
          __ test_backedge_count_for_osr(invoke_ctr, R4_counters, R14_bcp, Rdisp, Rscratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1867
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1868
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1869
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1870
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1871
    __ bind(Lforward);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1872
  }
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  1873
  __ dispatch_next(vtos, 0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1874
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1875
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1876
// Helper function for if_cmp* methods below.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1877
// Factored out common compare and branch code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1878
void TemplateTable::if_cmp_common(Register Rfirst, Register Rsecond, Register Rscratch1, Register Rscratch2, Condition cc, bool is_jint, bool cmp0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1879
  Label Lnot_taken;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1880
  // Note: The condition code we get is the condition under which we
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1881
  // *fall through*! So we have to inverse the CC here.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1882
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1883
  if (is_jint) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1884
    if (cmp0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1885
      __ cmpwi(CCR0, Rfirst, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1886
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1887
      __ cmpw(CCR0, Rfirst, Rsecond);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1888
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1889
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1890
    if (cmp0) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1891
      __ cmpdi(CCR0, Rfirst, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1892
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1893
      __ cmpd(CCR0, Rfirst, Rsecond);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1894
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1895
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1896
  branch_conditional(CCR0, cc, Lnot_taken, /*invert*/ true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1897
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1898
  // Conition is false => Jump!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1899
  branch(false, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1900
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1901
  // Condition is not true => Continue.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1902
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1903
  __ bind(Lnot_taken);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1904
  __ profile_not_taken_branch(Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1905
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1906
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1907
// Compare integer values with zero and fall through if CC holds, branch away otherwise.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1908
void TemplateTable::if_0cmp(Condition cc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1909
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1910
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1911
  if_cmp_common(R17_tos, noreg, R11_scratch1, R12_scratch2, cc, true, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1912
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1913
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1914
// Compare integer values and fall through if CC holds, branch away otherwise.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1915
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1916
// Interface:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1917
//  - Rfirst: First operand  (older stack value)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1918
//  - tos:    Second operand (younger stack value)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1919
void TemplateTable::if_icmp(Condition cc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1920
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1921
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1922
  const Register Rfirst  = R0,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1923
                 Rsecond = R17_tos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1924
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1925
  __ pop_i(Rfirst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1926
  if_cmp_common(Rfirst, Rsecond, R11_scratch1, R12_scratch2, cc, true, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1927
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1928
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1929
void TemplateTable::if_nullcmp(Condition cc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1930
  transition(atos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1931
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1932
  if_cmp_common(R17_tos, noreg, R11_scratch1, R12_scratch2, cc, false, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1933
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1934
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1935
void TemplateTable::if_acmp(Condition cc) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1936
  transition(atos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1937
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1938
  const Register Rfirst  = R0,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1939
                 Rsecond = R17_tos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1940
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1941
  __ pop_ptr(Rfirst);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1942
  if_cmp_common(Rfirst, Rsecond, R11_scratch1, R12_scratch2, cc, false, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1943
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1944
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1945
void TemplateTable::ret() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1946
  locals_index(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1947
  __ load_local_ptr(R17_tos, R11_scratch1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1948
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1949
  __ profile_ret(vtos, R17_tos, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1950
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1951
  __ ld(R11_scratch1, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1952
  __ add(R11_scratch1, R17_tos, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1953
  __ addi(R14_bcp, R11_scratch1, in_bytes(ConstMethod::codes_offset()));
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  1954
  __ dispatch_next(vtos, 0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1955
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1956
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1957
void TemplateTable::wide_ret() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1958
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1959
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1960
  const Register Rindex = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1961
                 Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1962
                 Rscratch2 = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1963
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1964
  locals_index_wide(Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1965
  __ load_local_ptr(R17_tos, R17_tos, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1966
  __ profile_ret(vtos, R17_tos, Rscratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1967
  // Tos now contains the bci, compute the bcp from that.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1968
  __ ld(Rscratch1, in_bytes(Method::const_offset()), R19_method);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1969
  __ addi(Rscratch2, R17_tos, in_bytes(ConstMethod::codes_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1970
  __ add(R14_bcp, Rscratch1, Rscratch2);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  1971
  __ dispatch_next(vtos, 0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1972
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1973
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1974
void TemplateTable::tableswitch() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1975
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1976
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1977
  Label Ldispatch, Ldefault_case;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1978
  Register Rlow_byte         = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1979
           Rindex            = Rlow_byte,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1980
           Rhigh_byte        = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1981
           Rdef_offset_addr  = R5_ARG3, // is going to contain address of default offset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1982
           Rscratch1         = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1983
           Rscratch2         = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1984
           Roffset           = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1985
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1986
  // Align bcp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1987
  __ addi(Rdef_offset_addr, R14_bcp, BytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1988
  __ clrrdi(Rdef_offset_addr, Rdef_offset_addr, log2_long((jlong)BytesPerInt));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1989
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1990
  // Load lo & hi.
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1991
  __ get_u4(Rlow_byte, Rdef_offset_addr, BytesPerInt, InterpreterMacroAssembler::Unsigned);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  1992
  __ get_u4(Rhigh_byte, Rdef_offset_addr, 2 *BytesPerInt, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1993
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1994
  // Check for default case (=index outside [low,high]).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1995
  __ cmpw(CCR0, R17_tos, Rlow_byte);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1996
  __ cmpw(CCR1, R17_tos, Rhigh_byte);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1997
  __ blt(CCR0, Ldefault_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1998
  __ bgt(CCR1, Ldefault_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  1999
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2000
  // Lookup dispatch offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2001
  __ sub(Rindex, R17_tos, Rlow_byte);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2002
  __ extsw(Rindex, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2003
  __ profile_switch_case(Rindex, Rhigh_byte /* scratch */, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2004
  __ sldi(Rindex, Rindex, LogBytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2005
  __ addi(Rindex, Rindex, 3 * BytesPerInt);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2006
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2007
  __ lwbrx(Roffset, Rdef_offset_addr, Rindex);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2008
  __ extsw(Roffset, Roffset);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2009
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2010
  __ lwax(Roffset, Rdef_offset_addr, Rindex);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2011
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2012
  __ b(Ldispatch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2013
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2014
  __ bind(Ldefault_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2015
  __ profile_switch_default(Rhigh_byte, Rscratch1);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2016
  __ get_u4(Roffset, Rdef_offset_addr, 0, InterpreterMacroAssembler::Signed);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2017
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2018
  __ bind(Ldispatch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2019
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2020
  __ add(R14_bcp, Roffset, R14_bcp);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2021
  __ dispatch_next(vtos, 0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2022
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2023
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2024
void TemplateTable::lookupswitch() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2025
  transition(itos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2026
  __ stop("lookupswitch bytecode should have been rewritten");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2027
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2028
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2029
// Table switch using linear search through cases.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2030
// Bytecode stream format:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2031
// Bytecode (1) | 4-byte padding | default offset (4) | count (4) | value/offset pair1 (8) | value/offset pair2 (8) | ...
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2032
// Note: Everything is big-endian format here.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2033
void TemplateTable::fast_linearswitch() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2034
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2035
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2036
  Label Lloop_entry, Lsearch_loop, Lcontinue_execution, Ldefault_case;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2037
  Register Rcount           = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2038
           Rcurrent_pair    = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2039
           Rdef_offset_addr = R5_ARG3, // Is going to contain address of default offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2040
           Roffset          = R31,     // Might need to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2041
           Rvalue           = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2042
           Rscratch         = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2043
           Rcmp_value       = R17_tos;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2044
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2045
  // Align bcp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2046
  __ addi(Rdef_offset_addr, R14_bcp, BytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2047
  __ clrrdi(Rdef_offset_addr, Rdef_offset_addr, log2_long((jlong)BytesPerInt));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2048
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2049
  // Setup loop counter and limit.
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2050
  __ get_u4(Rcount, Rdef_offset_addr, BytesPerInt, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2051
  __ addi(Rcurrent_pair, Rdef_offset_addr, 2 * BytesPerInt); // Rcurrent_pair now points to first pair.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2052
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2053
  __ mtctr(Rcount);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2054
  __ cmpwi(CCR0, Rcount, 0);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2055
  __ bne(CCR0, Lloop_entry);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2056
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2057
  // Default case
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2058
  __ bind(Ldefault_case);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2059
  __ get_u4(Roffset, Rdef_offset_addr, 0, InterpreterMacroAssembler::Signed);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2060
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2061
    __ profile_switch_default(Rdef_offset_addr, Rcount/* scratch */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2062
  }
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2063
  __ b(Lcontinue_execution);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2064
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2065
  // Next iteration
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2066
  __ bind(Lsearch_loop);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2067
  __ bdz(Ldefault_case);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2068
  __ addi(Rcurrent_pair, Rcurrent_pair, 2 * BytesPerInt);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2069
  __ bind(Lloop_entry);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2070
  __ get_u4(Rvalue, Rcurrent_pair, 0, InterpreterMacroAssembler::Unsigned);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2071
  __ cmpw(CCR0, Rvalue, Rcmp_value);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2072
  __ bne(CCR0, Lsearch_loop);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2073
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2074
  // Found, load offset.
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2075
  __ get_u4(Roffset, Rcurrent_pair, BytesPerInt, InterpreterMacroAssembler::Signed);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2076
  // Calculate case index and profile
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2077
  __ mfctr(Rcurrent_pair);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2078
  if (ProfileInterpreter) {
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2079
    __ sub(Rcurrent_pair, Rcount, Rcurrent_pair);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2080
    __ profile_switch_case(Rcurrent_pair, Rcount /*scratch*/, Rdef_offset_addr/*scratch*/, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2081
  }
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2082
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2083
  __ bind(Lcontinue_execution);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2084
  __ add(R14_bcp, Roffset, R14_bcp);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2085
  __ dispatch_next(vtos, 0, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2086
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2087
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2088
// Table switch using binary search (value/offset pairs are ordered).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2089
// Bytecode stream format:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2090
// Bytecode (1) | 4-byte padding | default offset (4) | count (4) | value/offset pair1 (8) | value/offset pair2 (8) | ...
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2091
// Note: Everything is big-endian format here. So on little endian machines, we have to revers offset and count and cmp value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2092
void TemplateTable::fast_binaryswitch() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2093
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2094
  transition(itos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2095
  // Implementation using the following core algorithm: (copied from Intel)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2096
  //
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2097
  // int binary_search(int key, LookupswitchPair* array, int n) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2098
  //   // Binary search according to "Methodik des Programmierens" by
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2099
  //   // Edsger W. Dijkstra and W.H.J. Feijen, Addison Wesley Germany 1985.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2100
  //   int i = 0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2101
  //   int j = n;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2102
  //   while (i+1 < j) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2103
  //     // invariant P: 0 <= i < j <= n and (a[i] <= key < a[j] or Q)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2104
  //     // with      Q: for all i: 0 <= i < n: key < a[i]
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2105
  //     // where a stands for the array and assuming that the (inexisting)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2106
  //     // element a[n] is infinitely big.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2107
  //     int h = (i + j) >> 1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2108
  //     // i < h < j
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2109
  //     if (key < array[h].fast_match()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2110
  //       j = h;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2111
  //     } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2112
  //       i = h;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2113
  //     }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2114
  //   }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2115
  //   // R: a[i] <= key < a[i+1] or Q
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2116
  //   // (i.e., if key is within array, i is the correct index)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2117
  //   return i;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2118
  // }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2119
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2120
  // register allocation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2121
  const Register Rkey     = R17_tos;          // already set (tosca)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2122
  const Register Rarray   = R3_ARG1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2123
  const Register Ri       = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2124
  const Register Rj       = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2125
  const Register Rh       = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2126
  const Register Rscratch = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2127
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2128
  const int log_entry_size = 3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2129
  const int entry_size = 1 << log_entry_size;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2130
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2131
  Label found;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2132
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2133
  // Find Array start,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2134
  __ addi(Rarray, R14_bcp, 3 * BytesPerInt);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2135
  __ clrrdi(Rarray, Rarray, log2_long((jlong)BytesPerInt));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2136
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2137
  // initialize i & j
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2138
  __ li(Ri,0);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2139
  __ get_u4(Rj, Rarray, -BytesPerInt, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2140
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2141
  // and start.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2142
  Label entry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2143
  __ b(entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2144
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2145
  // binary search loop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2146
  { Label loop;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2147
    __ bind(loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2148
    // int h = (i + j) >> 1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2149
    __ srdi(Rh, Rh, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2150
    // if (key < array[h].fast_match()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2151
    //   j = h;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2152
    // } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2153
    //   i = h;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2154
    // }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2155
    __ sldi(Rscratch, Rh, log_entry_size);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2156
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2157
    __ lwbrx(Rscratch, Rscratch, Rarray);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2158
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2159
    __ lwzx(Rscratch, Rscratch, Rarray);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2160
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2161
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2162
    // if (key < current value)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2163
    //   Rh = Rj
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2164
    // else
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2165
    //   Rh = Ri
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2166
    Label Lgreater;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2167
    __ cmpw(CCR0, Rkey, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2168
    __ bge(CCR0, Lgreater);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2169
    __ mr(Rj, Rh);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2170
    __ b(entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2171
    __ bind(Lgreater);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2172
    __ mr(Ri, Rh);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2173
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2174
    // while (i+1 < j)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2175
    __ bind(entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2176
    __ addi(Rscratch, Ri, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2177
    __ cmpw(CCR0, Rscratch, Rj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2178
    __ add(Rh, Ri, Rj); // start h = i + j >> 1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2179
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2180
    __ blt(CCR0, loop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2181
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2182
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2183
  // End of binary search, result index is i (must check again!).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2184
  Label default_case;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2185
  Label continue_execution;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2186
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2187
    __ mr(Rh, Ri);              // Save index in i for profiling.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2188
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2189
  // Ri = value offset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2190
  __ sldi(Ri, Ri, log_entry_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2191
  __ add(Ri, Ri, Rarray);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2192
  __ get_u4(Rscratch, Ri, 0, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2193
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2194
  Label not_found;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2195
  // Ri = offset offset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2196
  __ cmpw(CCR0, Rkey, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2197
  __ beq(CCR0, not_found);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2198
  // entry not found -> j = default offset
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2199
  __ get_u4(Rj, Rarray, -2 * BytesPerInt, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2200
  __ b(default_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2201
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2202
  __ bind(not_found);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2203
  // entry found -> j = offset
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2204
  __ profile_switch_case(Rh, Rj, Rscratch, Rkey);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2205
  __ get_u4(Rj, Ri, BytesPerInt, InterpreterMacroAssembler::Unsigned);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2206
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2207
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2208
    __ b(continue_execution);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2209
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2210
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2211
  __ bind(default_case); // fall through (if not profiling)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2212
  __ profile_switch_default(Ri, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2213
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2214
  __ bind(continue_execution);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2215
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2216
  __ extsw(Rj, Rj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2217
  __ add(R14_bcp, Rj, R14_bcp);
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2218
  __ dispatch_next(vtos, 0 , true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2219
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2220
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2221
void TemplateTable::_return(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2222
  transition(state, state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2223
  assert(_desc->calls_vm(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2224
         "inconsistent calls_vm information"); // call in remove_activation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2225
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2226
  if (_desc->bytecode() == Bytecodes::_return_register_finalizer) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2227
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2228
    Register Rscratch     = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2229
             Rklass       = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2230
             Rklass_flags = Rklass;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2231
    Label Lskip_register_finalizer;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2232
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2233
    // Check if the method has the FINALIZER flag set and call into the VM to finalize in this case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2234
    assert(state == vtos, "only valid state");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2235
    __ ld(R17_tos, 0, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2236
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2237
    // Load klass of this obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2238
    __ load_klass(Rklass, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2239
    __ lwz(Rklass_flags, in_bytes(Klass::access_flags_offset()), Rklass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2240
    __ testbitdi(CCR0, R0, Rklass_flags, exact_log2(JVM_ACC_HAS_FINALIZER));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2241
    __ bfalse(CCR0, Lskip_register_finalizer);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2242
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2243
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::register_finalizer), R17_tos /* obj */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2244
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2245
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2246
    __ bind(Lskip_register_finalizer);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2247
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2248
48332
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2249
  if (SafepointMechanism::uses_thread_local_poll() && _desc->bytecode() != Bytecodes::_return_register_finalizer) {
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2250
    Label no_safepoint;
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2251
    __ ld(R11_scratch1, in_bytes(Thread::polling_page_offset()), R16_thread);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2252
    __ andi_(R11_scratch1, R11_scratch1, SafepointMechanism::poll_bit());
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2253
    __ beq(CCR0, no_safepoint);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2254
    __ push(state);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2255
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint));
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2256
    __ pop(state);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2257
    __ bind(no_safepoint);
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2258
  }
651a95f30dfb 8193257: PPC64, s390 implementation for Thread-local handshakes
mdoerr
parents: 48142
diff changeset
  2259
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2260
  // Move the result value into the correct register and remove memory stack frame.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2261
  __ remove_activation(state, /* throw_monitor_exception */ true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2262
  // Restoration of lr done by remove_activation.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2263
  switch (state) {
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2264
    // Narrow result if state is itos but result type is smaller.
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2265
    // Need to narrow in the return bytecode rather than in generate_return_entry
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2266
    // since compiled code callers expect the result to already be narrowed.
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2267
    case itos: __ narrow(R17_tos); /* fall through */
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2268
    case ltos:
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2269
    case atos: __ mr(R3_RET, R17_tos); break;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2270
    case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2271
    case dtos: __ fmr(F1_RET, F15_ftos); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2272
    case vtos: // This might be a constructor. Final fields (and volatile fields on PPC64) need
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2273
               // to get visible before the reference to the object gets stored anywhere.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2274
               __ membar(Assembler::StoreStore); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2275
    default  : ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2276
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2277
  __ blr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2278
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2279
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2280
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2281
// Constant pool cache access
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2282
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2283
// Memory ordering:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2284
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2285
// Like done in C++ interpreter, we load the fields
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2286
//   - _indices
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2287
//   - _f12_oop
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2288
// acquired, because these are asked if the cache is already resolved. We don't
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2289
// want to float loads above this check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2290
// See also comments in ConstantPoolCacheEntry::bytecode_1(),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2291
// ConstantPoolCacheEntry::bytecode_2() and ConstantPoolCacheEntry::f1();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2292
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2293
// Call into the VM if call site is not yet resolved
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2294
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2295
// Input regs:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2296
//   - None, all passed regs are outputs.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2297
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2298
// Returns:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2299
//   - Rcache:  The const pool cache entry that contains the resolved result.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2300
//   - Rresult: Either noreg or output for f1/f2.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2301
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2302
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2303
//   - Rscratch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2304
void TemplateTable::resolve_cache_and_index(int byte_no, Register Rcache, Register Rscratch, size_t index_size) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2305
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2306
  __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2307
  Label Lresolved, Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2308
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2309
  Bytecodes::Code code = bytecode();
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2310
  switch (code) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2311
  case Bytecodes::_nofast_getfield: code = Bytecodes::_getfield; break;
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2312
  case Bytecodes::_nofast_putfield: code = Bytecodes::_putfield; break;
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2313
  }
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2314
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2315
  assert(byte_no == f1_byte || byte_no == f2_byte, "byte_no out of range");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2316
  // We are resolved if the indices offset contains the current bytecode.
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2317
#if defined(VM_LITTLE_ENDIAN)
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2318
  __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + byte_no + 1, Rcache);
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2319
#else
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2320
  __ lbz(Rscratch, in_bytes(ConstantPoolCache::base_offset() + ConstantPoolCacheEntry::indices_offset()) + 7 - (byte_no + 1), Rcache);
25916
c5c22fab48fd 8050942: PPC64: implement template interpreter for ppc64le
kvn
parents: 25715
diff changeset
  2321
#endif
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2322
  // Acquire by cmp-br-isync (see below).
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2323
  __ cmpdi(CCR0, Rscratch, (int)code);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2324
  __ beq(CCR0, Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2325
30132
1f788eb36811 8076492: Make common code from template interpreter code
coleenp
parents: 30120
diff changeset
  2326
  address entry = CAST_FROM_FN_PTR(address, InterpreterRuntime::resolve_from_cache);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2327
  __ li(R4_ARG2, code);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2328
  __ call_VM(noreg, entry, R4_ARG2, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2329
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2330
  // Update registers with resolved info.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2331
  __ get_cache_and_index_at_bcp(Rcache, 1, index_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2332
  __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2333
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2334
  __ bind(Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2335
  __ isync(); // Order load wrt. succeeding loads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2336
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2337
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2338
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2339
// Load the constant pool cache entry at field accesses into registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2340
// The Rcache and Rindex registers must be set before call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2341
// Input:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2342
//   - Rcache, Rindex
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2343
// Output:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2344
//   - Robj, Roffset, Rflags
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2345
void TemplateTable::load_field_cp_cache_entry(Register Robj,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2346
                                              Register Rcache,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2347
                                              Register Rindex /* unused on PPC64 */,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2348
                                              Register Roffset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2349
                                              Register Rflags,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2350
                                              bool is_static = false) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2351
  assert_different_registers(Rcache, Rflags, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2352
  // assert(Rindex == noreg, "parameter not used on PPC64");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2353
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2354
  ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2355
  __ ld(Rflags, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::flags_offset()), Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2356
  __ ld(Roffset, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::f2_offset()), Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2357
  if (is_static) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2358
    __ ld(Robj, in_bytes(cp_base_offset) + in_bytes(ConstantPoolCacheEntry::f1_offset()), Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2359
    __ ld(Robj, in_bytes(Klass::java_mirror_offset()), Robj);
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
  2360
    __ resolve_oop_handle(Robj);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2361
    // Acquire not needed here. Following access has an address dependency on this value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2362
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2363
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2364
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2365
// Load the constant pool cache entry at invokes into registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2366
// Resolve if necessary.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2367
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2368
// Input Registers:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2369
//   - None, bcp is used, though
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2370
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2371
// Return registers:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2372
//   - Rmethod       (f1 field or f2 if invokevirtual)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2373
//   - Ritable_index (f2 field)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2374
//   - Rflags        (flags field)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2375
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2376
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2377
//   - R21
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2378
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2379
void TemplateTable::load_invoke_cp_cache_entry(int byte_no,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2380
                                               Register Rmethod,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2381
                                               Register Ritable_index,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2382
                                               Register Rflags,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2383
                                               bool is_invokevirtual,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2384
                                               bool is_invokevfinal,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2385
                                               bool is_invokedynamic) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2386
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2387
  ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2388
  // Determine constant pool cache field offsets.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2389
  assert(is_invokevirtual == (byte_no == f2_byte), "is_invokevirtual flag redundant");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2390
  const int method_offset = in_bytes(cp_base_offset + (is_invokevirtual ? ConstantPoolCacheEntry::f2_offset() : ConstantPoolCacheEntry::f1_offset()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2391
  const int flags_offset  = in_bytes(cp_base_offset + ConstantPoolCacheEntry::flags_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2392
  // Access constant pool cache fields.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2393
  const int index_offset  = in_bytes(cp_base_offset + ConstantPoolCacheEntry::f2_offset());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2394
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2395
  Register Rcache = R21_tmp1; // Note: same register as R21_sender_SP.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2396
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2397
  if (is_invokevfinal) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2398
    assert(Ritable_index == noreg, "register not used");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2399
    // Already resolved.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2400
    __ get_cache_and_index_at_bcp(Rcache, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2401
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2402
    resolve_cache_and_index(byte_no, Rcache, R0, is_invokedynamic ? sizeof(u4) : sizeof(u2));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2403
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2404
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2405
  __ ld(Rmethod, method_offset, Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2406
  __ ld(Rflags, flags_offset, Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2407
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2408
  if (Ritable_index != noreg) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2409
    __ ld(Ritable_index, index_offset, Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2410
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2411
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2412
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2413
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2414
// Field access
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2415
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2416
// Volatile variables demand their effects be made known to all CPU's
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2417
// in order. Store buffers on most chips allow reads & writes to
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2418
// reorder; the JMM's ReadAfterWrite.java test fails in -Xint mode
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2419
// without some kind of memory barrier (i.e., it's not sufficient that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2420
// the interpreter does not reorder volatile references, the hardware
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2421
// also must not reorder them).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2422
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2423
// According to the new Java Memory Model (JMM):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2424
// (1) All volatiles are serialized wrt to each other. ALSO reads &
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2425
//     writes act as aquire & release, so:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2426
// (2) A read cannot let unrelated NON-volatile memory refs that
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2427
//     happen after the read float up to before the read. It's OK for
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2428
//     non-volatile memory refs that happen before the volatile read to
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2429
//     float down below it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2430
// (3) Similar a volatile write cannot let unrelated NON-volatile
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2431
//     memory refs that happen BEFORE the write float down to after the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2432
//     write. It's OK for non-volatile memory refs that happen after the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2433
//     volatile write to float up before it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2434
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2435
// We only put in barriers around volatile refs (they are expensive),
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2436
// not _between_ memory refs (that would require us to track the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2437
// flavor of the previous memory refs). Requirements (2) and (3)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2438
// require some barriers before volatile stores and after volatile
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2439
// loads. These nearly cover requirement (1) but miss the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2440
// volatile-store-volatile-load case.  This final case is placed after
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2441
// volatile-stores although it could just as well go before
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2442
// volatile-loads.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2443
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2444
// The registers cache and index expected to be set before call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2445
// Correct values of the cache and index registers are preserved.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2446
// Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2447
//   Rcache (if has_tos)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2448
//   Rscratch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2449
void TemplateTable::jvmti_post_field_access(Register Rcache, Register Rscratch, bool is_static, bool has_tos) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2450
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2451
  assert_different_registers(Rcache, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2452
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2453
  if (JvmtiExport::can_post_field_access()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2454
    ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2455
    Label Lno_field_access_post;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2456
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2457
    // Check if post field access in enabled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2458
    int offs = __ load_const_optimized(Rscratch, JvmtiExport::get_field_access_count_addr(), R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2459
    __ lwz(Rscratch, offs, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2460
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2461
    __ cmpwi(CCR0, Rscratch, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2462
    __ beq(CCR0, Lno_field_access_post);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2463
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2464
    // Post access enabled - do it!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2465
    __ addi(Rcache, Rcache, in_bytes(cp_base_offset));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2466
    if (is_static) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2467
      __ li(R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2468
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2469
      if (has_tos) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2470
        // The fast bytecode versions have obj ptr in register.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2471
        // Thus, save object pointer before call_VM() clobbers it
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2472
        // put object on tos where GC wants it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2473
        __ push_ptr(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2474
      } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2475
        // Load top of stack (do not pop the value off the stack).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2476
        __ ld(R17_tos, Interpreter::expr_offset_in_bytes(0), R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2477
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2478
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2479
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2480
    // tos:   object pointer or NULL if static
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2481
    // cache: cache entry pointer
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2482
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_access), R17_tos, Rcache);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2483
    if (!is_static && has_tos) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2484
      // Restore object pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2485
      __ pop_ptr(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2486
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2487
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2488
      // Cache is still needed to get class or obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2489
      __ get_cache_and_index_at_bcp(Rcache, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2490
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2491
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2492
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2493
    __ bind(Lno_field_access_post);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2494
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2495
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2496
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2497
// kills R11_scratch1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2498
void TemplateTable::pop_and_check_object(Register Roop) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2499
  Register Rtmp = R11_scratch1;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2500
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2501
  assert_different_registers(Rtmp, Roop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2502
  __ pop_ptr(Roop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2503
  // For field access must check obj.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2504
  __ null_check_throw(Roop, -1, Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2505
  __ verify_oop(Roop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2506
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2507
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2508
// PPC64: implement volatile loads as fence-store-acquire.
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2509
void TemplateTable::getfield_or_static(int byte_no, bool is_static, RewriteControl rc) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2510
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2511
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2512
  Label Lacquire, Lisync;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2513
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2514
  const Register Rcache        = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2515
                 Rclass_or_obj = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2516
                 Roffset       = R23_tmp3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2517
                 Rflags        = R31,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2518
                 Rbtable       = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2519
                 Rbc           = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2520
                 Rscratch      = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2521
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2522
  static address field_branch_table[number_of_states],
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2523
                 static_branch_table[number_of_states];
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2524
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2525
  address* branch_table = (is_static || rc == may_not_rewrite) ? static_branch_table : field_branch_table;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2526
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2527
  // Get field offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2528
  resolve_cache_and_index(byte_no, Rcache, Rscratch, sizeof(u2));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2529
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2530
  // JVMTI support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2531
  jvmti_post_field_access(Rcache, Rscratch, is_static, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2532
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2533
  // Load after possible GC.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2534
  load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2535
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2536
  // Load pointer to branch table.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2537
  __ load_const_optimized(Rbtable, (address)branch_table, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2538
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2539
  // Get volatile flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2540
  __ rldicl(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // Extract volatile bit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2541
  // Note: sync is needed before volatile load on PPC64.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2542
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2543
  // Check field type.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2544
  __ rldicl(Rflags, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2545
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2546
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2547
  Label LFlagInvalid;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2548
  __ cmpldi(CCR0, Rflags, number_of_states);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2549
  __ bge(CCR0, LFlagInvalid);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2550
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2551
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2552
  // Load from branch table and dispatch (volatile case: one instruction ahead).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2553
  __ sldi(Rflags, Rflags, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2554
  __ cmpwi(CCR6, Rscratch, 1); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2555
  if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2556
    __ sldi(Rscratch, Rscratch, exact_log2(BytesPerInstWord)); // Volatile ? size of 1 instruction : 0.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2557
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2558
  __ ldx(Rbtable, Rbtable, Rflags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2559
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2560
  // Get the obj from stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2561
  if (!is_static) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2562
    pop_and_check_object(Rclass_or_obj); // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2563
  } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2564
    __ verify_oop(Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2565
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2566
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2567
  if (support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2568
    __ subf(Rbtable, Rscratch, Rbtable); // Point to volatile/non-volatile entry point.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2569
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2570
  __ mtctr(Rbtable);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2571
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2572
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2573
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2574
  __ bind(LFlagInvalid);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2575
  __ stop("got invalid flag", 0x654);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2576
#endif
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2577
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2578
  if (!is_static && rc == may_not_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2579
    // We reuse the code from is_static.  It's jumped to via the table above.
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2580
    return;
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2581
  }
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2582
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2583
#ifdef ASSERT
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2584
  // __ bind(Lvtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2585
  address pc_before_fence = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2586
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2587
  assert(__ pc() - pc_before_fence == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2588
  assert(branch_table[vtos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2589
  branch_table[vtos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2590
  __ stop("vtos unexpected", 0x655);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2591
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2592
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2593
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2594
  // __ bind(Ldtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2595
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2596
  assert(branch_table[dtos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2597
  branch_table[dtos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2598
  __ lfdx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2599
  __ push(dtos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2600
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2601
    patch_bytecode(Bytecodes::_fast_dgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2602
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2603
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2604
    Label acquire_double;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2605
    __ beq(CCR6, acquire_double); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2606
    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2607
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2608
    __ bind(acquire_double);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2609
    __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2610
    __ beq_predict_taken(CCR0, Lisync);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2611
    __ b(Lisync); // In case of NAN.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2612
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2613
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2614
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2615
  // __ bind(Lftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2616
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2617
  assert(branch_table[ftos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2618
  branch_table[ftos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2619
  __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2620
  __ push(ftos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2621
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2622
    patch_bytecode(Bytecodes::_fast_fgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2623
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2624
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2625
    Label acquire_float;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2626
    __ beq(CCR6, acquire_float); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2627
    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2628
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2629
    __ bind(acquire_float);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2630
    __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2631
    __ beq_predict_taken(CCR0, Lisync);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2632
    __ b(Lisync); // In case of NAN.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2633
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2634
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2635
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2636
  // __ bind(Litos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2637
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2638
  assert(branch_table[itos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2639
  branch_table[itos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2640
  __ lwax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2641
  __ push(itos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2642
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2643
    patch_bytecode(Bytecodes::_fast_igetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2644
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2645
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2646
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2647
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2648
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2649
  // __ bind(Lltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2650
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2651
  assert(branch_table[ltos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2652
  branch_table[ltos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2653
  __ ldx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2654
  __ push(ltos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2655
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2656
    patch_bytecode(Bytecodes::_fast_lgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2657
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2658
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2659
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2660
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2661
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2662
  // __ bind(Lbtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2663
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2664
  assert(branch_table[btos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2665
  branch_table[btos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2666
  __ lbzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2667
  __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2668
  __ push(btos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2669
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2670
    patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2671
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2672
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2673
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2674
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2675
  __ align(32, 28, 28); // Align load.
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2676
  // __ bind(Lztos); (same code as btos)
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2677
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2678
  assert(branch_table[ztos] == 0, "can't compute twice");
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2679
  branch_table[ztos] = __ pc(); // non-volatile_entry point
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2680
  __ lbzx(R17_tos, Rclass_or_obj, Roffset);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2681
  __ push(ztos);
41693
ad7de42d606b 8166689: PPC64: Race condition between stack bang and non-entrant patching
mdoerr
parents: 40030
diff changeset
  2682
  if (!is_static && rc == may_rewrite) {
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2683
    // use btos rewriting, no truncating to t/f bit is needed for getfield.
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2684
    patch_bytecode(Bytecodes::_fast_bgetfield, Rbc, Rscratch);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2685
  }
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2686
  __ beq(CCR6, Lacquire); // Volatile?
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2687
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2688
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2689
  __ align(32, 28, 28); // Align load.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2690
  // __ bind(Lctos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2691
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2692
  assert(branch_table[ctos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2693
  branch_table[ctos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2694
  __ lhzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2695
  __ push(ctos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2696
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2697
    patch_bytecode(Bytecodes::_fast_cgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2698
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2699
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2700
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2701
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2702
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2703
  // __ bind(Lstos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2704
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2705
  assert(branch_table[stos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2706
  branch_table[stos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2707
  __ lhax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2708
  __ push(stos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2709
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2710
    patch_bytecode(Bytecodes::_fast_sgetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2711
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2712
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2713
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2714
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2715
  __ align(32, 28, 28); // Align load.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2716
  // __ bind(Latos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2717
  __ fence(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2718
  assert(branch_table[atos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2719
  branch_table[atos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2720
  __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2721
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2722
  __ push(atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2723
  //__ dcbt(R17_tos); // prefetch
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2724
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2725
    patch_bytecode(Bytecodes::_fast_agetfield, Rbc, Rscratch);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2726
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2727
  __ beq(CCR6, Lacquire); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2728
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2729
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2730
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2731
  __ bind(Lacquire);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2732
  __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2733
  __ bind(Lisync);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2734
  __ isync(); // acquire
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2735
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2736
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2737
  for (int i = 0; i<number_of_states; ++i) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2738
    assert(branch_table[i], "get initialization");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2739
    //tty->print_cr("get: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2740
    //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2741
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2742
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2743
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2744
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2745
void TemplateTable::getfield(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2746
  getfield_or_static(byte_no, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2747
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2748
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2749
void TemplateTable::nofast_getfield(int byte_no) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2750
  getfield_or_static(byte_no, false, may_not_rewrite);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2751
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2752
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2753
void TemplateTable::getstatic(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2754
  getfield_or_static(byte_no, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2755
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2756
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2757
// The registers cache and index expected to be set before call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2758
// The function may destroy various registers, just not the cache and index registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2759
void TemplateTable::jvmti_post_field_mod(Register Rcache, Register Rscratch, bool is_static) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2760
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2761
  assert_different_registers(Rcache, Rscratch, R6_ARG4);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2762
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2763
  if (JvmtiExport::can_post_field_modification()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2764
    Label Lno_field_mod_post;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2765
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2766
    // Check if post field access in enabled.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2767
    int offs = __ load_const_optimized(Rscratch, JvmtiExport::get_field_modification_count_addr(), R0, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2768
    __ lwz(Rscratch, offs, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2769
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2770
    __ cmpwi(CCR0, Rscratch, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2771
    __ beq(CCR0, Lno_field_mod_post);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2772
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2773
    // Do the post
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2774
    ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2775
    const Register Robj = Rscratch;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2776
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2777
    __ addi(Rcache, Rcache, in_bytes(cp_base_offset));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2778
    if (is_static) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2779
      // Life is simple. Null out the object pointer.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2780
      __ li(Robj, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2781
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2782
      // In case of the fast versions, value lives in registers => put it back on tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2783
      int offs = Interpreter::expr_offset_in_bytes(0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2784
      Register base = R15_esp;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2785
      switch(bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2786
        case Bytecodes::_fast_aputfield: __ push_ptr(); offs+= Interpreter::stackElementSize; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2787
        case Bytecodes::_fast_iputfield: // Fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2788
        case Bytecodes::_fast_bputfield: // Fall through
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2789
        case Bytecodes::_fast_zputfield: // Fall through
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2790
        case Bytecodes::_fast_cputfield: // Fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2791
        case Bytecodes::_fast_sputfield: __ push_i(); offs+=  Interpreter::stackElementSize; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2792
        case Bytecodes::_fast_lputfield: __ push_l(); offs+=2*Interpreter::stackElementSize; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2793
        case Bytecodes::_fast_fputfield: __ push_f(); offs+=  Interpreter::stackElementSize; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2794
        case Bytecodes::_fast_dputfield: __ push_d(); offs+=2*Interpreter::stackElementSize; break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2795
        default: {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2796
          offs = 0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2797
          base = Robj;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2798
          const Register Rflags = Robj;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2799
          Label is_one_slot;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2800
          // Life is harder. The stack holds the value on top, followed by the
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2801
          // object. We don't know the size of the value, though; it could be
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2802
          // one or two words depending on its type. As a result, we must find
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2803
          // the type to determine where the object is.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2804
          __ ld(Rflags, in_bytes(ConstantPoolCacheEntry::flags_offset()), Rcache); // Big Endian
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2805
          __ rldicl(Rflags, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2806
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2807
          __ cmpwi(CCR0, Rflags, ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2808
          __ cmpwi(CCR1, Rflags, dtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2809
          __ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(1));
28492
57fecf138f7b 8068724: ppc64: update assembler: SPR access, CR logic, HTM
mdoerr
parents: 28187
diff changeset
  2810
          __ crnor(CCR0, Assembler::equal, CCR1, Assembler::equal);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2811
          __ beq(CCR0, is_one_slot);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2812
          __ addi(base, R15_esp, Interpreter::expr_offset_in_bytes(2));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2813
          __ bind(is_one_slot);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2814
          break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2815
        }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2816
      }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2817
      __ ld(Robj, offs, base);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2818
      __ verify_oop(Robj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2819
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2820
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2821
    __ addi(R6_ARG4, R15_esp, Interpreter::expr_offset_in_bytes(0));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2822
    __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::post_field_modification), Robj, Rcache, R6_ARG4);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2823
    __ get_cache_and_index_at_bcp(Rcache, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2824
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2825
    // In case of the fast versions, value lives in registers => put it back on tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2826
    switch(bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2827
      case Bytecodes::_fast_aputfield: __ pop_ptr(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2828
      case Bytecodes::_fast_iputfield: // Fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2829
      case Bytecodes::_fast_bputfield: // Fall through
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2830
      case Bytecodes::_fast_zputfield: // Fall through
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2831
      case Bytecodes::_fast_cputfield: // Fall through
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2832
      case Bytecodes::_fast_sputfield: __ pop_i(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2833
      case Bytecodes::_fast_lputfield: __ pop_l(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2834
      case Bytecodes::_fast_fputfield: __ pop_f(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2835
      case Bytecodes::_fast_dputfield: __ pop_d(); break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2836
      default: break; // Nothin' to do.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2837
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2838
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2839
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2840
    __ bind(Lno_field_mod_post);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2841
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2842
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2843
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2844
// PPC64: implement volatile stores as release-store (return bytecode contains an additional release).
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2845
void TemplateTable::putfield_or_static(int byte_no, bool is_static, RewriteControl rc) {
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2846
  Label Lvolatile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2847
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2848
  const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2849
                 Rclass_or_obj = R31,      // Needs to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2850
                 Roffset       = R22_tmp2, // Needs to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2851
                 Rflags        = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2852
                 Rbtable       = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2853
                 Rscratch      = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2854
                 Rscratch2     = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2855
                 Rscratch3     = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2856
                 Rbc           = Rscratch3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2857
  const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2858
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2859
  static address field_rw_branch_table[number_of_states],
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2860
                 field_norw_branch_table[number_of_states],
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2861
                 static_branch_table[number_of_states];
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2862
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2863
  address* branch_table = is_static ? static_branch_table :
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2864
    (rc == may_rewrite ? field_rw_branch_table : field_norw_branch_table);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2865
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2866
  // Stack (grows up):
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2867
  //  value
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2868
  //  obj
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2869
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2870
  // Load the field offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2871
  resolve_cache_and_index(byte_no, Rcache, Rscratch, sizeof(u2));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2872
  jvmti_post_field_mod(Rcache, Rscratch, is_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2873
  load_field_cp_cache_entry(Rclass_or_obj, Rcache, noreg, Roffset, Rflags, is_static);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2874
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2875
  // Load pointer to branch table.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2876
  __ load_const_optimized(Rbtable, (address)branch_table, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2877
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2878
  // Get volatile flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2879
  __ rldicl(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // Extract volatile bit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2880
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2881
  // Check the field type.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2882
  __ rldicl(Rflags, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2883
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2884
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2885
  Label LFlagInvalid;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2886
  __ cmpldi(CCR0, Rflags, number_of_states);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2887
  __ bge(CCR0, LFlagInvalid);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2888
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2889
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2890
  // Load from branch table and dispatch (volatile case: one instruction ahead).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2891
  __ sldi(Rflags, Rflags, LogBytesPerWord);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2892
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2893
    __ cmpwi(CR_is_vol, Rscratch, 1);  // Volatile?
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2894
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2895
  __ sldi(Rscratch, Rscratch, exact_log2(BytesPerInstWord)); // Volatile? size of instruction 1 : 0.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2896
  __ ldx(Rbtable, Rbtable, Rflags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2897
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2898
  __ subf(Rbtable, Rscratch, Rbtable); // Point to volatile/non-volatile entry point.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2899
  __ mtctr(Rbtable);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2900
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2901
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2902
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2903
  __ bind(LFlagInvalid);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2904
  __ stop("got invalid flag", 0x656);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2905
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2906
  // __ bind(Lvtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2907
  address pc_before_release = __ pc();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2908
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2909
  assert(__ pc() - pc_before_release == (ptrdiff_t)BytesPerInstWord, "must be single instruction");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2910
  assert(branch_table[vtos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2911
  branch_table[vtos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2912
  __ stop("vtos unexpected", 0x657);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2913
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2914
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2915
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2916
  // __ bind(Ldtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2917
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2918
  assert(branch_table[dtos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2919
  branch_table[dtos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2920
  __ pop(dtos);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2921
  if (!is_static) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2922
    pop_and_check_object(Rclass_or_obj);  // Kills R11_scratch1.
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2923
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2924
  __ stfdx(F15_ftos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2925
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2926
    patch_bytecode(Bytecodes::_fast_dputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2927
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2928
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2929
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2930
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2931
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2932
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2933
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2934
  // __ bind(Lftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2935
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2936
  assert(branch_table[ftos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2937
  branch_table[ftos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2938
  __ pop(ftos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2939
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2940
  __ stfsx(F15_ftos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2941
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2942
    patch_bytecode(Bytecodes::_fast_fputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2943
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2944
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2945
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2946
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2947
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2948
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2949
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2950
  // __ bind(Litos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2951
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2952
  assert(branch_table[itos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2953
  branch_table[itos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2954
  __ pop(itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2955
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2956
  __ stwx(R17_tos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2957
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2958
    patch_bytecode(Bytecodes::_fast_iputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2959
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2960
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2961
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2962
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2963
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2964
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2965
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2966
  // __ bind(Lltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2967
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2968
  assert(branch_table[ltos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2969
  branch_table[ltos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2970
  __ pop(ltos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2971
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2972
  __ stdx(R17_tos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2973
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2974
    patch_bytecode(Bytecodes::_fast_lputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2975
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2976
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2977
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2978
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2979
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2980
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2981
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2982
  // __ bind(Lbtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2983
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2984
  assert(branch_table[btos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2985
  branch_table[btos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2986
  __ pop(btos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2987
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2988
  __ stbx(R17_tos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2989
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2990
    patch_bytecode(Bytecodes::_fast_bputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  2991
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2992
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2993
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2994
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2995
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2996
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  2997
  __ align(32, 28, 28); // Align pop.
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2998
  // __ bind(Lztos);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  2999
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3000
  assert(branch_table[ztos] == 0, "can't compute twice");
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3001
  branch_table[ztos] = __ pc(); // non-volatile_entry point
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3002
  __ pop(ztos);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3003
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3004
  __ andi(R17_tos, R17_tos, 0x1);
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3005
  __ stbx(R17_tos, Rclass_or_obj, Roffset);
41693
ad7de42d606b 8166689: PPC64: Race condition between stack bang and non-entrant patching
mdoerr
parents: 40030
diff changeset
  3006
  if (!is_static && rc == may_rewrite) {
ad7de42d606b 8166689: PPC64: Race condition between stack bang and non-entrant patching
mdoerr
parents: 40030
diff changeset
  3007
    patch_bytecode(Bytecodes::_fast_zputfield, Rbc, Rscratch, true, byte_no);
ad7de42d606b 8166689: PPC64: Race condition between stack bang and non-entrant patching
mdoerr
parents: 40030
diff changeset
  3008
  }
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3009
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3010
    __ beq(CR_is_vol, Lvolatile); // Volatile?
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3011
  }
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3012
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3013
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3014
  __ align(32, 28, 28); // Align pop.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3015
  // __ bind(Lctos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3016
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3017
  assert(branch_table[ctos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3018
  branch_table[ctos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3019
  __ pop(ctos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3020
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1..
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3021
  __ sthx(R17_tos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3022
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3023
    patch_bytecode(Bytecodes::_fast_cputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3024
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3025
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3026
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3027
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3028
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3029
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3030
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3031
  // __ bind(Lstos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3032
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3033
  assert(branch_table[stos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3034
  branch_table[stos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3035
  __ pop(stos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3036
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3037
  __ sthx(R17_tos, Rclass_or_obj, Roffset);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3038
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3039
    patch_bytecode(Bytecodes::_fast_sputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3040
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3041
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3042
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3043
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3044
  __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3045
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3046
  __ align(32, 28, 28); // Align pop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3047
  // __ bind(Latos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3048
  __ release(); // Volatile entry point (one instruction before non-volatile_entry point).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3049
  assert(branch_table[atos] == 0, "can't compute twice");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3050
  branch_table[atos] = __ pc(); // non-volatile_entry point
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3051
  __ pop(atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3052
  if (!is_static) { pop_and_check_object(Rclass_or_obj); } // kills R11_scratch1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3053
  do_oop_store(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, Rscratch2, Rscratch3, _bs->kind(), false /* precise */, true /* check null */);
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3054
  if (!is_static && rc == may_rewrite) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3055
    patch_bytecode(Bytecodes::_fast_aputfield, Rbc, Rscratch, true, byte_no);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3056
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3057
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3058
    __ beq(CR_is_vol, Lvolatile); // Volatile?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3059
    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3060
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3061
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3062
    __ bind(Lvolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3063
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3064
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3065
  // fallthru: __ b(Lexit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3066
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3067
#ifdef ASSERT
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3068
  for (int i = 0; i<number_of_states; ++i) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3069
    assert(branch_table[i], "put initialization");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3070
    //tty->print_cr("put: %s_branch_table[%d] = 0x%llx (opcode 0x%llx)",
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3071
    //              is_static ? "static" : "field", i, branch_table[i], *((unsigned int*)branch_table[i]));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3072
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3073
#endif
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3074
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3075
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3076
void TemplateTable::putfield(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3077
  putfield_or_static(byte_no, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3078
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3079
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3080
void TemplateTable::nofast_putfield(int byte_no) {
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3081
  putfield_or_static(byte_no, false, may_not_rewrite);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3082
}
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3083
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3084
void TemplateTable::putstatic(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3085
  putfield_or_static(byte_no, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3086
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3087
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3088
// See SPARC. On PPC64, we have a different jvmti_post_field_mod which does the job.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3089
void TemplateTable::jvmti_post_fast_field_mod() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3090
  __ should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3091
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3092
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3093
void TemplateTable::fast_storefield(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3094
  transition(state, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3095
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3096
  const Register Rcache        = R5_ARG3,  // Do not use ARG1/2 (causes trouble in jvmti_post_field_mod).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3097
                 Rclass_or_obj = R31,      // Needs to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3098
                 Roffset       = R22_tmp2, // Needs to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3099
                 Rflags        = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3100
                 Rscratch      = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3101
                 Rscratch2     = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3102
                 Rscratch3     = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3103
  const ConditionRegister CR_is_vol = CCR2; // Non-volatile condition register (survives runtime call in do_oop_store).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3104
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3105
  // Constant pool already resolved => Load flags and offset of field.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3106
  __ get_cache_and_index_at_bcp(Rcache, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3107
  jvmti_post_field_mod(Rcache, Rscratch, false /* not static */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3108
  load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3109
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3110
  // Get the obj and the final store addr.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3111
  pop_and_check_object(Rclass_or_obj); // Kills R11_scratch1.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3112
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3113
  // Get volatile flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3114
  __ rldicl_(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // Extract volatile bit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3115
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) { __ cmpdi(CR_is_vol, Rscratch, 1); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3116
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3117
    Label LnotVolatile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3118
    __ beq(CCR0, LnotVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3119
    __ release();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3120
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3121
    __ bind(LnotVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3122
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3123
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3124
  // Do the store and fencing.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3125
  switch(bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3126
    case Bytecodes::_fast_aputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3127
      // Store into the field.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3128
      do_oop_store(_masm, Rclass_or_obj, Roffset, R17_tos, Rscratch, Rscratch2, Rscratch3, _bs->kind(), false /* precise */, true /* check null */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3129
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3130
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3131
    case Bytecodes::_fast_iputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3132
      __ stwx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3133
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3134
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3135
    case Bytecodes::_fast_lputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3136
      __ stdx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3137
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3138
37488
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3139
    case Bytecodes::_fast_zputfield:
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3140
      __ andi(R17_tos, R17_tos, 0x1);  // boolean is true if LSB is 1
ab63cdc0e14e 8154867: PPC64: Better byte behavior
mdoerr
parents: 35913
diff changeset
  3141
      // fall through to bputfield
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3142
    case Bytecodes::_fast_bputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3143
      __ stbx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3144
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3145
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3146
    case Bytecodes::_fast_cputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3147
    case Bytecodes::_fast_sputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3148
      __ sthx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3149
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3150
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3151
    case Bytecodes::_fast_fputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3152
      __ stfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3153
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3154
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3155
    case Bytecodes::_fast_dputfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3156
      __ stfdx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3157
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3158
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3159
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3160
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3161
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3162
  if (!support_IRIW_for_not_multiple_copy_atomic_cpu) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3163
    Label LVolatile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3164
    __ beq(CR_is_vol, LVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3165
    __ dispatch_epilog(vtos, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3166
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3167
    __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3168
    __ bind(LVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3169
    __ fence();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3170
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3171
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3172
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3173
void TemplateTable::fast_accessfield(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3174
  transition(atos, state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3175
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3176
  Label LisVolatile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3177
  ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3178
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3179
  const Register Rcache        = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3180
                 Rclass_or_obj = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3181
                 Roffset       = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3182
                 Rflags        = R23_tmp3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3183
                 Rscratch      = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3184
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3185
  // Constant pool already resolved. Get the field offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3186
  __ get_cache_and_index_at_bcp(Rcache, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3187
  load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3188
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3189
  // JVMTI support
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3190
  jvmti_post_field_access(Rcache, Rscratch, false, true);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3191
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3192
  // Get the load address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3193
  __ null_check_throw(Rclass_or_obj, -1, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3194
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3195
  // Get volatile flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3196
  __ rldicl_(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // Extract volatile bit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3197
  __ bne(CCR0, LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3198
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3199
  switch(bytecode()) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3200
    case Bytecodes::_fast_agetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3201
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3202
      __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3203
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3204
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3205
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3206
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3207
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3208
      __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3209
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3210
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3211
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3212
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3213
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3214
    case Bytecodes::_fast_igetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3215
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3216
      __ lwax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3217
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3218
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3219
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3220
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3221
      __ lwax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3222
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3223
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3224
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3225
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3226
    case Bytecodes::_fast_lgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3227
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3228
      __ ldx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3229
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3230
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3231
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3232
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3233
      __ ldx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3234
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3235
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3236
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3237
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3238
    case Bytecodes::_fast_bgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3239
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3240
      __ lbzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3241
      __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3242
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3243
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3244
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3245
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3246
      __ lbzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3247
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3248
      __ extsb(R17_tos, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3249
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3250
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3251
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3252
    case Bytecodes::_fast_cgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3253
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3254
      __ lhzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3255
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3256
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3257
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3258
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3259
      __ lhzx(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3260
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3261
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3262
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3263
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3264
    case Bytecodes::_fast_sgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3265
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3266
      __ lhax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3267
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3268
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3269
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3270
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3271
      __ lhax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3272
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3273
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3274
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3275
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3276
    case Bytecodes::_fast_fgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3277
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3278
      __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3279
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3280
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3281
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3282
      Label Ldummy;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3283
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3284
      __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3285
      __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3286
      __ bne_predict_not_taken(CCR0, Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3287
      __ bind(Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3288
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3289
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3290
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3291
    case Bytecodes::_fast_dgetfield:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3292
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3293
      __ lfdx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3294
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3295
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3296
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3297
      Label Ldummy;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3298
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3299
      __ lfdx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3300
      __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3301
      __ bne_predict_not_taken(CCR0, Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3302
      __ bind(Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3303
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3304
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3305
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3306
    default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3307
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3308
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3309
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3310
void TemplateTable::fast_xaccess(TosState state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3311
  transition(vtos, state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3312
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3313
  Label LisVolatile;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3314
  ByteSize cp_base_offset = ConstantPoolCache::base_offset();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3315
  const Register Rcache        = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3316
                 Rclass_or_obj = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3317
                 Roffset       = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3318
                 Rflags        = R23_tmp3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3319
                 Rscratch      = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3320
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3321
  __ ld(Rclass_or_obj, 0, R18_locals);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3322
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3323
  // Constant pool already resolved. Get the field offset.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3324
  __ get_cache_and_index_at_bcp(Rcache, 2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3325
  load_field_cp_cache_entry(noreg, Rcache, noreg, Roffset, Rflags, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3326
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3327
  // JVMTI support not needed, since we switch back to single bytecode as soon as debugger attaches.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3328
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3329
  // Needed to report exception at the correct bcp.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3330
  __ addi(R14_bcp, R14_bcp, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3331
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3332
  // Get the load address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3333
  __ null_check_throw(Rclass_or_obj, -1, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3334
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3335
  // Get volatile flag.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3336
  __ rldicl_(Rscratch, Rflags, 64-ConstantPoolCacheEntry::is_volatile_shift, 63); // Extract volatile bit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3337
  __ bne(CCR0, LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3338
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3339
  switch(state) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3340
  case atos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3341
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3342
      __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3343
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3344
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()) - 1); // Undo bcp increment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3345
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3346
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3347
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3348
      __ load_heap_oop(R17_tos, (RegisterOrConstant)Roffset, Rclass_or_obj);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3349
      __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3350
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3351
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3352
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3353
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3354
  case itos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3355
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3356
      __ lwax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3357
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()) - 1); // Undo bcp increment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3358
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3359
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3360
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3361
      __ lwax(R17_tos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3362
      __ twi_0(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3363
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3364
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3365
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3366
  case ftos:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3367
    {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3368
      __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3369
      __ dispatch_epilog(state, Bytecodes::length_for(bytecode()) - 1); // Undo bcp increment.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3370
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3371
      __ bind(LisVolatile);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3372
      Label Ldummy;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3373
      if (support_IRIW_for_not_multiple_copy_atomic_cpu) { __ fence(); }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3374
      __ lfsx(F15_ftos, Rclass_or_obj, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3375
      __ fcmpu(CCR0, F15_ftos, F15_ftos); // Acquire by cmp-br-isync.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3376
      __ bne_predict_not_taken(CCR0, Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3377
      __ bind(Ldummy);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3378
      __ isync();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3379
      break;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3380
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3381
  default: ShouldNotReachHere();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3382
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3383
  __ addi(R14_bcp, R14_bcp, -1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3384
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3385
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3386
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3387
// Calls
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3388
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3389
// Common code for invoke
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3390
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3391
// Input:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3392
//   - byte_no
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3393
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3394
// Output:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3395
//   - Rmethod:        The method to invoke next.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3396
//   - Rret_addr:      The return address to return to.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3397
//   - Rindex:         MethodType (invokehandle) or CallSite obj (invokedynamic)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3398
//   - Rrecv:          Cache for "this" pointer, might be noreg if static call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3399
//   - Rflags:         Method flags from const pool cache.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3400
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3401
//  Kills:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3402
//   - Rscratch1
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3403
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3404
void TemplateTable::prepare_invoke(int byte_no,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3405
                                   Register Rmethod,  // linked method (or i-klass)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3406
                                   Register Rret_addr,// return address
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3407
                                   Register Rindex,   // itable index, MethodType, etc.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3408
                                   Register Rrecv,    // If caller wants to see it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3409
                                   Register Rflags,   // If caller wants to test it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3410
                                   Register Rscratch
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3411
                                   ) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3412
  // Determine flags.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3413
  const Bytecodes::Code code = bytecode();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3414
  const bool is_invokeinterface  = code == Bytecodes::_invokeinterface;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3415
  const bool is_invokedynamic    = code == Bytecodes::_invokedynamic;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3416
  const bool is_invokehandle     = code == Bytecodes::_invokehandle;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3417
  const bool is_invokevirtual    = code == Bytecodes::_invokevirtual;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3418
  const bool is_invokespecial    = code == Bytecodes::_invokespecial;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3419
  const bool load_receiver       = (Rrecv != noreg);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3420
  assert(load_receiver == (code != Bytecodes::_invokestatic && code != Bytecodes::_invokedynamic), "");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3421
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3422
  assert_different_registers(Rmethod, Rindex, Rflags, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3423
  assert_different_registers(Rmethod, Rrecv, Rflags, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3424
  assert_different_registers(Rret_addr, Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3425
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3426
  load_invoke_cp_cache_entry(byte_no, Rmethod, Rindex, Rflags, is_invokevirtual, false, is_invokedynamic);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3427
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3428
  // Saving of SP done in call_from_interpreter.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3429
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3430
  // Maybe push "appendix" to arguments.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3431
  if (is_invokedynamic || is_invokehandle) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3432
    Label Ldone;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3433
    __ rldicl_(R0, Rflags, 64-ConstantPoolCacheEntry::has_appendix_shift, 63);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3434
    __ beq(CCR0, Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3435
    // Push "appendix" (MethodType, CallSite, etc.).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3436
    // This must be done before we get the receiver,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3437
    // since the parameter_size includes it.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3438
    __ load_resolved_reference_at_index(Rscratch, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3439
    __ verify_oop(Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3440
    __ push_ptr(Rscratch);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3441
    __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3442
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3443
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3444
  // Load receiver if needed (after appendix is pushed so parameter size is correct).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3445
  if (load_receiver) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3446
    const Register Rparam_count = Rscratch;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3447
    __ andi(Rparam_count, Rflags, ConstantPoolCacheEntry::parameter_size_mask);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3448
    __ load_receiver(Rparam_count, Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3449
    __ verify_oop(Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3450
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3451
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3452
  // Get return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3453
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3454
    Register Rtable_addr = Rscratch;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3455
    Register Rret_type = Rret_addr;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3456
    address table_addr = (address) Interpreter::invoke_return_entry_table_for(code);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3457
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3458
    // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3459
    __ rldicl(Rret_type, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3460
    __ load_dispatch_table(Rtable_addr, (address*)table_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3461
    __ sldi(Rret_type, Rret_type, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3462
    // Get return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3463
    __ ldx(Rret_addr, Rtable_addr, Rret_type);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3464
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3465
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3466
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3467
// Helper for virtual calls. Load target out of vtable and jump off!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3468
// Kills all passed registers.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3469
void TemplateTable::generate_vtable_call(Register Rrecv_klass, Register Rindex, Register Rret, Register Rtemp) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3470
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3471
  assert_different_registers(Rrecv_klass, Rtemp, Rret);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3472
  const Register Rtarget_method = Rindex;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3473
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3474
  // Get target method & entry point.
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  3475
  const int base = in_bytes(Klass::vtable_start_offset());
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3476
  // Calc vtable addr scale the vtable index by 8.
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35232
diff changeset
  3477
  __ sldi(Rindex, Rindex, exact_log2(vtableEntry::size_in_bytes()));
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3478
  // Load target.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3479
  __ addi(Rrecv_klass, Rrecv_klass, base + vtableEntry::method_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3480
  __ ldx(Rtarget_method, Rindex, Rrecv_klass);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3481
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3482
  __ profile_arguments_type(Rtarget_method, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3483
  __ call_from_interpreter(Rtarget_method, Rret, Rrecv_klass /* scratch1 */, Rtemp /* scratch2 */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3484
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3485
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3486
// Virtual or final call. Final calls are rewritten on the fly to run through "fast_finalcall" next time.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3487
void TemplateTable::invokevirtual(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3488
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3489
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3490
  Register Rtable_addr = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3491
           Rret_type = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3492
           Rret_addr = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3493
           Rflags = R22_tmp2, // Should survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3494
           Rrecv = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3495
           Rrecv_klass = Rrecv,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3496
           Rvtableindex_or_method = R31, // Should survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3497
           Rnum_params = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3498
           Rnew_bc = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3499
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3500
  Label LnotFinal;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3501
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3502
  load_invoke_cp_cache_entry(byte_no, Rvtableindex_or_method, noreg, Rflags, /*virtual*/ true, false, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3503
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3504
  __ testbitdi(CCR0, R0, Rflags, ConstantPoolCacheEntry::is_vfinal_shift);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3505
  __ bfalse(CCR0, LnotFinal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3506
48142
b7fc502cb8aa 8191770: [ppc64] Fix CDS: don't rewrite invokefinal if DumpSharedSpaces
simonis
parents: 47580
diff changeset
  3507
  if (RewriteBytecodes && !UseSharedSpaces && !DumpSharedSpaces) {
30119
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3508
    patch_bytecode(Bytecodes::_fast_invokevfinal, Rnew_bc, R12_scratch2);
7c3010fca7e7 8076163: ppc: port "8074345: Enable RewriteBytecodes when VM runs with CDS"
goetz
parents: 28837
diff changeset
  3509
  }
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3510
  invokevfinal_helper(Rvtableindex_or_method, Rflags, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3511
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3512
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3513
  __ bind(LnotFinal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3514
  // Load "this" pointer (receiver).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3515
  __ rldicl(Rnum_params, Rflags, 64, 48);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3516
  __ load_receiver(Rnum_params, Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3517
  __ verify_oop(Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3518
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3519
  // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3520
  __ rldicl(Rret_type, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3521
  __ load_dispatch_table(Rtable_addr, Interpreter::invoke_return_entry_table());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3522
  __ sldi(Rret_type, Rret_type, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3523
  __ ldx(Rret_addr, Rret_type, Rtable_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3524
  __ null_check_throw(Rrecv, oopDesc::klass_offset_in_bytes(), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3525
  __ load_klass(Rrecv_klass, Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3526
  __ verify_klass_ptr(Rrecv_klass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3527
  __ profile_virtual_call(Rrecv_klass, R11_scratch1, R12_scratch2, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3528
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3529
  generate_vtable_call(Rrecv_klass, Rvtableindex_or_method, Rret_addr, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3530
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3531
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3532
void TemplateTable::fast_invokevfinal(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3533
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3534
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3535
  assert(byte_no == f2_byte, "use this argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3536
  Register Rflags  = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3537
           Rmethod = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3538
  load_invoke_cp_cache_entry(byte_no, Rmethod, noreg, Rflags, /*virtual*/ true, /*is_invokevfinal*/ true, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3539
  invokevfinal_helper(Rmethod, Rflags, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3540
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3541
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3542
void TemplateTable::invokevfinal_helper(Register Rmethod, Register Rflags, Register Rscratch1, Register Rscratch2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3543
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3544
  assert_different_registers(Rmethod, Rflags, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3545
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3546
  // Load receiver from stack slot.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3547
  Register Rrecv = Rscratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3548
  Register Rnum_params = Rrecv;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3549
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3550
  __ ld(Rnum_params, in_bytes(Method::const_offset()), Rmethod);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3551
  __ lhz(Rnum_params /* number of params */, in_bytes(ConstMethod::size_of_parameters_offset()), Rnum_params);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3552
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3553
  // Get return address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3554
  Register Rtable_addr = Rscratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3555
           Rret_addr   = Rflags,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3556
           Rret_type   = Rret_addr;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3557
  // Get return type. It's coded into the upper 4 bits of the lower half of the 64 bit value.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3558
  __ rldicl(Rret_type, Rflags, 64-ConstantPoolCacheEntry::tos_state_shift, 64-ConstantPoolCacheEntry::tos_state_bits);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3559
  __ load_dispatch_table(Rtable_addr, Interpreter::invoke_return_entry_table());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3560
  __ sldi(Rret_type, Rret_type, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3561
  __ ldx(Rret_addr, Rret_type, Rtable_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3562
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3563
  // Load receiver and receiver NULL check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3564
  __ load_receiver(Rnum_params, Rrecv);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3565
  __ null_check_throw(Rrecv, -1, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3566
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3567
  __ profile_final_call(Rrecv, Rscratch1);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3568
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3569
  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3570
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3571
  // Do the call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3572
  __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3573
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3574
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3575
void TemplateTable::invokespecial(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3576
  assert(byte_no == f1_byte, "use this argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3577
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3578
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3579
  Register Rtable_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3580
           Rret_addr   = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3581
           Rflags      = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3582
           Rreceiver   = R6_ARG4,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3583
           Rmethod     = R31;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3584
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3585
  prepare_invoke(byte_no, Rmethod, Rret_addr, noreg, Rreceiver, Rflags, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3586
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3587
  // Receiver NULL check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3588
  __ null_check_throw(Rreceiver, -1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3589
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3590
  __ profile_call(R11_scratch1, R12_scratch2);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3591
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3592
  __ profile_arguments_type(Rmethod, R11_scratch1, R12_scratch2, false);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3593
  __ call_from_interpreter(Rmethod, Rret_addr, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3594
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3595
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3596
void TemplateTable::invokestatic(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3597
  assert(byte_no == f1_byte, "use this argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3598
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3599
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3600
  Register Rtable_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3601
           Rret_addr   = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3602
           Rflags      = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3603
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3604
  prepare_invoke(byte_no, R19_method, Rret_addr, noreg, noreg, Rflags, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3605
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3606
  __ profile_call(R11_scratch1, R12_scratch2);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3607
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3608
  __ profile_arguments_type(R19_method, R11_scratch1, R12_scratch2, false);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3609
  __ call_from_interpreter(R19_method, Rret_addr, R11_scratch1, R12_scratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3610
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3611
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3612
void TemplateTable::invokeinterface_object_method(Register Rrecv_klass,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3613
                                                  Register Rret,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3614
                                                  Register Rflags,
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3615
                                                  Register Rmethod,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3616
                                                  Register Rtemp1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3617
                                                  Register Rtemp2) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3618
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3619
  assert_different_registers(Rmethod, Rret, Rrecv_klass, Rflags, Rtemp1, Rtemp2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3620
  Label LnotFinal;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3621
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3622
  // Check for vfinal.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3623
  __ testbitdi(CCR0, R0, Rflags, ConstantPoolCacheEntry::is_vfinal_shift);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3624
  __ bfalse(CCR0, LnotFinal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3625
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3626
  Register Rscratch = Rflags; // Rflags is dead now.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3627
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3628
  // Final call case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3629
  __ profile_final_call(Rtemp1, Rscratch);
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3630
  // Argument and return type profiling.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3631
  __ profile_arguments_type(Rmethod, Rscratch, Rrecv_klass /* scratch */, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3632
  // Do the final call - the index (f2) contains the method.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3633
  __ call_from_interpreter(Rmethod, Rret, Rscratch, Rrecv_klass /* scratch */);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3634
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3635
  // Non-final callc case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3636
  __ bind(LnotFinal);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3637
  __ profile_virtual_call(Rrecv_klass, Rtemp1, Rscratch, false);
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3638
  generate_vtable_call(Rrecv_klass, Rmethod, Rret, Rscratch);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3639
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3640
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3641
void TemplateTable::invokeinterface(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3642
  assert(byte_no == f1_byte, "use this argument");
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3643
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3644
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3645
  const Register Rscratch1        = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3646
                 Rscratch2        = R12_scratch2,
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3647
                 Rmethod          = R6_ARG4,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3648
                 Rmethod2         = R9_ARG7,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3649
                 Rinterface_klass = R5_ARG3,
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3650
                 Rret_addr        = R8_ARG6,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3651
                 Rindex           = R10_ARG8,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3652
                 Rreceiver        = R3_ARG1,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3653
                 Rrecv_klass      = R4_ARG2,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3654
                 Rflags           = R7_ARG5;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3655
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3656
  prepare_invoke(byte_no, Rinterface_klass, Rret_addr, Rmethod, Rreceiver, Rflags, Rscratch1);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3657
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3658
  // Get receiver klass.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3659
  __ null_check_throw(Rreceiver, oopDesc::klass_offset_in_bytes(), Rscratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3660
  __ load_klass(Rrecv_klass, Rreceiver);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3661
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3662
  // Check corner case object method.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3663
  Label LobjectMethod, L_no_such_interface, Lthrow_ame;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3664
  __ testbitdi(CCR0, R0, Rflags, ConstantPoolCacheEntry::is_forced_virtual_shift);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3665
  __ btrue(CCR0, LobjectMethod);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3666
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3667
  __ lookup_interface_method(Rrecv_klass, Rinterface_klass, noreg, noreg, Rscratch1, Rscratch2,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3668
                             L_no_such_interface, /*return_method=*/false);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3669
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3670
  __ profile_virtual_call(Rrecv_klass, Rscratch1, Rscratch2, false);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3671
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3672
  // Find entry point to call.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3673
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3674
  // Get declaring interface class from method
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3675
  __ ld(Rinterface_klass, in_bytes(Method::const_offset()), Rmethod);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3676
  __ ld(Rinterface_klass, in_bytes(ConstMethod::constants_offset()), Rinterface_klass);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3677
  __ ld(Rinterface_klass, ConstantPool::pool_holder_offset_in_bytes(), Rinterface_klass);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3678
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3679
  // Get itable index from method
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3680
  __ lwa(Rindex, in_bytes(Method::itable_index_offset()), Rmethod);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3681
  __ subfic(Rindex, Rindex, Method::itable_index_max);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3682
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3683
  __ lookup_interface_method(Rrecv_klass, Rinterface_klass, Rindex, Rmethod2, Rscratch1, Rscratch2,
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3684
                             L_no_such_interface);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3685
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3686
  __ cmpdi(CCR0, Rmethod2, 0);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3687
  __ beq(CCR0, Lthrow_ame);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3688
  // Found entry. Jump off!
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3689
  // Argument and return type profiling.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3690
  __ profile_arguments_type(Rmethod2, Rscratch1, Rscratch2, true);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3691
  //__ profile_called_method(Rindex, Rscratch1);
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3692
  __ call_from_interpreter(Rmethod2, Rret_addr, Rscratch1, Rscratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3693
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3694
  // Vtable entry was NULL => Throw abstract method error.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3695
  __ bind(Lthrow_ame);
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3696
  // Pass arguments for generating a verbose error message.
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3697
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_AbstractMethodErrorVerbose),
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3698
          Rrecv_klass, Rmethod);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3699
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3700
  // Interface was not found => Throw incompatible class change error.
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3701
  __ bind(L_no_such_interface);
49368
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3702
  // Pass arguments for generating a verbose error message.
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3703
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose),
2ed1c37df3a5 8197405: Improve messages of AbstractMethodErrors and IncompatibleClassChangeErrors.
goetz
parents: 49359
diff changeset
  3704
          Rrecv_klass, Rinterface_klass);
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3705
  DEBUG_ONLY( __ should_not_reach_here(); )
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3706
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3707
  // Special case of invokeinterface called for virtual method of
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3708
  // java.lang.Object. See ConstantPoolCacheEntry::set_method() for details:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3709
  // The invokeinterface was rewritten to a invokevirtual, hence we have
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3710
  // to handle this corner case. This code isn't produced by javac, but could
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3711
  // be produced by another compliant java compiler.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3712
  __ bind(LobjectMethod);
48585
d9fcb7ba8133 8191907: PPC64 and s390 parts of JDK-8174962: Better interface invocations
mdoerr
parents: 48332
diff changeset
  3713
  invokeinterface_object_method(Rrecv_klass, Rret_addr, Rflags, Rmethod, Rscratch1, Rscratch2);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3714
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3715
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3716
void TemplateTable::invokedynamic(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3717
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3718
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3719
  const Register Rret_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3720
                 Rflags    = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3721
                 Rmethod   = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3722
                 Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3723
                 Rscratch2 = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3724
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3725
  prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, noreg, Rflags, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3726
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3727
  // Profile this call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3728
  __ profile_call(Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3729
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3730
  // Off we go. With the new method handles, we don't jump to a method handle
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3731
  // entry any more. Instead, we pushed an "appendix" in prepare invoke, which happens
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3732
  // to be the callsite object the bootstrap method returned. This is passed to a
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3733
  // "link" method which does the dispatch (Most likely just grabs the MH stored
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3734
  // inside the callsite and does an invokehandle).
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3735
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3736
  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, false);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3737
  __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3738
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3739
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3740
void TemplateTable::invokehandle(int byte_no) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3741
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3742
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3743
  const Register Rret_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3744
                 Rflags    = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3745
                 Rrecv     = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3746
                 Rmethod   = R22_tmp2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3747
                 Rscratch1 = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3748
                 Rscratch2 = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3749
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3750
  prepare_invoke(byte_no, Rmethod, Rret_addr, Rscratch1, Rrecv, Rflags, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3751
  __ verify_method_ptr(Rmethod);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3752
  __ null_check_throw(Rrecv, -1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3753
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3754
  __ profile_final_call(Rrecv, Rscratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3755
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3756
  // Still no call from handle => We call the method handle interpreter here.
28187
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3757
  // Argument and return type profiling.
fc19df82d6ee 8066964: ppc64: argument and return type profiling, fix problem with popframe
goetz
parents: 27625
diff changeset
  3758
  __ profile_arguments_type(Rmethod, Rscratch1, Rscratch2, true);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3759
  __ call_from_interpreter(Rmethod, Rret_addr, Rscratch1 /* scratch1 */, Rscratch2 /* scratch2 */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3760
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3761
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3762
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3763
// Allocation
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3764
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3765
// Puts allocated obj ref onto the expression stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3766
void TemplateTable::_new() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3767
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3768
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3769
  Label Lslow_case,
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3770
        Ldone;
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3771
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3772
  const Register RallocatedObject = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3773
                 RinstanceKlass   = R9_ARG7,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3774
                 Rscratch         = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3775
                 Roffset          = R8_ARG6,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3776
                 Rinstance_size   = Roffset,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3777
                 Rcpool           = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3778
                 Rtags            = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3779
                 Rindex           = R5_ARG3;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3780
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3781
  // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3782
  // Check if fast case is possible.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3783
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3784
  // Load pointers to const pool and const pool's tags array.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3785
  __ get_cpool_and_tags(Rcpool, Rtags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3786
  // Load index of constant pool entry.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3787
  __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3788
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3789
  // Note: compared to other architectures, PPC's implementation always goes
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3790
  // to the slow path if TLAB is used and fails.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3791
  if (UseTLAB) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3792
    // Make sure the class we're about to instantiate has been resolved
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3793
    // This is done before loading instanceKlass to be consistent with the order
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3794
    // how Constant Pool is updated (see ConstantPoolCache::klass_at_put).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3795
    __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3796
    __ lbzx(Rtags, Rindex, Rtags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3797
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3798
    __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3799
    __ bne(CCR0, Lslow_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3800
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 42068
diff changeset
  3801
    // Get instanceKlass
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3802
    __ sldi(Roffset, Rindex, LogBytesPerWord);
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 42068
diff changeset
  3803
    __ load_resolved_klass_at_offset(Rcpool, Roffset, RinstanceKlass);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3804
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3805
    // Make sure klass is fully initialized and get instance_size.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3806
    __ lbz(Rscratch, in_bytes(InstanceKlass::init_state_offset()), RinstanceKlass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3807
    __ lwz(Rinstance_size, in_bytes(Klass::layout_helper_offset()), RinstanceKlass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3808
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3809
    __ cmpdi(CCR1, Rscratch, InstanceKlass::fully_initialized);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3810
    // Make sure klass does not have has_finalizer, or is abstract, or interface or java/lang/Class.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3811
    __ andi_(R0, Rinstance_size, Klass::_lh_instance_slow_path_bit); // slow path bit equals 0?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3812
28492
57fecf138f7b 8068724: ppc64: update assembler: SPR access, CR logic, HTM
mdoerr
parents: 28187
diff changeset
  3813
    __ crnand(CCR0, Assembler::equal, CCR1, Assembler::equal); // slow path bit set or not fully initialized?
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3814
    __ beq(CCR0, Lslow_case);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3815
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3816
    // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3817
    // Fast case:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3818
    // Allocate the instance.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3819
    // 1) Try to allocate in the TLAB.
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3820
    // 2) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3821
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3822
    Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3823
    Register RnewTopValue = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3824
    Register RendValue    = R7_ARG5;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3825
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3826
    // Check if we can allocate in the TLAB.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3827
    __ ld(RoldTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3828
    __ ld(RendValue,    in_bytes(JavaThread::tlab_end_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3829
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3830
    __ add(RnewTopValue, Rinstance_size, RoldTopValue);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3831
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3832
    // If there is enough space, we do not CAS and do not clear.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3833
    __ cmpld(CCR0, RnewTopValue, RendValue);
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3834
    __ bgt(CCR0, Lslow_case);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3835
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3836
    __ std(RnewTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3837
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3838
    if (!ZeroTLAB) {
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3839
      // --------------------------------------------------------------------------
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3840
      // Init1: Zero out newly allocated memory.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3841
      // Initialize remaining object fields.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3842
      Register Rbase = Rtags;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3843
      __ addi(Rinstance_size, Rinstance_size, 7 - (int)sizeof(oopDesc));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3844
      __ addi(Rbase, RallocatedObject, sizeof(oopDesc));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3845
      __ srdi(Rinstance_size, Rinstance_size, 3);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3846
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3847
      // Clear out object skipping header. Takes also care of the zero length case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3848
      __ clear_memory_doubleword(Rbase, Rinstance_size);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3849
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3850
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3851
    // --------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3852
    // Init2: Initialize the header: mark, klass
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3853
    // Init mark.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3854
    if (UseBiasedLocking) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3855
      __ ld(Rscratch, in_bytes(Klass::prototype_header_offset()), RinstanceKlass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3856
    } else {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3857
      __ load_const_optimized(Rscratch, markOopDesc::prototype(), R0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3858
    }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3859
    __ std(Rscratch, oopDesc::mark_offset_in_bytes(), RallocatedObject);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3860
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3861
    // Init klass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3862
    __ store_klass_gap(RallocatedObject);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3863
    __ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3864
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3865
    // Check and trigger dtrace event.
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3866
    SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3867
    __ push(atos);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3868
    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc));
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3869
    __ pop(atos);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3870
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3871
    __ b(Ldone);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3872
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3873
48476
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3874
  // --------------------------------------------------------------------------
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3875
  // slow case
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3876
  __ bind(Lslow_case);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3877
  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex);
ca9489245872 8191987: JDK-8190862 work for arch ppc64
jcbeyler
parents: 48332
diff changeset
  3878
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3879
  // continue
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3880
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3881
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3882
  // Must prevent reordering of stores for object initialization with stores that publish the new object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3883
  __ membar(Assembler::StoreStore);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3884
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3885
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3886
void TemplateTable::newarray() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3887
  transition(itos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3888
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3889
  __ lbz(R4, 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3890
  __ extsw(R5, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3891
  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::newarray), R4, R5 /* size */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3892
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3893
  // Must prevent reordering of stores for object initialization with stores that publish the new object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3894
  __ membar(Assembler::StoreStore);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3895
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3896
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3897
void TemplateTable::anewarray() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3898
  transition(itos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3899
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3900
  __ get_constant_pool(R4);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3901
  __ get_2_byte_integer_at_bcp(1, R5, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3902
  __ extsw(R6, R17_tos); // size
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3903
  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::anewarray), R4 /* pool */, R5 /* index */, R6 /* size */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3904
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3905
  // Must prevent reordering of stores for object initialization with stores that publish the new object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3906
  __ membar(Assembler::StoreStore);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3907
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3908
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3909
// Allocate a multi dimensional array
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3910
void TemplateTable::multianewarray() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3911
  transition(vtos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3912
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3913
  Register Rptr = R31; // Needs to survive C call.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3914
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3915
  // Put ndims * wordSize into frame temp slot
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3916
  __ lbz(Rptr, 3, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3917
  __ sldi(Rptr, Rptr, Interpreter::logStackElementSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3918
  // Esp points past last_dim, so set to R4 to first_dim address.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3919
  __ add(R4, Rptr, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3920
  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::multianewarray), R4 /* first_size_address */);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3921
  // Pop all dimensions off the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3922
  __ add(R15_esp, Rptr, R15_esp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3923
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3924
  // Must prevent reordering of stores for object initialization with stores that publish the new object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3925
  __ membar(Assembler::StoreStore);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3926
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3927
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3928
void TemplateTable::arraylength() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3929
  transition(atos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3930
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3931
  Label LnoException;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3932
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3933
  __ null_check_throw(R17_tos, arrayOopDesc::length_offset_in_bytes(), R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3934
  __ lwa(R17_tos, arrayOopDesc::length_offset_in_bytes(), R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3935
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3936
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3937
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3938
// Typechecks
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3939
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3940
void TemplateTable::checkcast() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3941
  transition(atos, atos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3942
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3943
  Label Ldone, Lis_null, Lquicked, Lresolved;
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
  3944
  Register Roffset         = R6_ARG4,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3945
           RobjKlass       = R4_ARG2,
24349
d8f40e5b392d 8042309: Some bugfixes for the ppc64 port.
goetz
parents: 24322
diff changeset
  3946
           RspecifiedKlass = R5_ARG3, // Generate_ClassCastException_verbose_handler will read value from this register.
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3947
           Rcpool          = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3948
           Rtags           = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3949
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3950
  // Null does not pass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3951
  __ cmpdi(CCR0, R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3952
  __ beq(CCR0, Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3953
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3954
  // Get constant pool tag to find out if the bytecode has already been "quickened".
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3955
  __ get_cpool_and_tags(Rcpool, Rtags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3956
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3957
  __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3958
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3959
  __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3960
  __ lbzx(Rtags, Rtags, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3961
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3962
  __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3963
  __ beq(CCR0, Lquicked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3964
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3965
  // Call into the VM to "quicken" instanceof.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3966
  __ push_ptr();  // for GC
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3967
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3968
  __ get_vm_result_2(RspecifiedKlass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3969
  __ pop_ptr();   // Restore receiver.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3970
  __ b(Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3971
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3972
  // Extract target class from constant pool.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3973
  __ bind(Lquicked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3974
  __ sldi(Roffset, Roffset, LogBytesPerWord);
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 42068
diff changeset
  3975
  __ load_resolved_klass_at_offset(Rcpool, Roffset, RspecifiedKlass);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3976
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3977
  // Do the checkcast.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3978
  __ bind(Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3979
  // Get value klass in RobjKlass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3980
  __ load_klass(RobjKlass, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3981
  // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3982
  __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3983
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3984
  // Not a subtype; so must throw exception
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3985
  // Target class oop is in register R6_ARG4 == RspecifiedKlass by convention.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3986
  __ load_dispatch_table(R11_scratch1, (address*)Interpreter::_throw_ClassCastException_entry);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3987
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3988
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3989
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3990
  // Profile the null case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3991
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3992
  __ bind(Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3993
  __ profile_null_seen(R11_scratch1, Rtags); // Rtags used as scratch.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3994
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3995
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3996
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3997
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3998
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  3999
// Output:
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4000
//   - tos == 0: Obj was null or not an instance of class.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4001
//   - tos == 1: Obj was an instance of class.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4002
void TemplateTable::instanceof() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4003
  transition(atos, itos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4004
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4005
  Label Ldone, Lis_null, Lquicked, Lresolved;
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
  4006
  Register Roffset         = R6_ARG4,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4007
           RobjKlass       = R4_ARG2,
30303
c703c89fddbf 8077838: Recent developments for ppc.
goetz
parents: 29695
diff changeset
  4008
           RspecifiedKlass = R5_ARG3,
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4009
           Rcpool          = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4010
           Rtags           = R12_scratch2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4011
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4012
  // Null does not pass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4013
  __ cmpdi(CCR0, R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4014
  __ beq(CCR0, Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4015
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4016
  // Get constant pool tag to find out if the bytecode has already been "quickened".
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4017
  __ get_cpool_and_tags(Rcpool, Rtags);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4018
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4019
  __ get_2_byte_integer_at_bcp(1, Roffset, InterpreterMacroAssembler::Unsigned);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4020
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4021
  __ addi(Rtags, Rtags, Array<u1>::base_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4022
  __ lbzx(Rtags, Rtags, Roffset);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4023
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4024
  __ cmpdi(CCR0, Rtags, JVM_CONSTANT_Class);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4025
  __ beq(CCR0, Lquicked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4026
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4027
  // Call into the VM to "quicken" instanceof.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4028
  __ push_ptr();  // for GC
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4029
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::quicken_io_cc));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4030
  __ get_vm_result_2(RspecifiedKlass);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4031
  __ pop_ptr();   // Restore receiver.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4032
  __ b(Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4033
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4034
  // Extract target class from constant pool.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4035
  __ bind(Lquicked);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4036
  __ sldi(Roffset, Roffset, LogBytesPerWord);
46427
54713555867e 8171392: Move Klass pointers outside of ConstantPool entries so ConstantPool can be read-only
iklam
parents: 42068
diff changeset
  4037
  __ load_resolved_klass_at_offset(Rcpool, Roffset, RspecifiedKlass);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4038
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4039
  // Do the checkcast.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4040
  __ bind(Lresolved);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4041
  // Get value klass in RobjKlass.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4042
  __ load_klass(RobjKlass, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4043
  // Generate a fast subtype check. Branch to cast_ok if no failure. Return 0 if failure.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4044
  __ li(R17_tos, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4045
  __ gen_subtype_check(RobjKlass, RspecifiedKlass, /*3 temp regs*/ Roffset, Rcpool, Rtags, /*target if subtype*/ Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4046
  __ li(R17_tos, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4047
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4048
  if (ProfileInterpreter) {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4049
    __ b(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4050
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4051
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4052
  // Profile the null case.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4053
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4054
  __ bind(Lis_null);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4055
  __ profile_null_seen(Rcpool, Rtags); // Rcpool and Rtags used as scratch.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4056
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4057
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4058
  __ bind(Ldone);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4059
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4060
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4061
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4062
// Breakpoints
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4063
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4064
void TemplateTable::_breakpoint() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4065
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4066
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4067
  // Get the unpatched byte code.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4068
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::get_original_bytecode_at), R19_method, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4069
  __ mr(R31, R3_RET);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4070
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4071
  // Post the breakpoint event.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4072
  __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::_breakpoint), R19_method, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4073
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4074
  // Complete the execution of original bytecode.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4075
  __ dispatch_Lbyte_code(vtos, R31, Interpreter::normal_table(vtos));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4076
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4077
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4078
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4079
// Exceptions
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4080
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4081
void TemplateTable::athrow() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4082
  transition(atos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4083
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4084
  // Exception oop is in tos
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4085
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4086
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4087
  __ null_check_throw(R17_tos, -1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4088
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4089
  // Throw exception interpreter entry expects exception oop to be in R3.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4090
  __ mr(R3_RET, R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4091
  __ load_dispatch_table(R11_scratch1, (address*)Interpreter::throw_exception_entry());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4092
  __ mtctr(R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4093
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4094
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4095
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4096
// =============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4097
// Synchronization
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4098
// Searches the basic object lock list on the stack for a free slot
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4099
// and uses it to lock the obect in tos.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4100
//
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4101
// Recursive locking is enabled by exiting the search if the same
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4102
// object is already found in the list. Thus, a new basic lock obj lock
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4103
// is allocated "higher up" in the stack and thus is found first
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4104
// at next monitor exit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4105
void TemplateTable::monitorenter() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4106
  transition(atos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4107
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4108
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4109
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4110
  Register Rcurrent_monitor  = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4111
           Rcurrent_obj      = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4112
           Robj_to_lock      = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4113
           Rscratch1         = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4114
           Rscratch2         = R4_ARG2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4115
           Rscratch3         = R5_ARG3,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4116
           Rcurrent_obj_addr = R6_ARG4;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4117
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4118
  // ------------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4119
  // Null pointer exception.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4120
  __ null_check_throw(Robj_to_lock, -1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4121
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4122
  // Try to acquire a lock on the object.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4123
  // Repeat until succeeded (i.e., until monitorenter returns true).
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4124
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4125
  // ------------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4126
  // Find a free slot in the monitor block.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4127
  Label Lfound, Lexit, Lallocate_new;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4128
  ConditionRegister found_free_slot = CCR0,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4129
                    found_same_obj  = CCR1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4130
                    reached_limit   = CCR6;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4131
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4132
    Label Lloop, Lentry;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4133
    Register Rlimit = Rcurrent_monitor;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4134
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4135
    // Set up search loop - start with topmost monitor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4136
    __ add(Rcurrent_obj_addr, BasicObjectLock::obj_offset_in_bytes(), R26_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4137
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4138
    __ ld(Rlimit, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4139
    __ addi(Rlimit, Rlimit, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes() - BasicObjectLock::obj_offset_in_bytes())); // Monitor base
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4140
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4141
    // Check if any slot is present => short cut to allocation if not.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4142
    __ cmpld(reached_limit, Rcurrent_obj_addr, Rlimit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4143
    __ bgt(reached_limit, Lallocate_new);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4144
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4145
    // Pre-load topmost slot.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4146
    __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4147
    __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4148
    // The search loop.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4149
    __ bind(Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4150
    // Found free slot?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4151
    __ cmpdi(found_free_slot, Rcurrent_obj, 0);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4152
    // Is this entry for same obj? If so, stop the search and take the found
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4153
    // free slot or allocate a new one to enable recursive locking.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4154
    __ cmpd(found_same_obj, Rcurrent_obj, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4155
    __ cmpld(reached_limit, Rcurrent_obj_addr, Rlimit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4156
    __ beq(found_free_slot, Lexit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4157
    __ beq(found_same_obj, Lallocate_new);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4158
    __ bgt(reached_limit, Lallocate_new);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4159
    // Check if last allocated BasicLockObj reached.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4160
    __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4161
    __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4162
    // Next iteration if unchecked BasicObjectLocks exist on the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4163
    __ b(Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4164
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4165
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4166
  // ------------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4167
  // Check if we found a free slot.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4168
  __ bind(Lexit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4169
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4170
  __ addi(Rcurrent_monitor, Rcurrent_obj_addr, -(frame::interpreter_frame_monitor_size() * wordSize) - BasicObjectLock::obj_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4171
  __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, - frame::interpreter_frame_monitor_size() * wordSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4172
  __ b(Lfound);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4173
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4174
  // We didn't find a free BasicObjLock => allocate one.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4175
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4176
  __ bind(Lallocate_new);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4177
  __ add_monitor_to_stack(false, Rscratch1, Rscratch2);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4178
  __ mr(Rcurrent_monitor, R26_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4179
  __ addi(Rcurrent_obj_addr, R26_monitor, BasicObjectLock::obj_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4180
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4181
  // ------------------------------------------------------------------------------
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4182
  // We now have a slot to lock.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4183
  __ bind(Lfound);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4184
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4185
  // Increment bcp to point to the next bytecode, so exception handling for async. exceptions work correctly.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4186
  // The object has already been poped from the stack, so the expression stack looks correct.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4187
  __ addi(R14_bcp, R14_bcp, 1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4188
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4189
  __ std(Robj_to_lock, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4190
  __ lock_object(Rcurrent_monitor, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4191
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4192
  // Check if there's enough space on the stack for the monitors after locking.
39390
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 37488
diff changeset
  4193
  // This emits a single store.
edf6a424a8b7 8159335: Fix problems with stack overflow handling.
goetz
parents: 37488
diff changeset
  4194
  __ generate_stack_overflow_check(0);
23221
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4195
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4196
  // The bcp has already been incremented. Just need to dispatch to next instruction.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4197
  __ dispatch_next(vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4198
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4199
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4200
void TemplateTable::monitorexit() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4201
  transition(atos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4202
  __ verify_oop(R17_tos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4203
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4204
  Register Rcurrent_monitor  = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4205
           Rcurrent_obj      = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4206
           Robj_to_lock      = R17_tos,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4207
           Rcurrent_obj_addr = R3_ARG1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4208
           Rlimit            = R4_ARG2;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4209
  Label Lfound, Lillegal_monitor_state;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4210
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4211
  // Check corner case: unbalanced monitorEnter / Exit.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4212
  __ ld(Rlimit, 0, R1_SP);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4213
  __ addi(Rlimit, Rlimit, - (frame::ijava_state_size + frame::interpreter_frame_monitor_size_in_bytes())); // Monitor base
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4214
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4215
  // Null pointer check.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4216
  __ null_check_throw(Robj_to_lock, -1, R11_scratch1);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4217
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4218
  __ cmpld(CCR0, R26_monitor, Rlimit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4219
  __ bgt(CCR0, Lillegal_monitor_state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4220
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4221
  // Find the corresponding slot in the monitors stack section.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4222
  {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4223
    Label Lloop;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4224
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4225
    // Start with topmost monitor.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4226
    __ addi(Rcurrent_obj_addr, R26_monitor, BasicObjectLock::obj_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4227
    __ addi(Rlimit, Rlimit, BasicObjectLock::obj_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4228
    __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4229
    __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4230
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4231
    __ bind(Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4232
    // Is this entry for same obj?
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4233
    __ cmpd(CCR0, Rcurrent_obj, Robj_to_lock);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4234
    __ beq(CCR0, Lfound);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4235
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4236
    // Check if last allocated BasicLockObj reached.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4237
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4238
    __ ld(Rcurrent_obj, 0, Rcurrent_obj_addr);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4239
    __ cmpld(CCR0, Rcurrent_obj_addr, Rlimit);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4240
    __ addi(Rcurrent_obj_addr, Rcurrent_obj_addr, frame::interpreter_frame_monitor_size() * wordSize);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4241
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4242
    // Next iteration if unchecked BasicObjectLocks exist on the stack.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4243
    __ ble(CCR0, Lloop);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4244
  }
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4245
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4246
  // Fell through without finding the basic obj lock => throw up!
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4247
  __ bind(Lillegal_monitor_state);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4248
  call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_illegal_monitor_state_exception));
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4249
  __ should_not_reach_here();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4250
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4251
  __ align(32, 12);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4252
  __ bind(Lfound);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4253
  __ addi(Rcurrent_monitor, Rcurrent_obj_addr,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4254
          -(frame::interpreter_frame_monitor_size() * wordSize) - BasicObjectLock::obj_offset_in_bytes());
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4255
  __ unlock_object(Rcurrent_monitor);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4256
}
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4257
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4258
// ============================================================================
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4259
// Wide bytecodes
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4260
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4261
// Wide instructions. Simply redirects to the wide entry point for that instruction.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4262
void TemplateTable::wide() {
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4263
  transition(vtos, vtos);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4264
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4265
  const Register Rtable = R11_scratch1,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4266
                 Rindex = R12_scratch2,
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4267
                 Rtmp   = R0;
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4268
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4269
  __ lbz(Rindex, 1, R14_bcp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4270
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4271
  __ load_dispatch_table(Rtable, Interpreter::_wentry_point);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4272
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4273
  __ slwi(Rindex, Rindex, LogBytesPerWord);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4274
  __ ldx(Rtmp, Rtable, Rindex);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4275
  __ mtctr(Rtmp);
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4276
  __ bctr();
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4277
  // Note: the bcp increment step is part of the individual wide bytecode implementations.
b70675ece1ce 8036976: PPC64: implement the template interpreter
goetz
parents:
diff changeset
  4278
}