Skip to content

Commit

Permalink
This patch uses single BytesInstruction Courgette ops to point to lon…
Browse files Browse the repository at this point in the history
…g stretches of the binary file, instead of using one ByteInstruction op, which copies one byte at a time. This reduces memory usages for very large files, since less data is copied, and fewer Instruction classes are constructed.

BUG=266068

Review URL: https://chromiumcodereview.appspot.com/22728002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@217138 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
paulgazz@chromium.org committed Aug 13, 2013
1 parent ea2ab47 commit c092858
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions courgette/assembly_program.cc
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ EncodedProgram* AssemblyProgram::Encode() const {
const uint8* byte_values =
static_cast<BytesInstruction*>(instruction)->byte_values();
uint32 len = static_cast<BytesInstruction*>(instruction)->len();

if (!encoded->AddCopy(len, byte_values))
return NULL;
break;
Expand Down
12 changes: 6 additions & 6 deletions courgette/disassembler_elf_32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -409,13 +409,13 @@ CheckBool DisassemblerElf32::ParseSimpleRegion(
const uint8* start = OffsetToPointer(start_file_offset);
const uint8* end = OffsetToPointer(end_file_offset);

const uint8* p = start;
// Callers don't guarantee start < end
if (start >= end) return true;

while (p < end) {
if (!program->EmitByteInstruction(*p))
return false;
++p;
}
const ptrdiff_t len = end - start; // Works because vars are byte pointers

if (!program->EmitBytesInstruction(start, len))
return false;

return true;
}
Expand Down

0 comments on commit c092858

Please sign in to comment.