summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.h
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2018-07-23 15:30:52 +0100
committerVladimir Marko <vmarko@google.com>2018-07-23 18:30:45 +0100
commitfca0b491a34144acf6769ab9c5fb528ac81bd325 (patch)
tree3896bc10455308ed675886d8d8037d5358c1556d /compiler/optimizing/instruction_builder.h
parentfb9c672577ae9772557f72f9cecb77d4d24af585 (diff)
Fix a stale reference use.
It is unsafe to use an expression like klass.Get() == ResolveType() where the `ResolveType()` call can invalidate the plain pointer already retrieved from a Handle<>. We fix this in HInstructionBuilder::BuildLoadClass() by reordering the code and we change the prefix of related functions from "Get" to "Resolve" to better express their semantics. We also pass the ScopedObjectAccess helper all the way to the `ResolveClassFrom()` to avoid constructing a new one. Test: m test-art-host-gtest Test: testrunner.py --host Bug: 31113334 Change-Id: I13c1ea356386f28fdc9548da781982f9774080f1
Diffstat (limited to 'compiler/optimizing/instruction_builder.h')
-rw-r--r--compiler/optimizing/instruction_builder.h15
1 files changed, 10 insertions, 5 deletions
diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h
index 578172a18e..af1b86ca6f 100644
--- a/compiler/optimizing/instruction_builder.h
+++ b/compiler/optimizing/instruction_builder.h
@@ -219,7 +219,8 @@ class HInstructionBuilder : public ValueObject {
// Builds a `HLoadClass` loading the given `type_index`.
HLoadClass* BuildLoadClass(dex::TypeIndex type_index, uint32_t dex_pc);
- HLoadClass* BuildLoadClass(dex::TypeIndex type_index,
+ HLoadClass* BuildLoadClass(ScopedObjectAccess& soa,
+ dex::TypeIndex type_index,
const DexFile& dex_file,
Handle<mirror::Class> klass,
uint32_t dex_pc,
@@ -229,7 +230,7 @@ class HInstructionBuilder : public ValueObject {
Handle<mirror::Class> ResolveClass(ScopedObjectAccess& soa, dex::TypeIndex type_index)
REQUIRES_SHARED(Locks::mutator_lock_);
- bool LoadClassNeedsAccessCheck(Handle<mirror::Class> klass)
+ bool LoadClassNeedsAccessCheck(ScopedObjectAccess& soa, Handle<mirror::Class> klass)
REQUIRES_SHARED(Locks::mutator_lock_);
// Builds a `HLoadMethodHandle` loading the given `method_handle_index`.
@@ -239,10 +240,12 @@ class HInstructionBuilder : public ValueObject {
void BuildLoadMethodType(dex::ProtoIndex proto_index, uint32_t dex_pc);
// Returns the outer-most compiling method's class.
- ObjPtr<mirror::Class> GetOutermostCompilingClass() const;
+ ObjPtr<mirror::Class> ResolveOutermostCompilingClass(ScopedObjectAccess& soa) const
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Returns the class whose method is being compiled.
- ObjPtr<mirror::Class> GetCompilingClass() const;
+ ObjPtr<mirror::Class> ResolveCompilingClass(ScopedObjectAccess& soa) const
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Returns whether `type_index` points to the outer-most compiling method's class.
bool IsOutermostCompilingClass(dex::TypeIndex type_index) const;
@@ -269,6 +272,7 @@ class HInstructionBuilder : public ValueObject {
void HandleStringInitResult(HInvokeStaticOrDirect* invoke);
HClinitCheck* ProcessClinitCheckForInvoke(
+ ScopedObjectAccess& soa,
uint32_t dex_pc,
ArtMethod* method,
HInvokeStaticOrDirect::ClinitCheckRequirement* clinit_check_requirement)
@@ -282,7 +286,8 @@ class HInstructionBuilder : public ValueObject {
void BuildConstructorFenceForAllocation(HInstruction* allocation);
// Return whether the compiler can assume `cls` is initialized.
- bool IsInitialized(Handle<mirror::Class> cls) const REQUIRES_SHARED(Locks::mutator_lock_);
+ bool IsInitialized(ScopedObjectAccess& soa, Handle<mirror::Class> cls) const
+ REQUIRES_SHARED(Locks::mutator_lock_);
// Try to resolve a method using the class linker. Return null if a method could
// not be resolved.