Commit 1ee8df3c authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[d8] Add compile benchmarking options

Add --compile-only and --repeat-compile=N options for benchmarking
compilation performance.

Change-Id: Ibcdce94ef0d2a24374badeca114f44b693adb2ac
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2827903
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73987}
parent 3d4b92eb
......@@ -696,6 +696,12 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
Local<Context> context(isolate->GetCurrentContext());
ScriptOrigin origin(isolate, name);
for (int i = 1; i < options.repeat_compile; ++i) {
HandleScope handle_scope(isolate);
if (CompileString<Script>(isolate, context, source, origin).IsEmpty()) {
return false;
}
}
Local<Script> script;
if (!CompileString<Script>(isolate, context, source, origin)
.ToLocal(&script)) {
......@@ -710,6 +716,9 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
StoreInCodeCache(isolate, source, cached_data);
delete cached_data;
}
if (options.compile_only) {
return true;
}
maybe_result = script->Run(realm);
if (options.code_cache_options ==
ShellOptions::CodeCacheOptions::kProduceCacheAfterExecute) {
......@@ -4058,6 +4067,12 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--web-snapshot-config=", 22) == 0) {
options.web_snapshot_config = argv[i] + 22;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--compile-only") == 0) {
options.compile_only = true;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--repeat-compile=", 17) == 0) {
options.repeat_compile = atoi(argv[i] + 17);
argv[i] = nullptr;
#ifdef V8_FUZZILLI
} else if (strcmp(argv[i], "--no-fuzzilli-enable-builtins-coverage") == 0) {
options.fuzzilli_enable_builtins_coverage = false;
......
......@@ -403,6 +403,8 @@ class ShellOptions {
"enable-system-instrumentation", false};
DisallowReassignment<const char*> web_snapshot_config = {
"web-snapshot-config", nullptr};
DisallowReassignment<bool> compile_only = {"compile-only", false};
DisallowReassignment<int> repeat_compile = {"repeat-compile", 1};
};
class Shell : public i::AllStatic {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment