hotspot/src/share/vm/interpreter/cppInterpreter.cpp
author stefank
Tue, 23 Nov 2010 13:22:55 -0800
changeset 7397 5b173b4ca846
parent 5547 f4b087cbb361
child 9176 42d9d1010f38
permissions -rw-r--r--
6989984: Use standard include model for Hospot Summary: Replaced MakeDeps and the includeDB files with more standardized solutions. Reviewed-by: coleenp, kvn, kamg
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1997, 2010, 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: 2534
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2534
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: 2534
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/bytecodeInterpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
#include "interpreter/interpreter.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "interpreter/interpreterGenerator.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "interpreter/interpreterRuntime.hpp"
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
# define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
void CppInterpreter::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  if (_code != NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  AbstractInterpreter::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
  // generate interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  { ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    TraceTime timer("Interpreter generation", TraceStartupTime);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
    int code_size = InterpreterCodeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
                          "Interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    InterpreterGenerator g(_code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    if (PrintInterpreter) print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // Allow c++ interpreter to do one initialization now that switches are set, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  if (JvmtiExport::can_post_interpreter_events())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
    BytecodeInterpreter::runWithChecks(&start_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
    BytecodeInterpreter::run(&start_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
address    CppInterpreter::_tosca_to_stack         [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
address    CppInterpreter::_stack_to_stack         [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
address    CppInterpreter::_stack_to_native_abi    [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
static const BasicType types[Interpreter::number_of_result_handlers] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  T_BOOLEAN,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  T_CHAR   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  T_BYTE   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  T_SHORT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  T_INT    ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  T_LONG   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  T_VOID   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  T_FLOAT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  T_DOUBLE ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  T_OBJECT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
void CppInterpreterGenerator::generate_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  AbstractInterpreterGenerator::generate_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  { CodeletMark cm(_masm, "result handlers for native calls");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    // The various result converter stublets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    int is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    memset(is_generated, 0, sizeof(is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
    memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      BasicType type = types[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
      if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
        Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type);
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  { CodeletMark cm(_masm, "(kind = frame_manager)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    // all non-native method kinds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    method_entry(zerolocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    method_entry(zerolocals_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    method_entry(empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    method_entry(accessor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    method_entry(abstract);
2534
08dac9ce0cd7 6655638: dynamic languages need method handles
jrose
parents: 1
diff changeset
   120
    method_entry(method_handle);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    method_entry(java_lang_math_sin   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    method_entry(java_lang_math_cos   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    method_entry(java_lang_math_tan   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    method_entry(java_lang_math_abs   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    method_entry(java_lang_math_sqrt  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    method_entry(java_lang_math_log   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    method_entry(java_lang_math_log10 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
    Interpreter::_native_entry_begin = Interpreter::code()->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
    method_entry(native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    method_entry(native_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    Interpreter::_native_entry_end = Interpreter::code()->code_end();
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
#undef method_entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
#endif // CC_INTERP