Merge V8 5.4.500.40

Test: Manual - built & ran d8
Change-Id: I4edfa2853d3e565b729723645395688ece3193f4
diff --git a/src/compiler/js-inlining.cc b/src/compiler/js-inlining.cc
index 0664105..635daa4 100644
--- a/src/compiler/js-inlining.cc
+++ b/src/compiler/js-inlining.cc
@@ -16,9 +16,10 @@
 #include "src/compiler/node-matchers.h"
 #include "src/compiler/node-properties.h"
 #include "src/compiler/operator-properties.h"
+#include "src/compiler/simplified-operator.h"
 #include "src/compiler/type-hint-analyzer.h"
 #include "src/isolate-inl.h"
-#include "src/parsing/parser.h"
+#include "src/parsing/parse-info.h"
 #include "src/parsing/rewriter.h"
 
 namespace v8 {
@@ -57,7 +58,7 @@
 
   Node* frame_state() {
     // Both, {JSCallFunction} and {JSCallConstruct}, have frame state.
-    return NodeProperties::GetFrameStateInput(call_, 0);
+    return NodeProperties::GetFrameStateInput(call_);
   }
 
   int formal_arguments() {
@@ -106,13 +107,13 @@
           Replace(use, new_target);
         } else if (index == inlinee_arity_index) {
           // The projection is requesting the number of arguments.
-          Replace(use, jsgraph_->Int32Constant(inliner_inputs - 2));
+          Replace(use, jsgraph()->Int32Constant(inliner_inputs - 2));
         } else if (index == inlinee_context_index) {
           // The projection is requesting the inlinee function context.
           Replace(use, context);
         } else {
           // Call has fewer arguments than required, fill with undefined.
-          Replace(use, jsgraph_->UndefinedConstant());
+          Replace(use, jsgraph()->UndefinedConstant());
         }
         break;
       }
@@ -143,9 +144,8 @@
       case IrOpcode::kDeoptimize:
       case IrOpcode::kTerminate:
       case IrOpcode::kThrow:
-        NodeProperties::MergeControlToEnd(jsgraph_->graph(), jsgraph_->common(),
-                                          input);
-        Revisit(jsgraph_->graph()->end());
+        NodeProperties::MergeControlToEnd(graph(), common(), input);
+        Revisit(graph()->end());
         break;
       default:
         UNREACHABLE();
@@ -159,20 +159,20 @@
   // uses with said value or kill value uses if no value can be returned.
   if (values.size() > 0) {
     int const input_count = static_cast<int>(controls.size());
-    Node* control_output = jsgraph_->graph()->NewNode(
-        jsgraph_->common()->Merge(input_count), input_count, &controls.front());
+    Node* control_output = graph()->NewNode(common()->Merge(input_count),
+                                            input_count, &controls.front());
     values.push_back(control_output);
     effects.push_back(control_output);
-    Node* value_output = jsgraph_->graph()->NewNode(
-        jsgraph_->common()->Phi(MachineRepresentation::kTagged, input_count),
+    Node* value_output = graph()->NewNode(
+        common()->Phi(MachineRepresentation::kTagged, input_count),
         static_cast<int>(values.size()), &values.front());
-    Node* effect_output = jsgraph_->graph()->NewNode(
-        jsgraph_->common()->EffectPhi(input_count),
-        static_cast<int>(effects.size()), &effects.front());
+    Node* effect_output =
+        graph()->NewNode(common()->EffectPhi(input_count),
+                         static_cast<int>(effects.size()), &effects.front());
     ReplaceWithValue(call, value_output, effect_output, control_output);
     return Changed(value_output);
   } else {
-    ReplaceWithValue(call, call, call, jsgraph_->Dead());
+    ReplaceWithValue(call, call, call, jsgraph()->Dead());
     return Changed(call);
   }
 }
@@ -183,24 +183,24 @@
                                             FrameStateType frame_state_type,
                                             Handle<SharedFunctionInfo> shared) {
   const FrameStateFunctionInfo* state_info =
-      jsgraph_->common()->CreateFrameStateFunctionInfo(
-          frame_state_type, parameter_count + 1, 0, shared);
+      common()->CreateFrameStateFunctionInfo(frame_state_type,
+                                             parameter_count + 1, 0, shared);
 
-  const Operator* op = jsgraph_->common()->FrameState(
+  const Operator* op = common()->FrameState(
       BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info);
-  const Operator* op0 = jsgraph_->common()->StateValues(0);
-  Node* node0 = jsgraph_->graph()->NewNode(op0);
+  const Operator* op0 = common()->StateValues(0);
+  Node* node0 = graph()->NewNode(op0);
   NodeVector params(local_zone_);
   for (int parameter = 0; parameter < parameter_count + 1; ++parameter) {
     params.push_back(node->InputAt(1 + parameter));
   }
   const Operator* op_param =
-      jsgraph_->common()->StateValues(static_cast<int>(params.size()));
-  Node* params_node = jsgraph_->graph()->NewNode(
+      common()->StateValues(static_cast<int>(params.size()));
+  Node* params_node = graph()->NewNode(
       op_param, static_cast<int>(params.size()), &params.front());
-  return jsgraph_->graph()->NewNode(op, params_node, node0, node0,
-                                    jsgraph_->UndefinedConstant(),
-                                    node->InputAt(0), outer_frame_state);
+  return graph()->NewNode(op, params_node, node0, node0,
+                          jsgraph()->UndefinedConstant(), node->InputAt(0),
+                          outer_frame_state);
 }
 
 Node* JSInliner::CreateTailCallerFrameState(Node* node, Node* frame_state) {
@@ -212,25 +212,25 @@
 
   // If we are inlining a tail call drop caller's frame state and an
   // arguments adaptor if it exists.
-  frame_state = NodeProperties::GetFrameStateInput(frame_state, 0);
+  frame_state = NodeProperties::GetFrameStateInput(frame_state);
   if (frame_state->opcode() == IrOpcode::kFrameState) {
     FrameStateInfo const& frame_info = OpParameter<FrameStateInfo>(frame_state);
     if (frame_info.type() == FrameStateType::kArgumentsAdaptor) {
-      frame_state = NodeProperties::GetFrameStateInput(frame_state, 0);
+      frame_state = NodeProperties::GetFrameStateInput(frame_state);
     }
   }
 
   const FrameStateFunctionInfo* state_info =
-      jsgraph_->common()->CreateFrameStateFunctionInfo(
+      common()->CreateFrameStateFunctionInfo(
           FrameStateType::kTailCallerFunction, 0, 0, shared);
 
-  const Operator* op = jsgraph_->common()->FrameState(
+  const Operator* op = common()->FrameState(
       BailoutId(-1), OutputFrameStateCombine::Ignore(), state_info);
-  const Operator* op0 = jsgraph_->common()->StateValues(0);
-  Node* node0 = jsgraph_->graph()->NewNode(op0);
-  return jsgraph_->graph()->NewNode(op, node0, node0, node0,
-                                    jsgraph_->UndefinedConstant(), function,
-                                    frame_state);
+  const Operator* op0 = common()->StateValues(0);
+  Node* node0 = graph()->NewNode(op0);
+  return graph()->NewNode(op, node0, node0, node0,
+                          jsgraph()->UndefinedConstant(), function,
+                          frame_state);
 }
 
 namespace {
@@ -417,7 +417,7 @@
   }
 
   Node* frame_state = call.frame_state();
-  Node* new_target = jsgraph_->UndefinedConstant();
+  Node* new_target = jsgraph()->UndefinedConstant();
 
   // Inline {JSCallConstruct} requires some additional magic.
   if (node->opcode() == IrOpcode::kJSCallConstruct) {
@@ -425,28 +425,26 @@
     // constructor dispatch (allocate implicit receiver and check return value).
     // This models the behavior usually accomplished by our {JSConstructStub}.
     // Note that the context has to be the callers context (input to call node).
-    Node* receiver = jsgraph_->UndefinedConstant();  // Implicit receiver.
+    Node* receiver = jsgraph()->UndefinedConstant();  // Implicit receiver.
     if (NeedsImplicitReceiver(shared_info)) {
       Node* frame_state_before = NodeProperties::FindFrameStateBefore(node);
       Node* effect = NodeProperties::GetEffectInput(node);
       Node* context = NodeProperties::GetContextInput(node);
-      Node* create = jsgraph_->graph()->NewNode(
-          jsgraph_->javascript()->Create(), call.target(), call.new_target(),
-          context, frame_state_before, effect);
+      Node* create = graph()->NewNode(javascript()->Create(), call.target(),
+                                      call.new_target(), context,
+                                      frame_state_before, effect);
       NodeProperties::ReplaceEffectInput(node, create);
       // Insert a check of the return value to determine whether the return
-      // value
-      // or the implicit receiver should be selected as a result of the call.
-      Node* check = jsgraph_->graph()->NewNode(
-          jsgraph_->javascript()->CallRuntime(Runtime::kInlineIsJSReceiver, 1),
-          node, context, node, start);
-      Node* select = jsgraph_->graph()->NewNode(
-          jsgraph_->common()->Select(MachineRepresentation::kTagged), check,
-          node, create);
-      NodeProperties::ReplaceUses(node, select, check, node, node);
-      NodeProperties::ReplaceValueInput(select, node, 1);
-      NodeProperties::ReplaceValueInput(check, node, 0);
-      NodeProperties::ReplaceEffectInput(check, node);
+      // value or the implicit receiver should be selected as a result of the
+      // call.
+      Node* check = graph()->NewNode(simplified()->ObjectIsReceiver(), node);
+      Node* select =
+          graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
+                           check, node, create);
+      NodeProperties::ReplaceUses(node, select, node, node, node);
+      // Fix-up inputs that have been mangled by the {ReplaceUses} call above.
+      NodeProperties::ReplaceValueInput(select, node, 1);  // Fix-up input.
+      NodeProperties::ReplaceValueInput(check, node, 0);   // Fix-up input.
       receiver = create;  // The implicit receiver.
     }
 
@@ -455,7 +453,7 @@
     // behaves as if we were dealing with a regular function invocation.
     new_target = call.new_target();  // Retrieve new target value input.
     node->RemoveInput(call.formal_arguments() + 1);  // Drop new target.
-    node->InsertInput(jsgraph_->graph()->zone(), 1, receiver);
+    node->InsertInput(graph()->zone(), 1, receiver);
 
     // Insert a construct stub frame into the chain of frame states. This will
     // reconstruct the proper frame when deoptimizing within the constructor.
@@ -468,7 +466,7 @@
   // TODO(turbofan): We might want to load the context from the JSFunction at
   // runtime in case we only know the SharedFunctionInfo once we have dynamic
   // type feedback in the compiler.
-  Node* context = jsgraph_->Constant(handle(function->context()));
+  Node* context = jsgraph()->Constant(handle(function->context()));
 
   // Insert a JSConvertReceiver node for sloppy callees. Note that the context
   // passed into this node has to be the callees context (loaded above). Note
@@ -481,9 +479,9 @@
     const CallFunctionParameters& p = CallFunctionParametersOf(node->op());
     Node* frame_state_before = NodeProperties::FindFrameStateBefore(node);
     Node* effect = NodeProperties::GetEffectInput(node);
-    Node* convert = jsgraph_->graph()->NewNode(
-        jsgraph_->javascript()->ConvertReceiver(p.convert_mode()),
-        call.receiver(), context, frame_state_before, effect, start);
+    Node* convert = graph()->NewNode(
+        javascript()->ConvertReceiver(p.convert_mode()), call.receiver(),
+        context, frame_state_before, effect, start);
     NodeProperties::ReplaceValueInput(node, convert, 1);
     NodeProperties::ReplaceEffectInput(node, convert);
   }
@@ -519,6 +517,16 @@
 
 Graph* JSInliner::graph() const { return jsgraph()->graph(); }
 
+JSOperatorBuilder* JSInliner::javascript() const {
+  return jsgraph()->javascript();
+}
+
+CommonOperatorBuilder* JSInliner::common() const { return jsgraph()->common(); }
+
+SimplifiedOperatorBuilder* JSInliner::simplified() const {
+  return jsgraph()->simplified();
+}
+
 }  // namespace compiler
 }  // namespace internal
 }  // namespace v8