Remove CompiledMethod dependency on CompilerDriver.
Test: m test-art-host-gtest
Change-Id: Ibee78d5c54d3ff8162258963fde25065b579a000
diff --git a/compiler/compiled_method.cc b/compiler/compiled_method.cc
index 29f004c..ef9d919 100644
--- a/compiler/compiled_method.cc
+++ b/compiler/compiled_method.cc
@@ -17,21 +17,20 @@
#include "compiled_method.h"
#include "driver/compiled_method_storage.h"
-#include "driver/compiler_driver.h"
#include "utils/swap_space.h"
namespace art {
-CompiledCode::CompiledCode(CompilerDriver* compiler_driver,
+CompiledCode::CompiledCode(CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code)
- : compiler_driver_(compiler_driver),
- quick_code_(compiler_driver_->GetCompiledMethodStorage()->DeduplicateCode(quick_code)),
+ : storage_(storage),
+ quick_code_(storage->DeduplicateCode(quick_code)),
packed_fields_(InstructionSetField::Encode(instruction_set)) {
}
CompiledCode::~CompiledCode() {
- compiler_driver_->GetCompiledMethodStorage()->ReleaseCode(quick_code_);
+ GetStorage()->ReleaseCode(quick_code_);
}
bool CompiledCode::operator==(const CompiledCode& rhs) const {
@@ -99,29 +98,29 @@
}
}
-CompiledMethod::CompiledMethod(CompilerDriver* driver,
+CompiledMethod::CompiledMethod(CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code,
const ArrayRef<const uint8_t>& vmap_table,
const ArrayRef<const uint8_t>& cfi_info,
const ArrayRef<const linker::LinkerPatch>& patches)
- : CompiledCode(driver, instruction_set, quick_code),
- vmap_table_(driver->GetCompiledMethodStorage()->DeduplicateVMapTable(vmap_table)),
- cfi_info_(driver->GetCompiledMethodStorage()->DeduplicateCFIInfo(cfi_info)),
- patches_(driver->GetCompiledMethodStorage()->DeduplicateLinkerPatches(patches)) {
+ : CompiledCode(storage, instruction_set, quick_code),
+ vmap_table_(storage->DeduplicateVMapTable(vmap_table)),
+ cfi_info_(storage->DeduplicateCFIInfo(cfi_info)),
+ patches_(storage->DeduplicateLinkerPatches(patches)) {
}
CompiledMethod* CompiledMethod::SwapAllocCompiledMethod(
- CompilerDriver* driver,
+ CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code,
const ArrayRef<const uint8_t>& vmap_table,
const ArrayRef<const uint8_t>& cfi_info,
const ArrayRef<const linker::LinkerPatch>& patches) {
- SwapAllocator<CompiledMethod> alloc(driver->GetCompiledMethodStorage()->GetSwapSpaceAllocator());
+ SwapAllocator<CompiledMethod> alloc(storage->GetSwapSpaceAllocator());
CompiledMethod* ret = alloc.allocate(1);
alloc.construct(ret,
- driver,
+ storage,
instruction_set,
quick_code,
vmap_table,
@@ -129,14 +128,15 @@
return ret;
}
-void CompiledMethod::ReleaseSwapAllocatedCompiledMethod(CompilerDriver* driver, CompiledMethod* m) {
- SwapAllocator<CompiledMethod> alloc(driver->GetCompiledMethodStorage()->GetSwapSpaceAllocator());
+void CompiledMethod::ReleaseSwapAllocatedCompiledMethod(CompiledMethodStorage* storage,
+ CompiledMethod* m) {
+ SwapAllocator<CompiledMethod> alloc(storage->GetSwapSpaceAllocator());
alloc.destroy(m);
alloc.deallocate(m, 1);
}
CompiledMethod::~CompiledMethod() {
- CompiledMethodStorage* storage = GetCompilerDriver()->GetCompiledMethodStorage();
+ CompiledMethodStorage* storage = GetStorage();
storage->ReleaseLinkerPatches(patches_);
storage->ReleaseCFIInfo(cfi_info_);
storage->ReleaseVMapTable(vmap_table_);
diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h
index 864ce58..75790c9 100644
--- a/compiler/compiled_method.h
+++ b/compiler/compiled_method.h
@@ -28,7 +28,6 @@
namespace art {
template <typename T> class ArrayRef;
-class CompilerDriver;
class CompiledMethodStorage;
template<typename T> class LengthPrefixedArray;
@@ -39,7 +38,7 @@
class CompiledCode {
public:
// For Quick to supply an code blob
- CompiledCode(CompilerDriver* compiler_driver,
+ CompiledCode(CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code);
@@ -78,8 +77,8 @@
template <typename T>
static ArrayRef<const T> GetArray(const LengthPrefixedArray<T>* array);
- CompilerDriver* GetCompilerDriver() {
- return compiler_driver_;
+ CompiledMethodStorage* GetStorage() {
+ return storage_;
}
template <typename BitFieldType>
@@ -96,7 +95,7 @@
private:
using InstructionSetField = BitField<InstructionSet, 0u, kInstructionSetFieldSize>;
- CompilerDriver* const compiler_driver_;
+ CompiledMethodStorage* const storage_;
// Used to store the compiled code.
const LengthPrefixedArray<uint8_t>* const quick_code_;
@@ -109,7 +108,7 @@
// Constructs a CompiledMethod.
// Note: Consider using the static allocation methods below that will allocate the CompiledMethod
// in the swap space.
- CompiledMethod(CompilerDriver* driver,
+ CompiledMethod(CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code,
const ArrayRef<const uint8_t>& vmap_table,
@@ -119,14 +118,14 @@
virtual ~CompiledMethod();
static CompiledMethod* SwapAllocCompiledMethod(
- CompilerDriver* driver,
+ CompiledMethodStorage* storage,
InstructionSet instruction_set,
const ArrayRef<const uint8_t>& quick_code,
const ArrayRef<const uint8_t>& vmap_table,
const ArrayRef<const uint8_t>& cfi_info,
const ArrayRef<const linker::LinkerPatch>& patches);
- static void ReleaseSwapAllocatedCompiledMethod(CompilerDriver* driver, CompiledMethod* m);
+ static void ReleaseSwapAllocatedCompiledMethod(CompiledMethodStorage* storage, CompiledMethod* m);
bool IsIntrinsic() const {
return GetPackedField<IsIntrinsicField>();
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index fe99eaa..04ad10c 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -614,7 +614,7 @@
instruction_set = InstructionSet::kArm;
}
CompiledMethod* ret = CompiledMethod::SwapAllocCompiledMethod(
- driver_,
+ driver_->GetCompiledMethodStorage(),
instruction_set,
ArrayRef<const uint8_t>(), // no code
ArrayRef<const uint8_t>(quicken_data), // vmap_table
@@ -665,7 +665,8 @@
// There is up to one compiled method for each method ref. Releasing it leaves the
// deduped data intact, this means its safe to do even when other threads might be
// compiling.
- CompiledMethod::ReleaseSwapAllocatedCompiledMethod(driver_, method);
+ CompiledMethod::ReleaseSwapAllocatedCompiledMethod(driver_->GetCompiledMethodStorage(),
+ method);
}
}
}
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index 8b35bd3..9fac2bc 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -19,24 +19,13 @@
#include <gtest/gtest.h>
#include "compiled_method-inl.h"
-#include "compiler_driver.h"
-#include "compiler_options.h"
-#include "dex/verification_results.h"
namespace art {
TEST(CompiledMethodStorage, Deduplicate) {
- CompilerOptions compiler_options;
- VerificationResults verification_results(&compiler_options);
- CompilerDriver driver(&compiler_options,
- &verification_results,
- Compiler::kOptimizing,
- /* image_classes */ nullptr,
- /* thread_count */ 1u,
- /* swap_fd */ -1);
- CompiledMethodStorage* storage = driver.GetCompiledMethodStorage();
+ CompiledMethodStorage storage(/* swap_fd */ -1);
- ASSERT_TRUE(storage->DedupeEnabled()); // The default.
+ ASSERT_TRUE(storage.DedupeEnabled()); // The default.
const uint8_t raw_code1[] = { 1u, 2u, 3u };
const uint8_t raw_code2[] = { 4u, 3u, 2u, 1u };
@@ -76,7 +65,7 @@
for (auto&& f : cfi_info) {
for (auto&& p : patches) {
compiled_methods.push_back(CompiledMethod::SwapAllocCompiledMethod(
- &driver, InstructionSet::kNone, c, v, f, p));
+ &storage, InstructionSet::kNone, c, v, f, p));
}
}
}
@@ -105,7 +94,7 @@
}
}
for (CompiledMethod* method : compiled_methods) {
- CompiledMethod::ReleaseSwapAllocatedCompiledMethod(&driver, method);
+ CompiledMethod::ReleaseSwapAllocatedCompiledMethod(&storage, method);
}
}
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 0d0a7f2..77b0cea 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -276,7 +276,7 @@
compiled_methods_.Visit([this](const DexFileReference& ref ATTRIBUTE_UNUSED,
CompiledMethod* method) {
if (method != nullptr) {
- CompiledMethod::ReleaseSwapAllocatedCompiledMethod(this, method);
+ CompiledMethod::ReleaseSwapAllocatedCompiledMethod(GetCompiledMethodStorage(), method);
}
});
compiler_->UnInit();
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index fe6abd4..1db20fc 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -765,7 +765,7 @@
ScopedArenaVector<uint8_t> stack_map = codegen->BuildStackMaps(code_item_for_osr_check);
CompiledMethod* compiled_method = CompiledMethod::SwapAllocCompiledMethod(
- GetCompilerDriver(),
+ GetCompilerDriver()->GetCompiledMethodStorage(),
codegen->GetInstructionSet(),
code_allocator->GetMemory(),
ArrayRef<const uint8_t>(stack_map),
@@ -1222,7 +1222,7 @@
ScopedArenaVector<uint8_t> stack_map = CreateJniStackMap(&stack_map_allocator,
jni_compiled_method);
return CompiledMethod::SwapAllocCompiledMethod(
- GetCompilerDriver(),
+ GetCompilerDriver()->GetCompiledMethodStorage(),
jni_compiled_method.GetInstructionSet(),
jni_compiled_method.GetCode(),
ArrayRef<const uint8_t>(stack_map),