LCOV - code coverage report
Current view: top level - src/compiler - js-generic-lowering.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 496 568 87.3 %
Date: 2019-04-17 Functions: 84 117 71.8 %

          Line data    Source code
       1             : // Copyright 2014 the V8 project authors. All rights reserved.
       2             : // Use of this source code is governed by a BSD-style license that can be
       3             : // found in the LICENSE file.
       4             : 
       5             : #include "src/compiler/js-generic-lowering.h"
       6             : 
       7             : #include "src/ast/ast.h"
       8             : #include "src/builtins/builtins-constructor.h"
       9             : #include "src/code-factory.h"
      10             : #include "src/compiler/common-operator.h"
      11             : #include "src/compiler/js-graph.h"
      12             : #include "src/compiler/machine-operator.h"
      13             : #include "src/compiler/node-matchers.h"
      14             : #include "src/compiler/node-properties.h"
      15             : #include "src/compiler/operator-properties.h"
      16             : #include "src/feedback-vector.h"
      17             : #include "src/objects/feedback-cell.h"
      18             : #include "src/objects/scope-info.h"
      19             : 
      20             : namespace v8 {
      21             : namespace internal {
      22             : namespace compiler {
      23             : 
      24             : namespace {
      25             : 
      26             : CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
      27     3394691 :   return OperatorProperties::HasFrameStateInput(node->op())
      28             :              ? CallDescriptor::kNeedsFrameState
      29     3394699 :              : CallDescriptor::kNoFlags;
      30             : }
      31             : 
      32             : }  // namespace
      33             : 
      34      464159 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor)
      35      464159 :     : AdvancedReducer(editor), jsgraph_(jsgraph) {}
      36             : 
      37             : JSGenericLowering::~JSGenericLowering() = default;
      38             : 
      39             : 
      40    44356873 : Reduction JSGenericLowering::Reduce(Node* node) {
      41    44356873 :   switch (node->opcode()) {
      42             : #define DECLARE_CASE(x)  \
      43             :     case IrOpcode::k##x: \
      44             :       Lower##x(node);    \
      45             :       break;
      46       12078 :     JS_OP_LIST(DECLARE_CASE)
      47             : #undef DECLARE_CASE
      48             :     default:
      49             :       // Nothing to see.
      50             :       return NoChange();
      51             :   }
      52             :   return Changed(node);
      53             : }
      54             : 
      55             : #define REPLACE_STUB_CALL(Name)                                              \
      56             :   void JSGenericLowering::LowerJS##Name(Node* node) {                        \
      57             :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);               \
      58             :     Callable callable = Builtins::CallableFor(isolate(), Builtins::k##Name); \
      59             :     ReplaceWithStubCall(node, callable, flags);                              \
      60             :   }
      61      173175 : REPLACE_STUB_CALL(Add)
      62       26145 : REPLACE_STUB_CALL(Subtract)
      63       29845 : REPLACE_STUB_CALL(Multiply)
      64       53670 : REPLACE_STUB_CALL(Divide)
      65        3105 : REPLACE_STUB_CALL(Modulus)
      66         755 : REPLACE_STUB_CALL(Exponentiate)
      67       35820 : REPLACE_STUB_CALL(BitwiseAnd)
      68       44810 : REPLACE_STUB_CALL(BitwiseOr)
      69        1285 : REPLACE_STUB_CALL(BitwiseXor)
      70       10375 : REPLACE_STUB_CALL(ShiftLeft)
      71        2640 : REPLACE_STUB_CALL(ShiftRight)
      72        4795 : REPLACE_STUB_CALL(ShiftRightLogical)
      73       95955 : REPLACE_STUB_CALL(LessThan)
      74        7270 : REPLACE_STUB_CALL(LessThanOrEqual)
      75       85425 : REPLACE_STUB_CALL(GreaterThan)
      76        7850 : REPLACE_STUB_CALL(GreaterThanOrEqual)
      77         660 : REPLACE_STUB_CALL(BitwiseNot)
      78       10250 : REPLACE_STUB_CALL(Decrement)
      79       52275 : REPLACE_STUB_CALL(Increment)
      80       19685 : REPLACE_STUB_CALL(Negate)
      81        7930 : REPLACE_STUB_CALL(HasProperty)
      82       46000 : REPLACE_STUB_CALL(Equal)
      83         135 : REPLACE_STUB_CALL(ToLength)
      84       38065 : REPLACE_STUB_CALL(ToNumber)
      85         360 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
      86       15025 : REPLACE_STUB_CALL(ToNumeric)
      87        5420 : REPLACE_STUB_CALL(ToName)
      88           0 : REPLACE_STUB_CALL(ToObject)
      89       10615 : REPLACE_STUB_CALL(ToString)
      90        7190 : REPLACE_STUB_CALL(ForInEnumerate)
      91         615 : REPLACE_STUB_CALL(AsyncFunctionEnter)
      92         530 : REPLACE_STUB_CALL(AsyncFunctionReject)
      93         555 : REPLACE_STUB_CALL(AsyncFunctionResolve)
      94        3745 : REPLACE_STUB_CALL(FulfillPromise)
      95         895 : REPLACE_STUB_CALL(PerformPromiseThen)
      96         470 : REPLACE_STUB_CALL(PromiseResolve)
      97        5450 : REPLACE_STUB_CALL(RejectPromise)
      98        1415 : REPLACE_STUB_CALL(ResolvePromise)
      99             : #undef REPLACE_STUB_CALL
     100             : 
     101     2016002 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     102             :                                             Callable callable,
     103             :                                             CallDescriptor::Flags flags) {
     104     4032006 :   ReplaceWithStubCall(node, callable, flags, node->op()->properties());
     105     2016004 : }
     106             : 
     107     2103386 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     108             :                                             Callable callable,
     109             :                                             CallDescriptor::Flags flags,
     110             :                                             Operator::Properties properties) {
     111             :   const CallInterfaceDescriptor& descriptor = callable.descriptor();
     112             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     113             :       zone(), descriptor, descriptor.GetStackParameterCount(), flags,
     114     2103386 :       properties);
     115     2103386 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     116     2103385 :   node->InsertInput(zone(), 0, stub_code);
     117     2103389 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     118     2103388 : }
     119             : 
     120             : 
     121      875359 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
     122             :                                                Runtime::FunctionId f,
     123             :                                                int nargs_override) {
     124      875366 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     125      875366 :   Operator::Properties properties = node->op()->properties();
     126      875366 :   const Runtime::Function* fun = Runtime::FunctionForId(f);
     127      875358 :   int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
     128             :   auto call_descriptor =
     129      875358 :       Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
     130      875360 :   Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
     131      875365 :   Node* arity = jsgraph()->Int32Constant(nargs);
     132      875362 :   node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
     133      875366 :   node->InsertInput(zone(), nargs + 1, ref);
     134      875366 :   node->InsertInput(zone(), nargs + 2, arity);
     135      875365 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     136      875359 : }
     137             : 
     138       87384 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
     139             :   // The === operator doesn't need the current context.
     140       87384 :   NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
     141       87384 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
     142       87384 :   node->RemoveInput(4);  // control
     143       87384 :   ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
     144       87384 :                       Operator::kEliminatable);
     145       87384 : }
     146             : 
     147       39198 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
     148       39198 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     149       39198 :   const PropertyAccess& p = PropertyAccessOf(node->op());
     150       39198 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     151             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     152       78396 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     153       39198 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     154             :     Callable callable = Builtins::CallableFor(
     155             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     156             :                        ? Builtins::kKeyedLoadICTrampoline_Megamorphic
     157       36970 :                        : Builtins::kKeyedLoadICTrampoline);
     158       73940 :     ReplaceWithStubCall(node, callable, flags);
     159             :   } else {
     160             :     Callable callable = Builtins::CallableFor(
     161             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     162             :                        ? Builtins::kKeyedLoadIC_Megamorphic
     163        2228 :                        : Builtins::kKeyedLoadIC);
     164        2228 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     165        2228 :     node->InsertInput(zone(), 3, vector);
     166        4456 :     ReplaceWithStubCall(node, callable, flags);
     167             :   }
     168       39198 : }
     169             : 
     170      439184 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
     171      439184 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     172      439184 :   NamedAccess const& p = NamedAccessOf(node->op());
     173      439184 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     174             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     175      439184 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     176      439184 :   if (!p.feedback().IsValid()) {
     177             :     Callable callable =
     178      180350 :         Builtins::CallableFor(isolate(), Builtins::kGetProperty);
     179      360700 :     ReplaceWithStubCall(node, callable, flags);
     180             :     return;
     181             :   }
     182      517668 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     183      258834 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     184             :     Callable callable = Builtins::CallableFor(
     185             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     186             :                        ? Builtins::kLoadICTrampoline_Megamorphic
     187      256032 :                        : Builtins::kLoadICTrampoline);
     188      512064 :     ReplaceWithStubCall(node, callable, flags);
     189             :   } else {
     190             :     Callable callable =
     191             :         Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
     192             :                                              ? Builtins::kLoadIC_Megamorphic
     193        2802 :                                              : Builtins::kLoadIC);
     194        2802 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     195        2802 :     node->InsertInput(zone(), 3, vector);
     196        5604 :     ReplaceWithStubCall(node, callable, flags);
     197             :   }
     198             : }
     199             : 
     200      560234 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
     201      560234 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     202      560234 :   const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
     203      560234 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     204             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     205      560234 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     206     1120468 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     207      560234 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     208      548344 :     Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
     209     1096688 :     ReplaceWithStubCall(node, callable, flags);
     210             :   } else {
     211             :     Callable callable =
     212       11890 :         CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
     213       11890 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     214       11890 :     node->InsertInput(zone(), 2, vector);
     215       23780 :     ReplaceWithStubCall(node, callable, flags);
     216             :   }
     217      560234 : }
     218             : 
     219        8817 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
     220        8817 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     221        8817 :   PropertyAccess const& p = PropertyAccessOf(node->op());
     222        8817 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     223             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     224       17634 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     225        8817 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     226             :     Callable callable =
     227        8560 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
     228       17120 :     ReplaceWithStubCall(node, callable, flags);
     229             :   } else {
     230             :     Callable callable =
     231         257 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
     232         257 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     233         257 :     node->InsertInput(zone(), 4, vector);
     234         514 :     ReplaceWithStubCall(node, callable, flags);
     235             :   }
     236        8817 : }
     237             : 
     238       82532 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
     239       82532 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     240       82532 :   NamedAccess const& p = NamedAccessOf(node->op());
     241       82532 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     242             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     243       82532 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     244       82532 :   if (!p.feedback().IsValid()) {
     245       19343 :     ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
     246       19343 :     return;
     247             :   }
     248      126378 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     249       63189 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     250             :     Callable callable =
     251       57818 :         Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
     252      115636 :     ReplaceWithStubCall(node, callable, flags);
     253             :   } else {
     254        5371 :     Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
     255        5371 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     256        5371 :     node->InsertInput(zone(), 4, vector);
     257       10742 :     ReplaceWithStubCall(node, callable, flags);
     258             :   }
     259             : }
     260             : 
     261       30781 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
     262       30781 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     263       30781 :   StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
     264       30781 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     265             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     266       30781 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     267       61562 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     268       30781 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     269       30748 :     Callable callable = CodeFactory::StoreOwnIC(isolate());
     270       61496 :     ReplaceWithStubCall(node, callable, flags);
     271             :   } else {
     272          33 :     Callable callable = CodeFactory::StoreOwnICInOptimizedCode(isolate());
     273          33 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     274          33 :     node->InsertInput(zone(), 4, vector);
     275          66 :     ReplaceWithStubCall(node, callable, flags);
     276             :   }
     277       30781 : }
     278             : 
     279      208349 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
     280      208349 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     281      208349 :   const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
     282      208349 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     283             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     284      208349 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     285      416698 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     286      208349 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     287             :     Callable callable =
     288      208314 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
     289      416628 :     ReplaceWithStubCall(node, callable, flags);
     290             :   } else {
     291             :     Callable callable =
     292          35 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
     293          35 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     294          35 :     node->InsertInput(zone(), 3, vector);
     295          70 :     ReplaceWithStubCall(node, callable, flags);
     296             :   }
     297      208349 : }
     298             : 
     299         447 : void JSGenericLowering::LowerJSStoreDataPropertyInLiteral(Node* node) {
     300         447 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     301         447 :   node->InsertInputs(zone(), 4, 2);
     302         447 :   node->ReplaceInput(4, jsgraph()->HeapConstant(p.feedback().vector()));
     303         894 :   node->ReplaceInput(5, jsgraph()->SmiConstant(p.feedback().index()));
     304         447 :   ReplaceWithRuntimeCall(node, Runtime::kDefineDataPropertyInLiteral);
     305         447 : }
     306             : 
     307       49633 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
     308             :   Callable callable =
     309       49633 :       Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
     310       49633 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     311       49633 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     312             :   RelaxControls(node);
     313       99266 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     314       49633 :   node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
     315       99266 :   ReplaceWithStubCall(node, callable, flags);
     316       49633 : }
     317             : 
     318        1082 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
     319        1082 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     320             :   Callable callable =
     321        1082 :       Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
     322        2164 :   ReplaceWithStubCall(node, callable, flags);
     323        1082 : }
     324             : 
     325          77 : void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
     326          77 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     327             :   Callable callable =
     328          77 :       Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
     329         154 :   ReplaceWithStubCall(node, callable, flags);
     330          77 : }
     331             : 
     332           0 : void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
     333           0 :   ReplaceWithRuntimeCall(node, Runtime::kHasInPrototypeChain);
     334           0 : }
     335             : 
     336        2878 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
     337        2878 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     338        2878 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
     339        5756 :   ReplaceWithStubCall(node, callable, flags);
     340        2878 : }
     341             : 
     342          89 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
     343          89 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     344             :   Callable callable =
     345          89 :       Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
     346         178 :   ReplaceWithStubCall(node, callable, flags);
     347          89 : }
     348             : 
     349           0 : void JSGenericLowering::LowerJSLoadContext(Node* node) {
     350           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     351             : }
     352             : 
     353             : 
     354           0 : void JSGenericLowering::LowerJSStoreContext(Node* node) {
     355           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     356             : }
     357             : 
     358             : 
     359         276 : void JSGenericLowering::LowerJSCreate(Node* node) {
     360         276 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     361             :   Callable callable =
     362         276 :       Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
     363         552 :   ReplaceWithStubCall(node, callable, flags);
     364         276 : }
     365             : 
     366             : 
     367           8 : void JSGenericLowering::LowerJSCreateArguments(Node* node) {
     368           8 :   CreateArgumentsType const type = CreateArgumentsTypeOf(node->op());
     369           8 :   switch (type) {
     370             :     case CreateArgumentsType::kMappedArguments:
     371           8 :       ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
     372           8 :       break;
     373             :     case CreateArgumentsType::kUnmappedArguments:
     374           0 :       ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments);
     375           0 :       break;
     376             :     case CreateArgumentsType::kRestParameter:
     377           0 :       ReplaceWithRuntimeCall(node, Runtime::kNewRestParameter);
     378           0 :       break;
     379             :   }
     380           8 : }
     381             : 
     382             : 
     383         167 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
     384         167 :   CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
     385         167 :   int const arity = static_cast<int>(p.arity());
     386         334 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     387             :       zone(), ArrayConstructorDescriptor{}, arity + 1,
     388         167 :       CallDescriptor::kNeedsFrameState, node->op()->properties());
     389         167 :   Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
     390         167 :   Node* stub_arity = jsgraph()->Int32Constant(arity);
     391             :   MaybeHandle<AllocationSite> const maybe_site = p.site();
     392             :   Handle<AllocationSite> site;
     393             :   Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
     394         248 :                                                : jsgraph()->UndefinedConstant();
     395         167 :   Node* receiver = jsgraph()->UndefinedConstant();
     396         167 :   node->InsertInput(zone(), 0, stub_code);
     397         167 :   node->InsertInput(zone(), 3, stub_arity);
     398         167 :   node->InsertInput(zone(), 4, type_info);
     399         167 :   node->InsertInput(zone(), 5, receiver);
     400         167 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     401         167 : }
     402             : 
     403           0 : void JSGenericLowering::LowerJSCreateArrayIterator(Node* node) {
     404           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     405             : }
     406             : 
     407           0 : void JSGenericLowering::LowerJSCreateAsyncFunctionObject(Node* node) {
     408           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     409             : }
     410             : 
     411           0 : void JSGenericLowering::LowerJSCreateCollectionIterator(Node* node) {
     412           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     413             : }
     414             : 
     415           0 : void JSGenericLowering::LowerJSCreateBoundFunction(Node* node) {
     416           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     417             : }
     418             : 
     419           0 : void JSGenericLowering::LowerJSObjectIsArray(Node* node) {
     420           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     421             : }
     422             : 
     423          60 : void JSGenericLowering::LowerJSCreateObject(Node* node) {
     424          60 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     425             :   Callable callable = Builtins::CallableFor(
     426          60 :       isolate(), Builtins::kCreateObjectWithoutProperties);
     427         120 :   ReplaceWithStubCall(node, callable, flags);
     428          60 : }
     429             : 
     430         185 : void JSGenericLowering::LowerJSParseInt(Node* node) {
     431         185 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     432         185 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
     433         370 :   ReplaceWithStubCall(node, callable, flags);
     434         185 : }
     435             : 
     436         494 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
     437         494 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     438             :   Callable callable =
     439         494 :       Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
     440         988 :   ReplaceWithStubCall(node, callable, flags);
     441         494 : }
     442             : 
     443      410165 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
     444      410165 :   CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
     445             :   Handle<SharedFunctionInfo> const shared_info = p.shared_info();
     446      410166 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
     447      410167 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
     448      410167 :   node->RemoveInput(4);  // control
     449             : 
     450             :   // Use the FastNewClosure builtin only for functions allocated in new space.
     451      410167 :   if (p.allocation() == AllocationType::kYoung) {
     452             :     Callable callable =
     453      396671 :         Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
     454      396671 :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     455      793342 :     ReplaceWithStubCall(node, callable, flags);
     456             :   } else {
     457       13496 :     ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
     458             :   }
     459      410167 : }
     460             : 
     461             : 
     462        4775 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
     463             :   const CreateFunctionContextParameters& parameters =
     464        4775 :       CreateFunctionContextParametersOf(node->op());
     465             :   Handle<ScopeInfo> scope_info = parameters.scope_info();
     466             :   int slot_count = parameters.slot_count();
     467             :   ScopeType scope_type = parameters.scope_type();
     468        4775 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     469             : 
     470        4775 :   if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
     471             :     Callable callable =
     472        4775 :         CodeFactory::FastNewFunctionContext(isolate(), scope_type);
     473        4775 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     474        4775 :     node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
     475        9550 :     ReplaceWithStubCall(node, callable, flags);
     476             :   } else {
     477           0 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     478           0 :     ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
     479             :   }
     480        4775 : }
     481             : 
     482         791 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
     483         791 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     484             :   Callable callable =
     485         791 :       Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
     486         791 :   node->RemoveInput(4);  // control
     487        1582 :   ReplaceWithStubCall(node, callable, flags);
     488         791 : }
     489             : 
     490           0 : void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
     491           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     492             : }
     493             : 
     494           0 : void JSGenericLowering::LowerJSCreateStringIterator(Node* node) {
     495           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     496             : }
     497             : 
     498           0 : void JSGenericLowering::LowerJSCreateKeyValueArray(Node* node) {
     499           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     500             : }
     501             : 
     502           0 : void JSGenericLowering::LowerJSCreatePromise(Node* node) {
     503           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     504             : }
     505             : 
     506         648 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
     507         648 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     508             :   Callable callable =
     509         648 :       Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
     510        1296 :   ReplaceWithStubCall(node, callable, flags);
     511         648 : }
     512             : 
     513        5621 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
     514        5621 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     515        5621 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     516        5621 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     517       11242 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     518        5621 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     519             : 
     520             :   // Use the CreateShallowArrayLiteratlr builtin only for shallow boilerplates
     521             :   // without properties up to the number of elements that the stubs can handle.
     522        5621 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     523             :       p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
     524             :     Callable callable =
     525        5224 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
     526       10448 :     ReplaceWithStubCall(node, callable, flags);
     527             :   } else {
     528         397 :     node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     529         397 :     ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
     530             :   }
     531        5621 : }
     532             : 
     533       21408 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
     534       21408 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     535       21408 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     536       21408 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     537       42816 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     538       21408 :   node->RemoveInput(4);  // control
     539             :   Callable callable =
     540       21408 :       Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
     541       42816 :   ReplaceWithStubCall(node, callable, flags);
     542       21408 : }
     543             : 
     544         545 : void JSGenericLowering::LowerJSCreateArrayFromIterable(Node* node) {
     545         545 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     546             :   Callable callable = Builtins::CallableFor(
     547         545 :       isolate(), Builtins::kIterableToListWithSymbolLookup);
     548        1090 :   ReplaceWithStubCall(node, callable, flags);
     549         545 : }
     550             : 
     551       13062 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
     552       13062 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     553       13062 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     554       13062 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     555       26124 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     556       13062 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     557       13062 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     558             : 
     559             :   // Use the CreateShallowObjectLiteratal builtin only for shallow boilerplates
     560             :   // without elements up to the number of properties that the stubs can handle.
     561       13062 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     562             :       p.length() <=
     563             :           ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
     564             :     Callable callable =
     565       12468 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
     566       24936 :     ReplaceWithStubCall(node, callable, flags);
     567             :   } else {
     568         594 :     ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
     569             :   }
     570       13062 : }
     571             : 
     572          94 : void JSGenericLowering::LowerJSCloneObject(Node* node) {
     573          94 :   CloneObjectParameters const& p = CloneObjectParametersOf(node->op());
     574          94 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     575             :   Callable callable =
     576          94 :       Builtins::CallableFor(isolate(), Builtins::kCloneObjectIC);
     577          94 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.flags()));
     578         188 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     579          94 :   node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector()));
     580         188 :   ReplaceWithStubCall(node, callable, flags);
     581          94 : }
     582             : 
     583           0 : void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
     584           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     585             : }
     586             : 
     587        5899 : void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
     588        5899 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     589        5899 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     590             :   Callable callable =
     591        5899 :       Builtins::CallableFor(isolate(), Builtins::kCreateRegExpLiteral);
     592        5899 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     593       11798 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     594        5899 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     595        5899 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     596       11798 :   ReplaceWithStubCall(node, callable, flags);
     597        5899 : }
     598             : 
     599             : 
     600           0 : void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
     601           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     602             : }
     603             : 
     604           0 : void JSGenericLowering::LowerJSCreateWithContext(Node* node) {
     605           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     606             : }
     607             : 
     608           0 : void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
     609           0 :   Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
     610           0 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     611           0 :   ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
     612           0 : }
     613             : 
     614          40 : void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) {
     615             :   ConstructForwardVarargsParameters p =
     616          40 :       ConstructForwardVarargsParametersOf(node->op());
     617          40 :   int const arg_count = static_cast<int>(p.arity() - 2);
     618          40 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     619          40 :   Callable callable = CodeFactory::ConstructForwardVarargs(isolate());
     620          80 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     621          80 :       zone(), callable.descriptor(), arg_count + 1, flags);
     622          40 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     623          40 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     624          40 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     625             :   Node* new_target = node->InputAt(arg_count + 1);
     626          40 :   Node* receiver = jsgraph()->UndefinedConstant();
     627          40 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     628          40 :   node->InsertInput(zone(), 0, stub_code);
     629          40 :   node->InsertInput(zone(), 2, new_target);
     630          40 :   node->InsertInput(zone(), 3, stub_arity);
     631          40 :   node->InsertInput(zone(), 4, start_index);
     632          40 :   node->InsertInput(zone(), 5, receiver);
     633          40 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     634          40 : }
     635             : 
     636       32901 : void JSGenericLowering::LowerJSConstruct(Node* node) {
     637       32901 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     638       32901 :   int const arg_count = static_cast<int>(p.arity() - 2);
     639       32901 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     640       32901 :   Callable callable = CodeFactory::Construct(isolate());
     641       65802 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     642       65802 :       zone(), callable.descriptor(), arg_count + 1, flags);
     643       32901 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     644       32901 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     645             :   Node* new_target = node->InputAt(arg_count + 1);
     646       32901 :   Node* receiver = jsgraph()->UndefinedConstant();
     647       32901 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     648       32901 :   node->InsertInput(zone(), 0, stub_code);
     649       32901 :   node->InsertInput(zone(), 2, new_target);
     650       32901 :   node->InsertInput(zone(), 3, stub_arity);
     651       32901 :   node->InsertInput(zone(), 4, receiver);
     652       32901 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     653       32901 : }
     654             : 
     655          63 : void JSGenericLowering::LowerJSConstructWithArrayLike(Node* node) {
     656             :   Callable callable =
     657          63 :       Builtins::CallableFor(isolate(), Builtins::kConstructWithArrayLike);
     658          63 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     659             :   auto call_descriptor =
     660         126 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     661          63 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     662          63 :   Node* receiver = jsgraph()->UndefinedConstant();
     663             :   Node* arguments_list = node->InputAt(1);
     664             :   Node* new_target = node->InputAt(2);
     665          63 :   node->InsertInput(zone(), 0, stub_code);
     666          63 :   node->ReplaceInput(2, new_target);
     667          63 :   node->ReplaceInput(3, arguments_list);
     668          63 :   node->InsertInput(zone(), 4, receiver);
     669          63 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     670          63 : }
     671             : 
     672          65 : void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
     673          65 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     674          65 :   int const arg_count = static_cast<int>(p.arity() - 2);
     675             :   int const spread_index = arg_count;
     676          65 :   int const new_target_index = arg_count + 1;
     677          65 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     678          65 :   Callable callable = CodeFactory::ConstructWithSpread(isolate());
     679          65 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     680         130 :       zone(), callable.descriptor(), arg_count, flags);
     681          65 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     682          65 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     683             :   Node* new_target = node->InputAt(new_target_index);
     684             :   Node* spread = node->InputAt(spread_index);
     685          65 :   Node* receiver = jsgraph()->UndefinedConstant();
     686             :   DCHECK(new_target_index > spread_index);
     687          65 :   node->RemoveInput(new_target_index);  // Drop new target.
     688          65 :   node->RemoveInput(spread_index);
     689             : 
     690          65 :   node->InsertInput(zone(), 0, stub_code);
     691          65 :   node->InsertInput(zone(), 2, new_target);
     692          65 :   node->InsertInput(zone(), 3, stack_arg_count);
     693          65 :   node->InsertInput(zone(), 4, spread);
     694          65 :   node->InsertInput(zone(), 5, receiver);
     695          65 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     696          65 : }
     697             : 
     698          82 : void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) {
     699          82 :   CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op());
     700          82 :   int const arg_count = static_cast<int>(p.arity() - 2);
     701          82 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     702          82 :   Callable callable = CodeFactory::CallForwardVarargs(isolate());
     703         164 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     704         164 :       zone(), callable.descriptor(), arg_count + 1, flags);
     705          82 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     706          82 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     707          82 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     708          82 :   node->InsertInput(zone(), 0, stub_code);
     709          82 :   node->InsertInput(zone(), 2, stub_arity);
     710          82 :   node->InsertInput(zone(), 3, start_index);
     711          82 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     712          82 : }
     713             : 
     714      448588 : void JSGenericLowering::LowerJSCall(Node* node) {
     715      448588 :   CallParameters const& p = CallParametersOf(node->op());
     716      448588 :   int const arg_count = static_cast<int>(p.arity() - 2);
     717             :   ConvertReceiverMode const mode = p.convert_mode();
     718      448588 :   Callable callable = CodeFactory::Call(isolate(), mode);
     719      448588 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     720      897176 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     721      897176 :       zone(), callable.descriptor(), arg_count + 1, flags);
     722      448588 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     723      448588 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     724      448588 :   node->InsertInput(zone(), 0, stub_code);
     725      448588 :   node->InsertInput(zone(), 2, stub_arity);
     726      448588 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     727      448587 : }
     728             : 
     729         361 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
     730         361 :   Callable callable = CodeFactory::CallWithArrayLike(isolate());
     731         361 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     732             :   auto call_descriptor =
     733         722 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     734         361 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     735             :   Node* receiver = node->InputAt(1);
     736             :   Node* arguments_list = node->InputAt(2);
     737         361 :   node->InsertInput(zone(), 0, stub_code);
     738         361 :   node->ReplaceInput(3, receiver);
     739         361 :   node->ReplaceInput(2, arguments_list);
     740         361 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     741         361 : }
     742             : 
     743         894 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
     744         894 :   CallParameters const& p = CallParametersOf(node->op());
     745         894 :   int const arg_count = static_cast<int>(p.arity() - 2);
     746         894 :   int const spread_index = static_cast<int>(p.arity() + 1);
     747         894 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     748         894 :   Callable callable = CodeFactory::CallWithSpread(isolate());
     749         894 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     750        1788 :       zone(), callable.descriptor(), arg_count, flags);
     751         894 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     752             :   // We pass the spread in a register, not on the stack.
     753         894 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     754         894 :   node->InsertInput(zone(), 0, stub_code);
     755         894 :   node->InsertInput(zone(), 2, stack_arg_count);
     756         894 :   node->InsertInput(zone(), 3, node->InputAt(spread_index));
     757         894 :   node->RemoveInput(spread_index + 1);
     758         894 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     759         894 : }
     760             : 
     761      315092 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
     762      315092 :   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
     763      315092 :   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
     764      315092 : }
     765             : 
     766           0 : void JSGenericLowering::LowerJSForInNext(Node* node) {
     767           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     768             : }
     769             : 
     770           0 : void JSGenericLowering::LowerJSForInPrepare(Node* node) {
     771           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     772             : }
     773             : 
     774           0 : void JSGenericLowering::LowerJSLoadMessage(Node* node) {
     775           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     776             : }
     777             : 
     778             : 
     779           0 : void JSGenericLowering::LowerJSStoreMessage(Node* node) {
     780           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     781             : }
     782             : 
     783           0 : void JSGenericLowering::LowerJSLoadModule(Node* node) {
     784           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     785             : }
     786             : 
     787           0 : void JSGenericLowering::LowerJSStoreModule(Node* node) {
     788           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     789             : }
     790             : 
     791           0 : void JSGenericLowering::LowerJSGeneratorStore(Node* node) {
     792           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     793             : }
     794             : 
     795           0 : void JSGenericLowering::LowerJSGeneratorRestoreContinuation(Node* node) {
     796           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     797             : }
     798             : 
     799           0 : void JSGenericLowering::LowerJSGeneratorRestoreContext(Node* node) {
     800           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     801             : }
     802             : 
     803           0 : void JSGenericLowering::LowerJSGeneratorRestoreInputOrDebugPos(Node* node) {
     804           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     805             : }
     806             : 
     807           0 : void JSGenericLowering::LowerJSGeneratorRestoreRegister(Node* node) {
     808           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     809             : }
     810             : 
     811      525981 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
     812      525981 :   Node* effect = NodeProperties::GetEffectInput(node);
     813      525988 :   Node* control = NodeProperties::GetControlInput(node);
     814             : 
     815      525988 :   Node* limit = effect = graph()->NewNode(
     816             :       machine()->Load(MachineType::Pointer()),
     817             :       jsgraph()->ExternalConstant(
     818             :           ExternalReference::address_of_stack_limit(isolate())),
     819             :       jsgraph()->IntPtrConstant(0), effect, control);
     820      525990 :   Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
     821             : 
     822      525989 :   Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
     823             :   Node* branch =
     824      525990 :       graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
     825             : 
     826      525990 :   Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
     827             :   Node* etrue = effect;
     828             : 
     829      525989 :   Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
     830      525990 :   NodeProperties::ReplaceControlInput(node, if_false);
     831      525989 :   NodeProperties::ReplaceEffectInput(node, effect);
     832             :   Node* efalse = if_false = node;
     833             : 
     834      525990 :   Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
     835      525990 :   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
     836             : 
     837             :   // Wire the new diamond into the graph, {node} can still throw.
     838      525988 :   NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
     839      525984 :   NodeProperties::ReplaceControlInput(merge, if_false, 1);
     840      525988 :   NodeProperties::ReplaceEffectInput(ephi, efalse, 1);
     841             : 
     842             :   // This iteration cuts out potential {IfSuccess} or {IfException} projection
     843             :   // uses of the original node and places them inside the diamond, so that we
     844             :   // can change the original {node} into the slow-path runtime call.
     845     4192073 :   for (Edge edge : merge->use_edges()) {
     846     1833042 :     if (!NodeProperties::IsControlEdge(edge)) continue;
     847     1833041 :     if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
     848        7310 :       NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
     849        7310 :       NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
     850        7310 :       edge.UpdateTo(node);
     851             :     }
     852     1833036 :     if (edge.from()->opcode() == IrOpcode::kIfException) {
     853        7310 :       NodeProperties::ReplaceEffectInput(edge.from(), node);
     854        7310 :       edge.UpdateTo(node);
     855             :     }
     856             :   }
     857             : 
     858             :   // Turn the stack check into a runtime call.
     859      525989 :   ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
     860      525983 : }
     861             : 
     862         915 : void JSGenericLowering::LowerJSDebugger(Node* node) {
     863         915 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     864         915 :   Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
     865        1830 :   ReplaceWithStubCall(node, callable, flags);
     866         915 : }
     867             : 
     868           0 : Zone* JSGenericLowering::zone() const { return graph()->zone(); }
     869             : 
     870             : 
     871           0 : Isolate* JSGenericLowering::isolate() const { return jsgraph()->isolate(); }
     872             : 
     873             : 
     874           0 : Graph* JSGenericLowering::graph() const { return jsgraph()->graph(); }
     875             : 
     876             : 
     877           0 : CommonOperatorBuilder* JSGenericLowering::common() const {
     878           0 :   return jsgraph()->common();
     879             : }
     880             : 
     881             : 
     882           0 : MachineOperatorBuilder* JSGenericLowering::machine() const {
     883           0 :   return jsgraph()->machine();
     884             : }
     885             : 
     886             : }  // namespace compiler
     887             : }  // namespace internal
     888      122004 : }  // namespace v8

Generated by: LCOV version 1.10