Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/src/compiler/js-builtin-reducer.cc b/src/compiler/js-builtin-reducer.cc
index 263b0fe..a7a7da5 100644
--- a/src/compiler/js-builtin-reducer.cc
+++ b/src/compiler/js-builtin-reducer.cc
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "src/compiler/diamond.h"
-#include "src/compiler/graph-inl.h"
#include "src/compiler/js-builtin-reducer.h"
#include "src/compiler/js-graph.h"
#include "src/compiler/node-matchers.h"
-#include "src/compiler/node-properties-inl.h"
+#include "src/compiler/node-properties.h"
+#include "src/compiler/simplified-operator.h"
+#include "src/objects-inl.h"
#include "src/types.h"
namespace v8 {
@@ -15,17 +15,6 @@
namespace compiler {
-// Helper method that assumes replacement nodes are pure values that don't
-// produce an effect. Replaces {node} with {reduction} and relaxes effects.
-static Reduction ReplaceWithPureReduction(Node* node, Reduction reduction) {
- if (reduction.Changed()) {
- NodeProperties::ReplaceWithValue(node, reduction.replacement());
- return reduction;
- }
- return Reducer::NoChange();
-}
-
-
// Helper class to access JSCallFunction nodes that are potential candidates
// for reduction when they have a BuiltinFunctionId associated with them.
class JSCallReduction {
@@ -36,17 +25,17 @@
// constant callee being a well-known builtin with a BuiltinFunctionId.
bool HasBuiltinFunctionId() {
if (node_->opcode() != IrOpcode::kJSCallFunction) return false;
- HeapObjectMatcher<Object> m(NodeProperties::GetValueInput(node_, 0));
- if (!m.HasValue() || !m.Value().handle()->IsJSFunction()) return false;
- Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle());
+ HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0));
+ if (!m.HasValue() || !m.Value()->IsJSFunction()) return false;
+ Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
return function->shared()->HasBuiltinFunctionId();
}
// Retrieves the BuiltinFunctionId as described above.
BuiltinFunctionId GetBuiltinFunctionId() {
DCHECK_EQ(IrOpcode::kJSCallFunction, node_->opcode());
- HeapObjectMatcher<Object> m(NodeProperties::GetValueInput(node_, 0));
- Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value().handle());
+ HeapObjectMatcher m(NodeProperties::GetValueInput(node_, 0));
+ Handle<JSFunction> function = Handle<JSFunction>::cast(m.Value());
return function->shared()->builtin_function_id();
}
@@ -56,20 +45,20 @@
// Determines whether the call takes one input of the given type.
bool InputsMatchOne(Type* t1) {
return GetJSCallArity() == 1 &&
- NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1);
+ NodeProperties::GetType(GetJSCallInput(0))->Is(t1);
}
// Determines whether the call takes two inputs of the given types.
bool InputsMatchTwo(Type* t1, Type* t2) {
return GetJSCallArity() == 2 &&
- NodeProperties::GetBounds(GetJSCallInput(0)).upper->Is(t1) &&
- NodeProperties::GetBounds(GetJSCallInput(1)).upper->Is(t2);
+ NodeProperties::GetType(GetJSCallInput(0))->Is(t1) &&
+ NodeProperties::GetType(GetJSCallInput(1))->Is(t2);
}
// Determines whether the call takes inputs all of the given type.
bool InputsMatchAll(Type* t) {
for (int i = 0; i < GetJSCallArity(); i++) {
- if (!NodeProperties::GetBounds(GetJSCallInput(i)).upper->Is(t)) {
+ if (!NodeProperties::GetType(GetJSCallInput(i))->Is(t)) {
return false;
}
}
@@ -97,40 +86,8 @@
};
-JSBuiltinReducer::JSBuiltinReducer(JSGraph* jsgraph)
- : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
-
-
-// ECMA-262, section 15.8.2.1.
-Reduction JSBuiltinReducer::ReduceMathAbs(Node* node) {
- JSCallReduction r(node);
- if (r.InputsMatchOne(Type::Unsigned32())) {
- // Math.abs(a:uint32) -> a
- return Replace(r.left());
- }
- if (r.InputsMatchOne(Type::Number())) {
- // Math.abs(a:number) -> (a > 0 ? a : 0 - a)
- Node* const value = r.left();
- Node* const zero = jsgraph()->ZeroConstant();
- return Replace(graph()->NewNode(
- common()->Select(kMachNone),
- graph()->NewNode(simplified()->NumberLessThan(), zero, value), value,
- graph()->NewNode(simplified()->NumberSubtract(), zero, value)));
- }
- return NoChange();
-}
-
-
-// ECMA-262, section 15.8.2.17.
-Reduction JSBuiltinReducer::ReduceMathSqrt(Node* node) {
- JSCallReduction r(node);
- if (r.InputsMatchOne(Type::Number())) {
- // Math.sqrt(a:number) -> Float64Sqrt(a)
- Node* value = graph()->NewNode(machine()->Float64Sqrt(), r.left());
- return Replace(value);
- }
- return NoChange();
-}
+JSBuiltinReducer::JSBuiltinReducer(Editor* editor, JSGraph* jsgraph)
+ : AdvancedReducer(editor), jsgraph_(jsgraph) {}
// ECMA-262, section 15.8.2.11.
@@ -150,9 +107,9 @@
for (int i = 1; i < r.GetJSCallArity(); i++) {
Node* const input = r.GetJSCallInput(i);
value = graph()->NewNode(
- common()->Select(kMachNone),
- graph()->NewNode(simplified()->NumberLessThan(), input, value), input,
- value);
+ common()->Select(MachineRepresentation::kNone),
+ graph()->NewNode(simplified()->NumberLessThan(), input, value), value,
+ input);
}
return Replace(value);
}
@@ -185,62 +142,40 @@
}
-// ES6 draft 10-14-14, section 20.2.2.16.
-Reduction JSBuiltinReducer::ReduceMathFloor(Node* node) {
- if (!machine()->HasFloat64Floor()) return NoChange();
- JSCallReduction r(node);
- if (r.InputsMatchOne(Type::Number())) {
- // Math.floor(a:number) -> Float64Floor(a)
- Node* value = graph()->NewNode(machine()->Float64Floor(), r.left());
- return Replace(value);
- }
- return NoChange();
-}
-
-
-// ES6 draft 10-14-14, section 20.2.2.10.
-Reduction JSBuiltinReducer::ReduceMathCeil(Node* node) {
- if (!machine()->HasFloat64Ceil()) return NoChange();
- JSCallReduction r(node);
- if (r.InputsMatchOne(Type::Number())) {
- // Math.ceil(a:number) -> Float64Ceil(a)
- Node* value = graph()->NewNode(machine()->Float64Ceil(), r.left());
- return Replace(value);
- }
- return NoChange();
-}
-
-
Reduction JSBuiltinReducer::Reduce(Node* node) {
+ Reduction reduction = NoChange();
JSCallReduction r(node);
// Dispatch according to the BuiltinFunctionId if present.
if (!r.HasBuiltinFunctionId()) return NoChange();
switch (r.GetBuiltinFunctionId()) {
- case kMathAbs:
- return ReplaceWithPureReduction(node, ReduceMathAbs(node));
- case kMathSqrt:
- return ReplaceWithPureReduction(node, ReduceMathSqrt(node));
case kMathMax:
- return ReplaceWithPureReduction(node, ReduceMathMax(node));
+ reduction = ReduceMathMax(node);
+ break;
case kMathImul:
- return ReplaceWithPureReduction(node, ReduceMathImul(node));
+ reduction = ReduceMathImul(node);
+ break;
case kMathFround:
- return ReplaceWithPureReduction(node, ReduceMathFround(node));
- case kMathFloor:
- return ReplaceWithPureReduction(node, ReduceMathFloor(node));
- case kMathCeil:
- return ReplaceWithPureReduction(node, ReduceMathCeil(node));
+ reduction = ReduceMathFround(node);
+ break;
default:
break;
}
- return NoChange();
+
+ // Replace builtin call assuming replacement nodes are pure values that don't
+ // produce an effect. Replaces {node} with {reduction} and relaxes effects.
+ if (reduction.Changed()) ReplaceWithValue(node, reduction.replacement());
+
+ return reduction;
}
Graph* JSBuiltinReducer::graph() const { return jsgraph()->graph(); }
+Isolate* JSBuiltinReducer::isolate() const { return jsgraph()->isolate(); }
+
+
CommonOperatorBuilder* JSBuiltinReducer::common() const {
return jsgraph()->common();
}
@@ -250,6 +185,11 @@
return jsgraph()->machine();
}
+
+SimplifiedOperatorBuilder* JSBuiltinReducer::simplified() const {
+ return jsgraph()->simplified();
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8