src/hotspot/cpu/ppc/nativeInst_ppc.hpp
author mdoerr
Wed, 10 Jan 2018 11:09:55 +0100
changeset 48506 478e77658965
parent 47216 71c04702a3d5
child 48637 7bba05746c44
permissions -rw-r--r--
8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP Summary: Use mmap on AIX to allocate protected page. Use trap instructions for polling if UseSIGTRAP is enabled. Reviewed-by: rehn, goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     1
/*
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
     2
 * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
35594
cc13089c6327 8147937: Adapt SAP copyrights to new company name.
goetz
parents: 35085
diff changeset
     3
 * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     5
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     8
 * published by the Free Software Foundation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
     9
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    14
 * accompanied this code).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    15
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    19
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    22
 * questions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    23
 *
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    24
 */
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    25
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    26
#ifndef CPU_PPC_VM_NATIVEINST_PPC_HPP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    27
#define CPU_PPC_VM_NATIVEINST_PPC_HPP
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    28
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    29
#include "asm/assembler.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    30
#include "asm/macroAssembler.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    31
#include "memory/allocation.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    32
#include "runtime/icache.hpp"
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    33
#include "runtime/os.hpp"
48506
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
    34
#include "runtime/safepointMechanism.hpp"
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    35
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    36
// We have interfaces for the following instructions:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    37
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    38
// - NativeInstruction
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    39
//   - NativeCall
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    40
//   - NativeFarCall
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    41
//   - NativeMovConstReg
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    42
//   - NativeJump
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    43
//   - NativeIllegalInstruction
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    44
//   - NativeConditionalFarBranch
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    45
//   - NativeCallTrampolineStub
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    46
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    47
// The base class for different kinds of native instruction abstractions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    48
// It provides the primitive operations to manipulate code relative to this.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    49
class NativeInstruction VALUE_OBJ_CLASS_SPEC {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    50
  friend class Relocation;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    51
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    52
 public:
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
    53
  bool is_jump() { return Assembler::is_b(long_at(0)); } // See NativeGeneralJump.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
    54
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    55
  bool is_sigtrap_ic_miss_check() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    56
    assert(UseSIGTRAP, "precondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    57
    return MacroAssembler::is_trap_ic_miss_check(long_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    58
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    59
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    60
  bool is_sigtrap_null_check() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    61
    assert(UseSIGTRAP && TrapBasedNullChecks, "precondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    62
    return MacroAssembler::is_trap_null_check(long_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    63
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    64
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    65
  // We use a special trap for marking a method as not_entrant or zombie
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    66
  // iff UseSIGTRAP.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    67
  bool is_sigtrap_zombie_not_entrant() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    68
    assert(UseSIGTRAP, "precondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    69
    return MacroAssembler::is_trap_zombie_not_entrant(long_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    70
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    71
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    72
  // We use an illtrap for marking a method as not_entrant or zombie
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    73
  // iff !UseSIGTRAP.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    74
  bool is_sigill_zombie_not_entrant() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    75
    assert(!UseSIGTRAP, "precondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    76
    // Work around a C++ compiler bug which changes 'this'.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    77
    return NativeInstruction::is_sigill_zombie_not_entrant_at(addr_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    78
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    79
  static bool is_sigill_zombie_not_entrant_at(address addr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    80
22856
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
    81
#ifdef COMPILER2
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    82
  // SIGTRAP-based implicit range checks
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    83
  bool is_sigtrap_range_check() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    84
    assert(UseSIGTRAP && TrapBasedRangeChecks, "precondition");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    85
    return MacroAssembler::is_trap_range_check(long_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    86
  }
22856
03ad2cf18166 8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents: 22824
diff changeset
    87
#endif
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    88
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    89
  // 'should not reach here'.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    90
  bool is_sigtrap_should_not_reach_here() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    91
    return MacroAssembler::is_trap_should_not_reach_here(long_at(0));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    92
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    93
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    94
  bool is_safepoint_poll() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    95
    // Is the current instruction a POTENTIAL read access to the polling page?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
    96
    // The current arguments of the instruction are not checked!
48506
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
    97
    if (SafepointMechanism::uses_thread_local_poll() && USE_POLL_BIT_ONLY) {
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
    98
      int encoding = SafepointMechanism::poll_bit();
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
    99
      return MacroAssembler::is_tdi(long_at(0), Assembler::traptoGreaterThanUnsigned | Assembler::traptoEqual,
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
   100
                                    -1, encoding);
478e77658965 8194258: PPC64 safepoint mechanism: Fix initialization on AIX and support SIGTRAP
mdoerr
parents: 47216
diff changeset
   101
    }
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   102
    return MacroAssembler::is_load_from_polling_page(long_at(0), NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   103
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   104
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   105
  bool is_memory_serialization(JavaThread *thread, void *ucontext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   106
    // Is the current instruction a write access of thread to the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   107
    // memory serialization page?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   108
    return MacroAssembler::is_memory_serialization(long_at(0), thread, ucontext);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   109
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   110
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   111
  address get_stack_bang_address(void *ucontext) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   112
    // If long_at(0) is not a stack bang, return 0. Otherwise, return
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   113
    // banged address.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   114
    return MacroAssembler::get_stack_bang_address(long_at(0), ucontext);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   115
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   116
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   117
 protected:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   118
  address  addr_at(int offset) const    { return address(this) + offset; }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   119
  int      long_at(int offset) const    { return *(int*)addr_at(offset); }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   120
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   121
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   122
  void verify() NOT_DEBUG_RETURN;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   123
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   124
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   125
inline NativeInstruction* nativeInstruction_at(address address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   126
  NativeInstruction* inst = (NativeInstruction*)address;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   127
  inst->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   128
  return inst;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   129
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   130
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   131
// The NativeCall is an abstraction for accessing/manipulating call
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   132
// instructions. It is used to manipulate inline caches, primitive &
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   133
// dll calls, etc.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   134
//
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   135
// Sparc distinguishes `NativeCall' and `NativeFarCall'. On PPC64,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   136
// at present, we provide a single class `NativeCall' representing the
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   137
// sequence `load_const, mtctr, bctrl' or the sequence 'ld_from_toc,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   138
// mtctr, bctrl'.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   139
class NativeCall: public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   140
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   141
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   142
  enum ppc_specific_constants {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   143
    load_const_instruction_size                 = 28,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   144
    load_const_from_method_toc_instruction_size = 16,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   145
    instruction_size                            = 16 // Used in shared code for calls with reloc_info.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   146
  };
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   147
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   148
  static bool is_call_at(address a) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   149
    return Assembler::is_bl(*(int*)(a));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   150
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   151
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   152
  static bool is_call_before(address return_address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   153
    return NativeCall::is_call_at(return_address - 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   154
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   155
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   156
  address instruction_address() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   157
    return addr_at(0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   158
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   159
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   160
  address next_instruction_address() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   161
    // We have only bl.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   162
    assert(MacroAssembler::is_bl(*(int*)instruction_address()), "Should be bl instruction!");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   163
    return addr_at(4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   164
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   165
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   166
  address return_address() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   167
    return next_instruction_address();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   168
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   169
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   170
  address destination() const;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   171
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   172
  // The parameter assert_lock disables the assertion during code generation.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   173
  void set_destination_mt_safe(address dest, bool assert_lock = true);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   174
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   175
  address get_trampoline();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   176
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   177
  void verify_alignment() {} // do nothing on ppc
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   178
  void verify() NOT_DEBUG_RETURN;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   179
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   180
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   181
inline NativeCall* nativeCall_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   182
  NativeCall* call = (NativeCall*)instr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   183
  call->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   184
  return call;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   185
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   186
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   187
inline NativeCall* nativeCall_before(address return_address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   188
  NativeCall* call = NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   189
  if (MacroAssembler::is_bl(*(int*)(return_address - 4)))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   190
    call = (NativeCall*)(return_address - 4);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   191
  call->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   192
  return call;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   193
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   194
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   195
// The NativeFarCall is an abstraction for accessing/manipulating native
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   196
// call-anywhere instructions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   197
// Used to call native methods which may be loaded anywhere in the address
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   198
// space, possibly out of reach of a call instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   199
class NativeFarCall: public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   200
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   201
  // We use MacroAssembler::bl64_patchable() for implementing a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   202
  // call-anywhere instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   203
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   204
  // Checks whether instr points at a NativeFarCall instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   205
  static bool is_far_call_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   206
    return MacroAssembler::is_bl64_patchable_at(instr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   207
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   208
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   209
  // Does the NativeFarCall implementation use a pc-relative encoding
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   210
  // of the call destination?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   211
  // Used when relocating code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   212
  bool is_pcrelative() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   213
    assert(MacroAssembler::is_bl64_patchable_at((address)this),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   214
           "unexpected call type");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   215
    return MacroAssembler::is_bl64_patchable_pcrelative_at((address)this);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   216
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   217
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   218
  // Returns the NativeFarCall's destination.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   219
  address destination() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   220
    assert(MacroAssembler::is_bl64_patchable_at((address)this),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   221
           "unexpected call type");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   222
    return MacroAssembler::get_dest_of_bl64_patchable_at((address)this);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   223
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   224
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   225
  // Sets the NativeCall's destination, not necessarily mt-safe.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   226
  // Used when relocating code.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   227
  void set_destination(address dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   228
    // Set new destination (implementation of call may change here).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   229
    assert(MacroAssembler::is_bl64_patchable_at((address)this),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   230
           "unexpected call type");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   231
    MacroAssembler::set_dest_of_bl64_patchable_at((address)this, dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   232
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   233
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   234
  void verify() NOT_DEBUG_RETURN;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   235
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   236
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   237
// Instantiates a NativeFarCall object starting at the given instruction
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   238
// address and returns the NativeFarCall object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   239
inline NativeFarCall* nativeFarCall_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   240
  NativeFarCall* call = (NativeFarCall*)instr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   241
  call->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   242
  return call;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   243
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   244
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   245
// An interface for accessing/manipulating native set_oop imm, reg instructions
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   246
// (used to manipulate inlined data references, etc.).
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   247
class NativeMovConstReg: public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   248
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   249
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   250
  enum ppc_specific_constants {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   251
    load_const_instruction_size                 = 20,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   252
    load_const_from_method_toc_instruction_size =  8,
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   253
    instruction_size                            =  8 // Used in shared code for calls with reloc_info.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   254
  };
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   255
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   256
  address instruction_address() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   257
    return addr_at(0);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   258
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   259
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   260
  address next_instruction_address() const;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   261
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   262
  // (The [set_]data accessor respects oop_type relocs also.)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   263
  intptr_t data() const;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   264
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   265
  // Patch the code stream.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   266
  address set_data_plain(intptr_t x, CodeBlob *code);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   267
  // Patch the code stream and oop pool.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   268
  void set_data(intptr_t x);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   269
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   270
  // Patch narrow oop constants. Use this also for narrow klass.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   271
  void set_narrow_oop(narrowOop data, CodeBlob *code = NULL);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   272
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   273
  void verify() NOT_DEBUG_RETURN;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   274
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   275
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   276
inline NativeMovConstReg* nativeMovConstReg_at(address address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   277
  NativeMovConstReg* test = (NativeMovConstReg*)address;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   278
  test->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   279
  return test;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   280
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   281
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   282
// The NativeJump is an abstraction for accessing/manipulating native
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   283
// jump-anywhere instructions.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   284
class NativeJump: public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   285
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   286
  // We use MacroAssembler::b64_patchable() for implementing a
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   287
  // jump-anywhere instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   288
22861
f5c393d456fc 8029940: PPC64 (part 122): C2 compiler port
goetz
parents: 22856
diff changeset
   289
  enum ppc_specific_constants {
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   290
    instruction_size = MacroAssembler::b64_patchable_size
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   291
  };
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   292
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   293
  // Checks whether instr points at a NativeJump instruction.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   294
  static bool is_jump_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   295
    return MacroAssembler::is_b64_patchable_at(instr)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   296
      || (   MacroAssembler::is_load_const_from_method_toc_at(instr)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   297
          && Assembler::is_mtctr(*(int*)(instr + 2 * 4))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   298
          && Assembler::is_bctr(*(int*)(instr + 3 * 4)));
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   299
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   300
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   301
  // Does the NativeJump implementation use a pc-relative encoding
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   302
  // of the call destination?
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   303
  // Used when relocating code or patching jumps.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   304
  bool is_pcrelative() {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   305
    return MacroAssembler::is_b64_patchable_pcrelative_at((address)this);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   306
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   307
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   308
  // Returns the NativeJump's destination.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   309
  address jump_destination() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   310
    if (MacroAssembler::is_b64_patchable_at((address)this)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   311
      return MacroAssembler::get_dest_of_b64_patchable_at((address)this);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   312
    } else if (MacroAssembler::is_load_const_from_method_toc_at((address)this)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   313
               && Assembler::is_mtctr(*(int*)((address)this + 2 * 4))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   314
               && Assembler::is_bctr(*(int*)((address)this + 3 * 4))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   315
      return (address)((NativeMovConstReg *)this)->data();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   316
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   317
      ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   318
      return NULL;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   319
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   320
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   321
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   322
  // Sets the NativeJump's destination, not necessarily mt-safe.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   323
  // Used when relocating code or patching jumps.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   324
  void set_jump_destination(address dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   325
    // Set new destination (implementation of call may change here).
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   326
    if (MacroAssembler::is_b64_patchable_at((address)this)) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   327
      MacroAssembler::set_dest_of_b64_patchable_at((address)this, dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   328
    } else if (MacroAssembler::is_load_const_from_method_toc_at((address)this)
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   329
               && Assembler::is_mtctr(*(int*)((address)this + 2 * 4))
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   330
               && Assembler::is_bctr(*(int*)((address)this + 3 * 4))) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   331
      ((NativeMovConstReg *)this)->set_data((intptr_t)dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   332
    } else {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   333
      ShouldNotReachHere();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   334
    }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   335
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   336
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   337
  // MT-safe insertion of native jump at verified method entry
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   338
  static void patch_verified_entry(address entry, address verified_entry, address dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   339
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   340
  void verify() NOT_DEBUG_RETURN;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   341
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   342
  static void check_verified_entry_alignment(address entry, address verified_entry) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   343
    // We just patch one instruction on ppc64, so the jump doesn't have to
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   344
    // be aligned. Nothing to do here.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   345
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   346
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   347
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   348
// Instantiates a NativeJump object starting at the given instruction
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   349
// address and returns the NativeJump object.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   350
inline NativeJump* nativeJump_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   351
  NativeJump* call = (NativeJump*)instr;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   352
  call->verify();
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   353
  return call;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   354
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   355
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   356
// NativeConditionalFarBranch is abstraction for accessing/manipulating
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   357
// conditional far branches.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   358
class NativeConditionalFarBranch : public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   359
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   360
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   361
  static bool is_conditional_far_branch_at(address instr) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   362
    return MacroAssembler::is_bc_far_at(instr);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   363
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   364
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   365
  address branch_destination() const {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   366
    return MacroAssembler::get_dest_of_bc_far_at((address)this);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   367
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   368
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   369
  void set_branch_destination(address dest) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   370
    MacroAssembler::set_dest_of_bc_far_at((address)this, dest);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   371
  }
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   372
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   373
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   374
inline NativeConditionalFarBranch* NativeConditionalFarBranch_at(address address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   375
  assert(NativeConditionalFarBranch::is_conditional_far_branch_at(address),
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   376
         "must be a conditional far branch");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   377
  return (NativeConditionalFarBranch*)address;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   378
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   379
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   380
// Call trampoline stubs.
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   381
class NativeCallTrampolineStub : public NativeInstruction {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   382
 private:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   383
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   384
  address encoded_destination_addr() const;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   385
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   386
 public:
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   387
22867
309bcf262a19 8031319: PPC64: Some fixes in ppc and aix coding.
goetz
parents: 22861
diff changeset
   388
  address destination(nmethod *nm = NULL) const;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   389
  int destination_toc_offset() const;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   390
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   391
  void set_destination(address new_destination);
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   392
};
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   393
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   394
// Note: Other stubs must not begin with this pattern.
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   395
inline bool is_NativeCallTrampolineStub_at(address address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   396
  int first_instr = *(int*)address;
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   397
  // calculate_address_from_global_toc and long form of ld_largeoffset_unchecked begin with addis with target R12
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   398
  if (Assembler::is_addis(first_instr) &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   399
      (Register)(intptr_t)Assembler::inv_rt_field(first_instr) == R12_scratch2) return true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   400
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   401
  // short form of ld_largeoffset_unchecked is ld which is followed by mtctr
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   402
  int second_instr = *((int*)address + 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   403
  if (Assembler::is_ld(first_instr) &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   404
      (Register)(intptr_t)Assembler::inv_rt_field(first_instr) == R12_scratch2 &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   405
      Assembler::is_mtctr(second_instr) &&
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   406
      (Register)(intptr_t)Assembler::inv_rs_field(second_instr) == R12_scratch2) return true;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   407
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   408
  return false;
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   409
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   410
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   411
inline NativeCallTrampolineStub* NativeCallTrampolineStub_at(address address) {
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   412
  assert(is_NativeCallTrampolineStub_at(address), "no call trampoline found");
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   413
  return (NativeCallTrampolineStub*)address;
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   414
}
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   415
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   416
///////////////////////////////////////////////////////////////////////////////////////////////////
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   417
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   418
//-------------------------------------
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   419
//  N a t i v e G e n e r a l J u m p
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   420
//-------------------------------------
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   421
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   422
// Despite the name, handles only simple branches.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   423
class NativeGeneralJump;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   424
inline NativeGeneralJump* nativeGeneralJump_at(address address);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   425
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   426
// Currently only implemented as single unconditional branch.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   427
class NativeGeneralJump: public NativeInstruction {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   428
 public:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   429
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   430
  enum PPC64_specific_constants {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   431
    instruction_size = 4
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   432
  };
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   433
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   434
  address instruction_address() const { return addr_at(0); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   435
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   436
  // Creation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   437
  friend inline NativeGeneralJump* nativeGeneralJump_at(address addr) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   438
    NativeGeneralJump* jump = (NativeGeneralJump*)(addr);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   439
    DEBUG_ONLY( jump->verify(); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   440
    return jump;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   441
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   442
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   443
  // Insertion of native general jump instruction.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   444
  static void insert_unconditional(address code_pos, address entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   445
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   446
  address jump_destination() const {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   447
    DEBUG_ONLY( verify(); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   448
    return addr_at(0) + Assembler::inv_li_field(long_at(0));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   449
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   450
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   451
  void set_jump_destination(address dest) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   452
    DEBUG_ONLY( verify(); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   453
    insert_unconditional(addr_at(0), dest);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   454
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   455
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   456
  static void replace_mt_safe(address instr_addr, address code_buffer);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   457
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   458
  void verify() const { guarantee(Assembler::is_b(long_at(0)), "invalid NativeGeneralJump"); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   459
};
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   460
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   461
// An interface for accessing/manipulating native load int (load_const32).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   462
class NativeMovRegMem;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   463
inline NativeMovRegMem* nativeMovRegMem_at(address address);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   464
class NativeMovRegMem: public NativeInstruction {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   465
 public:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   466
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   467
  enum PPC64_specific_constants {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   468
    instruction_size = 8
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   469
  };
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   470
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   471
  address instruction_address() const { return addr_at(0); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   472
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   473
  intptr_t offset() const {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   474
#ifdef VM_LITTLE_ENDIAN
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   475
    short *hi_ptr = (short*)(addr_at(0));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   476
    short *lo_ptr = (short*)(addr_at(4));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   477
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   478
    short *hi_ptr = (short*)(addr_at(0) + 2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   479
    short *lo_ptr = (short*)(addr_at(4) + 2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   480
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   481
    return ((*hi_ptr) << 16) | ((*lo_ptr) & 0xFFFF);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   482
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   483
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   484
  void set_offset(intptr_t x) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   485
#ifdef VM_LITTLE_ENDIAN
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   486
    short *hi_ptr = (short*)(addr_at(0));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   487
    short *lo_ptr = (short*)(addr_at(4));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   488
#else
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   489
    short *hi_ptr = (short*)(addr_at(0) + 2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   490
    short *lo_ptr = (short*)(addr_at(4) + 2);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   491
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   492
    *hi_ptr = x >> 16;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   493
    *lo_ptr = x & 0xFFFF;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   494
    ICache::ppc64_flush_icache_bytes(addr_at(0), NativeMovRegMem::instruction_size);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   495
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   496
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   497
  void add_offset_in_bytes(intptr_t radd_offset) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   498
    set_offset(offset() + radd_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   499
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   500
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   501
  void verify() const {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   502
    guarantee(Assembler::is_lis(long_at(0)), "load_const32 1st instr");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   503
    guarantee(Assembler::is_ori(long_at(4)), "load_const32 2nd instr");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   504
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   505
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   506
 private:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   507
  friend inline NativeMovRegMem* nativeMovRegMem_at(address address) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   508
    NativeMovRegMem* test = (NativeMovRegMem*)address;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   509
    DEBUG_ONLY( test->verify(); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   510
    return test;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   511
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   512
};
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents: 22867
diff changeset
   513
22824
28258dd5cb2e 8019972: PPC64 (part 9): platform files for interpreter only VM.
goetz
parents:
diff changeset
   514
#endif // CPU_PPC_VM_NATIVEINST_PPC_HPP