Implemented Nested Transaction
Transaction can be created recursively and every transaction knows which
class it is created for.
The goal of implementing nested transaction is to let every class
initialization (especially execution of class initializer) associates
with one transaction which provides the ability to track whether field
accesses are valid. To achieve this goal, we implemented a subclass for
ClassLinker called AotClassLinker, which will be instantiated instead of
ClassLinker under AOT compiler.
All invocations of InitializeClass happens at AOT compiler will be
wrapped with creating and destorying transactions.
Transactions will be paused when rollbacking, otherwise the memory will
not be rollbacked properly.
The use the transaction is changed and all usage are updated,
corresponding with native tests mentioning transaction, including
transaction_test and unstarted_runtime_test.
The validation rules will be implemented and explained in another CL.
Test: make test-art-host -j64
Change-Id: If53d3ee3231c337a9ea917f5b885c173917765de
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 62fb45b..324ed0c 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -141,7 +141,7 @@
};
explicit ClassLinker(InternTable* intern_table);
- ~ClassLinker();
+ virtual ~ClassLinker();
// Initialize class linker by bootstraping from dex files.
bool InitWithoutImage(std::vector<std::unique_ptr<const DexFile>> boot_class_path,
@@ -702,6 +702,14 @@
ClassTable* class_table;
};
+ protected:
+ virtual bool InitializeClass(Thread* self,
+ Handle<mirror::Class> klass,
+ bool can_run_clinit,
+ bool can_init_parents)
+ REQUIRES_SHARED(Locks::mutator_lock_)
+ REQUIRES(!Locks::dex_lock_);
+
private:
class LinkInterfaceMethodsHelper;
@@ -891,12 +899,6 @@
REQUIRES(!Locks::dex_lock_)
REQUIRES_SHARED(Locks::mutator_lock_);
- bool InitializeClass(Thread* self,
- Handle<mirror::Class> klass,
- bool can_run_clinit,
- bool can_init_parents)
- REQUIRES_SHARED(Locks::mutator_lock_)
- REQUIRES(!Locks::dex_lock_);
bool InitializeDefaultInterfaceRecursive(Thread* self,
Handle<mirror::Class> klass,
bool can_run_clinit,