summaryrefslogtreecommitdiffstats
path: root/runtime/dex_instruction.cc
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2015-06-10 15:55:30 -0700
committerIgor Murashkin <iam@google.com>2015-06-18 10:22:27 -0700
commit158f35c98e2ec0d40d2c032b8cdce5fb60944a7f (patch)
tree63bb3bbed85b0add42c7fdc714cd611424d8af2e /runtime/dex_instruction.cc
parentc449e8b79aaaf156ce055524c41474cc1200ed5a (diff)
downloadart-158f35c98e2ec0d40d2c032b8cdce5fb60944a7f.tar.gz
art-158f35c98e2ec0d40d2c032b8cdce5fb60944a7f.tar.bz2
art-158f35c98e2ec0d40d2c032b8cdce5fb60944a7f.zip
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/dex_instruction.cc')
-rw-r--r--runtime/dex_instruction.cc30
1 files changed, 29 insertions, 1 deletions
diff --git a/runtime/dex_instruction.cc b/runtime/dex_instruction.cc
index 69fe87464d..537fa154b1 100644
--- a/runtime/dex_instruction.cc
+++ b/runtime/dex_instruction.cc
@@ -63,7 +63,7 @@ int const Instruction::kInstructionSizeInCodeUnits[] = {
#define INSTRUCTION_SIZE(opcode, c, p, format, r, i, a, v) \
((opcode == NOP) ? -1 : \
((format >= k10x) && (format <= k10t)) ? 1 : \
- ((format >= k20t) && (format <= k22c)) ? 2 : \
+ ((format >= k20t) && (format <= k25x)) ? 2 : \
((format >= k32x) && (format <= k3rc)) ? 3 : \
(format == k51l) ? 5 : -1),
#include "dex_instruction_list.h"
@@ -224,6 +224,14 @@ std::string Instruction::DumpString(const DexFile* file) const {
break;
}
FALLTHROUGH_INTENDED;
+ case CREATE_LAMBDA:
+ if (file != nullptr) {
+ uint32_t method_idx = VRegB_21c();
+ os << opcode << " v" << static_cast<int>(VRegA_21c()) << ", " << PrettyMethod(method_idx, *file, true)
+ << " // method@" << method_idx;
+ break;
+ }
+ FALLTHROUGH_INTENDED;
default:
os << StringPrintf("%s v%d, thing@%d", opcode, VRegA_21c(), VRegB_21c());
break;
@@ -304,6 +312,26 @@ std::string Instruction::DumpString(const DexFile* file) const {
}
break;
}
+ case k25x: {
+ if (Opcode() == INVOKE_LAMBDA) {
+ uint32_t arg[kMaxVarArgRegs];
+ GetAllArgs25x(arg);
+ const size_t num_extra_var_args = VRegB_25x();
+ DCHECK_LE(num_extra_var_args + 1, kMaxVarArgRegs);
+
+ // invoke-lambda vC, {vD, vE, vF, vG}
+ os << opcode << " v" << arg[0] << ", {";
+ for (size_t i = 0; i < num_extra_var_args; ++i) {
+ if (i != 0) {
+ os << ", ";
+ }
+ os << "v" << arg[i+1];
+ }
+ os << "}";
+ break;
+ }
+ FALLTHROUGH_INTENDED;
+ }
case k32x: os << StringPrintf("%s v%d, v%d", opcode, VRegA_32x(), VRegB_32x()); break;
case k30t: os << StringPrintf("%s %+d", opcode, VRegA_30t()); break;
case k31t: os << StringPrintf("%s v%d, %+d", opcode, VRegA_31t(), VRegB_31t()); break;