8293287: add ReplayReduce flag

Reviewed-by: kvn, thartmann
This commit is contained in:
Dean Long 2022-09-09 18:45:43 +00:00
parent b8598b0297
commit dbec22b84b
9 changed files with 47 additions and 94 deletions

@ -1647,6 +1647,12 @@ void ciEnv::find_dynamic_call_sites() {
void ciEnv::dump_compile_data(outputStream* out) {
CompileTask* task = this->task();
if (task) {
#ifdef COMPILER2
if (ReplayReduce && compiler_data() != NULL) {
// Dump C2 "reduced" inlining data.
((Compile*)compiler_data())->dump_inline_data_reduced(out);
}
#endif
Method* method = task->method();
int entry_bci = task->osr_bci();
int comp_level = task->comp_level();

@ -633,6 +633,7 @@ class CompileReplay : public StackObj {
}
line_no++;
}
reset();
}
void process_command(TRAPS) {
@ -731,13 +732,7 @@ class CompileReplay : public StackObj {
Method* method = parse_method(CHECK);
if (had_error()) return;
int entry_bci = parse_int("entry_bci");
const char* comp_level_label = "comp_level";
int comp_level = parse_int(comp_level_label);
// old version w/o comp_level
if (had_error() && (error_message() == comp_level_label)) {
// use highest available tier
comp_level = CompilationPolicy::highest_compile_level();
}
int comp_level = parse_int("comp_level");
if (!is_valid_comp_level(comp_level)) {
return;
}
@ -808,7 +803,6 @@ class CompileReplay : public StackObj {
CompileBroker::compile_method(methodHandle(THREAD, method), entry_bci, comp_level,
methodHandle(), 0, CompileTask::Reason_Replay, THREAD);
replay_state = NULL;
reset();
}
// ciMethod <klass> <name> <signature> <invocation_counter> <backedge_counter> <interpreter_invocation_count> <interpreter_throwout_count> <instructions_size>

@ -308,6 +308,9 @@
product(bool, ReplayCompiles, false, DIAGNOSTIC, \
"Enable replay of compilations from ReplayDataFile") \
\
product(bool, ReplayReduce, false, EXPERIMENTAL, \
"Enable features to facilitate replay file reduction") \
\
product(ccstr, ReplayDataFile, NULL, \
"File containing compilation replay information" \
"[default: ./replay_pid%p.log] (%p replaced with pid)") \

@ -713,11 +713,11 @@ int InlineTree::count() const {
return result;
}
void InlineTree::dump_replay_data(outputStream* out) {
out->print(" %d %d %d ", inline_level(), caller_bci(), _late_inline);
void InlineTree::dump_replay_data(outputStream* out, int depth_adjust) {
out->print(" %d %d %d ", inline_level() + depth_adjust, caller_bci(), _late_inline);
method()->dump_name_as_ascii(out);
for (int i = 0 ; i < _subtrees.length(); i++) {
_subtrees.at(i)->dump_replay_data(out);
_subtrees.at(i)->dump_replay_data(out, depth_adjust);
}
}

@ -4574,6 +4574,35 @@ void Compile::dump_inline_data(outputStream* out) {
}
}
void Compile::dump_inline_data_reduced(outputStream* out) {
assert(ReplayReduce, "");
InlineTree* inl_tree = ilt();
if (inl_tree == NULL) {
return;
}
// Enable iterative replay file reduction
// Output "compile" lines for depth 1 subtrees,
// simulating that those trees were compiled
// instead of inlined.
for (int i = 0; i < inl_tree->subtrees().length(); ++i) {
InlineTree* sub = inl_tree->subtrees().at(i);
if (sub->inline_level() != 1) {
continue;
}
ciMethod* method = sub->method();
int entry_bci = -1;
int comp_level = env()->task()->comp_level();
out->print("compile ");
method->dump_name_as_ascii(out);
out->print(" %d %d", entry_bci, comp_level);
out->print(" inline %d", sub->count());
sub->dump_replay_data(out, -1);
out->cr();
}
}
int Compile::cmp_expensive_nodes(Node* n1, Node* n2) {
if (n1->Opcode() < n2->Opcode()) return -1;
else if (n1->Opcode() > n2->Opcode()) return 1;

@ -506,6 +506,7 @@ class Compile : public Phase {
// Dump inlining replay data to the stream.
void dump_inline_data(outputStream* out);
void dump_inline_data_reduced(outputStream* out);
private:
// Matching, CFG layout, allocation, code generation

@ -92,7 +92,6 @@ protected:
InlineTree* caller_tree() const { return _caller_tree; }
InlineTree* callee_at(int bci, ciMethod* m) const;
int inline_level() const { return stack_depth(); }
int stack_depth() const { return _caller_jvms ? _caller_jvms->depth() : 0; }
const char* msg() const { return _msg; }
void set_msg(const char* msg) { _msg = msg; }
@ -124,6 +123,7 @@ public:
ciMethod *method() const { return _method; }
int caller_bci() const { return _caller_jvms ? _caller_jvms->bci() : InvocationEntryBci; }
uint count_inline_bcs() const { return _count_inline_bcs; }
int inline_level() const { return stack_depth(); }
#ifndef PRODUCT
private:
@ -141,7 +141,7 @@ public:
// Count number of nodes in this subtree
int count() const;
// Dump inlining replay data to the stream.
void dump_replay_data(outputStream* out);
void dump_replay_data(outputStream* out, int depth_adjust = 0);
};

@ -1698,7 +1698,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt
MemTracker::final_report(&fds);
}
static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay
static bool skip_replay = ReplayCompiles && !ReplayReduce; // Do not overwrite file during replay
if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) {
skip_replay = true;
ciEnv* env = ciEnv::current();

@ -1,80 +0,0 @@
/*
* Copyright (c) 2016, 2022, 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.
*/
/**
* @test
* @bug 8011675
* @library / /test/lib
* @summary testing of ciReplay with using generated by VM replay.txt w/o comp_level
* @requires vm.flightRecorder != true & vm.compMode != "Xint" & vm.debug == true &
* (vm.opt.TieredStopAtLevel == null | vm.opt.TieredStopAtLevel == 1 | vm.opt.TieredStopAtLevel == 4)
* @modules java.base/jdk.internal.misc
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* compiler.ciReplay.TestVMNoCompLevel
*/
package compiler.ciReplay;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.nio.file.StandardOpenOption;
import java.util.List;
public class TestVMNoCompLevel extends CiReplayBase {
public static void main(String args[]) {
new TestVMNoCompLevel().runTest(false);
}
@Override
public void testAction() {
try {
Path replayFilePath = Paths.get(REPLAY_FILE_NAME);
List<String> replayContent = Files.readAllLines(replayFilePath);
for (int i = 0; i < replayContent.size(); i++) {
String line = replayContent.get(i);
if (line.startsWith("compile ")) {
replayContent.set(i, line.substring(0, line.lastIndexOf(" ")));
}
}
Files.write(replayFilePath, replayContent, StandardOpenOption.TRUNCATE_EXISTING);
} catch (IOException ioe) {
throw new Error("Failed to read/write replay data: " + ioe, ioe);
}
if (CLIENT_VM_AVAILABLE) {
if (SERVER_VM_AVAILABLE) {
negativeTest(CLIENT_VM_OPTION);
} else {
positiveTest(CLIENT_VM_OPTION);
}
}
if (SERVER_VM_AVAILABLE) {
positiveTest(TIERED_DISABLED_VM_OPTION, SERVER_VM_OPTION);
positiveTest(TIERED_ENABLED_VM_OPTION, SERVER_VM_OPTION);
}
}
}