annotate src/share/vm/interpreter/cppInterpreter.cpp @ 654:c664a0794f85

6805748: Assertion "don't reset to 0 -- could be mistaken for never-executed" in CompilationPolicy Summary: Resetting the invocation counter for a method invocation event was setting count to zero for CompileThreshold=1, making it look like a never executed method. Reviewed-by: phh, kamg, acorn, never
author coleenp
date Fri, 20 Mar 2009 22:08:48 -0400
parents a61af66fc99e
children e5b0439ef4ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 #include "incls/_precompiled.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
26 #include "incls/_cppInterpreter.cpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 #ifdef CC_INTERP
a61af66fc99e Initial load
duke
parents:
diff changeset
29 # define __ _masm->
a61af66fc99e Initial load
duke
parents:
diff changeset
30
a61af66fc99e Initial load
duke
parents:
diff changeset
31 void CppInterpreter::initialize() {
a61af66fc99e Initial load
duke
parents:
diff changeset
32 if (_code != NULL) return;
a61af66fc99e Initial load
duke
parents:
diff changeset
33 AbstractInterpreter::initialize();
a61af66fc99e Initial load
duke
parents:
diff changeset
34
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // generate interpreter
a61af66fc99e Initial load
duke
parents:
diff changeset
36 { ResourceMark rm;
a61af66fc99e Initial load
duke
parents:
diff changeset
37 TraceTime timer("Interpreter generation", TraceStartupTime);
a61af66fc99e Initial load
duke
parents:
diff changeset
38 int code_size = InterpreterCodeSize;
a61af66fc99e Initial load
duke
parents:
diff changeset
39 NOT_PRODUCT(code_size *= 4;) // debug uses extra interpreter code space
a61af66fc99e Initial load
duke
parents:
diff changeset
40 _code = new StubQueue(new InterpreterCodeletInterface, code_size, NULL,
a61af66fc99e Initial load
duke
parents:
diff changeset
41 "Interpreter");
a61af66fc99e Initial load
duke
parents:
diff changeset
42 InterpreterGenerator g(_code);
a61af66fc99e Initial load
duke
parents:
diff changeset
43 if (PrintInterpreter) print();
a61af66fc99e Initial load
duke
parents:
diff changeset
44 }
a61af66fc99e Initial load
duke
parents:
diff changeset
45
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // Allow c++ interpreter to do one initialization now that switches are set, etc.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 BytecodeInterpreter start_msg(BytecodeInterpreter::initialize);
a61af66fc99e Initial load
duke
parents:
diff changeset
49 if (JvmtiExport::can_post_interpreter_events())
a61af66fc99e Initial load
duke
parents:
diff changeset
50 BytecodeInterpreter::runWithChecks(&start_msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
51 else
a61af66fc99e Initial load
duke
parents:
diff changeset
52 BytecodeInterpreter::run(&start_msg);
a61af66fc99e Initial load
duke
parents:
diff changeset
53 }
a61af66fc99e Initial load
duke
parents:
diff changeset
54
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 address CppInterpreter::_tosca_to_stack [AbstractInterpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
57 address CppInterpreter::_stack_to_stack [AbstractInterpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
58 address CppInterpreter::_stack_to_native_abi [AbstractInterpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 CppInterpreterGenerator::CppInterpreterGenerator(StubQueue* _code): AbstractInterpreterGenerator(_code) {
a61af66fc99e Initial load
duke
parents:
diff changeset
61 }
a61af66fc99e Initial load
duke
parents:
diff changeset
62
a61af66fc99e Initial load
duke
parents:
diff changeset
63 static const BasicType types[Interpreter::number_of_result_handlers] = {
a61af66fc99e Initial load
duke
parents:
diff changeset
64 T_BOOLEAN,
a61af66fc99e Initial load
duke
parents:
diff changeset
65 T_CHAR ,
a61af66fc99e Initial load
duke
parents:
diff changeset
66 T_BYTE ,
a61af66fc99e Initial load
duke
parents:
diff changeset
67 T_SHORT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
68 T_INT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
69 T_LONG ,
a61af66fc99e Initial load
duke
parents:
diff changeset
70 T_VOID ,
a61af66fc99e Initial load
duke
parents:
diff changeset
71 T_FLOAT ,
a61af66fc99e Initial load
duke
parents:
diff changeset
72 T_DOUBLE ,
a61af66fc99e Initial load
duke
parents:
diff changeset
73 T_OBJECT
a61af66fc99e Initial load
duke
parents:
diff changeset
74 };
a61af66fc99e Initial load
duke
parents:
diff changeset
75
a61af66fc99e Initial load
duke
parents:
diff changeset
76 void CppInterpreterGenerator::generate_all() {
a61af66fc99e Initial load
duke
parents:
diff changeset
77 AbstractInterpreterGenerator::generate_all();
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 { CodeletMark cm(_masm, "result handlers for native calls");
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // The various result converter stublets.
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int is_generated[Interpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
82 memset(is_generated, 0, sizeof(is_generated));
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int _tosca_to_stack_is_generated[Interpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int _stack_to_stack_is_generated[Interpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
85 int _stack_to_native_abi_is_generated[Interpreter::number_of_result_handlers];
a61af66fc99e Initial load
duke
parents:
diff changeset
86
a61af66fc99e Initial load
duke
parents:
diff changeset
87 memset(_tosca_to_stack_is_generated, 0, sizeof(_tosca_to_stack_is_generated));
a61af66fc99e Initial load
duke
parents:
diff changeset
88 memset(_stack_to_stack_is_generated, 0, sizeof(_stack_to_stack_is_generated));
a61af66fc99e Initial load
duke
parents:
diff changeset
89 memset(_stack_to_native_abi_is_generated, 0, sizeof(_stack_to_native_abi_is_generated));
a61af66fc99e Initial load
duke
parents:
diff changeset
90 for (int i = 0; i < Interpreter::number_of_result_handlers; i++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 BasicType type = types[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
92 if (!is_generated[Interpreter::BasicType_as_index(type)]++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
93 Interpreter::_native_abi_to_tosca[Interpreter::BasicType_as_index(type)] = generate_result_handler_for(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
94 }
a61af66fc99e Initial load
duke
parents:
diff changeset
95 if (!_tosca_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 Interpreter::_tosca_to_stack[Interpreter::BasicType_as_index(type)] = generate_tosca_to_stack_converter(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if (!_stack_to_stack_is_generated[Interpreter::BasicType_as_index(type)]++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 Interpreter::_stack_to_stack[Interpreter::BasicType_as_index(type)] = generate_stack_to_stack_converter(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
100 }
a61af66fc99e Initial load
duke
parents:
diff changeset
101 if (!_stack_to_native_abi_is_generated[Interpreter::BasicType_as_index(type)]++) {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 Interpreter::_stack_to_native_abi[Interpreter::BasicType_as_index(type)] = generate_stack_to_native_abi_converter(type);
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 }
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 #define method_entry(kind) Interpreter::_entry_table[Interpreter::kind] = generate_method_entry(Interpreter::kind)
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 { CodeletMark cm(_masm, "(kind = frame_manager)");
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // all non-native method kinds
a61af66fc99e Initial load
duke
parents:
diff changeset
112 method_entry(zerolocals);
a61af66fc99e Initial load
duke
parents:
diff changeset
113 method_entry(zerolocals_synchronized);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 method_entry(empty);
a61af66fc99e Initial load
duke
parents:
diff changeset
115 method_entry(accessor);
a61af66fc99e Initial load
duke
parents:
diff changeset
116 method_entry(abstract);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 method_entry(java_lang_math_sin );
a61af66fc99e Initial load
duke
parents:
diff changeset
118 method_entry(java_lang_math_cos );
a61af66fc99e Initial load
duke
parents:
diff changeset
119 method_entry(java_lang_math_tan );
a61af66fc99e Initial load
duke
parents:
diff changeset
120 method_entry(java_lang_math_abs );
a61af66fc99e Initial load
duke
parents:
diff changeset
121 method_entry(java_lang_math_sqrt );
a61af66fc99e Initial load
duke
parents:
diff changeset
122 method_entry(java_lang_math_log );
a61af66fc99e Initial load
duke
parents:
diff changeset
123 method_entry(java_lang_math_log10 );
a61af66fc99e Initial load
duke
parents:
diff changeset
124 Interpreter::_native_entry_begin = Interpreter::code()->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
125 method_entry(native);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 method_entry(native_synchronized);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 Interpreter::_native_entry_end = Interpreter::code()->code_end();
a61af66fc99e Initial load
duke
parents:
diff changeset
128 }
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 #undef method_entry
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133 }
a61af66fc99e Initial load
duke
parents:
diff changeset
134
a61af66fc99e Initial load
duke
parents:
diff changeset
135 #endif // CC_INTERP