summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpaulgazz@chromium.org <paulgazz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 00:46:30 +0000
committerpaulgazz@chromium.org <paulgazz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-08-13 00:46:30 +0000
commitc092858ac6b1fa0480b7bf6d05529257b53a436f (patch)
treeb2a1f5f07bef110edbfdbd1169a6ea01771a3e75
parentea2ab47bf5fd0157ee8dfd877f65ae2dc453e551 (diff)
downloadchromium_src-c092858ac6b1fa0480b7bf6d05529257b53a436f.zip
chromium_src-c092858ac6b1fa0480b7bf6d05529257b53a436f.tar.gz
chromium_src-c092858ac6b1fa0480b7bf6d05529257b53a436f.tar.bz2
This patch uses single BytesInstruction Courgette ops to point to long 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
-rw-r--r--courgette/assembly_program.cc1
-rw-r--r--courgette/disassembler_elf_32.cc12
2 files changed, 7 insertions, 6 deletions
diff --git a/courgette/assembly_program.cc b/courgette/assembly_program.cc
index f577b98..021de59 100644
--- a/courgette/assembly_program.cc
+++ b/courgette/assembly_program.cc
@@ -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;
diff --git a/courgette/disassembler_elf_32.cc b/courgette/disassembler_elf_32.cc
index fc4c379..bfd1ef4 100644
--- a/courgette/disassembler_elf_32.cc
+++ b/courgette/disassembler_elf_32.cc
@@ -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;
}