summaryrefslogtreecommitdiffstats
path: root/courgette/encoded_program.h
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 00:19:02 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-01 00:19:02 +0000
commitfbd31eb81436cf7f6d4f9ea3683c100f112361e6 (patch)
treeb0c191290d86ac3a70209fb0984320a88c1e3c07 /courgette/encoded_program.h
parent4b764ded93509c0a58a1a8cca10b0964fdcca41d (diff)
downloadchromium_src-fbd31eb81436cf7f6d4f9ea3683c100f112361e6.zip
chromium_src-fbd31eb81436cf7f6d4f9ea3683c100f112361e6.tar.gz
chromium_src-fbd31eb81436cf7f6d4f9ea3683c100f112361e6.tar.bz2
Implementation of an STL compatible allocator for Courgette on Windows.
This is to better handle low memory situations when applying a differential patch to a large Chrome setup. For reading input files, I'm also switching to using memory mapped files instead of ReadFileToString to reduce the load on the heap. TEST=courgette.exe should succeed in applying a patch between two chrome 10.x archives on an XP machine with 180MB of physical memory and no page file. BUG=72459,73209 Review URL: http://codereview.chromium.org/6597038 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'courgette/encoded_program.h')
-rw-r--r--courgette/encoded_program.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/courgette/encoded_program.h b/courgette/encoded_program.h
index 25bc075..5662f2e 100644
--- a/courgette/encoded_program.h
+++ b/courgette/encoded_program.h
@@ -9,6 +9,7 @@
#include "base/basictypes.h"
#include "courgette/image_info.h"
+#include "courgette/memory_allocator.h"
namespace courgette {
@@ -37,7 +38,7 @@ class EncodedProgram {
// (3) Add instructions in the order needed to generate bytes of file.
void AddOrigin(RVA rva);
- void AddCopy(int count, const void* bytes);
+ void AddCopy(uint32 count, const void* bytes);
void AddRel32(int label_index);
void AddAbs32(int label_index);
void AddMakeRelocs();
@@ -67,25 +68,30 @@ class EncodedProgram {
OP_LAST
};
+ typedef std::vector<RVA, MemoryAllocator<RVA> > RvaVector;
+ typedef std::vector<uint32, MemoryAllocator<uint32> > UInt32Vector;
+ typedef std::vector<uint8, MemoryAllocator<uint8> > UInt8Vector;
+ typedef std::vector<OP, MemoryAllocator<OP> > OPVector;
+
void DebuggingSummary();
void GenerateBaseRelocations(SinkStream *buffer);
- void DefineLabelCommon(std::vector<RVA>*, int, RVA);
- void FinishLabelsCommon(std::vector<RVA>* addresses);
+ void DefineLabelCommon(RvaVector*, int, RVA);
+ void FinishLabelsCommon(RvaVector* addresses);
// Binary assembly language tables.
uint64 image_base_;
- std::vector<RVA> rel32_rva_;
- std::vector<RVA> abs32_rva_;
- std::vector<OP> ops_;
- std::vector<RVA> origins_;
- std::vector<int> copy_counts_;
- std::vector<uint8> copy_bytes_;
- std::vector<uint32> rel32_ix_;
- std::vector<uint32> abs32_ix_;
+ RvaVector rel32_rva_;
+ RvaVector abs32_rva_;
+ OPVector ops_;
+ RvaVector origins_;
+ UInt32Vector copy_counts_;
+ UInt8Vector copy_bytes_;
+ UInt32Vector rel32_ix_;
+ UInt32Vector abs32_ix_;
// Table of the addresses containing abs32 relocations; computed during
// assembly, used to generate base relocation table.
- std::vector<uint32> abs32_relocs_;
+ UInt32Vector abs32_relocs_;
DISALLOW_COPY_AND_ASSIGN(EncodedProgram);
};