Chromium Code Reviews| Index: runtime/vm/simulator_dbc.cc |
| diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc |
| index 416dda577e7635daf1b5d7bcad6818e9ac9004f2..1090b8153a665c71012e4e924b259ba11d045947 100644 |
| --- a/runtime/vm/simulator_dbc.cc |
| +++ b/runtime/vm/simulator_dbc.cc |
| @@ -122,6 +122,17 @@ class SimulatorHelpers { |
| f->ptr()->usage_counter_++; |
| } |
| + DART_FORCE_INLINE static void IncrementICUsageCount(RawObject** entries, |
| + intptr_t offset, |
| + intptr_t args_tested) { |
| + const intptr_t count_offset = ICData::CountIndexFor(args_tested); |
| + const intptr_t raw_smi_old = |
| + reinterpret_cast<intptr_t>(entries[offset + count_offset]); |
| + const intptr_t raw_smi_new = raw_smi_old + Smi::RawValue(1); |
| + *reinterpret_cast<intptr_t*>(&entries[offset + count_offset]) = |
| + raw_smi_new; |
| + } |
| + |
| DART_FORCE_INLINE static bool IsStrictEqualWithNumberCheck(RawObject* lhs, |
| RawObject* rhs) { |
| if (lhs == rhs) { |
| @@ -588,7 +599,8 @@ DART_FORCE_INLINE void Simulator::InstanceCall1(Thread* thread, |
| RawObjectPool** pp, |
| uint32_t** pc, |
| RawObject*** FP, |
| - RawObject*** SP) { |
| + RawObject*** SP, |
| + bool optimized) { |
| ASSERT(icdata->GetClassId() == kICDataCid); |
| const intptr_t kCheckedArgs = 1; |
| @@ -604,6 +616,9 @@ DART_FORCE_INLINE void Simulator::InstanceCall1(Thread* thread, |
| if (cache->data()[i + 0] == receiver_cid) { |
| top[0] = cache->data()[i + kCheckedArgs]; |
| found = true; |
| + if (!optimized) { |
| + SimulatorHelpers::IncrementICUsageCount(cache->data(), i, kCheckedArgs); |
|
zra
2016/07/28 22:03:53
Should this be incremented after handling an inlin
rmacnak
2016/07/28 22:22:04
No, the runtime call that adds the new entry gives
|
| + } |
| break; |
| } |
| } |
| @@ -626,7 +641,8 @@ DART_FORCE_INLINE void Simulator::InstanceCall2(Thread* thread, |
| RawObjectPool** pp, |
| uint32_t** pc, |
| RawObject*** FP, |
| - RawObject*** SP) { |
| + RawObject*** SP, |
| + bool optimized) { |
| ASSERT(icdata->GetClassId() == kICDataCid); |
| const intptr_t kCheckedArgs = 2; |
| @@ -644,6 +660,9 @@ DART_FORCE_INLINE void Simulator::InstanceCall2(Thread* thread, |
| (cache->data()[i + 1] == arg0_cid)) { |
| top[0] = cache->data()[i + kCheckedArgs]; |
| found = true; |
| + if (!optimized) { |
|
zra
2016/07/28 22:03:53
ditto.
|
| + SimulatorHelpers::IncrementICUsageCount(cache->data(), i, kCheckedArgs); |
| + } |
| break; |
| } |
| } |
| @@ -762,12 +781,8 @@ static DART_NOINLINE bool InvokeNativeWrapper( |
| ASSERT(Bytecode::IsCallOpcode(*pc)); \ |
| const uint16_t kidx = Bytecode::DecodeD(*pc); \ |
| const RawICData* icdata = RAW_CAST(ICData, LOAD_CONSTANT(kidx)); \ |
| - RawObject** data = icdata->ptr()->ic_data_->ptr()->data(); \ |
| - const intptr_t count_offset = ICData::CountIndexFor(2); \ |
| - const intptr_t raw_smi_old = \ |
| - reinterpret_cast<intptr_t>(data[count_offset]); \ |
| - const intptr_t raw_smi_new = raw_smi_old + Smi::RawValue(1); \ |
| - *reinterpret_cast<intptr_t*>(&data[count_offset]) = raw_smi_new; \ |
| + RawObject** entries = icdata->ptr()->ic_data_->ptr()->data(); \ |
| + SimulatorHelpers::IncrementICUsageCount(entries, 0, 2); \ |
| } while (0); \ |
| // Declare bytecode handler for a smi operation (e.g. AddTOS) with the |
| @@ -1389,8 +1404,9 @@ RawObject* Simulator::Call(const Code& code, |
| // Lookup the funciton in the ICData. |
| RawObject* ic_data_obj = SP[0]; |
| RawICData* ic_data = RAW_CAST(ICData, ic_data_obj); |
| - RawArray* cache = ic_data->ptr()->ic_data_->ptr(); |
| - SP[0] = cache->data()[ICData::TargetIndexFor( |
| + RawObject** data = ic_data->ptr()->ic_data_->ptr()->data(); |
| + SimulatorHelpers::IncrementICUsageCount(data, 0, 0); |
| + SP[0] = data[ICData::TargetIndexFor( |
| ic_data->ptr()->state_bits_ & 0x3)]; |
| RawObject** call_base = SP - argc; |
| RawObject** call_top = SP; // *SP contains function |
| @@ -1431,8 +1447,9 @@ RawObject* Simulator::Call(const Code& code, |
| RawICData* icdata = RAW_CAST(ICData, LOAD_CONSTANT(kidx)); |
| SimulatorHelpers::IncrementUsageCounter( |
| RAW_CAST(Function, icdata->ptr()->owner_)); |
| - InstanceCall1( |
| - thread, icdata, call_base, call_top, &argdesc, &pp, &pc, &FP, &SP); |
| + InstanceCall1(thread, icdata, call_base, call_top, |
| + &argdesc, &pp, &pc, &FP, &SP, |
| + false /* optimized */); |
| } |
| DISPATCH(); |
| @@ -1456,8 +1473,9 @@ RawObject* Simulator::Call(const Code& code, |
| RawICData* icdata = RAW_CAST(ICData, LOAD_CONSTANT(kidx)); |
| SimulatorHelpers::IncrementUsageCounter( |
| RAW_CAST(Function, icdata->ptr()->owner_)); |
| - InstanceCall2( |
| - thread, icdata, call_base, call_top, &argdesc, &pp, &pc, &FP, &SP); |
| + InstanceCall2(thread, icdata, call_base, call_top, |
| + &argdesc, &pp, &pc, &FP, &SP, |
| + false /* optimized */); |
| } |
| DISPATCH(); |
| @@ -1475,8 +1493,9 @@ RawObject* Simulator::Call(const Code& code, |
| RawICData* icdata = RAW_CAST(ICData, LOAD_CONSTANT(kidx)); |
| SimulatorHelpers::IncrementUsageCounter(FrameFunction(FP)); |
| - InstanceCall1( |
| - thread, icdata, call_base, call_top, &argdesc, &pp, &pc, &FP, &SP); |
| + InstanceCall1(thread, icdata, call_base, call_top, |
| + &argdesc, &pp, &pc, &FP, &SP, |
| + true /* optimized */); |
| } |
| DISPATCH(); |
| @@ -1494,8 +1513,9 @@ RawObject* Simulator::Call(const Code& code, |
| RawICData* icdata = RAW_CAST(ICData, LOAD_CONSTANT(kidx)); |
| SimulatorHelpers::IncrementUsageCounter(FrameFunction(FP)); |
| - InstanceCall2( |
| - thread, icdata, call_base, call_top, &argdesc, &pp, &pc, &FP, &SP); |
| + InstanceCall2(thread, icdata, call_base, call_top, |
| + &argdesc, &pp, &pc, &FP, &SP, |
| + true /* optimized */); |
| } |
| DISPATCH(); |