Commit a1c96c7b authored by Clemens Backes's avatar Clemens Backes Committed by V8 LUCI CQ

[wasm] Enable dynamic tiering in serialization tests

Some tests disabled dynamic tiering in order to actually serialize
TurboFan code. This makes the tests a bit simpler, but does not reflect
real-world usage.
This CL enables dynamic tiering in those tests and when needed executes
the code until tier-up was observed.

R=ahaas@chromium.org

Bug: v8:12899
Change-Id: I34cb8cedbc5908d9e6ca09d56c51609d0c8b2d6a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3660262
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/main@{#80849}
parent b5ccb0ef
......@@ -23,21 +23,18 @@
#include "test/common/wasm/wasm-macro-gen.h"
#include "test/common/wasm/wasm-module-runner.h"
namespace v8 {
namespace internal {
namespace wasm {
namespace test_wasm_serialization {
namespace v8::internal::wasm {
// Approximate gtest TEST_F style, in case we adopt gtest.
class WasmSerializationTest {
public:
WasmSerializationTest()
: zone_(&allocator_, ZONE_NAME),
no_wasm_dynamic_tiering_(&FLAG_wasm_dynamic_tiering, false) {
WasmSerializationTest() : zone_(&allocator_, ZONE_NAME) {
// Don't call here if we move to gtest.
SetUp();
}
static constexpr const char* kFunctionName = "increment";
static void BuildWireBytes(Zone* zone, ZoneBuffer* buffer) {
WasmModuleBuilder* builder = zone->New<WasmModuleBuilder>(zone);
TestSignatures sigs;
......@@ -50,7 +47,7 @@ class WasmSerializationTest {
builder->WriteTo(buffer);
}
void ClearSerializedData() { serialized_bytes_ = {nullptr, 0}; }
void ClearSerializedData() { serialized_bytes_ = {}; }
void InvalidateVersion() {
uint32_t* slot = reinterpret_cast<uint32_t*>(
......@@ -104,8 +101,6 @@ class WasmSerializationTest {
}
private:
static const char* kFunctionName;
Zone* zone() { return &zone_; }
void SetUp() {
......@@ -141,10 +136,6 @@ class WasmSerializationTest {
// Check that the native module exists at this point.
CHECK(weak_native_module.lock());
auto* native_module = module_object->native_module();
native_module->compilation_state()->WaitForTopTierFinished();
DCHECK(!native_module->compilation_state()->failed());
v8::Local<v8::Object> v8_module_obj =
v8::Utils::ToLocal(Handle<JSObject>::cast(module_object));
CHECK(v8_module_obj->IsWasmModuleObject());
......@@ -158,8 +149,19 @@ class WasmSerializationTest {
uint8_t* bytes_copy = zone()->NewArray<uint8_t>(uncompiled_bytes.size());
memcpy(bytes_copy, uncompiled_bytes.data(), uncompiled_bytes.size());
wire_bytes_ = {bytes_copy, uncompiled_bytes.size()};
// keep alive data_ until the end
data_ = compiled_module.Serialize();
// Run the code until tier-up (of the single function) was observed.
Handle<WasmInstanceObject> instance =
GetWasmEngine()
->SyncInstantiate(serialization_isolate, &thrower, module_object,
{}, {})
.ToHandleChecked();
CHECK_EQ(0, data_.size);
while (data_.size == 0) {
testing::CallWasmFunctionForTesting(serialization_isolate, instance,
kFunctionName, 0, nullptr);
data_ = compiled_module.Serialize();
}
CHECK_LT(0, data_.size);
}
// Dispose of serialization isolate to destroy the reference to the
......@@ -186,11 +188,8 @@ class WasmSerializationTest {
v8::OwnedBuffer data_;
v8::MemorySpan<const uint8_t> wire_bytes_ = {nullptr, 0};
v8::MemorySpan<const uint8_t> serialized_bytes_ = {nullptr, 0};
FlagScope<bool> no_wasm_dynamic_tiering_;
};
const char* WasmSerializationTest::kFunctionName = "increment";
TEST(DeserializeValidModule) {
WasmSerializationTest test;
{
......@@ -323,6 +322,8 @@ TEST(TierDownAfterDeserialization) {
auto* native_module = module_object->native_module();
CHECK_EQ(1, native_module->module()->functions.size());
WasmCodeRefScope code_ref_scope;
// The deserialized code must be TurboFan (we wait for tier-up before
// serializing).
auto* turbofan_code = native_module->GetCode(0);
CHECK_NOT_NULL(turbofan_code);
CHECK_EQ(ExecutionTier::kTurbofan, turbofan_code->tier());
......@@ -363,7 +364,4 @@ TEST(SerializeLiftoffModuleFails) {
CHECK(!wasm_serializer.SerializeNativeModule({buffer.get(), buffer_size}));
}
} // namespace test_wasm_serialization
} // namespace wasm
} // namespace internal
} // namespace v8
} // namespace v8::internal::wasm
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