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,
DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const WasmFeatures& enabled,
const WasmModule* module, WasmFeatures* detected,
FunctionBody& body) { // NOLINT(runtime/references)
const FunctionBody& body) {
Zone zone(allocator, ZONE_NAME);
WasmFullDecoder<Decoder::kValidate, EmptyInterface> decoder(
&zone, module, enabled, detected, body);
......
......@@ -34,10 +34,11 @@ struct FunctionBody {
: sig(sig), offset(offset), start(start), end(end) {}
};
V8_EXPORT_PRIVATE DecodeResult
VerifyWasmCode(AccountingAllocator* allocator, const WasmFeatures& enabled,
const WasmModule* module, WasmFeatures* detected,
FunctionBody& body); // NOLINT(runtime/references)
V8_EXPORT_PRIVATE DecodeResult VerifyWasmCode(AccountingAllocator* allocator,
const WasmFeatures& enabled,
const WasmModule* module,
WasmFeatures* detected,
const FunctionBody& body);
enum PrintLocals { kPrintLocals, kOmitLocals };
V8_EXPORT_PRIVATE
......
......@@ -1921,7 +1921,7 @@ bool AsyncStreamingProcessor::ProcessSection(SectionCode section_code,
if (section_code == SectionCode::kUnknownSectionCode) {
Decoder decoder(bytes, offset);
section_code = ModuleDecoder::IdentifyUnknownSection(
decoder, bytes.begin() + bytes.length());
&decoder, bytes.begin() + bytes.length());
if (section_code == SectionCode::kUnknownSectionCode) {
// Skip unknown sections that we do not know how to handle.
return true;
......
This diff is collapsed.
......@@ -139,14 +139,12 @@ class ModuleDecoder {
// Translates the unknown section that decoder is pointing to to an extended
// 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.
// If a SectionCode other than kUnknownSectionCode is returned, the decoder
// will point right after the identifier string. Otherwise, the position is
// undefined.
static SectionCode IdentifyUnknownSection(
Decoder& decoder, // NOLINT(runtime/references)
const byte* end);
static SectionCode IdentifyUnknownSection(Decoder* decoder, const byte* end);
private:
const WasmFeatures enabled_features_;
......
......@@ -18,29 +18,29 @@ namespace wasm {
namespace {
PRINTF_FORMAT(3, 0)
void VPrintFToString(std::string& str, // NOLINT(runtime/references)
size_t str_offset, const char* format, va_list args) {
DCHECK_LE(str_offset, str.size());
void VPrintFToString(std::string* str, size_t str_offset, const char* format,
va_list args) {
DCHECK_LE(str_offset, str->size());
size_t len = str_offset + strlen(format);
// Allocate increasingly large buffers until the message fits.
for (;; len = base::bits::RoundUpToPowerOfTwo64(len + 1)) {
DCHECK_GE(kMaxInt, len);
str.resize(len);
str->resize(len);
va_list args_copy;
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)),
format, args_copy);
va_end(args_copy);
if (written < 0) continue; // not enough space.
str.resize(str_offset + written);
str->resize(str_offset + written);
return;
}
}
PRINTF_FORMAT(3, 4)
void PrintFToString(std::string& str, // NOLINT(runtime/references)
size_t str_offset, const char* format, ...) {
void PrintFToString(std::string* str, size_t str_offset, const char* format,
...) {
va_list args;
va_start(args, format);
VPrintFToString(str, str_offset, format, args);
......@@ -52,7 +52,7 @@ void PrintFToString(std::string& str, // NOLINT(runtime/references)
// static
std::string WasmError::FormatError(const char* format, va_list args) {
std::string result;
VPrintFToString(result, 0, format, args);
VPrintFToString(&result, 0, format, args);
return result;
}
......@@ -63,10 +63,10 @@ void ErrorThrower::Format(ErrorType type, const char* format, va_list args) {
size_t context_len = 0;
if (context_) {
PrintFToString(error_msg_, 0, "%s: ", context_);
PrintFToString(&error_msg_, 0, "%s: ", context_);
context_len = error_msg_.size();
}
VPrintFToString(error_msg_, context_len, format, args);
VPrintFToString(&error_msg_, context_len, format, args);
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