annotate src/share/vm/interpreter/interpreter.hpp @ 3992:d1bdeef3e3e2

7098282: G1: assert(interval >= 0) failed: Sanity check, referencePolicy.cpp: 76 Summary: There is a race between one thread successfully forwarding and copying the klass mirror for the SoftReference class (including the static master clock) and another thread attempting to use the master clock while attempting to discover a soft reference object. Maintain a shadow copy of the soft reference master clock and use the shadow during reference discovery and reference processing. Reviewed-by: tonyp, brutisso, ysr
author johnc
date Wed, 12 Oct 2011 10:25:51 -0700
parents 1d1603768966
children b31471cdc53e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 605
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
25 #ifndef SHARE_VM_INTERPRETER_INTERPRETER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
26 #define SHARE_VM_INTERPRETER_INTERPRETER_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
28 #include "code/stubs.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
29 #include "interpreter/cppInterpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
30 #include "interpreter/templateInterpreter.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
31 #ifdef ZERO
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
32 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
33 # include "entry_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
34 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
35 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
36
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
37 // This file contains the platform-independent parts
0
a61af66fc99e Initial load
duke
parents:
diff changeset
38 // of the interpreter and the interpreter generator.
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // An InterpreterCodelet is a piece of interpreter code. All
a61af66fc99e Initial load
duke
parents:
diff changeset
42 // interpreter code is generated into little codelets which
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // contain extra information for debugging and printing purposes.
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 class InterpreterCodelet: public Stub {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
47 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 int _size; // the size in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
49 const char* _description; // a description of the codelet, for debugging & printing
a61af66fc99e Initial load
duke
parents:
diff changeset
50 Bytecodes::Code _bytecode; // associated bytecode if any
a61af66fc99e Initial load
duke
parents:
diff changeset
51
a61af66fc99e Initial load
duke
parents:
diff changeset
52 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Initialization/finalization
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void initialize(int size) { _size = size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void finalize() { ShouldNotCallThis(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // General info/converters
a61af66fc99e Initial load
duke
parents:
diff changeset
58 int size() const { return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 static int code_size_to_size(int code_size) { return round_to(sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // Code info
a61af66fc99e Initial load
duke
parents:
diff changeset
62 address code_begin() const { return (address)this + round_to(sizeof(InterpreterCodelet), CodeEntryAlignment); }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 address code_end() const { return (address)this + size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
66 void verify();
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
67 void print_on(outputStream* st) const;
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
68 void print() const { print_on(tty); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // Interpreter-specific initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
71 void initialize(const char* description, Bytecodes::Code bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
72
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // Interpreter-specific attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
74 int code_size() const { return code_end() - code_begin(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
75 const char* description() const { return _description; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 Bytecodes::Code bytecode() const { return _bytecode; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 };
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Define a prototype interface
a61af66fc99e Initial load
duke
parents:
diff changeset
80 DEF_STUB_INTERFACE(InterpreterCodelet);
a61af66fc99e Initial load
duke
parents:
diff changeset
81
a61af66fc99e Initial load
duke
parents:
diff changeset
82
a61af66fc99e Initial load
duke
parents:
diff changeset
83 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
84 // A CodeletMark serves as an automatic creator/initializer for Codelets
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // (As a subclass of ResourceMark it automatically GC's the allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // code buffer and assemblers).
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 class CodeletMark: ResourceMark {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 InterpreterCodelet* _clet;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 InterpreterMacroAssembler** _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 CodeBuffer _cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
93
a61af66fc99e Initial load
duke
parents:
diff changeset
94 int codelet_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 // Request the whole code buffer (minus a little for alignment).
a61af66fc99e Initial load
duke
parents:
diff changeset
96 // The commit call below trims it back for each codelet.
a61af66fc99e Initial load
duke
parents:
diff changeset
97 int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 // Guarantee there's a little bit of code space left.
a61af66fc99e Initial load
duke
parents:
diff changeset
100 guarantee (codelet_size > 0 && (size_t)codelet_size > 2*K,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "not enough space for interpreter generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 return codelet_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
107 CodeletMark(
a61af66fc99e Initial load
duke
parents:
diff changeset
108 InterpreterMacroAssembler*& masm,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 const char* description,
a61af66fc99e Initial load
duke
parents:
diff changeset
110 Bytecodes::Code bytecode = Bytecodes::_illegal):
a61af66fc99e Initial load
duke
parents:
diff changeset
111 _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
a61af66fc99e Initial load
duke
parents:
diff changeset
112 _cb(_clet->code_begin(), _clet->code_size())
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 { // request all space (add some slack for Codelet data)
a61af66fc99e Initial load
duke
parents:
diff changeset
115 assert (_clet != NULL, "we checked not enough space already");
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // initialize Codelet attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
118 _clet->initialize(description, bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 // create assembler for code generation
a61af66fc99e Initial load
duke
parents:
diff changeset
120 masm = new InterpreterMacroAssembler(&_cb);
a61af66fc99e Initial load
duke
parents:
diff changeset
121 _masm = &masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 ~CodeletMark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // align so printing shows nop's instead of random code at the end (Codelets are aligned)
a61af66fc99e Initial load
duke
parents:
diff changeset
126 (*_masm)->align(wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
127 // make sure all code is in code buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
128 (*_masm)->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // commit Codelet
1748
3e8fbc61cee8 6978355: renaming for 6961697
twisti
parents: 1681
diff changeset
132 AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size());
0
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // make sure nobody can use _masm outside a CodeletMark lifespan
a61af66fc99e Initial load
duke
parents:
diff changeset
134 *_masm = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
135 }
a61af66fc99e Initial load
duke
parents:
diff changeset
136 };
a61af66fc99e Initial load
duke
parents:
diff changeset
137
a61af66fc99e Initial load
duke
parents:
diff changeset
138 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
a61af66fc99e Initial load
duke
parents:
diff changeset
139 // the c++ interpreter or the template interpreter.
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Debugging/printing
a61af66fc99e Initial load
duke
parents:
diff changeset
145 static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); }
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
146 #ifdef TARGET_ARCH_x86
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
147 # include "interpreter_x86.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
148 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
149 #ifdef TARGET_ARCH_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
150 # include "interpreter_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
151 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
152 #ifdef TARGET_ARCH_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
153 # include "interpreter_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
154 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
155 #ifdef TARGET_ARCH_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
156 # include "interpreter_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
157 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
158 #ifdef TARGET_ARCH_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
159 # include "interpreter_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
160 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
161
0
a61af66fc99e Initial load
duke
parents:
diff changeset
162 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
163
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1748
diff changeset
164 #endif // SHARE_VM_INTERPRETER_INTERPRETER_HPP