hotspot/src/share/vm/interpreter/templateInterpreter.cpp
author twisti
Thu, 24 Oct 2013 16:23:07 -0700
changeset 21198 dd647e8d1d72
parent 18507 61bfc8995bb3
child 24424 2658d7834c6e
permissions -rw-r--r--
8026328: Setting a breakpoint on invokedynamic crashes the JVM Reviewed-by: jrose, roland
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 5402
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: 5402
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: 5547
diff changeset
    25
#include "precompiled.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "interpreter/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/interpreterRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/templateTable.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
# define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
void TemplateInterpreter::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  if (_code != NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  // assertions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
         "dispatch table too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  AbstractInterpreter::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  TemplateTable::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  // generate interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  { ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
    TraceTime timer("Interpreter generation", TraceStartupTime);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    int code_size = InterpreterCodeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
                          "Interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    InterpreterGenerator g(_code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    if (PrintInterpreter) print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // initialize dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  _active_table = _normal_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// Implementation of EntryPoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
EntryPoint::EntryPoint() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  assert(number_of_states == 9, "check the code below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  _entry[btos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  _entry[ctos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  _entry[stos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  _entry[atos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  _entry[itos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  _entry[ltos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  _entry[ftos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  _entry[dtos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  _entry[vtos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
EntryPoint::EntryPoint(address bentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  assert(number_of_states == 9, "check the code below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  _entry[btos] = bentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  _entry[ctos] = centry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  _entry[stos] = sentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  _entry[atos] = aentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _entry[itos] = ientry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  _entry[ltos] = lentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  _entry[ftos] = fentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  _entry[dtos] = dentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  _entry[vtos] = ventry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
void EntryPoint::set_entry(TosState state, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  assert(0 <= state && state < number_of_states, "state out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  _entry[state] = entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
address EntryPoint::entry(TosState state) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  assert(0 <= state && state < number_of_states, "state out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  return _entry[state];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
void EntryPoint::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  tty->print("[");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  for (int i = 0; i < number_of_states; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
    if (i > 0) tty->print(", ");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    tty->print(INTPTR_FORMAT, _entry[i]);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  tty->print("]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
bool EntryPoint::operator == (const EntryPoint& y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  int i = number_of_states;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    if (_entry[i] != y._entry[i]) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
// Implementation of DispatchTable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
EntryPoint DispatchTable::entry(int i) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  assert(0 <= i && i < length, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
      _table[btos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
      _table[ctos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
      _table[stos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
      _table[atos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
      _table[itos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
      _table[ltos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
      _table[ftos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
      _table[dtos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
      _table[vtos][i]
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
void DispatchTable::set_entry(int i, EntryPoint& entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  assert(0 <= i && i < length, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  assert(number_of_states == 9, "check the code below");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  _table[btos][i] = entry.entry(btos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  _table[ctos][i] = entry.entry(ctos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  _table[stos][i] = entry.entry(stos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  _table[atos][i] = entry.entry(atos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  _table[itos][i] = entry.entry(itos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  _table[ltos][i] = entry.entry(ltos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  _table[ftos][i] = entry.entry(ftos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  _table[dtos][i] = entry.entry(dtos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  _table[vtos][i] = entry.entry(vtos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
bool DispatchTable::operator == (DispatchTable& y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  int i = length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    EntryPoint t = y.entry(i); // for compiler compatibility (BugId 4150096)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
    if (!(entry(i) == t)) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
address    TemplateInterpreter::_remove_activation_entry                    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
address    TemplateInterpreter::_remove_activation_preserving_args_entry    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
address    TemplateInterpreter::_throw_ArrayIndexOutOfBoundsException_entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
address    TemplateInterpreter::_throw_ArrayStoreException_entry            = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
address    TemplateInterpreter::_throw_ArithmeticException_entry            = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
address    TemplateInterpreter::_throw_ClassCastException_entry             = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
address    TemplateInterpreter::_throw_NullPointerException_entry           = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
address    TemplateInterpreter::_throw_StackOverflowError_entry             = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
address    TemplateInterpreter::_throw_exception_entry                      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
EntryPoint TemplateInterpreter::_trace_code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
EntryPoint TemplateInterpreter::_return_entry[TemplateInterpreter::number_of_return_entries];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
EntryPoint TemplateInterpreter::_earlyret_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
EntryPoint TemplateInterpreter::_deopt_entry [TemplateInterpreter::number_of_deopt_entries ];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
EntryPoint TemplateInterpreter::_continuation_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
EntryPoint TemplateInterpreter::_safept_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   187
address TemplateInterpreter::_invoke_return_entry[TemplateInterpreter::number_of_return_addrs];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   188
address TemplateInterpreter::_invokeinterface_return_entry[TemplateInterpreter::number_of_return_addrs];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   189
address TemplateInterpreter::_invokedynamic_return_entry[TemplateInterpreter::number_of_return_addrs];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
DispatchTable TemplateInterpreter::_active_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
DispatchTable TemplateInterpreter::_normal_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
DispatchTable TemplateInterpreter::_safept_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
address    TemplateInterpreter::_wentry_point[DispatchTable::length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
TemplateInterpreterGenerator::TemplateInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  _unimplemented_bytecode    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  _illegal_bytecode_sequence = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
static const BasicType types[Interpreter::number_of_result_handlers] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  T_BOOLEAN,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  T_CHAR   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  T_BYTE   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  T_SHORT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  T_INT    ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  T_LONG   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  T_VOID   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  T_FLOAT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  T_DOUBLE ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  T_OBJECT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
void TemplateInterpreterGenerator::generate_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  AbstractInterpreterGenerator::generate_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  { CodeletMark cm(_masm, "error exits");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
    _unimplemented_bytecode    = generate_error_exit("unimplemented bytecode");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
    _illegal_bytecode_sequence = generate_error_exit("illegal bytecode sequence - method not verified");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  if (TraceBytecodes) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
    CodeletMark cm(_masm, "bytecode tracing support");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
    Interpreter::_trace_code =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
      EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
        generate_trace_code(btos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
        generate_trace_code(ctos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
        generate_trace_code(stos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
        generate_trace_code(atos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
        generate_trace_code(itos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
        generate_trace_code(ltos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
        generate_trace_code(ftos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
        generate_trace_code(dtos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
        generate_trace_code(vtos)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  { CodeletMark cm(_masm, "return entry points");
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   241
    const int index_size = sizeof(u2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
    for (int i = 0; i < Interpreter::number_of_return_entries; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
      Interpreter::_return_entry[i] =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
        EntryPoint(
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   245
          generate_return_entry_for(itos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   246
          generate_return_entry_for(itos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   247
          generate_return_entry_for(itos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   248
          generate_return_entry_for(atos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   249
          generate_return_entry_for(itos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   250
          generate_return_entry_for(ltos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   251
          generate_return_entry_for(ftos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   252
          generate_return_entry_for(dtos, i, index_size),
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   253
          generate_return_entry_for(vtos, i, index_size)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
        );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   258
  { CodeletMark cm(_masm, "invoke return entry points");
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   259
    const TosState states[] = {itos, itos, itos, itos, ltos, ftos, dtos, atos, vtos};
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   260
    const int invoke_length = Bytecodes::length_for(Bytecodes::_invokestatic);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   261
    const int invokeinterface_length = Bytecodes::length_for(Bytecodes::_invokeinterface);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   262
    const int invokedynamic_length = Bytecodes::length_for(Bytecodes::_invokedynamic);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   263
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   264
    for (int i = 0; i < Interpreter::number_of_return_addrs; i++) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   265
      TosState state = states[i];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   266
      Interpreter::_invoke_return_entry[i] = generate_return_entry_for(state, invoke_length, sizeof(u2));
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   267
      Interpreter::_invokeinterface_return_entry[i] = generate_return_entry_for(state, invokeinterface_length, sizeof(u2));
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   268
      Interpreter::_invokedynamic_return_entry[i] = generate_return_entry_for(state, invokedynamic_length, sizeof(u4));
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   269
    }
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   270
  }
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   271
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  { CodeletMark cm(_masm, "earlyret entry points");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
    Interpreter::_earlyret_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
      EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
        generate_earlyret_entry_for(btos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
        generate_earlyret_entry_for(ctos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
        generate_earlyret_entry_for(stos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
        generate_earlyret_entry_for(atos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
        generate_earlyret_entry_for(itos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
        generate_earlyret_entry_for(ltos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
        generate_earlyret_entry_for(ftos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
        generate_earlyret_entry_for(dtos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
        generate_earlyret_entry_for(vtos)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  { CodeletMark cm(_masm, "deoptimization entry points");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    for (int i = 0; i < Interpreter::number_of_deopt_entries; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
      Interpreter::_deopt_entry[i] =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
        EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
          generate_deopt_entry_for(itos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
          generate_deopt_entry_for(itos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
          generate_deopt_entry_for(itos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
          generate_deopt_entry_for(atos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
          generate_deopt_entry_for(itos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
          generate_deopt_entry_for(ltos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
          generate_deopt_entry_for(ftos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
          generate_deopt_entry_for(dtos, i),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
          generate_deopt_entry_for(vtos, i)
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
  { CodeletMark cm(_masm, "result handlers for native calls");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
    // The various result converter stublets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
    int is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
    memset(is_generated, 0, sizeof(is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
    for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
      BasicType type = types[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
      if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
        Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  { CodeletMark cm(_masm, "continuation entry points");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
    Interpreter::_continuation_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
      EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
        generate_continuation_for(btos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
        generate_continuation_for(ctos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
        generate_continuation_for(stos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
        generate_continuation_for(atos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
        generate_continuation_for(itos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
        generate_continuation_for(ltos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
        generate_continuation_for(ftos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
        generate_continuation_for(dtos),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
        generate_continuation_for(vtos)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
      );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
  { CodeletMark cm(_masm, "safepoint entry points");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
    Interpreter::_safept_entry =
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
      EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
        generate_safept_entry_for(btos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
        generate_safept_entry_for(ctos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
        generate_safept_entry_for(stos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
        generate_safept_entry_for(atos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
        generate_safept_entry_for(itos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
        generate_safept_entry_for(ltos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
        generate_safept_entry_for(ftos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
        generate_safept_entry_for(dtos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint)),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
        generate_safept_entry_for(vtos, CAST_FROM_FN_PTR(address, InterpreterRuntime::at_safepoint))
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
  { CodeletMark cm(_masm, "exception handling");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
    // (Note: this is not safepoint safe because thread may return to compiled code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
    generate_throw_exception();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  { CodeletMark cm(_masm, "throw exception entrypoints");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
    Interpreter::_throw_ArrayIndexOutOfBoundsException_entry = generate_ArrayIndexOutOfBounds_handler("java/lang/ArrayIndexOutOfBoundsException");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
    Interpreter::_throw_ArrayStoreException_entry            = generate_klass_exception_handler("java/lang/ArrayStoreException"                 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
    Interpreter::_throw_ArithmeticException_entry            = generate_exception_handler("java/lang/ArithmeticException"           , "/ by zero");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
    Interpreter::_throw_ClassCastException_entry             = generate_ClassCastException_handler();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
    Interpreter::_throw_NullPointerException_entry           = generate_exception_handler("java/lang/NullPointerException"          , NULL       );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
    Interpreter::_throw_StackOverflowError_entry             = generate_StackOverflowError_handler();
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
#define method_entry(kind)                                                                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  { CodeletMark cm(_masm, "method entry point (kind = " #kind ")");                    \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
    Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind);  \
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  // all non-native method kinds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  method_entry(zerolocals)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  method_entry(zerolocals_synchronized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  method_entry(empty)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  method_entry(accessor)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  method_entry(abstract)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  method_entry(java_lang_math_sin  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  method_entry(java_lang_math_cos  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  method_entry(java_lang_math_tan  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  method_entry(java_lang_math_abs  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  method_entry(java_lang_math_sqrt )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  method_entry(java_lang_math_log  )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  method_entry(java_lang_math_log10)
12739
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 10004
diff changeset
   381
  method_entry(java_lang_math_exp  )
09f26b73ae66 7133857: exp() and pow() should use the x87 ISA on x86
roland
parents: 10004
diff changeset
   382
  method_entry(java_lang_math_pow  )
9176
42d9d1010f38 7009266: G1: assert(obj->is_oop_or_null(true )) failed: Error
johnc
parents: 7913
diff changeset
   383
  method_entry(java_lang_ref_reference_get)
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
18507
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   385
  if (UseCRC32Intrinsics) {
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   386
    method_entry(java_util_zip_CRC32_update)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   387
    method_entry(java_util_zip_CRC32_updateBytes)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   388
    method_entry(java_util_zip_CRC32_updateByteBuffer)
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   389
  }
61bfc8995bb3 7088419: Use x86 Hardware CRC32 Instruction with java.util.zip.CRC32
drchase
parents: 14294
diff changeset
   390
14294
130e947dfbe6 8000780: make Zero build and run with JDK8
twisti
parents: 13728
diff changeset
   391
  initialize_method_handle_entries();
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12739
diff changeset
   392
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  // all native method kinds (must be one contiguous block)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  Interpreter::_native_entry_begin = Interpreter::code()->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  method_entry(native)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  method_entry(native_synchronized)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  Interpreter::_native_entry_end = Interpreter::code()->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
#undef method_entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  // Bytecodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  set_entry_points_for_all_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  set_safepoints_for_all_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
address TemplateInterpreterGenerator::generate_error_exit(const char* msg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  address entry = __ pc();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  __ stop(msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  return entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
void TemplateInterpreterGenerator::set_entry_points_for_all_bytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  for (int i = 0; i < DispatchTable::length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
    Bytecodes::Code code = (Bytecodes::Code)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
    if (Bytecodes::is_defined(code)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
      set_entry_points(code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
    } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
      set_unimplemented(i);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
void TemplateInterpreterGenerator::set_safepoints_for_all_bytes() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  for (int i = 0; i < DispatchTable::length; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    Bytecodes::Code code = (Bytecodes::Code)i;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
    if (Bytecodes::is_defined(code)) Interpreter::_safept_table.set_entry(code, Interpreter::_safept_entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
void TemplateInterpreterGenerator::set_unimplemented(int i) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  address e = _unimplemented_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  EntryPoint entry(e, e, e, e, e, e, e, e, e);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  Interpreter::_normal_table.set_entry(i, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  Interpreter::_wentry_point[i] = _unimplemented_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
void TemplateInterpreterGenerator::set_entry_points(Bytecodes::Code code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  CodeletMark cm(_masm, Bytecodes::name(code), code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // initialize entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  assert(_unimplemented_bytecode    != NULL, "should have been generated before");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  assert(_illegal_bytecode_sequence != NULL, "should have been generated before");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  address bep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  address cep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  address sep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
  address aep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  address iep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  address lep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  address fep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  address dep = _illegal_bytecode_sequence;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  address vep = _unimplemented_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  address wep = _unimplemented_bytecode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  // code for short & wide version of bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  if (Bytecodes::is_defined(code)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
    Template* t = TemplateTable::template_for(code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
    assert(t->is_valid(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
    set_short_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  if (Bytecodes::wide_is_defined(code)) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    Template* t = TemplateTable::template_for_wide(code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    assert(t->is_valid(), "just checking");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    set_wide_entry_point(t, wep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  // set entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  EntryPoint entry(bep, cep, sep, aep, iep, lep, fep, dep, vep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  Interpreter::_normal_table.set_entry(code, entry);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  Interpreter::_wentry_point[code] = wep;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
void TemplateInterpreterGenerator::set_wide_entry_point(Template* t, address& wep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
  assert(t->is_valid(), "template must exist");
5402
c51fd0c1d005 6888953: some calls to function-like macros are missing semicolons
jcoomes
parents: 4441
diff changeset
   480
  assert(t->tos_in() == vtos, "only vtos tos_in supported for wide instructions");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  wep = __ pc(); generate_and_dispatch(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
void TemplateInterpreterGenerator::set_short_entry_points(Template* t, address& bep, address& cep, address& sep, address& aep, address& iep, address& lep, address& fep, address& dep, address& vep) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  assert(t->is_valid(), "template must exist");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  switch (t->tos_in()) {
4441
1dfb3f44c62a 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 4429
diff changeset
   488
    case btos:
1dfb3f44c62a 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 4429
diff changeset
   489
    case ctos:
1dfb3f44c62a 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 4429
diff changeset
   490
    case stos:
1dfb3f44c62a 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 4429
diff changeset
   491
      ShouldNotReachHere();  // btos/ctos/stos should use itos.
1dfb3f44c62a 6902000: use ShouldNotReachHere() for btos/ctos/stos in TemplateInterpreterGenerator::set_short_entry_points
twisti
parents: 4429
diff changeset
   492
      break;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
    case atos: vep = __ pc(); __ pop(atos); aep = __ pc(); generate_and_dispatch(t); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
    case itos: vep = __ pc(); __ pop(itos); iep = __ pc(); generate_and_dispatch(t); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
    case ltos: vep = __ pc(); __ pop(ltos); lep = __ pc(); generate_and_dispatch(t); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
    case ftos: vep = __ pc(); __ pop(ftos); fep = __ pc(); generate_and_dispatch(t); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
    case dtos: vep = __ pc(); __ pop(dtos); dep = __ pc(); generate_and_dispatch(t); break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
    case vtos: set_vtos_entry_points(t, bep, cep, sep, aep, iep, lep, fep, dep, vep);     break;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
    default  : ShouldNotReachHere();                                                 break;
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
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
void TemplateInterpreterGenerator::generate_and_dispatch(Template* t, TosState tos_out) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  if (PrintBytecodeHistogram)                                    histogram_bytecode(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  // debugging code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  if (CountBytecodes || TraceBytecodes || StopInterpreterAt > 0) count_bytecode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  if (PrintBytecodePairHistogram)                                histogram_bytecode_pair(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
  if (TraceBytecodes)                                            trace_bytecode(t);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  if (StopInterpreterAt > 0)                                     stop_interpreter_at();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  __ verify_FPU(1, t->tos_in());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  int step;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  if (!t->does_dispatch()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
    step = t->is_wide() ? Bytecodes::wide_length_for(t->bytecode()) : Bytecodes::length_for(t->bytecode());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
    if (tos_out == ilgl) tos_out = t->tos_out();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
    // compute bytecode size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
    assert(step > 0, "just checkin'");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
    // setup stuff for dispatching next bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
    if (ProfileInterpreter && VerifyDataPointer
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   524
        && MethodData::bytecode_has_profile(t->bytecode())) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
      __ verify_method_data_pointer();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
    __ dispatch_prolog(tos_out, step);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  // generate template
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  t->generate(_masm);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
  // advance
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  if (t->does_dispatch()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
    // make sure execution doesn't go beyond this point if code is broken
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
    __ should_not_reach_here();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
#endif // ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  } else {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
    // dispatch to next bytecode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
    __ dispatch_epilog(tos_out, step);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
// Entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   546
/**
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   547
 * Returns the return entry table for the given invoke bytecode.
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   548
 */
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   549
address* TemplateInterpreter::invoke_return_entry_table_for(Bytecodes::Code code) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   550
  switch (code) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   551
  case Bytecodes::_invokestatic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   552
  case Bytecodes::_invokespecial:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   553
  case Bytecodes::_invokevirtual:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   554
  case Bytecodes::_invokehandle:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   555
    return Interpreter::invoke_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   556
  case Bytecodes::_invokeinterface:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   557
    return Interpreter::invokeinterface_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   558
  case Bytecodes::_invokedynamic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   559
    return Interpreter::invokedynamic_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   560
  default:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   561
    fatal(err_msg("invalid bytecode: %s", Bytecodes::name(code)));
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   562
    return NULL;
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   563
  }
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   564
}
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   565
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   566
/**
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   567
 * Returns the return entry address for the given top-of-stack state and bytecode.
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   568
 */
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   569
address TemplateInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  guarantee(0 <= length && length < Interpreter::number_of_return_entries, "illegal length");
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   571
  const int index = TosState_as_index(state);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   572
  switch (code) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   573
  case Bytecodes::_invokestatic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   574
  case Bytecodes::_invokespecial:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   575
  case Bytecodes::_invokevirtual:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   576
  case Bytecodes::_invokehandle:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   577
    return _invoke_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   578
  case Bytecodes::_invokeinterface:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   579
    return _invokeinterface_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   580
  case Bytecodes::_invokedynamic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   581
    return _invokedynamic_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   582
  default:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   583
    assert(!Bytecodes::is_invoke(code), err_msg("invoke instructions should be handled separately: %s", Bytecodes::name(code)));
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   584
    return _return_entry[length].entry(state);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   585
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
address TemplateInterpreter::deopt_entry(TosState state, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  return _deopt_entry[length].entry(state);
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
// Suport for invokes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
int TemplateInterpreter::TosState_as_index(TosState state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
  assert( state < number_of_states , "Invalid state in TosState_as_index");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  return (int)state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
// Safepoint suppport
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
static inline void copy_table(address* from, address* to, int size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  // Copy non-overlapping tables. The copy has to occur word wise for MT safety.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  while (size-- > 0) *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
void TemplateInterpreter::notice_safepoints() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
  if (!_notice_safepoints) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
    // switch to safepoint dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
    _notice_safepoints = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
    copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
// switch from the dispatch table which notices safepoints back to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
// normal dispatch table.  So that we can notice single stepping points,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
// keep the safepoint dispatch table if we are single stepping in JVMTI.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
// Note that the should_post_single_step test is exactly as fast as the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
// JvmtiExport::_enabled test and covers both cases.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
void TemplateInterpreter::ignore_safepoints() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  if (_notice_safepoints) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
    if (!JvmtiExport::should_post_single_step()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
      // switch to normal dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
      _notice_safepoints = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
      copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   635
//------------------------------------------------------------------------------------------------------------------------
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   636
// Deoptimization support
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   638
// If deoptimization happens, this function returns the point of next bytecode to continue execution
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   639
address TemplateInterpreter::deopt_continue_after_entry(Method* method, address bcp, int callee_parameters, bool is_top_frame) {
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   640
  return AbstractInterpreter::deopt_continue_after_entry(method, bcp, callee_parameters, is_top_frame);
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   641
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   643
// If deoptimization happens, this function returns the point where the interpreter reexecutes
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   644
// the bytecode.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   645
// Note: Bytecodes::_athrow (C1 only) and Bytecodes::_return are the special cases
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   646
//       that do not return "Interpreter::deopt_entry(vtos, 0)"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
   647
address TemplateInterpreter::deopt_reexecute_entry(Method* method, address bcp) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  assert(method->contains(bcp), "just checkin'");
7913
dd096a83bdbb 4926272: methodOopDesc::method_from_bcp is unsafe
never
parents: 7397
diff changeset
   649
  Bytecodes::Code code   = Bytecodes::java_code_at(method, bcp);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  if (code == Bytecodes::_return) {
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   651
    // This is used for deopt during registration of finalizers
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   652
    // during Object.<init>.  We simply need to resume execution at
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   653
    // the standard return vtos bytecode to pop the frame normally.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   654
    // reexecuting the real bytecode would cause double registration
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   655
    // of the finalizable object.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   656
    return _normal_table.entry(Bytecodes::_return).entry(vtos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  } else {
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   658
    return AbstractInterpreter::deopt_reexecute_entry(method, bcp);
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   659
  }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   660
}
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   661
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   662
// If deoptimization happens, the interpreter should reexecute this bytecode.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   663
// This function mainly helps the compilers to set up the reexecute bit.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   664
bool TemplateInterpreter::bytecode_should_reexecute(Bytecodes::Code code) {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   665
  if (code == Bytecodes::_return) {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   666
    //Yes, we consider Bytecodes::_return as a special case of reexecution
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   667
    return true;
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   668
  } else {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   669
    return AbstractInterpreter::bytecode_should_reexecute(code);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
#endif // !CC_INTERP