summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
authorAart Bik <ajcbik@google.com>2016-06-02 17:53:58 -0700
committerAart Bik <ajcbik@google.com>2016-06-03 14:32:49 -0700
commit1415413bddb3a9cd9432de3381ef27e5181e58cc (patch)
treec3f6e6593cbd93ee4f04683548bcf7e014ee1dcc /compiler/optimizing/instruction_builder.cc
parent3f432d5a7c184b7580bd5aba27158c1455c328ff (diff)
Do not place null check from unresolved field access.
Rationale: These accesses go though the runtime anyway where various checks are done, including null check. Since particular checks, like access checks, need to occur prior to the null check (to ensure link errors are not masked by a null reference), the explicit null check should not occur in the HIR. BUG=29068831 Change-Id: I30fc9cb8cf4993e4176e235ceba3a38aef98d503
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index aaddc01f1f..5e691c7f5f 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -1204,7 +1204,12 @@ bool HInstructionBuilder::BuildInstanceFieldAccess(const Instruction& instructio
compiler_driver_->ComputeInstanceFieldInfo(field_index, dex_compilation_unit_, is_put, soa);
- HInstruction* object = LoadNullCheckedLocal(obj_reg, dex_pc);
+ // Generate an explicit null check on the reference, unless the field access
+ // is unresolved. In that case, we rely on the runtime to perform various
+ // checks first, followed by a null check.
+ HInstruction* object = (resolved_field == nullptr)
+ ? LoadLocal(obj_reg, Primitive::kPrimNot)
+ : LoadNullCheckedLocal(obj_reg, dex_pc);
Primitive::Type field_type = (resolved_field == nullptr)
? GetFieldAccessType(*dex_file_, field_index)