mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 00:13:50 +00:00
[vm/bytecode] Cleanup support for bytecode formats older than v7
Bytecode format v7 was introduced 2019 May 08,
in 68de477535
.
Change-Id: I79d94f7153d66d418088707c3658d928a3ec41ad
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/106969
Reviewed-by: Régis Crelier <regis@google.com>
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
This commit is contained in:
parent
7a57e241a3
commit
9b5718ca7e
|
@ -13,127 +13,91 @@ library vm.bytecode.dbc;
|
|||
const int currentBytecodeFormatVersion = 11;
|
||||
|
||||
enum Opcode {
|
||||
// Old instructions, used before bytecode v7.
|
||||
// TODO(alexmarkov): remove
|
||||
|
||||
kTrap_Old,
|
||||
|
||||
// Prologue and stack management.
|
||||
kEntry_Old,
|
||||
kEntryFixed_Old,
|
||||
kEntryOptional_Old,
|
||||
kLoadConstant_Old,
|
||||
kFrame_Old,
|
||||
kCheckFunctionTypeArgs_Old,
|
||||
kCheckStack_Old,
|
||||
|
||||
// Object allocation.
|
||||
kAllocate_Old,
|
||||
kAllocateT_Old,
|
||||
kCreateArrayTOS_Old,
|
||||
|
||||
// Context allocation and access.
|
||||
kAllocateContext_Old,
|
||||
kCloneContext_Old,
|
||||
kLoadContextParent_Old,
|
||||
kStoreContextParent_Old,
|
||||
kLoadContextVar_Old,
|
||||
kStoreContextVar_Old,
|
||||
|
||||
// Constants.
|
||||
kPushConstant_Old,
|
||||
kPushNull_Old,
|
||||
kPushTrue_Old,
|
||||
kPushFalse_Old,
|
||||
kPushInt_Old,
|
||||
|
||||
// Locals and expression stack.
|
||||
kDrop1_Old,
|
||||
kPush_Old,
|
||||
kPopLocal_Old,
|
||||
kStoreLocal_Old,
|
||||
|
||||
// Instance fields and arrays.
|
||||
kLoadFieldTOS_Old,
|
||||
kStoreFieldTOS_Old,
|
||||
kStoreIndexedTOS_Old,
|
||||
|
||||
// Static fields.
|
||||
kPushStatic_Old,
|
||||
kStoreStaticTOS_Old,
|
||||
|
||||
// Jumps.
|
||||
kJump_Old,
|
||||
kJumpIfNoAsserts_Old,
|
||||
kJumpIfNotZeroTypeArgs_Old,
|
||||
kJumpIfEqStrict_Old,
|
||||
kJumpIfNeStrict_Old,
|
||||
kJumpIfTrue_Old,
|
||||
kJumpIfFalse_Old,
|
||||
kJumpIfNull_Old,
|
||||
kJumpIfNotNull_Old,
|
||||
|
||||
// Calls.
|
||||
kUnused00_Old,
|
||||
kInterfaceCall_Old,
|
||||
kDynamicCall_Old,
|
||||
kNativeCall_Old,
|
||||
kReturnTOS_Old,
|
||||
|
||||
// Types and type checks.
|
||||
kAssertAssignable_Old,
|
||||
kAssertBoolean_Old,
|
||||
kAssertSubtype_Old,
|
||||
kLoadTypeArgumentsField_Old,
|
||||
kInstantiateType_Old,
|
||||
kInstantiateTypeArgumentsTOS_Old,
|
||||
|
||||
// Exception handling.
|
||||
kThrow_Old,
|
||||
kMoveSpecial_Old,
|
||||
kSetFrame_Old,
|
||||
|
||||
// Bool operations.
|
||||
kBooleanNegateTOS_Old,
|
||||
|
||||
// Null operations.
|
||||
kEqualsNull_Old,
|
||||
|
||||
// Int operations.
|
||||
kNegateInt_Old,
|
||||
kAddInt_Old,
|
||||
kSubInt_Old,
|
||||
kMulInt_Old,
|
||||
kTruncDivInt_Old,
|
||||
kModInt_Old,
|
||||
kBitAndInt_Old,
|
||||
kBitOrInt_Old,
|
||||
kBitXorInt_Old,
|
||||
kShlInt_Old,
|
||||
kShrInt_Old,
|
||||
kCompareIntEq_Old,
|
||||
kCompareIntGt_Old,
|
||||
kCompareIntLt_Old,
|
||||
kCompareIntGe_Old,
|
||||
kCompareIntLe_Old,
|
||||
|
||||
kDirectCall_Old,
|
||||
|
||||
kAllocateClosure_Old,
|
||||
|
||||
kUncheckedInterfaceCall_Old,
|
||||
|
||||
// Double operations.
|
||||
kNegateDouble_Old,
|
||||
kAddDouble_Old,
|
||||
kSubDouble_Old,
|
||||
kMulDouble_Old,
|
||||
kDivDouble_Old,
|
||||
kCompareDoubleEq_Old,
|
||||
kCompareDoubleGt_Old,
|
||||
kCompareDoubleLt_Old,
|
||||
kCompareDoubleGe_Old,
|
||||
kCompareDoubleLe_Old,
|
||||
kUnusedOpcode000,
|
||||
kUnusedOpcode001,
|
||||
kUnusedOpcode002,
|
||||
kUnusedOpcode003,
|
||||
kUnusedOpcode004,
|
||||
kUnusedOpcode005,
|
||||
kUnusedOpcode006,
|
||||
kUnusedOpcode007,
|
||||
kUnusedOpcode008,
|
||||
kUnusedOpcode009,
|
||||
kUnusedOpcode010,
|
||||
kUnusedOpcode011,
|
||||
kUnusedOpcode012,
|
||||
kUnusedOpcode013,
|
||||
kUnusedOpcode014,
|
||||
kUnusedOpcode015,
|
||||
kUnusedOpcode016,
|
||||
kUnusedOpcode017,
|
||||
kUnusedOpcode018,
|
||||
kUnusedOpcode019,
|
||||
kUnusedOpcode020,
|
||||
kUnusedOpcode021,
|
||||
kUnusedOpcode022,
|
||||
kUnusedOpcode023,
|
||||
kUnusedOpcode024,
|
||||
kUnusedOpcode025,
|
||||
kUnusedOpcode026,
|
||||
kUnusedOpcode027,
|
||||
kUnusedOpcode028,
|
||||
kUnusedOpcode029,
|
||||
kUnusedOpcode030,
|
||||
kUnusedOpcode031,
|
||||
kUnusedOpcode032,
|
||||
kUnusedOpcode033,
|
||||
kUnusedOpcode034,
|
||||
kUnusedOpcode035,
|
||||
kUnusedOpcode036,
|
||||
kUnusedOpcode037,
|
||||
kUnusedOpcode038,
|
||||
kUnusedOpcode039,
|
||||
kUnusedOpcode040,
|
||||
kUnusedOpcode041,
|
||||
kUnusedOpcode042,
|
||||
kUnusedOpcode043,
|
||||
kUnusedOpcode044,
|
||||
kUnusedOpcode045,
|
||||
kUnusedOpcode046,
|
||||
kUnusedOpcode047,
|
||||
kUnusedOpcode048,
|
||||
kUnusedOpcode049,
|
||||
kUnusedOpcode050,
|
||||
kUnusedOpcode051,
|
||||
kUnusedOpcode052,
|
||||
kUnusedOpcode053,
|
||||
kUnusedOpcode054,
|
||||
kUnusedOpcode055,
|
||||
kUnusedOpcode056,
|
||||
kUnusedOpcode057,
|
||||
kUnusedOpcode058,
|
||||
kUnusedOpcode059,
|
||||
kUnusedOpcode060,
|
||||
kUnusedOpcode061,
|
||||
kUnusedOpcode062,
|
||||
kUnusedOpcode063,
|
||||
kUnusedOpcode064,
|
||||
kUnusedOpcode065,
|
||||
kUnusedOpcode066,
|
||||
kUnusedOpcode067,
|
||||
kUnusedOpcode068,
|
||||
kUnusedOpcode069,
|
||||
kUnusedOpcode070,
|
||||
kUnusedOpcode071,
|
||||
kUnusedOpcode072,
|
||||
kUnusedOpcode073,
|
||||
kUnusedOpcode074,
|
||||
kUnusedOpcode075,
|
||||
kUnusedOpcode076,
|
||||
kUnusedOpcode077,
|
||||
kUnusedOpcode078,
|
||||
kUnusedOpcode079,
|
||||
kUnusedOpcode080,
|
||||
kUnusedOpcode081,
|
||||
kUnusedOpcode082,
|
||||
kUnusedOpcode083,
|
||||
kUnusedOpcode084,
|
||||
|
||||
// Bytecode instructions since bytecode format v7:
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include "vm/bootstrap.h"
|
||||
#include "vm/class_id.h"
|
||||
#include "vm/compiler/backend/code_statistics.h"
|
||||
#include "vm/compiler/frontend/bytecode_reader.h"
|
||||
#include "vm/compiler/relocation.h"
|
||||
#include "vm/dart.h"
|
||||
#include "vm/heap/heap.h"
|
||||
|
@ -1358,14 +1357,6 @@ class KernelProgramInfoDeserializationCluster : public DeserializationCluster {
|
|||
info.set_libraries_cache(array);
|
||||
array = HashTables::New<UnorderedHashMap<SmiTraits>>(16, Heap::kOld);
|
||||
info.set_classes_cache(array);
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
array = info.bytecode_component();
|
||||
if (!array.IsNull()) {
|
||||
kernel::BytecodeReader::UseBytecodeVersion(
|
||||
kernel::BytecodeComponentData(&array).GetVersion());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -160,32 +160,6 @@ static void FormatT(char* buf,
|
|||
Apply(&buf, &size, instr, op1, x, "");
|
||||
}
|
||||
|
||||
static void FormatA_D(char* buf,
|
||||
intptr_t size,
|
||||
KernelBytecode::Opcode opcode,
|
||||
const KBCInstr* instr,
|
||||
Fmt op1,
|
||||
Fmt op2,
|
||||
Fmt op3) {
|
||||
const int32_t a = KernelBytecode::DecodeA(instr);
|
||||
const int32_t bc = KernelBytecode::DecodeD(instr);
|
||||
Apply(&buf, &size, instr, op1, a, ", ");
|
||||
Apply(&buf, &size, instr, op2, bc, "");
|
||||
}
|
||||
|
||||
static void FormatA_X(char* buf,
|
||||
intptr_t size,
|
||||
KernelBytecode::Opcode opcode,
|
||||
const KBCInstr* instr,
|
||||
Fmt op1,
|
||||
Fmt op2,
|
||||
Fmt op3) {
|
||||
const int32_t a = KernelBytecode::DecodeA(instr);
|
||||
const int32_t bc = KernelBytecode::DecodeX(instr);
|
||||
Apply(&buf, &size, instr, op1, a, ", ");
|
||||
Apply(&buf, &size, instr, op2, bc, "");
|
||||
}
|
||||
|
||||
static void FormatA_E(char* buf,
|
||||
intptr_t size,
|
||||
KernelBytecode::Opcode opcode,
|
||||
|
@ -257,21 +231,6 @@ static const BytecodeFormatter kFormatters[] = {
|
|||
|
||||
static intptr_t GetConstantPoolIndex(const KBCInstr* instr) {
|
||||
switch (KernelBytecode::DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kLoadConstant_Old:
|
||||
case KernelBytecode::kInstantiateTypeArgumentsTOS_Old:
|
||||
case KernelBytecode::kAssertAssignable_Old:
|
||||
case KernelBytecode::kPushConstant_Old:
|
||||
case KernelBytecode::kStoreStaticTOS_Old:
|
||||
case KernelBytecode::kPushStatic_Old:
|
||||
case KernelBytecode::kAllocate_Old:
|
||||
case KernelBytecode::kAllocateClosure_Old:
|
||||
case KernelBytecode::kInstantiateType_Old:
|
||||
case KernelBytecode::kDirectCall_Old:
|
||||
case KernelBytecode::kInterfaceCall_Old:
|
||||
case KernelBytecode::kUncheckedInterfaceCall_Old:
|
||||
case KernelBytecode::kDynamicCall_Old:
|
||||
return KernelBytecode::DecodeD(instr);
|
||||
|
||||
case KernelBytecode::kLoadConstant:
|
||||
case KernelBytecode::kLoadConstant_Wide:
|
||||
case KernelBytecode::kInstantiateTypeArgumentsTOS:
|
||||
|
|
|
@ -388,12 +388,10 @@ void BytecodeFlowGraphBuilder::BuildInstruction(KernelBytecode::Opcode opcode) {
|
|||
#define BUILD_BYTECODE_CASE(name, encoding, kind, op1, op2, op3) \
|
||||
BUILD_BYTECODE_CASE_##kind(name, encoding)
|
||||
|
||||
#define BUILD_BYTECODE_CASE_OLD(name, encoding)
|
||||
#define BUILD_BYTECODE_CASE_WIDE(name, encoding)
|
||||
#define BUILD_BYTECODE_CASE_RESV(name, encoding)
|
||||
#define BUILD_BYTECODE_CASE_ORDN(name, encoding) \
|
||||
case KernelBytecode::k##name: \
|
||||
case KernelBytecode::k##name##_Old: \
|
||||
WIDE_CASE_##encoding(name) Build##name(); \
|
||||
break;
|
||||
|
||||
|
@ -410,7 +408,6 @@ void BytecodeFlowGraphBuilder::BuildInstruction(KernelBytecode::Opcode opcode) {
|
|||
#undef WIDE_CASE_D_F
|
||||
#undef WIDE_CASE_A_B_C
|
||||
#undef BUILD_BYTECODE_CASE
|
||||
#undef BUILD_BYTECODE_CASE_OLD
|
||||
#undef BUILD_BYTECODE_CASE_WIDE
|
||||
#undef BUILD_BYTECODE_CASE_RESV
|
||||
#undef BUILD_BYTECODE_CASE_ORDN
|
||||
|
@ -1804,16 +1801,13 @@ JoinEntryInstr* BytecodeFlowGraphBuilder::EnsureControlFlowJoin(
|
|||
bool BytecodeFlowGraphBuilder::RequiresScratchVar(const KBCInstr* instr) {
|
||||
switch (KernelBytecode::DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kEntryOptional:
|
||||
case KernelBytecode::kEntryOptional_Old:
|
||||
return KernelBytecode::DecodeC(instr) > 0;
|
||||
|
||||
case KernelBytecode::kEqualsNull:
|
||||
case KernelBytecode::kEqualsNull_Old:
|
||||
return true;
|
||||
|
||||
case KernelBytecode::kNativeCall:
|
||||
case KernelBytecode::kNativeCall_Wide:
|
||||
case KernelBytecode::kNativeCall_Old:
|
||||
return MethodRecognizer::RecognizeKind(function()) ==
|
||||
MethodRecognizer::kListFactory;
|
||||
|
||||
|
|
|
@ -825,15 +825,8 @@ RawBytecode* BytecodeReaderHelper::ReadBytecode(const ObjectPool& pool) {
|
|||
TIMELINE_DURATION(Thread::Current(), CompilerVerbose,
|
||||
"BytecodeReaderHelper::ReadBytecode");
|
||||
#endif // defined(SUPPORT_TIMELINE)
|
||||
intptr_t size = reader_.ReadUInt();
|
||||
intptr_t offset = reader_.offset();
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
if (bytecode_component_->GetVersion() < 7) {
|
||||
const intptr_t kAlignment = 4;
|
||||
offset = Utils::RoundUp(offset, kAlignment);
|
||||
}
|
||||
const intptr_t size = reader_.ReadUInt();
|
||||
const intptr_t offset = reader_.offset();
|
||||
|
||||
const uint8_t* data = reader_.BufferAt(offset);
|
||||
reader_.set_offset(offset + size);
|
||||
|
@ -859,10 +852,6 @@ void BytecodeReaderHelper::ReadExceptionsTable(const Bytecode& bytecode,
|
|||
ExceptionHandlerList* exception_handlers_list =
|
||||
new (Z) ExceptionHandlerList();
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
const int kPCShifter = (bytecode_component_->GetVersion() < 7) ? 2 : 0;
|
||||
|
||||
// Encoding of ExceptionsTable is described in
|
||||
// pkg/vm/lib/bytecode/exceptions.dart.
|
||||
for (intptr_t try_index = 0; try_index < try_block_count; try_index++) {
|
||||
|
@ -870,13 +859,13 @@ void BytecodeReaderHelper::ReadExceptionsTable(const Bytecode& bytecode,
|
|||
intptr_t outer_try_index = outer_try_index_plus1 - 1;
|
||||
// PcDescriptors are expressed in terms of return addresses.
|
||||
intptr_t start_pc =
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt() << kPCShifter,
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt(),
|
||||
/* is_return_address = */ true);
|
||||
intptr_t end_pc =
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt() << kPCShifter,
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt(),
|
||||
/* is_return_address = */ true);
|
||||
intptr_t handler_pc =
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt() << kPCShifter,
|
||||
KernelBytecode::BytecodePcToOffset(reader_.ReadUInt(),
|
||||
/* is_return_address = */ false);
|
||||
uint8_t flags = reader_.ReadByte();
|
||||
const uint8_t kFlagNeedsStackTrace = 1 << 0;
|
||||
|
@ -1031,7 +1020,6 @@ RawArray* BytecodeReaderHelper::ReadBytecodeComponent(intptr_t md_offset) {
|
|||
version, KernelBytecode::kMinSupportedBytecodeFormatVersion,
|
||||
KernelBytecode::kMaxSupportedBytecodeFormatVersion);
|
||||
}
|
||||
BytecodeReader::UseBytecodeVersion(version);
|
||||
|
||||
reader_.ReadUInt32(); // Skip stringTable.numItems
|
||||
const intptr_t string_table_offset = start_offset + reader_.ReadUInt32();
|
||||
|
@ -3148,28 +3136,6 @@ RawLocalVarDescriptors* BytecodeReader::ComputeLocalVarDescriptors(
|
|||
}
|
||||
#endif // !defined(PRODUCT)
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
void BytecodeReader::UseBytecodeVersion(intptr_t version) {
|
||||
Isolate* isolate = Isolate::Current();
|
||||
bool using_old = isolate->is_using_old_bytecode_instructions();
|
||||
bool using_new = isolate->is_using_new_bytecode_instructions();
|
||||
if (version < 7) {
|
||||
using_old = true;
|
||||
isolate->set_is_using_old_bytecode_instructions(true);
|
||||
} else {
|
||||
using_new = true;
|
||||
isolate->set_is_using_new_bytecode_instructions(true);
|
||||
}
|
||||
|
||||
if (using_old && using_new) {
|
||||
FATAL1(
|
||||
"Unable to use both new and old bytecode instructions in the same Dart "
|
||||
"isolate (%s)",
|
||||
isolate->name());
|
||||
}
|
||||
}
|
||||
|
||||
bool IsStaticFieldGetterGeneratedAsInitializer(const Function& function,
|
||||
Zone* zone) {
|
||||
ASSERT(function.kind() == RawFunction::kImplicitStaticGetter);
|
||||
|
|
|
@ -326,8 +326,6 @@ class BytecodeReader : public AllStatic {
|
|||
const Function& function,
|
||||
const Bytecode& bytecode);
|
||||
#endif
|
||||
|
||||
static void UseBytecodeVersion(intptr_t version);
|
||||
};
|
||||
|
||||
class BytecodeSourcePositionsIterator : ValueObject {
|
||||
|
@ -337,9 +335,6 @@ class BytecodeSourcePositionsIterator : ValueObject {
|
|||
if (bytecode.HasSourcePositions()) {
|
||||
reader_.set_offset(bytecode.source_positions_binary_offset());
|
||||
pairs_remaining_ = reader_.ReadUInt();
|
||||
if (Isolate::Current()->is_using_old_bytecode_instructions()) {
|
||||
pc_shifter_ = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -349,7 +344,7 @@ class BytecodeSourcePositionsIterator : ValueObject {
|
|||
}
|
||||
ASSERT(pairs_remaining_ > 0);
|
||||
--pairs_remaining_;
|
||||
cur_bci_ += reader_.ReadUInt() << pc_shifter_;
|
||||
cur_bci_ += reader_.ReadUInt();
|
||||
cur_token_pos_ += reader_.ReadSLEB128();
|
||||
return true;
|
||||
}
|
||||
|
@ -361,7 +356,6 @@ class BytecodeSourcePositionsIterator : ValueObject {
|
|||
private:
|
||||
Reader reader_;
|
||||
intptr_t pairs_remaining_ = 0;
|
||||
intptr_t pc_shifter_ = 0;
|
||||
intptr_t cur_bci_ = 0;
|
||||
intptr_t cur_token_pos_ = 0;
|
||||
};
|
||||
|
|
|
@ -7,10 +7,6 @@
|
|||
|
||||
namespace dart {
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
static const intptr_t kOldInstructionSize = 4;
|
||||
|
||||
static const intptr_t kInstructionSize0 = 1;
|
||||
static const intptr_t kInstructionSizeA = 2;
|
||||
static const intptr_t kInstructionSizeD = 2;
|
||||
|
@ -28,13 +24,11 @@ static const intptr_t kInstructionSizeWideD_F = 6;
|
|||
static const intptr_t kInstructionSizeA_B_C = 4;
|
||||
|
||||
const intptr_t KernelBytecode::kInstructionSize[] = {
|
||||
#define SIZE_OLD(encoding) kOldInstructionSize
|
||||
#define SIZE_ORDN(encoding) kInstructionSize##encoding
|
||||
#define SIZE_WIDE(encoding) kInstructionSizeWide##encoding
|
||||
#define SIZE_RESV(encoding) SIZE_ORDN(encoding)
|
||||
#define SIZE(name, encoding, kind, op1, op2, op3) SIZE_##kind(encoding),
|
||||
KERNEL_BYTECODES_LIST(SIZE)
|
||||
#undef SIZE_OLD
|
||||
#undef SIZE_ORDN
|
||||
#undef SIZE_WIDE
|
||||
#undef SIZE_RESV
|
||||
|
|
|
@ -453,9 +453,9 @@ namespace dart {
|
|||
// V(BytecodeName, OperandForm, BytecodeKind, Op1, Op2, Op3)
|
||||
//
|
||||
// - OperandForm specifies operand encoding and should be one of 0, A, D, X, T,
|
||||
// A_D (old), A_X (old), A_E, A_Y, D_F or A_B_C (see ENCODING section above).
|
||||
// A_E, A_Y, D_F or A_B_C (see ENCODING section above).
|
||||
//
|
||||
// - BytecodeKind is one of OLD, WIDE, RESV (reserved), ORDN (ordinary)
|
||||
// - BytecodeKind is one of WIDE, RESV (reserved), ORDN (ordinary)
|
||||
//
|
||||
// - Op1, Op2, Op3 specify operand meaning. Possible values:
|
||||
//
|
||||
|
@ -471,91 +471,91 @@ namespace dart {
|
|||
// and before decoding.
|
||||
//
|
||||
#define PUBLIC_KERNEL_BYTECODES_LIST(V) \
|
||||
V(Trap_Old, 0, OLD, ___, ___, ___) \
|
||||
V(Entry_Old, D, OLD, num, ___, ___) \
|
||||
V(EntryFixed_Old, A_D, OLD, num, num, ___) \
|
||||
V(EntryOptional_Old, A_B_C, OLD, num, num, num) \
|
||||
V(LoadConstant_Old, A_D, OLD, reg, lit, ___) \
|
||||
V(Frame_Old, D, OLD, num, ___, ___) \
|
||||
V(CheckFunctionTypeArgs_Old, A_D, OLD, num, reg, ___) \
|
||||
V(CheckStack_Old, A, OLD, num, ___, ___) \
|
||||
V(Allocate_Old, D, OLD, lit, ___, ___) \
|
||||
V(AllocateT_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CreateArrayTOS_Old, 0, OLD, ___, ___, ___) \
|
||||
V(AllocateContext_Old, D, OLD, num, ___, ___) \
|
||||
V(CloneContext_Old, D, OLD, num, ___, ___) \
|
||||
V(LoadContextParent_Old, 0, OLD, ___, ___, ___) \
|
||||
V(StoreContextParent_Old, 0, OLD, ___, ___, ___) \
|
||||
V(LoadContextVar_Old, D, OLD, num, ___, ___) \
|
||||
V(StoreContextVar_Old, D, OLD, num, ___, ___) \
|
||||
V(PushConstant_Old, D, OLD, lit, ___, ___) \
|
||||
V(PushNull_Old, 0, OLD, ___, ___, ___) \
|
||||
V(PushTrue_Old, 0, OLD, ___, ___, ___) \
|
||||
V(PushFalse_Old, 0, OLD, ___, ___, ___) \
|
||||
V(PushInt_Old, X, OLD, num, ___, ___) \
|
||||
V(Drop1_Old, 0, OLD, ___, ___, ___) \
|
||||
V(Push_Old, X, OLD, xeg, ___, ___) \
|
||||
V(PopLocal_Old, X, OLD, xeg, ___, ___) \
|
||||
V(StoreLocal_Old, X, OLD, xeg, ___, ___) \
|
||||
V(LoadFieldTOS_Old, D, OLD, lit, ___, ___) \
|
||||
V(StoreFieldTOS_Old, D, OLD, lit, ___, ___) \
|
||||
V(StoreIndexedTOS_Old, 0, OLD, ___, ___, ___) \
|
||||
V(PushStatic_Old, D, OLD, lit, ___, ___) \
|
||||
V(StoreStaticTOS_Old, D, OLD, lit, ___, ___) \
|
||||
V(Jump_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfNoAsserts_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfNotZeroTypeArgs_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfEqStrict_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfNeStrict_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfTrue_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfFalse_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfNull_Old, T, OLD, tgt, ___, ___) \
|
||||
V(JumpIfNotNull_Old, T, OLD, tgt, ___, ___) \
|
||||
V(Unused00_Old, 0, RESV, num, num, ___) \
|
||||
V(InterfaceCall_Old, A_D, OLD, num, num, ___) \
|
||||
V(DynamicCall_Old, A_D, OLD, num, num, ___) \
|
||||
V(NativeCall_Old, D, OLD, lit, ___, ___) \
|
||||
V(ReturnTOS_Old, 0, OLD, ___, ___, ___) \
|
||||
V(AssertAssignable_Old, A_D, OLD, num, lit, ___) \
|
||||
V(AssertBoolean_Old, A, OLD, num, ___, ___) \
|
||||
V(AssertSubtype_Old, 0, OLD, ___, ___, ___) \
|
||||
V(LoadTypeArgumentsField_Old, D, OLD, lit, ___, ___) \
|
||||
V(InstantiateType_Old, D, OLD, lit, ___, ___) \
|
||||
V(InstantiateTypeArgumentsTOS_Old, A_D, OLD, num, lit, ___) \
|
||||
V(Throw_Old, A, OLD, num, ___, ___) \
|
||||
V(MoveSpecial_Old, A_X, OLD, num, xeg, ___) \
|
||||
V(SetFrame_Old, A, OLD, num, ___, num) \
|
||||
V(BooleanNegateTOS_Old, 0, OLD, ___, ___, ___) \
|
||||
V(EqualsNull_Old, 0, OLD, ___, ___, ___) \
|
||||
V(NegateInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(AddInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(SubInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(MulInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(TruncDivInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(ModInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(BitAndInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(BitOrInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(BitXorInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(ShlInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(ShrInt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareIntEq_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareIntGt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareIntLt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareIntGe_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareIntLe_Old, 0, OLD, ___, ___, ___) \
|
||||
V(DirectCall_Old, A_D, OLD, num, num, ___) \
|
||||
V(AllocateClosure_Old, D, OLD, lit, ___, ___) \
|
||||
V(UncheckedInterfaceCall_Old, A_D, OLD, num, num, ___) \
|
||||
V(NegateDouble_Old, 0, OLD, ___, ___, ___) \
|
||||
V(AddDouble_Old, 0, OLD, ___, ___, ___) \
|
||||
V(SubDouble_Old, 0, OLD, ___, ___, ___) \
|
||||
V(MulDouble_Old, 0, OLD, ___, ___, ___) \
|
||||
V(DivDouble_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareDoubleEq_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareDoubleGt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareDoubleLt_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareDoubleGe_Old, 0, OLD, ___, ___, ___) \
|
||||
V(CompareDoubleLe_Old, 0, OLD, ___, ___, ___) \
|
||||
V(UnusedOpcode000, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode001, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode002, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode003, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode004, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode005, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode006, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode007, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode008, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode009, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode010, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode011, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode012, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode013, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode014, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode015, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode016, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode017, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode018, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode019, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode020, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode021, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode022, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode023, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode024, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode025, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode026, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode027, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode028, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode029, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode030, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode031, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode032, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode033, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode034, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode035, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode036, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode037, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode038, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode039, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode040, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode041, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode042, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode043, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode044, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode045, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode046, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode047, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode048, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode049, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode050, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode051, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode052, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode053, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode054, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode055, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode056, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode057, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode058, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode059, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode060, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode061, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode062, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode063, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode064, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode065, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode066, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode067, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode068, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode069, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode070, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode071, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode072, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode073, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode074, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode075, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode076, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode077, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode078, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode079, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode080, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode081, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode082, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode083, 0, RESV, ___, ___, ___) \
|
||||
V(UnusedOpcode084, 0, RESV, ___, ___, ___) \
|
||||
V(Trap, 0, ORDN, ___, ___, ___) \
|
||||
V(Entry, D, ORDN, num, ___, ___) \
|
||||
V(Entry_Wide, D, WIDE, num, ___, ___) \
|
||||
|
@ -745,7 +745,7 @@ class KernelBytecode {
|
|||
// Magic value of bytecode files.
|
||||
static const intptr_t kMagicValue = 0x44424332; // 'DBC2'
|
||||
// Minimum bytecode format version supported by VM.
|
||||
static const intptr_t kMinSupportedBytecodeFormatVersion = 3;
|
||||
static const intptr_t kMinSupportedBytecodeFormatVersion = 7;
|
||||
// Maximum bytecode format version supported by VM.
|
||||
// The range of supported versions should include version produced by bytecode
|
||||
// generator (currentBytecodeFormatVersion in pkg/vm/lib/bytecode/dbc.dart).
|
||||
|
@ -777,12 +777,6 @@ class KernelBytecode {
|
|||
private:
|
||||
static const intptr_t kWideModifier = 1;
|
||||
|
||||
static_assert(kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
DART_FORCE_INLINE static bool IsOld(const KBCInstr* instr) {
|
||||
return DecodeOpcode(instr) < kTrap;
|
||||
}
|
||||
|
||||
// Should be used only on instructions with wide variants.
|
||||
DART_FORCE_INLINE static bool IsWide(const KBCInstr* instr) {
|
||||
return ((DecodeOpcode(instr) & kWideModifier) != 0);
|
||||
|
@ -796,9 +790,7 @@ class KernelBytecode {
|
|||
DART_FORCE_INLINE static uint8_t DecodeC(const KBCInstr* bc) { return bc[3]; }
|
||||
|
||||
DART_FORCE_INLINE static uint32_t DecodeD(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return static_cast<uint16_t>(bc[2]) | (static_cast<uint16_t>(bc[3]) << 8);
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return static_cast<uint32_t>(bc[1]) |
|
||||
(static_cast<uint32_t>(bc[2]) << 8) |
|
||||
(static_cast<uint32_t>(bc[3]) << 16) |
|
||||
|
@ -809,10 +801,7 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static int32_t DecodeX(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return static_cast<int16_t>(static_cast<uint16_t>(bc[2]) |
|
||||
(static_cast<uint16_t>(bc[3]) << 8));
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return static_cast<int32_t>(static_cast<uint32_t>(bc[1]) |
|
||||
(static_cast<uint32_t>(bc[2]) << 8) |
|
||||
(static_cast<uint32_t>(bc[3]) << 16) |
|
||||
|
@ -823,12 +812,7 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static int32_t DecodeT(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return static_cast<int32_t>((static_cast<uint32_t>(bc[1]) << 8) |
|
||||
(static_cast<uint32_t>(bc[2]) << 16) |
|
||||
(static_cast<uint32_t>(bc[3]) << 24)) >>
|
||||
(8 - 2);
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return static_cast<int32_t>((static_cast<uint32_t>(bc[1]) << 8) |
|
||||
(static_cast<uint32_t>(bc[2]) << 16) |
|
||||
(static_cast<uint32_t>(bc[3]) << 24)) >>
|
||||
|
@ -839,9 +823,7 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static uint32_t DecodeE(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return static_cast<uint16_t>(bc[2]) | (static_cast<uint16_t>(bc[3]) << 8);
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return static_cast<uint32_t>(bc[2]) |
|
||||
(static_cast<uint32_t>(bc[3]) << 8) |
|
||||
(static_cast<uint32_t>(bc[4]) << 16) |
|
||||
|
@ -852,10 +834,7 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static int32_t DecodeY(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return static_cast<int16_t>(static_cast<uint16_t>(bc[2]) |
|
||||
(static_cast<uint16_t>(bc[3]) << 8));
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return static_cast<int32_t>(static_cast<uint32_t>(bc[2]) |
|
||||
(static_cast<uint32_t>(bc[3]) << 8) |
|
||||
(static_cast<uint32_t>(bc[4]) << 16) |
|
||||
|
@ -866,9 +845,7 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static uint8_t DecodeF(const KBCInstr* bc) {
|
||||
if (IsOld(bc)) {
|
||||
return bc[1];
|
||||
} else if (IsWide(bc)) {
|
||||
if (IsWide(bc)) {
|
||||
return bc[5];
|
||||
} else {
|
||||
return bc[2];
|
||||
|
@ -885,15 +862,6 @@ class KernelBytecode {
|
|||
|
||||
DART_FORCE_INLINE static bool IsJumpOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kJump_Old:
|
||||
case KernelBytecode::kJumpIfNoAsserts_Old:
|
||||
case KernelBytecode::kJumpIfNotZeroTypeArgs_Old:
|
||||
case KernelBytecode::kJumpIfEqStrict_Old:
|
||||
case KernelBytecode::kJumpIfNeStrict_Old:
|
||||
case KernelBytecode::kJumpIfTrue_Old:
|
||||
case KernelBytecode::kJumpIfFalse_Old:
|
||||
case KernelBytecode::kJumpIfNull_Old:
|
||||
case KernelBytecode::kJumpIfNotNull_Old:
|
||||
case KernelBytecode::kJump:
|
||||
case KernelBytecode::kJump_Wide:
|
||||
case KernelBytecode::kJumpIfNoAsserts:
|
||||
|
@ -923,7 +891,6 @@ class KernelBytecode {
|
|||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kLoadConstant:
|
||||
case KernelBytecode::kLoadConstant_Wide:
|
||||
case KernelBytecode::kLoadConstant_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -931,30 +898,17 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsCheckStackOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kCheckStack:
|
||||
case KernelBytecode::kCheckStack_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return DecodeOpcode(instr) == KernelBytecode::kCheckStack;
|
||||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsEntryOptionalOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kEntryOptional:
|
||||
case KernelBytecode::kEntryOptional_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return DecodeOpcode(instr) == KernelBytecode::kEntryOptional;
|
||||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsFrameOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kFrame:
|
||||
case KernelBytecode::kFrame_Wide:
|
||||
case KernelBytecode::kFrame_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -962,33 +916,13 @@ class KernelBytecode {
|
|||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsSetFrameOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kSetFrame:
|
||||
case KernelBytecode::kSetFrame_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsCallOpcode_Old(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kDirectCall_Old:
|
||||
case KernelBytecode::kInterfaceCall_Old:
|
||||
case KernelBytecode::kUncheckedInterfaceCall_Old:
|
||||
case KernelBytecode::kDynamicCall_Old:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return DecodeOpcode(instr) == KernelBytecode::kSetFrame;
|
||||
}
|
||||
|
||||
DART_FORCE_INLINE static bool IsNativeCallOpcode(const KBCInstr* instr) {
|
||||
switch (DecodeOpcode(instr)) {
|
||||
case KernelBytecode::kNativeCall:
|
||||
case KernelBytecode::kNativeCall_Wide:
|
||||
case KernelBytecode::kNativeCall_Old:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
|
@ -1026,19 +960,6 @@ class KernelBytecode {
|
|||
|
||||
static const uint8_t kNativeCallToGrowableListArgc = 2;
|
||||
|
||||
DART_FORCE_INLINE static uint8_t DecodeArgc_Old(const KBCInstr* ret_addr) {
|
||||
const intptr_t kOldInstructionSize = 4;
|
||||
const KBCInstr* call = ret_addr - kOldInstructionSize;
|
||||
ASSERT(IsOld(call));
|
||||
if (DecodeOpcode(call) == KernelBytecode::kNativeCall_Old) {
|
||||
// The only NativeCall redirecting to a bytecode function is the call
|
||||
// to new _GrowableList<E>(0).
|
||||
return kNativeCallToGrowableListArgc;
|
||||
}
|
||||
ASSERT(IsCallOpcode_Old(call));
|
||||
return DecodeA(call);
|
||||
}
|
||||
|
||||
// Returns a fake return address which points after the 2-argument
|
||||
// bytecode call, followed by ReturnTOS instructions.
|
||||
static const KBCInstr* GetNativeCallToGrowableListReturnTrampoline();
|
||||
|
|
|
@ -910,20 +910,11 @@ DART_FORCE_INLINE bool Interpreter::InstanceCall2(Thread* thread,
|
|||
|
||||
#define BYTECODE_ENTRY_LABEL(Name) bc##Name:
|
||||
#define BYTECODE_WIDE_ENTRY_LABEL(Name) bc##Name##_Wide:
|
||||
#define BYTECODE_OLD_ENTRY_LABEL(Name) bc##Name##_Old:
|
||||
#define BYTECODE_IMPL_LABEL(Name) bc##Name##Impl:
|
||||
#define GOTO_BYTECODE_IMPL(Name) goto bc##Name##Impl;
|
||||
|
||||
// Define entry point that handles bytecode Name with the given operand format.
|
||||
#define BYTECODE(Name, Operands) BYTECODE_HEADER_##Operands##_WITH_OLD(Name)
|
||||
|
||||
// TODO(alexmarkov): switch BYTECODE macro to BYTECODE_NEW implementation
|
||||
// and replace BYTECODE_NEW with BYTECODE when old instructions are gone.
|
||||
// Cleanup BYTECODE_HEADER_*_WITH_OLD macros and drop _WITH_OLD.
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
|
||||
#define BYTECODE_NEW(Name, Operands) BYTECODE_HEADER_##Operands(Name)
|
||||
#define BYTECODE(Name, Operands) BYTECODE_HEADER_##Operands(Name)
|
||||
|
||||
// Helpers to decode common instruction formats. Used in conjunction with
|
||||
// BYTECODE() macro.
|
||||
|
@ -932,32 +923,16 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
BYTECODE_ENTRY_LABEL(Name) \
|
||||
pc += 1;
|
||||
|
||||
#define BYTECODE_HEADER_0_WITH_OLD(Name) \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_HEADER_0(Name) \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_A_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_A(Name) \
|
||||
uint32_t rA; \
|
||||
USE(rA); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
pc += 2; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
pc += 2;
|
||||
|
||||
#define BYTECODE_HEADER_D_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_D(Name) \
|
||||
uint32_t rD; \
|
||||
USE(rD); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rD = static_cast<uint32_t>(pc[2]) | (static_cast<uint32_t>(pc[3]) << 8); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rD = static_cast<uint32_t>(pc[1]) | (static_cast<uint32_t>(pc[2]) << 8) | \
|
||||
(static_cast<uint32_t>(pc[3]) << 16) | \
|
||||
|
@ -969,14 +944,9 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 2; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_X_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_X(Name) \
|
||||
int32_t rX; \
|
||||
USE(rX); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rX = static_cast<int16_t>(static_cast<uint16_t>(pc[2]) | \
|
||||
(static_cast<uint16_t>(pc[3]) << 8)); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rX = static_cast<int32_t>(static_cast<uint32_t>(pc[1]) | \
|
||||
(static_cast<uint32_t>(pc[2]) << 8) | \
|
||||
|
@ -989,16 +959,9 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 2; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_T_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_T(Name) \
|
||||
const KBCInstr* rT; \
|
||||
USE(rT); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rT = pc + (static_cast<int32_t>((static_cast<uint32_t>(pc[1]) << 8) | \
|
||||
(static_cast<uint32_t>(pc[2]) << 16) | \
|
||||
(static_cast<uint32_t>(pc[3]) << 24)) >> \
|
||||
(8 - 2)); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rT = pc + (static_cast<int32_t>((static_cast<uint32_t>(pc[1]) << 8) | \
|
||||
(static_cast<uint32_t>(pc[2]) << 16) | \
|
||||
|
@ -1011,15 +974,10 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 2; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_A_E_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_A_E(Name) \
|
||||
uint32_t rA, rE; \
|
||||
USE(rA); \
|
||||
USE(rE); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
rE = static_cast<uint32_t>(pc[2]) | (static_cast<uint32_t>(pc[3]) << 8); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
rE = static_cast<uint32_t>(pc[2]) | (static_cast<uint32_t>(pc[3]) << 8) | \
|
||||
|
@ -1033,17 +991,11 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 3; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_A_Y_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_A_Y(Name) \
|
||||
uint32_t rA; \
|
||||
int32_t rY; \
|
||||
USE(rA); \
|
||||
USE(rY); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
rY = static_cast<int16_t>(static_cast<uint16_t>(pc[2]) | \
|
||||
(static_cast<uint16_t>(pc[3]) << 8)); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
rY = static_cast<int32_t>(static_cast<uint32_t>(pc[2]) | \
|
||||
|
@ -1058,15 +1010,10 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 3; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_D_F_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_D_F(Name) \
|
||||
uint32_t rD, rF; \
|
||||
USE(rD); \
|
||||
USE(rF); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
rF = pc[1]; \
|
||||
rD = static_cast<uint32_t>(pc[2]) | (static_cast<uint32_t>(pc[3]) << 8); \
|
||||
pc += 4; \
|
||||
GOTO_BYTECODE_IMPL(Name); \
|
||||
BYTECODE_WIDE_ENTRY_LABEL(Name) \
|
||||
rD = static_cast<uint32_t>(pc[1]) | (static_cast<uint32_t>(pc[2]) << 8) | \
|
||||
(static_cast<uint32_t>(pc[3]) << 16) | \
|
||||
|
@ -1080,12 +1027,11 @@ static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
|||
pc += 3; \
|
||||
BYTECODE_IMPL_LABEL(Name)
|
||||
|
||||
#define BYTECODE_HEADER_A_B_C_WITH_OLD(Name) \
|
||||
#define BYTECODE_HEADER_A_B_C(Name) \
|
||||
uint32_t rA, rB, rC; \
|
||||
USE(rA); \
|
||||
USE(rB); \
|
||||
USE(rC); \
|
||||
BYTECODE_OLD_ENTRY_LABEL(Name) \
|
||||
BYTECODE_ENTRY_LABEL(Name) \
|
||||
rA = pc[1]; \
|
||||
rB = pc[2]; \
|
||||
|
@ -2161,12 +2107,10 @@ SwitchDispatch:
|
|||
// Change the ArgumentsDescriptor of the call with a new cached one.
|
||||
argdesc_ = ArgumentsDescriptor::New(
|
||||
0, KernelBytecode::kNativeCallToGrowableListArgc);
|
||||
if (!thread->isolate()->is_using_old_bytecode_instructions()) {
|
||||
// Replace PC to the return trampoline so ReturnTOS would see
|
||||
// a call bytecode at return address and will be able to get argc
|
||||
// via DecodeArgc.
|
||||
pc = KernelBytecode::GetNativeCallToGrowableListReturnTrampoline();
|
||||
}
|
||||
// Replace PC to the return trampoline so ReturnTOS would see
|
||||
// a call bytecode at return address and will be able to get argc
|
||||
// via DecodeArgc.
|
||||
pc = KernelBytecode::GetNativeCallToGrowableListReturnTrampoline();
|
||||
if (!Invoke(thread, SP - 1, SP + 1, &pc, &FP, &SP)) {
|
||||
HANDLE_EXCEPTION;
|
||||
}
|
||||
|
@ -2317,9 +2261,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
// Look at the caller to determine how many arguments to pop.
|
||||
const uint8_t argc = thread->isolate()->is_using_old_bytecode_instructions()
|
||||
? KernelBytecode::DecodeArgc_Old(pc)
|
||||
: KernelBytecode::DecodeArgc(pc);
|
||||
const uint8_t argc = KernelBytecode::DecodeArgc(pc);
|
||||
|
||||
// Restore SP, FP and PP. Push result and dispatch.
|
||||
SP = FrameArguments(FP, argc);
|
||||
|
@ -3070,51 +3012,27 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE(Trap, 0);
|
||||
BYTECODE(Unused00, 0);
|
||||
BYTECODE_NEW(Unused01, 0);
|
||||
BYTECODE_NEW(Unused02, 0);
|
||||
BYTECODE_NEW(Unused03, 0);
|
||||
BYTECODE_NEW(Unused04, 0);
|
||||
BYTECODE_NEW(Unused05, 0);
|
||||
BYTECODE_NEW(Unused06, 0);
|
||||
BYTECODE_NEW(Unused07, 0);
|
||||
BYTECODE_NEW(Unused08, 0);
|
||||
BYTECODE_NEW(Unused09, 0);
|
||||
BYTECODE_NEW(Unused10, 0);
|
||||
BYTECODE_NEW(Unused11, 0);
|
||||
BYTECODE_NEW(Unused12, 0);
|
||||
BYTECODE_NEW(Unused13, 0);
|
||||
BYTECODE_NEW(Unused14, 0);
|
||||
BYTECODE_NEW(Unused15, 0);
|
||||
BYTECODE_NEW(Unused16, 0);
|
||||
BYTECODE_NEW(Unused17, 0);
|
||||
BYTECODE_NEW(Unused18, 0);
|
||||
BYTECODE_NEW(Unused19, 0);
|
||||
BYTECODE_NEW(Unused20, 0);
|
||||
BYTECODE_NEW(Unused21, 0);
|
||||
BYTECODE_NEW(Unused22, 0);
|
||||
BYTECODE_NEW(Unused23, 0);
|
||||
BYTECODE_NEW(Unused24, 0);
|
||||
BYTECODE_NEW(Unused25, 0);
|
||||
BYTECODE_NEW(Unused26, 0);
|
||||
BYTECODE_NEW(Unused27, 0);
|
||||
BYTECODE_NEW(Unused28, 0);
|
||||
BYTECODE_NEW(Unused29, 0);
|
||||
BYTECODE_NEW(Unused30, 0);
|
||||
BYTECODE_NEW(Unused31, 0);
|
||||
BYTECODE_NEW(Unused32, 0);
|
||||
BYTECODE_NEW(Unused33, 0);
|
||||
BYTECODE_NEW(Unused34, 0);
|
||||
BYTECODE_NEW(Unused35, 0);
|
||||
BYTECODE_NEW(Unused36, 0);
|
||||
BYTECODE_NEW(Unused37, 0);
|
||||
BYTECODE_ENTRY_LABEL(Trap);
|
||||
|
||||
#define UNIMPLEMENTED_LABEL_ORDN(Name)
|
||||
#define UNIMPLEMENTED_LABEL_WIDE(Name)
|
||||
#define UNIMPLEMENTED_LABEL_RESV(Name) BYTECODE_ENTRY_LABEL(Name)
|
||||
#define UNIMPLEMENTED_LABEL(name, encoding, kind, op1, op2, op3) \
|
||||
UNIMPLEMENTED_LABEL_##kind(name)
|
||||
|
||||
KERNEL_BYTECODES_LIST(UNIMPLEMENTED_LABEL)
|
||||
|
||||
#undef UNIMPLEMENTED_LABEL_ORDN
|
||||
#undef UNIMPLEMENTED_LABEL_WIDE
|
||||
#undef UNIMPLEMENTED_LABEL_RESV
|
||||
#undef UNIMPLEMENTED_LABEL
|
||||
|
||||
UNIMPLEMENTED();
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ImplicitGetter, 0);
|
||||
BYTECODE(VMInternal_ImplicitGetter, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kImplicitGetter);
|
||||
|
@ -3163,7 +3081,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ImplicitSetter, 0);
|
||||
BYTECODE(VMInternal_ImplicitSetter, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kImplicitSetter);
|
||||
|
@ -3284,7 +3202,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ImplicitStaticGetter, 0);
|
||||
BYTECODE(VMInternal_ImplicitStaticGetter, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kImplicitStaticGetter);
|
||||
|
@ -3316,7 +3234,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_MethodExtractor, 0);
|
||||
BYTECODE(VMInternal_MethodExtractor, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kMethodExtractor);
|
||||
|
@ -3356,7 +3274,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_InvokeClosure, 0);
|
||||
BYTECODE(VMInternal_InvokeClosure, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kInvokeFieldDispatcher);
|
||||
|
@ -3378,7 +3296,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_InvokeField, 0);
|
||||
BYTECODE(VMInternal_InvokeField, 0);
|
||||
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kInvokeFieldDispatcher);
|
||||
|
@ -3482,7 +3400,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ForwardDynamicInvocation, 0);
|
||||
BYTECODE(VMInternal_ForwardDynamicInvocation, 0);
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) ==
|
||||
RawFunction::kDynamicInvocationForwarder);
|
||||
|
@ -3584,14 +3502,14 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_NoSuchMethodDispatcher, 0);
|
||||
BYTECODE(VMInternal_NoSuchMethodDispatcher, 0);
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kNoSuchMethodDispatcher);
|
||||
goto NoSuchMethodFromPrologue;
|
||||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ImplicitStaticClosure, 0);
|
||||
BYTECODE(VMInternal_ImplicitStaticClosure, 0);
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kImplicitClosureFunction);
|
||||
UNIMPLEMENTED();
|
||||
|
@ -3599,7 +3517,7 @@ SwitchDispatch:
|
|||
}
|
||||
|
||||
{
|
||||
BYTECODE_NEW(VMInternal_ImplicitInstanceClosure, 0);
|
||||
BYTECODE(VMInternal_ImplicitInstanceClosure, 0);
|
||||
RawFunction* function = FrameFunction(FP);
|
||||
ASSERT(Function::kind(function) == RawFunction::kImplicitClosureFunction);
|
||||
UNIMPLEMENTED();
|
||||
|
|
|
@ -781,23 +781,6 @@ class Isolate : public BaseIsolate {
|
|||
return !unsafe_trust_strong_mode_types();
|
||||
}
|
||||
|
||||
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup support for old bytecode format versions");
|
||||
bool is_using_old_bytecode_instructions() const {
|
||||
return UsingOldBytecodeInstructionsBit::decode(isolate_flags_);
|
||||
}
|
||||
void set_is_using_old_bytecode_instructions(bool value) {
|
||||
isolate_flags_ =
|
||||
UsingOldBytecodeInstructionsBit::update(value, isolate_flags_);
|
||||
}
|
||||
bool is_using_new_bytecode_instructions() const {
|
||||
return UsingNewBytecodeInstructionsBit::decode(isolate_flags_);
|
||||
}
|
||||
void set_is_using_new_bytecode_instructions(bool value) {
|
||||
isolate_flags_ =
|
||||
UsingNewBytecodeInstructionsBit::update(value, isolate_flags_);
|
||||
}
|
||||
|
||||
bool has_attempted_stepping() const {
|
||||
return HasAttemptedSteppingBit::decode(isolate_flags_);
|
||||
}
|
||||
|
@ -930,13 +913,7 @@ class Isolate : public BaseIsolate {
|
|||
V(Obfuscate) \
|
||||
V(CompactionInProgress) \
|
||||
V(ShouldLoadVmService) \
|
||||
V(UnsafeTrustStrongModeTypes) \
|
||||
V(UsingOldBytecodeInstructions) \
|
||||
V(UsingNewBytecodeInstructions)
|
||||
|
||||
static_assert(
|
||||
KernelBytecode::kMinSupportedBytecodeFormatVersion < 7,
|
||||
"Cleanup UsingOldBytecodeInstructions and UsingNewBytecodeInstructions");
|
||||
V(UnsafeTrustStrongModeTypes)
|
||||
|
||||
// Isolate specific flags.
|
||||
enum FlagBits {
|
||||
|
|
Loading…
Reference in a new issue