aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc')
-rw-r--r--deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc60
1 files changed, 35 insertions, 25 deletions
diff --git a/deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc b/deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc
index 47d7d2e69b..299c039698 100644
--- a/deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc
+++ b/deps/v8/test/cctest/wasm/test-wasm-import-wrapper-cache.cc
@@ -4,6 +4,7 @@
#include "src/compiler/wasm-compiler.h"
#include "src/wasm/function-compiler.h"
+#include "src/wasm/module-compiler.h"
#include "src/wasm/wasm-code-manager.h"
#include "src/wasm/wasm-engine.h"
#include "src/wasm/wasm-import-wrapper-cache.h"
@@ -32,17 +33,19 @@ TEST(CacheHit) {
auto module = NewModule(isolate);
TestSignatures sigs;
WasmCodeRefScope wasm_code_ref_scope;
+ WasmImportWrapperCache::ModificationScope cache_scope(
+ module->import_wrapper_cache());
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
- WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
+ WasmCode* c1 =
+ CompileImportWrapper(isolate->wasm_engine(), module.get(),
+ isolate->counters(), kind, sigs.i_i(), &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
- WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
+ WasmCode* c2 = cache_scope[{kind, sigs.i_i()}];
CHECK_NOT_NULL(c2);
CHECK_EQ(c1, c2);
@@ -53,20 +56,21 @@ TEST(CacheMissSig) {
auto module = NewModule(isolate);
TestSignatures sigs;
WasmCodeRefScope wasm_code_ref_scope;
+ WasmImportWrapperCache::ModificationScope cache_scope(
+ module->import_wrapper_cache());
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
- WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
+ WasmCode* c1 =
+ CompileImportWrapper(isolate->wasm_engine(), module.get(),
+ isolate->counters(), kind, sigs.i_i(), &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
- WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
+ WasmCode* c2 = cache_scope[{kind, sigs.i_ii()}];
- CHECK_NOT_NULL(c2);
- CHECK_NE(c1, c2);
+ CHECK_NULL(c2);
}
TEST(CacheMissKind) {
@@ -74,21 +78,22 @@ TEST(CacheMissKind) {
auto module = NewModule(isolate);
TestSignatures sigs;
WasmCodeRefScope wasm_code_ref_scope;
+ WasmImportWrapperCache::ModificationScope cache_scope(
+ module->import_wrapper_cache());
auto kind1 = compiler::WasmImportCallKind::kJSFunctionArityMatch;
auto kind2 = compiler::WasmImportCallKind::kJSFunctionArityMismatch;
- WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind1, sigs.i_i());
+ WasmCode* c1 = CompileImportWrapper(isolate->wasm_engine(), module.get(),
+ isolate->counters(), kind1, sigs.i_i(),
+ &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
- WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind2, sigs.i_i());
+ WasmCode* c2 = cache_scope[{kind2, sigs.i_i()}];
- CHECK_NOT_NULL(c2);
- CHECK_NE(c1, c2);
+ CHECK_NULL(c2);
}
TEST(CacheHitMissSig) {
@@ -96,29 +101,34 @@ TEST(CacheHitMissSig) {
auto module = NewModule(isolate);
TestSignatures sigs;
WasmCodeRefScope wasm_code_ref_scope;
+ WasmImportWrapperCache::ModificationScope cache_scope(
+ module->import_wrapper_cache());
auto kind = compiler::WasmImportCallKind::kJSFunctionArityMatch;
- WasmCode* c1 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
+ WasmCode* c1 =
+ CompileImportWrapper(isolate->wasm_engine(), module.get(),
+ isolate->counters(), kind, sigs.i_i(), &cache_scope);
CHECK_NOT_NULL(c1);
CHECK_EQ(WasmCode::Kind::kWasmToJsWrapper, c1->kind());
- WasmCode* c2 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
+ WasmCode* c2 = cache_scope[{kind, sigs.i_ii()}];
+
+ CHECK_NULL(c2);
+
+ c2 = CompileImportWrapper(isolate->wasm_engine(), module.get(),
+ isolate->counters(), kind, sigs.i_ii(),
+ &cache_scope);
- CHECK_NOT_NULL(c2);
CHECK_NE(c1, c2);
- WasmCode* c3 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_i());
+ WasmCode* c3 = cache_scope[{kind, sigs.i_i()}];
CHECK_NOT_NULL(c3);
CHECK_EQ(c1, c3);
- WasmCode* c4 = module->import_wrapper_cache()->GetOrCompile(
- isolate->wasm_engine(), isolate->counters(), kind, sigs.i_ii());
+ WasmCode* c4 = cache_scope[{kind, sigs.i_ii()}];
CHECK_NOT_NULL(c4);
CHECK_EQ(c2, c4);