Chromium Code Reviews| 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.
|