| Index: runtime/vm/simulator_dbc.cc
|
| diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc
|
| index 1938950cebf21817fa52746ec83d614fc136e32f..e3a25ed774bc1b2dd59e0b28d0a7966d5a341446 100644
|
| --- a/runtime/vm/simulator_dbc.cc
|
| +++ b/runtime/vm/simulator_dbc.cc
|
| @@ -21,6 +21,7 @@
|
| #include "vm/dart_entry.h"
|
| #include "vm/debugger.h"
|
| #include "vm/disassembler.h"
|
| +#include "vm/flow_graph_compiler.h"
|
| #include "vm/lockers.h"
|
| #include "vm/native_arguments.h"
|
| #include "vm/native_entry.h"
|
| @@ -1978,6 +1979,86 @@ RawObject* Simulator::Call(const Code& code,
|
| }
|
|
|
| {
|
| + BYTECODE(CheckNull, A_D);
|
| + RawObject* obj = FP[rA];
|
| + if (((rD == 1) && (obj != null_value)) ||
|
| + ((rD == 0) && (obj == null_value))) {
|
| + pc++;
|
| + }
|
| + DISPATCH();
|
| + }
|
| +
|
| + {
|
| + BYTECODE(CheckDenseSwitchTOS, A_D);
|
| + const intptr_t cid_mask = Smi::Value(RAW_CAST(Smi, *SP--));
|
| + const intptr_t cid_min = Smi::Value(RAW_CAST(Smi, *SP--));
|
| + const ICData& ic_data =
|
| + ICData::Handle(RAW_CAST(ICData, LOAD_CONSTANT(rD)));
|
| + const intptr_t value = reinterpret_cast<intptr_t>(FP[rA]);
|
| + const bool is_smi = ((value & kSmiTagMask) == kSmiTag);
|
| + if (is_smi) {
|
| + //OS::PrintErr("CheckDenseSwitchTOS: Smi\n");
|
| + if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) {
|
| + //OS::PrintErr("\tCheckDenseSwitchTOS: receiver is smi\n");
|
| + pc++;
|
| + } else {
|
| + //OS::PrintErr("\tCheckDenseSwitchTOS: receiver is NOT smi\n");
|
| + }
|
| + } else {
|
| + const intptr_t cid_max = Utils::HighestBit(cid_mask) + cid_min;
|
| + const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
|
| + //OS::PrintErr("\tCheckDenseSwitchTOS: cid_min = %ld, cid_max = %ld, cid = %ld\n",
|
| + //cid_min, cid_max, cid);
|
| + // 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)) {
|
| + //OS::PrintErr("\tCheckDenseSwitchTOS: Good\n");
|
| + pc++;
|
| + } else {
|
| + //OS::PrintErr("\tCheckDenseSwitchTOS: Not Good\n");
|
| + }
|
| + }
|
| + DISPATCH();
|
| + }
|
| +
|
| + {
|
| + BYTECODE(CheckForCid, A_D);
|
| + const ICData& ic_data =
|
| + ICData::Handle(RAW_CAST(ICData, LOAD_CONSTANT(rD)));
|
| + const intptr_t value = reinterpret_cast<intptr_t>(FP[rA]);
|
| + const bool is_smi = ((value & kSmiTagMask) == kSmiTag);
|
| + if (is_smi) {
|
| + //OS::PrintErr("CheckForCid: Smi\n");
|
| + if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) {
|
| + //OS::PrintErr("\tCheckForCid: receiver is smi\n");
|
| + pc++;
|
| + } else {
|
| + //OS::PrintErr("\tCheckForCid: receiver is not smi\n");
|
| + }
|
| + } else {
|
| + const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]);
|
| + GrowableArray<CidTarget> sorted_ic_data;
|
| + FlowGraphCompiler::SortICDataByCount(ic_data,
|
| + &sorted_ic_data,
|
| + /* drop_smi = */ true);
|
| + const intptr_t num_checks = sorted_ic_data.length();
|
| + //OS::PrintErr("CheckForCid: cid = %ld, num_checks = %ld\n",
|
| + //cid, num_checks);
|
| + for (intptr_t i = 0; i < num_checks; i++) {
|
| + const intptr_t data_cid = sorted_ic_data[i].cid;
|
| + //OS::PrintErr("\tCheckForCid: looking at %ld\n", data_cid);
|
| + ASSERT(cid != kSmiCid);
|
| + if (cid == data_cid) {
|
| + //OS::PrintErr("\tCheckForCid: Found\n");
|
| + pc++;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + DISPATCH();
|
| + }
|
| +
|
| + {
|
| BYTECODE(IfEqStrictTOS, 0);
|
| SP -= 2;
|
| if (SP[1] != SP[2]) {
|
| @@ -2116,6 +2197,8 @@ RawObject* Simulator::Call(const Code& code,
|
| BYTECODE(Deopt, A_D);
|
| const bool is_lazy = rD == 0;
|
|
|
| + //OS::PrintErr("Deopt instr pc = %p\n", pc - 1);
|
| +
|
| // Preserve result of the previous call.
|
| // TODO(vegorov) we could have actually included result into the
|
| // deoptimization environment because it is passed through the stack.
|
|
|