Commit 1583e86d authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[wasm] Remove Isolate from WasmImportWrapperCache.

R=clemensh@chromium.org

Change-Id: I48bfae1dbbfaafb1cadad8d3cbbc921c53801f8c
Reviewed-on: https://chromium-review.googlesource.com/c/1405857Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58727}
parent 63e2c114
......@@ -1632,7 +1632,7 @@ bool InstanceBuilder::ProcessImportedFunction(
// The imported function is a callable.
NativeModule* native_module = instance->module_object()->native_module();
WasmCode* wasm_code = native_module->import_wrapper_cache()->GetOrCompile(
isolate_, kind, expected_sig);
isolate_->wasm_engine(), isolate_->counters(), kind, expected_sig);
ImportedFunctionEntry entry(instance, func_index);
if (wasm_code->kind() == WasmCode::kWasmToJsWrapper) {
// Wasm to JS wrappers are treated specially in the import table.
......
......@@ -7,8 +7,6 @@
#include "src/compiler/wasm-compiler.h"
#include "src/counters.h"
#include "src/handles-inl.h"
#include "src/objects/code-inl.h"
#include "src/wasm/value-type.h"
#include "src/wasm/wasm-code-manager.h"
......@@ -19,19 +17,16 @@ namespace wasm {
// Implements a cache for import wrappers.
class WasmImportWrapperCache {
public:
WasmCode* GetOrCompile(Isolate* isolate, compiler::WasmImportCallKind kind,
FunctionSig* sig) {
// TODO(titzer/mstarzinger): remove the isolate parameter.
WasmCode* GetOrCompile(WasmEngine* wasm_engine, Counters* counters,
compiler::WasmImportCallKind kind, FunctionSig* sig) {
base::MutexGuard lock(&mutex_);
CacheKey key(static_cast<uint8_t>(kind), *sig);
WasmCode*& cached = entry_map_[key];
if (cached == nullptr) {
// TODO(wasm): no need to hold the lock while compiling an import wrapper.
HandleScope scope(isolate);
bool source_positions = native_module_->module()->origin == kAsmJsOrigin;
cached = compiler::CompileWasmImportCallWrapper(
isolate->wasm_engine(), native_module_, kind, sig, source_positions);
auto counters = isolate->counters();
wasm_engine, native_module_, kind, sig, source_positions);
counters->wasm_generated_code_size()->Increment(
cached->instructions().length());
counters->wasm_reloc_size()->Increment(cached->reloc_info().length());
......
......@@ -35,14 +35,14 @@ TEST(CacheHit) {
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
WasmCode* c1 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_i());
WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
WasmCode* c2 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_i());
WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
CHECK_NOT_NULL(c2);
CHECK_EQ(c1, c2);
......@@ -55,14 +55,14 @@ TEST(CacheMissSig) {
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
WasmCode* c1 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_i());
WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
WasmCode* c2 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_ii());
WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
CHECK_NOT_NULL(c2);
CHECK_NE(c1, c2);
......@@ -76,14 +76,14 @@ TEST(CacheMissKind) {
auto kind1 = compiler::WasmImportCallKind::kJSFunctionArityMatch;
auto kind2 = compiler::WasmImportCallKind::kJSFunctionArityMismatch;
WasmCode* c1 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind1, sigs.i_i());
WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind1, sigs.i_i());
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
WasmCode* c2 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind2, sigs.i_i());
WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind2, sigs.i_i());
CHECK_NOT_NULL(c2);
CHECK_NE(c1, c2);
......@@ -96,26 +96,26 @@ TEST(CacheHitMissSig) {
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
WasmCode* c1 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_i());
WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
WasmCode* c2 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_ii());
WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
CHECK_NOT_NULL(c2);
CHECK_NE(c1, c2);
WasmCode* c3 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_i());
WasmCode* c3 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
CHECK_NOT_NULL(c3);
CHECK_EQ(c1, c3);
WasmCode* c4 =
module->import_wrapper_cache()->GetOrCompile(isolate, kind, sigs.i_ii());
WasmCode* c4 = module->import_wrapper_cache()->GetOrCompile(
isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
CHECK_NOT_NULL(c4);
CHECK_EQ(c2, c4);
......
......@@ -46,7 +46,7 @@ TestingModuleBuilder::TestingModuleBuilder(
auto kind = compiler::GetWasmImportCallKind(maybe_import->js_function,
maybe_import->sig, false);
auto import_wrapper = native_module_->import_wrapper_cache()->GetOrCompile(
isolate_, kind, maybe_import->sig);
isolate_->wasm_engine(), isolate_->counters(), kind, maybe_import->sig);
ImportedFunctionEntry(instance_object_, maybe_import_index)
.SetWasmToJs(isolate_, maybe_import->js_function, import_wrapper);
......
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