Chromium Code Reviews| Index: runtime/vm/simulator_dbc.cc |
| diff --git a/runtime/vm/simulator_dbc.cc b/runtime/vm/simulator_dbc.cc |
| index 6c7112e26c58ae4340995c5b2f704fc9a37423d3..3ac7d2bdca7a75c2ce21188017cb300da3ec96c7 100644 |
| --- a/runtime/vm/simulator_dbc.cc |
| +++ b/runtime/vm/simulator_dbc.cc |
| @@ -239,6 +239,160 @@ class SimulatorHelpers { |
| return false; |
| } |
| + static bool Double_getIsNan(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + RawObject** args = FrameArguments(FP, 1); |
| + RawDouble* d = static_cast<RawDouble*>(args[0]); |
| + *result = isnan(d->ptr()->value_) |
| + ? Bool::True().raw() |
| + : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool ObjectEquals(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + RawObject** args = FrameArguments(FP, 2); |
| + *result = args[0] == args[1] ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool ObjectRuntimeType(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + RawObject** args = FrameArguments(FP, 1); |
| + const intptr_t cid = GetClassId(args[0]); |
| + if (cid == kClosureCid) { |
| + return false; |
| + } |
| + RawClass* cls = thread->isolate()->class_table()->At(cid); |
| + if (cls->ptr()->num_type_arguments_ != 0) { |
| + return false; |
| + } |
| + RawType* typ = cls->ptr()->canonical_type_; |
| + if (typ == Object::null()) { |
| + return false; |
| + } |
| + *result = static_cast<RawObject*>(typ); |
| + return true; |
| + } |
| + |
| + static bool GetDoubleOperands(RawObject** args, double* d1, double* d2) { |
| + RawObject* obj2 = args[1]; |
| + if (!obj2->IsHeapObject()) { |
|
Florian Schneider
2016/10/17 16:58:54
I'd rather use obj2->IsSmi() for readability avoid
zra
2016/10/17 17:22:51
IsSmi() calls GetClassId() which calls ptr() which
|
| + *d2 = static_cast<double>( |
| + reinterpret_cast<intptr_t>(obj2) >> kSmiTagSize); |
| + } else if (obj2->GetClassId() == kDoubleCid) { |
| + RawDouble* obj2d = static_cast<RawDouble*>(obj2); |
| + *d2 = obj2d->ptr()->value_; |
| + } else { |
| + return false; |
| + } |
| + RawDouble* obj1 = static_cast<RawDouble*>(args[0]); |
| + *d1 = obj1->ptr()->value_; |
| + return true; |
| + } |
| + |
| + static bool Double_add(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = static_cast<RawObject*>(Double::New(d1 + d2)); |
| + return true; |
| + } |
| + |
| + static bool Double_mul(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = static_cast<RawObject*>(Double::New(d1 * d2)); |
| + return true; |
| + } |
| + |
| + static bool Double_sub(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = static_cast<RawObject*>(Double::New(d1 - d2)); |
| + return true; |
| + } |
| + |
| + static bool Double_div(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = static_cast<RawObject*>(Double::New(d1 / d2)); |
| + return true; |
| + } |
| + |
| + static bool Double_greaterThan(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = d1 > d2 ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool Double_greaterEqualThan(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = d1 >= d2 ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool Double_lessThan(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = d1 < d2 ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool Double_equal(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = d1 == d2 ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| + static bool Double_lessEqualThan(Thread* thread, |
| + RawObject** FP, |
| + RawObject** result) { |
| + double d1, d2; |
| + if (!GetDoubleOperands(FrameArguments(FP, 2), &d1, &d2)) { |
| + return false; |
| + } |
| + *result = d1 <= d2 ? Bool::True().raw() : Bool::False().raw(); |
| + return true; |
| + } |
| + |
| DART_FORCE_INLINE static RawCode* FrameCode(RawObject** FP) { |
| ASSERT(GetClassId(FP[kPcMarkerSlotFromFp]) == kCodeCid); |
| return static_cast<RawCode*>(FP[kPcMarkerSlotFromFp]); |
| @@ -290,6 +444,31 @@ void Simulator::InitOnce() { |
| SimulatorHelpers::GrowableArraySetIndexed; |
| intrinsics_[kGrowableArrayGetIndexedIntrinsic] = |
| SimulatorHelpers::GrowableArrayGetIndexed; |
| + intrinsics_[kObjectEqualsIntrinsic] = |
| + SimulatorHelpers::ObjectEquals; |
| + intrinsics_[kObjectRuntimeTypeIntrinsic] = |
| + SimulatorHelpers::ObjectRuntimeType; |
| + |
| + intrinsics_[kDouble_getIsNaNIntrinsic] = |
| + SimulatorHelpers::Double_getIsNan; |
| + intrinsics_[kDouble_addIntrinsic] = |
| + SimulatorHelpers::Double_add; |
| + intrinsics_[kDouble_mulIntrinsic] = |
| + SimulatorHelpers::Double_mul; |
| + intrinsics_[kDouble_subIntrinsic] = |
| + SimulatorHelpers::Double_sub; |
| + intrinsics_[kDouble_divIntrinsic] = |
| + SimulatorHelpers::Double_div; |
| + intrinsics_[kDouble_greaterThanIntrinsic] = |
| + SimulatorHelpers::Double_greaterThan; |
| + intrinsics_[kDouble_greaterEqualThanIntrinsic] = |
| + SimulatorHelpers::Double_greaterEqualThan; |
| + intrinsics_[kDouble_lessThanIntrinsic] = |
| + SimulatorHelpers::Double_lessThan; |
| + intrinsics_[kDouble_equalIntrinsic] = |
| + SimulatorHelpers::Double_equal; |
| + intrinsics_[kDouble_lessEqualThanIntrinsic] = |
| + SimulatorHelpers::Double_lessEqualThan; |
| } |
| @@ -2882,10 +3061,6 @@ RawObject* Simulator::Call(const Code& code, |
| pc++; |
| break; |
| } |
| - // The cids are sorted in descending order. |
| - if (cid > desired_cid) { |
| - break; |
| - } |
| } |
| pc += cids_length; |
| } else { |