Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1617)

Unified Diff: src/interpreter/bytecodes.cc

Issue 1832653002: [interpreter] Fix memory leak in Bytecodes::Decode(). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: iomanip variant. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/unittests/unittests.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/bytecodes.cc
diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc
index ac793dab6a60099e55295c611814c3978a6aab3a..136e2802be988c01590453ba4305a455e6d2cb8d 100644
--- a/src/interpreter/bytecodes.cc
+++ b/src/interpreter/bytecodes.cc
@@ -4,6 +4,8 @@
#include "src/interpreter/bytecodes.h"
+#include <iomanip>
+
#include "src/frames.h"
#include "src/interpreter/bytecode-traits.h"
@@ -484,8 +486,6 @@ uint32_t Bytecodes::DecodeUnsignedOperand(const uint8_t* operand_start,
// static
std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
int parameter_count) {
- Vector<char> buf = Vector<char>::New(50);
-
Bytecode bytecode = Bytecodes::FromByte(bytecode_start[0]);
int prefix_offset = 0;
OperandScale operand_scale = OperandScale::kSingle;
@@ -494,11 +494,19 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
operand_scale = Bytecodes::PrefixBytecodeToOperandScale(bytecode);
Michael Achenbach 2016/03/24 13:35:29 FYI: The experimental code-coverage claims this co
bytecode = Bytecodes::FromByte(bytecode_start[1]);
}
+
+ // Prepare to print bytecode and operands as hex digits.
+ std::ios saved_format(nullptr);
+ saved_format.copyfmt(saved_format);
+ os.fill('0');
+ os.flags(std::ios::hex);
+
int bytecode_size = Bytecodes::Size(bytecode, operand_scale);
for (int i = 0; i < prefix_offset + bytecode_size; i++) {
- SNPrintF(buf, "%02x ", bytecode_start[i]);
- os << buf.start();
+ os << std::setw(2) << static_cast<uint32_t>(bytecode_start[i]) << ' ';
}
+ os.copyfmt(saved_format);
+
const int kBytecodeColumnSize = 6;
for (int i = prefix_offset + bytecode_size; i < kBytecodeColumnSize; i++) {
os << " ";
« no previous file with comments | « no previous file | test/unittests/unittests.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698