src/hotspot/share/interpreter/templateInterpreter.cpp
author dlong
Tue, 21 Nov 2017 09:04:42 -0800
changeset 47916 bdbef8638948
parent 47688 3d1e3786d66e
child 55608 47af68c44e02
child 58678 9cf78a70fa4f
permissions -rw-r--r--
8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs Reviewed-by: vlivanov, dpochepk
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
     2
 * Copyright (c) 1997, 2017, 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/interpreterRuntime.hpp"
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    28
#include "interpreter/interp_masm.hpp"
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    29
#include "interpreter/templateInterpreter.hpp"
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
    30
#include "interpreter/templateInterpreterGenerator.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    31
#include "interpreter/templateTable.hpp"
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
    32
#include "memory/resourceArea.hpp"
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 36178
diff changeset
    33
#include "runtime/timerTrace.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
#ifndef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
# define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
void TemplateInterpreter::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  if (_code != NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  // assertions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
  assert((int)Bytecodes::number_of_codes <= (int)DispatchTable::length,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
         "dispatch table too small");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  AbstractInterpreter::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  TemplateTable::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  // generate interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  { ResourceMark rm;
37161
e881f320966e 8150015: Integrate TraceTime with Unified Logging more seamlessly
rehn
parents: 36178
diff changeset
    51
    TraceTime timer("Interpreter generation", TRACETIME_LOG(Info, startuptime));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    int code_size = InterpreterCodeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
    _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
                          "Interpreter");
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
    56
    TemplateInterpreterGenerator g(_code);
47688
3d1e3786d66e 8166317: InterpreterCodeSize should be computed
simonis
parents: 47216
diff changeset
    57
    // Free the unused memory not occupied by the interpreter and the stubs
3d1e3786d66e 8166317: InterpreterCodeSize should be computed
simonis
parents: 47216
diff changeset
    58
    _code->deallocate_unused_tail();
31620
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 25950
diff changeset
    59
  }
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 25950
diff changeset
    60
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 25950
diff changeset
    61
  if (PrintInterpreter) {
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 25950
diff changeset
    62
    ResourceMark rm;
53be635ad49c 8087333: Optionally Pre-Generate the HotSpot Template Interpreter
bdelsart
parents: 25950
diff changeset
    63
    print();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // initialize dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  _active_table = _normal_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
// Implementation of EntryPoint
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
EntryPoint::EntryPoint() {
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
    74
  assert(number_of_states == 10, "check the code below");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  _entry[btos] = NULL;
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
    76
  _entry[ztos] = NULL;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  _entry[ctos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  _entry[stos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  _entry[atos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  _entry[itos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  _entry[ltos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  _entry[ftos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  _entry[dtos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  _entry[vtos] = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
    88
EntryPoint::EntryPoint(address bentry, address zentry, address centry, address sentry, address aentry, address ientry, address lentry, address fentry, address dentry, address ventry) {
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
    89
  assert(number_of_states == 10, "check the code below");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  _entry[btos] = bentry;
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
    91
  _entry[ztos] = zentry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  _entry[ctos] = centry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  _entry[stos] = sentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  _entry[atos] = aentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  _entry[itos] = ientry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  _entry[ltos] = lentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  _entry[ftos] = fentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  _entry[dtos] = dentry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  _entry[vtos] = ventry;
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::set_entry(TosState state, address entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  assert(0 <= state && state < number_of_states, "state out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  _entry[state] = entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
address EntryPoint::entry(TosState state) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  assert(0 <= state && state < number_of_states, "state out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  return _entry[state];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
void EntryPoint::print() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  tty->print("[");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  for (int i = 0; i < number_of_states; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    if (i > 0) tty->print(", ");
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 21198
diff changeset
   119
    tty->print(INTPTR_FORMAT, p2i(_entry[i]));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  tty->print("]");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
bool EntryPoint::operator == (const EntryPoint& y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  int i = number_of_states;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    if (_entry[i] != y._entry[i]) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
// Implementation of DispatchTable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
EntryPoint DispatchTable::entry(int i) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  assert(0 <= i && i < length, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
    EntryPoint(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
      _table[btos][i],
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
   142
      _table[ztos][i],
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
      _table[ctos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
      _table[stos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
      _table[atos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
      _table[itos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
      _table[ltos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
      _table[ftos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
      _table[dtos][i],
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
      _table[vtos][i]
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
void DispatchTable::set_entry(int i, EntryPoint& entry) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  assert(0 <= i && i < length, "index out of bounds");
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
   157
  assert(number_of_states == 10, "check the code below");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  _table[btos][i] = entry.entry(btos);
37480
291ee208fb72 8132051: Better byte behavior
coleenp
parents: 37161
diff changeset
   159
  _table[ztos][i] = entry.entry(ztos);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  _table[ctos][i] = entry.entry(ctos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  _table[stos][i] = entry.entry(stos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  _table[atos][i] = entry.entry(atos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  _table[itos][i] = entry.entry(itos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  _table[ltos][i] = entry.entry(ltos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  _table[ftos][i] = entry.entry(ftos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  _table[dtos][i] = entry.entry(dtos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  _table[vtos][i] = entry.entry(vtos);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
bool DispatchTable::operator == (DispatchTable& y) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  int i = length;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  while (i-- > 0) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
    EntryPoint t = y.entry(i); // for compiler compatibility (BugId 4150096)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
    if (!(entry(i) == t)) return false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  return true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
address    TemplateInterpreter::_remove_activation_entry                    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
address    TemplateInterpreter::_remove_activation_preserving_args_entry    = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
address    TemplateInterpreter::_throw_ArrayIndexOutOfBoundsException_entry = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
address    TemplateInterpreter::_throw_ArrayStoreException_entry            = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
address    TemplateInterpreter::_throw_ArithmeticException_entry            = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
address    TemplateInterpreter::_throw_ClassCastException_entry             = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
address    TemplateInterpreter::_throw_NullPointerException_entry           = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
address    TemplateInterpreter::_throw_StackOverflowError_entry             = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
address    TemplateInterpreter::_throw_exception_entry                      = NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
EntryPoint TemplateInterpreter::_trace_code;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
#endif // !PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
EntryPoint TemplateInterpreter::_return_entry[TemplateInterpreter::number_of_return_entries];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
EntryPoint TemplateInterpreter::_earlyret_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
EntryPoint TemplateInterpreter::_deopt_entry [TemplateInterpreter::number_of_deopt_entries ];
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   198
address    TemplateInterpreter::_deopt_reexecute_return_entry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
EntryPoint TemplateInterpreter::_safept_entry;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   201
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
   202
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
   203
address TemplateInterpreter::_invokedynamic_return_entry[TemplateInterpreter::number_of_return_addrs];
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
DispatchTable TemplateInterpreter::_active_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
DispatchTable TemplateInterpreter::_normal_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
DispatchTable TemplateInterpreter::_safept_table;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
address    TemplateInterpreter::_wentry_point[DispatchTable::length];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
// Entry points
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   214
/**
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   215
 * 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
   216
 */
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   217
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
   218
  switch (code) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   219
  case Bytecodes::_invokestatic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   220
  case Bytecodes::_invokespecial:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   221
  case Bytecodes::_invokevirtual:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   222
  case Bytecodes::_invokehandle:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   223
    return Interpreter::invoke_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   224
  case Bytecodes::_invokeinterface:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   225
    return Interpreter::invokeinterface_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   226
  case Bytecodes::_invokedynamic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   227
    return Interpreter::invokedynamic_return_entry_table();
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   228
  default:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32391
diff changeset
   229
    fatal("invalid bytecode: %s", Bytecodes::name(code));
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   230
    return NULL;
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   231
  }
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   232
}
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   233
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   234
/**
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   235
 * 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
   236
 */
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   237
address TemplateInterpreter::return_entry(TosState state, int length, Bytecodes::Code code) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  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
   239
  const int index = TosState_as_index(state);
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   240
  switch (code) {
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   241
  case Bytecodes::_invokestatic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   242
  case Bytecodes::_invokespecial:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   243
  case Bytecodes::_invokevirtual:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   244
  case Bytecodes::_invokehandle:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   245
    return _invoke_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   246
  case Bytecodes::_invokeinterface:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   247
    return _invokeinterface_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   248
  case Bytecodes::_invokedynamic:
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   249
    return _invokedynamic_return_entry[index];
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   250
  default:
33105
294e48b4f704 8080775: Better argument formatting for assert() and friends
david
parents: 32391
diff changeset
   251
    assert(!Bytecodes::is_invoke(code), "invoke instructions should be handled separately: %s", Bytecodes::name(code));
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   252
    address entry = _return_entry[length].entry(state);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   253
    vmassert(entry != NULL, "unsupported return entry requested, length=%d state=%d", length, index);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   254
    return entry;
21198
dd647e8d1d72 8026328: Setting a breakpoint on invokedynamic crashes the JVM
twisti
parents: 18507
diff changeset
   255
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
address TemplateInterpreter::deopt_entry(TosState state, int length) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  guarantee(0 <= length && length < Interpreter::number_of_deopt_entries, "illegal length");
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   261
  address entry = _deopt_entry[length].entry(state);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   262
  vmassert(entry != NULL, "unsupported deopt entry requested, length=%d state=%d", length, TosState_as_index(state));
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   263
  return entry;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
// Suport for invokes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
int TemplateInterpreter::TosState_as_index(TosState state) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  assert( state < number_of_states , "Invalid state in TosState_as_index");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  assert(0 <= (int)state && (int)state < TemplateInterpreter::number_of_return_addrs, "index out of bounds");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  return (int)state;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
// Safepoint suppport
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
static inline void copy_table(address* from, address* to, int size) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  // Copy non-overlapping tables. The copy has to occur word wise for MT safety.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  while (size-- > 0) *to++ = *from++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
void TemplateInterpreter::notice_safepoints() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  if (!_notice_safepoints) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
    // switch to safepoint dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
    _notice_safepoints = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
    copy_table((address*)&_safept_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
// switch from the dispatch table which notices safepoints back to the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
// normal dispatch table.  So that we can notice single stepping points,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
// keep the safepoint dispatch table if we are single stepping in JVMTI.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
// Note that the should_post_single_step test is exactly as fast as the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
// JvmtiExport::_enabled test and covers both cases.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
void TemplateInterpreter::ignore_safepoints() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  if (_notice_safepoints) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
    if (!JvmtiExport::should_post_single_step()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
      // switch to normal dispatch table
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
      _notice_safepoints = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
      copy_table((address*)&_normal_table, (address*)&_active_table, sizeof(_active_table) / sizeof(address));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   307
//------------------------------------------------------------------------------------------------------------------------
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   308
// Deoptimization support
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   310
// 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
   311
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
   312
  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
   313
}
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   315
// 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
   316
// the bytecode.
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   317
// 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
   318
//       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
   319
address TemplateInterpreter::deopt_reexecute_entry(Method* method, address bcp) {
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  assert(method->contains(bcp), "just checkin'");
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   321
  Bytecodes::Code code   = Bytecodes::code_at(method, bcp);
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   322
  if (code == Bytecodes::_return_register_finalizer) {
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   323
    // 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
   324
    // 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
   325
    // 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
   326
    // 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
   327
    // of the finalizable object.
47916
bdbef8638948 8190817: deopt special-case for _return_register_finalizer is confusing and leads to bugs
dlong
parents: 47688
diff changeset
   328
    return Interpreter::deopt_reexecute_return_entry();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  } else {
3600
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   330
    return AbstractInterpreter::deopt_reexecute_entry(method, bcp);
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   331
  }
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   332
}
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   333
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   334
// 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
   335
// 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
   336
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
   337
  if (code == Bytecodes::_return) {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   338
    //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
   339
    return true;
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   340
  } else {
27aa4477d039 6833129: specjvm98 fails with NullPointerException in the compiler with -XX:DeoptimizeALot
cfang
parents: 2570
diff changeset
   341
    return AbstractInterpreter::bytecode_should_reexecute(code);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
35214
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
   345
InterpreterCodelet* TemplateInterpreter::codelet_containing(address pc) {
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
   346
  return (InterpreterCodelet*)_code->stub_containing(pc);
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
   347
}
d86005e0b4c2 8074457: Remove the non-Zero CPP Interpreter
coleenp
parents: 33589
diff changeset
   348
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
#endif // !CC_INTERP