runtime: Partially implement box-lambda and unbox-lambda experimental opcodes
These opcodes are not yet fully specified, and *will* change before they become shippable.
Do not write production code against experimental opcodes.
--
Implement partial interpreter support for new dex instructions box/unbox-lambda.
* box-lambda will take a closure and convert it into an Object
* unbox-lambda will take an Object and convert it to a closure
(Currently does not implement object identity or variable capture).
All new opcodes are disabled by default, use runtime option -Xexperimental-lambdas to enable them.
Change-Id: I3c15ccf8a26ccecd1d35808a8c1b4149220f6019
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 33b0935..c2c9923 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -2844,11 +2844,29 @@
break;
}
- case 0xf4:
- case 0xf5:
- case 0xf7 ... 0xf9: {
+ case Instruction::UNUSED_F4:
+ case Instruction::UNUSED_F5:
+ case Instruction::UNUSED_F7: {
DCHECK(false); // TODO(iam): Implement opcodes for lambdas
- FALLTHROUGH_INTENDED; // Conservatively fail verification on release builds.
+ // Conservatively fail verification on release builds.
+ Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "Unexpected opcode " << inst->DumpString(dex_file_);
+ break;
+ }
+
+ case Instruction::BOX_LAMBDA: {
+ // Don't bother verifying, instead the interpreter will take the slow path with access checks.
+ // 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
+ break;
+ }
+
+ case Instruction::UNBOX_LAMBDA: {
+ // Don't bother verifying, instead the interpreter will take the slow path with access checks.
+ // 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 unbox-lambda verification
+ break;
}
/* These should never appear during verification. */