[wasm] Remove indirection to WasmModule::signature_zone
The zone should just be a member of {WasmModule} instead of a heap-allocated second object. R=ahaas@chromium.org Change-Id: I9cf7d5145ea9131a5ae3382c6f5aa63b816d9aa4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4080032 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/main@{#84690}
This commit is contained in:
parent
eba4b4623a
commit
ea6e09b5c1
@ -314,8 +314,6 @@ class ModuleDecoderTemplate : public Decoder {
|
||||
ModuleOrigin origin, Tracer& tracer)
|
||||
: Decoder(wire_bytes),
|
||||
enabled_features_(enabled_features),
|
||||
module_(std::make_shared<WasmModule>(std::make_unique<Zone>(
|
||||
GetWasmEngine()->allocator(), "signatures"))),
|
||||
module_start_(wire_bytes.begin()),
|
||||
module_end_(wire_bytes.end()),
|
||||
tracer_(tracer) {
|
||||
@ -583,15 +581,15 @@ class ModuleDecoderTemplate : public Decoder {
|
||||
tracer_.Description(TypeKindName(kind));
|
||||
switch (kind) {
|
||||
case kWasmFunctionTypeCode: {
|
||||
const FunctionSig* sig = consume_sig(module_->signature_zone.get());
|
||||
const FunctionSig* sig = consume_sig(&module_->signature_zone);
|
||||
return {sig, kNoSuperType};
|
||||
}
|
||||
case kWasmStructTypeCode: {
|
||||
const StructType* type = consume_struct(module_->signature_zone.get());
|
||||
const StructType* type = consume_struct(&module_->signature_zone);
|
||||
return {type, kNoSuperType};
|
||||
}
|
||||
case kWasmArrayTypeCode: {
|
||||
const ArrayType* type = consume_array(module_->signature_zone.get());
|
||||
const ArrayType* type = consume_array(&module_->signature_zone);
|
||||
return {type, kNoSuperType};
|
||||
}
|
||||
default:
|
||||
@ -645,7 +643,7 @@ class ModuleDecoderTemplate : public Decoder {
|
||||
switch (opcode) {
|
||||
case kWasmFunctionTypeCode: {
|
||||
consume_bytes(1, "function");
|
||||
const FunctionSig* sig = consume_sig(module_->signature_zone.get());
|
||||
const FunctionSig* sig = consume_sig(&module_->signature_zone);
|
||||
if (!ok()) break;
|
||||
module_->types[i] = {sig, kNoSuperType};
|
||||
type_canon->AddRecursiveGroup(module_.get(), 1, i);
|
||||
@ -1690,7 +1688,7 @@ class ModuleDecoderTemplate : public Decoder {
|
||||
|
||||
private:
|
||||
const WasmFeatures enabled_features_;
|
||||
std::shared_ptr<WasmModule> module_;
|
||||
const std::shared_ptr<WasmModule> module_ = std::make_shared<WasmModule>();
|
||||
const byte* module_start_ = nullptr;
|
||||
const byte* module_end_ = nullptr;
|
||||
Tracer& tracer_;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "src/wasm/jump-table-assembler.h"
|
||||
#include "src/wasm/module-decoder.h"
|
||||
#include "src/wasm/wasm-code-manager.h"
|
||||
#include "src/wasm/wasm-engine.h"
|
||||
#include "src/wasm/wasm-init-expr.h"
|
||||
#include "src/wasm/wasm-js.h"
|
||||
#include "src/wasm/wasm-module-builder.h" // For {ZoneBuffer}.
|
||||
@ -213,8 +214,8 @@ std::ostream& operator<<(std::ostream& os, const WasmFunctionName& name) {
|
||||
return os;
|
||||
}
|
||||
|
||||
WasmModule::WasmModule(std::unique_ptr<Zone> signature_zone)
|
||||
: signature_zone(std::move(signature_zone)) {}
|
||||
WasmModule::WasmModule()
|
||||
: signature_zone(GetWasmEngine()->allocator(), "signature zone") {}
|
||||
|
||||
bool IsWasmCodegenAllowed(Isolate* isolate, Handle<Context> context) {
|
||||
// TODO(wasm): Once wasm has its own CSP policy, we should introduce a
|
||||
@ -624,9 +625,7 @@ inline size_t VectorSize(const std::vector<T>& vector) {
|
||||
|
||||
size_t EstimateStoredSize(const WasmModule* module) {
|
||||
return sizeof(WasmModule) + VectorSize(module->globals) +
|
||||
(module->signature_zone ? module->signature_zone->allocation_size()
|
||||
: 0) +
|
||||
VectorSize(module->types) +
|
||||
module->signature_zone.allocation_size() + VectorSize(module->types) +
|
||||
VectorSize(module->isorecursive_canonical_type_ids) +
|
||||
VectorSize(module->functions) + VectorSize(module->data_segments) +
|
||||
VectorSize(module->tables) + VectorSize(module->import_table) +
|
||||
|
@ -481,7 +481,7 @@ struct WasmTable;
|
||||
// Static representation of a module.
|
||||
struct V8_EXPORT_PRIVATE WasmModule {
|
||||
// ================ Fields ===================================================
|
||||
std::unique_ptr<Zone> signature_zone;
|
||||
Zone signature_zone;
|
||||
uint32_t initial_pages = 0; // initial size of the memory in 64k pages
|
||||
uint32_t maximum_pages = 0; // maximum size of the memory in 64k pages
|
||||
bool has_shared_memory = false; // true if memory is a SharedArrayBuffer
|
||||
@ -545,7 +545,7 @@ struct V8_EXPORT_PRIVATE WasmModule {
|
||||
mutable std::unique_ptr<std::atomic<uint8_t>[]> validated_functions;
|
||||
|
||||
// ================ Constructors =============================================
|
||||
explicit WasmModule(std::unique_ptr<Zone> signature_zone = nullptr);
|
||||
WasmModule();
|
||||
WasmModule(const WasmModule&) = delete;
|
||||
WasmModule& operator=(const WasmModule&) = delete;
|
||||
|
||||
|
@ -75,8 +75,7 @@ enum MemoryType { kMemory32, kMemory64 };
|
||||
// globals, or memories.
|
||||
class TestModuleBuilder {
|
||||
public:
|
||||
explicit TestModuleBuilder(ModuleOrigin origin = kWasmOrigin)
|
||||
: allocator(), mod(std::make_unique<Zone>(&allocator, ZONE_NAME)) {
|
||||
explicit TestModuleBuilder(ModuleOrigin origin = kWasmOrigin) {
|
||||
mod.origin = origin;
|
||||
}
|
||||
byte AddGlobal(ValueType type, bool mutability = true) {
|
||||
@ -124,7 +123,7 @@ class TestModuleBuilder {
|
||||
|
||||
byte AddStruct(std::initializer_list<F> fields,
|
||||
uint32_t supertype = kNoSuperType) {
|
||||
StructType::Builder type_builder(mod.signature_zone.get(),
|
||||
StructType::Builder type_builder(&mod.signature_zone,
|
||||
static_cast<uint32_t>(fields.size()));
|
||||
for (F field : fields) {
|
||||
type_builder.AddField(field.first, field.second);
|
||||
@ -135,7 +134,7 @@ class TestModuleBuilder {
|
||||
}
|
||||
|
||||
byte AddArray(ValueType type, bool mutability) {
|
||||
ArrayType* array = mod.signature_zone->New<ArrayType>(type, mutability);
|
||||
ArrayType* array = mod.signature_zone.New<ArrayType>(type, mutability);
|
||||
mod.add_array_type(array, kNoSuperType);
|
||||
GetTypeCanonicalizer()->AddRecursiveGroup(module(), 1);
|
||||
return static_cast<byte>(mod.types.size() - 1);
|
||||
@ -191,7 +190,6 @@ class TestModuleBuilder {
|
||||
return static_cast<byte>(mod.functions.size() - 1);
|
||||
}
|
||||
|
||||
AccountingAllocator allocator;
|
||||
WasmModule mod;
|
||||
};
|
||||
|
||||
@ -5033,7 +5031,6 @@ TEST_F(TypeReaderTest, HeapTypeDecodingTest) {
|
||||
|
||||
class LocalDeclDecoderTest : public TestWithZone {
|
||||
public:
|
||||
v8::internal::AccountingAllocator allocator;
|
||||
WasmFeatures enabled_features_;
|
||||
|
||||
size_t ExpectRun(ValueType* local_types, size_t pos, ValueType expected,
|
||||
|
@ -27,7 +27,7 @@ FieldInit immut(ValueType type) { return FieldInit(type, false); }
|
||||
void DefineStruct(WasmModule* module, std::initializer_list<FieldInit> fields,
|
||||
uint32_t supertype = kNoSuperType,
|
||||
bool in_singleton_rec_group = true) {
|
||||
StructType::Builder builder(module->signature_zone.get(),
|
||||
StructType::Builder builder(&module->signature_zone,
|
||||
static_cast<uint32_t>(fields.size()));
|
||||
for (FieldInit field : fields) {
|
||||
builder.AddField(field.first, field.second);
|
||||
@ -41,7 +41,7 @@ void DefineStruct(WasmModule* module, std::initializer_list<FieldInit> fields,
|
||||
void DefineArray(WasmModule* module, FieldInit element_type,
|
||||
uint32_t supertype = kNoSuperType,
|
||||
bool in_singleton_rec_group = true) {
|
||||
module->add_array_type(module->signature_zone->New<ArrayType>(
|
||||
module->add_array_type(module->signature_zone.New<ArrayType>(
|
||||
element_type.first, element_type.second),
|
||||
supertype);
|
||||
if (in_singleton_rec_group) {
|
||||
@ -55,8 +55,7 @@ void DefineSignature(WasmModule* module,
|
||||
uint32_t supertype = kNoSuperType,
|
||||
bool in_singleton_rec_group = true) {
|
||||
module->add_signature(
|
||||
FunctionSig::Build(module->signature_zone.get(), returns, params),
|
||||
supertype);
|
||||
FunctionSig::Build(&module->signature_zone, returns, params), supertype);
|
||||
if (in_singleton_rec_group) {
|
||||
GetTypeCanonicalizer()->AddRecursiveGroup(module, 1);
|
||||
}
|
||||
@ -66,8 +65,8 @@ TEST_F(WasmSubtypingTest, Subtyping) {
|
||||
FLAG_SCOPE(experimental_wasm_gc);
|
||||
FLAG_VALUE_SCOPE(wasm_gc_structref_as_dataref, false);
|
||||
v8::internal::AccountingAllocator allocator;
|
||||
WasmModule module1_(std::make_unique<Zone>(&allocator, ZONE_NAME));
|
||||
WasmModule module2_(std::make_unique<Zone>(&allocator, ZONE_NAME));
|
||||
WasmModule module1_;
|
||||
WasmModule module2_;
|
||||
|
||||
WasmModule* module1 = &module1_;
|
||||
WasmModule* module2 = &module2_;
|
||||
|
@ -381,7 +381,6 @@ class HexDumpModuleDis {
|
||||
module_(module),
|
||||
names_(names),
|
||||
wire_bytes_(wire_bytes),
|
||||
allocator_(allocator),
|
||||
zone_(allocator, "disassembler") {}
|
||||
|
||||
// Public entrypoint.
|
||||
@ -394,8 +393,7 @@ class HexDumpModuleDis {
|
||||
std::unique_ptr<WasmModule> fake_module;
|
||||
std::unique_ptr<NamesProvider> names_provider;
|
||||
if (!names_) {
|
||||
fake_module.reset(
|
||||
new WasmModule(std::make_unique<Zone>(allocator_, "fake module")));
|
||||
fake_module.reset(new WasmModule());
|
||||
names_provider.reset(
|
||||
new NamesProvider(fake_module.get(), wire_bytes_.module_bytes()));
|
||||
names_ = names_provider.get();
|
||||
@ -701,7 +699,6 @@ class HexDumpModuleDis {
|
||||
const WasmModule* module_;
|
||||
NamesProvider* names_;
|
||||
const ModuleWireBytes wire_bytes_;
|
||||
AccountingAllocator* allocator_;
|
||||
Zone zone_;
|
||||
|
||||
StringBuilder description_;
|
||||
|
Loading…
Reference in New Issue
Block a user