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

Unified Diff: courgette/assembly_program.h

Issue 6677141: Switch out use of std::string and std::vector for large allocations for a buffer class that doesn... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
Index: courgette/assembly_program.h
===================================================================
--- courgette/assembly_program.h (revision 80344)
+++ courgette/assembly_program.h (working copy)
@@ -19,8 +19,7 @@
class EncodedProgram;
class Instruction;
-typedef std::vector<Instruction*, MemoryAllocator<Instruction*> >
- InstructionVector;
+typedef NoThrowBuffer<Instruction*> InstructionVector;
// A Label is a symbolic reference to an address. Unlike a conventional
// assembly language, we always know the address. The address will later be
@@ -34,7 +33,7 @@
Label() : rva_(0), index_(kNoIndex) {}
explicit Label(RVA rva) : rva_(rva), index_(kNoIndex) {}
- RVA rva_; // Address refered to by the label.
+ RVA rva_; // Address referred to by the label.
int index_; // Index of address in address table, kNoIndex until assigned.
};
@@ -69,19 +68,19 @@
// Instructions will be assembled in the order they are emitted.
// Generates an entire base relocation table.
- void EmitMakeRelocsInstruction();
+ CheckBool EmitMakeRelocsInstruction();
// Following instruction will be assembled at address 'rva'.
- void EmitOriginInstruction(RVA rva);
+ CheckBool EmitOriginInstruction(RVA rva);
// Generates a single byte of data or machine instruction.
- void EmitByteInstruction(uint8 byte);
+ CheckBool EmitByteInstruction(uint8 byte);
// Generates 4-byte relative reference to address of 'label'.
- void EmitRel32(Label* label);
+ CheckBool EmitRel32(Label* label);
// Generates 4-byte absolute reference to address of 'label'.
- void EmitAbs32(Label* label);
+ CheckBool EmitAbs32(Label* label);
Label* FindOrMakeAbs32Label(RVA rva);
grt (UTC plus 2) 2011/04/05 17:10:08 Document that these may return NULL.
tommi (sloooow) - chröme 2011/04/05 19:06:53 Done.
Label* FindOrMakeRel32Label(RVA rva);
@@ -106,7 +105,11 @@
Label* InstructionRel32Label(const Instruction* instruction) const;
private:
- void Emit(Instruction* instruction) { instructions_.push_back(instruction); }
+ CheckBool Emit(Instruction* instruction) {
grt (UTC plus 2) 2011/04/05 17:10:08 This method is leaky. Does Emit unconditionally t
tommi (sloooow) - chröme 2011/04/05 19:06:53 Done.
+ if (!instruction)
+ return false;
+ return instructions_.push_back(instruction);
+ }
Label* FindLabel(RVA rva, RVAToLabel* labels);
grt (UTC plus 2) 2011/04/05 17:10:08 Document that this may return NULL.
tommi (sloooow) - chröme 2011/04/05 19:06:53 Done.

Powered by Google App Engine
This is Rietveld 408576698