annotate src/share/vm/runtime/stubCodeGenerator.hpp @ 18096:ca6d25be853b jdk8u25-b13

8044269: Analysis of archive files. Summary: Add checksum verification. Reviewed-by: iklam, dholmes, mschoene
author jiangli
date Tue, 12 Aug 2014 17:46:16 -0400
parents b9a9ed0f8eeb
children 63a4eb8bcd23
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
6842
b9a9ed0f8eeb 7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents: 6197
diff changeset
2 * Copyright (c) 1997, 2012, 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
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
25 #ifndef SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
26 #define SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
28 #include "asm/assembler.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
29 #include "memory/allocation.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
30
0
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // All the basic framework for stubcode generation/debugging/printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
32
a61af66fc99e Initial load
duke
parents:
diff changeset
33
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // A StubCodeDesc describes a piece of generated code (usually stubs).
a61af66fc99e Initial load
duke
parents:
diff changeset
35 // This information is mainly useful for debugging and printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
36 // Currently, code descriptors are simply chained in a linked list,
a61af66fc99e Initial load
duke
parents:
diff changeset
37 // this may have to change if searching becomes too slow.
a61af66fc99e Initial load
duke
parents:
diff changeset
38
6197
d2a62e0f25eb 6995781: Native Memory Tracking (Phase 1)
zgu
parents: 3757
diff changeset
39 class StubCodeDesc: public CHeapObj<mtCode> {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
40 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
41 static StubCodeDesc* _list; // the list of all descriptors
a61af66fc99e Initial load
duke
parents:
diff changeset
42 static int _count; // length of list
a61af66fc99e Initial load
duke
parents:
diff changeset
43
a61af66fc99e Initial load
duke
parents:
diff changeset
44 StubCodeDesc* _next; // the next element in the linked list
a61af66fc99e Initial load
duke
parents:
diff changeset
45 const char* _group; // the group to which the stub code belongs
a61af66fc99e Initial load
duke
parents:
diff changeset
46 const char* _name; // the name assigned to the stub code
a61af66fc99e Initial load
duke
parents:
diff changeset
47 int _index; // serial number assigned to the stub
a61af66fc99e Initial load
duke
parents:
diff changeset
48 address _begin; // points to the first byte of the stub code (included)
a61af66fc99e Initial load
duke
parents:
diff changeset
49 address _end; // points to the first byte after the stub code (excluded)
a61af66fc99e Initial load
duke
parents:
diff changeset
50
a61af66fc99e Initial load
duke
parents:
diff changeset
51 void set_end(address end) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 assert(_begin <= end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
53 _end = end;
a61af66fc99e Initial load
duke
parents:
diff changeset
54 }
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 void set_begin(address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
57 assert(begin >= _begin, "begin may not decrease");
a61af66fc99e Initial load
duke
parents:
diff changeset
58 assert(_end == NULL || begin <= _end, "begin & end not properly ordered");
a61af66fc99e Initial load
duke
parents:
diff changeset
59 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61
a61af66fc99e Initial load
duke
parents:
diff changeset
62 friend class StubCodeMark;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 friend class StubCodeGenerator;
a61af66fc99e Initial load
duke
parents:
diff changeset
64
a61af66fc99e Initial load
duke
parents:
diff changeset
65 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
66 static StubCodeDesc* desc_for(address pc); // returns the code descriptor for the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
67 static StubCodeDesc* desc_for_index(int); // returns the code descriptor for the index or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
68 static const char* name_for(address pc); // returns the name of the code containing pc or NULL
a61af66fc99e Initial load
duke
parents:
diff changeset
69
a61af66fc99e Initial load
duke
parents:
diff changeset
70 StubCodeDesc(const char* group, const char* name, address begin) {
a61af66fc99e Initial load
duke
parents:
diff changeset
71 assert(name != NULL, "no name specified");
a61af66fc99e Initial load
duke
parents:
diff changeset
72 _next = _list;
a61af66fc99e Initial load
duke
parents:
diff changeset
73 _group = group;
a61af66fc99e Initial load
duke
parents:
diff changeset
74 _name = name;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 _index = ++_count; // (never zero)
a61af66fc99e Initial load
duke
parents:
diff changeset
76 _begin = begin;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 _end = NULL;
a61af66fc99e Initial load
duke
parents:
diff changeset
78 _list = this;
a61af66fc99e Initial load
duke
parents:
diff changeset
79 };
a61af66fc99e Initial load
duke
parents:
diff changeset
80
a61af66fc99e Initial load
duke
parents:
diff changeset
81 const char* group() const { return _group; }
a61af66fc99e Initial load
duke
parents:
diff changeset
82 const char* name() const { return _name; }
a61af66fc99e Initial load
duke
parents:
diff changeset
83 int index() const { return _index; }
a61af66fc99e Initial load
duke
parents:
diff changeset
84 address begin() const { return _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
85 address end() const { return _end; }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 int size_in_bytes() const { return _end - _begin; }
a61af66fc99e Initial load
duke
parents:
diff changeset
87 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
88 void print_on(outputStream* st) const;
126ea7725993 6953477: Increase portability and flexibility of building Hotspot
bobv
parents: 1552
diff changeset
89 void print() const { print_on(tty); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
90 };
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // The base class for all stub-generating code generators.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Provides utility functions.
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 class StubCodeGenerator: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
97 MacroAssembler* _masm;
a61af66fc99e Initial load
duke
parents:
diff changeset
98
a61af66fc99e Initial load
duke
parents:
diff changeset
99 StubCodeDesc* _first_stub;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 StubCodeDesc* _last_stub;
3757
f8c9417e3571 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 1972
diff changeset
101 bool _print_code;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
102
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public:
3757
f8c9417e3571 7052219: JSR 292: Crash in ~BufferBlob::MethodHandles adapters
never
parents: 1972
diff changeset
104 StubCodeGenerator(CodeBuffer* code, bool print_code = false);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
105 ~StubCodeGenerator();
a61af66fc99e Initial load
duke
parents:
diff changeset
106
a61af66fc99e Initial load
duke
parents:
diff changeset
107 MacroAssembler* assembler() const { return _masm; }
a61af66fc99e Initial load
duke
parents:
diff changeset
108
a61af66fc99e Initial load
duke
parents:
diff changeset
109 virtual void stub_prolog(StubCodeDesc* cdesc); // called by StubCodeMark constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
110 virtual void stub_epilog(StubCodeDesc* cdesc); // called by StubCodeMark destructor
a61af66fc99e Initial load
duke
parents:
diff changeset
111 };
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // Stack-allocated helper class used to assciate a stub code with a name.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // All stub code generating functions that use a StubCodeMark will be registered
a61af66fc99e Initial load
duke
parents:
diff changeset
116 // in the global StubCodeDesc list and the generated stub code can be identified
a61af66fc99e Initial load
duke
parents:
diff changeset
117 // later via an address pointing into it.
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 class StubCodeMark: public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
120 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
121 StubCodeGenerator* _cgen;
a61af66fc99e Initial load
duke
parents:
diff changeset
122 StubCodeDesc* _cdesc;
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
125 StubCodeMark(StubCodeGenerator* cgen, const char* group, const char* name);
a61af66fc99e Initial load
duke
parents:
diff changeset
126 ~StubCodeMark();
a61af66fc99e Initial load
duke
parents:
diff changeset
127
a61af66fc99e Initial load
duke
parents:
diff changeset
128 };
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
129
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1681
diff changeset
130 #endif // SHARE_VM_RUNTIME_STUBCODEGENERATOR_HPP