hotspot/src/cpu/ppc/vm/c1_CodeStubs_ppc.cpp
author simonis
Wed, 23 Aug 2017 18:24:47 +0200
changeset 46960 b498e2123d2f
parent 35594 cc13089c6327
permissions -rw-r--r--
8186667: InterpreterCodeSize overflows on AIX Reviewed-by: goetz
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     1
/*
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     2
 * Copyright (c) 1999, 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.
35085
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     4
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     5
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     6
 * This code is free software; you can redistribute it and/or modify it
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     7
 * under the terms of the GNU General Public License version 2 only, as
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     8
 * published by the Free Software Foundation.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
     9
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    10
 * This code is distributed in the hope that it will be useful, but WITHOUT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    11
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    12
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    13
 * version 2 for more details (a copy is included in the LICENSE file that
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    14
 * accompanied this code).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    15
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    16
 * You should have received a copy of the GNU General Public License version
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    17
 * 2 along with this work; if not, write to the Free Software Foundation,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    18
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    19
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    20
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    21
 * or visit www.oracle.com if you need additional information or have any
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    22
 * questions.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    23
 *
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    24
 */
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    25
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    26
#include "precompiled.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    27
#include "c1/c1_CodeStubs.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    28
#include "c1/c1_FrameMap.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    29
#include "c1/c1_LIRAssembler.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    30
#include "c1/c1_MacroAssembler.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    31
#include "c1/c1_Runtime1.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    32
#include "nativeInst_ppc.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    33
#include "runtime/sharedRuntime.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    34
#include "utilities/macros.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    35
#include "vmreg_ppc.inline.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    36
#if INCLUDE_ALL_GCS
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    37
#include "gc/g1/g1SATBCardTableModRefBS.hpp"
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    38
#endif // INCLUDE_ALL_GCS
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    39
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    40
#define __ ce->masm()->
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    41
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    42
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    43
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    44
                               bool throw_index_out_of_bounds_exception)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    45
  : _throw_index_out_of_bounds_exception(throw_index_out_of_bounds_exception)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    46
  , _index(index) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    47
  assert(info != NULL, "must have info");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    48
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    49
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    50
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    51
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    52
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    53
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    54
  if (_info->deoptimize_on_exception()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    55
    address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    56
    // May be used by optimizations like LoopInvariantCodeMotion or RangeCheckEliminator.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    57
    DEBUG_ONLY( __ untested("RangeCheckStub: predicate_failed_trap_id"); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    58
    //__ load_const_optimized(R0, a);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    59
    __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    60
    __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    61
    __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    62
    ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    63
    ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    64
    debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    65
    return;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    66
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    67
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    68
  address stub = _throw_index_out_of_bounds_exception ? Runtime1::entry_for(Runtime1::throw_index_exception_id)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    69
                                                      : Runtime1::entry_for(Runtime1::throw_range_check_failed_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    70
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    71
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    72
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    73
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    74
  Register index = R0; // pass in R0
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    75
  if (_index->is_register()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    76
    __ extsw(index, _index->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    77
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    78
    __ load_const_optimized(index, _index->as_jint());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    79
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    80
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    81
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    82
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    83
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    84
  debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    85
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    86
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    87
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    88
PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    89
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    90
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    91
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    92
void PredicateFailedStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    93
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    94
  address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    95
  //__ load_const_optimized(R0, a);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    96
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    97
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    98
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
    99
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   100
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   101
  debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   102
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   103
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   104
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   105
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   106
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   107
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   108
  // Parameter 1: bci
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   109
  __ load_const_optimized(R0, _bci);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   110
  __ std(R0, -16, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   111
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   112
  // Parameter 2: Method*
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   113
  Metadata *m = _method->as_constant_ptr()->as_metadata();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   114
  AddressLiteral md = __ constant_metadata_address(m); // Notify OOP recorder (don't need the relocation).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   115
  __ load_const_optimized(R0, md.value());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   116
  __ std(R0, -8, R1_SP);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   117
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   118
  address a = Runtime1::entry_for(Runtime1::counter_overflow_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   119
  //__ load_const_optimized(R0, a);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   120
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   121
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   122
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   123
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   124
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   125
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   126
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   127
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   128
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   129
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   130
void DivByZeroStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   131
  if (_offset != -1) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   132
    ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   133
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   134
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   135
  address stub = Runtime1::entry_for(Runtime1::throw_div0_exception_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   136
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   137
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   138
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   139
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   140
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   141
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   142
  debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   143
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   144
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   145
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   146
void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   147
  address a;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   148
  if (_info->deoptimize_on_exception()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   149
    // Deoptimize, do not throw the exception, because it is probably wrong to do it here.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   150
    a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   151
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   152
    a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   153
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   154
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   155
  if (ImplicitNullChecks || TrapBasedNullChecks) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   156
    ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   157
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   158
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   159
  //__ load_const_optimized(R0, a);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   160
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(a));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   161
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   162
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   163
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   164
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   165
  debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   166
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   167
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   168
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   169
// Implementation of SimpleExceptionStub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   170
void SimpleExceptionStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   171
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   172
  address stub = Runtime1::entry_for(_stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   173
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   174
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   175
  if (_obj->is_valid()) { __ mr_if_needed(/*tmp1 in do_CheckCast*/ R4_ARG2, _obj->as_register()); }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   176
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   177
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   178
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   179
  debug_only( __ illtrap(); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   180
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   181
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   182
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   183
// Implementation of NewInstanceStub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   184
NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   185
  _result = result;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   186
  _klass = klass;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   187
  _klass_reg = klass_reg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   188
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   189
  assert(stub_id == Runtime1::new_instance_id                 ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   190
         stub_id == Runtime1::fast_new_instance_id            ||
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   191
         stub_id == Runtime1::fast_new_instance_init_check_id,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   192
         "need new_instance id");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   193
  _stub_id = stub_id;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   194
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   195
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   196
void NewInstanceStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   197
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   198
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   199
  address entry = Runtime1::entry_for(_stub_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   200
  //__ load_const_optimized(R0, entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   201
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   202
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   203
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   204
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   205
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   206
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   207
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   208
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   209
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   210
// Implementation of NewTypeArrayStub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   211
NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   212
  _klass_reg = klass_reg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   213
  _length = length;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   214
  _result = result;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   215
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   216
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   217
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   218
void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   219
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   220
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   221
  address entry = Runtime1::entry_for(Runtime1::new_type_array_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   222
  //__ load_const_optimized(R0, entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   223
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   224
  __ mr_if_needed(/*op->tmp1()->as_register()*/ R5_ARG3, _length->as_register()); // already sign-extended
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   225
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   226
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   227
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   228
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   229
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   230
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   231
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   232
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   233
// Implementation of NewObjectArrayStub
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   234
NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   235
  _klass_reg = klass_reg;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   236
  _length = length;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   237
  _result = result;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   238
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   239
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   240
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   241
void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   242
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   243
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   244
  address entry = Runtime1::entry_for(Runtime1::new_object_array_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   245
  //__ load_const_optimized(R0, entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   246
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(entry));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   247
  __ mr_if_needed(/*op->tmp1()->as_register()*/ R5_ARG3, _length->as_register()); // already sign-extended
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   248
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   249
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   250
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   251
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   252
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   253
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   254
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   255
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   256
// Implementation of MonitorAccessStubs
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   257
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   258
  : MonitorAccessStub(obj_reg, lock_reg) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   259
  _info = new CodeEmitInfo(info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   260
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   261
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   262
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   263
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   264
  address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorenter_id : Runtime1::monitorenter_nofpu_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   265
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   266
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   267
  __ mr_if_needed(/*scratch_opr()->as_register()*/ R4_ARG2, _obj_reg->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   268
  assert(_lock_reg->as_register() == R5_ARG3, "");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   269
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   270
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   271
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   272
  ce->verify_oop_map(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   273
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   274
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   275
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   276
void MonitorExitStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   277
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   278
  if (_compute_lock) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   279
    ce->monitor_address(_monitor_ix, _lock_reg);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   280
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   281
  address stub = Runtime1::entry_for(ce->compilation()->has_fpu_code() ? Runtime1::monitorexit_id : Runtime1::monitorexit_nofpu_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   282
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   283
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   284
  assert(_lock_reg->as_register() == R4_ARG2, "");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   285
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   286
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   287
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   288
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   289
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   290
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   291
// Implementation of patching:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   292
// - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes).
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   293
// - Replace original code with a call to the stub.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   294
// At Runtime:
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   295
// - call to stub, jump to runtime
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   296
// - in runtime: preserve all registers (especially objects, i.e., source and destination object)
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   297
// - in runtime: after initializing class, restore original code, reexecute instruction
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   298
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   299
int PatchingStub::_patch_info_offset = -(5 * BytesPerInstWord);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   300
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   301
void PatchingStub::align_patch_site(MacroAssembler* ) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   302
  // Patch sites on ppc are always properly aligned.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   303
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   304
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   305
#ifdef ASSERT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   306
inline void compare_with_patch_site(address template_start, address pc_start, int bytes_to_copy) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   307
  address start = template_start;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   308
  for (int i = 0; i < bytes_to_copy; i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   309
    address ptr = (address)(pc_start + i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   310
    int a_byte = (*ptr) & 0xFF;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   311
    assert(a_byte == *start++, "should be the same code");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   312
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   313
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   314
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   315
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   316
void PatchingStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   317
  // copy original code here
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   318
  assert(NativeGeneralJump::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF,
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   319
         "not enough room for call");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   320
  assert((_bytes_to_copy & 0x3) == 0, "must copy a multiple of four bytes");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   321
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   322
  Label call_patch;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   323
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   324
  int being_initialized_entry = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   325
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   326
  if (_id == load_klass_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   327
    // Produce a copy of the load klass instruction for use by the being initialized case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   328
    AddressLiteral addrlit((address)NULL, metadata_Relocation::spec(_index));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   329
    __ load_const(_obj, addrlit, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   330
    DEBUG_ONLY( compare_with_patch_site(__ code_section()->start() + being_initialized_entry, _pc_start, _bytes_to_copy); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   331
  } else if (_id == load_mirror_id || _id == load_appendix_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   332
    // Produce a copy of the load mirror instruction for use by the being initialized case.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   333
    AddressLiteral addrlit((address)NULL, oop_Relocation::spec(_index));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   334
    __ load_const(_obj, addrlit, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   335
    DEBUG_ONLY( compare_with_patch_site(__ code_section()->start() + being_initialized_entry, _pc_start, _bytes_to_copy); )
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   336
  } else {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   337
    // Make a copy the code which is going to be patched.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   338
    for (int i = 0; i < _bytes_to_copy; i++) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   339
      address ptr = (address)(_pc_start + i);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   340
      int a_byte = (*ptr) & 0xFF;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   341
      __ emit_int8 (a_byte);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   342
    }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   343
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   344
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   345
  address end_of_patch = __ pc();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   346
  int bytes_to_skip = 0;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   347
  if (_id == load_mirror_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   348
    int offset = __ offset();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   349
    __ block_comment(" being_initialized check");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   350
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   351
    // Static field accesses have special semantics while the class
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   352
    // initializer is being run so we emit a test which can be used to
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   353
    // check that this code is being executed by the initializing
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   354
    // thread.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   355
    assert(_obj != noreg, "must be a valid register");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   356
    assert(_index >= 0, "must have oop index");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   357
    __ mr(R0, _obj); // spill
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   358
    __ ld(_obj, java_lang_Class::klass_offset_in_bytes(), _obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   359
    __ ld(_obj, in_bytes(InstanceKlass::init_thread_offset()), _obj);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   360
    __ cmpd(CCR0, _obj, R16_thread);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   361
    __ mr(_obj, R0); // restore
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   362
    __ bne(CCR0, call_patch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   363
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   364
    // Load_klass patches may execute the patched code before it's
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   365
    // copied back into place so we need to jump back into the main
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   366
    // code of the nmethod to continue execution.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   367
    __ b(_patch_site_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   368
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   369
    // Make sure this extra code gets skipped.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   370
    bytes_to_skip += __ offset() - offset;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   371
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   372
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   373
  // Now emit the patch record telling the runtime how to find the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   374
  // pieces of the patch.  We only need 3 bytes but it has to be
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   375
  // aligned as an instruction so emit 4 bytes.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   376
  int sizeof_patch_record = 4;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   377
  bytes_to_skip += sizeof_patch_record;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   378
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   379
  // Emit the offsets needed to find the code to patch.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   380
  int being_initialized_entry_offset = __ offset() - being_initialized_entry + sizeof_patch_record;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   381
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   382
  // Emit the patch record.  We need to emit a full word, so emit an extra empty byte.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   383
  __ emit_int8(0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   384
  __ emit_int8(being_initialized_entry_offset);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   385
  __ emit_int8(bytes_to_skip);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   386
  __ emit_int8(_bytes_to_copy);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   387
  address patch_info_pc = __ pc();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   388
  assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   389
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   390
  address entry = __ pc();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   391
  NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   392
  address target = NULL;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   393
  relocInfo::relocType reloc_type = relocInfo::none;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   394
  switch (_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   395
    case access_field_id:  target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   396
    case load_klass_id:    target = Runtime1::entry_for(Runtime1::load_klass_patching_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   397
                           reloc_type = relocInfo::metadata_type; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   398
    case load_mirror_id:   target = Runtime1::entry_for(Runtime1::load_mirror_patching_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   399
                           reloc_type = relocInfo::oop_type; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   400
    case load_appendix_id: target = Runtime1::entry_for(Runtime1::load_appendix_patching_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   401
                           reloc_type = relocInfo::oop_type; break;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   402
    default: ShouldNotReachHere();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   403
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   404
  __ bind(call_patch);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   405
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   406
  __ block_comment("patch entry point");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   407
  //__ load_const(R0, target); + mtctr + bctrl must have size -_patch_info_offset
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   408
  __ load_const32(R0, MacroAssembler::offset_to_global_toc(target));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   409
  __ add(R0, R29_TOC, R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   410
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   411
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   412
  assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   413
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   414
  __ b(_patch_site_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   415
  if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   416
    CodeSection* cs = __ code_section();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   417
    address pc = (address)_pc_start;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   418
    RelocIterator iter(cs, pc, pc + 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   419
    relocInfo::change_reloc_info_for_address(&iter, (address) pc, reloc_type, relocInfo::none);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   420
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   421
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   422
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   423
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   424
void DeoptimizeStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   425
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   426
  address stub = Runtime1::entry_for(Runtime1::deoptimize_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   427
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   428
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   429
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   430
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   431
  __ load_const_optimized(R0, _trap_request); // Pass trap request in R0.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   432
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   433
  ce->add_call_info_here(_info);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   434
  debug_only(__ illtrap());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   435
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   436
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   437
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   438
void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   439
  //---------------slow case: call to native-----------------
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   440
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   441
  __ mr(R3_ARG1, src()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   442
  __ extsw(R4_ARG2, src_pos()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   443
  __ mr(R5_ARG3, dst()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   444
  __ extsw(R6_ARG4, dst_pos()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   445
  __ extsw(R7_ARG5, length()->as_register());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   446
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   447
  ce->emit_static_call_stub();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   448
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   449
  bool success = ce->emit_trampoline_stub_for_call(SharedRuntime::get_resolve_static_call_stub());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   450
  if (!success) { return; }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   451
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   452
  __ relocate(relocInfo::static_call_type);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   453
  // Note: At this point we do not have the address of the trampoline
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   454
  // stub, and the entry point might be too far away for bl, so __ pc()
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   455
  // serves as dummy and the bl will be patched later.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   456
  __ code()->set_insts_mark();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   457
  __ bl(__ pc());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   458
  ce->add_call_info_here(info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   459
  ce->verify_oop_map(info());
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   460
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   461
#ifndef PRODUCT
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   462
  const address counter = (address)&Runtime1::_arraycopy_slowcase_cnt;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   463
  const Register tmp = R3, tmp2 = R4;
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   464
  int simm16_offs = __ load_const_optimized(tmp, counter, tmp2, true);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   465
  __ lwz(tmp2, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   466
  __ addi(tmp2, tmp2, 1);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   467
  __ stw(tmp2, simm16_offs, tmp);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   468
#endif
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   469
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   470
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   471
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   472
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   473
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   474
///////////////////////////////////////////////////////////////////////////////////
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   475
#if INCLUDE_ALL_GCS
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   476
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   477
void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   478
  // At this point we know that marking is in progress.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   479
  // If do_load() is true then we have to emit the
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   480
  // load of the previous value; otherwise it has already
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   481
  // been loaded into _pre_val.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   482
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   483
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   484
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   485
  assert(pre_val()->is_register(), "Precondition.");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   486
  Register pre_val_reg = pre_val()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   487
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   488
  if (do_load()) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   489
    ce->mem2reg(addr(), pre_val(), T_OBJECT, patch_code(), info(), false /*wide*/, false /*unaligned*/);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   490
  }
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   491
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   492
  __ cmpdi(CCR0, pre_val_reg, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   493
  __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), _continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   494
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   495
  address stub = Runtime1::entry_for(Runtime1::Runtime1::g1_pre_barrier_slow_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   496
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   497
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   498
  __ std(pre_val_reg, -8, R1_SP); // Pass pre_val on stack.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   499
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   500
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   501
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   502
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   503
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   504
void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   505
  __ bind(_entry);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   506
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   507
  assert(addr()->is_register(), "Precondition.");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   508
  assert(new_val()->is_register(), "Precondition.");
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   509
  Register addr_reg = addr()->as_pointer_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   510
  Register new_val_reg = new_val()->as_register();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   511
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   512
  __ cmpdi(CCR0, new_val_reg, 0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   513
  __ bc_far_optimized(Assembler::bcondCRbiIs1, __ bi0(CCR0, Assembler::equal), _continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   514
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   515
  address stub = Runtime1::entry_for(Runtime1::Runtime1::g1_post_barrier_slow_id);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   516
  //__ load_const_optimized(R0, stub);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   517
  __ add_const_optimized(R0, R29_TOC, MacroAssembler::offset_to_global_toc(stub));
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   518
  __ mtctr(R0);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   519
  __ mr(R0, addr_reg); // Pass addr in R0.
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   520
  __ bctrl();
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   521
  __ b(_continuation);
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   522
}
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   523
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   524
#endif // INCLUDE_ALL_GCS
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   525
///////////////////////////////////////////////////////////////////////////////////
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   526
839c8ba29724 8144019: PPC64 C1: Introduce Client Compiler
mdoerr
parents:
diff changeset
   527
#undef __