[vm/bytecode] Cleanup support for bytecode format before v20

Bytecode format v20 was introduced Sep 06 2019 in
https://dart-review.googlesource.com/c/sdk/+/116120.
This change drops support for older bytecode format versions from VM.

Change-Id: I11b75ba16e6b7570e0346f9ac024265b08c0c801
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/123920
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:
Alexander Markov 2019-11-01 20:36:32 +00:00 committed by commit-bot@chromium.org
parent d96cd87896
commit ed1910006c
5 changed files with 13 additions and 92 deletions

View file

@ -249,8 +249,6 @@ static intptr_t GetConstantPoolIndex(const KBCInstr* instr) {
case KernelBytecode::kStoreStaticTOS_Wide:
case KernelBytecode::kLoadStatic:
case KernelBytecode::kLoadStatic_Wide:
case KernelBytecode::kPushStatic:
case KernelBytecode::kPushStatic_Wide:
case KernelBytecode::kAllocate:
case KernelBytecode::kAllocate_Wide:
case KernelBytecode::kAllocateClosure:

View file

@ -1065,13 +1065,9 @@ void BytecodeFlowGraphBuilder::BuildDynamicCall() {
// A DebugStepCheck is performed as part of the calling stub.
const UnlinkedCall& selector =
UnlinkedCall::Cast(ConstantAt(DecodeOperandD()).value());
const String& name = String::Cast(ConstantAt(DecodeOperandD()).value());
const ArgumentsDescriptor arg_desc(
Array::Handle(Z, selector.args_descriptor()));
const String& name = String::ZoneHandle(Z, selector.target_name());
Array::Cast(ConstantAt(DecodeOperandD(), 1).value()));
Token::Kind token_kind;
intptr_t checked_argument_count;
@ -1334,18 +1330,6 @@ void BytecodeFlowGraphBuilder::BuildLoadStatic() {
code_ += B->LoadStaticField();
}
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 19,
"Cleanup PushStatic bytecode instruction");
void BytecodeFlowGraphBuilder::BuildPushStatic() {
// Note: Field object is both pushed into the stack and
// available in constant pool entry D.
// TODO(alexmarkov): clean this up. If we stop pushing field object
// explicitly, we might need the following code to get it from constant
// pool: PushConstant(ConstantAt(DecodeOperandD()));
code_ += B->LoadStaticField();
}
void BytecodeFlowGraphBuilder::BuildStoreIndexedTOS() {
LoadStackSlots(3);
code_ += B->StoreIndexed(kArrayCid);

View file

@ -697,7 +697,7 @@ intptr_t BytecodeReaderHelper::ReadConstantPool(const Function& function,
kUnused4,
kUnused5,
kUnused6,
kICData, // Obsolete in bytecode v20.
kUnused6a,
kUnused7,
kStaticField,
kInstanceField,
@ -725,18 +725,8 @@ intptr_t BytecodeReaderHelper::ReadConstantPool(const Function& function,
kDirectCallViaDynamicForwarder,
};
enum InvocationKind {
method, // x.foo(...) or foo(...)
getter, // x.foo
setter // x.foo = ...
};
const int kInvocationKindMask = 0x3;
const int kFlagDynamic = 1 << 2;
Object& obj = Object::Handle(Z);
Object& elem = Object::Handle(Z);
Array& array = Array::Handle(Z);
Field& field = Field::Handle(Z);
Class& cls = Class::Handle(Z);
String& name = String::Handle(Z);
@ -746,33 +736,6 @@ intptr_t BytecodeReaderHelper::ReadConstantPool(const Function& function,
switch (tag) {
case ConstantPoolTag::kInvalid:
UNREACHABLE();
case ConstantPoolTag::kICData: {
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 20,
"Cleanup ICData constant pool entry");
intptr_t flags = reader_.ReadByte();
InvocationKind kind =
static_cast<InvocationKind>(flags & kInvocationKindMask);
bool isDynamic = (flags & kFlagDynamic) != 0;
name ^= ReadObject();
ASSERT(name.IsSymbol());
intptr_t arg_desc_index = reader_.ReadUInt();
ASSERT(arg_desc_index < i);
array ^= pool.ObjectAt(arg_desc_index);
// Do not mangle == or call:
// * operator == takes an Object so its either not checked or checked
// at the entry because the parameter is marked covariant, neither
// of those cases require a dynamic invocation forwarder;
// * we assume that all closures are entered in a checked way.
if (isDynamic && (kind != InvocationKind::getter) &&
I->should_emit_strong_mode_checks() &&
(name.raw() != Symbols::EqualOperator().raw()) &&
(name.raw() != Symbols::Call().raw())) {
name = Function::CreateDynamicInvocationForwarderName(name);
}
obj = UnlinkedCall::New();
UnlinkedCall::Cast(obj).set_target_name(name);
UnlinkedCall::Cast(obj).set_args_descriptor(array);
} break;
case ConstantPoolTag::kStaticField:
obj = ReadObject();
ASSERT(obj.IsField());
@ -896,7 +859,6 @@ intptr_t BytecodeReaderHelper::ReadConstantPool(const Function& function,
case ConstantPoolTag::kDynamicCall: {
name ^= ReadObject();
ASSERT(name.IsSymbol());
array ^= ReadObject();
// Do not mangle == or call:
// * operator == takes an Object so it is either not checked or
// checked at the entry because the parameter is marked covariant,
@ -907,21 +869,15 @@ intptr_t BytecodeReaderHelper::ReadConstantPool(const Function& function,
(name.raw() != Symbols::Call().raw())) {
name = Function::CreateDynamicInvocationForwarderName(name);
}
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 20,
"Can use 2 slots in object pool");
// DynamicCall constant occupies 2 entries: selector and arguments
// descriptor. For backwards compatibility with ICData constants
// selector and arguments descriptor are packaged into UnlinkedCall
// object. The 2nd slot is filled with null.
obj = UnlinkedCall::New();
UnlinkedCall::Cast(obj).set_target_name(name);
UnlinkedCall::Cast(obj).set_args_descriptor(array);
// descriptor.
pool.SetTypeAt(i, ObjectPool::EntryType::kTaggedObject,
ObjectPool::Patchability::kNotPatchable);
pool.SetObjectAt(i, obj);
pool.SetObjectAt(i, name);
++i;
ASSERT(i < obj_count);
obj = Object::null();
// The second entry is used for arguments descriptor.
obj = ReadObject();
} break;
case ConstantPoolTag::kDirectCallViaDynamicForwarder: {
// DirectCallViaDynamicForwarder constant occupies 2 entries.
@ -2091,13 +2047,7 @@ void BytecodeReaderHelper::ReadFieldDeclarations(const Class& cls,
}
}
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 14,
"Cleanup support for old bytecode format versions");
const bool has_initializer_code =
bytecode_component_->GetVersion() >= 14
? (flags & kHasInitializerCodeFlag) != 0
: has_initializer && is_static;
if (has_initializer_code) {
if ((flags & kHasInitializerCodeFlag) != 0) {
const intptr_t code_offset = reader_.ReadUInt();
field.set_bytecode_offset(code_offset +
bytecode_component_->GetCodesOffset());

View file

@ -625,8 +625,8 @@ namespace dart {
V(StoreFieldTOS_Wide, D, WIDE, lit, ___, ___) \
V(StoreIndexedTOS, 0, ORDN, ___, ___, ___) \
V(Unused20, 0, RESV, ___, ___, ___) \
V(PushStatic, D, ORDN, lit, ___, ___) \
V(PushStatic_Wide, D, WIDE, lit, ___, ___) \
V(Unused40, 0, RESV, ___, ___, ___) \
V(Unused41, 0, RESV, ___, ___, ___) \
V(StoreStaticTOS, D, ORDN, lit, ___, ___) \
V(StoreStaticTOS_Wide, D, WIDE, lit, ___, ___) \
V(Jump, T, ORDN, tgt, ___, ___) \
@ -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 = 10;
static const intptr_t kMinSupportedBytecodeFormatVersion = 20;
// 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).

View file

@ -1971,9 +1971,8 @@ SwitchDispatch:
RawObject** call_top = SP + 1;
InterpreterHelpers::IncrementUsageCounter(FrameFunction(FP));
RawUnlinkedCall* selector = RAW_CAST(UnlinkedCall, LOAD_CONSTANT(kidx));
RawString* target_name = selector->ptr()->target_name_;
argdesc_ = selector->ptr()->args_descriptor_;
RawString* target_name = RAW_CAST(String, LOAD_CONSTANT(kidx));
argdesc_ = RAW_CAST(Array, LOAD_CONSTANT(kidx + 1));
if (!InstanceCall(thread, target_name, call_base, call_top, &pc, &FP,
&SP)) {
HANDLE_EXCEPTION;
@ -2247,16 +2246,6 @@ SwitchDispatch:
DISPATCH();
}
{
static_assert(KernelBytecode::kMinSupportedBytecodeFormatVersion < 19,
"Cleanup PushStatic bytecode instruction");
BYTECODE(PushStatic, D);
RawField* field = reinterpret_cast<RawField*>(LOAD_CONSTANT(rD));
// Note: field is also on the stack, hence no increment.
*SP = field->ptr()->value_.static_value_;
DISPATCH();
}
{
BYTECODE(LoadStatic, D);
RawField* field = reinterpret_cast<RawField*>(LOAD_CONSTANT(rD));