hotspot/src/share/vm/interpreter/interpreter.cpp
author coleenp
Wed, 09 Aug 2017 19:00:54 -0400
changeset 46783 bfa353c0d440
parent 35479 62c12ca7a45e
permissions -rw-r--r--
8068317: No_Safepoint_Verifier is not necessary in Rewriter::scan_method Summary: remove NSV, Method* can't move or be redefined while being rewritten Reviewed-by: shade, jiangli
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
35479
62c12ca7a45e 8146410: Interpreter functions are declared and defined in the wrong files
coleenp
parents: 35214
diff changeset
     2
 * Copyright (c) 1997, 2016, 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: 4564
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 4564
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: 4564
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: 6176
diff changeset
    25
#include "precompiled.hpp"
14626
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 14294
diff changeset
    26
#include "asm/macroAssembler.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 14294
diff changeset
    27
#include "asm/macroAssembler.inline.hpp"
0cf4eccf130f 8003240: x86: move MacroAssembler into separate file
twisti
parents: 14294
diff changeset
    28
#include "compiler/disassembler.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    29
#include "interpreter/bytecodeHistogram.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    30
#include "interpreter/bytecodeInterpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    31
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    32
#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
    33
#include "interpreter/interp_masm.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    34
#include "interpreter/templateTable.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    35
#include "memory/allocation.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    36
#include "memory/resourceArea.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    37
#include "oops/arrayOop.hpp"
13728
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    38
#include "oops/methodData.hpp"
882756847a04 6964458: Reimplement class meta-data storage to use native memory
coleenp
parents: 13391
diff changeset
    39
#include "oops/method.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    40
#include "oops/oop.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    41
#include "prims/forte.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    42
#include "prims/jvmtiExport.hpp"
13391
30245956af37 7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents: 12739
diff changeset
    43
#include "prims/methodHandles.hpp"
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    44
#include "runtime/handles.inline.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    45
#include "runtime/sharedRuntime.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    46
#include "runtime/stubRoutines.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 6176
diff changeset
    47
#include "runtime/timer.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
# define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
//------------------------------------------------------------------------------------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// Implementation of InterpreterCodelet
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
void InterpreterCodelet::initialize(const char* description, Bytecodes::Code bytecode) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  _description       = description;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  _bytecode          = bytecode;
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
void InterpreterCodelet::verify() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    65
void InterpreterCodelet::print_on(outputStream* st) const {
13887
89b873bcc55b 7200163: add CodeComments functionality to assember stubs
kvn
parents: 13728
diff changeset
    66
  ttyLocker ttyl;
89b873bcc55b 7200163: add CodeComments functionality to assember stubs
kvn
parents: 13728
diff changeset
    67
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  if (PrintInterpreter) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    69
    st->cr();
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    70
    st->print_cr("----------------------------------------------------------------------");
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    73
  if (description() != NULL) st->print("%s  ", description());
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    74
  if (bytecode()    >= 0   ) st->print("%d %s  ", bytecode(), Bytecodes::name(bytecode()));
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    75
  st->print_cr("[" INTPTR_FORMAT ", " INTPTR_FORMAT "]  %d bytes",
24424
2658d7834c6e 8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents: 21198
diff changeset
    76
                p2i(code_begin()), p2i(code_end()), code_size());
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  if (PrintInterpreter) {
6176
4d9030fe341f 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 5924
diff changeset
    79
    st->cr();
16368
713209c45a82 8008555: Debugging code in compiled method sometimes leaks memory
roland
parents: 14626
diff changeset
    80
    Disassembler::decode(code_begin(), code_end(), st, DEBUG_ONLY(_strings) NOT_DEBUG(CodeStrings()));
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    84
CodeletMark::CodeletMark(InterpreterMacroAssembler*& masm,
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    85
                         const char* description,
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    86
                         Bytecodes::Code bytecode) :
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    87
  _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    88
  _cb(_clet->code_begin(), _clet->code_size()) {
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    89
  // Request all space (add some slack for Codelet data).
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    90
  assert(_clet != NULL, "we checked not enough space already");
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    91
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    92
  // Initialize Codelet attributes.
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    93
  _clet->initialize(description, bytecode);
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    94
  // Create assembler for code generation.
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    95
  masm = new InterpreterMacroAssembler(&_cb);
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    96
  _masm = &masm;
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    97
}
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    98
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
    99
CodeletMark::~CodeletMark() {
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   100
  // Align so printing shows nop's instead of random code at the end (Codelets are aligned).
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   101
  (*_masm)->align(wordSize);
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   102
  // Make sure all code is in code buffer.
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   103
  (*_masm)->flush();
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   104
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   105
  // Commit Codelet.
33070
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 33066
diff changeset
   106
  int committed_code_size = (*_masm)->code()->pure_insts_size();
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 33066
diff changeset
   107
  if (committed_code_size) {
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 33066
diff changeset
   108
    AbstractInterpreter::code()->commit(committed_code_size, (*_masm)->code()->strings());
54f3f085b165 8136525: Generate interpreter entries only once and avoid unnecessary jump to jump
mdoerr
parents: 33066
diff changeset
   109
  }
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   110
  // Make sure nobody can use _masm outside a CodeletMark lifespan.
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   111
  *_masm = NULL;
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24424
diff changeset
   112
}
1
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 interpreter_init() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  Interpreter::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  if (TraceBytecodes) BytecodeTracer::set_closure(BytecodeTracer::std_closure());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
#endif // PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // need to hit every safepoint in order to call zapping routine
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  // register the interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  Forte::register_stub(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    "Interpreter",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    AbstractInterpreter::code()->code_start(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    AbstractInterpreter::code()->code_end()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // notify JVMTI profiler
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  if (JvmtiExport::should_post_dynamic_code_generated()) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    JvmtiExport::post_dynamic_code_generated("Interpreter",
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
                                             AbstractInterpreter::code()->code_start(),
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
                                             AbstractInterpreter::code()->code_end());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
}