Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit4cb7124

Browse files
committed
8262912: ciReplay: replay does not simulate unresolved classes
Reviewed-by: kvn, dlong
1 parent322b130 commit4cb7124

File tree

8 files changed

+241
-15
lines changed

8 files changed

+241
-15
lines changed

‎src/hotspot/share/ci/ciEnv.cpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,15 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
636636
}
637637

638638
// It is known to be accessible, since it was found in the constant pool.
639+
ciKlass* ciKlass =get_klass(klass);
639640
is_accessible =true;
640-
returnget_klass(klass);
641+
#ifndef PRODUCT
642+
if (ReplayCompiles && ciKlass == _unloaded_ciinstance_klass) {
643+
// Klass was unresolved at replay dump time and therefore not accessible.
644+
is_accessible =false;
645+
}
646+
#endif
647+
return ciKlass;
641648
}
642649

643650
// ------------------------------------------------------------------

‎src/hotspot/share/ci/ciEnv.hpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727

2828
#include"ci/ciClassList.hpp"
2929
#include"ci/ciObjectFactory.hpp"
30+
#include"ci/ciReplay.hpp"
3031
#include"classfile/vmClassMacros.hpp"
3132
#include"code/debugInfoRec.hpp"
3233
#include"code/dependencies.hpp"
@@ -187,6 +188,15 @@ class ciEnv : StackObj {
187188
if (o ==NULL) {
188189
returnNULL;
189190
}else {
191+
#ifndef PRODUCT
192+
if (ReplayCompiles && o->is_klass()) {
193+
Klass* k = (Klass*)o;
194+
if (k->is_instance_klass() &&ciReplay::is_klass_unresolved((InstanceKlass*)k)) {
195+
// Klass was unresolved at replay dump time. Simulate this case.
196+
return ciEnv::_unloaded_ciinstance_klass;
197+
}
198+
}
199+
#endif
190200
return _factory->get_metadata(o);
191201
}
192202
}

‎src/hotspot/share/ci/ciInstanceKlass.hpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ class ciInstanceKlass : public ciKlass {
4343
friendclassciExceptionHandler;
4444
friendclassciMethod;
4545
friendclassciField;
46+
friendclassciReplay;
4647

4748
private:
4849
enum SubklassValue { subklass_unknown, subklass_false, subklass_true };

‎src/hotspot/share/ci/ciObjectFactory.cpp‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ ciMetadata* ciObjectFactory::create_new_metadata(Metadata* o) {
378378
if (o->is_klass()) {
379379
Klass* k = (Klass*)o;
380380
if (k->is_instance_klass()) {
381+
assert(!ReplayCompiles ||ciReplay::no_replay_state() || !ciReplay::is_klass_unresolved((InstanceKlass*)k),"must be whitelisted for replay compilation");
381382
returnnew (arena())ciInstanceKlass(k);
382383
}elseif (k->is_objArray_klass()) {
383384
returnnew (arena())ciObjArrayKlass(k);

‎src/hotspot/share/ci/ciReplay.cpp‎

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#include"runtime/fieldDescriptor.inline.hpp"
5050
#include"runtime/globals_extension.hpp"
5151
#include"runtime/handles.inline.hpp"
52+
#include"runtime/jniHandles.inline.hpp"
5253
#include"runtime/java.hpp"
5354
#include"utilities/copy.hpp"
5455
#include"utilities/macros.hpp"
@@ -90,6 +91,11 @@ typedef struct _ciMethodRecord {
9091
int _backedge_counter;
9192
} ciMethodRecord;
9293

94+
typedefstruct_ciInstanceKlassRecord {
95+
const InstanceKlass* _klass;
96+
jobject _java_mirror;// Global handle to java mirror to prevent unloading
97+
} ciInstanceKlassRecord;
98+
9399
typedefstruct_ciInlineRecord {
94100
constchar* _klass_name;
95101
constchar* _method_name;
@@ -111,6 +117,7 @@ class CompileReplay : public StackObj {
111117

112118
GrowableArray<ciMethodRecord*> _ci_method_records;
113119
GrowableArray<ciMethodDataRecord*> _ci_method_data_records;
120+
GrowableArray<ciInstanceKlassRecord*> _ci_instance_klass_records;
114121

115122
// Use pointer because we may need to return inline records
116123
// without destroying them.
@@ -882,7 +889,7 @@ class CompileReplay : public StackObj {
882889
// constant pool is the same length as 'length' and make sure the
883890
// constant pool tags are in the same state.
884891
voidprocess_ciInstanceKlass(TRAPS) {
885-
InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK);
892+
InstanceKlass* k = (InstanceKlass*)parse_klass(CHECK);
886893
if (k ==NULL) {
887894
return;
888895
}
@@ -905,6 +912,7 @@ class CompileReplay : public StackObj {
905912
}elseif (is_linked) {
906913
k->link_class(CHECK);
907914
}
915+
new_ciInstanceKlass(k);
908916
ConstantPool* cp = k->constants();
909917
if (length != cp->length()) {
910918
report_error("constant pool length mismatch: wrong class files?");
@@ -951,10 +959,10 @@ class CompileReplay : public StackObj {
951959
break;
952960

953961
case JVM_CONSTANT_Class:
954-
if (tag ==JVM_CONSTANT_Class) {
955-
}elseif (tag == JVM_CONSTANT_UnresolvedClass) {
956-
tty->print_cr("Warning: entry was unresolved in the replay data");
957-
}else {
962+
if (tag ==JVM_CONSTANT_UnresolvedClass) {
963+
Klass* k = cp->klass_at(i, CHECK);
964+
tty->print_cr("Warning: entry was unresolved in the replay data: %s", k->name()->as_utf8());
965+
}elseif (tag != JVM_CONSTANT_Class){
958966
report_error("Unexpected tag");
959967
return;
960968
}
@@ -1132,6 +1140,28 @@ class CompileReplay : public StackObj {
11321140
returnNULL;
11331141
}
11341142

1143+
// Create and initialize a record for a ciInstanceKlass which was present at replay dump time.
1144+
voidnew_ciInstanceKlass(const InstanceKlass* klass) {
1145+
ciInstanceKlassRecord* rec =NEW_RESOURCE_OBJ(ciInstanceKlassRecord);
1146+
rec->_klass = klass;
1147+
oop java_mirror = klass->java_mirror();
1148+
Handleh_java_mirror(_thread, java_mirror);
1149+
rec->_java_mirror =JNIHandles::make_global(h_java_mirror);
1150+
_ci_instance_klass_records.append(rec);
1151+
}
1152+
1153+
// Check if a ciInstanceKlass was present at replay dump time for a klass.
1154+
ciInstanceKlassRecord*find_ciInstanceKlass(const InstanceKlass* klass) {
1155+
for (int i =0; i < _ci_instance_klass_records.length(); i++) {
1156+
ciInstanceKlassRecord* rec = _ci_instance_klass_records.at(i);
1157+
if (klass == rec->_klass) {
1158+
// ciInstanceKlass for this klass was resolved.
1159+
return rec;
1160+
}
1161+
}
1162+
returnNULL;
1163+
}
1164+
11351165
// Create and initialize a record for a ciMethodData
11361166
ciMethodDataRecord*new_ciMethodData(Method* method) {
11371167
ciMethodDataRecord* rec =NEW_RESOURCE_OBJ(ciMethodDataRecord);
@@ -1265,6 +1295,10 @@ void ciReplay::replay(TRAPS) {
12651295
vm_exit(exit_code);
12661296
}
12671297

1298+
boolciReplay::no_replay_state() {
1299+
return replay_state ==NULL;
1300+
}
1301+
12681302
void*ciReplay::load_inline_data(ciMethod* method,int entry_bci,int comp_level) {
12691303
if (FLAG_IS_DEFAULT(InlineDataFile)) {
12701304
tty->print_cr("ERROR: no inline replay data file specified (use -XX:InlineDataFile=inline_pid12345.txt).");
@@ -1336,7 +1370,7 @@ int ciReplay::replay_impl(TRAPS) {
13361370
}
13371371

13381372
voidciReplay::initialize(ciMethodData* m) {
1339-
if (replay_state ==NULL) {
1373+
if (no_replay_state()) {
13401374
return;
13411375
}
13421376

@@ -1390,7 +1424,7 @@ void ciReplay::initialize(ciMethodData* m) {
13901424

13911425

13921426
boolciReplay::should_not_inline(ciMethod* method) {
1393-
if (replay_state ==NULL) {
1427+
if (no_replay_state()) {
13941428
returnfalse;
13951429
}
13961430
VM_ENTRY_MARK;
@@ -1427,7 +1461,7 @@ bool ciReplay::should_not_inline(void* data, ciMethod* method, int bci, int inli
14271461
}
14281462

14291463
voidciReplay::initialize(ciMethod* m) {
1430-
if (replay_state ==NULL) {
1464+
if (no_replay_state()) {
14311465
return;
14321466
}
14331467

@@ -1456,8 +1490,17 @@ void ciReplay::initialize(ciMethod* m) {
14561490
}
14571491
}
14581492

1493+
voidciReplay::initialize(ciInstanceKlass* ci_ik, InstanceKlass* ik) {
1494+
assert(!no_replay_state(),"must have replay state");
1495+
1496+
ASSERT_IN_VM;
1497+
ciInstanceKlassRecord* rec = replay_state->find_ciInstanceKlass(ik);
1498+
assert(rec !=NULL,"ciInstanceKlass must be whitelisted");
1499+
ci_ik->_java_mirror = CURRENT_ENV->get_instance(JNIHandles::resolve(rec->_java_mirror));
1500+
}
1501+
14591502
boolciReplay::is_loaded(Method* method) {
1460-
if (replay_state ==NULL) {
1503+
if (no_replay_state()) {
14611504
returntrue;
14621505
}
14631506

@@ -1467,6 +1510,16 @@ bool ciReplay::is_loaded(Method* method) {
14671510
ciMethodRecord* rec = replay_state->find_ciMethodRecord(method);
14681511
return rec !=NULL;
14691512
}
1513+
1514+
boolciReplay::is_klass_unresolved(const InstanceKlass* klass) {
1515+
if (no_replay_state()) {
1516+
returnfalse;
1517+
}
1518+
1519+
// Check if klass is found on whitelist.
1520+
ciInstanceKlassRecord* rec = replay_state->find_ciInstanceKlass(klass);
1521+
return rec ==NULL;
1522+
}
14701523
#endif// PRODUCT
14711524

14721525
oopciReplay::obj_field(oop obj, Symbol* name) {

‎src/hotspot/share/ci/ciReplay.hpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class ciReplay {
106106
public:
107107
// Replay specified compilation and exit VM.
108108
staticvoidreplay(TRAPS);
109+
staticboolno_replay_state();
109110
// Load inlining decisions from file and use them
110111
// during compilation of specified method.
111112
staticvoid*load_inline_data(ciMethod* method,int entry_bci,int comp_level);
@@ -114,7 +115,9 @@ class ciReplay {
114115
// replay file when replaying compiles.
115116
staticvoidinitialize(ciMethodData* method);
116117
staticvoidinitialize(ciMethod* method);
118+
staticvoidinitialize(ciInstanceKlass* ciKlass, InstanceKlass* ik);
117119

120+
staticboolis_klass_unresolved(const InstanceKlass* klass);
118121
staticboolis_loaded(Method* method);
119122

120123
staticboolshould_not_inline(ciMethod* method);

‎test/hotspot/jtreg/compiler/ciReplay/CiReplayBase.java‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ public void runTest(boolean needCoreDump, String... args) {
132132

133133
publicabstractvoidtestAction();
134134

135-
privatestaticvoidremove(Stringitem) {
135+
publicstaticvoidremove(Stringitem) {
136136
FiletoDelete =newFile(item);
137137
toDelete.delete();
138138
if (Platform.isWindows()) {
@@ -164,14 +164,14 @@ public boolean generateReplay(boolean needCoreDump, String... vmopts) {
164164
options.add(needCoreDump ?ENABLE_COREDUMP_ON_CRASH :DISABLE_COREDUMP_ON_CRASH);
165165
if (needCoreDump) {
166166
// CiReplayBase$TestMain needs to be quoted because of shell eval
167-
options.add("-XX:CompileOnly='" +TestMain.class.getName() +"::test'");
168-
options.add("'" +TestMain.class.getName() +"'");
167+
options.add("-XX:CompileOnly='" +getTestClass() +"::test'");
168+
options.add("'" +getTestClass() +"'");
169169
crashOut =ProcessTools.executeProcess(
170170
CoreUtils.addCoreUlimitCommand(
171171
ProcessTools.createTestJvm(options.toArray(newString[0]))));
172172
}else {
173-
options.add("-XX:CompileOnly=" +TestMain.class.getName() +"::test");
174-
options.add(TestMain.class.getName());
173+
options.add("-XX:CompileOnly=" +getTestClass() +"::test");
174+
options.add(getTestClass());
175175
crashOut =ProcessTools.executeProcess(ProcessTools.createTestJvm(options));
176176
}
177177
crashOutputString =crashOut.getOutput();
@@ -194,6 +194,10 @@ public boolean generateReplay(boolean needCoreDump, String... vmopts) {
194194
returntrue;
195195
}
196196

197+
publicStringgetTestClass() {
198+
returnTestMain.class.getName();
199+
}
200+
197201
publicvoidcommonTests() {
198202
positiveTest();
199203
if (Platform.isTieredSupported()) {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp