Commit 8255fb5e authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] Add --wasm-lazy-compilation flag

This will lazily compile all wasm modules. Just for experimenting
currently.

R=ahaas@chromium.org
BUG=v8:5991

Change-Id: I51fc3655e15f55e87d9fec86ff5dca109fb052be
Reviewed-on: https://chromium-review.googlesource.com/458008Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#44044}
parent 69ad35ac
......@@ -2946,9 +2946,9 @@ Node* WasmGraphBuilder::SetGlobal(uint32_t index, Node* val) {
void WasmGraphBuilder::BoundsCheckMem(MachineType memtype, Node* index,
uint32_t offset,
wasm::WasmCodePosition position) {
DCHECK(module_ && module_->instance);
if (FLAG_wasm_no_bounds_checks) return;
uint32_t size = module_->instance->mem_size;
uint32_t size =
module_ && module_->instance ? module_->instance->mem_size : 0;
byte memsize = wasm::WasmOpcodes::MemSize(memtype);
size_t effective_size;
......
......@@ -967,8 +967,8 @@ class RuntimeCallTimerScope {
MICROSECOND) \
HT(asm_wasm_translation_time, V8.AsmWasmTranslationMicroSeconds, 1000000, \
MICROSECOND) \
HT(asm_wasm_lazy_compilation_time, V8.AsmWasmLazyCompilationMicroSeconds, \
1000000, MICROSECOND)
HT(wasm_lazy_compilation_time, V8.WasmLazyCompilationMicroSeconds, 1000000, \
MICROSECOND)
#define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
AHT(compile_lazy, V8.CompileLazyMicroSeconds)
......@@ -1137,7 +1137,7 @@ class RuntimeCallTimerScope {
SC(total_baseline_compile_count, V8.TotalBaselineCompileCount) \
SC(wasm_generated_code_size, V8.WasmGeneratedCodeBytes) \
SC(wasm_reloc_size, V8.WasmRelocBytes) \
SC(asm_wasm_lazily_compiled_functions, V8.AsmWasmLazilyCompiledFunctions)
SC(wasm_lazily_compiled_functions, V8.WasmLazilyCompiledFunctions)
// This file contains all the v8 counters that are in use.
class Counters {
......
......@@ -587,6 +587,8 @@ DEFINE_BOOL(wasm_interpret_all, false,
DEFINE_BOOL(asm_wasm_lazy_compilation, false,
"enable lazy compilation for asm-wasm modules")
DEFINE_IMPLICATION(validate_asm, asm_wasm_lazy_compilation)
DEFINE_BOOL(wasm_lazy_compilation, false,
"enable lazy compilation for all wasm modules")
// Profiler flags.
DEFINE_INT(frame_count, 1, "number of stack frames inspected by the profiler")
......
......@@ -289,6 +289,11 @@ Handle<Code> EnsureTableExportLazyDeoptData(
return code;
}
bool compile_lazy(const WasmModule* module) {
return FLAG_wasm_lazy_compilation || (FLAG_asm_wasm_lazy_compilation &&
module->origin == wasm::kAsmJsOrigin);
}
// A helper for compiling an entire module.
class CompilationHelper {
public:
......@@ -521,8 +526,7 @@ class CompilationHelper {
factory->NewFixedArray(static_cast<int>(code_table_size), TENURED);
// Check whether lazy compilation is enabled for this module.
bool lazy_compile =
FLAG_asm_wasm_lazy_compilation && module_->origin == wasm::kAsmJsOrigin;
bool lazy_compile = compile_lazy(module_);
// If lazy compile: Initialize the code table with the lazy compile builtin.
// Otherwise: Initialize with the illegal builtin. All call sites will be
......@@ -871,7 +875,7 @@ int ExtractDirectCallIndex(wasm::Decoder& decoder, const byte* pc) {
}
void RecordLazyCodeStats(Isolate* isolate, Code* code) {
isolate->counters()->asm_wasm_lazily_compiled_functions()->Increment();
isolate->counters()->wasm_lazily_compiled_functions()->Increment();
isolate->counters()->wasm_generated_code_size()->Increment(code->body_size());
isolate->counters()->wasm_reloc_size()->Increment(
code->relocation_info()->length());
......@@ -2184,8 +2188,7 @@ class InstantiationHelper {
// Count the number of table exports for each function (needed for lazy
// compilation).
std::unordered_map<uint32_t, uint32_t> num_table_exports;
if (FLAG_asm_wasm_lazy_compilation &&
module_->origin == ModuleOrigin::kAsmJsOrigin) {
if (compile_lazy(module_)) {
for (auto table_init : module_->table_inits) {
for (uint32_t func_index : table_init.entries) {
Code* code =
......@@ -2945,7 +2948,7 @@ void wasm::AsyncCompileAndInstantiate(Isolate* isolate,
Handle<Code> wasm::CompileLazy(Isolate* isolate) {
HistogramTimerScope lazy_time_scope(
isolate->counters()->asm_wasm_lazy_compilation_time());
isolate->counters()->wasm_lazy_compilation_time());
// Find the wasm frame which triggered the lazy compile, to get the wasm
// instance.
......
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