Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(190)

Unified Diff: runtime/vm/simulator_dbc.cc

Issue 2098573004: DBC: CheckClassInstr (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Clean up comment Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/simulator_dbc.cc
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
index 1938950cebf21817fa52746ec83d614fc136e32f..324d16ece18e558a0c6a29b5c9c578bcea6796ad 100644
--- a/runtime/vm/simulator_dbc.cc
+++ b/runtime/vm/simulator_dbc.cc
@@ -1978,6 +1978,72 @@ RawObject* Simulator::Call(const Code& code,
}
{
+ BYTECODE(CheckDenseSwitch, A_D);
+ const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
+ const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
+ const intptr_t cid_min =
+ Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*pc))));
+ const intptr_t cid_mask =
+ Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*(pc + 1)))));
+ if (LIKELY(!is_smi)) {
+ const intptr_t cid_max = Utils::HighestBit(cid_mask) + cid_min;
+ const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
+ // The cid is in-bounds, and the bit is set in the mask.
+ if ((cid >= cid_min) && (cid <= cid_max) &&
+ ((cid_mask & (1 << (cid - cid_min))) != 0)) {
+ pc += 3;
+ } else {
+ pc += 2;
+ }
+ } else {
+ const bool may_be_smi = (rD == 1);
+ pc += (may_be_smi ? 3 : 2);
+ }
+ DISPATCH();
+ }
+
+ {
+ BYTECODE(CheckCid, A_D);
+ const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
+ const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
+ const bool may_be_smi = (rD == 1);
+ if (is_smi) {
+ pc += (may_be_smi ? 2 : 1);
+ } else {
+ const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
+ const intptr_t desired_cid =
+ Smi::Value(RAW_CAST(Smi, LOAD_CONSTANT(Bytecode::DecodeD(*pc))));
+ pc += ((cid == desired_cid) ? 2 : 1);
+ }
+ DISPATCH();
+ }
+
+ {
+ BYTECODE(CheckCids, A_D);
+ const intptr_t raw_value = reinterpret_cast<intptr_t>(FP[rA]);
+ const bool is_smi = ((raw_value & kSmiTagMask) == kSmiTag);
+ const bool may_be_smi = (rD == 1);
+ if (is_smi) {
Vyacheslav Egorov (Google) 2016/06/29 17:11:06 Flip this conditions to match CheckDenseSwitch if
zra 2016/06/29 22:19:19 Done.
+ pc += (may_be_smi ? 2 : 1);
+ } else {
+ const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
+ const RawArray* cid_array =
+ RAW_CAST(Array, LOAD_CONSTANT(Bytecode::DecodeD(*pc)));
+ RawObject** cids = cid_array->ptr()->data();
+ const intptr_t cids_length = Smi::Value(cid_array->ptr()->length_);
+ for (intptr_t i = 0; i < cids_length; i++) {
+ const intptr_t desired_cid = Smi::Value(RAW_CAST(Smi, cids[i]));
Vyacheslav Egorov (Google) 2016/06/29 18:33:10 the array of cids is sorted so you can exit the lo
zra 2016/06/29 22:19:19 Done.
+ if (cid == desired_cid) {
+ pc++;
+ break;
+ }
+ }
+ pc++;
+ }
+ DISPATCH();
+ }
+
+ {
BYTECODE(IfEqStrictTOS, 0);
SP -= 2;
if (SP[1] != SP[2]) {
@@ -2066,6 +2132,22 @@ RawObject* Simulator::Call(const Code& code,
}
{
+ BYTECODE(IfEqNull, A);
+ if (FP[rA] != null_value) {
+ pc++;
+ }
+ DISPATCH();
+ }
+
+ {
+ BYTECODE(IfNeNull, A_D);
+ if (FP[rA] == null_value) {
+ pc++;
+ }
+ DISPATCH();
+ }
+
+ {
BYTECODE(Jump, 0);
const int32_t target = static_cast<int32_t>(op) >> 8;
pc += (target - 1);
@@ -2151,7 +2233,7 @@ RawObject* Simulator::Call(const Code& code,
INVOKE_RUNTIME(DRT_DeoptimizeMaterialize, native_args);
}
const intptr_t materialization_arg_count =
- Smi::Value(RAW_CAST(Smi, *SP--));
+ Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize;
if (is_lazy) {
// Reload the result. It might have been relocated by GC.
result = *SP--;

Powered by Google App Engine
This is Rietveld 408576698