Commit 45a6503c authored by Frederik Gossen's avatar Frederik Gossen Committed by Commit Bot

[wasm-hints] Add Tests for Compilation Hints

Add tests for tiering and lazy compilation with compilation hints. The
tests build modules and verify the {WasmCode}'s tier internally. The
module builder now supports compilation hints in CCTests.

Bug: v8:9003
Change-Id: I18d926c3b1ef3508835a51a9d1d86bfadcb5216e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1566522Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Frederik Gossen <frgossen@google.com>
Cr-Commit-Position: refs/heads/master@{#60916}
parent f3546530
......@@ -1465,6 +1465,7 @@ WasmCodeRefScope::~WasmCodeRefScope() {
// static
void WasmCodeRefScope::AddRef(WasmCode* code) {
DCHECK_NOT_NULL(code);
WasmCodeRefScope* current_scope = current_code_refs_scope;
DCHECK_NOT_NULL(current_scope);
auto entry = current_scope->code_ptrs_.insert(code);
......
......@@ -8,6 +8,8 @@
#include <cstddef>
#include <cstdint>
#include "src/globals.h"
namespace v8 {
namespace internal {
namespace wasm {
......@@ -87,6 +89,10 @@ enum SectionCode : int8_t {
kFirstUnorderedSection = kDataCountSectionCode,
};
// Binary encoding of compilation hints.
constexpr uint8_t kDefaultCompilationHint = 0x0;
constexpr uint8_t kNoCompilationHint = kMaxUInt8;
// Binary encoding of name section kinds.
enum NameSectionKindCode : uint8_t { kModule = 0, kFunction = 1, kLocal = 2 };
......
......@@ -171,6 +171,16 @@ void WasmFunctionBuilder::SetAsmFunctionStartPosition(
last_asm_source_position_ = function_position_u32;
}
void WasmFunctionBuilder::SetCompilationHint(
WasmCompilationHintStrategy strategy, WasmCompilationHintTier baseline,
WasmCompilationHintTier top_tier) {
uint8_t hint_byte = static_cast<uint8_t>(strategy) |
static_cast<uint8_t>(baseline) << 2 |
static_cast<uint8_t>(top_tier) << 4;
DCHECK_NE(hint_byte, kNoCompilationHint);
hint_ = hint_byte;
}
void WasmFunctionBuilder::DeleteCodeAfter(size_t position) {
DCHECK_LE(position, body_.size());
body_.Truncate(position);
......@@ -361,7 +371,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
if (functions_.size() > 0) {
size_t start = EmitSection(kFunctionSectionCode, buffer);
buffer.write_size(functions_.size());
for (auto function : functions_) {
for (auto* function : functions_) {
function->WriteSignature(buffer);
if (!function->name_.empty()) ++num_function_names;
}
......@@ -498,11 +508,37 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
FixupSection(buffer, start);
}
// == emit compilation hints section =========================================
bool emit_compilation_hints = false;
for (auto* fn : functions_) {
if (fn->hint_ != kNoCompilationHint) {
emit_compilation_hints = true;
break;
}
}
if (emit_compilation_hints) {
// Emit the section code.
buffer.write_u8(kUnknownSectionCode);
// Emit a placeholder for section length.
size_t start = buffer.reserve_u32v();
// Emit custom section name.
buffer.write_string(CStrVector("compilationHints"));
// Emit hint count.
buffer.write_size(functions_.size());
// Emit hint bytes.
for (auto* fn : functions_) {
uint8_t hint_byte =
fn->hint_ != kNoCompilationHint ? fn->hint_ : kDefaultCompilationHint;
buffer.write_u8(hint_byte);
}
FixupSection(buffer, start);
}
// == emit code ==============================================================
if (functions_.size() > 0) {
size_t start = EmitSection(kCodeSectionCode, buffer);
buffer.write_size(functions_.size());
for (auto function : functions_) {
for (auto* function : functions_) {
function->WriteBody(buffer);
}
FixupSection(buffer, start);
......@@ -531,8 +567,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
// Emit a placeholder for the length.
size_t start = buffer.reserve_u32v();
// Emit the section string.
buffer.write_size(4);
buffer.write(reinterpret_cast<const byte*>("name"), 4);
buffer.write_string(CStrVector("name"));
// Emit a subsection for the function names.
buffer.write_u8(NameSectionKindCode::kFunction);
// Emit a placeholder for the subsection length.
......@@ -549,7 +584,7 @@ void WasmModuleBuilder::WriteTo(ZoneBuffer& buffer) const {
buffer.write_string(import->name);
}
if (num_function_names > 0) {
for (auto function : functions_) {
for (auto* function : functions_) {
DCHECK_EQ(function_index,
function->func_index() + function_imports_.size());
if (!function->name_.empty()) {
......@@ -568,7 +603,7 @@ void WasmModuleBuilder::WriteAsmJsOffsetTable(ZoneBuffer& buffer) const {
// == Emit asm.js offset table ===============================================
buffer.write_size(functions_.size());
// Emit the offset table per function.
for (auto function : functions_) {
for (auto* function : functions_) {
function->WriteAsmWasmOffsetTable(buffer);
}
// Append a 0 to indicate that this is an encoded table.
......
......@@ -12,6 +12,7 @@
#include "src/vector.h"
#include "src/wasm/leb-helper.h"
#include "src/wasm/local-decl-encoder.h"
#include "src/wasm/wasm-module.h"
#include "src/wasm/wasm-opcodes.h"
#include "src/wasm/wasm-result.h"
......@@ -176,6 +177,9 @@ class V8_EXPORT_PRIVATE WasmFunctionBuilder : public ZoneObject {
void SetName(Vector<const char> name);
void AddAsmWasmOffset(size_t call_position, size_t to_number_position);
void SetAsmFunctionStartPosition(size_t function_position);
void SetCompilationHint(WasmCompilationHintStrategy strategy,
WasmCompilationHintTier baseline,
WasmCompilationHintTier top_tier);
size_t GetPosition() const { return body_.size(); }
void FixupByte(size_t position, byte value) {
......@@ -217,6 +221,7 @@ class V8_EXPORT_PRIVATE WasmFunctionBuilder : public ZoneObject {
uint32_t last_asm_byte_offset_ = 0;
uint32_t last_asm_source_position_ = 0;
uint32_t asm_func_start_source_position_ = 0;
uint8_t hint_ = kNoCompilationHint;
};
class V8_EXPORT_PRIVATE WasmModuleBuilder : public ZoneObject {
......
......@@ -93,6 +93,155 @@ TEST(Run_WasmModule_Return114) {
Cleanup();
}
TEST(Run_WasmModule_CompilationHintsLazy) {
if (!FLAG_wasm_tier_up || !FLAG_liftoff) return;
{
EXPERIMENTAL_FLAG_SCOPE(compilation_hints);
static const int32_t kReturnValue = 114;
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
// Build module with one lazy function.
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_I32V_2(kReturnValue)};
EMIT_CODE_WITH_END(f, code);
f->SetCompilationHint(WasmCompilationHintStrategy::kLazy,
WasmCompilationHintTier::kBaseline,
WasmCompilationHintTier::kOptimized);
// Compile module. No function is actually compiled as the function is lazy.
ZoneBuffer buffer(&zone);
builder->WriteTo(buffer);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
testing::SetupIsolateForWasmModule(isolate);
ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
MaybeHandle<WasmModuleObject> module = testing::CompileForTesting(
isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end()));
CHECK(!module.is_null());
// Lazy function was not invoked and therefore not compiled yet.
int func_index = 0;
NativeModule* native_module = module.ToHandleChecked()->native_module();
CHECK(!native_module->HasCode(func_index));
// Instantiate and invoke function.
MaybeHandle<WasmInstanceObject> instance =
isolate->wasm_engine()->SyncInstantiate(
isolate, &thrower, module.ToHandleChecked(), {}, {});
CHECK(!instance.is_null());
int32_t result = testing::RunWasmModuleForTesting(
isolate, instance.ToHandleChecked(), 0, nullptr);
CHECK_EQ(kReturnValue, result);
// Lazy function was invoked and therefore compiled.
CHECK(native_module->HasCode(func_index));
WasmCodeRefScope code_ref_scope;
ExecutionTier actual_tier = native_module->GetCode(func_index)->tier();
static_assert(ExecutionTier::kInterpreter < ExecutionTier::kLiftoff &&
ExecutionTier::kLiftoff < ExecutionTier::kTurbofan,
"Assume an order on execution tiers");
ExecutionTier baseline_tier = ExecutionTier::kLiftoff;
CHECK_LE(baseline_tier, actual_tier);
}
Cleanup();
}
TEST(Run_WasmModule_CompilationHintsNoTiering) {
if (!FLAG_wasm_tier_up || !FLAG_liftoff) return;
{
EXPERIMENTAL_FLAG_SCOPE(compilation_hints);
static const int32_t kReturnValue = 114;
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
// Build module with regularly compiled function (no tiering).
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_I32V_2(kReturnValue)};
EMIT_CODE_WITH_END(f, code);
f->SetCompilationHint(WasmCompilationHintStrategy::kEager,
WasmCompilationHintTier::kBaseline,
WasmCompilationHintTier::kBaseline);
// Compile module.
ZoneBuffer buffer(&zone);
builder->WriteTo(buffer);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
testing::SetupIsolateForWasmModule(isolate);
ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
MaybeHandle<WasmModuleObject> module = testing::CompileForTesting(
isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end()));
CHECK(!module.is_null());
// Synchronous compilation finished and no tiering units were initialized.
int func_index = 0;
NativeModule* native_module = module.ToHandleChecked()->native_module();
CHECK(native_module->HasCode(func_index));
WasmCodeRefScope code_ref_scope;
ExecutionTier expected_tier = ExecutionTier::kLiftoff;
ExecutionTier actual_tier = native_module->GetCode(func_index)->tier();
CHECK_EQ(expected_tier, actual_tier);
}
Cleanup();
}
TEST(Run_WasmModule_CompilationHintsTierUp) {
if (!FLAG_wasm_tier_up || !FLAG_liftoff) return;
{
EXPERIMENTAL_FLAG_SCOPE(compilation_hints);
static const int32_t kReturnValue = 114;
TestSignatures sigs;
v8::internal::AccountingAllocator allocator;
Zone zone(&allocator, ZONE_NAME);
// Build module with tiering compilation hint.
WasmModuleBuilder* builder = new (&zone) WasmModuleBuilder(&zone);
WasmFunctionBuilder* f = builder->AddFunction(sigs.i_v());
ExportAsMain(f);
byte code[] = {WASM_I32V_2(kReturnValue)};
EMIT_CODE_WITH_END(f, code);
f->SetCompilationHint(WasmCompilationHintStrategy::kEager,
WasmCompilationHintTier::kBaseline,
WasmCompilationHintTier::kOptimized);
// Compile module.
ZoneBuffer buffer(&zone);
builder->WriteTo(buffer);
Isolate* isolate = CcTest::InitIsolateOnce();
HandleScope scope(isolate);
testing::SetupIsolateForWasmModule(isolate);
ErrorThrower thrower(isolate, "CompileAndRunWasmModule");
MaybeHandle<WasmModuleObject> module = testing::CompileForTesting(
isolate, &thrower, ModuleWireBytes(buffer.begin(), buffer.end()));
CHECK(!module.is_null());
// Expect code baseline code or top tier code.
int func_index = 0;
NativeModule* native_module = module.ToHandleChecked()->native_module();
CHECK(native_module->HasCode(func_index));
WasmCodeRefScope code_ref_scope;
ExecutionTier actual_tier = native_module->GetCode(func_index)->tier();
static_assert(ExecutionTier::kInterpreter < ExecutionTier::kLiftoff &&
ExecutionTier::kLiftoff < ExecutionTier::kTurbofan,
"Assume an order on execution tiers");
ExecutionTier baseline_tier = ExecutionTier::kLiftoff;
CHECK_LE(baseline_tier, actual_tier);
ExecutionTier top_tier = ExecutionTier::kTurbofan;
CHECK_LE(actual_tier, top_tier);
}
Cleanup();
}
TEST(Run_WasmModule_CallAdd) {
{
v8::internal::AccountingAllocator allocator;
......
......@@ -26,14 +26,21 @@ uint32_t GetInitialMemSize(const WasmModule* module) {
return kWasmPageSize * module->initial_pages;
}
MaybeHandle<WasmInstanceObject> CompileAndInstantiateForTesting(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes) {
MaybeHandle<WasmModuleObject> CompileForTesting(Isolate* isolate,
ErrorThrower* thrower,
const ModuleWireBytes& bytes) {
auto enabled_features = WasmFeaturesFromIsolate(isolate);
MaybeHandle<WasmModuleObject> module = isolate->wasm_engine()->SyncCompile(
isolate, enabled_features, thrower, bytes);
DCHECK_EQ(thrower->error(), module.is_null());
if (module.is_null()) return {};
return module;
}
MaybeHandle<WasmInstanceObject> CompileAndInstantiateForTesting(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes) {
MaybeHandle<WasmModuleObject> module =
CompileForTesting(isolate, thrower, bytes);
if (module.is_null()) return {};
return isolate->wasm_engine()->SyncInstantiate(
isolate, thrower, module.ToHandleChecked(), {}, {});
}
......
......@@ -57,6 +57,11 @@ bool InterpretWasmModuleForTesting(Isolate* isolate,
int32_t CompileAndRunWasmModule(Isolate* isolate, const byte* module_start,
const byte* module_end);
// Decode and compile the given module with no imports.
MaybeHandle<WasmModuleObject> CompileForTesting(Isolate* isolate,
ErrorThrower* thrower,
const ModuleWireBytes& bytes);
// Decode, compile, and instantiate the given module with no imports.
MaybeHandle<WasmInstanceObject> CompileAndInstantiateForTesting(
Isolate* isolate, ErrorThrower* thrower, const ModuleWireBytes& bytes);
......
......@@ -11,9 +11,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_i)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.compile(bytes)
......@@ -27,9 +27,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_l)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.compile(bytes)
......@@ -50,9 +50,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_i)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiate(bytes)
......
......@@ -13,9 +13,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.exportFunc();
assertThrows(() => builder.instantiate({mod: {pow: Math.pow}}),
WebAssembly.CompileError,
......@@ -30,9 +30,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyDefault,
kCompilationHintTierInterpreter,
kCompilationHintTierInterpreter)
.setCompilationHint(kCompilationHintStrategyDefault,
kCompilationHintTierInterpreter,
kCompilationHintTierInterpreter)
.exportFunc();
builder.addFunction('upow2', kSig_i_i)
.addBody([kExprGetLocal, 0,
......@@ -61,9 +61,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierBaseline,
kCompilationHintTierOptimized)
.setCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierBaseline,
kCompilationHintTierOptimized)
.exportFunc();
let instance = builder.instantiate({mod: {pow: Math.pow}});
assertEquals(27, instance.exports.upow(3))
......@@ -75,9 +75,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprI32Mul])
.giveCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierDefault,
kCompilationHintTierOptimized)
.setCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierDefault,
kCompilationHintTierOptimized)
.exportFunc();
let instance = builder.instantiate();
assertEquals(9, instance.exports.sq(3))
......@@ -89,9 +89,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprI32Mul])
.giveCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierDefault,
kCompilationHintTierOptimized)
.setCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierDefault,
kCompilationHintTierOptimized)
builder.instantiate();
})();
......@@ -101,9 +101,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprI32Mul])
.giveCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierOptimized,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyEager,
kCompilationHintTierOptimized,
kCompilationHintTierDefault)
.exportFunc();
let instance = builder.instantiate();
assertEquals(9, instance.exports.sq(3))
......@@ -115,9 +115,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprI32Mul])
.giveCompilationHint(0x3,
kCompilationHintTierOptimized,
kCompilationHintTierDefault)
.setCompilationHint(0x3,
kCompilationHintTierOptimized,
kCompilationHintTierDefault)
.exportFunc();
assertThrows(() => builder.instantiate(),
WebAssembly.CompileError,
......
......@@ -12,9 +12,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyDefault,
kCompilationHintTierInterpreter,
kCompilationHintTierInterpreter)
.setCompilationHint(kCompilationHintStrategyDefault,
kCompilationHintTierInterpreter,
kCompilationHintTierInterpreter)
.exportFunc();
let instance = builder.instantiate({mod: {pow: Math.pow}});
assertEquals(27, instance.exports.upow(3))
......
......@@ -18,9 +18,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes),
......@@ -40,9 +40,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes),
......@@ -65,9 +65,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes),
......@@ -94,9 +94,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
.addBody([kExprGetLocal, 0,
kExprGetLocal, 0,
kExprCallFunction, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
let bytes = builder.toBuffer();
assertPromiseResult(WebAssembly.instantiateStreaming(Promise.resolve(bytes),
......
......@@ -11,9 +11,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_i)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierOptimized,
kCompilationHintTierBaseline)
.exportFunc();
assertThrows(() => builder.toModule(),
WebAssembly.CompileError,
......@@ -26,9 +26,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_l)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
assertThrows(() => builder.toModule(),
WebAssembly.CompileError,
......@@ -47,9 +47,9 @@ load('test/mjsunit/wasm/wasm-module-builder.js');
let builder = new WasmModuleBuilder();
builder.addFunction('id', kSig_i_i)
.addBody([kExprGetLocal, 0])
.giveCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.setCompilationHint(kCompilationHintStrategyLazy,
kCompilationHintTierDefault,
kCompilationHintTierDefault)
.exportFunc();
assertEquals(42, builder.instantiate().exports.id(42));
})();
......@@ -640,8 +640,8 @@ class WasmFunctionBuilder {
return this;
}
giveCompilationHint(strategy, baselineTier, topTier) {
this.module.giveCompilationHint(strategy, baselineTier, topTier, this.index);
setCompilationHint(strategy, baselineTier, topTier) {
this.module.setCompilationHint(strategy, baselineTier, topTier, this.index);
return this;
}
......@@ -871,7 +871,7 @@ class WasmModuleBuilder {
return this;
}
giveCompilationHint(strategy, baselineTier, topTier, index) {
setCompilationHint(strategy, baselineTier, topTier, index) {
this.compilation_hints[index] = {strategy: strategy, baselineTier:
baselineTier, topTier: topTier};
return this;
......
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