Skip to content

Commit

Permalink
[VM runtime] For now, do not use field guards when using kernel bytec…
Browse files Browse the repository at this point in the history
…ode.

Change-Id: I6619d329eda70a4fd684f2c2bed4ba2934d1271f
Reviewed-on: https://dart-review.googlesource.com/68540
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Commit-Queue: Régis Crelier <regis@google.com>
  • Loading branch information
crelier authored and commit-bot@chromium.org committed Aug 7, 2018
1 parent 31765bf commit 66693ea
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
9 changes: 8 additions & 1 deletion runtime/vm/flag_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
#define USING_DBC false
#endif

// Don't use USING_KBC outside of this file.
#if defined(DART_USE_INTERPRETER)
#define USING_KBC true
#else
#define USING_KBC false
#endif

// Don't use USING_MULTICORE outside of this file.
#if defined(ARCH_IS_MULTI_CORE)
#define USING_MULTICORE true
Expand Down Expand Up @@ -186,7 +193,7 @@ constexpr bool kDartPrecompiledRuntime = false;
P(use_compactor, bool, false, "Compact the heap during old-space GC.") \
P(use_cha_deopt, bool, true, \
"Use class hierarchy analysis even if it can cause deoptimization.") \
P(use_field_guards, bool, !USING_DBC, \
P(use_field_guards, bool, !USING_DBC && !USING_KBC, \
"Use field guards and track field types") \
C(use_osr, false, true, bool, true, "Use OSR") \
P(use_strong_mode_types, bool, true, "Optimize based on strong mode types.") \
Expand Down
55 changes: 33 additions & 22 deletions runtime/vm/interpreter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1013,28 +1013,30 @@ DART_NOINLINE bool Interpreter::ProcessInvocation(bool* invoked,
return false;
}
}
// Check value cid according to field.guarded_cid().
// The interpreter should never see a cloned field.
ASSERT(field->ptr()->owner_->GetClassId() != kFieldCid);
const classid_t field_guarded_cid = field->ptr()->guarded_cid_;
const classid_t field_nullability_cid = field->ptr()->is_nullable_;
const classid_t value_cid = InterpreterHelpers::GetClassId(value);
if (value_cid != field_guarded_cid &&
value_cid != field_nullability_cid) {
if (Smi::Value(field->ptr()->guarded_list_length_) <
Field::kUnknownFixedLength &&
field_guarded_cid == kIllegalCid) {
field->ptr()->guarded_cid_ = value_cid;
field->ptr()->is_nullable_ = value_cid;
} else if (field_guarded_cid != kDynamicCid) {
call_top[1] = 0; // Unused result of runtime call.
call_top[2] = field;
call_top[3] = value;
Exit(thread, *FP, call_top + 4, *pc);
NativeArguments native_args(thread, 2, call_top + 2, call_top + 1);
if (!InvokeRuntime(thread, this, DRT_UpdateFieldCid, native_args)) {
*invoked = true;
return false;
if (thread->isolate()->use_field_guards()) {
// Check value cid according to field.guarded_cid().
// The interpreter should never see a cloned field.
ASSERT(field->ptr()->owner_->GetClassId() != kFieldCid);
const classid_t field_guarded_cid = field->ptr()->guarded_cid_;
const classid_t field_nullability_cid = field->ptr()->is_nullable_;
const classid_t value_cid = InterpreterHelpers::GetClassId(value);
if (value_cid != field_guarded_cid &&
value_cid != field_nullability_cid) {
if (Smi::Value(field->ptr()->guarded_list_length_) <
Field::kUnknownFixedLength &&
field_guarded_cid == kIllegalCid) {
field->ptr()->guarded_cid_ = value_cid;
field->ptr()->is_nullable_ = value_cid;
} else if (field_guarded_cid != kDynamicCid) {
call_top[1] = 0; // Unused result of runtime call.
call_top[2] = field;
call_top[3] = value;
Exit(thread, *FP, call_top + 4, *pc);
NativeArguments native_args(thread, 2, call_top + 2, call_top + 1);
if (!InvokeRuntime(thread, this, DRT_UpdateFieldCid, native_args)) {
*invoked = true;
return false;
}
}
}
}
Expand Down Expand Up @@ -3480,6 +3482,9 @@ RawObject* Interpreter::Call(RawFunction* function,
RawInstance* instance = reinterpret_cast<RawInstance*>(FP[rA]);
RawObject* value = FP[value_reg];

// TODO(regis): Implement cid guard.
ASSERT(!thread->isolate()->use_field_guards());

instance->StorePointer(
reinterpret_cast<RawObject**>(instance->ptr()) + offset_in_words,
value);
Expand All @@ -3493,6 +3498,8 @@ RawObject* Interpreter::Call(RawFunction* function,
RawInstance* instance = reinterpret_cast<RawInstance*>(FP[rA]);
RawObject* value = FP[rD];

UNREACHABLE(); // TODO(regis): unused, remove.

instance->StorePointer(
reinterpret_cast<RawObject**>(instance->ptr()) + offset_in_words,
value);
Expand All @@ -3506,6 +3513,10 @@ RawObject* Interpreter::Call(RawFunction* function,
RawInstance* instance = reinterpret_cast<RawInstance*>(SP[-1]);
RawObject* value = reinterpret_cast<RawObject*>(SP[0]);
SP -= 2; // Drop instance and value.

// TODO(regis): Implement cid guard.
ASSERT(!thread->isolate()->use_field_guards());

instance->StorePointer(
reinterpret_cast<RawObject**>(instance->ptr()) + offset_in_words,
value);
Expand Down

0 comments on commit 66693ea

Please sign in to comment.