runtime: Add lambda box/unbox object equality
A lambda that is boxed with box-lambda is now stored as a weak reference
in a global runtime table (lambda::BoxTable). Repeatedly boxing the same
lambda closure value will always return the same java.lang.Object back.
Since there is no way to observe the address of an object, a GC can
happen and clean up the table of any dead boxed lambdas, which can also
shrink the table to prevent the memory use from growing too much.
(Note that a lambda closure is immutable, so hashing over it is
guaranteed safe.)
Change-Id: I786c1323ff14eed937936b303d511875f9642524
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 11c3e65..764b6ba 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -2946,6 +2946,12 @@
// If the code would've normally hard-failed, then the interpreter will throw the
// appropriate verification errors at runtime.
Fail(VERIFY_ERROR_FORCE_INTERPRETER); // TODO(iam): implement box-lambda verification
+
+ // Partial verification. Sets the resulting type to always be an object, which
+ // is good enough for some other verification to occur without hard-failing.
+ const uint32_t vreg_target_object = inst->VRegA_22x(); // box-lambda vA, vB
+ const RegType& reg_type = reg_types_.JavaLangObject(need_precise_constants_);
+ work_line_->SetRegisterType(this, vreg_target_object, reg_type);
break;
}