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

Unified Diff: courgette/disassembler.cc

Issue 2854113002: [Courgette] Reduce AssemblyProgram to reduce Courgette-apply RAM floor and disk churn. (Closed)
Patch Set: Sync and merge. Created 3 years, 8 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/disassembler.cc
diff --git a/courgette/disassembler.cc b/courgette/disassembler.cc
index 64ca27400aa06c944df5e9f9291b436b1178add2..e14ff325c652e741d39587ed9abf493d99f724de 100644
--- a/courgette/disassembler.cc
+++ b/courgette/disassembler.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "courgette/assembly_program.h"
+#include "courgette/encoded_program.h"
namespace courgette {
@@ -54,8 +55,7 @@ const uint8_t* Disassembler::RVAToPointer(RVA rva) const {
return FileOffsetToPointer(file_offset);
}
-std::unique_ptr<AssemblyProgram> Disassembler::Disassemble(
- bool annotate_labels) {
+std::unique_ptr<AssemblyProgram> Disassembler::CreateProgram(bool annotate) {
if (!ok() || !ExtractAbs32Locations() || !ExtractRel32Locations())
return nullptr;
@@ -64,16 +64,25 @@ std::unique_ptr<AssemblyProgram> Disassembler::Disassemble(
PrecomputeLabels(program.get());
RemoveUnusedRel32Locations(program.get());
+ program->DefaultAssignIndexes();
- if (!program->GenerateInstructions(GetInstructionGenerator(program.get()),
- annotate_labels)) {
- return nullptr;
+ if (annotate) {
+ if (!program->AnnotateLabels(GetInstructionGenerator(program.get())))
+ return nullptr;
}
- program->DefaultAssignIndexes();
return program;
}
+Status Disassembler::DisassembleAndEncode(AssemblyProgram* program,
+ EncodedProgram* encoded) {
+ program->PrepareEncodedProgram(encoded);
+ return encoded->GenerateInstructions(program->kind(),
+ GetInstructionGenerator(program))
+ ? C_OK
+ : C_DISASSEMBLY_FAILED;
+}
+
bool Disassembler::Good() {
failure_reason_ = nullptr;
return true;

Powered by Google App Engine
This is Rietveld 408576698