src/hotspot/share/c1/c1_LIRGenerator.cpp
author chegar
Thu, 17 Oct 2019 20:54:25 +0100
branchdatagramsocketimpl-branch
changeset 58679 9c3209ff7550
parent 58678 9cf78a70fa4f
parent 58537 30a9612a657d
permissions -rw-r--r--
datagramsocketimpl-branch: merge with default
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
54078
085309069d3c 8217576: C1 atomic access handlers use incorrect decorators
kbarrett
parents: 53765
diff changeset
     2
 * Copyright (c) 2005, 2019, 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: 5334
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5334
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: 5334
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"
30764
fec48bf5a827 8079792: GC directory structure cleanup
pliden
parents: 30305
diff changeset
    26
#include "c1/c1_Compilation.hpp"
29474
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
    27
#include "c1/c1_Defs.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    28
#include "c1/c1_FrameMap.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    29
#include "c1/c1_Instruction.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    30
#include "c1/c1_LIRAssembler.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    31
#include "c1/c1_LIRGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    32
#include "c1/c1_ValueStack.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    33
#include "ci/ciArrayKlass.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    34
#include "ci/ciInstance.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13487
diff changeset
    35
#include "ci/ciObjArray.hpp"
49164
7e958a8ebcd3 8195142: Refactor out card table from CardTableModRefBS to flatten the BarrierSet hierarchy
eosterlund
parents: 47580
diff changeset
    36
#include "ci/ciUtilities.hpp"
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
    37
#include "gc/shared/barrierSet.hpp"
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
    38
#include "gc/shared/c1/barrierSetC1.hpp"
58537
30a9612a657d 8232050: Improve inlining of Klass accessors
redestad
parents: 58273
diff changeset
    39
#include "oops/klass.inline.hpp"
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
    40
#include "runtime/arguments.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    41
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    42
#include "runtime/stubRoutines.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24933
diff changeset
    43
#include "runtime/vm_version.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6970
diff changeset
    44
#include "utilities/bitMap.inline.hpp"
15482
470d0b0c09f1 8005915: Unify SERIALGC and INCLUDE_ALTERNATE_GCS
jprovino
parents: 14832
diff changeset
    45
#include "utilities/macros.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
#define __ gen()->lir(__FILE__, __LINE__)->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
#define __ gen()->lir()->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
29474
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
    53
#ifndef PATCHED_ADDR
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
    54
#define PATCHED_ADDR  (max_jint)
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
    55
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
54125
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    57
void PhiResolverState::reset() {
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    58
  _virtual_operands.clear();
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    59
  _other_operands.clear();
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    60
  _vreg_table.clear();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
//--------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
// PhiResolver
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
// Resolves cycles:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
//  r1 := r2  becomes  temp := r1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//  r2 := r1           r1 := r2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//                     r2 := temp
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
// and orders moves:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
//  r2 := r3  becomes  r1 := r2
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//  r1 := r2           r2 := r3
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
54125
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    77
PhiResolver::PhiResolver(LIRGenerator* gen)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
 : _gen(gen)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
 , _state(gen->resolver_state())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
 , _temp(LIR_OprFact::illegalOpr)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
{
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // reinitialize the shared state arrays
54125
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
    83
  _state.reset();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
void PhiResolver::emit_move(LIR_Opr src, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  assert(src->is_valid(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  assert(dest->is_valid(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  __ move(src, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
void PhiResolver::move_temp_to(LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  assert(_temp->is_valid(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  emit_move(_temp, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  NOT_PRODUCT(_temp = LIR_OprFact::illegalOpr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
void PhiResolver::move_to_temp(LIR_Opr src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  assert(_temp->is_illegal(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  _temp = _gen->new_register(src->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  emit_move(src, _temp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
// Traverse assignment graph in depth first order and generate moves in post order
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// ie. two assignments: b := c, a := b start with node c:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
// Call graph: move(NULL, c) -> move(c, b) -> move(b, a)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
// Generates moves in this order: move b to a and move c to b
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
// ie. cycle a := b, b := a start with node a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
// Call graph: move(NULL, a) -> move(a, b) -> move(b, a)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
// Generates moves in this order: move b to temp, move a to b, move temp to a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
void PhiResolver::move(ResolveNode* src, ResolveNode* dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  if (!dest->visited()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    dest->set_visited();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    for (int i = dest->no_of_destinations()-1; i >= 0; i --) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
      move(dest, dest->destination_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  } else if (!dest->start_node()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    // cylce in graph detected
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    assert(_loop == NULL, "only one loop valid!");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    _loop = dest;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    move_to_temp(src->operand());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  } // else dest is a start node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  if (!dest->assigned()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    if (_loop == dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      move_temp_to(dest->operand());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
      dest->set_assigned();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
    } else if (src != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
      emit_move(src->operand(), dest->operand());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      dest->set_assigned();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
PhiResolver::~PhiResolver() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  int i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // resolve any cycles in moves from and to virtual registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  for (i = virtual_operands().length() - 1; i >= 0; i --) {
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 38017
diff changeset
   145
    ResolveNode* node = virtual_operands().at(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
    if (!node->visited()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      _loop = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      move(NULL, node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      node->set_start_node();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      assert(_temp->is_illegal(), "move_temp_to() call missing");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // generate move for move from non virtual register to abitrary destination
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  for (i = other_operands().length() - 1; i >= 0; i --) {
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 38017
diff changeset
   156
    ResolveNode* node = other_operands().at(i);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
    for (int j = node->no_of_destinations() - 1; j >= 0; j --) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
      emit_move(node->operand(), node->destination_at(j)->operand());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
ResolveNode* PhiResolver::create_node(LIR_Opr opr, bool source) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  ResolveNode* node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  if (opr->is_virtual()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    int vreg_num = opr->vreg_number();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
    node = vreg_table().at_grow(vreg_num, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    assert(node == NULL || node->operand() == opr, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
    if (node == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      node = new ResolveNode(opr);
38031
e0b822facc03 8149374: Replace C1-specific collection classes with universal collection classes
fzhinkin
parents: 38017
diff changeset
   172
      vreg_table().at_put(vreg_num, node);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    // Make sure that all virtual operands show up in the list when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    // they are used as the source of a move.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
    if (source && !virtual_operands().contains(node)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
      virtual_operands().append(node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    assert(source, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    node = new ResolveNode(opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
    other_operands().append(node);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  return node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
void PhiResolver::move(LIR_Opr src, LIR_Opr dest) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  assert(dest->is_virtual(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // tty->print("move "); src->print(); tty->print(" to "); dest->print(); tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  assert(src->is_valid(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  assert(dest->is_valid(), "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  ResolveNode* source = source_node(src);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  source->append(destination_node(dest));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
//--------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
// LIRItem
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
void LIRItem::set_result(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  assert(value()->operand()->is_illegal() || value()->operand()->is_constant(), "operand should never change");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  value()->set_operand(opr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  if (opr->is_virtual()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    _gen->_instruction_for_operand.at_put_grow(opr->vreg_number(), value(), NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  _result = opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
void LIRItem::load_item() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  if (result()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
    // update the items result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
    _result = value()->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  if (!result()->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    LIR_Opr reg = _gen->new_register(value()->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    __ move(result(), reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
    if (result()->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
      _result = reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
      set_result(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    }
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
void LIRItem::load_for_store(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  if (_gen->can_store_as_constant(value(), type)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    _result = value()->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
    if (!_result->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
      _result = LIR_OprFact::value_type(value()->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  } else if (type == T_BYTE || type == T_BOOLEAN) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
    load_byte_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
void LIRItem::load_item_force(LIR_Opr reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  LIR_Opr r = result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  if (r != reg) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   245
#if !defined(ARM) && !defined(E500V2)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
    if (r->type() != reg->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
      // moves between different types need an intervening spill slot
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   248
      r = _gen->force_to_spill(r, reg->type());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
    }
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   250
#endif
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   251
    __ move(r, reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    _result = reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
ciObject* LIRItem::get_jobject_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  ObjectType* oc = type()->as_ObjectType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  if (oc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    return oc->constant_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
jint LIRItem::get_jint_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  assert(is_constant() && value() != NULL, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  assert(type()->as_IntConstant() != NULL, "type check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  return type()->as_IntConstant()->value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
jint LIRItem::get_address_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  assert(is_constant() && value() != NULL, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  assert(type()->as_AddressConstant() != NULL, "type check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  return type()->as_AddressConstant()->value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
jfloat LIRItem::get_jfloat_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  assert(is_constant() && value() != NULL, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  assert(type()->as_FloatConstant() != NULL, "type check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  return type()->as_FloatConstant()->value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
jdouble LIRItem::get_jdouble_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  assert(is_constant() && value() != NULL, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
  assert(type()->as_DoubleConstant() != NULL, "type check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  return type()->as_DoubleConstant()->value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
jlong LIRItem::get_jlong_constant() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  assert(is_constant() && value() != NULL, "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  assert(type()->as_LongConstant() != NULL, "type check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  return type()->as_LongConstant()->value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
//--------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
void LIRGenerator::block_do_prolog(BlockBegin* block) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  if (PrintIRWithLIR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    block->print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // set up the list of LIR instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  assert(block->lir() == NULL, "LIR list already computed for this block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  _lir = new LIR_List(compilation(), block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  block->set_lir(_lir);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  __ branch_destination(block->label());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  if (LIRTraceExecution &&
5707
6c66849ed24e 6958292: C1: Enable parallel compilation
iveresov
parents: 5702
diff changeset
   319
      Compilation::current()->hir()->start()->block_id() != block->block_id() &&
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
      !block->is_set(BlockBegin::exception_entry_flag)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
    assert(block->lir()->instructions_list()->length() == 1, "should come right after br_dst");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
    trace_block_entry(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
void LIRGenerator::block_do_epilog(BlockBegin* block) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  if (PrintIRWithLIR) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
    tty->cr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // LIR_Opr for unpinned constants shouldn't be referenced by other
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // blocks so clear them out after processing the block.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  for (int i = 0; i < _unpinned_constants.length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
    _unpinned_constants.at(i)->clear_operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  _unpinned_constants.trunc_to(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // clear our any registers for other local constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  _constants.trunc_to(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  _reg_for_constants.trunc_to(0);
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
void LIRGenerator::block_do(BlockBegin* block) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  block_do_prolog(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  set_block(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  for (Instruction* instr = block; instr != NULL; instr = instr->next()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    if (instr->is_pinned()) do_root(instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  set_block(NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
  block_do_epilog(block);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
//-------------------------LIRGenerator-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
// This is where the tree-walk starts; instr must be root;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
void LIRGenerator::do_root(Value instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  CHECK_BAILOUT();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  InstructionMark im(compilation(), instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  assert(instr->is_pinned(), "use only with roots");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  assert(instr->subst() == instr, "shouldn't have missed substitution");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  instr->visit(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  assert(!instr->has_uses() || instr->operand()->is_valid() ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
         instr->as_Constant() != NULL || bailed_out(), "invalid item set");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
// This is called for each node in tree; the walk stops if a root is reached
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
void LIRGenerator::walk(Value instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
  InstructionMark im(compilation(), instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  //stop walk when encounter a root
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 45514
diff changeset
   384
  if ((instr->is_pinned() && instr->as_Phi() == NULL) || instr->operand()->is_valid()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    assert(instr->operand() != LIR_OprFact::illegalOpr || instr->as_Constant() != NULL, "this root has not yet been visited");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    assert(instr->subst() == instr, "shouldn't have missed substitution");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
    instr->visit(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
    // assert(instr->use_count() > 0 || instr->as_Phi() != NULL, "leaf instruction must have a use");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
CodeEmitInfo* LIRGenerator::state_for(Instruction* x, ValueStack* state, bool ignore_xhandler) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   395
  assert(state != NULL, "state must be defined");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   396
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   397
#ifndef PRODUCT
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   398
  state->verify();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   399
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   400
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   401
  ValueStack* s = state;
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   402
  for_each_state(s) {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   403
    if (s->kind() == ValueStack::EmptyExceptionState) {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   404
      assert(s->stack_size() == 0 && s->locals_size() == 0 && (s->locks_size() == 0 || s->locks_size() == 1), "state must be empty");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   405
      continue;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
    }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   407
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   408
    int index;
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   409
    Value value;
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   410
    for_each_stack_value(s, index, value) {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   411
      assert(value->subst() == value, "missed substitution");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   412
      if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) {
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   413
        walk(value);
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   414
        assert(value->operand()->is_valid(), "must be evaluated now");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   415
      }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   416
    }
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   417
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   418
    int bci = s->bci();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    IRScope* scope = s->scope();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    ciMethod* method = scope->method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    MethodLivenessResult liveness = method->liveness_at_bci(bci);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
    if (bci == SynchronizationEntryBCI) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
      if (x->as_ExceptionObject() || x->as_Throw()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
        // all locals are dead on exit from the synthetic unlocker
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
        liveness.clear();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
      } else {
11192
ff37c2093a0d 7112085: assert(fr.interpreter_frame_expression_stack_size()==0) failed: only handle empty stacks
iveresov
parents: 10730
diff changeset
   428
        assert(x->as_MonitorEnter() || x->as_ProfileInvoke(), "only other cases are MonitorEnter and ProfileInvoke");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    if (!liveness.is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
      // Degenerate or breakpointed method.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
      bailout("Degenerate or breakpointed method");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
      assert((int)liveness.size() == s->locals_size(), "error in use of liveness");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
      for_each_local_value(s, index, value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
        assert(value->subst() == value, "missed substition");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
        if (liveness.at(index) && !value->type()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
          if (!value->is_pinned() && value->as_Constant() == NULL && value->as_Local() == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
            walk(value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
            assert(value->operand()->is_valid(), "must be evaluated now");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
          // NULL out this local so that linear scan can assume that all non-NULL values are live.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
          s->invalidate_local(index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
   451
  return new CodeEmitInfo(state, ignore_xhandler ? NULL : x->exception_handlers(), x->check_flag(Instruction::DeoptimizeOnException));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
CodeEmitInfo* LIRGenerator::state_for(Instruction* x) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
   456
  return state_for(x, x->exception_state());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   460
void LIRGenerator::klass2reg_with_patching(LIR_Opr r, ciMetadata* obj, CodeEmitInfo* info, bool need_resolve) {
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   461
  /* C2 relies on constant pool entries being resolved (ciTypeFlow), so if TieredCompilation
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   462
   * is active and the class hasn't yet been resolved we need to emit a patch that resolves
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   463
   * the class. */
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   464
  if ((TieredCompilation && need_resolve) || !obj->is_loaded() || PatchALot) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
    assert(info != NULL, "info must be set if class is not loaded");
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13487
diff changeset
   466
    __ klass2reg_patch(NULL, r, info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    // no patching needed
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
   469
    __ metadata2reg(obj->constant_encoding(), r);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
void LIRGenerator::array_range_check(LIR_Opr array, LIR_Opr index,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
                                    CodeEmitInfo* null_check_info, CodeEmitInfo* range_check_info) {
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
   476
  CodeStub* stub = new RangeCheckStub(range_check_info, index, array);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  if (index->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
    cmp_mem_int(lir_cond_belowEqual, array, arrayOopDesc::length_offset_in_bytes(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
                index->as_jint(), null_check_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
    __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
    cmp_reg_mem(lir_cond_aboveEqual, index, array,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
                arrayOopDesc::length_offset_in_bytes(), T_INT, null_check_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
    __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
void LIRGenerator::nio_range_check(LIR_Opr buffer, LIR_Opr index, LIR_Opr result, CodeEmitInfo* info) {
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
   490
  CodeStub* stub = new RangeCheckStub(info, index);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  if (index->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
    cmp_mem_int(lir_cond_belowEqual, buffer, java_nio_Buffer::limit_offset(), index->as_jint(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    __ branch(lir_cond_belowEqual, T_INT, stub); // forward branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    cmp_reg_mem(lir_cond_aboveEqual, index, buffer,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
                java_nio_Buffer::limit_offset(), T_INT, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    __ branch(lir_cond_aboveEqual, T_INT, stub); // forward branch
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  __ move(index, result);
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
void LIRGenerator::arithmetic_op(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp_op, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  LIR_Opr result_op = result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  LIR_Opr left_op   = left;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  LIR_Opr right_op  = right;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  if (TwoOperandLIRForm && left_op != result_op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
    assert(right_op != result_op, "malformed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
    __ move(left_op, result_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
    left_op = result_op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
    case Bytecodes::_dadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
    case Bytecodes::_fadd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    case Bytecodes::_ladd:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    case Bytecodes::_iadd:  __ add(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    case Bytecodes::_fmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    case Bytecodes::_lmul:  __ mul(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    case Bytecodes::_dmul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
        if (is_strictfp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
          __ mul_strictfp(left_op, right_op, result_op, tmp_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
          __ mul(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
    case Bytecodes::_imul:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
      {
45632
e56cfcaea55c 8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents: 45514
diff changeset
   535
        bool did_strength_reduce = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
        if (right->is_constant()) {
45632
e56cfcaea55c 8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents: 45514
diff changeset
   538
          jint c = right->as_jint();
e56cfcaea55c 8181872: C1: possible overflow when strength reducing integer multiply by constant
vlivanov
parents: 45514
diff changeset
   539
          if (c > 0 && is_power_of_2(c)) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
            // do not need tmp here
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
            __ shift_left(left_op, exact_log2(c), result_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
            did_strength_reduce = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
          } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
            did_strength_reduce = strength_reduce_multiply(left_op, c, result_op, tmp_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
          }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
        // we couldn't strength reduce so just emit the multiply
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
        if (!did_strength_reduce) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
          __ mul(left_op, right_op, result_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
    case Bytecodes::_dsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
    case Bytecodes::_fsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
    case Bytecodes::_lsub:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
    case Bytecodes::_isub: __ sub(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
    case Bytecodes::_fdiv: __ div (left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
    // ldiv and lrem are implemented with a direct runtime call
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
    case Bytecodes::_ddiv:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
      {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
        if (is_strictfp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
          __ div_strictfp (left_op, right_op, result_op, tmp_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
        } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
          __ div (left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
    case Bytecodes::_drem:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
    case Bytecodes::_frem: __ rem (left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
    default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
void LIRGenerator::arithmetic_op_int(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, LIR_Opr tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  arithmetic_op(code, result, left, right, false, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
void LIRGenerator::arithmetic_op_long(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  arithmetic_op(code, result, left, right, false, LIR_OprFact::illegalOpr, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
void LIRGenerator::arithmetic_op_fpu(Bytecodes::Code code, LIR_Opr result, LIR_Opr left, LIR_Opr right, bool is_strictfp, LIR_Opr tmp) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  arithmetic_op(code, result, left, right, is_strictfp, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
void LIRGenerator::shift_op(Bytecodes::Code code, LIR_Opr result_op, LIR_Opr value, LIR_Opr count, LIR_Opr tmp) {
42063
dca9294d9f59 8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents: 42037
diff changeset
   596
dca9294d9f59 8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents: 42037
diff changeset
   597
  if (TwoOperandLIRForm && value != result_op
dca9294d9f59 8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents: 42037
diff changeset
   598
      // Only 32bit right shifts require two operand form on S390.
dca9294d9f59 8166561: [s390] Adaptions needed for s390 port in C1 and C2.
goetz
parents: 42037
diff changeset
   599
      S390_ONLY(&& (code == Bytecodes::_ishr || code == Bytecodes::_iushr))) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
    assert(count != result_op, "malformed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
    __ move(value, result_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
    value = result_op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  assert(count->is_constant() || count->is_register(), "must be");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
  case Bytecodes::_ishl:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  case Bytecodes::_lshl: __ shift_left(value, count, result_op, tmp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  case Bytecodes::_ishr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  case Bytecodes::_lshr: __ shift_right(value, count, result_op, tmp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  case Bytecodes::_iushr:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  case Bytecodes::_lushr: __ unsigned_shift_right(value, count, result_op, tmp); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
void LIRGenerator::logic_op (Bytecodes::Code code, LIR_Opr result_op, LIR_Opr left_op, LIR_Opr right_op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  if (TwoOperandLIRForm && left_op != result_op) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
    assert(right_op != result_op, "malformed");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
    __ move(left_op, result_op);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
    left_op = result_op;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  switch(code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
    case Bytecodes::_iand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    case Bytecodes::_land:  __ logical_and(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
    case Bytecodes::_ior:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
    case Bytecodes::_lor:   __ logical_or(left_op, right_op, result_op);  break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
    case Bytecodes::_ixor:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
    case Bytecodes::_lxor:  __ logical_xor(left_op, right_op, result_op); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
    default: ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
void LIRGenerator::monitor_enter(LIR_Opr object, LIR_Opr lock, LIR_Opr hdr, LIR_Opr scratch, int monitor_no, CodeEmitInfo* info_for_exception, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  if (!GenerateSynchronizationCode) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  // for slow path, use debug info for state after successful locking
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  CodeStub* slow_path = new MonitorEnterStub(object, lock, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  __ load_stack_address_monitor(monitor_no, lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  // for handling NullPointerException, use debug info representing just the lock stack before this monitorenter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  __ lock_object(hdr, object, lock, scratch, slow_path, info_for_exception);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   650
void LIRGenerator::monitor_exit(LIR_Opr object, LIR_Opr lock, LIR_Opr new_hdr, LIR_Opr scratch, int monitor_no) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  if (!GenerateSynchronizationCode) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  // setup registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  LIR_Opr hdr = lock;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  lock = new_hdr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  CodeStub* slow_path = new MonitorExitStub(lock, UseFastLocking, monitor_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  __ load_stack_address_monitor(monitor_no, lock);
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
   657
  __ unlock_object(hdr, object, lock, scratch, slow_path);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
24933
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   660
#ifndef PRODUCT
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   661
void LIRGenerator::print_if_not_loaded(const NewInstance* new_instance) {
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   662
  if (PrintNotLoaded && !new_instance->klass()->is_loaded()) {
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   663
    tty->print_cr("   ###class not loaded at new bci %d", new_instance->printable_bci());
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   664
  } else if (PrintNotLoaded && (TieredCompilation && new_instance->is_unresolved())) {
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   665
    tty->print_cr("   ###class not resolved at new bci %d", new_instance->printable_bci());
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   666
  }
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   667
}
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   668
#endif
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   669
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   670
void LIRGenerator::new_instance(LIR_Opr dst, ciInstanceKlass* klass, bool is_unresolved, LIR_Opr scratch1, LIR_Opr scratch2, LIR_Opr scratch3, LIR_Opr scratch4, LIR_Opr klass_reg, CodeEmitInfo* info) {
c16c7a4ac386 8031994: java/lang/Character/CheckProp test times out
rbackman
parents: 24442
diff changeset
   671
  klass2reg_with_patching(klass_reg, klass, info, is_unresolved);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
  // If klass is not loaded we do not know if the klass has finalizers:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  if (UseFastNewInstance && klass->is_loaded()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
      && !Klass::layout_helper_needs_slow_path(klass->layout_helper())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
    Runtime1::StubID stub_id = klass->is_initialized() ? Runtime1::fast_new_instance_id : Runtime1::fast_new_instance_init_check_id;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
    CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, stub_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
    assert(klass->is_loaded(), "must be loaded");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
    // allocate space for instance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
    assert(klass->size_helper() >= 0, "illegal instance size");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
    const int instance_size = align_object_size(klass->size_helper());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
    __ allocate_object(dst, scratch1, scratch2, scratch3, scratch4,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
                       oopDesc::header_size(), instance_size, klass_reg, !klass->is_initialized(), slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
    CodeStub* slow_path = new NewInstanceStub(klass_reg, dst, klass, info, Runtime1::new_instance_id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
    __ branch(lir_cond_always, T_ILLEGAL, slow_path);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
    __ branch_destination(slow_path->continuation());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
static bool is_constant_zero(Instruction* inst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  IntConstant* c = inst->type()->as_IntConstant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  if (c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
    return (c->value() == 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
static bool positive_constant(Instruction* inst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
  IntConstant* c = inst->type()->as_IntConstant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
  if (c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
    return (c->value() >= 0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
static ciArrayKlass* as_array_klass(ciType* type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
  if (type != NULL && type->is_array_klass() && type->is_loaded()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
    return (ciArrayKlass*)type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
    return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   720
static ciType* phi_declared_type(Phi* phi) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   721
  ciType* t = phi->operand_at(0)->declared_type();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   722
  if (t == NULL) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   723
    return NULL;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   724
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   725
  for(int i = 1; i < phi->operand_count(); i++) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   726
    if (t != phi->operand_at(i)->declared_type()) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   727
      return NULL;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   728
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   729
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   730
  return t;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   731
}
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   732
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
void LIRGenerator::arraycopy_helper(Intrinsic* x, int* flagsp, ciArrayKlass** expected_typep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
  Instruction* src     = x->argument_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  Instruction* src_pos = x->argument_at(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  Instruction* dst     = x->argument_at(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
  Instruction* dst_pos = x->argument_at(3);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
  Instruction* length  = x->argument_at(4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
  // first try to identify the likely type of the arrays involved
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
  ciArrayKlass* expected_type = NULL;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   742
  bool is_exact = false, src_objarray = false, dst_objarray = false;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
    ciArrayKlass* src_exact_type    = as_array_klass(src->exact_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
    ciArrayKlass* src_declared_type = as_array_klass(src->declared_type());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   746
    Phi* phi;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   747
    if (src_declared_type == NULL && (phi = src->as_Phi()) != NULL) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   748
      src_declared_type = as_array_klass(phi_declared_type(phi));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   749
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
    ciArrayKlass* dst_exact_type    = as_array_klass(dst->exact_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
    ciArrayKlass* dst_declared_type = as_array_klass(dst->declared_type());
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   752
    if (dst_declared_type == NULL && (phi = dst->as_Phi()) != NULL) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   753
      dst_declared_type = as_array_klass(phi_declared_type(phi));
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   754
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   755
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
    if (src_exact_type != NULL && src_exact_type == dst_exact_type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
      // the types exactly match so the type is fully known
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
      is_exact = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
      expected_type = src_exact_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
    } else if (dst_exact_type != NULL && dst_exact_type->is_obj_array_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
      ciArrayKlass* dst_type = (ciArrayKlass*) dst_exact_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
      ciArrayKlass* src_type = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
      if (src_exact_type != NULL && src_exact_type->is_obj_array_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
        src_type = (ciArrayKlass*) src_exact_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
      } else if (src_declared_type != NULL && src_declared_type->is_obj_array_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
        src_type = (ciArrayKlass*) src_declared_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
      if (src_type != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
        if (src_type->element_type()->is_subtype_of(dst_type->element_type())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
          is_exact = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
          expected_type = dst_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
    // at least pass along a good guess
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
    if (expected_type == NULL) expected_type = dst_exact_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
    if (expected_type == NULL) expected_type = src_declared_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
    if (expected_type == NULL) expected_type = dst_declared_type;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   779
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   780
    src_objarray = (src_exact_type && src_exact_type->is_obj_array_klass()) || (src_declared_type && src_declared_type->is_obj_array_klass());
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   781
    dst_objarray = (dst_exact_type && dst_exact_type->is_obj_array_klass()) || (dst_declared_type && dst_declared_type->is_obj_array_klass());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   782
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   783
489c9b5090e2 Initial load
duke
parents:
diff changeset
   784
  // if a probable array type has been identified, figure out if any
489c9b5090e2 Initial load
duke
parents:
diff changeset
   785
  // of the required checks for a fast case can be elided.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   786
  int flags = LIR_OpArrayCopy::all_flags;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   787
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   788
  if (!src_objarray)
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   789
    flags &= ~LIR_OpArrayCopy::src_objarray;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   790
  if (!dst_objarray)
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   791
    flags &= ~LIR_OpArrayCopy::dst_objarray;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   792
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   793
  if (!x->arg_needs_null_check(0))
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   794
    flags &= ~LIR_OpArrayCopy::src_null_check;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   795
  if (!x->arg_needs_null_check(2))
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   796
    flags &= ~LIR_OpArrayCopy::dst_null_check;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   797
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   798
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  if (expected_type != NULL) {
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   800
    Value length_limit = NULL;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   801
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   802
    IfOp* ifop = length->as_IfOp();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   803
    if (ifop != NULL) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   804
      // look for expressions like min(v, a.length) which ends up as
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   805
      //   x > y ? y : x  or  x >= y ? y : x
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   806
      if ((ifop->cond() == If::gtr || ifop->cond() == If::geq) &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   807
          ifop->x() == ifop->fval() &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   808
          ifop->y() == ifop->tval()) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   809
        length_limit = ifop->y();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   810
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   811
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   812
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   813
    // try to skip null checks and range checks
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   814
    NewArray* src_array = src->as_NewArray();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   815
    if (src_array != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
      flags &= ~LIR_OpArrayCopy::src_null_check;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   817
      if (length_limit != NULL &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   818
          src_array->length() == length_limit &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   819
          is_constant_zero(src_pos)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   820
        flags &= ~LIR_OpArrayCopy::src_range_check;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   821
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   822
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   823
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   824
    NewArray* dst_array = dst->as_NewArray();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   825
    if (dst_array != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
      flags &= ~LIR_OpArrayCopy::dst_null_check;
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   827
      if (length_limit != NULL &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   828
          dst_array->length() == length_limit &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   829
          is_constant_zero(dst_pos)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   830
        flags &= ~LIR_OpArrayCopy::dst_range_check;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   831
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   832
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
    // check from incoming constant values
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
    if (positive_constant(src_pos))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
      flags &= ~LIR_OpArrayCopy::src_pos_positive_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
    if (positive_constant(dst_pos))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
      flags &= ~LIR_OpArrayCopy::dst_pos_positive_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
    if (positive_constant(length))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
      flags &= ~LIR_OpArrayCopy::length_positive_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
    // see if the range check can be elided, which might also imply
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
    // that src or dst is non-null.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
    ArrayLength* al = length->as_ArrayLength();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
    if (al != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
      if (al->array() == src) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
        // it's the length of the source array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
        flags &= ~LIR_OpArrayCopy::length_positive_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
        flags &= ~LIR_OpArrayCopy::src_null_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
        if (is_constant_zero(src_pos))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
          flags &= ~LIR_OpArrayCopy::src_range_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
      if (al->array() == dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
        // it's the length of the destination array
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
        flags &= ~LIR_OpArrayCopy::length_positive_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
        flags &= ~LIR_OpArrayCopy::dst_null_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
        if (is_constant_zero(dst_pos))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
          flags &= ~LIR_OpArrayCopy::dst_range_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
    if (is_exact) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
      flags &= ~LIR_OpArrayCopy::type_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
9102
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   866
  IntConstant* src_int = src_pos->type()->as_IntConstant();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   867
  IntConstant* dst_int = dst_pos->type()->as_IntConstant();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   868
  if (src_int && dst_int) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   869
    int s_offs = src_int->value();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   870
    int d_offs = dst_int->value();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   871
    if (src_int->value() >= dst_int->value()) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   872
      flags &= ~LIR_OpArrayCopy::overlapping;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   873
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   874
    if (expected_type != NULL) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   875
      BasicType t = expected_type->element_type()->basic_type();
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   876
      int element_size = type2aelembytes(t);
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   877
      if (((arrayOopDesc::base_offset_in_bytes(t) + s_offs * element_size) % HeapWordSize == 0) &&
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   878
          ((arrayOopDesc::base_offset_in_bytes(t) + d_offs * element_size) % HeapWordSize == 0)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   879
        flags &= ~LIR_OpArrayCopy::unaligned;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   880
      }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   881
    }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   882
  } else if (src_pos == dst_pos || is_constant_zero(dst_pos)) {
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   883
    // src and dest positions are the same, or dst is zero so assume
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   884
    // nonoverlapping copy.
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   885
    flags &= ~LIR_OpArrayCopy::overlapping;
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   886
  }
4708a4aefb33 7033154: Improve C1 arraycopy performance
roland
parents: 8676
diff changeset
   887
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  if (src == dst) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
    // moving within a single array so no type checks are needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
    if (flags & LIR_OpArrayCopy::type_check) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
      flags &= ~LIR_OpArrayCopy::type_check;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
  *flagsp = flags;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
  *expected_typep = (ciArrayKlass*)expected_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
LIR_Opr LIRGenerator::round_item(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  assert(opr->is_register(), "why spill if item is not register?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  if (RoundFPResults && UseSSE < 1 && opr->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
    LIR_Opr result = new_register(T_FLOAT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
    set_vreg_flag(result, must_start_in_memory);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
    assert(opr->is_register(), "only a register can be spilled");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
    assert(opr->value_type()->is_float(), "rounding only for floats available");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
    __ roundfp(opr, LIR_OprFact::illegalOpr, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
    return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
  return opr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
LIR_Opr LIRGenerator::force_to_spill(LIR_Opr value, BasicType t) {
13487
75aa4880b15f 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 13486
diff changeset
   915
  assert(type2size[t] == type2size[value->type()],
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 33096
diff changeset
   916
         "size mismatch: t=%s, value->type()=%s", type2name(t), type2name(value->type()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
  if (!value->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
    // force into a register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
    LIR_Opr r = new_register(value->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
    __ move(value, r);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
    value = r;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
  // create a spill location
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  LIR_Opr tmp = new_register(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  set_vreg_flag(tmp, LIRGenerator::must_start_in_memory);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  // move from register to spill
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  __ move(value, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  return tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
void LIRGenerator::profile_branch(If* if_instr, If::Condition cond) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  if (if_instr->should_profile()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
    ciMethod* method = if_instr->profiled_method();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
    assert(method != NULL, "method should be set if branch is profiled");
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
   937
    ciMethodData* md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
   938
    assert(md != NULL, "Sanity");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
    ciProfileData* data = md->bci_to_data(if_instr->profiled_bci());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
    assert(data != NULL, "must have profiling data");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
    assert(data->is_BranchData(), "need BranchData for two-way branches");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
    int taken_count_offset     = md->byte_offset_of_slot(data, BranchData::taken_offset());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
    int not_taken_count_offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   944
    if (if_instr->is_swapped()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   945
      int t = taken_count_offset;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   946
      taken_count_offset = not_taken_count_offset;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   947
      not_taken_count_offset = t;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   948
    }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   949
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
   950
    LIR_Opr md_reg = new_register(T_METADATA);
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
   951
    __ metadata2reg(md->constant_encoding(), md_reg);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   952
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   953
    LIR_Opr data_offset_reg = new_pointer_register();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
    __ cmove(lir_cond(cond),
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   955
             LIR_OprFact::intptrConst(taken_count_offset),
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   956
             LIR_OprFact::intptrConst(not_taken_count_offset),
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7432
diff changeset
   957
             data_offset_reg, as_BasicType(if_instr->x()->type()));
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   958
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   959
    // MDO cells are intptr_t, so the data_reg width is arch-dependent.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   960
    LIR_Opr data_reg = new_pointer_register();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   961
    LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   962
    __ move(data_addr, data_reg);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
   963
    // Use leal instead of add to avoid destroying condition codes on x86
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
    LIR_Address* fake_incr_value = new LIR_Address(data_reg, DataLayout::counter_increment, T_INT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
    __ leal(LIR_OprFact::address(fake_incr_value), data_reg);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
   966
    __ move(data_reg, data_addr);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
// Phi technique:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
// This is about passing live values from one basic block to the other.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
// In code generated with Java it is rather rare that more than one
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
// value is on the stack from one basic block to the other.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
// We optimize our technique for efficient passing of one value
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
// (of type long, int, double..) but it can be extended.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
// When entering or leaving a basic block, all registers and all spill
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
// slots are release and empty. We use the released registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
// and spill slots to pass the live values from one block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
// to the other. The topmost value, i.e., the value on TOS of expression
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
// stack is passed in registers. All other values are stored in spilling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
// area. Every Phi has an index which designates its spill slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
// At exit of a basic block, we fill the register(s) and spill slots.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
// At entry of a basic block, the block_prolog sets up the content of phi nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
// and locks necessary registers and spilling slots.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
// move current value to referenced phi function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
void LIRGenerator::move_to_phi(PhiResolver* resolver, Value cur_val, Value sux_val) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
  Phi* phi = sux_val->as_Phi();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  // cur_val can be null without phi being null in conjunction with inlining
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  if (phi != NULL && cur_val != NULL && cur_val != phi && !phi->is_illegal()) {
36817
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   992
    Phi* cur_phi = cur_val->as_Phi();
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   993
    if (cur_phi != NULL && cur_phi->is_illegal()) {
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   994
      // Phi and local would need to get invalidated
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   995
      // (which is unexpected for Linear Scan).
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   996
      // But this case is very rare so we simply bail out.
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   997
      bailout("propagation of illegal phi");
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   998
      return;
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
   999
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
    LIR_Opr operand = cur_val->operand();
36817
57ce0a76b6b0 8151818: C1: LIRGenerator::move_to_phi can't deal with illegal phi
mdoerr
parents: 36559
diff changeset
  1001
    if (operand->is_illegal()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
      assert(cur_val->as_Constant() != NULL || cur_val->as_Local() != NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
             "these can be produced lazily");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
      operand = operand_for_instruction(cur_val);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
    resolver->move(operand, operand_for_instruction(phi));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
// Moves all stack values into their PHI position
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
void LIRGenerator::move_to_phi(ValueStack* cur_state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  BlockBegin* bb = block();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
  if (bb->number_of_sux() == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
    BlockBegin* sux = bb->sux_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
    assert(sux->number_of_preds() > 0, "invalid CFG");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
    // a block with only one predecessor never has phi functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
    if (sux->number_of_preds() > 1) {
54125
70a818b1d9db 8220502: Inefficient pre-sizing of PhiResolverState arrays in c1_LIRGenerator
redestad
parents: 54078
diff changeset
  1020
      PhiResolver resolver(this);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
      ValueStack* sux_state = sux->state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
      Value sux_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
      int index;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1026
      assert(cur_state->scope() == sux_state->scope(), "not matching");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1027
      assert(cur_state->locals_size() == sux_state->locals_size(), "not matching");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1028
      assert(cur_state->stack_size() == sux_state->stack_size(), "not matching");
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1029
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
      for_each_stack_value(sux_state, index, sux_value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
        move_to_phi(&resolver, cur_state->stack_at(index), sux_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
      for_each_local_value(sux_state, index, sux_value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
        move_to_phi(&resolver, cur_state->local_at(index), sux_value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
      assert(cur_state->caller_state() == sux_state->caller_state(), "caller states must be equal");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
LIR_Opr LIRGenerator::new_register(BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  int vreg = _virtual_register_number;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  // add a little fudge factor for the bailout, since the bailout is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  // only checked periodically.  This gives a few extra registers to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
  // hand out before we really run out, which helps us keep from
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  // tripping over assertions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  if (vreg + 20 >= LIR_OprDesc::vreg_max) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
    bailout("out of virtual registers");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
    if (vreg + 2 >= LIR_OprDesc::vreg_max) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
      // wrap it around
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
      _virtual_register_number = LIR_OprDesc::vreg_base;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1056
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1057
  _virtual_register_number += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1058
  return LIR_OprFact::virtual_register(vreg, type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1059
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1060
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1061
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1062
// Try to lock using register in hint
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1063
LIR_Opr LIRGenerator::rlock(Value instr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1064
  return new_register(instr->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1065
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1066
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1067
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1068
// does an rlock and sets result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1069
LIR_Opr LIRGenerator::rlock_result(Value x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1070
  LIR_Opr reg = rlock(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1071
  set_result(x, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1072
  return reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1073
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1074
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1075
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1076
// does an rlock and sets result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1077
LIR_Opr LIRGenerator::rlock_result(Value x, BasicType type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1078
  LIR_Opr reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1079
  switch (type) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1080
  case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1081
  case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1082
    reg = rlock_byte(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1083
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1084
  default:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1085
    reg = rlock(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1086
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1087
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1088
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1089
  set_result(x, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1090
  return reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1091
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1092
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1093
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1094
//---------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1095
ciObject* LIRGenerator::get_jobject_constant(Value value) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1096
  ObjectType* oc = value->type()->as_ObjectType();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1097
  if (oc) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1098
    return oc->constant_value();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1099
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1100
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1101
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1102
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1103
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1104
void LIRGenerator::do_ExceptionObject(ExceptionObject* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1105
  assert(block()->is_set(BlockBegin::exception_entry_flag), "ExceptionObject only allowed in exception handler block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1106
  assert(block()->next() == x, "ExceptionObject must be first instruction of block");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1107
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1108
  // no moves are created for phi functions at the begin of exception
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1109
  // handlers, so assign operands manually here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1110
  for_each_phi_fun(block(), phi,
53028
b3830528df29 8214352: C1: Unnecessary "compilation bailout: block join failed" with JVMTI
mdoerr
parents: 52220
diff changeset
  1111
                   if (!phi->is_illegal()) { operand_for_instruction(phi); });
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1112
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1113
  LIR_Opr thread_reg = getThreadPointer();
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1114
  __ move_wide(new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT),
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1115
               exceptionOopOpr());
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1116
  __ move_wide(LIR_OprFact::oopConst(NULL),
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1117
               new LIR_Address(thread_reg, in_bytes(JavaThread::exception_oop_offset()), T_OBJECT));
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1118
  __ move_wide(LIR_OprFact::oopConst(NULL),
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1119
               new LIR_Address(thread_reg, in_bytes(JavaThread::exception_pc_offset()), T_OBJECT));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1120
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1121
  LIR_Opr result = new_register(T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1122
  __ move(exceptionOopOpr(), result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1123
  set_result(x, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1124
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1125
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1126
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1127
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1128
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1129
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1130
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1131
//                        visitor functions
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1132
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1133
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1134
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1135
//----------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1136
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1137
void LIRGenerator::do_Phi(Phi* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1138
  // phi functions are never visited directly
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1139
  ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1140
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1141
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1142
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1143
// Code for a constant is generated lazily unless the constant is frequently used and can't be inlined.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1144
void LIRGenerator::do_Constant(Constant* x) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1145
  if (x->state_before() != NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1146
    // Any constant with a ValueStack requires patching so emit the patch here
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1147
    LIR_Opr reg = rlock_result(x);
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1148
    CodeEmitInfo* info = state_for(x, x->state_before());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1149
    __ oop2reg_patch(NULL, reg, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1150
  } else if (x->use_count() > 1 && !can_inline_as_constant(x)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1151
    if (!x->is_pinned()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1152
      // unpinned constants are handled specially so that they can be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1153
      // put into registers when they are used multiple times within a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1154
      // block.  After the block completes their operand will be
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1155
      // cleared so that other blocks can't refer to that register.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1156
      set_result(x, load_constant(x));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1157
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1158
      LIR_Opr res = x->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1159
      if (!res->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1160
        res = LIR_OprFact::value_type(x->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1161
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1162
      if (res->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1163
        LIR_Opr reg = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1164
        __ move(res, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1165
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1166
        set_result(x, res);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1167
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1168
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1169
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1170
    set_result(x, LIR_OprFact::value_type(x->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1171
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1172
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1173
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1174
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1175
void LIRGenerator::do_Local(Local* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1176
  // operand_for_instruction has the side effect of setting the result
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1177
  // so there's no need to do it here.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1178
  operand_for_instruction(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1179
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1180
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1181
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1182
void LIRGenerator::do_IfInstanceOf(IfInstanceOf* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1183
  Unimplemented();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1184
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1185
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1186
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1187
void LIRGenerator::do_Return(Return* x) {
2867
69187054225f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 2105
diff changeset
  1188
  if (compilation()->env()->dtrace_method_probes()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1189
    BasicTypeList signature;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1190
    signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21095
diff changeset
  1191
    signature.append(T_METADATA); // Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1192
    LIR_OprList* args = new LIR_OprList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1193
    args->append(getThreadPointer());
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  1194
    LIR_Opr meth = new_register(T_METADATA);
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  1195
    __ metadata2reg(method()->constant_encoding(), meth);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1196
    args->append(meth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1197
    call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), voidType, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1198
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1199
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1200
  if (x->type()->is_void()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1201
    __ return_op(LIR_OprFact::illegalOpr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1202
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1203
    LIR_Opr reg = result_register_for(x->type(), /*callee=*/true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1204
    LIRItem result(x->result(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1205
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1206
    result.load_item_force(reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1207
    __ return_op(result.result());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1208
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1209
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1210
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1211
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1212
// Examble: ref.get()
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1213
// Combination of LoadField and g1 pre-write barrier
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1214
void LIRGenerator::do_Reference_get(Intrinsic* x) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1215
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1216
  const int referent_offset = java_lang_ref_Reference::referent_offset;
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1217
  guarantee(referent_offset > 0, "referent offset not initialized");
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1218
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1219
  assert(x->number_of_arguments() == 1, "wrong type");
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1220
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1221
  LIRItem reference(x->argument_at(0), this);
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1222
  reference.load_item();
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1223
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1224
  // need to perform the null check on the reference objecy
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1225
  CodeEmitInfo* info = NULL;
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1226
  if (x->needs_null_check()) {
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1227
    info = state_for(x);
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1228
  }
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1229
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1230
  LIR_Opr result = rlock_result(x, T_OBJECT);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1231
  access_load_at(IN_HEAP | ON_WEAK_OOP_REF, T_OBJECT,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1232
                 reference, LIR_OprFact::intConst(referent_offset), result);
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  1233
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1234
12949
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1235
// Example: clazz.isInstance(object)
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1236
void LIRGenerator::do_isInstance(Intrinsic* x) {
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1237
  assert(x->number_of_arguments() == 2, "wrong type");
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1238
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1239
  // TODO could try to substitute this node with an equivalent InstanceOf
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1240
  // if clazz is known to be a constant Class. This will pick up newly found
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1241
  // constants after HIR construction. I'll leave this to a future change.
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1242
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1243
  // as a first cut, make a simple leaf call to runtime to stay platform independent.
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1244
  // could follow the aastore example in a future change.
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1245
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1246
  LIRItem clazz(x->argument_at(0), this);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1247
  LIRItem object(x->argument_at(1), this);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1248
  clazz.load_item();
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1249
  object.load_item();
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1250
  LIR_Opr result = rlock_result(x);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1251
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1252
  // need to perform null check on clazz
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1253
  if (x->needs_null_check()) {
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1254
    CodeEmitInfo* info = state_for(x);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1255
    __ null_check(clazz.result(), info);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1256
  }
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1257
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1258
  LIR_Opr call_result = call_runtime(clazz.value(), object.value(),
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1259
                                     CAST_FROM_FN_PTR(address, Runtime1::is_instance_of),
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1260
                                     x->type(),
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1261
                                     NULL); // NULL CodeEmitInfo results in a leaf call
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1262
  __ move(call_result, result);
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1263
}
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  1264
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1265
// Example: object.getClass ()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1266
void LIRGenerator::do_getClass(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1267
  assert(x->number_of_arguments() == 1, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1268
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1269
  LIRItem rcvr(x->argument_at(0), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1270
  rcvr.load_item();
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20709
diff changeset
  1271
  LIR_Opr temp = new_register(T_METADATA);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1272
  LIR_Opr result = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1273
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1274
  // need to perform the null check on the rcvr
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1275
  CodeEmitInfo* info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1276
  if (x->needs_null_check()) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1277
    info = state_for(x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1278
  }
21088
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20709
diff changeset
  1279
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20709
diff changeset
  1280
  // FIXME T_ADDRESS should actually be T_METADATA but it can't because the
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20709
diff changeset
  1281
  // meaning of these two is mixed up (see JDK-8026837).
4f0ada6dcace 8008242: VerifyOops is broken on SPARC
morris
parents: 20709
diff changeset
  1282
  __ move(new LIR_Address(rcvr.result(), oopDesc::klass_offset_in_bytes(), T_ADDRESS), temp, info);
51408
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1283
  __ move_wide(new LIR_Address(temp, in_bytes(Klass::java_mirror_offset()), T_ADDRESS), temp);
47580
96392e113a0a 8186777: Make Klass::_java_mirror an OopHandle
coleenp
parents: 47216
diff changeset
  1284
  // mirror = ((OopHandle)mirror)->resolve();
51408
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1285
  access_load(IN_NATIVE, T_OBJECT,
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1286
              LIR_OprFact::address(new LIR_Address(temp, T_OBJECT)), result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1287
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1288
36552
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1289
// java.lang.Class::isPrimitive()
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1290
void LIRGenerator::do_isPrimitive(Intrinsic* x) {
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1291
  assert(x->number_of_arguments() == 1, "wrong type");
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1292
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1293
  LIRItem rcvr(x->argument_at(0), this);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1294
  rcvr.load_item();
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1295
  LIR_Opr temp = new_register(T_METADATA);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1296
  LIR_Opr result = rlock_result(x);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1297
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1298
  CodeEmitInfo* info = NULL;
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1299
  if (x->needs_null_check()) {
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1300
    info = state_for(x);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1301
  }
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1302
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1303
  __ move(new LIR_Address(rcvr.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), temp, info);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1304
  __ cmp(lir_cond_notEqual, temp, LIR_OprFact::intConst(0));
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1305
  __ cmove(lir_cond_notEqual, LIR_OprFact::intConst(0), LIR_OprFact::intConst(1), result, T_BOOLEAN);
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1306
}
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  1307
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1308
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1309
// Example: Thread.currentThread()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1310
void LIRGenerator::do_currentThread(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1311
  assert(x->number_of_arguments() == 0, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1312
  LIR_Opr reg = rlock_result(x);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  1313
  __ move_wide(new LIR_Address(getThreadPointer(), in_bytes(JavaThread::threadObj_offset()), T_OBJECT), reg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1314
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1315
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1316
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1317
void LIRGenerator::do_RegisterFinalizer(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1318
  assert(x->number_of_arguments() == 1, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1319
  LIRItem receiver(x->argument_at(0), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1321
  receiver.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1322
  BasicTypeList signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1323
  signature.append(T_OBJECT); // receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1324
  LIR_OprList* args = new LIR_OprList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1325
  args->append(receiver.result());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1326
  CodeEmitInfo* info = state_for(x, x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1327
  call_runtime(&signature, args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1328
               CAST_FROM_FN_PTR(address, Runtime1::entry_for(Runtime1::register_finalizer_id)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1329
               voidType, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1330
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1331
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1332
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1333
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1334
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1335
//------------------------local access--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1336
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1337
LIR_Opr LIRGenerator::operand_for_instruction(Instruction* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1338
  if (x->operand()->is_illegal()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1339
    Constant* c = x->as_Constant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1340
    if (c != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1341
      x->set_operand(LIR_OprFact::value_type(c->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1342
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1343
      assert(x->as_Phi() || x->as_Local() != NULL, "only for Phi and Local");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1344
      // allocate a virtual register for this local or phi
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1345
      x->set_operand(rlock(x));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1346
      _instruction_for_operand.at_put_grow(x->operand()->vreg_number(), x, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1347
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1348
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1349
  return x->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1350
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1351
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1352
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1353
Instruction* LIRGenerator::instruction_for_opr(LIR_Opr opr) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1354
  if (opr->is_virtual()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1355
    return instruction_for_vreg(opr->vreg_number());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1356
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1357
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1358
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1359
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1360
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1361
Instruction* LIRGenerator::instruction_for_vreg(int reg_num) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1362
  if (reg_num < _instruction_for_operand.length()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1363
    return _instruction_for_operand.at(reg_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1364
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1365
  return NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1366
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1367
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1368
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1369
void LIRGenerator::set_vreg_flag(int vreg_num, VregFlag f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1370
  if (_vreg_flags.size_in_bits() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1371
    BitMap2D temp(100, num_vreg_flags);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1372
    _vreg_flags = temp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1373
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1374
  _vreg_flags.at_put_grow(vreg_num, f, true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1375
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1376
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1377
bool LIRGenerator::is_vreg_flag_set(int vreg_num, VregFlag f) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1378
  if (!_vreg_flags.is_valid_index(vreg_num, f)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1379
    return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1380
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1381
  return _vreg_flags.at(vreg_num, f);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1382
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1384
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1385
// Block local constant handling.  This code is useful for keeping
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1386
// unpinned constants and constants which aren't exposed in the IR in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1387
// registers.  Unpinned Constant instructions have their operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1388
// cleared when the block is finished so that other blocks can't end
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1389
// up referring to their registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1390
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1391
LIR_Opr LIRGenerator::load_constant(Constant* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1392
  assert(!x->is_pinned(), "only for unpinned constants");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1393
  _unpinned_constants.append(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1394
  return load_constant(LIR_OprFact::value_type(x->type())->as_constant_ptr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1395
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1396
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1397
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1398
LIR_Opr LIRGenerator::load_constant(LIR_Const* c) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1399
  BasicType t = c->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1400
  for (int i = 0; i < _constants.length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1401
    LIR_Const* other = _constants.at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1402
    if (t == other->type()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1403
      switch (t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1404
      case T_INT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1405
      case T_FLOAT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1406
        if (c->as_jint_bits() != other->as_jint_bits()) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1407
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1408
      case T_LONG:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1409
      case T_DOUBLE:
1673
fe654c35dfe2 6757316: load_constant() produces a wrong long constant, with high a low words swapped
never
parents: 1412
diff changeset
  1410
        if (c->as_jint_hi_bits() != other->as_jint_hi_bits()) continue;
fe654c35dfe2 6757316: load_constant() produces a wrong long constant, with high a low words swapped
never
parents: 1412
diff changeset
  1411
        if (c->as_jint_lo_bits() != other->as_jint_lo_bits()) continue;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1412
        break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1413
      case T_OBJECT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1414
        if (c->as_jobject() != other->as_jobject()) continue;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1415
        break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 45514
diff changeset
  1416
      default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 45514
diff changeset
  1417
        break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1418
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1419
      return _reg_for_constants.at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1420
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1421
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1422
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1423
  LIR_Opr result = new_register(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1424
  __ move((LIR_Opr)c, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1425
  _constants.append(c);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1426
  _reg_for_constants.append(result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1427
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1429
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1430
//------------------------field access--------------------------------------
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1431
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1432
void LIRGenerator::do_CompareAndSwap(Intrinsic* x, ValueType* type) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1433
  assert(x->number_of_arguments() == 4, "wrong type");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1434
  LIRItem obj   (x->argument_at(0), this);  // object
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1435
  LIRItem offset(x->argument_at(1), this);  // offset of field
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1436
  LIRItem cmp   (x->argument_at(2), this);  // value to compare with field
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1437
  LIRItem val   (x->argument_at(3), this);  // replace field with val if matches cmp
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1438
  assert(obj.type()->tag() == objectTag, "invalid type");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1439
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1440
  // In 64bit the type can be long, sparc doesn't have this assert
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1441
  // assert(offset.type()->tag() == intTag, "invalid type");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1442
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1443
  assert(cmp.type()->tag() == type->tag(), "invalid type");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1444
  assert(val.type()->tag() == type->tag(), "invalid type");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1445
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1446
  LIR_Opr result = access_atomic_cmpxchg_at(IN_HEAP, as_BasicType(type),
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1447
                                            obj, offset, cmp, val);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1448
  set_result(x, result);
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1449
}
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1450
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1451
// Comment copied form templateTable_i486.cpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1452
// ----------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1453
// Volatile variables demand their effects be made known to all CPU's in
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1454
// order.  Store buffers on most chips allow reads & writes to reorder; the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1455
// JMM's ReadAfterWrite.java test fails in -Xint mode without some kind of
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1456
// memory barrier (i.e., it's not sufficient that the interpreter does not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1457
// reorder volatile references, the hardware also must not reorder them).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1458
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1459
// According to the new Java Memory Model (JMM):
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1460
// (1) All volatiles are serialized wrt to each other.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1461
// ALSO reads & writes act as aquire & release, so:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1462
// (2) A read cannot let unrelated NON-volatile memory refs that happen after
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1463
// the read float up to before the read.  It's OK for non-volatile memory refs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1464
// that happen before the volatile read to float down below it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1465
// (3) Similar a volatile write cannot let unrelated NON-volatile memory refs
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1466
// that happen BEFORE the write float down to after the write.  It's OK for
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1467
// non-volatile memory refs that happen after the volatile write to float up
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1468
// before it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1469
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1470
// We only put in barriers around volatile refs (they are expensive), not
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1471
// _between_ memory refs (that would require us to track the flavor of the
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1472
// previous memory refs).  Requirements (2) and (3) require some barriers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1473
// before volatile stores and after volatile loads.  These nearly cover
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1474
// requirement (1) but miss the volatile-store-volatile-load case.  This final
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1475
// case is placed after volatile-stores although it could just as well go
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1476
// before volatile-loads.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1477
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1478
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1479
void LIRGenerator::do_StoreField(StoreField* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1480
  bool needs_patching = x->needs_patching();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1481
  bool is_volatile = x->field()->is_volatile();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1482
  BasicType field_type = x->field_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1483
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1484
  CodeEmitInfo* info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1485
  if (needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1486
    assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1487
    info = state_for(x, x->state_before());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1488
  } else if (x->needs_null_check()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1489
    NullCheck* nc = x->explicit_null_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1490
    if (nc == NULL) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1491
      info = state_for(x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1492
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1493
      info = state_for(nc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1494
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1495
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1496
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1497
  LIRItem object(x->obj(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1498
  LIRItem value(x->value(),  this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1499
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1500
  object.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1501
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1502
  if (is_volatile || needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1503
    // load item if field is volatile (fewer special cases for volatiles)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1504
    // load item if field not initialized
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1505
    // load item if field not constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1506
    // because of code patching we cannot inline constants
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1507
    if (field_type == T_BYTE || field_type == T_BOOLEAN) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1508
      value.load_byte_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1509
    } else  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1510
      value.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1511
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1512
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1513
    value.load_for_store(field_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1514
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1515
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1516
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1517
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1518
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1519
  if (PrintNotLoaded && needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1520
    tty->print_cr("   ###class not loaded at store_%s bci %d",
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1521
                  x->is_static() ?  "static" : "field", x->printable_bci());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1522
  }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1523
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1524
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1525
  if (x->needs_null_check() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1526
      (needs_patching ||
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1527
       MacroAssembler::needs_explicit_null_check(x->offset()))) {
43676
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1528
    // Emit an explicit null check because the offset is too large.
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1529
    // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1530
    // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1531
    __ null_check(object.result(), new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1532
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1533
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1534
  DecoratorSet decorators = IN_HEAP;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1535
  if (is_volatile) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1536
    decorators |= MO_SEQ_CST;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1537
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1538
  if (needs_patching) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1539
    decorators |= C1_NEEDS_PATCHING;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1540
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1541
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1542
  access_store_at(decorators, field_type, object, LIR_OprFact::intConst(x->offset()),
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1543
                  value.result(), info != NULL ? new CodeEmitInfo(info) : NULL, info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1544
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1545
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1546
void LIRGenerator::do_StoreIndexed(StoreIndexed* x) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1547
  assert(x->is_pinned(),"");
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1548
  bool needs_range_check = x->compute_needs_range_check();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1549
  bool use_length = x->length() != NULL;
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54200
diff changeset
  1550
  bool obj_store = is_reference_type(x->elt_type());
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1551
  bool needs_store_check = obj_store && (x->value()->as_Constant() == NULL ||
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1552
                                         !get_jobject_constant(x->value())->is_null_object() ||
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1553
                                         x->should_profile());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1554
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1555
  LIRItem array(x->array(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1556
  LIRItem index(x->index(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1557
  LIRItem value(x->value(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1558
  LIRItem length(this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1559
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1560
  array.load_item();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1561
  index.load_nonconstant();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1562
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1563
  if (use_length && needs_range_check) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1564
    length.set_instruction(x->length());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1565
    length.load_item();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1566
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1567
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1568
  if (needs_store_check || x->check_boolean()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1569
    value.load_item();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1570
  } else {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1571
    value.load_for_store(x->elt_type());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1572
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1573
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1574
  set_no_result(x);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1575
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1576
  // the CodeEmitInfo must be duplicated for each different
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1577
  // LIR-instruction because spilling can occur anywhere between two
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1578
  // instructions and so the debug information must be different
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1579
  CodeEmitInfo* range_check_info = state_for(x);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1580
  CodeEmitInfo* null_check_info = NULL;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1581
  if (x->needs_null_check()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1582
    null_check_info = new CodeEmitInfo(range_check_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1583
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1584
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1585
  if (GenerateRangeChecks && needs_range_check) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1586
    if (use_length) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1587
      __ cmp(lir_cond_belowEqual, length.result(), index.result());
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
  1588
      __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result(), array.result()));
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1589
    } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1590
      array_range_check(array.result(), index.result(), null_check_info, range_check_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1591
      // range_check also does the null check
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1592
      null_check_info = NULL;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1593
    }
1374
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1594
  }
4c24294029a9 6711316: Open source the Garbage-First garbage collector
ysr
parents: 1
diff changeset
  1595
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1596
  if (GenerateArrayStoreCheck && needs_store_check) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1597
    CodeEmitInfo* store_check_info = new CodeEmitInfo(range_check_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1598
    array_store_check(value.result(), array.result(), store_check_info, x->profiled_method(), x->profiled_bci());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1599
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1600
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50589
diff changeset
  1601
  DecoratorSet decorators = IN_HEAP | IS_ARRAY;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1602
  if (x->check_boolean()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1603
    decorators |= C1_MASK_BOOLEAN;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1604
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1605
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1606
  access_store_at(decorators, x->elt_type(), array, index.result(), value.result(),
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1607
                  NULL, null_check_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1608
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1609
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1610
void LIRGenerator::access_load_at(DecoratorSet decorators, BasicType type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1611
                                  LIRItem& base, LIR_Opr offset, LIR_Opr result,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1612
                                  CodeEmitInfo* patch_info, CodeEmitInfo* load_emit_info) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1613
  decorators |= ACCESS_READ;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1614
  LIRAccess access(this, decorators, base, offset, type, patch_info, load_emit_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1615
  if (access.is_raw()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1616
    _barrier_set->BarrierSetC1::load_at(access, result);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1617
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1618
    _barrier_set->load_at(access, result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1619
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1620
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1621
51408
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1622
void LIRGenerator::access_load(DecoratorSet decorators, BasicType type,
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1623
                               LIR_Opr addr, LIR_Opr result) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1624
  decorators |= ACCESS_READ;
51408
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1625
  LIRAccess access(this, decorators, LIR_OprFact::illegalOpr, LIR_OprFact::illegalOpr, type);
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1626
  access.set_resolved_addr(addr);
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1627
  if (access.is_raw()) {
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1628
    _barrier_set->BarrierSetC1::load(access, result);
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1629
  } else {
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1630
    _barrier_set->load(access, result);
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1631
  }
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1632
}
59269a19f108 8208582: Introduce native oop barriers in C1 for OopHandle
eosterlund
parents: 51079
diff changeset
  1633
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1634
void LIRGenerator::access_store_at(DecoratorSet decorators, BasicType type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1635
                                   LIRItem& base, LIR_Opr offset, LIR_Opr value,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1636
                                   CodeEmitInfo* patch_info, CodeEmitInfo* store_emit_info) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1637
  decorators |= ACCESS_WRITE;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1638
  LIRAccess access(this, decorators, base, offset, type, patch_info, store_emit_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1639
  if (access.is_raw()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1640
    _barrier_set->BarrierSetC1::store_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1641
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1642
    _barrier_set->store_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1643
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1644
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1645
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1646
LIR_Opr LIRGenerator::access_atomic_cmpxchg_at(DecoratorSet decorators, BasicType type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1647
                                               LIRItem& base, LIRItem& offset, LIRItem& cmp_value, LIRItem& new_value) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1648
  decorators |= ACCESS_READ;
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1649
  decorators |= ACCESS_WRITE;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1650
  // Atomic operations are SEQ_CST by default
54078
085309069d3c 8217576: C1 atomic access handlers use incorrect decorators
kbarrett
parents: 53765
diff changeset
  1651
  decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1652
  LIRAccess access(this, decorators, base, offset, type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1653
  if (access.is_raw()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1654
    return _barrier_set->BarrierSetC1::atomic_cmpxchg_at(access, cmp_value, new_value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1655
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1656
    return _barrier_set->atomic_cmpxchg_at(access, cmp_value, new_value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1657
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1658
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1659
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1660
LIR_Opr LIRGenerator::access_atomic_xchg_at(DecoratorSet decorators, BasicType type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1661
                                            LIRItem& base, LIRItem& offset, LIRItem& value) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1662
  decorators |= ACCESS_READ;
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1663
  decorators |= ACCESS_WRITE;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1664
  // Atomic operations are SEQ_CST by default
54078
085309069d3c 8217576: C1 atomic access handlers use incorrect decorators
kbarrett
parents: 53765
diff changeset
  1665
  decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1666
  LIRAccess access(this, decorators, base, offset, type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1667
  if (access.is_raw()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1668
    return _barrier_set->BarrierSetC1::atomic_xchg_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1669
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1670
    return _barrier_set->atomic_xchg_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1671
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1672
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1673
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1674
LIR_Opr LIRGenerator::access_atomic_add_at(DecoratorSet decorators, BasicType type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1675
                                           LIRItem& base, LIRItem& offset, LIRItem& value) {
51484
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1676
  decorators |= ACCESS_READ;
2730e629e32d 8209801: Rename C1_WRITE_ACCESS and C1_READ_ACCESS decorators to ACCESS_READ and ACCESS_WRITE
rkennke
parents: 51408
diff changeset
  1677
  decorators |= ACCESS_WRITE;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1678
  // Atomic operations are SEQ_CST by default
54078
085309069d3c 8217576: C1 atomic access handlers use incorrect decorators
kbarrett
parents: 53765
diff changeset
  1679
  decorators |= ((decorators & MO_DECORATOR_MASK) == 0) ? MO_SEQ_CST : 0;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1680
  LIRAccess access(this, decorators, base, offset, type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1681
  if (access.is_raw()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1682
    return _barrier_set->BarrierSetC1::atomic_add_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1683
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1684
    return _barrier_set->atomic_add_at(access, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1685
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1686
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1687
51487
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1688
LIR_Opr LIRGenerator::access_resolve(DecoratorSet decorators, LIR_Opr obj) {
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1689
  // Use stronger ACCESS_WRITE|ACCESS_READ by default.
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1690
  if ((decorators & (ACCESS_READ | ACCESS_WRITE)) == 0) {
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1691
    decorators |= ACCESS_READ | ACCESS_WRITE;
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1692
  }
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1693
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1694
  return _barrier_set->resolve(this, decorators, obj);
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1695
}
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1696
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1697
void LIRGenerator::do_LoadField(LoadField* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1698
  bool needs_patching = x->needs_patching();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1699
  bool is_volatile = x->field()->is_volatile();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1700
  BasicType field_type = x->field_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1701
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1702
  CodeEmitInfo* info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1703
  if (needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1704
    assert(x->explicit_null_check() == NULL, "can't fold null check into patching field access");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1705
    info = state_for(x, x->state_before());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1706
  } else if (x->needs_null_check()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1707
    NullCheck* nc = x->explicit_null_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1708
    if (nc == NULL) {
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1709
      info = state_for(x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1710
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1711
      info = state_for(nc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1712
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1713
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1714
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1715
  LIRItem object(x->obj(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1716
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1717
  object.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1718
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1719
#ifndef PRODUCT
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1720
  if (PrintNotLoaded && needs_patching) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1721
    tty->print_cr("   ###class not loaded at load_%s bci %d",
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1722
                  x->is_static() ?  "static" : "field", x->printable_bci());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1723
  }
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1724
#endif
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1725
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1726
  bool stress_deopt = StressLoopInvariantCodeMotion && info && info->deoptimize_on_exception();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1727
  if (x->needs_null_check() &&
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1728
      (needs_patching ||
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1729
       MacroAssembler::needs_explicit_null_check(x->offset()) ||
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1730
       stress_deopt)) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1731
    LIR_Opr obj = object.result();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1732
    if (stress_deopt) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1733
      obj = new_register(T_OBJECT);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1734
      __ move(LIR_OprFact::oopConst(NULL), obj);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1735
    }
43676
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1736
    // Emit an explicit null check because the offset is too large.
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1737
    // If the class is not loaded and the object is NULL, we need to deoptimize to throw a
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1738
    // NoClassDefFoundError in the interpreter instead of an implicit NPE from compiled code.
c6eed495a42b 8173373: C1: NPE is thrown instead of LinkageError when accessing inaccessible field on NULL receiver
thartmann
parents: 42544
diff changeset
  1739
    __ null_check(obj, new CodeEmitInfo(info), /* deoptimize */ needs_patching);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1740
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1741
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1742
  DecoratorSet decorators = IN_HEAP;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1743
  if (is_volatile) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1744
    decorators |= MO_SEQ_CST;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1745
  }
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1746
  if (needs_patching) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1747
    decorators |= C1_NEEDS_PATCHING;
34160
3240e478a30e 8138894: C1: Support IRIW on weak memory platforms
mdoerr
parents: 33105
diff changeset
  1748
  }
3240e478a30e 8138894: C1: Support IRIW on weak memory platforms
mdoerr
parents: 33105
diff changeset
  1749
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1750
  LIR_Opr result = rlock_result(x, field_type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1751
  access_load_at(decorators, field_type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1752
                 object, LIR_OprFact::intConst(x->offset()), result,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1753
                 info ? new CodeEmitInfo(info) : NULL, info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1754
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1755
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1756
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1757
//------------------------java.nio.Buffer.checkIndex------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1758
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1759
// int java.nio.Buffer.checkIndex(int)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1760
void LIRGenerator::do_NIOCheckIndex(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1761
  // NOTE: by the time we are in checkIndex() we are guaranteed that
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1762
  // the buffer is non-null (because checkIndex is package-private and
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1763
  // only called from within other methods in the buffer).
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1764
  assert(x->number_of_arguments() == 2, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1765
  LIRItem buf  (x->argument_at(0), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1766
  LIRItem index(x->argument_at(1), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1767
  buf.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1768
  index.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1769
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1770
  LIR_Opr result = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1771
  if (GenerateRangeChecks) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1772
    CodeEmitInfo* info = state_for(x);
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
  1773
    CodeStub* stub = new RangeCheckStub(info, index.result());
51487
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1774
    LIR_Opr buf_obj = access_resolve(IS_NOT_NULL | ACCESS_READ, buf.result());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1775
    if (index.result()->is_constant()) {
51487
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1776
      cmp_mem_int(lir_cond_belowEqual, buf_obj, java_nio_Buffer::limit_offset(), index.result()->as_jint(), info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1777
      __ branch(lir_cond_belowEqual, T_INT, stub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1778
    } else {
51487
f791e6fb8040 8209667: Explicit barriers for C1/LIR
rkennke
parents: 51484
diff changeset
  1779
      cmp_reg_mem(lir_cond_aboveEqual, index.result(), buf_obj,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1780
                  java_nio_Buffer::limit_offset(), T_INT, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1781
      __ branch(lir_cond_aboveEqual, T_INT, stub);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1782
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1783
    __ move(index.result(), result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1784
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1785
    // Just load the index into the result register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1786
    __ move(index.result(), result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1787
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1788
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1789
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1790
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1791
//------------------------array access--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1792
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1793
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1794
void LIRGenerator::do_ArrayLength(ArrayLength* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1795
  LIRItem array(x->array(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1796
  array.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1797
  LIR_Opr reg = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1798
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1799
  CodeEmitInfo* info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1800
  if (x->needs_null_check()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1801
    NullCheck* nc = x->explicit_null_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1802
    if (nc == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1803
      info = state_for(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1804
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1805
      info = state_for(nc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1806
    }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1807
    if (StressLoopInvariantCodeMotion && info->deoptimize_on_exception()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1808
      LIR_Opr obj = new_register(T_OBJECT);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1809
      __ move(LIR_OprFact::oopConst(NULL), obj);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1810
      __ null_check(obj, new CodeEmitInfo(info));
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1811
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1812
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1813
  __ load(new LIR_Address(array.result(), arrayOopDesc::length_offset_in_bytes(), T_INT), reg, info, lir_patch_none);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1814
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1815
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1816
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1817
void LIRGenerator::do_LoadIndexed(LoadIndexed* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1818
  bool use_length = x->length() != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1819
  LIRItem array(x->array(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1820
  LIRItem index(x->index(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1821
  LIRItem length(this);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1822
  bool needs_range_check = x->compute_needs_range_check();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1823
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1824
  if (use_length && needs_range_check) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1825
    length.set_instruction(x->length());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1826
    length.load_item();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1827
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1828
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1829
  array.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1830
  if (index.is_constant() && can_inline_as_constant(x->index())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1831
    // let it be a constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1832
    index.dont_load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1833
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1834
    index.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1835
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1836
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1837
  CodeEmitInfo* range_check_info = state_for(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1838
  CodeEmitInfo* null_check_info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1839
  if (x->needs_null_check()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1840
    NullCheck* nc = x->explicit_null_check();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1841
    if (nc != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1842
      null_check_info = state_for(nc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1843
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1844
      null_check_info = range_check_info;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1845
    }
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1846
    if (StressLoopInvariantCodeMotion && null_check_info->deoptimize_on_exception()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1847
      LIR_Opr obj = new_register(T_OBJECT);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1848
      __ move(LIR_OprFact::oopConst(NULL), obj);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1849
      __ null_check(obj, new CodeEmitInfo(null_check_info));
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1850
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1851
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1852
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1853
  if (GenerateRangeChecks && needs_range_check) {
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1854
    if (StressLoopInvariantCodeMotion && range_check_info->deoptimize_on_exception()) {
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
  1855
      __ branch(lir_cond_always, T_ILLEGAL, new RangeCheckStub(range_check_info, index.result(), array.result()));
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  1856
    } else if (use_length) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1857
      // TODO: use a (modified) version of array_range_check that does not require a
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1858
      //       constant length to be loaded to a register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1859
      __ cmp(lir_cond_belowEqual, length.result(), index.result());
50094
2f79462aab9b 8201593: Print array length in ArrayIndexOutOfBoundsException.
goetz
parents: 49906
diff changeset
  1860
      __ branch(lir_cond_belowEqual, T_INT, new RangeCheckStub(range_check_info, index.result(), array.result()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1861
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1862
      array_range_check(array.result(), index.result(), null_check_info, range_check_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1863
      // The range check performs the null check, so clear it out for the load
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1864
      null_check_info = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1865
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1866
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1867
50728
9375184cec98 8205459: Rename Access API flag decorators
kbarrett
parents: 50589
diff changeset
  1868
  DecoratorSet decorators = IN_HEAP | IS_ARRAY;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1869
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1870
  LIR_Opr result = rlock_result(x, x->elt_type());
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1871
  access_load_at(decorators, x->elt_type(),
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1872
                 array, index.result(), result,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  1873
                 NULL, null_check_info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1874
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1875
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1876
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1877
void LIRGenerator::do_NullCheck(NullCheck* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1878
  if (x->can_trap()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1879
    LIRItem value(x->obj(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1880
    value.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1881
    CodeEmitInfo* info = state_for(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1882
    __ null_check(value.result(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1883
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1884
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1885
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1886
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1887
void LIRGenerator::do_TypeCast(TypeCast* x) {
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1888
  LIRItem value(x->obj(), this);
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1889
  value.load_item();
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1890
  // the result is the same as from the node we are casting
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1891
  set_result(x, value.result());
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1892
}
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1893
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  1894
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1895
void LIRGenerator::do_Throw(Throw* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1896
  LIRItem exception(x->exception(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1897
  exception.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1898
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1899
  LIR_Opr exception_opr = exception.result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1900
  CodeEmitInfo* info = state_for(x, x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1901
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1902
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1903
  if (PrintC1Statistics) {
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  1904
    increment_counter(Runtime1::throw_count_address(), T_INT);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1905
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1906
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1907
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1908
  // check if the instruction has an xhandler in any of the nested scopes
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1909
  bool unwind = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1910
  if (info->exception_handlers()->length() == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1911
    // this throw is not inside an xhandler
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1912
    unwind = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1913
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1914
    // get some idea of the throw type
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1915
    bool type_is_exact = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1916
    ciType* throw_type = x->exception()->exact_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1917
    if (throw_type == NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1918
      type_is_exact = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1919
      throw_type = x->exception()->declared_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1920
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1921
    if (throw_type != NULL && throw_type->is_instance_klass()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1922
      ciInstanceKlass* throw_klass = (ciInstanceKlass*)throw_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1923
      unwind = !x->exception_handlers()->could_catch(throw_klass, type_is_exact);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1924
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1925
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1926
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1927
  // do null check before moving exception oop into fixed register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1928
  // to avoid a fixed interval with an oop during the null check.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1929
  // Use a copy of the CodeEmitInfo because debug information is
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1930
  // different for null_check and throw.
37291
f13632a2a389 8151724: Remove -XX:GenerateCompilerNullChecks
thartmann
parents: 36817
diff changeset
  1931
  if (x->exception()->as_NewInstance() == NULL && x->exception()->as_ExceptionObject() == NULL) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1932
    // if the exception object wasn't created using new then it might be null.
6745
a34ef8968a84 6986046: C1 valuestack cleanup
roland
parents: 6742
diff changeset
  1933
    __ null_check(exception_opr, new CodeEmitInfo(info, x->state()->copy(ValueStack::ExceptionState, x->state()->bci())));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1934
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1935
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5055
diff changeset
  1936
  if (compilation()->env()->jvmti_can_post_on_exceptions()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1937
    // we need to go through the exception lookup path to get JVMTI
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1938
    // notification done
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1939
    unwind = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1940
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1941
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1942
  // move exception oop into fixed register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1943
  __ move(exception_opr, exceptionOopOpr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1944
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1945
  if (unwind) {
5334
b2d040a8d375 6939930: exception unwind changes in 6919934 hurts compilation speed
never
parents: 5055
diff changeset
  1946
    __ unwind_exception(exceptionOopOpr());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1947
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1948
    __ throw_exception(exceptionPcOpr(), exceptionOopOpr(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1949
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1950
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1951
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1952
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1953
void LIRGenerator::do_RoundFP(RoundFP* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1954
  LIRItem input(x->input(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1955
  input.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1956
  LIR_Opr input_opr = input.result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1957
  assert(input_opr->is_register(), "why round if value is not in a register?");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1958
  assert(input_opr->is_single_fpu() || input_opr->is_double_fpu(), "input should be floating-point value");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1959
  if (input_opr->is_single_fpu()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1960
    set_result(x, round_item(input_opr)); // This code path not currently taken
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1961
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1962
    LIR_Opr result = new_register(T_DOUBLE);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1963
    set_vreg_flag(result, must_start_in_memory);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1964
    __ roundfp(input_opr, LIR_OprFact::illegalOpr, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1965
    set_result(x, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1966
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1967
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1968
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1969
// Here UnsafeGetRaw may have x->base() and x->index() be int or long
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1970
// on both 64 and 32 bits. Expecting x->base() to be always long on 64bit.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1971
void LIRGenerator::do_UnsafeGetRaw(UnsafeGetRaw* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1972
  LIRItem base(x->base(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1973
  LIRItem idx(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1974
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1975
  base.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1976
  if (x->has_index()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1977
    idx.set_instruction(x->index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1978
    idx.load_nonconstant();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1979
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1980
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1981
  LIR_Opr reg = rlock_result(x, x->basic_type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1982
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1983
  int   log2_scale = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1984
  if (x->has_index()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1985
    log2_scale = x->log2_scale();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1986
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1987
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1988
  assert(!x->has_index() || idx.value() == x->index(), "should match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1989
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1990
  LIR_Opr base_op = base.result();
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1991
  LIR_Opr index_op = idx.result();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1992
#ifndef _LP64
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  1993
  if (base_op->type() == T_LONG) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1994
    base_op = new_register(T_INT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1995
    __ convert(Bytecodes::_l2i, base.result(), base_op);
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1996
  }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1997
  if (x->has_index()) {
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  1998
    if (index_op->type() == T_LONG) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  1999
      LIR_Opr long_index_op = index_op;
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2000
      if (index_op->is_constant()) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2001
        long_index_op = new_register(T_LONG);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2002
        __ move(index_op, long_index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2003
      }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2004
      index_op = new_register(T_INT);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2005
      __ convert(Bytecodes::_l2i, long_index_op, index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2006
    } else {
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2007
      assert(x->index()->type()->tag() == intTag, "must be");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2008
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2009
  }
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2010
  // At this point base and index should be all ints.
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2011
  assert(base_op->type() == T_INT && !base_op->is_constant(), "base should be an non-constant int");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2012
  assert(!x->has_index() || index_op->type() == T_INT, "index should be an int");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2013
#else
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2014
  if (x->has_index()) {
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2015
    if (index_op->type() == T_INT) {
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2016
      if (!index_op->is_constant()) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2017
        index_op = new_register(T_LONG);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2018
        __ convert(Bytecodes::_i2l, idx.result(), index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2019
      }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2020
    } else {
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2021
      assert(index_op->type() == T_LONG, "must be");
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2022
      if (index_op->is_constant()) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2023
        index_op = new_register(T_LONG);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2024
        __ move(idx.result(), index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2025
      }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2026
    }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2027
  }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2028
  // At this point base is a long non-constant
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2029
  // Index is a long register or a int constant.
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2030
  // We allow the constant to stay an int because that would allow us a more compact encoding by
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2031
  // embedding an immediate offset in the address expression. If we have a long constant, we have to
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2032
  // move it into a register first.
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2033
  assert(base_op->type() == T_LONG && !base_op->is_constant(), "base must be a long non-constant");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2034
  assert(!x->has_index() || (index_op->type() == T_INT && index_op->is_constant()) ||
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2035
                            (index_op->type() == T_LONG && !index_op->is_constant()), "unexpected index type");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2036
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2038
  BasicType dst_type = x->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2039
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2040
  LIR_Address* addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2041
  if (index_op->is_constant()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2042
    assert(log2_scale == 0, "must not have a scale");
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2043
    assert(index_op->type() == T_INT, "only int constants supported");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2044
    addr = new LIR_Address(base_op, index_op->as_jint(), dst_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2045
  } else {
1066
717c3345024f 5108146: Merge i486 and amd64 cpu directories
never
parents: 1
diff changeset
  2046
#ifdef X86
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2047
    addr = new LIR_Address(base_op, index_op, LIR_Address::Scale(log2_scale), 0, dst_type);
29474
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
  2048
#elif defined(GENERATE_ADDRESS_IS_PREFERRED)
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
  2049
    addr = generate_address(base_op, index_op, log2_scale, 0, dst_type);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2050
#else
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2051
    if (index_op->is_illegal() || log2_scale == 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2052
      addr = new LIR_Address(base_op, index_op, dst_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2053
    } else {
4430
95b539dfa1e8 6769124: various 64-bit fixes for c1
roland
parents: 3908
diff changeset
  2054
      LIR_Opr tmp = new_pointer_register();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2055
      __ shift_left(index_op, log2_scale, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2056
      addr = new LIR_Address(base_op, tmp, dst_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2057
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2058
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2059
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2060
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2061
  if (x->may_be_unaligned() && (dst_type == T_LONG || dst_type == T_DOUBLE)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2062
    __ unaligned_move(addr, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2063
  } else {
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2064
    if (dst_type == T_OBJECT && x->is_wide()) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2065
      __ move_wide(addr, reg);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2066
    } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2067
      __ move(addr, reg);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2068
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2069
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2070
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2071
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2072
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2073
void LIRGenerator::do_UnsafePutRaw(UnsafePutRaw* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2074
  int  log2_scale = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2075
  BasicType type = x->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2076
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2077
  if (x->has_index()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2078
    log2_scale = x->log2_scale();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2079
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2080
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2081
  LIRItem base(x->base(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2082
  LIRItem value(x->value(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2083
  LIRItem idx(this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2084
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2085
  base.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2086
  if (x->has_index()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2087
    idx.set_instruction(x->index());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2088
    idx.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2089
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2090
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2091
  if (type == T_BYTE || type == T_BOOLEAN) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2092
    value.load_byte_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2093
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2094
    value.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2095
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2096
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2097
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2098
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2099
  LIR_Opr base_op = base.result();
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2100
  LIR_Opr index_op = idx.result();
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2101
29474
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
  2102
#ifdef GENERATE_ADDRESS_IS_PREFERRED
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
  2103
  LIR_Address* addr = generate_address(base_op, index_op, log2_scale, 0, x->basic_type());
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
  2104
#else
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2105
#ifndef _LP64
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2106
  if (base_op->type() == T_LONG) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2107
    base_op = new_register(T_INT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2108
    __ convert(Bytecodes::_l2i, base.result(), base_op);
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2109
  }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2110
  if (x->has_index()) {
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2111
    if (index_op->type() == T_LONG) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2112
      index_op = new_register(T_INT);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2113
      __ convert(Bytecodes::_l2i, idx.result(), index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2114
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2115
  }
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2116
  // At this point base and index should be all ints and not constants
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2117
  assert(base_op->type() == T_INT && !base_op->is_constant(), "base should be an non-constant int");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2118
  assert(!x->has_index() || (index_op->type() == T_INT && !index_op->is_constant()), "index should be an non-constant int");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2119
#else
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2120
  if (x->has_index()) {
27014
8c348142e099 8059621: JVM crashes with "unexpected index type" assert in LIRGenerator::do_UnsafeGetRaw
iveresov
parents: 26819
diff changeset
  2121
    if (index_op->type() == T_INT) {
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2122
      index_op = new_register(T_LONG);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2123
      __ convert(Bytecodes::_i2l, idx.result(), index_op);
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2124
    }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2125
  }
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2126
  // At this point base and index are long and non-constant
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2127
  assert(base_op->type() == T_LONG && !base_op->is_constant(), "base must be a non-constant long");
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2128
  assert(!x->has_index() || (index_op->type() == T_LONG && !index_op->is_constant()), "index must be a non-constant long");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2129
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2130
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2131
  if (log2_scale != 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2132
    // temporary fix (platform dependent code without shift on Intel would be better)
26819
9f09d23f946c 8058744: Crash in C1 OSRed method w/ Unsafe usage
iveresov
parents: 25715
diff changeset
  2133
    // TODO: ARM also allows embedded shift in the address
31637
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2134
    LIR_Opr tmp = new_pointer_register();
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2135
    if (TwoOperandLIRForm) {
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2136
      __ move(index_op, tmp);
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2137
      index_op = tmp;
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2138
    }
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2139
    __ shift_left(index_op, log2_scale, tmp);
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2140
    if (!TwoOperandLIRForm) {
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2141
      index_op = tmp;
d5811f0c68dc 8071731: Better scaling for C1
roland
parents: 31369
diff changeset
  2142
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2143
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2144
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2145
  LIR_Address* addr = new LIR_Address(base_op, index_op, x->basic_type());
29474
81a5c5330d08 8072383: resolve conflicts between open and closed ports
dlong
parents: 29325
diff changeset
  2146
#endif // !GENERATE_ADDRESS_IS_PREFERRED
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2147
  __ move(value.result(), addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2148
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2149
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2150
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2151
void LIRGenerator::do_UnsafeGetObject(UnsafeGetObject* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2152
  BasicType type = x->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2153
  LIRItem src(x->object(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2154
  LIRItem off(x->offset(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2155
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2156
  off.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2157
  src.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2158
53765
e002408eb0c0 8218879: Keep track of memory accesses originated from Unsafe
vlivanov
parents: 53028
diff changeset
  2159
  DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2160
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2161
  if (x->is_volatile()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2162
    decorators |= MO_SEQ_CST;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2163
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2164
  if (type == T_BOOLEAN) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2165
    decorators |= C1_MASK_BOOLEAN;
34160
3240e478a30e 8138894: C1: Support IRIW on weak memory platforms
mdoerr
parents: 33105
diff changeset
  2166
  }
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54200
diff changeset
  2167
  if (is_reference_type(type)) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2168
    decorators |= ON_UNKNOWN_OOP_REF;
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  2169
  }
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2170
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2171
  LIR_Opr result = rlock_result(x, type);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2172
  access_load_at(decorators, type,
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2173
                 src, off.result(), result);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2174
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2175
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2176
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2177
void LIRGenerator::do_UnsafePutObject(UnsafePutObject* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2178
  BasicType type = x->basic_type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2179
  LIRItem src(x->object(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2180
  LIRItem off(x->offset(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2181
  LIRItem data(x->value(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2182
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2183
  src.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2184
  if (type == T_BOOLEAN || type == T_BYTE) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2185
    data.load_byte_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2186
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2187
    data.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2188
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2189
  off.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2190
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2191
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2192
53765
e002408eb0c0 8218879: Keep track of memory accesses originated from Unsafe
vlivanov
parents: 53028
diff changeset
  2193
  DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS;
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54200
diff changeset
  2194
  if (is_reference_type(type)) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2195
    decorators |= ON_UNKNOWN_OOP_REF;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2196
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2197
  if (x->is_volatile()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2198
    decorators |= MO_SEQ_CST;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2199
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2200
  access_store_at(decorators, type, src, off.result(), data.result());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2201
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2202
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2203
void LIRGenerator::do_UnsafeGetAndSetObject(UnsafeGetAndSetObject* x) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2204
  BasicType type = x->basic_type();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2205
  LIRItem src(x->object(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2206
  LIRItem off(x->offset(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2207
  LIRItem value(x->value(), this);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2208
53765
e002408eb0c0 8218879: Keep track of memory accesses originated from Unsafe
vlivanov
parents: 53028
diff changeset
  2209
  DecoratorSet decorators = IN_HEAP | C1_UNSAFE_ACCESS | MO_SEQ_CST;
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2210
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54200
diff changeset
  2211
  if (is_reference_type(type)) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2212
    decorators |= ON_UNKNOWN_OOP_REF;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2213
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2214
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2215
  LIR_Opr result;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2216
  if (x->is_add()) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2217
    result = access_atomic_add_at(decorators, type, src, off, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2218
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2219
    result = access_atomic_xchg_at(decorators, type, src, off, value);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2220
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2221
  set_result(x, result);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  2222
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2223
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2224
void LIRGenerator::do_SwitchRanges(SwitchRangeArray* x, LIR_Opr value, BlockBegin* default_sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2225
  int lng = x->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2226
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2227
  for (int i = 0; i < lng; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2228
    SwitchRange* one_range = x->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2229
    int low_key = one_range->low_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2230
    int high_key = one_range->high_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2231
    BlockBegin* dest = one_range->sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2232
    if (low_key == high_key) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2233
      __ cmp(lir_cond_equal, value, low_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2234
      __ branch(lir_cond_equal, T_INT, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2235
    } else if (high_key - low_key == 1) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2236
      __ cmp(lir_cond_equal, value, low_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2237
      __ branch(lir_cond_equal, T_INT, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2238
      __ cmp(lir_cond_equal, value, high_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2239
      __ branch(lir_cond_equal, T_INT, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2240
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2241
      LabelObj* L = new LabelObj();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2242
      __ cmp(lir_cond_less, value, low_key);
11563
1edf1d19c36d 7131028: Switch statement takes wrong path
iveresov
parents: 11430
diff changeset
  2243
      __ branch(lir_cond_less, T_INT, L->label());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2244
      __ cmp(lir_cond_lessEqual, value, high_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2245
      __ branch(lir_cond_lessEqual, T_INT, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2246
      __ branch_destination(L->label());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2247
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2248
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2249
  __ jump(default_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2250
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2251
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2252
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2253
SwitchRangeArray* LIRGenerator::create_lookup_ranges(TableSwitch* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2254
  SwitchRangeList* res = new SwitchRangeList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2255
  int len = x->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2256
  if (len > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2257
    BlockBegin* sux = x->sux_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2258
    int key = x->lo_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2259
    BlockBegin* default_sux = x->default_sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2260
    SwitchRange* range = new SwitchRange(key, sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2261
    for (int i = 0; i < len; i++, key++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2262
      BlockBegin* new_sux = x->sux_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2263
      if (sux == new_sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2264
        // still in same range
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2265
        range->set_high_key(key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2266
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2267
        // skip tests which explicitly dispatch to the default
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2268
        if (sux != default_sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2269
          res->append(range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2270
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2271
        range = new SwitchRange(key, new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2272
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2273
      sux = new_sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2274
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2275
    if (res->length() == 0 || res->last() != range)  res->append(range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2276
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2277
  return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2278
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2279
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2280
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2281
// we expect the keys to be sorted by increasing value
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2282
SwitchRangeArray* LIRGenerator::create_lookup_ranges(LookupSwitch* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2283
  SwitchRangeList* res = new SwitchRangeList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2284
  int len = x->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2285
  if (len > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2286
    BlockBegin* default_sux = x->default_sux();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2287
    int key = x->key_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2288
    BlockBegin* sux = x->sux_at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2289
    SwitchRange* range = new SwitchRange(key, sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2290
    for (int i = 1; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2291
      int new_key = x->key_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2292
      BlockBegin* new_sux = x->sux_at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2293
      if (key+1 == new_key && sux == new_sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2294
        // still in same range
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2295
        range->set_high_key(new_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2296
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2297
        // skip tests which explicitly dispatch to the default
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2298
        if (range->sux() != default_sux) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2299
          res->append(range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2300
        }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2301
        range = new SwitchRange(new_key, new_sux);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2302
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2303
      key = new_key;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2304
      sux = new_sux;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2305
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2306
    if (res->length() == 0 || res->last() != range)  res->append(range);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2307
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2308
  return res;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2309
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2310
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2311
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2312
void LIRGenerator::do_TableSwitch(TableSwitch* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2313
  LIRItem tag(x->tag(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2314
  tag.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2315
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2316
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2317
  if (x->is_safepoint()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2318
    __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2319
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2320
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2321
  // move values into phi locations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2322
  move_to_phi(x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2323
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2324
  int lo_key = x->lo_key();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2325
  int len = x->length();
50207
24b5f2e635f6 8203196: C1 emits incorrect code due to integer overflow in _tableswitch keys
thartmann
parents: 50153
diff changeset
  2326
  assert(lo_key <= (lo_key + (len - 1)), "integer overflow");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2327
  LIR_Opr value = tag.result();
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2328
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2329
  if (compilation()->env()->comp_level() == CompLevel_full_profile && UseSwitchProfiling) {
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2330
    ciMethod* method = x->state()->scope()->method();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2331
    ciMethodData* md = method->method_data_or_null();
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  2332
    assert(md != NULL, "Sanity");
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2333
    ciProfileData* data = md->bci_to_data(x->state()->bci());
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  2334
    assert(data != NULL, "must have profiling data");
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2335
    assert(data->is_MultiBranchData(), "bad profile data?");
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2336
    int default_count_offset = md->byte_offset_of_slot(data, MultiBranchData::default_count_offset());
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2337
    LIR_Opr md_reg = new_register(T_METADATA);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2338
    __ metadata2reg(md->constant_encoding(), md_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2339
    LIR_Opr data_offset_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2340
    LIR_Opr tmp_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2341
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2342
    __ move(LIR_OprFact::intptrConst(default_count_offset), data_offset_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2343
    for (int i = 0; i < len; i++) {
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2344
      int count_offset = md->byte_offset_of_slot(data, MultiBranchData::case_count_offset(i));
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2345
      __ cmp(lir_cond_equal, value, i + lo_key);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2346
      __ move(data_offset_reg, tmp_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2347
      __ cmove(lir_cond_equal,
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2348
               LIR_OprFact::intptrConst(count_offset),
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2349
               tmp_reg,
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2350
               data_offset_reg, T_INT);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2351
    }
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2352
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2353
    LIR_Opr data_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2354
    LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type());
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2355
    __ move(data_addr, data_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2356
    __ add(data_reg, LIR_OprFact::intptrConst(1), data_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2357
    __ move(data_reg, data_addr);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2358
  }
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2359
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2360
  if (UseTableRanges) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2361
    do_SwitchRanges(create_lookup_ranges(x), value, x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2362
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2363
    for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2364
      __ cmp(lir_cond_equal, value, i + lo_key);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2365
      __ branch(lir_cond_equal, T_INT, x->sux_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2366
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2367
    __ jump(x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2368
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2369
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2370
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2371
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2372
void LIRGenerator::do_LookupSwitch(LookupSwitch* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2373
  LIRItem tag(x->tag(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2374
  tag.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2375
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2376
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2377
  if (x->is_safepoint()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2378
    __ safepoint(safepoint_poll_register(), state_for(x, x->state_before()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2379
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2380
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2381
  // move values into phi locations
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2382
  move_to_phi(x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2383
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2384
  LIR_Opr value = tag.result();
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2385
  int len = x->length();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2386
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2387
  if (compilation()->env()->comp_level() == CompLevel_full_profile && UseSwitchProfiling) {
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2388
    ciMethod* method = x->state()->scope()->method();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2389
    ciMethodData* md = method->method_data_or_null();
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  2390
    assert(md != NULL, "Sanity");
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2391
    ciProfileData* data = md->bci_to_data(x->state()->bci());
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  2392
    assert(data != NULL, "must have profiling data");
49877
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2393
    assert(data->is_MultiBranchData(), "bad profile data?");
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2394
    int default_count_offset = md->byte_offset_of_slot(data, MultiBranchData::default_count_offset());
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2395
    LIR_Opr md_reg = new_register(T_METADATA);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2396
    __ metadata2reg(md->constant_encoding(), md_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2397
    LIR_Opr data_offset_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2398
    LIR_Opr tmp_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2399
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2400
    __ move(LIR_OprFact::intptrConst(default_count_offset), data_offset_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2401
    for (int i = 0; i < len; i++) {
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2402
      int count_offset = md->byte_offset_of_slot(data, MultiBranchData::case_count_offset(i));
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2403
      __ cmp(lir_cond_equal, value, x->key_at(i));
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2404
      __ move(data_offset_reg, tmp_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2405
      __ cmove(lir_cond_equal,
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2406
               LIR_OprFact::intptrConst(count_offset),
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2407
               tmp_reg,
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2408
               data_offset_reg, T_INT);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2409
    }
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2410
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2411
    LIR_Opr data_reg = new_pointer_register();
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2412
    LIR_Address* data_addr = new LIR_Address(md_reg, data_offset_reg, data_reg->type());
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2413
    __ move(data_addr, data_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2414
    __ add(data_reg, LIR_OprFact::intptrConst(1), data_reg);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2415
    __ move(data_reg, data_addr);
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2416
  }
d84f06a0cae1 8200303: C2 should leverage profiling for lookupswitch/tableswitch
roland
parents: 49754
diff changeset
  2417
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2418
  if (UseTableRanges) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2419
    do_SwitchRanges(create_lookup_ranges(x), value, x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2420
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2421
    int len = x->length();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2422
    for (int i = 0; i < len; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2423
      __ cmp(lir_cond_equal, value, x->key_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2424
      __ branch(lir_cond_equal, T_INT, x->sux_at(i));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2425
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2426
    __ jump(x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2427
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2428
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2429
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2430
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2431
void LIRGenerator::do_Goto(Goto* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2432
  set_no_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2433
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2434
  if (block()->next()->as_OsrEntry()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2435
    // need to free up storage used for OSR entry point
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2436
    LIR_Opr osrBuffer = block()->next()->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2437
    BasicTypeList signature;
23486
36d781313d5a 8037140: C1: Incorrect argument type used for SharedRuntime::OSR_migration_end in LIRGenerator::do_Goto
iveresov
parents: 23189
diff changeset
  2438
    signature.append(NOT_LP64(T_INT) LP64_ONLY(T_LONG)); // pass a pointer to osrBuffer
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2439
    CallingConvention* cc = frame_map()->c_calling_convention(&signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2440
    __ move(osrBuffer, cc->args()->at(0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2441
    __ call_runtime_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::OSR_migration_end),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2442
                         getThreadTemp(), LIR_OprFact::illegalOpr, cc->args());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2443
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2444
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2445
  if (x->is_safepoint()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2446
    ValueStack* state = x->state_before() ? x->state_before() : x->state();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2447
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2448
    // increment backedge counter if needed
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2449
    CodeEmitInfo* info = state_for(x, state);
10730
38dcf027574e 7097679: Tiered: events with bad bci to Gotos reduced from Ifs
iveresov
parents: 10569
diff changeset
  2450
    increment_backedge_counter(info, x->profiled_bci());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2451
    CodeEmitInfo* safepoint_info = state_for(x, state);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2452
    __ safepoint(safepoint_poll_register(), safepoint_info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2453
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2454
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2455
  // Gotos can be folded Ifs, handle this case.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2456
  if (x->should_profile()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2457
    ciMethod* method = x->profiled_method();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2458
    assert(method != NULL, "method should be set if branch is profiled");
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2459
    ciMethodData* md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  2460
    assert(md != NULL, "Sanity");
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2461
    ciProfileData* data = md->bci_to_data(x->profiled_bci());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2462
    assert(data != NULL, "must have profiling data");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2463
    int offset;
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2464
    if (x->direction() == Goto::taken) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2465
      assert(data->is_BranchData(), "need BranchData for two-way branches");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2466
      offset = md->byte_offset_of_slot(data, BranchData::taken_offset());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2467
    } else if (x->direction() == Goto::not_taken) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2468
      assert(data->is_BranchData(), "need BranchData for two-way branches");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2469
      offset = md->byte_offset_of_slot(data, BranchData::not_taken_offset());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2470
    } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2471
      assert(data->is_JumpData(), "need JumpData for branches");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2472
      offset = md->byte_offset_of_slot(data, JumpData::taken_offset());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2473
    }
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  2474
    LIR_Opr md_reg = new_register(T_METADATA);
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  2475
    __ metadata2reg(md->constant_encoding(), md_reg);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2476
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2477
    increment_counter(new LIR_Address(md_reg, offset,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2478
                                      NOT_LP64(T_INT) LP64_ONLY(T_LONG)), DataLayout::counter_increment);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2479
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2480
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2481
  // emit phi-instruction move after safepoint since this simplifies
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2482
  // describing the state as the safepoint.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2483
  move_to_phi(x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2484
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2485
  __ jump(x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2486
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2487
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2488
/**
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2489
 * Emit profiling code if needed for arguments, parameters, return value types
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2490
 *
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2491
 * @param md                    MDO the code will update at runtime
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2492
 * @param md_base_offset        common offset in the MDO for this profile and subsequent ones
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2493
 * @param md_offset             offset in the MDO (on top of md_base_offset) for this profile
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2494
 * @param profiled_k            current profile
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2495
 * @param obj                   IR node for the object to be profiled
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2496
 * @param mdp                   register to hold the pointer inside the MDO (md + md_base_offset).
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2497
 *                              Set once we find an update to make and use for next ones.
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2498
 * @param not_null              true if we know obj cannot be null
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2499
 * @param signature_at_call_k   signature at call for obj
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2500
 * @param callee_signature_k    signature of callee for obj
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2501
 *                              at call and callee signatures differ at method handle call
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2502
 * @return                      the only klass we know will ever be seen at this profile point
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2503
 */
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2504
ciKlass* LIRGenerator::profile_type(ciMethodData* md, int md_base_offset, int md_offset, intptr_t profiled_k,
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2505
                                    Value obj, LIR_Opr& mdp, bool not_null, ciKlass* signature_at_call_k,
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2506
                                    ciKlass* callee_signature_k) {
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2507
  ciKlass* result = NULL;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2508
  bool do_null = !not_null && !TypeEntries::was_null_seen(profiled_k);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2509
  bool do_update = !TypeEntries::is_type_unknown(profiled_k);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2510
  // known not to be null or null bit already set and already set to
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2511
  // unknown: nothing we can do to improve profiling
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2512
  if (!do_null && !do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2513
    return result;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2514
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2515
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2516
  ciKlass* exact_klass = NULL;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2517
  Compilation* comp = Compilation::current();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2518
  if (do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2519
    // try to find exact type, using CHA if possible, so that loading
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2520
    // the klass from the object can be avoided
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2521
    ciType* type = obj->exact_type();
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2522
    if (type == NULL) {
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2523
      type = obj->declared_type();
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2524
      type = comp->cha_exact_type(type);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2525
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2526
    assert(type == NULL || type->is_klass(), "type should be class");
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2527
    exact_klass = (type != NULL && type->is_loaded()) ? (ciKlass*)type : NULL;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2528
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2529
    do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2530
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2531
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2532
  if (!do_null && !do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2533
    return result;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2534
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2535
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2536
  ciKlass* exact_signature_k = NULL;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2537
  if (do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2538
    // Is the type from the signature exact (the only one possible)?
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2539
    exact_signature_k = signature_at_call_k->exact_klass();
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2540
    if (exact_signature_k == NULL) {
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2541
      exact_signature_k = comp->cha_exact_type(signature_at_call_k);
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2542
    } else {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2543
      result = exact_signature_k;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2544
      // Known statically. No need to emit any code: prevent
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2545
      // LIR_Assembler::emit_profile_type() from emitting useless code
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2546
      profiled_k = ciTypeEntries::with_status(result, profiled_k);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2547
    }
24313
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 24088
diff changeset
  2548
    // exact_klass and exact_signature_k can be both non NULL but
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 24088
diff changeset
  2549
    // different if exact_klass is loaded after the ciObject for
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 24088
diff changeset
  2550
    // exact_signature_k is created.
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 24088
diff changeset
  2551
    if (exact_klass == NULL && exact_signature_k != NULL && exact_klass != exact_signature_k) {
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2552
      // sometimes the type of the signature is better than the best type
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2553
      // the compiler has
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2554
      exact_klass = exact_signature_k;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2555
    }
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2556
    if (callee_signature_k != NULL &&
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2557
        callee_signature_k != signature_at_call_k) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2558
      ciKlass* improved_klass = callee_signature_k->exact_klass();
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2559
      if (improved_klass == NULL) {
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2560
        improved_klass = comp->cha_exact_type(callee_signature_k);
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2561
      }
24313
2e10cd8a870f 8041481: JVM crashes with collect_args_for_profiling
roland
parents: 24088
diff changeset
  2562
      if (exact_klass == NULL && improved_klass != NULL && exact_klass != improved_klass) {
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2563
        exact_klass = exact_signature_k;
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2564
      }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2565
    }
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2566
    do_update = exact_klass == NULL || ciTypeEntries::valid_ciklass(profiled_k) != exact_klass;
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2567
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2568
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2569
  if (!do_null && !do_update) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2570
    return result;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2571
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2572
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2573
  if (mdp == LIR_OprFact::illegalOpr) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2574
    mdp = new_register(T_METADATA);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2575
    __ metadata2reg(md->constant_encoding(), mdp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2576
    if (md_base_offset != 0) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2577
      LIR_Address* base_type_address = new LIR_Address(mdp, md_base_offset, T_ADDRESS);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2578
      mdp = new_pointer_register();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2579
      __ leal(LIR_OprFact::address(base_type_address), mdp);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2580
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2581
  }
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2582
  LIRItem value(obj, this);
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2583
  value.load_item();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2584
  __ profile_type(new LIR_Address(mdp, md_offset, T_METADATA),
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2585
                  value.result(), exact_klass, profiled_k, new_pointer_register(), not_null, exact_signature_k != NULL);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2586
  return result;
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2587
}
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  2588
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2589
// profile parameters on entry to the root of the compilation
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2590
void LIRGenerator::profile_parameters(Base* x) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2591
  if (compilation()->profile_parameters()) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2592
    CallingConvention* args = compilation()->frame_map()->incoming_arguments();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2593
    ciMethodData* md = scope()->method()->method_data_or_null();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2594
    assert(md != NULL, "Sanity");
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2595
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2596
    if (md->parameters_type_data() != NULL) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2597
      ciParametersTypeData* parameters_type_data = md->parameters_type_data();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2598
      ciTypeStackSlotEntries* parameters =  parameters_type_data->parameters();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2599
      LIR_Opr mdp = LIR_OprFact::illegalOpr;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2600
      for (int java_index = 0, i = 0, j = 0; j < parameters_type_data->number_of_parameters(); i++) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2601
        LIR_Opr src = args->at(i);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2602
        assert(!src->is_illegal(), "check");
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2603
        BasicType t = src->type();
58273
08a5148e7c4e 8230505: Replace JVM type comparisons to T_OBJECT and T_ARRAY with call to is_reference_type
lfoltan
parents: 54200
diff changeset
  2604
        if (is_reference_type(t)) {
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2605
          intptr_t profiled_k = parameters->type(j);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2606
          Local* local = x->state()->local_at(java_index)->as_Local();
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2607
          ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2608
                                        in_bytes(ParametersTypeData::type_offset(j)) - in_bytes(ParametersTypeData::type_offset(0)),
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  2609
                                        profiled_k, local, mdp, false, local->declared_type()->as_klass(), NULL);
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2610
          // If the profile is known statically set it once for all and do not emit any code
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2611
          if (exact != NULL) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2612
            md->set_parameter_type(j, exact);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2613
          }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2614
          j++;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2615
        }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2616
        java_index += type2size[t];
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2617
      }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2618
    }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2619
  }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2620
}
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2621
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2622
void LIRGenerator::do_Base(Base* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2623
  __ std_entry(LIR_OprFact::illegalOpr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2624
  // Emit moves from physical registers / stack slots to virtual registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2625
  CallingConvention* args = compilation()->frame_map()->incoming_arguments();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2626
  IRScope* irScope = compilation()->hir()->top_scope();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2627
  int java_index = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2628
  for (int i = 0; i < args->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2629
    LIR_Opr src = args->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2630
    assert(!src->is_illegal(), "check");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2631
    BasicType t = src->type();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2632
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2633
    // Types which are smaller than int are passed as int, so
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2634
    // correct the type which passed.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2635
    switch (t) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2636
    case T_BYTE:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2637
    case T_BOOLEAN:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2638
    case T_SHORT:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2639
    case T_CHAR:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2640
      t = T_INT;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2641
      break;
46630
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 45514
diff changeset
  2642
    default:
75aa3e39d02c 8182299: Enable disabled clang warnings, build on OSX 10 + Xcode 8
jwilhelm
parents: 45514
diff changeset
  2643
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2644
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2645
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2646
    LIR_Opr dest = new_register(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2647
    __ move(src, dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2648
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2649
    // Assign new location to Local instruction for this local
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2650
    Local* local = x->state()->local_at(java_index)->as_Local();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2651
    assert(local != NULL, "Locals for incoming arguments must have been created");
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
  2652
#ifndef __SOFTFP__
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
  2653
    // The java calling convention passes double as long and float as int.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2654
    assert(as_ValueType(t)->tag() == local->type()->tag(), "check");
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5707
diff changeset
  2655
#endif // __SOFTFP__
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2656
    local->set_operand(dest);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2657
    _instruction_for_operand.at_put_grow(dest->vreg_number(), local, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2658
    java_index += type2size[t];
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2659
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2660
2867
69187054225f 6788527: Server vm intermittently fails with assertion "live value must not be garbage" with fastdebug bits
kvn
parents: 2105
diff changeset
  2661
  if (compilation()->env()->dtrace_method_probes()) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2662
    BasicTypeList signature;
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2663
    signature.append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21095
diff changeset
  2664
    signature.append(T_METADATA); // Method*
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2665
    LIR_OprList* args = new LIR_OprList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2666
    args->append(getThreadPointer());
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  2667
    LIR_Opr meth = new_register(T_METADATA);
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  2668
    __ metadata2reg(method()->constant_encoding(), meth);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2669
    args->append(meth);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2670
    call_runtime(&signature, args, CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_entry), voidType, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2671
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2672
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2673
  if (method()->is_synchronized()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2674
    LIR_Opr obj;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2675
    if (method()->is_static()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2676
      obj = new_register(T_OBJECT);
3908
24b55ad4c228 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 3172
diff changeset
  2677
      __ oop2reg(method()->holder()->java_mirror()->constant_encoding(), obj);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2678
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2679
      Local* receiver = x->state()->local_at(0)->as_Local();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2680
      assert(receiver != NULL, "must already exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2681
      obj = receiver->operand();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2682
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2683
    assert(obj->is_valid(), "must be valid");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2684
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2685
    if (method()->is_synchronized() && GenerateSynchronizationCode) {
34201
2de6f3566659 8138895: C1: PPC64 Port needs special register for Locks in synchronization code
mdoerr
parents: 34200
diff changeset
  2686
      LIR_Opr lock = syncLockOpr();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2687
      __ load_stack_address_monitor(0, lock);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2688
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  2689
      CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, x->check_flag(Instruction::DeoptimizeOnException));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2690
      CodeStub* slow_path = new MonitorEnterStub(obj, lock, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2691
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2692
      // receiver is guaranteed non-NULL so don't need CodeEmitInfo
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2693
      __ lock_object(syncTempOpr(), obj, lock, new_register(T_OBJECT), slow_path, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2694
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2695
  }
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  2696
  if (compilation()->age_code()) {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  2697
    CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, 0), NULL, false);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  2698
    decrement_age(info);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  2699
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2700
  // increment invocation counters if needed
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2701
  if (!method()->is_accessor()) { // Accessors do not have MDOs, so no counting.
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  2702
    profile_parameters(x);
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  2703
    CodeEmitInfo* info = new CodeEmitInfo(scope()->start()->state()->copy(ValueStack::StateBefore, SynchronizationEntryBCI), NULL, false);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2704
    increment_invocation_counter(info);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  2705
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2706
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2707
  // all blocks with a successor must end with an unconditional jump
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2708
  // to the successor even if they are consecutive
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2709
  __ jump(x->default_sux());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2710
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2711
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2712
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2713
void LIRGenerator::do_OsrEntry(OsrEntry* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2714
  // construct our frame and model the production of incoming pointer
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2715
  // to the OSR buffer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2716
  __ osr_entry(LIR_Assembler::osrBufferPointer());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2717
  LIR_Opr result = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2718
  __ move(LIR_Assembler::osrBufferPointer(), result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2719
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2720
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2721
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2722
void LIRGenerator::invoke_load_arguments(Invoke* x, LIRItemList* args, const LIR_OprList* arg_list) {
13487
75aa4880b15f 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 13486
diff changeset
  2723
  assert(args->length() == arg_list->length(),
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 33096
diff changeset
  2724
         "args=%d, arg_list=%d", args->length(), arg_list->length());
13487
75aa4880b15f 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 13486
diff changeset
  2725
  for (int i = x->has_receiver() ? 1 : 0; i < args->length(); i++) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2726
    LIRItem* param = args->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2727
    LIR_Opr loc = arg_list->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2728
    if (loc->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2729
      param->load_item_force(loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2730
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2731
      LIR_Address* addr = loc->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2732
      param->load_for_store(addr->type());
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2733
      if (addr->type() == T_OBJECT) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2734
        __ move_wide(param->result(), addr);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2735
      } else
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2736
        if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2737
          __ unaligned_move(param->result(), addr);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2738
        } else {
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2739
          __ move(param->result(), addr);
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2740
        }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2741
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2742
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2743
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2744
  if (x->has_receiver()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2745
    LIRItem* receiver = args->at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2746
    LIR_Opr loc = arg_list->at(0);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2747
    if (loc->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2748
      receiver->load_item_force(loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2749
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2750
      assert(loc->is_address(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2751
      receiver->load_for_store(T_OBJECT);
7427
d7b79a367474 6985015: C1 needs to support compressed oops
iveresov
parents: 7397
diff changeset
  2752
      __ move_wide(receiver->result(), loc->as_address_ptr());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2753
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2754
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2755
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2756
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2757
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2758
// Visits all arguments, returns appropriate items without loading them
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2759
LIRItemList* LIRGenerator::invoke_visit_arguments(Invoke* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2760
  LIRItemList* argument_items = new LIRItemList();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2761
  if (x->has_receiver()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2762
    LIRItem* receiver = new LIRItem(x->receiver(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2763
    argument_items->append(receiver);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2764
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2765
  for (int i = 0; i < x->number_of_arguments(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2766
    LIRItem* param = new LIRItem(x->argument_at(i), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2767
    argument_items->append(param);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2768
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2769
  return argument_items;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2770
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2771
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2772
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2773
// The invoke with receiver has following phases:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2774
//   a) traverse and load/lock receiver;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2775
//   b) traverse all arguments -> item-array (invoke_visit_argument)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2776
//   c) push receiver on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2777
//   d) load each of the items and push on stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2778
//   e) unlock receiver
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2779
//   f) move receiver into receiver-register %o0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2780
//   g) lock result registers and emit call operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2781
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2782
// Before issuing a call, we must spill-save all values on stack
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2783
// that are in caller-save register. "spill-save" moves those registers
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2784
// either in a free callee-save register or spills them if no free
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2785
// callee save register is available.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2786
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2787
// The problem is where to invoke spill-save.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2788
// - if invoked between e) and f), we may lock callee save
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2789
//   register in "spill-save" that destroys the receiver register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2790
//   before f) is executed
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2791
// - if we rearrange f) to be earlier (by loading %o0) it
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2792
//   may destroy a value on the stack that is currently in %o0
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2793
//   and is waiting to be spilled
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2794
// - if we keep the receiver locked while doing spill-save,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2795
//   we cannot spill it as it is spill-locked
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2796
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2797
void LIRGenerator::do_Invoke(Invoke* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2798
  CallingConvention* cc = frame_map()->java_calling_convention(x->signature(), true);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2799
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2800
  LIR_OprList* arg_list = cc->args();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2801
  LIRItemList* args = invoke_visit_arguments(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2802
  LIR_Opr receiver = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2803
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2804
  // setup result register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2805
  LIR_Opr result_register = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2806
  if (x->type() != voidType) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2807
    result_register = result_register_for(x->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2808
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2809
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2810
  CodeEmitInfo* info = state_for(x, x->state());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2811
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2812
  invoke_load_arguments(x, args, arg_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2813
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2814
  if (x->has_receiver()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2815
    args->at(0)->load_item_force(LIR_Assembler::receiverOpr());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2816
    receiver = args->at(0)->result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2817
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2818
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2819
  // emit invoke code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2820
  assert(receiver->is_illegal() || receiver->is_equal(LIR_Assembler::receiverOpr()), "must match");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2821
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2822
  // JSR 292
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2823
  // Preserve the SP over MethodHandle call sites, if needed.
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2824
  ciMethod* target = x->target();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  2825
  bool is_method_handle_invoke = (// %%% FIXME: Are both of these relevant?
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  2826
                                  target->is_method_handle_intrinsic() ||
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  2827
                                  target->is_compiled_lambda_form());
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  2828
  if (is_method_handle_invoke) {
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2829
    info->set_is_method_handle_invoke(true);
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2830
    if(FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr) {
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2831
        __ move(FrameMap::stack_pointer(), FrameMap::method_handle_invoke_SP_save_opr());
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2832
    }
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2833
  }
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2834
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2835
  switch (x->code()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2836
    case Bytecodes::_invokestatic:
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2837
      __ call_static(target, result_register,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2838
                     SharedRuntime::get_resolve_static_call_stub(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2839
                     arg_list, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2840
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2841
    case Bytecodes::_invokespecial:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2842
    case Bytecodes::_invokevirtual:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2843
    case Bytecodes::_invokeinterface:
42544
58de8aaf9365 8160543: C1: Crash in java.lang.String.indexOf in some java.sql tests
neliasso
parents: 42063
diff changeset
  2844
      // for loaded and final (method or class) target we still produce an inline cache,
58de8aaf9365 8160543: C1: Crash in java.lang.String.indexOf in some java.sql tests
neliasso
parents: 42063
diff changeset
  2845
      // in order to be able to call mixed mode
58de8aaf9365 8160543: C1: Crash in java.lang.String.indexOf in some java.sql tests
neliasso
parents: 42063
diff changeset
  2846
      if (x->code() == Bytecodes::_invokespecial || x->target_is_final()) {
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2847
        __ call_opt_virtual(target, receiver, result_register,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2848
                            SharedRuntime::get_resolve_opt_virtual_call_stub(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2849
                            arg_list, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2850
      } else if (x->vtable_index() < 0) {
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2851
        __ call_icvirtual(target, receiver, result_register,
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2852
                          SharedRuntime::get_resolve_virtual_call_stub(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2853
                          arg_list, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2854
      } else {
35899
0dbc821628fc 8148047: Move the vtable length field to Klass
mgerdin
parents: 35871
diff changeset
  2855
        int entry_offset = in_bytes(Klass::vtable_start_offset()) + x->vtable_index() * vtableEntry::size_in_bytes();
35871
607bf949dfb3 8147461: Use byte offsets for vtable start and vtable length offsets
mgerdin
parents: 35109
diff changeset
  2856
        int vtable_offset = entry_offset + vtableEntry::method_offset_in_bytes();
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2857
        __ call_virtual(target, receiver, result_register, vtable_offset, arg_list, info);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2858
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2859
      break;
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4761
diff changeset
  2860
    case Bytecodes::_invokedynamic: {
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2861
      __ call_dynamic(target, receiver, result_register,
13487
75aa4880b15f 7192167: JSR 292: C1 has old broken code which needs to be removed
twisti
parents: 13486
diff changeset
  2862
                      SharedRuntime::get_resolve_static_call_stub(),
5046
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4761
diff changeset
  2863
                      arg_list, info);
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4761
diff changeset
  2864
      break;
27e801a857cb 6919934: JSR 292 needs to support x86 C1
twisti
parents: 4761
diff changeset
  2865
    }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2866
    default:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 33096
diff changeset
  2867
      fatal("unexpected bytecode: %s", Bytecodes::name(x->code()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2868
      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2869
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2870
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2871
  // JSR 292
30305
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2872
  // Restore the SP after MethodHandle call sites, if needed.
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2873
  if (is_method_handle_invoke
b92a97e1e9cb 8068945: Use RBP register as proper frame pointer in JIT compiled code on x86
zmajo
parents: 30302
diff changeset
  2874
      && FrameMap::method_handle_invoke_SP_save_opr() != LIR_OprFact::illegalOpr) {
5687
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2875
    __ move(FrameMap::method_handle_invoke_SP_save_opr(), FrameMap::stack_pointer());
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2876
  }
b862d1f189bd 6930772: JSR 292 needs to support SPARC C1
twisti
parents: 5334
diff changeset
  2877
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2878
  if (x->type()->is_float() || x->type()->is_double()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2879
    // Force rounding of results from non-strictfp when in strictfp
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2880
    // scope (or when we don't know the strictness of the callee, to
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2881
    // be safe.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2882
    if (method()->is_strict()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2883
      if (!x->target_is_loaded() || !x->target_is_strictfp()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2884
        result_register = round_item(result_register);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2885
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2886
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2887
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2888
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2889
  if (result_register->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2890
    LIR_Opr result = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2891
    __ move(result_register, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2892
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2893
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2894
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2895
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2896
void LIRGenerator::do_FPIntrinsics(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2897
  assert(x->number_of_arguments() == 1, "wrong type");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2898
  LIRItem value       (x->argument_at(0), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2899
  LIR_Opr reg = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2900
  value.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2901
  LIR_Opr tmp = force_to_spill(value.result(), as_BasicType(x->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2902
  __ move(tmp, reg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2903
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2904
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2905
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2906
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2907
// Code for  :  x->x() {x->cond()} x->y() ? x->tval() : x->fval()
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2908
void LIRGenerator::do_IfOp(IfOp* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2909
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2910
  {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2911
    ValueTag xtag = x->x()->type()->tag();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2912
    ValueTag ttag = x->tval()->type()->tag();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2913
    assert(xtag == intTag || xtag == objectTag, "cannot handle others");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2914
    assert(ttag == addressTag || ttag == intTag || ttag == objectTag || ttag == longTag, "cannot handle others");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2915
    assert(ttag == x->fval()->type()->tag(), "cannot handle others");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2916
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2917
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2918
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2919
  LIRItem left(x->x(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2920
  LIRItem right(x->y(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2921
  left.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2922
  if (can_inline_as_constant(right.value())) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2923
    right.dont_load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2924
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2925
    right.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2926
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2927
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2928
  LIRItem t_val(x->tval(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2929
  LIRItem f_val(x->fval(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2930
  t_val.dont_load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2931
  f_val.dont_load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2932
  LIR_Opr reg = rlock_result(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2933
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2934
  __ cmp(lir_cond(x->cond()), left.result(), right.result());
7713
1e06d2419258 7009231: C1: Incorrect CAS code for longs on SPARC 32bit
iveresov
parents: 7432
diff changeset
  2935
  __ cmove(lir_cond(x->cond()), t_val.result(), f_val.result(), reg, as_BasicType(x->x()->type()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2936
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  2937
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2938
#ifdef JFR_HAVE_INTRINSICS
40899
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2939
void LIRGenerator::do_ClassIDIntrinsic(Intrinsic* x) {
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2940
  CodeEmitInfo* info = state_for(x);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2941
  CodeEmitInfo* info2 = new CodeEmitInfo(info); // Clone for the second null check
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2942
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2943
  assert(info != NULL, "must have info");
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2944
  LIRItem arg(x->argument_at(0), this);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2945
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2946
  arg.load_item();
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2947
  LIR_Opr klass = new_register(T_METADATA);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2948
  __ move(new LIR_Address(arg.result(), java_lang_Class::klass_offset_in_bytes(), T_ADDRESS), klass, info);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2949
  LIR_Opr id = new_register(T_LONG);
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2950
  ByteSize offset = KLASS_TRACE_ID_OFFSET;
40899
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2951
  LIR_Address* trace_id_addr = new LIR_Address(klass, in_bytes(offset), T_LONG);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2952
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2953
  __ move(trace_id_addr, id);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2954
  __ logical_or(id, LIR_OprFact::longConst(0x01l), id);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2955
  __ store(id, trace_id_addr);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2956
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2957
#ifdef TRACE_ID_META_BITS
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2958
  __ logical_and(id, LIR_OprFact::longConst(~TRACE_ID_META_BITS), id);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2959
#endif
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2960
#ifdef TRACE_ID_SHIFT
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2961
  __ unsigned_shift_right(id, TRACE_ID_SHIFT, id);
40899
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2962
#endif
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2963
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2964
  __ move(id, rlock_result(x));
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2965
}
42037
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2966
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2967
void LIRGenerator::do_getEventWriter(Intrinsic* x) {
42037
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2968
  LabelObj* L_end = new LabelObj();
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2969
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2970
  LIR_Address* jobj_addr = new LIR_Address(getThreadPointer(),
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  2971
                                           in_bytes(THREAD_LOCAL_WRITER_OFFSET_JFR),
42037
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2972
                                           T_OBJECT);
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2973
  LIR_Opr result = rlock_result(x);
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2974
  __ move_wide(jobj_addr, result);
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2975
  __ cmp(lir_cond_equal, result, LIR_OprFact::oopConst(NULL));
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2976
  __ branch(lir_cond_equal, T_OBJECT, L_end->label());
51643
8267d480566f 8210158: Accessorize JFR getEventWriter() intrinsics
eosterlund
parents: 51487
diff changeset
  2977
8267d480566f 8210158: Accessorize JFR getEventWriter() intrinsics
eosterlund
parents: 51487
diff changeset
  2978
  LIR_Opr jobj = new_register(T_OBJECT);
8267d480566f 8210158: Accessorize JFR getEventWriter() intrinsics
eosterlund
parents: 51487
diff changeset
  2979
  __ move(result, jobj);
8267d480566f 8210158: Accessorize JFR getEventWriter() intrinsics
eosterlund
parents: 51487
diff changeset
  2980
  access_load(IN_NATIVE, T_OBJECT, LIR_OprFact::address(new LIR_Address(jobj, T_OBJECT)), result);
42037
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2981
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2982
  __ branch_destination(L_end->label());
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2983
}
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  2984
40899
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2985
#endif
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2986
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  2987
35109
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2988
void LIRGenerator::do_RuntimeCall(address routine, Intrinsic* x) {
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2989
  assert(x->number_of_arguments() == 0, "wrong type");
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2990
  // Enforce computation of _reserved_argument_area_size which is required on some platforms.
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2991
  BasicTypeList signature;
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2992
  CallingConvention* cc = frame_map()->c_calling_convention(&signature);
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2993
  LIR_Opr reg = result_register_for(x->type());
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2994
  __ call_runtime_leaf(routine, getThreadTemp(),
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2995
                       reg, new LIR_OprList());
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2996
  LIR_Opr result = rlock_result(x);
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  2997
  __ move(reg, result);
12377
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  2998
}
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  2999
36384
b0b41336a9a8 8143226: Minor updates to Event Based tracing
mgronlun
parents: 35899
diff changeset
  3000
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3001
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3002
void LIRGenerator::do_Intrinsic(Intrinsic* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3003
  switch (x->id()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3004
  case vmIntrinsics::_intBitsToFloat      :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3005
  case vmIntrinsics::_doubleToRawLongBits :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3006
  case vmIntrinsics::_longBitsToDouble    :
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3007
  case vmIntrinsics::_floatToRawIntBits   : {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3008
    do_FPIntrinsics(x);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3009
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3010
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3011
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  3012
#ifdef JFR_HAVE_INTRINSICS
40899
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  3013
  case vmIntrinsics::_getClassId:
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  3014
    do_ClassIDIntrinsic(x);
d7140c75c2c6 8163589: Add back class id intrinsic method for event based tracing
rehn
parents: 40030
diff changeset
  3015
    break;
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  3016
  case vmIntrinsics::_getEventWriter:
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  3017
    do_getEventWriter(x);
42037
6269c5b5b651 8166806: Add intrinsic support for writer used in event based tracing
mgronlun
parents: 41330
diff changeset
  3018
    break;
12377
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3019
  case vmIntrinsics::_counterTime:
50113
caf115bb98ad 8199712: Flight Recorder
egahlin
parents: 50094
diff changeset
  3020
    do_RuntimeCall(CAST_FROM_FN_PTR(address, JFR_TIME_FUNCTION), x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3021
    break;
12377
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3022
#endif
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3023
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3024
  case vmIntrinsics::_currentTimeMillis:
35109
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  3025
    do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeMillis), x);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3026
    break;
12377
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3027
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3028
  case vmIntrinsics::_nanoTime:
35109
92535200db7d 8143817: C1: Platform dependent stack space not preserved for all runtime calls
mdoerr
parents: 34211
diff changeset
  3029
    do_RuntimeCall(CAST_FROM_FN_PTR(address, os::javaTimeNanos), x);
12377
ae6def2813e0 7160570: Intrinsification support for tracing framework
rbackman
parents: 11886
diff changeset
  3030
    break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3031
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3032
  case vmIntrinsics::_Object_init:    do_RegisterFinalizer(x); break;
12949
e125ba4c16bd 7171890: C1: add Class.isInstance intrinsic
roland
parents: 12739
diff changeset
  3033
  case vmIntrinsics::_isInstance:     do_isInstance(x);    break;
36552
0db9be43cebb 8150669: C1 intrinsic for Class.isPrimitive
shade
parents: 35899
diff changeset
  3034
  case vmIntrinsics::_isPrimitive:    do_isPrimitive(x);   break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3035
  case vmIntrinsics::_getClass:       do_getClass(x);      break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3036
  case vmIntrinsics::_currentThread:  do_currentThread(x); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3038
  case vmIntrinsics::_dlog:           // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3039
  case vmIntrinsics::_dlog10:         // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3040
  case vmIntrinsics::_dabs:           // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3041
  case vmIntrinsics::_dsqrt:          // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3042
  case vmIntrinsics::_dtan:           // fall through
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3043
  case vmIntrinsics::_dsin :          // fall through
12739
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 12377
diff changeset
  3044
  case vmIntrinsics::_dcos :          // fall through
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 12377
diff changeset
  3045
  case vmIntrinsics::_dexp :          // fall through
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 12377
diff changeset
  3046
  case vmIntrinsics::_dpow :          do_MathIntrinsic(x); break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3047
  case vmIntrinsics::_arraycopy:      do_ArrayCopy(x);     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3048
41323
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 41319
diff changeset
  3049
  case vmIntrinsics::_fmaD:           do_FmaIntrinsic(x); break;
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 41319
diff changeset
  3050
  case vmIntrinsics::_fmaF:           do_FmaIntrinsic(x); break;
ddd5600d4762 8154122: Intrinsify fused mac operations
vdeshpande
parents: 41319
diff changeset
  3051
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3052
  // java.nio.Buffer.checkIndex
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3053
  case vmIntrinsics::_checkIndex:     do_NIOCheckIndex(x); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3054
52220
9c260a6b6471 8207146: Rename jdk.internal.misc.Unsafe::xxxObject to xxxReference
mchung
parents: 51996
diff changeset
  3055
  case vmIntrinsics::_compareAndSetReference:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3056
    do_CompareAndSwap(x, objectType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3057
    break;
45514
0fc9cc73ce45 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents: 44315
diff changeset
  3058
  case vmIntrinsics::_compareAndSetInt:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3059
    do_CompareAndSwap(x, intType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3060
    break;
45514
0fc9cc73ce45 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
psandoz
parents: 44315
diff changeset
  3061
  case vmIntrinsics::_compareAndSetLong:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3062
    do_CompareAndSwap(x, longType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3063
    break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3064
14832
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3065
  case vmIntrinsics::_loadFence :
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3066
    __ membar_acquire();
14832
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3067
    break;
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3068
  case vmIntrinsics::_storeFence:
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3069
    __ membar_release();
14832
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3070
    break;
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3071
  case vmIntrinsics::_fullFence :
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3072
    __ membar();
14832
61b025224ac9 8004318: JEP-171: Support Unsafe fences intrinsics
kvn
parents: 13969
diff changeset
  3073
    break;
38017
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 37291
diff changeset
  3074
  case vmIntrinsics::_onSpinWait:
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 37291
diff changeset
  3075
    __ on_spin_wait();
55047d16f141 8147844: new method j.l.Runtime.onSpinWait() and the corresponding x86 hotspot instrinsic
ikrylov
parents: 37291
diff changeset
  3076
    break;
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  3077
  case vmIntrinsics::_Reference_get:
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  3078
    do_Reference_get(x);
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  3079
    break;
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 8676
diff changeset
  3080
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3081
  case vmIntrinsics::_updateCRC32:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3082
  case vmIntrinsics::_updateBytesCRC32:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3083
  case vmIntrinsics::_updateByteBufferCRC32:
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3084
    do_update_CRC32(x);
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3085
    break;
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 17879
diff changeset
  3086
38237
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38031
diff changeset
  3087
  case vmIntrinsics::_updateBytesCRC32C:
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38031
diff changeset
  3088
  case vmIntrinsics::_updateDirectByteBufferCRC32C:
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38031
diff changeset
  3089
    do_update_CRC32C(x);
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38031
diff changeset
  3090
    break;
d972e3a2df53 8155162: java.util.zip.CRC32C Interpreter/C1 intrinsics support on SPARC
kvn
parents: 38031
diff changeset
  3091
38238
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38237
diff changeset
  3092
  case vmIntrinsics::_vectorizedMismatch:
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38237
diff changeset
  3093
    do_vectorizedMismatch(x);
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38237
diff changeset
  3094
    break;
1bbcc430c78d 8151268: Wire up the x86 _vectorizedMismatch stub routine in C1
psandoz
parents: 38237
diff changeset
  3095
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3096
  default: ShouldNotReachHere(); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3097
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3098
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3099
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3100
void LIRGenerator::profile_arguments(ProfileCall* x) {
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3101
  if (compilation()->profile_arguments()) {
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3102
    int bci = x->bci_of_invoke();
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3103
    ciMethodData* md = x->method()->method_data_or_null();
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  3104
    assert(md != NULL, "Sanity");
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3105
    ciProfileData* data = md->bci_to_data(bci);
44315
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3106
    if (data != NULL) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3107
      if ((data->is_CallTypeData() && data->as_CallTypeData()->has_arguments()) ||
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3108
          (data->is_VirtualCallTypeData() && data->as_VirtualCallTypeData()->has_arguments())) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3109
        ByteSize extra = data->is_CallTypeData() ? CallTypeData::args_data_offset() : VirtualCallTypeData::args_data_offset();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3110
        int base_offset = md->byte_offset_of_slot(data, extra);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3111
        LIR_Opr mdp = LIR_OprFact::illegalOpr;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3112
        ciTypeStackSlotEntries* args = data->is_CallTypeData() ? ((ciCallTypeData*)data)->args() : ((ciVirtualCallTypeData*)data)->args();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3113
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3114
        Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3115
        int start = 0;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3116
        int stop = data->is_CallTypeData() ? ((ciCallTypeData*)data)->number_of_arguments() : ((ciVirtualCallTypeData*)data)->number_of_arguments();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3117
        if (x->callee()->is_loaded() && x->callee()->is_static() && Bytecodes::has_receiver(bc)) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3118
          // first argument is not profiled at call (method handle invoke)
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3119
          assert(x->method()->raw_code_at_bci(bci) == Bytecodes::_invokehandle, "invokehandle expected");
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3120
          start = 1;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3121
        }
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3122
        ciSignature* callee_signature = x->callee()->signature();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3123
        // method handle call to virtual method
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3124
        bool has_receiver = x->callee()->is_loaded() && !x->callee()->is_static() && !Bytecodes::has_receiver(bc);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3125
        ciSignatureStream callee_signature_stream(callee_signature, has_receiver ? x->callee()->holder() : NULL);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3126
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3127
        bool ignored_will_link;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3128
        ciSignature* signature_at_call = NULL;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3129
        x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3130
        ciSignatureStream signature_at_call_stream(signature_at_call);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3131
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3132
        // if called through method handle invoke, some arguments may have been popped
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3133
        for (int i = 0; i < stop && i+start < x->nb_profiled_args(); i++) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3134
          int off = in_bytes(TypeEntriesAtCall::argument_type_offset(i)) - in_bytes(TypeEntriesAtCall::args_data_offset());
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3135
          ciKlass* exact = profile_type(md, base_offset, off,
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3136
              args->type(i), x->profiled_arg_at(i+start), mdp,
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3137
              !x->arg_needs_null_check(i+start),
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3138
              signature_at_call_stream.next_klass(), callee_signature_stream.next_klass());
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3139
          if (exact != NULL) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3140
            md->set_argument_type(bci, i, exact);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3141
          }
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3142
        }
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3143
      } else {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3144
#ifdef ASSERT
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3145
        Bytecodes::Code code = x->method()->raw_code_at_bci(x->bci_of_invoke());
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3146
        int n = x->nb_profiled_args();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3147
        assert(MethodData::profile_parameters() && (MethodData::profile_arguments_jsr292_only() ||
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3148
            (x->inlined() && ((code == Bytecodes::_invokedynamic && n <= 1) || (code == Bytecodes::_invokehandle && n <= 2)))),
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3149
            "only at JSR292 bytecodes");
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3150
#endif
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3151
      }
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3152
    }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3153
  }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3154
}
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3155
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3156
// profile parameters on entry to an inlined method
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3157
void LIRGenerator::profile_parameters_at_call(ProfileCall* x) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3158
  if (compilation()->profile_parameters() && x->inlined()) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3159
    ciMethodData* md = x->callee()->method_data_or_null();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3160
    if (md != NULL) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3161
      ciParametersTypeData* parameters_type_data = md->parameters_type_data();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3162
      if (parameters_type_data != NULL) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3163
        ciTypeStackSlotEntries* parameters =  parameters_type_data->parameters();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3164
        LIR_Opr mdp = LIR_OprFact::illegalOpr;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3165
        bool has_receiver = !x->callee()->is_static();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3166
        ciSignature* sig = x->callee()->signature();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3167
        ciSignatureStream sig_stream(sig, has_receiver ? x->callee()->holder() : NULL);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3168
        int i = 0; // to iterate on the Instructions
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3169
        Value arg = x->recv();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3170
        bool not_null = false;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3171
        int bci = x->bci_of_invoke();
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3172
        Bytecodes::Code bc = x->method()->java_code_at_bci(bci);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3173
        // The first parameter is the receiver so that's what we start
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  3174
        // with if it exists. One exception is method handle call to
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  3175
        // virtual method: the receiver is in the args list
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3176
        if (arg == NULL || !Bytecodes::has_receiver(bc)) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3177
          i = 1;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3178
          arg = x->profiled_arg_at(0);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3179
          not_null = !x->arg_needs_null_check(0);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3180
        }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3181
        int k = 0; // to iterate on the profile data
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3182
        for (;;) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3183
          intptr_t profiled_k = parameters->type(k);
21579
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  3184
          ciKlass* exact = profile_type(md, md->byte_offset_of_slot(parameters_type_data, ParametersTypeData::type_offset(0)),
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  3185
                                        in_bytes(ParametersTypeData::type_offset(k)) - in_bytes(ParametersTypeData::type_offset(0)),
c396d68f3e48 8027631: "unexpected profiling mismatch" error with new type profiling
roland
parents: 21102
diff changeset
  3186
                                        profiled_k, arg, mdp, not_null, sig_stream.next_klass(), NULL);
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3187
          // If the profile is known statically set it once for all and do not emit any code
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3188
          if (exact != NULL) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3189
            md->set_parameter_type(k, exact);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3190
          }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3191
          k++;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3192
          if (k >= parameters_type_data->number_of_parameters()) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3193
#ifdef ASSERT
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3194
            int extra = 0;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3195
            if (MethodData::profile_arguments() && TypeProfileParmsLimit != -1 &&
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3196
                x->nb_profiled_args() >= TypeProfileParmsLimit &&
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3197
                x->recv() != NULL && Bytecodes::has_receiver(bc)) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3198
              extra += 1;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3199
            }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3200
            assert(i == x->nb_profiled_args() - extra || (TypeProfileParmsLimit != -1 && TypeProfileArgsLimit > TypeProfileParmsLimit), "unused parameters?");
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3201
#endif
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3202
            break;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3203
          }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3204
          arg = x->profiled_arg_at(i);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3205
          not_null = !x->arg_needs_null_check(i);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3206
          i++;
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3207
        }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3208
      }
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3209
    }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3210
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3211
}
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3212
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3213
void LIRGenerator::do_ProfileCall(ProfileCall* x) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3214
  // Need recv in a temporary register so it interferes with the other temporaries
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3215
  LIR_Opr recv = LIR_OprFact::illegalOpr;
51649
8f594f75e054 8187078: -XX:+VerifyOops finds numerous problems when running JPRT
dlong
parents: 51643
diff changeset
  3216
  LIR_Opr mdo = new_register(T_METADATA);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3217
  // tmp is used to hold the counters on SPARC
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3218
  LIR_Opr tmp = new_pointer_register();
20702
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3219
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3220
  if (x->nb_profiled_args() > 0) {
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3221
    profile_arguments(x);
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3222
  }
bbe0fcde6e13 8023657: New type profiling points: arguments to call
roland
parents: 20695
diff changeset
  3223
21095
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3224
  // profile parameters on inlined method entry including receiver
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3225
  if (x->recv() != NULL || x->nb_profiled_args() > 0) {
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3226
    profile_parameters_at_call(x);
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3227
  }
1a04f7b3946e 8026251: New type profiling points: parameters to methods
roland
parents: 21088
diff changeset
  3228
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3229
  if (x->recv() != NULL) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3230
    LIRItem value(x->recv(), this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3231
    value.load_item();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3232
    recv = new_register(T_OBJECT);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3233
    __ move(value.result(), recv);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3234
  }
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12959
diff changeset
  3235
  __ profile_call(x->method(), x->bci_of_invoke(), x->callee(), mdo, recv, tmp, x->known_holder());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3236
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3237
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3238
void LIRGenerator::do_ProfileReturnType(ProfileReturnType* x) {
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3239
  int bci = x->bci_of_invoke();
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3240
  ciMethodData* md = x->method()->method_data_or_null();
51079
9e19d3a1a69d 8206873: 2 Null pointer dereference defect groups in LIRGenerator
rraghavan
parents: 50728
diff changeset
  3241
  assert(md != NULL, "Sanity");
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3242
  ciProfileData* data = md->bci_to_data(bci);
44315
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3243
  if (data != NULL) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3244
    assert(data->is_CallTypeData() || data->is_VirtualCallTypeData(), "wrong profile data type");
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3245
    ciReturnTypeEntry* ret = data->is_CallTypeData() ? ((ciCallTypeData*)data)->ret() : ((ciVirtualCallTypeData*)data)->ret();
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3246
    LIR_Opr mdp = LIR_OprFact::illegalOpr;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3247
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3248
    bool ignored_will_link;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3249
    ciSignature* signature_at_call = NULL;
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3250
    x->method()->get_method_at_bci(bci, ignored_will_link, &signature_at_call);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3251
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3252
    // The offset within the MDO of the entry to update may be too large
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3253
    // to be used in load/store instructions on some platforms. So have
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3254
    // profile_type() compute the address of the profile in a register.
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3255
    ciKlass* exact = profile_type(md, md->byte_offset_of_slot(data, ret->type_offset()), 0,
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3256
        ret->type(), x->ret(), mdp,
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3257
        !x->needs_null_check(),
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3258
        signature_at_call->return_type()->as_klass(),
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3259
        x->callee()->signature()->return_type()->as_klass());
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3260
    if (exact != NULL) {
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3261
      md->set_return_type(bci, exact);
1e2f842b0c96 8175340: Possible invalid memory accesses due to ciMethodData::bci_to_data() returning NULL
zmajo
parents: 43676
diff changeset
  3262
    }
20709
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3263
  }
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3264
}
034be898bf04 8026054: New type profiling points: type of return values at calls
roland
parents: 20702
diff changeset
  3265
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3266
void LIRGenerator::do_ProfileInvoke(ProfileInvoke* x) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3267
  // We can safely ignore accessors here, since c2 will inline them anyway,
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3268
  // accessors are also always mature.
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3269
  if (!x->inlinee()->is_accessor()) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3270
    CodeEmitInfo* info = state_for(x, x->state(), true);
10569
f5ce1108443b 7096639: Tiered: Incorrect counter overflow handling for inlined methods
iveresov
parents: 9979
diff changeset
  3271
    // Notify the runtime very infrequently only to take care of counter overflows
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3272
    int freq_log = Tier23InlineeNotifyFreqLog;
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3273
    double scale;
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3274
    if (_method->has_option_value("CompileThresholdScaling", scale)) {
50589
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 50207
diff changeset
  3275
      freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3276
    }
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3277
    increment_event_counter_impl(info, x->inlinee(), LIR_OprFact::intConst(InvocationCounter::count_increment), right_n_bits(freq_log), InvocationEntryBci, false, true);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3278
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3279
}
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3280
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3281
void LIRGenerator::increment_backedge_counter_conditionally(LIR_Condition cond, LIR_Opr left, LIR_Opr right, CodeEmitInfo* info, int left_bci, int right_bci, int bci) {
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3282
  if (compilation()->count_backedges()) {
54200
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3283
#if defined(X86) && !defined(_LP64)
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3284
    // BEWARE! On 32-bit x86 cmp clobbers its left argument so we need a temp copy.
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3285
    LIR_Opr left_copy = new_register(left->type());
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3286
    __ move(left, left_copy);
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3287
    __ cmp(cond, left_copy, right);
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3288
#else
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3289
    __ cmp(cond, left, right);
54200
af3f568cbd2d 8211100: hotspot C1 issue with comparing long numbers on x86 32-bit
dcherepanov
parents: 54125
diff changeset
  3290
#endif
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3291
    LIR_Opr step = new_register(T_INT);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3292
    LIR_Opr plus_one = LIR_OprFact::intConst(InvocationCounter::count_increment);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3293
    LIR_Opr zero = LIR_OprFact::intConst(0);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3294
    __ cmove(cond,
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3295
        (left_bci < bci) ? plus_one : zero,
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3296
        (right_bci < bci) ? plus_one : zero,
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3297
        step, left->type());
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3298
    increment_backedge_counter(info, step, bci);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3299
  }
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3300
}
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3301
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3302
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3303
void LIRGenerator::increment_event_counter(CodeEmitInfo* info, LIR_Opr step, int bci, bool backedge) {
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33105
diff changeset
  3304
  int freq_log = 0;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3305
  int level = compilation()->env()->comp_level();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3306
  if (level == CompLevel_limited_profile) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3307
    freq_log = (backedge ? Tier2BackedgeNotifyFreqLog : Tier2InvokeNotifyFreqLog);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3308
  } else if (level == CompLevel_full_profile) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3309
    freq_log = (backedge ? Tier3BackedgeNotifyFreqLog : Tier3InvokeNotifyFreqLog);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3310
  } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3311
    ShouldNotReachHere();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3312
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3313
  // Increment the appropriate invocation/backedge counter and notify the runtime.
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3314
  double scale;
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3315
  if (_method->has_option_value("CompileThresholdScaling", scale)) {
50589
e5d741569070 8184349: There should be some verification that EnableJVMCI is disabled if a GC not supporting JVMCI is selected
kvn
parents: 50207
diff changeset
  3316
    freq_log = CompilerConfig::scaled_freq_log(freq_log, scale);
28650
772aaab2582f 8059606: Enable per-method usage of CompileThresholdScaling (per-method compilation thresholds)
zmajo
parents: 27014
diff changeset
  3317
  }
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3318
  increment_event_counter_impl(info, info->scope()->method(), step, right_n_bits(freq_log), bci, backedge, true);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3319
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3320
24442
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3321
void LIRGenerator::decrement_age(CodeEmitInfo* info) {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3322
  ciMethod* method = info->scope()->method();
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3323
  MethodCounters* mc_adr = method->ensure_method_counters();
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3324
  if (mc_adr != NULL) {
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3325
    LIR_Opr mc = new_pointer_register();
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3326
    __ move(LIR_OprFact::intptrConst(mc_adr), mc);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3327
    int offset = in_bytes(MethodCounters::nmethod_age_offset());
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3328
    LIR_Address* counter = new LIR_Address(mc, offset, T_INT);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3329
    LIR_Opr result = new_register(T_INT);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3330
    __ load(counter, result);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3331
    __ sub(result, LIR_OprFact::intConst(1), result);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3332
    __ store(result, counter);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3333
    // DeoptimizeStub will reexecute from the current state in code info.
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3334
    CodeStub* deopt = new DeoptimizeStub(info, Deoptimization::Reason_tenured,
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3335
                                         Deoptimization::Action_make_not_entrant);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3336
    __ cmp(lir_cond_lessEqual, result, LIR_OprFact::intConst(0));
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3337
    __ branch(lir_cond_lessEqual, T_INT, deopt);
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3338
  }
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3339
}
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3340
4d4ae31dea26 8032463: VirtualDispatch test timeout with DeoptimizeALot
iveresov
parents: 24313
diff changeset
  3341
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3342
void LIRGenerator::increment_event_counter_impl(CodeEmitInfo* info,
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3343
                                                ciMethod *method, LIR_Opr step, int frequency,
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3344
                                                int bci, bool backedge, bool notify) {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3345
  assert(frequency == 0 || is_power_of_2(frequency + 1), "Frequency must be x^2 - 1 or 0");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3346
  int level = _compilation->env()->comp_level();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3347
  assert(level > CompLevel_simple, "Shouldn't be here");
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3348
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3349
  int offset = -1;
33589
7cbd1b2c139b 8139040: Fix initializations before ShouldNotReachHere() etc. and enable -Wuninitialized on linux.
goetz
parents: 33105
diff changeset
  3350
  LIR_Opr counter_holder = NULL;
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3351
  if (level == CompLevel_limited_profile) {
20695
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 19156
diff changeset
  3352
    MethodCounters* counters_adr = method->ensure_method_counters();
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 19156
diff changeset
  3353
    if (counters_adr == NULL) {
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 19156
diff changeset
  3354
      bailout("method counters allocation failed");
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 19156
diff changeset
  3355
      return;
4f5a5e95090b 8025566: EXCEPTION_ACCESS_VIOLATION in compiled by C1 String.valueOf method
twisti
parents: 19156
diff changeset
  3356
    }
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16620
diff changeset
  3357
    counter_holder = new_pointer_register();
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16620
diff changeset
  3358
    __ move(LIR_OprFact::intptrConst(counters_adr), counter_holder);
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16620
diff changeset
  3359
    offset = in_bytes(backedge ? MethodCounters::backedge_counter_offset() :
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16620
diff changeset
  3360
                                 MethodCounters::invocation_counter_offset());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3361
  } else if (level == CompLevel_full_profile) {
17000
11bf92e571a2 8010862: The Method counter fields used for profiling can be allocated lazily.
jiangli
parents: 16620
diff changeset
  3362
    counter_holder = new_register(T_METADATA);
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13487
diff changeset
  3363
    offset = in_bytes(backedge ? MethodData::backedge_counter_offset() :
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13487
diff changeset
  3364
                                 MethodData::invocation_counter_offset());
7432
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  3365
    ciMethodData* md = method->method_data_or_null();
f06f1253c317 7003554: (tiered) assert(is_null_object() || handle() != NULL) failed: cannot embed null pointer
iveresov
parents: 7427
diff changeset
  3366
    assert(md != NULL, "Sanity");
13742
9180987e305d 7195816: NPG: Crash in c1_ValueType - ShouldNotReachHere
roland
parents: 13734
diff changeset
  3367
    __ metadata2reg(md->constant_encoding(), counter_holder);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3368
  } else {
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3369
    ShouldNotReachHere();
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3370
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3371
  LIR_Address* counter = new LIR_Address(counter_holder, offset, T_INT);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3372
  LIR_Opr result = new_register(T_INT);
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3373
  __ load(counter, result);
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3374
  __ add(result, step, result);
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3375
  __ store(result, counter);
40022
3eb9922d1a5b 8159620: -XX:-UseOnStackReplacement does not work together with -XX:+TieredCompilation on ppc64 and sparc
simonis
parents: 38241
diff changeset
  3376
  if (notify && (!backedge || UseOnStackReplacement)) {
34200
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3377
    LIR_Opr meth = LIR_OprFact::metadataConst(method->constant_encoding());
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3378
    // The bci for info can point to cmp for if's we want the if bci
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3379
    CodeStub* overflow = new CounterOverflowStub(info, bci, meth);
34200
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3380
    int freq = frequency << InvocationCounter::count_shift;
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3381
    if (freq == 0) {
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3382
      if (!step->is_constant()) {
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3383
        __ cmp(lir_cond_notEqual, step, LIR_OprFact::intConst(0));
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3384
        __ branch(lir_cond_notEqual, T_ILLEGAL, overflow);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3385
      } else {
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3386
        __ branch(lir_cond_always, T_ILLEGAL, overflow);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3387
      }
34200
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3388
    } else {
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3389
      LIR_Opr mask = load_immediate(freq, T_INT);
50153
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3390
      if (!step->is_constant()) {
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3391
        // If step is 0, make sure the overflow check below always fails
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3392
        __ cmp(lir_cond_notEqual, step, LIR_OprFact::intConst(0));
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3393
        __ cmove(lir_cond_notEqual, result, LIR_OprFact::intConst(InvocationCounter::count_increment), result, T_INT);
9010b580d8a9 8201447: C1 does backedge profiling incorrectly
iveresov
parents: 50113
diff changeset
  3394
      }
34200
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3395
      __ logical_and(result, mask, result);
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3396
      __ cmp(lir_cond_equal, result, LIR_OprFact::intConst(0));
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3397
      __ branch(lir_cond_equal, T_INT, overflow);
0a24709c3861 8138892: C1: Improve counter overflow checking
mdoerr
parents: 34185
diff changeset
  3398
    }
6453
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3399
    __ branch_destination(overflow->continuation());
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3400
  }
970dc585ab63 6953144: Tiered compilation
iveresov
parents: 6176
diff changeset
  3401
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3402
8065
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3403
void LIRGenerator::do_RuntimeCall(RuntimeCall* x) {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3404
  LIR_OprList* args = new LIR_OprList(x->number_of_arguments());
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3405
  BasicTypeList* signature = new BasicTypeList(x->number_of_arguments());
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3406
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3407
  if (x->pass_thread()) {
21102
1dd11ccfe9da 8026495: JVM Crashes when started with -XX:+DTraceMethodProbes on Solaris x86_64
iveresov
parents: 21095
diff changeset
  3408
    signature->append(LP64_ONLY(T_LONG) NOT_LP64(T_INT));    // thread
8065
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3409
    args->append(getThreadPointer());
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3410
  }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3411
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3412
  for (int i = 0; i < x->number_of_arguments(); i++) {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3413
    Value a = x->argument_at(i);
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3414
    LIRItem* item = new LIRItem(a, this);
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3415
    item->load_item();
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3416
    args->append(item->result());
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3417
    signature->append(as_BasicType(a->type()));
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3418
  }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3419
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3420
  LIR_Opr result = call_runtime(signature, args, x->entry(), x->type(), NULL);
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3421
  if (x->type() == voidType) {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3422
    set_no_result(x);
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3423
  } else {
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3424
    __ move(result, rlock_result(x));
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3425
  }
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3426
}
7ca689ce3d32 6809483: hotspot:::method_entry are not correctly generated for "method()V"
never
parents: 7713
diff changeset
  3427
17011
def8879c5b81 8011648: C1: optimized build is broken after 7153771
roland
parents: 16672
diff changeset
  3428
#ifdef ASSERT
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3429
void LIRGenerator::do_Assert(Assert *x) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3430
  ValueTag tag = x->x()->type()->tag();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3431
  If::Condition cond = x->cond();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3432
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3433
  LIRItem xitem(x->x(), this);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3434
  LIRItem yitem(x->y(), this);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3435
  LIRItem* xin = &xitem;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3436
  LIRItem* yin = &yitem;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3437
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3438
  assert(tag == intTag, "Only integer assertions are valid!");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3439
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3440
  xin->load_item();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3441
  yin->dont_load_item();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3442
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3443
  set_no_result(x);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3444
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3445
  LIR_Opr left = xin->result();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3446
  LIR_Opr right = yin->result();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3447
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3448
  __ lir_assert(lir_cond(x->cond()), left, right, x->message(), true);
17011
def8879c5b81 8011648: C1: optimized build is broken after 7153771
roland
parents: 16672
diff changeset
  3449
}
16611
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3450
#endif
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3451
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3452
void LIRGenerator::do_RangeCheckPredicate(RangeCheckPredicate *x) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3453
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3454
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3455
  Instruction *a = x->x();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3456
  Instruction *b = x->y();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3457
  if (!a || StressRangeCheckElimination) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3458
    assert(!b || StressRangeCheckElimination, "B must also be null");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3459
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3460
    CodeEmitInfo *info = state_for(x, x->state());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3461
    CodeStub* stub = new PredicateFailedStub(info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3462
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3463
    __ jump(stub);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3464
  } else if (a->type()->as_IntConstant() && b->type()->as_IntConstant()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3465
    int a_int = a->type()->as_IntConstant()->value();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3466
    int b_int = b->type()->as_IntConstant()->value();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3467
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3468
    bool ok = false;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3469
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3470
    switch(x->cond()) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3471
      case Instruction::eql: ok = (a_int == b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3472
      case Instruction::neq: ok = (a_int != b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3473
      case Instruction::lss: ok = (a_int < b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3474
      case Instruction::leq: ok = (a_int <= b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3475
      case Instruction::gtr: ok = (a_int > b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3476
      case Instruction::geq: ok = (a_int >= b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3477
      case Instruction::aeq: ok = ((unsigned int)a_int >= (unsigned int)b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3478
      case Instruction::beq: ok = ((unsigned int)a_int <= (unsigned int)b_int); break;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3479
      default: ShouldNotReachHere();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3480
    }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3481
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3482
    if (ok) {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3483
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3484
      CodeEmitInfo *info = state_for(x, x->state());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3485
      CodeStub* stub = new PredicateFailedStub(info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3486
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3487
      __ jump(stub);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3488
    }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3489
  } else {
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3490
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3491
    ValueTag tag = x->x()->type()->tag();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3492
    If::Condition cond = x->cond();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3493
    LIRItem xitem(x->x(), this);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3494
    LIRItem yitem(x->y(), this);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3495
    LIRItem* xin = &xitem;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3496
    LIRItem* yin = &yitem;
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3497
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3498
    assert(tag == intTag, "Only integer deoptimizations are valid!");
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3499
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3500
    xin->load_item();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3501
    yin->dont_load_item();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3502
    set_no_result(x);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3503
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3504
    LIR_Opr left = xin->result();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3505
    LIR_Opr right = yin->result();
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3506
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3507
    CodeEmitInfo *info = state_for(x, x->state());
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3508
    CodeStub* stub = new PredicateFailedStub(info);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3509
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3510
    __ cmp(lir_cond(cond), left, right);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3511
    __ branch(lir_cond(cond), right->type(), stub);
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3512
  }
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3513
}
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3514
6807a703dd6b 7153771: array bound check elimination for c1
roland
parents: 15482
diff changeset
  3515
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3516
LIR_Opr LIRGenerator::call_runtime(Value arg1, address entry, ValueType* result_type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3517
  LIRItemList args(1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3518
  LIRItem value(arg1, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3519
  args.append(&value);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3520
  BasicTypeList signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3521
  signature.append(as_BasicType(arg1->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3522
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3523
  return call_runtime(&signature, &args, entry, result_type, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3524
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3525
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3526
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3527
LIR_Opr LIRGenerator::call_runtime(Value arg1, Value arg2, address entry, ValueType* result_type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3528
  LIRItemList args(2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3529
  LIRItem value1(arg1, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3530
  LIRItem value2(arg2, this);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3531
  args.append(&value1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3532
  args.append(&value2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3533
  BasicTypeList signature;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3534
  signature.append(as_BasicType(arg1->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3535
  signature.append(as_BasicType(arg2->type()));
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3536
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3537
  return call_runtime(&signature, &args, entry, result_type, info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3538
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3539
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3540
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3541
LIR_Opr LIRGenerator::call_runtime(BasicTypeArray* signature, LIR_OprList* args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3542
                                   address entry, ValueType* result_type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3543
  // get a result register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3544
  LIR_Opr phys_reg = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3545
  LIR_Opr result = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3546
  if (result_type->tag() != voidTag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3547
    result = new_register(result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3548
    phys_reg = result_register_for(result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3549
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3550
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3551
  // move the arguments into the correct location
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3552
  CallingConvention* cc = frame_map()->c_calling_convention(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3553
  assert(cc->length() == args->length(), "argument mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3554
  for (int i = 0; i < args->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3555
    LIR_Opr arg = args->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3556
    LIR_Opr loc = cc->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3557
    if (loc->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3558
      __ move(arg, loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3559
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3560
      LIR_Address* addr = loc->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3561
//           if (!can_store_as_constant(arg)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3562
//             LIR_Opr tmp = new_register(arg->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3563
//             __ move(arg, tmp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3564
//             arg = tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3565
//           }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3566
      if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3567
        __ unaligned_move(arg, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3568
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3569
        __ move(arg, addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3570
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3571
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3572
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3573
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3574
  if (info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3575
    __ call_runtime(entry, getThreadTemp(), phys_reg, cc->args(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3576
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3577
    __ call_runtime_leaf(entry, getThreadTemp(), phys_reg, cc->args());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3578
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3579
  if (result->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3580
    __ move(phys_reg, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3581
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3582
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3583
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3584
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3585
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3586
LIR_Opr LIRGenerator::call_runtime(BasicTypeArray* signature, LIRItemList* args,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3587
                                   address entry, ValueType* result_type, CodeEmitInfo* info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3588
  // get a result register
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3589
  LIR_Opr phys_reg = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3590
  LIR_Opr result = LIR_OprFact::illegalOpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3591
  if (result_type->tag() != voidTag) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3592
    result = new_register(result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3593
    phys_reg = result_register_for(result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3594
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3595
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3596
  // move the arguments into the correct location
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3597
  CallingConvention* cc = frame_map()->c_calling_convention(signature);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3598
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3599
  assert(cc->length() == args->length(), "argument mismatch");
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3600
  for (int i = 0; i < args->length(); i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3601
    LIRItem* arg = args->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3602
    LIR_Opr loc = cc->at(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3603
    if (loc->is_register()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3604
      arg->load_item_force(loc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3605
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3606
      LIR_Address* addr = loc->as_address_ptr();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3607
      arg->load_for_store(addr->type());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3608
      if (addr->type() == T_LONG || addr->type() == T_DOUBLE) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3609
        __ unaligned_move(arg->result(), addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3610
      } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3611
        __ move(arg->result(), addr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3612
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3613
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3614
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3615
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3616
  if (info) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3617
    __ call_runtime(entry, getThreadTemp(), phys_reg, cc->args(), info);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3618
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3619
    __ call_runtime_leaf(entry, getThreadTemp(), phys_reg, cc->args());
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3620
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3621
  if (result->is_valid()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3622
    __ move(phys_reg, result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3623
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3624
  return result;
489c9b5090e2 Initial load
duke
parents:
diff changeset
  3625
}
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11563
diff changeset
  3626
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11563
diff changeset
  3627
void LIRGenerator::do_MemBar(MemBar* x) {
51996
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3628
  LIR_Code code = x->code();
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3629
  switch(code) {
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3630
  case lir_membar_acquire   : __ membar_acquire(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3631
  case lir_membar_release   : __ membar_release(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3632
  case lir_membar           : __ membar(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3633
  case lir_membar_loadload  : __ membar_loadload(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3634
  case lir_membar_storestore: __ membar_storestore(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3635
  case lir_membar_loadstore : __ membar_loadstore(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3636
  case lir_membar_storeload : __ membar_storeload(); break;
84743156e780 8188764: Obsolete AssumeMP and then remove all support for non-MP builds
dholmes
parents: 51649
diff changeset
  3637
  default                   : ShouldNotReachHere(); break;
11886
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11563
diff changeset
  3638
  }
feebf5c9f40c 7120481: storeStore barrier in constructor with final field
jiangli
parents: 11563
diff changeset
  3639
}
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3640
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3641
LIR_Opr LIRGenerator::mask_boolean(LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3642
  LIR_Opr value_fixed = rlock_byte(T_BYTE);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3643
  if (TwoOperandLIRForm) {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3644
    __ move(value, value_fixed);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3645
    __ logical_and(value_fixed, LIR_OprFact::intConst(1), value_fixed);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3646
  } else {
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3647
    __ logical_and(value, LIR_OprFact::intConst(1), value_fixed);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3648
  }
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3649
  LIR_Opr klass = new_register(T_METADATA);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3650
  __ move(new LIR_Address(array, oopDesc::klass_offset_in_bytes(), T_ADDRESS), klass, null_check_info);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3651
  null_check_info = NULL;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3652
  LIR_Opr layout = new_register(T_INT);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3653
  __ move(new LIR_Address(klass, in_bytes(Klass::layout_helper_offset()), T_INT), layout);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3654
  int diffbit = Klass::layout_helper_boolean_diffbit();
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3655
  __ logical_and(layout, LIR_OprFact::intConst(diffbit), layout);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3656
  __ cmp(lir_cond_notEqual, layout, LIR_OprFact::intConst(0));
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3657
  __ cmove(lir_cond_notEqual, value_fixed, value, value_fixed, T_BYTE);
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3658
  value = value_fixed;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3659
  return value;
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3660
}
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3661
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3662
LIR_Opr LIRGenerator::maybe_mask_boolean(StoreIndexed* x, LIR_Opr array, LIR_Opr value, CodeEmitInfo*& null_check_info) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3663
  if (x->check_boolean()) {
49906
4bb58f644e4e 8201543: Modularize C1 GC barriers
eosterlund
parents: 49877
diff changeset
  3664
    value = mask_boolean(array, value, null_check_info);
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3665
  }
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3666
  return value;
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37291
diff changeset
  3667
}