Skip to content

Commit f9004fe

Browse files
committed
8292561: Make "ReplayCompiles" a diagnostic product switch
Reviewed-by: kvn, xliu
1 parent 2fbb936 commit f9004fe

File tree

11 files changed

+84
-28
lines changed

11 files changed

+84
-28
lines changed

src/hotspot/share/ci/ciEnv.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -647,12 +647,10 @@ ciKlass* ciEnv::get_klass_by_index_impl(const constantPoolHandle& cpool,
647647
// It is known to be accessible, since it was found in the constant pool.
648648
ciKlass* ciKlass = get_klass(klass);
649649
is_accessible = true;
650-
#ifndef PRODUCT
651650
if (ReplayCompiles && ciKlass == _unloaded_ciinstance_klass) {
652651
// Klass was unresolved at replay dump time and therefore not accessible.
653652
is_accessible = false;
654653
}
655-
#endif
656654
return ciKlass;
657655
}
658656

@@ -943,11 +941,9 @@ ciMethod* ciEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
943941
: !m->method_holder()->is_loaded())) {
944942
m = NULL;
945943
}
946-
#ifdef ASSERT
947944
if (m != NULL && ReplayCompiles && !ciReplay::is_loaded(m)) {
948945
m = NULL;
949946
}
950-
#endif
951947
if (m != NULL) {
952948
// We found the method.
953949
return get_method(m);

src/hotspot/share/ci/ciEnv.hpp

-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
#include "ci/ciClassList.hpp"
2929
#include "ci/ciObjectFactory.hpp"
30-
#include "ci/ciReplay.hpp"
3130
#include "classfile/vmClassMacros.hpp"
3231
#include "code/debugInfoRec.hpp"
3332
#include "code/dependencies.hpp"
@@ -192,15 +191,6 @@ class ciEnv : StackObj {
192191
if (o == NULL) {
193192
return NULL;
194193
} else {
195-
#ifndef PRODUCT
196-
if (ReplayCompiles && o->is_klass()) {
197-
Klass* k = (Klass*)o;
198-
if (k->is_instance_klass() && ciReplay::is_klass_unresolved((InstanceKlass*)k)) {
199-
// Klass was unresolved at replay dump time. Simulate this case.
200-
return ciEnv::_unloaded_ciinstance_klass;
201-
}
202-
}
203-
#endif
204194
return _factory->get_metadata(o);
205195
}
206196
}

src/hotspot/share/ci/ciMethod.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,9 @@ ciMethod::ciMethod(const methodHandle& h_m, ciInstanceKlass* holder) :
156156
if (_interpreter_invocation_count == 0)
157157
_interpreter_invocation_count = 1;
158158
_instructions_size = -1;
159-
#ifdef ASSERT
160159
if (ReplayCompiles) {
161160
ciReplay::initialize(this);
162161
}
163-
#endif
164162
}
165163

166164

src/hotspot/share/ci/ciMethodData.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,12 @@ bool ciMethodData::load_data() {
261261
_arg_local = mdo->arg_local();
262262
_arg_stack = mdo->arg_stack();
263263
_arg_returned = mdo->arg_returned();
264-
#ifndef PRODUCT
265264
if (ReplayCompiles) {
266265
ciReplay::initialize(this);
267266
if (is_empty()) {
268267
return false;
269268
}
270269
}
271-
#endif
272270
return true;
273271
}
274272

src/hotspot/share/ci/ciObjectFactory.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
#include "ci/ciObjArrayKlass.hpp"
3737
#include "ci/ciObject.hpp"
3838
#include "ci/ciObjectFactory.hpp"
39+
#include "ci/ciReplay.hpp"
3940
#include "ci/ciSymbol.hpp"
4041
#include "ci/ciSymbols.hpp"
4142
#include "ci/ciTypeArray.hpp"
@@ -285,6 +286,14 @@ ciMetadata* ciObjectFactory::cached_metadata(Metadata* key) {
285286
ciMetadata* ciObjectFactory::get_metadata(Metadata* key) {
286287
ASSERT_IN_VM;
287288

289+
if (ReplayCompiles && key->is_klass()) {
290+
Klass* k = (Klass*)key;
291+
if (k->is_instance_klass() && ciReplay::is_klass_unresolved((InstanceKlass*)k)) {
292+
// Klass was unresolved at replay dump time. Simulate this case.
293+
return ciEnv::_unloaded_ciinstance_klass;
294+
}
295+
}
296+
288297
#ifdef ASSERT
289298
if (CIObjectFactoryVerify) {
290299
Metadata* last = NULL;

src/hotspot/share/ci/ciReplay.cpp

-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@
5757
#include "utilities/macros.hpp"
5858
#include "utilities/utf8.hpp"
5959

60-
#ifndef PRODUCT
61-
6260
// ciReplay
6361

6462
typedef struct _ciMethodDataRecord {
@@ -1585,7 +1583,6 @@ bool ciReplay::is_klass_unresolved(const InstanceKlass* klass) {
15851583
ciInstanceKlassRecord* rec = replay_state->find_ciInstanceKlass(klass);
15861584
return rec == NULL;
15871585
}
1588-
#endif // PRODUCT
15891586

15901587
oop ciReplay::obj_field(oop obj, Symbol* name) {
15911588
InstanceKlass* ik = InstanceKlass::cast(obj->klass());

src/hotspot/share/ci/ciReplay.hpp

-2
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@
9999
class ciReplay {
100100
CI_PACKAGE_ACCESS
101101

102-
#ifndef PRODUCT
103102
private:
104103
static int replay_impl(TRAPS);
105104

@@ -123,7 +122,6 @@ class ciReplay {
123122
static bool should_not_inline(ciMethod* method);
124123
static bool should_inline(void* data, ciMethod* method, int bci, int inline_depth, bool& should_delay);
125124
static bool should_not_inline(void* data, ciMethod* method, int bci, int inline_depth);
126-
#endif
127125

128126
public:
129127
static oop obj_field(oop obj, Symbol* name);

src/hotspot/share/compiler/compiler_globals.hpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@
305305
product(ccstrlist, CompileCommand, "", \
306306
"Prepend to .hotspot_compiler; e.g. log,java/lang/String.<init>") \
307307
\
308-
develop(bool, ReplayCompiles, false, \
308+
product(bool, ReplayCompiles, false, DIAGNOSTIC, \
309309
"Enable replay of compilations from ReplayDataFile") \
310310
\
311311
product(ccstr, ReplayDataFile, NULL, \
@@ -316,7 +316,7 @@
316316
"File containing inlining replay information" \
317317
"[default: ./inline_pid%p.log] (%p replaced with pid)") \
318318
\
319-
develop(intx, ReplaySuppressInitializers, 2, \
319+
product(intx, ReplaySuppressInitializers, 2, DIAGNOSTIC, \
320320
"Control handling of class initialization during replay: " \
321321
"0 - don't do anything special; " \
322322
"1 - treat all class initializers as empty; " \
@@ -325,7 +325,7 @@
325325
" pretend they are empty after starting replay") \
326326
range(0, 3) \
327327
\
328-
develop(bool, ReplayIgnoreInitErrors, false, \
328+
product(bool, ReplayIgnoreInitErrors, false, DIAGNOSTIC, \
329329
"Ignore exceptions thrown during initialization for replay") \
330330
\
331331
product(bool, DumpReplayDataOnError, true, \

src/hotspot/share/prims/jni.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -3657,9 +3657,7 @@ static jint JNI_CreateJavaVM_inner(JavaVM **vm, void **penv, void *args) {
36573657

36583658
post_thread_start_event(thread);
36593659

3660-
#ifndef PRODUCT
36613660
if (ReplayCompiles) ciReplay::replay(thread);
3662-
#endif
36633661

36643662
#ifdef ASSERT
36653663
// Some platforms (like Win*) need a wrapper around these test

src/hotspot/share/runtime/arguments.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -3872,9 +3872,12 @@ bool Arguments::handle_deprecated_print_gc_flags() {
38723872
}
38733873

38743874
static void apply_debugger_ergo() {
3875+
#ifndef PRODUCT
3876+
// UseDebuggerErgo is notproduct
38753877
if (ReplayCompiles) {
38763878
FLAG_SET_ERGO_IF_DEFAULT(UseDebuggerErgo, true);
38773879
}
3880+
#endif
38783881

38793882
if (UseDebuggerErgo) {
38803883
// Turn on sub-flags
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
25+
/*
26+
* @test
27+
* @summary Test that VM rejects and invalid replay file.
28+
* @library /test/lib
29+
* @requires vm.compMode != "Xint"
30+
* @modules java.base/jdk.internal.misc
31+
* java.management
32+
* @run driver TestInvalidReplayFile
33+
*/
34+
35+
import jdk.test.lib.process.OutputAnalyzer;
36+
import jdk.test.lib.process.ProcessTools;
37+
38+
import java.io.File;
39+
import java.io.FileWriter;
40+
41+
public class TestInvalidReplayFile {
42+
43+
44+
public static void main(String[] args) throws Exception {
45+
46+
// This test also serves as a very basic sanity test for release VMs (accepting the replay options and
47+
// attempting to read the replay file). Most of the tests in ciReplay use -XX:CICrashAt to induce artificial
48+
// crashes into the compiler, and that option is not available for release VMs. Therefore we cannot generate
49+
// replay files as a test in release builds.
50+
51+
File f = new File("bogus-replay-file.txt");
52+
FileWriter w = new FileWriter(f);
53+
w.write("Bogus 123");
54+
w.flush();
55+
w.close();
56+
57+
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
58+
"-XX:+UnlockDiagnosticVMOptions",
59+
"-Xmx100M",
60+
"-XX:+ReplayCompiles", "-XX:ReplayDataFile=./bogus-replay-file.txt");
61+
62+
OutputAnalyzer output_detail = new OutputAnalyzer(pb.start());
63+
output_detail.shouldNotHaveExitValue(0);
64+
output_detail.shouldContain("Error while parsing");
65+
66+
}
67+
}
68+
69+

0 commit comments

Comments
 (0)