Commit e4f5f23b authored by Igor Sheludko's avatar Igor Sheludko Committed by Commit Bot

[zone] Cleanup zone allocations in src/asmjs

... by migrating old-style code
  MyObject* obj = new (zone) MyObject(...)

to the new style
  MyObject* obj = zone->New<MyObject>(...)

Bug: v8:10689
Change-Id: I8293cc1854e39726eb9e4e5f9d2a34d38fa54859
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2288861Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68791}
parent 4dd5e1da
...@@ -241,9 +241,9 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() { ...@@ -241,9 +241,9 @@ UnoptimizedCompilationJob::Status AsmJsCompilationJob::ExecuteJobImpl() {
} }
return FAILED; return FAILED;
} }
module_ = new (compile_zone) wasm::ZoneBuffer(compile_zone); module_ = compile_zone->New<wasm::ZoneBuffer>(compile_zone);
parser.module_builder()->WriteTo(module_); parser.module_builder()->WriteTo(module_);
asm_offsets_ = new (compile_zone) wasm::ZoneBuffer(compile_zone); asm_offsets_ = compile_zone->New<wasm::ZoneBuffer>(compile_zone);
parser.module_builder()->WriteAsmJsOffsetTable(asm_offsets_); parser.module_builder()->WriteAsmJsOffsetTable(asm_offsets_);
stdlib_uses_ = *parser.stdlib_uses(); stdlib_uses_ = *parser.stdlib_uses();
......
...@@ -74,7 +74,7 @@ AsmJsParser::AsmJsParser(Zone* zone, uintptr_t stack_limit, ...@@ -74,7 +74,7 @@ AsmJsParser::AsmJsParser(Zone* zone, uintptr_t stack_limit,
Utf16CharacterStream* stream) Utf16CharacterStream* stream)
: zone_(zone), : zone_(zone),
scanner_(stream), scanner_(stream),
module_builder_(new (zone) WasmModuleBuilder(zone)), module_builder_(zone->New<WasmModuleBuilder>(zone)),
return_type_(nullptr), return_type_(nullptr),
stack_limit_(stack_limit), stack_limit_(stack_limit),
global_var_info_(zone), global_var_info_(zone),
...@@ -564,8 +564,7 @@ void AsmJsParser::ValidateModuleVarImport(VarInfo* info, ...@@ -564,8 +564,7 @@ void AsmJsParser::ValidateModuleVarImport(VarInfo* info,
AddGlobalImport(name, AsmType::Int(), kWasmI32, mutable_variable, info); AddGlobalImport(name, AsmType::Int(), kWasmI32, mutable_variable, info);
} else { } else {
info->kind = VarKind::kImportedFunction; info->kind = VarKind::kImportedFunction;
info->import = new (zone()->New(sizeof(FunctionImportInfo))) info->import = zone()->New<FunctionImportInfo>(name, zone());
FunctionImportInfo(name, zone());
info->mutable_variable = false; info->mutable_variable = false;
} }
} }
......
...@@ -172,7 +172,7 @@ class AsmFroundType final : public AsmCallableType { ...@@ -172,7 +172,7 @@ class AsmFroundType final : public AsmCallableType {
} // namespace } // namespace
AsmType* AsmType::FroundType(Zone* zone) { AsmType* AsmType::FroundType(Zone* zone) {
auto* Fround = new (zone) AsmFroundType(); auto* Fround = zone->New<AsmFroundType>();
return reinterpret_cast<AsmType*>(Fround); return reinterpret_cast<AsmType*>(Fround);
} }
...@@ -195,6 +195,7 @@ namespace { ...@@ -195,6 +195,7 @@ namespace {
class AsmMinMaxType final : public AsmCallableType { class AsmMinMaxType final : public AsmCallableType {
private: private:
friend AsmType; friend AsmType;
friend Zone;
AsmMinMaxType(AsmType* dest, AsmType* src) AsmMinMaxType(AsmType* dest, AsmType* src)
: AsmCallableType(), return_type_(dest), arg_(src) {} : AsmCallableType(), return_type_(dest), arg_(src) {}
...@@ -231,7 +232,7 @@ class AsmMinMaxType final : public AsmCallableType { ...@@ -231,7 +232,7 @@ class AsmMinMaxType final : public AsmCallableType {
AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) { AsmType* AsmType::MinMaxType(Zone* zone, AsmType* dest, AsmType* src) {
DCHECK_NOT_NULL(dest->AsValueType()); DCHECK_NOT_NULL(dest->AsValueType());
DCHECK_NOT_NULL(src->AsValueType()); DCHECK_NOT_NULL(src->AsValueType());
auto* MinMax = new (zone) AsmMinMaxType(dest, src); auto* MinMax = zone->New<AsmMinMaxType>(dest, src);
return reinterpret_cast<AsmType*>(MinMax); return reinterpret_cast<AsmType*>(MinMax);
} }
......
...@@ -139,6 +139,7 @@ class V8_EXPORT_PRIVATE AsmFunctionType final : public AsmCallableType { ...@@ -139,6 +139,7 @@ class V8_EXPORT_PRIVATE AsmFunctionType final : public AsmCallableType {
private: private:
friend AsmType; friend AsmType;
friend Zone;
std::string Name() override; std::string Name() override;
bool IsA(AsmType* other) override; bool IsA(AsmType* other) override;
...@@ -160,6 +161,7 @@ class V8_EXPORT_PRIVATE AsmOverloadedFunctionType final ...@@ -160,6 +161,7 @@ class V8_EXPORT_PRIVATE AsmOverloadedFunctionType final
private: private:
friend AsmType; friend AsmType;
friend Zone;
explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {} explicit AsmOverloadedFunctionType(Zone* zone) : overloads_(zone) {}
...@@ -196,14 +198,14 @@ class V8_EXPORT_PRIVATE AsmType { ...@@ -196,14 +198,14 @@ class V8_EXPORT_PRIVATE AsmType {
// A function returning ret. Callers still need to invoke AddArgument with the // A function returning ret. Callers still need to invoke AddArgument with the
// returned type to fully create this type. // returned type to fully create this type.
static AsmType* Function(Zone* zone, AsmType* ret) { static AsmType* Function(Zone* zone, AsmType* ret) {
AsmFunctionType* f = new (zone) AsmFunctionType(zone, ret); AsmFunctionType* f = zone->New<AsmFunctionType>(zone, ret);
return reinterpret_cast<AsmType*>(f); return reinterpret_cast<AsmType*>(f);
} }
// Overloaded function types. Not creatable by asm source, but useful to // Overloaded function types. Not creatable by asm source, but useful to
// represent the overloaded stdlib functions. // represent the overloaded stdlib functions.
static AsmType* OverloadedFunction(Zone* zone) { static AsmType* OverloadedFunction(Zone* zone) {
auto* f = new (zone) AsmOverloadedFunctionType(zone); auto* f = zone->New<AsmOverloadedFunctionType>(zone);
return reinterpret_cast<AsmType*>(f); return reinterpret_cast<AsmType*>(f);
} }
......
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