Revert "Revert "Upgrade to 5.0.71.48"" DO NOT MERGE
This reverts commit f2e3994fa5148cc3d9946666f0b0596290192b0e,
and updates the x64 makefile properly so it doesn't break that
build.
FPIIM-449
Change-Id: Ib83e35bfbae6af627451c926a9650ec57c045605
(cherry picked from commit 109988c7ccb6f3fd1a58574fa3dfb88beaef6632)
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc
index a7a7da5..3023031 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -8,6 +8,7 @@
#include "src/compiler/node-properties.h"
#include "src/compiler/simplified-operator.h"
#include "src/objects-inl.h"
+#include "src/type-cache.h"
#include "src/types.h"
namespace v8 {
@@ -85,10 +86,10 @@
Node* node_;
};
-
JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph)
- : AdvancedReducer(editor), jsgraph_(jsgraph) {}
-
+ : AdvancedReducer(editor),
+ jsgraph_(jsgraph),
+ type_cache_(TypeCache::Get()) {}
// ECMA-262, section 15.8.2.11.
Reduction JSBuiltinReducer::ReduceMathMax(Node* node) {
@@ -141,6 +142,31 @@
return NoChange();
}
+// ES6 section 20.2.2.28 Math.round ( x )
+Reduction JSBuiltinReducer::ReduceMathRound(Node* node) {
+ JSCallReduction r(node);
+ if (r.InputsMatchOne(type_cache_.kIntegerOrMinusZeroOrNaN)) {
+ // Math.round(a:integer \/ -0 \/ NaN) -> a
+ return Replace(r.left());
+ }
+ if (r.InputsMatchOne(Type::Number()) &&
+ machine()->Float64RoundUp().IsSupported()) {
+ // Math.round(a:number) -> Select(Float64LessThan(#0.5, Float64Sub(i, a)),
+ // Float64Sub(i, #1.0), i)
+ // where i = Float64RoundUp(a)
+ Node* value = r.left();
+ Node* integer = graph()->NewNode(machine()->Float64RoundUp().op(), value);
+ Node* real = graph()->NewNode(machine()->Float64Sub(), integer, value);
+ return Replace(graph()->NewNode(
+ common()->Select(MachineRepresentation::kFloat64),
+ graph()->NewNode(machine()->Float64LessThan(),
+ jsgraph()->Float64Constant(0.5), real),
+ graph()->NewNode(machine()->Float64Sub(), integer,
+ jsgraph()->Float64Constant(1.0)),
+ integer));
+ }
+ return NoChange();
+}
Reduction JSBuiltinReducer::Reduce(Node* node) {
Reduction reduction = NoChange();
@@ -158,6 +184,9 @@
case kMathFround:
reduction = ReduceMathFround(node);
break;
+ case kMathRound:
+ reduction = ReduceMathRound(node);
+ break;
default:
break;
}