diff options
author | 2015-06-10 15:55:30 -0700 | |
---|---|---|
committer | 2015-06-18 10:22:27 -0700 | |
commit | 158f35c98e2ec0d40d2c032b8cdce5fb60944a7f (patch) | |
tree | 63bb3bbed85b0add42c7fdc714cd611424d8af2e /runtime/interpreter/interpreter_switch_impl.cc | |
parent | c449e8b79aaaf156ce055524c41474cc1200ed5a (diff) |
interpreter: Add experimental lambda opcodes for invoke/create-lambda
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 invoke/create-lambda, and a
new opcode format 25x.
* Does not verify, in fact verification will soft fail when we see those opcodes.
* Compilers will punt to interpreter since they don't support new opcodes.
* As there is no way to capture/liberate variables yet, the "closure" is just
an ArtMethod for the time being.
All new opcodes are disabled by default, use runtime option -Xexperimental-lambdas to enable them.
For example:
dalvikvm ... -Xexperimental-lambdas ...
dex2oat --runtime-arg -Xexperimental-lambdas ...
Change-Id: I6c996ca32a9b54ec45ec21d7a959b84dfb8a24eb
Diffstat (limited to 'runtime/interpreter/interpreter_switch_impl.cc')
-rw-r--r-- | runtime/interpreter/interpreter_switch_impl.cc | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/runtime/interpreter/interpreter_switch_impl.cc b/runtime/interpreter/interpreter_switch_impl.cc index fcf083cbe1..80401977cd 100644 --- a/runtime/interpreter/interpreter_switch_impl.cc +++ b/runtime/interpreter/interpreter_switch_impl.cc @@ -53,6 +53,11 @@ namespace interpreter { } \ } while (false) +static bool IsExperimentalInstructionEnabled(const Instruction *inst) { + DCHECK(inst->IsExperimental()); + return Runtime::Current()->AreExperimentalLambdasEnabled(); +} + template<bool do_access_check, bool transaction_active> JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, ShadowFrame& shadow_frame, JValue result_register) { @@ -2217,8 +2222,39 @@ JValue ExecuteSwitchImpl(Thread* self, const DexFile::CodeItem* code_item, (inst->VRegC_22b() & 0x1f)); inst = inst->Next_2xx(); break; + case Instruction::INVOKE_LAMBDA: { + if (!IsExperimentalInstructionEnabled(inst)) { + UnexpectedOpcode(inst, shadow_frame); + } + + PREAMBLE(); + bool success = DoInvokeLambda<do_access_check>(self, shadow_frame, inst, inst_data, + &result_register); + POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_2xx); + break; + } + case Instruction::CREATE_LAMBDA: { + if (!IsExperimentalInstructionEnabled(inst)) { + UnexpectedOpcode(inst, shadow_frame); + } + + PREAMBLE(); + bool success = DoCreateLambda<do_access_check>(self, shadow_frame, inst); + POSSIBLY_HANDLE_PENDING_EXCEPTION(!success, Next_2xx); + break; + } + case Instruction::UNUSED_F4: + case Instruction::UNUSED_F5: + case Instruction::UNUSED_F7 ... Instruction::UNUSED_F9: { + if (!IsExperimentalInstructionEnabled(inst)) { + UnexpectedOpcode(inst, shadow_frame); + } + + CHECK(false); // TODO(iam): Implement opcodes for lambdas + break; + } case Instruction::UNUSED_3E ... Instruction::UNUSED_43: - case Instruction::UNUSED_F3 ... Instruction::UNUSED_FF: + case Instruction::UNUSED_FA ... Instruction::UNUSED_FF: case Instruction::UNUSED_79: case Instruction::UNUSED_7A: UnexpectedOpcode(inst, shadow_frame); |