hotspot/src/cpu/x86/vm/c1_CodeStubs_x86.cpp
author duke
Wed, 05 Jul 2017 20:10:48 +0200
changeset 27963 88d7c7c376e9
parent 24442 4d4ae31dea26
child 28637 69d08079c4a3
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22234
da823d78ad65 8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents: 19710
diff changeset
     2
 * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5046
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5046
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5046
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    26
#include "c1/c1_CodeStubs.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    27
#include "c1/c1_FrameMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    28
#include "c1/c1_LIRAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    29
#include "c1/c1_MacroAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    30
#include "c1/c1_Runtime1.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    31
#include "nativeInst_x86.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    32
#include "runtime/sharedRuntime.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14837
diff changeset
    33
#include "utilities/macros.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    34
#include "vmreg_x86.inline.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14837
diff changeset
    35
#if INCLUDE_ALL_GCS
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    36
#include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14837
diff changeset
    37
#endif // INCLUDE_ALL_GCS
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
#define __ ce->masm()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
float ConversionStub::float_zero = 0.0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
double ConversionStub::double_zero = 0.0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
void ConversionStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  assert(bytecode() == Bytecodes::_f2i || bytecode() == Bytecodes::_d2i, "other conversions do not require stub");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  if (input()->is_single_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    __ comiss(input()->as_xmm_float_reg(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
              ExternalAddress((address)&float_zero));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  } else if (input()->is_double_xmm()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    __ comisd(input()->as_xmm_double_reg(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
              ExternalAddress((address)&double_zero));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    57
    LP64_ONLY(ShouldNotReachHere());
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    58
    __ push(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
    __ ftst();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
    __ fnstsw_ax();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
    __ sahf();
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    62
    __ pop(rax);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  Label NaN, do_return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  __ jccb(Assembler::parity, NaN);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  __ jccb(Assembler::below, do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  // input is > 0 -> return maxInt
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  // result register already contains 0x80000000, so subtracting 1 gives 0x7fffffff
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  __ decrement(result()->as_register());
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  __ jmpb(do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // input is NaN -> return 0
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  __ bind(NaN);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
    76
  __ xorptr(result()->as_register(), result()->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  __ bind(do_return);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
void CounterOverflowStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  __ bind(_entry);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 5547
diff changeset
    84
  ce->store_parameter(_method->as_register(), 1);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  ce->store_parameter(_bci, 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::counter_overflow_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  ce->verify_oop_map(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
RangeCheckStub::RangeCheckStub(CodeEmitInfo* info, LIR_Opr index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
                               bool throw_index_out_of_bounds_exception)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  : _throw_index_out_of_bounds_exception(throw_index_out_of_bounds_exception)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  , _index(index)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
{
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6453
diff changeset
    97
  assert(info != NULL, "must have info");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6453
diff changeset
    98
  _info = new CodeEmitInfo(info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
void RangeCheckStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  __ bind(_entry);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   104
  if (_info->deoptimize_on_exception()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   105
    address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   106
    __ call(RuntimeAddress(a));
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   107
    ce->add_call_info_here(_info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   108
    ce->verify_oop_map(_info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   109
    debug_only(__ should_not_reach_here());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   110
    return;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   111
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   112
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // pass the array index on stack because all registers must be preserved
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  if (_index->is_cpu_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    ce->store_parameter(_index->as_register(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    ce->store_parameter(_index->as_jint(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  Runtime1::StubID stub_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  if (_throw_index_out_of_bounds_exception) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    stub_id = Runtime1::throw_index_exception_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    stub_id = Runtime1::throw_range_check_failed_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  __ call(RuntimeAddress(Runtime1::entry_for(stub_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  ce->add_call_info_here(_info);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   127
  ce->verify_oop_map(_info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  debug_only(__ should_not_reach_here());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   131
PredicateFailedStub::PredicateFailedStub(CodeEmitInfo* info) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   132
  _info = new CodeEmitInfo(info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   133
}
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   134
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   135
void PredicateFailedStub::emit_code(LIR_Assembler* ce) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   136
  __ bind(_entry);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   137
  address a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   138
  __ call(RuntimeAddress(a));
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   139
  ce->add_call_info_here(_info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   140
  ce->verify_oop_map(_info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   141
  debug_only(__ should_not_reach_here());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   142
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
void DivByZeroStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  if (_offset != -1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::throw_div0_exception_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  debug_only(__ should_not_reach_here());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// Implementation of NewInstanceStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
NewInstanceStub::NewInstanceStub(LIR_Opr klass_reg, LIR_Opr result, ciInstanceKlass* klass, CodeEmitInfo* info, Runtime1::StubID stub_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  _result = result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  _klass = klass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  _klass_reg = klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  _info = new CodeEmitInfo(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  assert(stub_id == Runtime1::new_instance_id                 ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
         stub_id == Runtime1::fast_new_instance_id            ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
         stub_id == Runtime1::fast_new_instance_init_check_id,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
         "need new_instance id");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  _stub_id   = stub_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
void NewInstanceStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  assert(__ rsp_offset() == 0, "frame size should be fixed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  __ bind(_entry);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   173
  __ movptr(rdx, _klass_reg->as_register());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  __ call(RuntimeAddress(Runtime1::entry_for(_stub_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  ce->verify_oop_map(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  assert(_result->as_register() == rax, "result must in rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
// Implementation of NewTypeArrayStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
NewTypeArrayStub::NewTypeArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  _klass_reg = klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  _length = length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  _result = result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  _info = new CodeEmitInfo(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
void NewTypeArrayStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  assert(__ rsp_offset() == 0, "frame size should be fixed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  assert(_length->as_register() == rbx, "length must in rbx,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_type_array_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  ce->verify_oop_map(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  assert(_result->as_register() == rax, "result must in rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
// Implementation of NewObjectArrayStub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
NewObjectArrayStub::NewObjectArrayStub(LIR_Opr klass_reg, LIR_Opr length, LIR_Opr result, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  _klass_reg = klass_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  _result = result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  _length = length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  _info = new CodeEmitInfo(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
void NewObjectArrayStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  assert(__ rsp_offset() == 0, "frame size should be fixed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  assert(_length->as_register() == rbx, "length must in rbx,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  assert(_klass_reg->as_register() == rdx, "klass_reg must in rdx");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::new_object_array_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  ce->verify_oop_map(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  assert(_result->as_register() == rax, "result must in rax,");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
// Implementation of MonitorAccessStubs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
MonitorEnterStub::MonitorEnterStub(LIR_Opr obj_reg, LIR_Opr lock_reg, CodeEmitInfo* info)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
: MonitorAccessStub(obj_reg, lock_reg)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  _info = new CodeEmitInfo(info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
void MonitorEnterStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  assert(__ rsp_offset() == 0, "frame size should be fixed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  ce->store_parameter(_obj_reg->as_register(),  1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  ce->store_parameter(_lock_reg->as_register(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  Runtime1::StubID enter_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  if (ce->compilation()->has_fpu_code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
    enter_id = Runtime1::monitorenter_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    enter_id = Runtime1::monitorenter_nofpu_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  __ call(RuntimeAddress(Runtime1::entry_for(enter_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  ce->verify_oop_map(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
void MonitorExitStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  if (_compute_lock) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    // lock_reg was destroyed by fast unlocking attempt => recompute it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    ce->monitor_address(_monitor_ix, _lock_reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  ce->store_parameter(_lock_reg->as_register(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  // note: non-blocking leaf routine => no call info needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  Runtime1::StubID exit_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  if (ce->compilation()->has_fpu_code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    exit_id = Runtime1::monitorexit_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
    exit_id = Runtime1::monitorexit_nofpu_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  __ call(RuntimeAddress(Runtime1::entry_for(exit_id)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
// Implementation of patching:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
// - Copy the code at given offset to an inlined buffer (first the bytes, then the number of bytes)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
// - Replace original code with a call to the stub
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// At Runtime:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
// - call to stub, jump to runtime
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
// - in runtime: preserve all registers (rspecially objects, i.e., source and destination object)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
// - in runtime: after initializing class, restore original code, reexecute instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
int PatchingStub::_patch_info_offset = -NativeGeneralJump::instruction_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
void PatchingStub::align_patch_site(MacroAssembler* masm) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  // We're patching a 5-7 byte instruction on intel and we need to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // make sure that we don't see a piece of the instruction.  It
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // appears mostly impossible on Intel to simply invalidate other
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  // processors caches and since they may do aggressive prefetch it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // very hard to make a guess about what code might be in the icache.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // Force the instruction to be double word aligned so that it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  // doesn't span a cache line.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  masm->align(round_to(NativeGeneralJump::instruction_size, wordSize));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
void PatchingStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  assert(NativeCall::instruction_size <= _bytes_to_copy && _bytes_to_copy <= 0xFF, "not enough room for call");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  Label call_patch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  // static field accesses have special semantics while the class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  // initializer is being run so we emit a test which can be used to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  // check that this code is being executed by the initializing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  // thread.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  address being_initialized_entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  if (CommentedAssembly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    __ block_comment(" patch template");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  if (_id == load_klass_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    // produce a copy of the load klass instruction for use by the being initialized case
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   310
#ifdef ASSERT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
    address start = __ pc();
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   312
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   313
    Metadata* o = NULL;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   314
    __ mov_metadata(_obj, o);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   315
#ifdef ASSERT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   316
    for (int i = 0; i < _bytes_to_copy; i++) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   317
      address ptr = (address)(_pc_start + i);
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   318
      int a_byte = (*ptr) & 0xFF;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   319
      assert(a_byte == *start++, "should be the same code");
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   320
    }
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   321
#endif
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   322
  } else if (_id == load_mirror_id) {
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   323
    // produce a copy of the load mirror instruction for use by the being
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   324
    // initialized case
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   325
#ifdef ASSERT
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   326
    address start = __ pc();
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   327
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
    jobject o = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
    __ movoop(_obj, o);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
    for (int i = 0; i < _bytes_to_copy; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
      address ptr = (address)(_pc_start + i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
      int a_byte = (*ptr) & 0xFF;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      assert(a_byte == *start++, "should be the same code");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
    // make a copy the code which is going to be patched.
14837
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   339
    for (int i = 0; i < _bytes_to_copy; i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
      address ptr = (address)(_pc_start + i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
      int a_byte = (*ptr) & 0xFF;
14837
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   342
      __ emit_int8(a_byte);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
      *ptr = 0x90; // make the site look like a nop
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  address end_of_patch = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  int bytes_to_skip = 0;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   349
  if (_id == load_mirror_id) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
    int offset = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
    if (CommentedAssembly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
      __ block_comment(" being_initialized check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    assert(_obj != noreg, "must be a valid register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    Register tmp = rax;
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8067
diff changeset
   356
    Register tmp2 = rbx;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   357
    __ push(tmp);
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8067
diff changeset
   358
    __ push(tmp2);
9120
3606dd709168 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 8729
diff changeset
   359
    // Load without verification to keep code size small. We need it because
3606dd709168 7034967: C1: assert(false) failed: error (assembler_sparc.cpp:2043)
iveresov
parents: 8729
diff changeset
   360
    // begin_initialized_entry_offset has to fit in a byte. Also, we know it's not null.
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   361
    __ movptr(tmp2, Address(_obj, java_lang_Class::klass_offset_in_bytes()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
    __ get_thread(tmp);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   363
    __ cmpptr(tmp, Address(tmp2, InstanceKlass::init_thread_offset()));
8725
8c1e3dd5fe1b 7017732: move static fields into Class to prepare for perm gen removal
never
parents: 8067
diff changeset
   364
    __ pop(tmp2);
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   365
    __ pop(tmp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
    __ jcc(Assembler::notEqual, call_patch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
    // access_field patches may execute the patched code before it's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    // copied back into place so we need to jump back into the main
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    // code of the nmethod to continue execution.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
    __ jmp(_patch_site_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
    // make sure this extra code gets skipped
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
    bytes_to_skip += __ offset() - offset;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  if (CommentedAssembly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
    __ block_comment("patch data encoded as movl");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  // Now emit the patch record telling the runtime how to find the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  // pieces of the patch.  We only need 3 bytes but for readability of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  // the disassembly we make the data look like a movl reg, imm32,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  // which requires 5 bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  int sizeof_patch_record = 5;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  bytes_to_skip += sizeof_patch_record;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  // emit the offsets needed to find the code to patch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  int being_initialized_entry_offset = __ pc() - being_initialized_entry + sizeof_patch_record;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
14837
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   389
  __ emit_int8((unsigned char)0xB8);
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   390
  __ emit_int8(0);
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   391
  __ emit_int8(being_initialized_entry_offset);
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   392
  __ emit_int8(bytes_to_skip);
a75c3082d106 8004250: replace AbstractAssembler a_byte/a_long with emit_int8/emit_int32
twisti
parents: 13728
diff changeset
   393
  __ emit_int8(_bytes_to_copy);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  address patch_info_pc = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  assert(patch_info_pc - end_of_patch == bytes_to_skip, "incorrect patch info");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  NativeGeneralJump::insert_unconditional((address)_pc_start, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  address target = NULL;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   400
  relocInfo::relocType reloc_type = relocInfo::none;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  switch (_id) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
    case access_field_id:  target = Runtime1::entry_for(Runtime1::access_field_patching_id); break;
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   403
    case load_klass_id:    target = Runtime1::entry_for(Runtime1::load_klass_patching_id); reloc_type = relocInfo::metadata_type; break;
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   404
    case load_mirror_id:   target = Runtime1::entry_for(Runtime1::load_mirror_patching_id); reloc_type = relocInfo::oop_type; break;
19710
2f8ca425504e 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents: 16611
diff changeset
   405
    case load_appendix_id:      target = Runtime1::entry_for(Runtime1::load_appendix_patching_id); reloc_type = relocInfo::oop_type; break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  __ bind(call_patch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  if (CommentedAssembly) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
    __ block_comment("patch entry point");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  __ call(RuntimeAddress(target));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  assert(_patch_info_offset == (patch_info_pc - __ pc()), "must not change");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  int jmp_off = __ offset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  __ jmp(_patch_site_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  // Add enough nops so deoptimization can overwrite the jmp above with a call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  // and not destroy the world.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  for (int j = __ offset() ; j < jmp_off + 5 ; j++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
    __ nop();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  }
19710
2f8ca425504e 7199175: JSR 292: C1 needs patching when invokedynamic/invokehandle call site is not linked
roland
parents: 16611
diff changeset
   423
  if (_id == load_klass_id || _id == load_mirror_id || _id == load_appendix_id) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    CodeSection* cs = __ code_section();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
    RelocIterator iter(cs, (address)_pc_start, (address)(_pc_start + 1));
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   426
    relocInfo::change_reloc_info_for_address(&iter, (address) _pc_start, reloc_type, relocInfo::none);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   431
void DeoptimizeStub::emit_code(LIR_Assembler* ce) {
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   432
  __ bind(_entry);
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 22234
diff changeset
   433
  ce->store_parameter(_trap_request, 0);
10972
ef164805934c 7102657: JSR 292: C1 deoptimizes unlinked invokedynamic call sites infinitely
twisti
parents: 9186
diff changeset
   434
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::deoptimize_id)));
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   435
  ce->add_call_info_here(_info);
10972
ef164805934c 7102657: JSR 292: C1 deoptimizes unlinked invokedynamic call sites infinitely
twisti
parents: 9186
diff changeset
   436
  DEBUG_ONLY(__ should_not_reach_here());
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   437
}
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   438
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 1412
diff changeset
   439
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
void ImplicitNullCheckStub::emit_code(LIR_Assembler* ce) {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   441
  address a;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   442
  if (_info->deoptimize_on_exception()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   443
    // Deoptimize, do not throw the exception, because it is probably wrong to do it here.
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   444
    a = Runtime1::entry_for(Runtime1::predicate_failed_trap_id);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   445
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   446
    a = Runtime1::entry_for(Runtime1::throw_null_pointer_exception_id);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   447
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   448
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  ce->compilation()->implicit_exception_table()->append(_offset, __ offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  __ bind(_entry);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   451
  __ call(RuntimeAddress(a));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  ce->add_call_info_here(_info);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   453
  ce->verify_oop_map(_info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  debug_only(__ should_not_reach_here());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
void SimpleExceptionStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  assert(__ rsp_offset() == 0, "frame size should be fixed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // pass the object on stack because all registers must be preserved
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  if (_obj->is_cpu_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    ce->store_parameter(_obj->as_register(), 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  __ call(RuntimeAddress(Runtime1::entry_for(_stub)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  ce->add_call_info_here(_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  debug_only(__ should_not_reach_here());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
void ArrayCopyStub::emit_code(LIR_Assembler* ce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  //---------------slow case: call to native-----------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  __ bind(_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  // Figure out where the args should go
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13486
diff changeset
   476
  // This should really convert the IntrinsicID to the Method* and signature
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  // but I don't know how to do that.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  VMRegPair args[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  BasicType signature[5] = { T_OBJECT, T_INT, T_OBJECT, T_INT, T_INT};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  SharedRuntime::java_calling_convention(signature, args, 5, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
  // push parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  // (src, src_pos, dest, destPos, length)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  Register r[5];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  r[0] = src()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  r[1] = src_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  r[2] = dst()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  r[3] = dst_pos()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  r[4] = length()->as_register();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  // next registers will get stored on the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  for (int i = 0; i < 5 ; i++ ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    VMReg r_1 = args[i].first();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    if (r_1->is_stack()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
      int st_off = r_1->reg2stack() * wordSize;
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   497
      __ movptr (Address(rsp, st_off), r[i]);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
      assert(r[i] == args[i].first()->as_Register(), "Wrong register for arg ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  ce->align_call(lir_static_call);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  ce->emit_static_call_stub();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  AddressLiteral resolve(SharedRuntime::get_resolve_static_call_stub(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
                         relocInfo::static_call_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  __ call(resolve);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  ce->add_call_info_here(info());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
#ifndef PRODUCT
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
   512
  __ incrementl(ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  __ jmp(_continuation);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   518
/////////////////////////////////////////////////////////////////////////////
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14837
diff changeset
   519
#if INCLUDE_ALL_GCS
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   520
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   521
void G1PreBarrierStub::emit_code(LIR_Assembler* ce) {
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   522
  // At this point we know that marking is in progress.
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   523
  // If do_load() is true then we have to emit the
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   524
  // load of the previous value; otherwise it has already
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   525
  // been loaded into _pre_val.
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   526
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   527
  __ bind(_entry);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   528
  assert(pre_val()->is_register(), "Precondition.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   529
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   530
  Register pre_val_reg = pre_val()->as_register();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   531
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   532
  if (do_load()) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   533
    ce->mem2reg(addr(), pre_val(), T_OBJECT, patch_code(), info(), false /*wide*/, false /*unaligned*/);
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8729
diff changeset
   534
  }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   535
1394
apetrusenko
parents: 1066 1374
diff changeset
   536
  __ cmpptr(pre_val_reg, (int32_t) NULL_WORD);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   537
  __ jcc(Assembler::equal, _continuation);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   538
  ce->store_parameter(pre_val()->as_register(), 0);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   539
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::g1_pre_barrier_slow_id)));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   540
  __ jmp(_continuation);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   541
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   542
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   543
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   544
jbyte* G1PostBarrierStub::_byte_map_base = NULL;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   545
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   546
jbyte* G1PostBarrierStub::byte_map_base_slow() {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   547
  BarrierSet* bs = Universe::heap()->barrier_set();
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   548
  assert(bs->is_a(BarrierSet::G1SATBCTLogging),
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   549
         "Must be if we're using this.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   550
  return ((G1SATBCardTableModRefBS*)bs)->byte_map_base;
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   551
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   552
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   553
void G1PostBarrierStub::emit_code(LIR_Assembler* ce) {
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   554
  __ bind(_entry);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   555
  assert(addr()->is_register(), "Precondition.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   556
  assert(new_val()->is_register(), "Precondition.");
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   557
  Register new_val_reg = new_val()->as_register();
1394
apetrusenko
parents: 1066 1374
diff changeset
   558
  __ cmpptr(new_val_reg, (int32_t) NULL_WORD);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   559
  __ jcc(Assembler::equal, _continuation);
6970
3ac175042286 6992477: fix for 6991512 broke sparc barriers
never
parents: 6745
diff changeset
   560
  ce->store_parameter(addr()->as_pointer_register(), 0);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   561
  __ call(RuntimeAddress(Runtime1::entry_for(Runtime1::g1_post_barrier_slow_id)));
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   562
  __ jmp(_continuation);
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   563
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   564
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14837
diff changeset
   565
#endif // INCLUDE_ALL_GCS
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
   566
/////////////////////////////////////////////////////////////////////////////
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
#undef __