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:
Florian Schneider 2015-10-29 22:58:33 +01:00
parent 4627a8e916
commit bcde4eee0b
3 changed files with 23 additions and 6 deletions

View file

@ -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;

View file

@ -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

View file

@ -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) \