Index: runtime/vm/simulator_dbc.cc |
diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc |
index 1938950cebf21817fa52746ec83d614fc136e32f..624c5e5c51306c04bae0b4bab171e3e83a37f6d4 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,69 @@ RawObject* Simulator::Call(const Code& code, |
} |
{ |
+ BYTECODE(CheckNull, A_D); |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
Consider splitting this instruction into two and n
zra
2016/06/28 19:31:40
Done.
|
+ 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))); |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
No handle allocation in the interpreter loop! Plea
zra
2016/06/28 19:31:40
Done.
|
+ const intptr_t value = reinterpret_cast<intptr_t>(FP[rA]); |
+ const bool is_smi = ((value & kSmiTagMask) == kSmiTag); |
+ if (is_smi) { |
+ if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) { |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
this case is unlikely for dense switches. I sugges
zra
2016/06/28 19:31:40
Done.
|
+ pc++; |
+ } |
+ } else { |
+ 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++; |
+ } |
+ } |
+ DISPATCH(); |
+ } |
+ |
+ { |
+ BYTECODE(CheckForCid, A_D); |
+ const ICData& ic_data = |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
No Handles.
zra
2016/06/28 19:31:40
Done.
|
+ 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) { |
+ if (ic_data.GetReceiverClassIdAt(0) == kSmiCid) { |
+ pc++; |
+ } |
+ } else { |
+ const intptr_t cid = SimulatorHelpers::GetClassId(FP[rA]); |
+ GrowableArray<CidTarget> sorted_ic_data; |
+ FlowGraphCompiler::SortICDataByCount(ic_data, |
Vyacheslav Egorov (Google)
2016/06/28 13:03:10
This should all be done in compile time. Sorting i
zra
2016/06/28 19:31:40
Done.
|
+ &sorted_ic_data, |
+ /* drop_smi = */ true); |
+ const intptr_t num_checks = sorted_ic_data.length(); |
+ for (intptr_t i = 0; i < num_checks; i++) { |
+ const intptr_t data_cid = sorted_ic_data[i].cid; |
+ ASSERT(cid != kSmiCid); |
+ if (cid == data_cid) { |
+ pc++; |
+ break; |
+ } |
+ } |
+ } |
+ DISPATCH(); |
+ } |
+ |
+ { |
BYTECODE(IfEqStrictTOS, 0); |
SP -= 2; |
if (SP[1] != SP[2]) { |
@@ -2151,7 +2215,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--; |