diff --git a/runtime/lib/double.dart b/runtime/lib/double.dart index ea7c1cf1ac2..87d80464f82 100644 --- a/runtime/lib/double.dart +++ b/runtime/lib/double.dart @@ -46,17 +46,14 @@ class _Double extends _Num implements double { return _remainder(other.toDouble()); } double _remainder(double other) native "Double_remainder"; - double operator -() { - // Handles properly 0.0, NAN, and other doubles. - return this._flipSignBit; - } - double get _flipSignBit native "Double_flipSignBit"; + + double operator -() native "Double_flipSignBit"; bool operator ==(other) { if (!(other is num)) return false; return _equal(other.toDouble()); } - bool _equal(double other)native "Double_equal"; + bool _equal(double other) native "Double_equal"; bool _equalToInteger(int other) native "Double_equalToInteger"; bool operator <(num other) { return other > this; diff --git a/runtime/vm/intrinsifier.cc b/runtime/vm/intrinsifier.cc index aa5ba86cb22..c3356b3a194 100644 --- a/runtime/vm/intrinsifier.cc +++ b/runtime/vm/intrinsifier.cc @@ -868,4 +868,23 @@ bool Intrinsifier::Build_GrowableArraySetLength(FlowGraph* flow_graph) { return true; } + +bool Intrinsifier::Build_DoubleFlipSignBit(FlowGraph* flow_graph) { + GraphEntryInstr* graph_entry = flow_graph->graph_entry(); + TargetEntryInstr* normal_entry = graph_entry->normal_entry(); + BlockBuilder builder(flow_graph, normal_entry); + + Definition* receiver = builder.AddParameter(1); + Definition* unboxed_value = + builder.AddUnboxInstr(kUnboxedDouble, new Value(receiver)); + Definition* unboxed_result = builder.AddDefinition( + new UnaryDoubleOpInstr(Token::kNEGATE, + new Value(unboxed_value), + Thread::kNoDeoptId)); + Definition* result = builder.AddDefinition( + BoxInstr::Create(kUnboxedDouble, new Value(unboxed_result))); + builder.AddIntrinsicReturn(new Value(result)); + return true; +} + } // namespace dart diff --git a/runtime/vm/method_recognizer.h b/runtime/vm/method_recognizer.h index 18c3e3d7d98..02e9dae948b 100644 --- a/runtime/vm/method_recognizer.h +++ b/runtime/vm/method_recognizer.h @@ -301,6 +301,7 @@ namespace dart { V(_GrowableList, [], GrowableArrayGetIndexed, 1962926024) \ V(_GrowableList, []=, GrowableArraySetIndexed, 457344024) \ V(_StringBase, get:length, StringBaseLength, 784518792) \ + V(_Double, unary-, DoubleFlipSignBit, 2107492213) #define GRAPH_INTRINSICS_LIST(V) \ GRAPH_CORE_INTRINSICS_LIST(V) \