annotate src/share/vm/interpreter/interpreter.hpp @ 1091:6aa7255741f3

6906727: UseCompressedOops: some card-marking fixes related to object arrays Summary: Introduced a new write_ref_array(HeapWords* start, size_t count) method that does the requisite MemRegion range calculation so (some of the) clients of the erstwhile write_ref_array(MemRegion mr) do not need to worry. This removed all external uses of array_size(), which was also simplified and made private. Asserts were added to catch other possible issues. Further, less essential, fixes stemming from this investigation are deferred to CR 6904516 (to follow shortly in hs17). Reviewed-by: kvn, coleenp, jmasa
author ysr
date Thu, 03 Dec 2009 15:01:57 -0800
parents 98cb887364d3
children c18cbe5936b8
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
605
98cb887364d3 6810672: Comment typos
twisti
parents: 0
diff changeset
25 // This file contains the platform-independent parts
0
a61af66fc99e Initial load
duke
parents:
diff changeset
26 // of the interpreter and the interpreter generator.
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // An InterpreterCodelet is a piece of interpreter code. All
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // interpreter code is generated into little codelets which
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // contain extra information for debugging and printing purposes.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class InterpreterCodelet: public Stub {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 friend class VMStructs;
a61af66fc99e Initial load
duke
parents:
diff changeset
35 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
36 int _size; // the size in bytes
a61af66fc99e Initial load
duke
parents:
diff changeset
37 const char* _description; // a description of the codelet, for debugging & printing
a61af66fc99e Initial load
duke
parents:
diff changeset
38 Bytecodes::Code _bytecode; // associated bytecode if any
a61af66fc99e Initial load
duke
parents:
diff changeset
39
a61af66fc99e Initial load
duke
parents:
diff changeset
40 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 // Initialization/finalization
a61af66fc99e Initial load
duke
parents:
diff changeset
42 void initialize(int size) { _size = size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
43 void finalize() { ShouldNotCallThis(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // General info/converters
a61af66fc99e Initial load
duke
parents:
diff changeset
46 int size() const { return _size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
47 static int code_size_to_size(int code_size) { return round_to(sizeof(InterpreterCodelet), CodeEntryAlignment) + code_size; }
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // Code info
a61af66fc99e Initial load
duke
parents:
diff changeset
50 address code_begin() const { return (address)this + round_to(sizeof(InterpreterCodelet), CodeEntryAlignment); }
a61af66fc99e Initial load
duke
parents:
diff changeset
51 address code_end() const { return (address)this + size(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
52
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // Debugging
a61af66fc99e Initial load
duke
parents:
diff changeset
54 void verify();
a61af66fc99e Initial load
duke
parents:
diff changeset
55 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
56
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // Interpreter-specific initialization
a61af66fc99e Initial load
duke
parents:
diff changeset
58 void initialize(const char* description, Bytecodes::Code bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
59
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Interpreter-specific attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
61 int code_size() const { return code_end() - code_begin(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
62 const char* description() const { return _description; }
a61af66fc99e Initial load
duke
parents:
diff changeset
63 Bytecodes::Code bytecode() const { return _bytecode; }
a61af66fc99e Initial load
duke
parents:
diff changeset
64 };
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Define a prototype interface
a61af66fc99e Initial load
duke
parents:
diff changeset
67 DEF_STUB_INTERFACE(InterpreterCodelet);
a61af66fc99e Initial load
duke
parents:
diff changeset
68
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 //------------------------------------------------------------------------------------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // A CodeletMark serves as an automatic creator/initializer for Codelets
a61af66fc99e Initial load
duke
parents:
diff changeset
72 // (As a subclass of ResourceMark it automatically GC's the allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // code buffer and assemblers).
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 class CodeletMark: ResourceMark {
a61af66fc99e Initial load
duke
parents:
diff changeset
76 private:
a61af66fc99e Initial load
duke
parents:
diff changeset
77 InterpreterCodelet* _clet;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 InterpreterMacroAssembler** _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 CodeBuffer _cb;
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int codelet_size() {
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // Request the whole code buffer (minus a little for alignment).
a61af66fc99e Initial load
duke
parents:
diff changeset
83 // The commit call below trims it back for each codelet.
a61af66fc99e Initial load
duke
parents:
diff changeset
84 int codelet_size = AbstractInterpreter::code()->available_space() - 2*K;
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Guarantee there's a little bit of code space left.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 guarantee (codelet_size > 0 && (size_t)codelet_size > 2*K,
a61af66fc99e Initial load
duke
parents:
diff changeset
88 "not enough space for interpreter generation");
a61af66fc99e Initial load
duke
parents:
diff changeset
89
a61af66fc99e Initial load
duke
parents:
diff changeset
90 return codelet_size;
a61af66fc99e Initial load
duke
parents:
diff changeset
91 }
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
94 CodeletMark(
a61af66fc99e Initial load
duke
parents:
diff changeset
95 InterpreterMacroAssembler*& masm,
a61af66fc99e Initial load
duke
parents:
diff changeset
96 const char* description,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 Bytecodes::Code bytecode = Bytecodes::_illegal):
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _clet((InterpreterCodelet*)AbstractInterpreter::code()->request(codelet_size())),
a61af66fc99e Initial load
duke
parents:
diff changeset
99 _cb(_clet->code_begin(), _clet->code_size())
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 { // request all space (add some slack for Codelet data)
a61af66fc99e Initial load
duke
parents:
diff changeset
102 assert (_clet != NULL, "we checked not enough space already");
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // initialize Codelet attributes
a61af66fc99e Initial load
duke
parents:
diff changeset
105 _clet->initialize(description, bytecode);
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // create assembler for code generation
a61af66fc99e Initial load
duke
parents:
diff changeset
107 masm = new InterpreterMacroAssembler(&_cb);
a61af66fc99e Initial load
duke
parents:
diff changeset
108 _masm = &masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
109 }
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 ~CodeletMark() {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // align so printing shows nop's instead of random code at the end (Codelets are aligned)
a61af66fc99e Initial load
duke
parents:
diff changeset
113 (*_masm)->align(wordSize);
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // make sure all code is in code buffer
a61af66fc99e Initial load
duke
parents:
diff changeset
115 (*_masm)->flush();
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118 // commit Codelet
a61af66fc99e Initial load
duke
parents:
diff changeset
119 AbstractInterpreter::code()->commit((*_masm)->code()->pure_code_size());
a61af66fc99e Initial load
duke
parents:
diff changeset
120 // make sure nobody can use _masm outside a CodeletMark lifespan
a61af66fc99e Initial load
duke
parents:
diff changeset
121 *_masm = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 }
a61af66fc99e Initial load
duke
parents:
diff changeset
123 };
a61af66fc99e Initial load
duke
parents:
diff changeset
124
a61af66fc99e Initial load
duke
parents:
diff changeset
125 // Wrapper classes to produce Interpreter/InterpreterGenerator from either
a61af66fc99e Initial load
duke
parents:
diff changeset
126 // the c++ interpreter or the template interpreter.
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 class Interpreter: public CC_INTERP_ONLY(CppInterpreter) NOT_CC_INTERP(TemplateInterpreter) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // Debugging/printing
a61af66fc99e Initial load
duke
parents:
diff changeset
132 static InterpreterCodelet* codelet_containing(address pc) { return (InterpreterCodelet*)_code->stub_containing(pc); }
a61af66fc99e Initial load
duke
parents:
diff changeset
133 #include "incls/_interpreter_pd.hpp.incl"
a61af66fc99e Initial load
duke
parents:
diff changeset
134 };