Mercurial > hg > truffle
annotate src/share/vm/interpreter/interpreter.hpp @ 2831:f072013daba9
Added lookup method.
author | Thomas Wuerthinger <thomas@wuerthinger.net> |
---|---|
date | Tue, 31 May 2011 11:32:48 +0200 |
parents | 1d1603768966 |
children | b31471cdc53e |
rev | line source |
---|---|
0 | 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 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
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 | 22 * |
23 */ | |
24 | |
1972 | 25 #ifndef SHARE_VM_INTERPRETER_INTERPRETER_HPP |
26 #define SHARE_VM_INTERPRETER_INTERPRETER_HPP | |
27 | |
28 #include "code/stubs.hpp" | |
29 #include "interpreter/cppInterpreter.hpp" | |
30 #include "interpreter/templateInterpreter.hpp" | |
31 #ifdef ZERO | |
32 #ifdef TARGET_ARCH_zero | |
33 # include "entry_zero.hpp" | |
34 #endif | |
35 #endif | |
36 | |
605 | 37 // This file contains the platform-independent parts |
0 | 38 // of the interpreter and the interpreter generator. |
39 | |
40 //------------------------------------------------------------------------------------------------------------------------ | |
41 // An InterpreterCodelet is a piece of interpreter code. All | |
42 // interpreter code is generated into little codelets which | |
43 // contain extra information for debugging and printing purposes. | |
44 | |
45 class InterpreterCodelet: public Stub { | |
46 friend class VMStructs; | |
47 private: | |
48 int _size; // the size in bytes | |
49 const char* _description; // a description of the codelet, for debugging & printing | |
50 Bytecodes::Code _bytecode; // associated bytecode if any | |
51 | |
52 public: | |
53 // Initialization/finalization | |
54 void initialize(int size) { _size = size; } | |
55 void finalize() { ShouldNotCallThis(); } | |
56 | |
57 // General info/converters | |
58 int size() const { return _size; } | |
59 static int code_size_to_size(int code_size) { return round_to(sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; } | |
60 | |
61 // Code info | |
62 address code_begin() const { return (address)this + round_to(sizeof(InterpreterCodelet), CodeEntryAlignment); } | |
63 address code_end() const { return (address)this + size(); } | |
64 | |
65 // Debugging | |
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 | 69 |
70 // Interpreter-specific initialization | |
71 void initialize(const char* description, Bytecodes::Code bytecode); | |
72 | |
73 // Interpreter-specific attributes | |
74 int code_size() const { return code_end() - code_begin(); } | |
75 const char* description() const { return _description; } | |
76 Bytecodes::Code bytecode() const { return _bytecode; } | |
77 }; | |
78 | |
79 // Define a prototype interface | |
80 DEF_STUB_INTERFACE(InterpreterCodelet); | |
81 | |
82 | |
83 //------------------------------------------------------------------------------------------------------------------------ | |
84 // A CodeletMark serves as an automatic creator/initializer for Codelets | |
85 // (As a subclass of ResourceMark it automatically GC's the allocated | |
86 // code buffer and assemblers). | |
87 | |
88 class CodeletMark: ResourceMark { | |
89 private: | |
90 InterpreterCodelet* _clet; | |
91 InterpreterMacroAssembler** _masm; | |
92 CodeBuffer _cb; | |
93 | |
94 int codelet_size() { | |
95 // Request the whole code buffer (minus a little for alignment). | |
96 // The commit call below trims it back for each codelet. | |
97 int codelet_size = AbstractInterpreter::code()->available_space() - 2*K; | |
98 | |
99 // Guarantee there's a little bit of code space left. | |
100 guarantee (codelet_size > 0 && (size_t)codelet_size > 2*K, | |
101 "not enough space for interpreter generation"); | |
102 | |
103 return codelet_size; | |
104 } | |
105 | |
106 public: | |
107 CodeletMark( | |
108 InterpreterMacroAssembler*& masm, | |
109 const char* description, | |
110 Bytecodes::Code bytecode = Bytecodes::_illegal): | |
111 _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())), | |
112 _cb(_clet->code_begin(), _clet->code_size()) | |
113 | |
114 { // request all space (add some slack for Codelet data) | |
115 assert (_clet != NULL, "we checked not enough space already"); | |
116 | |
117 // initialize Codelet attributes | |
118 _clet->initialize(description, bytecode); | |
119 // create assembler for code generation | |
120 masm = new InterpreterMacroAssembler(&_cb); | |
121 _masm = &masm; | |
122 } | |
123 | |
124 ~CodeletMark() { | |
125 // align so printing shows nop's instead of random code at the end (Codelets are aligned) | |
126 (*_masm)->align(wordSize); | |
127 // make sure all code is in code buffer | |
128 (*_masm)->flush(); | |
129 | |
130 | |
131 // commit Codelet | |
1748 | 132 AbstractInterpreter::code()->commit((*_masm)->code()->pure_insts_size()); |
0 | 133 // make sure nobody can use _masm outside a CodeletMark lifespan |
134 *_masm = NULL; | |
135 } | |
136 }; | |
137 | |
138 // Wrapper classes to produce Interpreter/InterpreterGenerator from either | |
139 // the c++ interpreter or the template interpreter. | |
140 | |
141 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) { | |
142 | |
143 public: | |
144 // Debugging/printing | |
145 static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); } | |
1972 | 146 #ifdef TARGET_ARCH_x86 |
147 # include "interpreter_x86.hpp" | |
148 #endif | |
149 #ifdef TARGET_ARCH_sparc | |
150 # include "interpreter_sparc.hpp" | |
151 #endif | |
152 #ifdef TARGET_ARCH_zero | |
153 # include "interpreter_zero.hpp" | |
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 | 161 |
0 | 162 }; |
1972 | 163 |
164 #endif // SHARE_VM_INTERPRETER_INTERPRETER_HPP |