-
Notifications
You must be signed in to change notification settings - Fork 200
/
resolutionErrors.hpp
137 lines (106 loc) · 5.01 KB
/
resolutionErrors.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
#ifndef SHARE_CLASSFILE_RESOLUTIONERRORS_HPP
#define SHARE_CLASSFILE_RESOLUTIONERRORS_HPP
#include "oops/constantPool.hpp"
#include "utilities/hashtable.hpp"
class ResolutionErrorEntry;
// ResolutionError objects are used to record errors encountered during
// constant pool resolution (JVMS 5.4.3).
// This value is added to the cpCache index of an invokedynamic instruction when
// storing the resolution error resulting from that invokedynamic instruction.
// This prevents issues where the cpCache index is the same as the constant pool
// index of another entry in the table.
const int CPCACHE_INDEX_MANGLE_VALUE = 1000000;
class ResolutionErrorTable : public Hashtable<ConstantPool*, mtClass> {
private:
void free_entry(ResolutionErrorEntry *entry);
public:
ResolutionErrorTable(int table_size);
ResolutionErrorEntry* bucket(int i) {
return (ResolutionErrorEntry*)Hashtable<ConstantPool*, mtClass>::bucket(i);
}
ResolutionErrorEntry** bucket_addr(int i) {
return (ResolutionErrorEntry**)Hashtable<ConstantPool*, mtClass>::bucket_addr(i);
}
void add_entry(int index, ResolutionErrorEntry* new_entry) {
Hashtable<ConstantPool*, mtClass>::add_entry(index,
(HashtableEntry<ConstantPool*, mtClass>*)new_entry);
}
void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index, Symbol* error, const char* error_msg,
Symbol* cause, const char* cause_msg);
void add_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index, const char* message);
// find error given the constant pool and constant pool index
ResolutionErrorEntry* find_entry(int index, unsigned int hash,
const constantPoolHandle& pool, int cp_index);
unsigned int compute_hash(const constantPoolHandle& pool, int cp_index) {
return (unsigned int) pool->identity_hash() + cp_index;
}
// purges unloaded entries from the table
void purge_resolution_errors();
// RedefineClasses support - remove obsolete constant pool entry
void delete_entry(ConstantPool* c);
// This function is used to encode an index to differentiate it from a
// constant pool index. It assumes it is being called with a cpCache index
// (that is less than 0).
static int encode_cpcache_index(int index) {
assert(index < 0, "Unexpected non-negative cpCache index");
return index + CPCACHE_INDEX_MANGLE_VALUE;
}
};
class ResolutionErrorEntry : public HashtableEntry<ConstantPool*, mtClass> {
private:
int _cp_index;
Symbol* _error;
const char* _message;
Symbol* _cause;
const char* _cause_msg;
const char* _nest_host_error;
public:
ConstantPool* pool() const { return literal(); }
int cp_index() const { return _cp_index; }
void set_cp_index(int cp_index) { _cp_index = cp_index; }
Symbol* error() const { return _error; }
void set_error(Symbol* e);
const char* message() const { return _message; }
// The incoming message is copied to the C-Heap.
void set_message(const char* c);
Symbol* cause() const { return _cause; }
void set_cause(Symbol* c);
const char* cause_msg() const { return _cause_msg; }
// The incoming cause_msg is copied to the C-Heap.
void set_cause_msg(const char* c);
const char* nest_host_error() const { return _nest_host_error; }
// The incoming nest host error message is already in the C-Heap.
void set_nest_host_error(const char* message);
ResolutionErrorEntry* next() const {
return (ResolutionErrorEntry*)HashtableEntry<ConstantPool*, mtClass>::next();
}
ResolutionErrorEntry** next_addr() {
return (ResolutionErrorEntry**)HashtableEntry<ConstantPool*, mtClass>::next_addr();
}
};
#endif // SHARE_CLASSFILE_RESOLUTIONERRORS_HPP