annotate src/share/vm/runtime/stubCodeGenerator.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 a61af66fc99e
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-2000 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 // All the basic framework for stubcode generation/debugging/printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
26
a61af66fc99e Initial load
duke
parents:
diff changeset
27
a61af66fc99e Initial load
duke
parents:
diff changeset
28 // A StubCodeDesc describes a piece of generated code (usually stubs).
a61af66fc99e Initial load
duke
parents:
diff changeset
29 // This information is mainly useful for debugging and printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // Currently, code descriptors are simply chained in a linked list,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // this may have to change if searching becomes too slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33 class StubCodeDesc: public CHeapObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
34 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
35 static StubCodeDesc* _list; // the list of all descriptors
a61af66fc99e Initial load
duke
parents:
diff changeset
36 static int _count; // length of list
a61af66fc99e Initial load
duke
parents:
diff changeset
37
a61af66fc99e Initial load
duke
parents:
diff changeset
38 StubCodeDesc* _next; // the next element in the linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
39 const char* _group; // the group to which the stub code belongs
a61af66fc99e Initial load
duke
parents:
diff changeset
40 const char* _name; // the name assigned to the stub code
a61af66fc99e Initial load
duke
parents:
diff changeset
41 int _index; // serial number assigned to the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
42 address _begin; // points to the first byte of the stub code (included)
a61af66fc99e Initial load
duke
parents:
diff changeset
43 address _end; // points to the first byte after the stub code (excluded)
a61af66fc99e Initial load
duke
parents:
diff changeset
44
a61af66fc99e Initial load
duke
parents:
diff changeset
45 void set_end(address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
46 assert(_begin <= end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
47 _end = end;
a61af66fc99e Initial load
duke
parents:
diff changeset
48 }
a61af66fc99e Initial load
duke
parents:
diff changeset
49
a61af66fc99e Initial load
duke
parents:
diff changeset
50 void set_begin(address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
51 assert(begin >= _begin, "begin may not decrease");
a61af66fc99e Initial load
duke
parents:
diff changeset
52 assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 friend class StubCodeMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 friend class StubCodeGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
58
a61af66fc99e Initial load
duke
parents:
diff changeset
59 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
60 static StubCodeDesc* desc_for(address pc); // returns the code descriptor for the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
61 static StubCodeDesc* desc_for_index(int); // returns the code descriptor for the index or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
62 static const char* name_for(address pc); // returns the name of the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 StubCodeDesc(const char* group, const char* name, address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
65 assert(name != NULL, "no name specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
66 _next = _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 _group = group;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 _index = ++_count; // (never zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
70 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 _end = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _list = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 };
a61af66fc99e Initial load
duke
parents:
diff changeset
74
a61af66fc99e Initial load
duke
parents:
diff changeset
75 const char* group() const { return _group; }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 const char* name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
77 int index() const { return _index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
78 address begin() const { return _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
79 address end() const { return _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
80 int size_in_bytes() const { return _end - _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
81 bool contains(address pc) const { return _begin <= pc && pc < _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 void print();
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85 // The base class for all stub-generating code generators.
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // Provides utility functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 class StubCodeGenerator: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
89 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
90 MacroAssembler* _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 StubCodeDesc* _first_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 StubCodeDesc* _last_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 StubCodeGenerator(CodeBuffer* code);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ~StubCodeGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 MacroAssembler* assembler() const { return _masm; }
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
102 virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor
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 // Stack-allocated helper class used to assciate a stub code with a name.
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // All stub code generating functions that use a StubCodeMark will be registered
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // in the global StubCodeDesc list and the generated stub code can be identified
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // later via an address pointing into it.
a61af66fc99e Initial load
duke
parents:
diff changeset
110
a61af66fc99e Initial load
duke
parents:
diff changeset
111 class StubCodeMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
113 StubCodeGenerator* _cgen;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 StubCodeDesc* _cdesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
115
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
117 StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 ~StubCodeMark();
a61af66fc99e Initial load
duke
parents:
diff changeset
119
a61af66fc99e Initial load
duke
parents:
diff changeset
120 };