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

Unified Diff: src/disasm-ia32.cc

Issue 1940: Replaced calls to functions that msvc consider deprecated. Used... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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 | « src/disasm.h ('k') | src/disassembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/disasm-ia32.cc
===================================================================
--- src/disasm-ia32.cc (revision 280)
+++ src/disasm-ia32.cc (working copy)
@@ -233,11 +233,11 @@
// Writes one disassembled instruction into 'buffer' (0-terminated).
// Returns the length of the disassembled machine instruction in bytes.
- int InstructionDecode(char* buffer, const int buffer_size, byte* instruction);
+ int InstructionDecode(v8::internal::Vector<char> buffer, byte* instruction);
private:
const NameConverter& converter_;
- char tmp_buffer_[128];
+ v8::internal::EmbeddedVector<char, 128> tmp_buffer_;
unsigned int tmp_buffer_pos_;
bool abort_on_unimplemented_;
@@ -307,15 +307,10 @@
void DisassemblerIA32::AppendToBuffer(const char* format, ...) {
- char* str = tmp_buffer_ + tmp_buffer_pos_;
- int size = (sizeof tmp_buffer_) - tmp_buffer_pos_;
+ v8::internal::Vector<char> buf = tmp_buffer_ + tmp_buffer_pos_;
va_list args;
va_start(args, format);
-#ifdef WIN32
- int result = _vsnprintf(str, size, format, args);
-#else
- int result = vsnprintf(str, size, format, args);
-#endif
+ int result = v8::internal::OS::VSNPrintF(buf, format, args);
va_end(args);
tmp_buffer_pos_ += result;
}
@@ -706,8 +701,7 @@
// Disassembled instruction '*instr' and writes it intro 'out_buffer'.
-int DisassemblerIA32::InstructionDecode(char* out_buffer,
- const int out_buffer_size,
+int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
byte* instr) {
tmp_buffer_pos_ = 0; // starting to write as position 0
byte* data = instr;
@@ -1040,20 +1034,17 @@
// Instruction bytes.
for (byte* bp = instr; bp < data; bp++) {
outp += v8::internal::OS::SNPrintF(out_buffer + outp,
- out_buffer_size - outp,
"%02x",
*bp);
}
for (int i = 6 - instr_len; i >= 0; i--) {
outp += v8::internal::OS::SNPrintF(out_buffer + outp,
- out_buffer_size - outp,
" ");
}
outp += v8::internal::OS::SNPrintF(out_buffer + outp,
- out_buffer_size - outp,
" %s",
- tmp_buffer_);
+ tmp_buffer_.start());
return instr_len;
}
@@ -1072,13 +1063,9 @@
const char* NameConverter::NameOfAddress(byte* addr) const {
- static char tmp_buffer[32];
-#ifdef WIN32
- _snprintf(tmp_buffer, sizeof tmp_buffer, "%p", addr);
-#else
- snprintf(tmp_buffer, sizeof tmp_buffer, "%p", addr);
-#endif
- return tmp_buffer;
+ v8::internal::EmbeddedVector<char, 32> tmp_buffer;
+ v8::internal::OS::SNPrintF(tmp_buffer, "%p", addr);
+ return tmp_buffer.start();
}
@@ -1120,11 +1107,10 @@
Disassembler::~Disassembler() {}
-int Disassembler::InstructionDecode(char* buffer,
- const int buffer_size,
+int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer,
byte* instruction) {
DisassemblerIA32 d(converter_, false /*do not crash if unimplemented*/);
- return d.InstructionDecode(buffer, buffer_size, instruction);
+ return d.InstructionDecode(buffer, instruction);
}
@@ -1135,10 +1121,10 @@
/*static*/ void Disassembler::Disassemble(FILE* f, byte* begin, byte* end) {
Disassembler d;
for (byte* pc = begin; pc < end;) {
- char buffer[128];
+ v8::internal::EmbeddedVector<char, 128> buffer;
buffer[0] = '\0';
byte* prev_pc = pc;
- pc += d.InstructionDecode(buffer, sizeof buffer, pc);
+ pc += d.InstructionDecode(buffer, pc);
fprintf(f, "%p", prev_pc);
fprintf(f, " ");
@@ -1148,7 +1134,7 @@
for (int i = 6 - (pc - prev_pc); i >= 0; i--) {
fprintf(f, " ");
}
- fprintf(f, " %s\n", buffer);
+ fprintf(f, " %s\n", buffer.start());
}
}
« no previous file with comments | « src/disasm.h ('k') | src/disassembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698