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

[wasm] Remove non-const arguments from decoder

R=ahaas@chromium.org

Bug: v8:9429, v8:9396
Change-Id: I79e5d707f6c3970c96eb2186604d8b26fda787e5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1687897Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62556}
parent 7a08b033
...@@ -45,7 +45,7 @@ BytecodeIterator::BytecodeIterator(const byte* start, const byte* end, ...@@ -45,7 +45,7 @@ BytecodeIterator::BytecodeIterator(const byte* start, const byte* end,
DecodeResult VerifyWasmCode(AccountingAllocator* allocator, DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const WasmFeatures& enabled, const WasmFeatures& enabled,
const WasmModule* module, WasmFeatures* detected, const WasmModule* module, WasmFeatures* detected,
FunctionBody& body) { // NOLINT(runtime/references) const FunctionBody& body) {
Zone zone(allocator, ZONE_NAME); Zone zone(allocator, ZONE_NAME);
WasmFullDecoder<Decoder::kValidate, EmptyInterface> decoder( WasmFullDecoder<Decoder::kValidate, EmptyInterface> decoder(
&zone, module, enabled, detected, body); &zone, module, enabled, detected, body);
......
...@@ -34,10 +34,11 @@ struct FunctionBody { ...@@ -34,10 +34,11 @@ struct FunctionBody {
: sig(sig), offset(offset), start(start), end(end) {} : sig(sig), offset(offset), start(start), end(end) {}
}; };
V8_EXPORT_PRIVATE DecodeResult V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
VerifyWasmCode(AccountingAllocator* allocator, const WasmFeatures& enabled, const WasmFeatures& enabled,
const WasmModule* module, WasmFeatures* detected, const WasmModule* module,
FunctionBody& body); // NOLINT(runtime/references) WasmFeatures* detected,
const FunctionBody& body);
enum PrintLocals { kPrintLocals, kOmitLocals }; enum PrintLocals { kPrintLocals, kOmitLocals };
V8_EXPORT_PRIVATE V8_EXPORT_PRIVATE
......
...@@ -1921,7 +1921,7 @@ bool AsyncStreamingProcessor::ProcessSection(SectionCode section_code, ...@@ -1921,7 +1921,7 @@ bool AsyncStreamingProcessor::ProcessSection(SectionCode section_code,
if (section_code == SectionCode::kUnknownSectionCode) { if (section_code == SectionCode::kUnknownSectionCode) {
Decoder decoder(bytes, offset); Decoder decoder(bytes, offset);
section_code = ModuleDecoder::IdentifyUnknownSection( section_code = ModuleDecoder::IdentifyUnknownSection(
decoder, bytes.begin() + bytes.length()); &decoder, bytes.begin() + bytes.length());
if (section_code == SectionCode::kUnknownSectionCode) { if (section_code == SectionCode::kUnknownSectionCode) {
// Skip unknown sections that we do not know how to handle. // Skip unknown sections that we do not know how to handle.
return true; return true;
......
This diff is collapsed.
...@@ -139,14 +139,12 @@ class ModuleDecoder { ...@@ -139,14 +139,12 @@ class ModuleDecoder {
// Translates the unknown section that decoder is pointing to to an extended // Translates the unknown section that decoder is pointing to to an extended
// SectionCode if the unknown section is known to decoder. // SectionCode if the unknown section is known to decoder.
// The decoder is expected to point after the section lenght and just before // The decoder is expected to point after the section length and just before
// the identifier string of the unknown section. // the identifier string of the unknown section.
// If a SectionCode other than kUnknownSectionCode is returned, the decoder // If a SectionCode other than kUnknownSectionCode is returned, the decoder
// will point right after the identifier string. Otherwise, the position is // will point right after the identifier string. Otherwise, the position is
// undefined. // undefined.
static SectionCode IdentifyUnknownSection( static SectionCode IdentifyUnknownSection(Decoder* decoder, const byte* end);
Decoder& decoder, // NOLINT(runtime/references)
const byte* end);
private: private:
const WasmFeatures enabled_features_; const WasmFeatures enabled_features_;
......
...@@ -18,29 +18,29 @@ namespace wasm { ...@@ -18,29 +18,29 @@ namespace wasm {
namespace { namespace {
PRINTF_FORMAT(3, 0) PRINTF_FORMAT(3, 0)
void VPrintFToString(std::string& str, // NOLINT(runtime/references) void VPrintFToString(std::string* str, size_t str_offset, const char* format,
size_t str_offset, const char* format, va_list args) { va_list args) {
DCHECK_LE(str_offset, str.size()); DCHECK_LE(str_offset, str->size());
size_t len = str_offset + strlen(format); size_t len = str_offset + strlen(format);
// Allocate increasingly large buffers until the message fits. // Allocate increasingly large buffers until the message fits.
for (;; len = base::bits::RoundUpToPowerOfTwo64(len + 1)) { for (;; len = base::bits::RoundUpToPowerOfTwo64(len + 1)) {
DCHECK_GE(kMaxInt, len); DCHECK_GE(kMaxInt, len);
str.resize(len); str->resize(len);
va_list args_copy; va_list args_copy;
va_copy(args_copy, args); va_copy(args_copy, args);
int written = VSNPrintF(Vector<char>(&str.front() + str_offset, int written = VSNPrintF(Vector<char>(&str->front() + str_offset,
static_cast<int>(len - str_offset)), static_cast<int>(len - str_offset)),
format, args_copy); format, args_copy);
va_end(args_copy); va_end(args_copy);
if (written < 0) continue; // not enough space. if (written < 0) continue; // not enough space.
str.resize(str_offset + written); str->resize(str_offset + written);
return; return;
} }
} }
PRINTF_FORMAT(3, 4) PRINTF_FORMAT(3, 4)
void PrintFToString(std::string& str, // NOLINT(runtime/references) void PrintFToString(std::string* str, size_t str_offset, const char* format,
size_t str_offset, const char* format, ...) { ...) {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
VPrintFToString(str, str_offset, format, args); VPrintFToString(str, str_offset, format, args);
...@@ -52,7 +52,7 @@ void PrintFToString(std::string& str, // NOLINT(runtime/references) ...@@ -52,7 +52,7 @@ void PrintFToString(std::string& str, // NOLINT(runtime/references)
// static // static
std::string WasmError::FormatError(const char* format, va_list args) { std::string WasmError::FormatError(const char* format, va_list args) {
std::string result; std::string result;
VPrintFToString(result, 0, format, args); VPrintFToString(&result, 0, format, args);
return result; return result;
} }
...@@ -63,10 +63,10 @@ void ErrorThrower::Format(ErrorType type, const char* format, va_list args) { ...@@ -63,10 +63,10 @@ void ErrorThrower::Format(ErrorType type, const char* format, va_list args) {
size_t context_len = 0; size_t context_len = 0;
if (context_) { if (context_) {
PrintFToString(error_msg_, 0, "%s: ", context_); PrintFToString(&error_msg_, 0, "%s: ", context_);
context_len = error_msg_.size(); context_len = error_msg_.size();
} }
VPrintFToString(error_msg_, context_len, format, args); VPrintFToString(&error_msg_, context_len, format, args);
error_type_ = type; error_type_ = type;
} }
......
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