annotate src/share/vm/runtime/stubCodeGenerator.hpp @ 1721:413ad0331a0c

6977924: Changes for 6975078 produce build error with certain gcc versions Summary: The changes introduced for 6975078 assign badHeapOopVal to the _allocation field in the ResourceObj class. In 32 bit linux builds with certain versions of gcc this assignment will be flagged as an error while compiling allocation.cpp. In 32 bit builds the constant value badHeapOopVal (which is cast to an intptr_t) is negative. The _allocation field is typed as an unsigned intptr_t and gcc catches this as an error. Reviewed-by: jcoomes, ysr, phh
author johnc
date Wed, 18 Aug 2010 10:59:06 -0700
parents 126ea7725993
children f95d63e2154a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
2 * Copyright (c) 1997, 2000, 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: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
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: 0
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
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; }
1681
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
82 void print_on(outputStream* st) const;
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
83 void print() const { print_on(tty); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
84 };
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 // The base class for all stub-generating code generators.
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Provides utility functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
88
a61af66fc99e Initial load
duke
parents:
diff changeset
89 class StubCodeGenerator: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
90 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
91 MacroAssembler* _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 StubCodeDesc* _first_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
94 StubCodeDesc* _last_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
95
a61af66fc99e Initial load
duke
parents:
diff changeset
96 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 StubCodeGenerator(CodeBuffer* code);
a61af66fc99e Initial load
duke
parents:
diff changeset
98 ~StubCodeGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 MacroAssembler* assembler() const { return _masm; }
a61af66fc99e Initial load
duke
parents:
diff changeset
101
a61af66fc99e Initial load
duke
parents:
diff changeset
102 virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
103 virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor
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 // Stack-allocated helper class used to assciate a stub code with a name.
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // All stub code generating functions that use a StubCodeMark will be registered
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // in the global StubCodeDesc list and the generated stub code can be identified
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // later via an address pointing into it.
a61af66fc99e Initial load
duke
parents:
diff changeset
111
a61af66fc99e Initial load
duke
parents:
diff changeset
112 class StubCodeMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
114 StubCodeGenerator* _cgen;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 StubCodeDesc* _cdesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
116
a61af66fc99e Initial load
duke
parents:
diff changeset
117 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
118 StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
119 ~StubCodeMark();
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 };