mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 04:16:51 +00:00
VM: Add double unary minus intrinsic.
Also remove an extra indirection in the unary minus operator for Double. BUG= R=rmacnak@google.com Review URL: https://codereview.chromium.org/1422753004 .
This commit is contained in:
parent
4627a8e916
commit
bcde4eee0b
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in a new issue