summaryrefslogtreecommitdiff
path: root/compiler/optimizing/code_generator.h
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2023-06-16 12:18:27 +0100
committer Nicolas Geoffray <ngeoffray@google.com> 2023-06-21 07:59:13 +0000
commit70bba9c9f5fbba03c62a4542411e1d938375f14e (patch)
tree0b4ef702e671db908321639d39912636603166bc /compiler/optimizing/code_generator.h
parent5bf0f68407d3467a3fbfa9ab9ae0c8fabead615b (diff)
Remove CodeAllocator and the extra copy of generated code.
The code used to copy the final generated code twice: from assembler to CodeAllocator, and then to CodeAllocator to SwapAllocator/JitMemory. The assemblers never depended on the exact location of the generated code, so just drop that feature. Test: test.py Change-Id: I8dc82e4926097092b9aac336a5a5d40f79dc62ca
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r--compiler/optimizing/code_generator.h21
1 files changed, 7 insertions, 14 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 5f4f377a27..bcbffe49fe 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -87,18 +87,6 @@ namespace linker {
class LinkerPatch;
} // namespace linker
-class CodeAllocator {
- public:
- CodeAllocator() {}
- virtual ~CodeAllocator() {}
-
- virtual uint8_t* Allocate(size_t size) = 0;
- virtual ArrayRef<const uint8_t> GetMemory() const = 0;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(CodeAllocator);
-};
-
class SlowPathCode : public DeletableArenaObject<kArenaAllocSlowPaths> {
public:
explicit SlowPathCode(HInstruction* instruction) : instruction_(instruction) {
@@ -205,7 +193,7 @@ class FieldAccessCallingConvention {
class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
public:
// Compiles the graph to executable instructions.
- void Compile(CodeAllocator* allocator);
+ void Compile();
static std::unique_ptr<CodeGenerator> Create(HGraph* graph,
const CompilerOptions& compiler_options,
OptimizingCompilerStats* stats = nullptr);
@@ -226,7 +214,7 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
}
virtual void Initialize() = 0;
- virtual void Finalize(CodeAllocator* allocator);
+ virtual void Finalize();
virtual void EmitLinkerPatches(ArenaVector<linker::LinkerPatch>* linker_patches);
virtual bool NeedsThunkCode(const linker::LinkerPatch& patch) const;
virtual void EmitThunkCode(const linker::LinkerPatch& patch,
@@ -736,6 +724,11 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
static QuickEntrypointEnum GetArrayAllocationEntrypoint(HNewArray* new_array);
static ScaleFactor ScaleFactorForType(DataType::Type type);
+ ArrayRef<const uint8_t> GetCode() const {
+ return ArrayRef<const uint8_t>(GetAssembler().CodeBufferBaseAddress(),
+ GetAssembler().CodeSize());
+ }
+
protected:
// Patch info used for recording locations of required linker patches and their targets,
// i.e. target method, string, type or code identified by their dex file and index,