hotspot/src/share/vm/interpreter/cppInterpreter.cpp
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 1 489c9b5090e2
child 2534 08dac9ce0cd7
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1997-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
#include "incls/_precompiled.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
#include "incls/_cppInterpreter.cpp.incl"
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
#ifdef CC_INTERP
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
# define __ _masm->
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
void CppInterpreter::initialize() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
  if (_code != NULL) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  AbstractInterpreter::initialize();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  // generate interpreter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
  { ResourceMark rm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
    TraceTime timer("Interpreter generation", TraceStartupTime);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
    int code_size = InterpreterCodeSize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
    NOT_PRODUCT(code_size *= 4;)  // debug uses extra interpreter code space
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
    _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
                          "Interpreter");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
    InterpreterGenerator g(_code);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
    if (PrintInterpreter) print();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  // Allow c++ interpreter to do one initialization now that switches are set, etc.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
  if (JvmtiExport::can_post_interpreter_events())
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    BytecodeInterpreter::runWithChecks(&start_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  else
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
    BytecodeInterpreter::run(&start_msg);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
address    CppInterpreter::_tosca_to_stack         [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
address    CppInterpreter::_stack_to_stack         [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
address    CppInterpreter::_stack_to_native_abi    [AbstractInterpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
static const BasicType types[Interpreter::number_of_result_handlers] = {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  T_BOOLEAN,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  T_CHAR   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  T_BYTE   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  T_SHORT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  T_INT    ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  T_LONG   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  T_VOID   ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  T_FLOAT  ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  T_DOUBLE ,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  T_OBJECT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
void CppInterpreterGenerator::generate_all() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  AbstractInterpreterGenerator::generate_all();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  { CodeletMark cm(_masm, "result handlers for native calls");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    // The various result converter stublets.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    int is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
    memset(is_generated, 0, sizeof(is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
    int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
    int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
    memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
    memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
    memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated));
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
      BasicType type = types[i];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
      if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
        Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
      if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
        Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
      if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
        Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
      if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
        Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
#define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  { CodeletMark cm(_masm, "(kind = frame_manager)");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    // all non-native method kinds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
    method_entry(zerolocals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
    method_entry(zerolocals_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
    method_entry(empty);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
    method_entry(accessor);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
    method_entry(abstract);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
    method_entry(java_lang_math_sin   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    method_entry(java_lang_math_cos   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
    method_entry(java_lang_math_tan   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
    method_entry(java_lang_math_abs   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
    method_entry(java_lang_math_sqrt  );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
    method_entry(java_lang_math_log   );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
    method_entry(java_lang_math_log10 );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
    Interpreter::_native_entry_begin = Interpreter::code()->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
    method_entry(native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
    method_entry(native_synchronized);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
    Interpreter::_native_entry_end = Interpreter::code()->code_end();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
#undef method_entry
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
#endif // CC_INTERP