Commit c30cbb17 authored by Clemens Hammacher's avatar Clemens Hammacher Committed by Commit Bot

[wasm] [cleanup] Remove unused DecodeStruct type

It was used before as a placeholder in Result<DecodeStruct*> to
communicate that no value was returned. We actually only created a
Results holding {nullptr} when returning such values. Thus, the whole
struct is not needed, and we return Result<nullptr_t> instead, which
clearly communicates that this result does not hold any value.

An alternative would be to use Result<void>, but this would require
partial specialization of the Result template, which would be overkill
here.

R=ahaas@chromium.org

Change-Id: Ib07d2c4fe716c735839675d11146c47f97997d40
Reviewed-on: https://chromium-review.googlesource.com/509551Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45464}
parent 0819f4c2
...@@ -2130,7 +2130,7 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator, ...@@ -2130,7 +2130,7 @@ DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
Zone zone(allocator, ZONE_NAME); Zone zone(allocator, ZONE_NAME);
WasmFullDecoder decoder(&zone, module, body); WasmFullDecoder decoder(&zone, module, body);
decoder.Decode(); decoder.Decode();
return decoder.toResult<DecodeStruct*>(nullptr); return decoder.toResult(nullptr);
} }
DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
...@@ -2138,7 +2138,7 @@ DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder, ...@@ -2138,7 +2138,7 @@ DecodeResult BuildTFGraph(AccountingAllocator* allocator, TFBuilder* builder,
Zone zone(allocator, ZONE_NAME); Zone zone(allocator, ZONE_NAME);
WasmFullDecoder decoder(&zone, builder, body); WasmFullDecoder decoder(&zone, builder, body);
decoder.Decode(); decoder.Decode();
return decoder.toResult<DecodeStruct*>(nullptr); return decoder.toResult(nullptr);
} }
unsigned OpcodeLength(const byte* pc, const byte* end) { unsigned OpcodeLength(const byte* pc, const byte* end) {
......
...@@ -42,13 +42,11 @@ static inline FunctionBody FunctionBodyForTesting(const byte* start, ...@@ -42,13 +42,11 @@ static inline FunctionBody FunctionBodyForTesting(const byte* start,
return {nullptr, start, start, end}; return {nullptr, start, start, end};
} }
struct DecodeStruct { // A {DecodeResult} only stores the failure / success status, but no data. Thus
int unused; // we use {nullptr_t} as data value, such that the only valid data stored in
}; // this type is a nullptr.
typedef Result<DecodeStruct*> DecodeResult; // Storing {void} would require template specialization.
inline std::ostream& operator<<(std::ostream& os, const DecodeStruct& tree) { using DecodeResult = Result<std::nullptr_t>;
return os;
}
V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator, V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const wasm::WasmModule* module, const wasm::WasmModule* module,
......
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