summaryrefslogtreecommitdiffstats
path: root/compiler/optimizing/codegen_test.cc
diff options
context:
space:
mode:
authorNicolas Geoffray <ngeoffray@google.com>2014-03-17 10:20:19 +0000
committerNicolas Geoffray <ngeoffray@google.com>2014-03-18 11:20:20 +0000
commit787c3076635cf117eb646c5a89a9014b2072fb44 (patch)
tree3c9c6c6d56e3900cf2255a5d1ade008ec6a40681 /compiler/optimizing/codegen_test.cc
parentb9d50a9829b795932eac4cc50a99b4ce80b0ecb4 (diff)
downloadart-787c3076635cf117eb646c5a89a9014b2072fb44.zip
art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.gz
art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.bz2
Plug new optimizing compiler in compilation pipeline.
Also rename accessors to ART's conventions. Change-Id: I344807055b98aa4b27215704ec362191464acecc
Diffstat (limited to 'compiler/optimizing/codegen_test.cc')
-rw-r--r--compiler/optimizing/codegen_test.cc26
1 files changed, 16 insertions, 10 deletions
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc
index 5020dd0..ff743d8 100644
--- a/compiler/optimizing/codegen_test.cc
+++ b/compiler/optimizing/codegen_test.cc
@@ -27,22 +27,24 @@
namespace art {
-class ExecutableMemoryAllocator : public CodeAllocator {
+class InternalCodeAllocator : public CodeAllocator {
public:
- ExecutableMemoryAllocator() { }
+ InternalCodeAllocator() { }
virtual uint8_t* Allocate(size_t size) {
+ size_ = size;
memory_.reset(new uint8_t[size]);
- CommonCompilerTest::MakeExecutable(memory_.get(), size);
return memory_.get();
}
- uint8_t* memory() const { return memory_.get(); }
+ size_t GetSize() const { return size_; }
+ uint8_t* GetMemory() const { return memory_.get(); }
private:
+ size_t size_;
UniquePtr<uint8_t[]> memory_;
- DISALLOW_COPY_AND_ASSIGN(ExecutableMemoryAllocator);
+ DISALLOW_COPY_AND_ASSIGN(InternalCodeAllocator);
};
static void TestCode(const uint16_t* data, bool has_result = false, int32_t expected = 0) {
@@ -52,18 +54,22 @@ static void TestCode(const uint16_t* data, bool has_result = false, int32_t expe
const DexFile::CodeItem* item = reinterpret_cast<const DexFile::CodeItem*>(data);
HGraph* graph = builder.BuildGraph(*item);
ASSERT_NE(graph, nullptr);
- ExecutableMemoryAllocator allocator;
- CHECK(CodeGenerator::CompileGraph(graph, kX86, &allocator));
+ InternalCodeAllocator allocator;
+ CodeGenerator* codegen = CodeGenerator::Create(&arena, graph, kX86);
+ codegen->Compile(&allocator);
typedef int32_t (*fptr)();
#if defined(__i386__)
- int32_t result = reinterpret_cast<fptr>(allocator.memory())();
+ CommonCompilerTest::MakeExecutable(allocator.GetMemory(), allocator.GetSize());
+ int32_t result = reinterpret_cast<fptr>(allocator.GetMemory())();
if (has_result) {
CHECK_EQ(result, expected);
}
#endif
- CHECK(CodeGenerator::CompileGraph(graph, kArm, &allocator));
+ codegen = CodeGenerator::Create(&arena, graph, kArm);
+ codegen->Compile(&allocator);
#if defined(__arm__)
- int32_t result = reinterpret_cast<fptr>(allocator.memory())();
+ CommonCompilerTest::MakeExecutable(allocator.GetMemory(), allocator.GetSize());
+ int32_t result = reinterpret_cast<fptr>(allocator.GetMemory())();
if (has_result) {
CHECK_EQ(result, expected);
}