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-18 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     3391553 :   return OperatorProperties::HasFrameStateInput(node->op())
      28             :              ? CallDescriptor::kNeedsFrameState
      29     3391554 :              : CallDescriptor::kNoFlags;
      30             : }
      31             : 
      32             : }  // namespace
      33             : 
      34      463655 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor)
      35      463655 :     : AdvancedReducer(editor), jsgraph_(jsgraph) {}
      36             : 
      37             : JSGenericLowering::~JSGenericLowering() = default;
      38             : 
      39             : 
      40    44347122 : Reduction JSGenericLowering::Reduce(Node* node) {
      41    44347122 :   switch (node->opcode()) {
      42             : #define DECLARE_CASE(x)  \
      43             :     case IrOpcode::k##x: \
      44             :       Lower##x(node);    \
      45             :       break;
      46       12072 :     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      173100 : REPLACE_STUB_CALL(Add)
      62       26120 : REPLACE_STUB_CALL(Subtract)
      63       29820 : REPLACE_STUB_CALL(Multiply)
      64       53660 : REPLACE_STUB_CALL(Divide)
      65        3110 : REPLACE_STUB_CALL(Modulus)
      66         755 : REPLACE_STUB_CALL(Exponentiate)
      67       35805 : REPLACE_STUB_CALL(BitwiseAnd)
      68       44770 : REPLACE_STUB_CALL(BitwiseOr)
      69        1285 : REPLACE_STUB_CALL(BitwiseXor)
      70       10345 : REPLACE_STUB_CALL(ShiftLeft)
      71        2640 : REPLACE_STUB_CALL(ShiftRight)
      72        4780 : REPLACE_STUB_CALL(ShiftRightLogical)
      73       95885 : REPLACE_STUB_CALL(LessThan)
      74        7270 : REPLACE_STUB_CALL(LessThanOrEqual)
      75       85105 : REPLACE_STUB_CALL(GreaterThan)
      76        7825 : REPLACE_STUB_CALL(GreaterThanOrEqual)
      77         660 : REPLACE_STUB_CALL(BitwiseNot)
      78       10250 : REPLACE_STUB_CALL(Decrement)
      79       52225 : REPLACE_STUB_CALL(Increment)
      80       19675 : REPLACE_STUB_CALL(Negate)
      81        7890 : REPLACE_STUB_CALL(HasProperty)
      82       45985 : REPLACE_STUB_CALL(Equal)
      83         135 : REPLACE_STUB_CALL(ToLength)
      84       38065 : REPLACE_STUB_CALL(ToNumber)
      85         360 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
      86       14995 : REPLACE_STUB_CALL(ToNumeric)
      87        5430 : REPLACE_STUB_CALL(ToName)
      88           0 : REPLACE_STUB_CALL(ToObject)
      89       10695 : REPLACE_STUB_CALL(ToString)
      90        7235 : 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         890 : REPLACE_STUB_CALL(PerformPromiseThen)
      96         470 : REPLACE_STUB_CALL(PromiseResolve)
      97        5445 : REPLACE_STUB_CALL(RejectPromise)
      98        1415 : REPLACE_STUB_CALL(ResolvePromise)
      99             : #undef REPLACE_STUB_CALL
     100             : 
     101     2013971 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     102             :                                             Callable callable,
     103             :                                             CallDescriptor::Flags flags) {
     104     4027943 :   ReplaceWithStubCall(node, callable, flags, node->op()->properties());
     105     2013972 : }
     106             : 
     107     2101435 : 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     2101435 :       properties);
     115     2101435 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     116     2101435 :   node->InsertInput(zone(), 0, stub_code);
     117     2101437 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     118     2101436 : }
     119             : 
     120             : 
     121      874967 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
     122             :                                                Runtime::FunctionId f,
     123             :                                                int nargs_override) {
     124      874968 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     125      874968 :   Operator::Properties properties = node->op()->properties();
     126      874968 :   const Runtime::Function* fun = Runtime::FunctionForId(f);
     127      874967 :   int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
     128             :   auto call_descriptor =
     129      874967 :       Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
     130      874971 :   Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
     131      874968 :   Node* arity = jsgraph()->Int32Constant(nargs);
     132      874966 :   node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
     133      874970 :   node->InsertInput(zone(), nargs + 1, ref);
     134      874972 :   node->InsertInput(zone(), nargs + 2, arity);
     135      874972 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     136      874968 : }
     137             : 
     138       87464 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
     139             :   // The === operator doesn't need the current context.
     140       87464 :   NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
     141       87464 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
     142       87464 :   node->RemoveInput(4);  // control
     143       87464 :   ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
     144       87464 :                       Operator::kEliminatable);
     145       87464 : }
     146             : 
     147       39254 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
     148       39254 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     149       39254 :   const PropertyAccess& p = PropertyAccessOf(node->op());
     150       39254 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     151             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     152       78508 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     153       39254 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     154             :     Callable callable = Builtins::CallableFor(
     155             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     156             :                        ? Builtins::kKeyedLoadICTrampoline_Megamorphic
     157       36975 :                        : Builtins::kKeyedLoadICTrampoline);
     158       73950 :     ReplaceWithStubCall(node, callable, flags);
     159             :   } else {
     160             :     Callable callable = Builtins::CallableFor(
     161             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     162             :                        ? Builtins::kKeyedLoadIC_Megamorphic
     163        2279 :                        : Builtins::kKeyedLoadIC);
     164        2279 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     165        2279 :     node->InsertInput(zone(), 3, vector);
     166        4558 :     ReplaceWithStubCall(node, callable, flags);
     167             :   }
     168       39254 : }
     169             : 
     170      438185 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
     171      438185 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     172      438185 :   NamedAccess const& p = NamedAccessOf(node->op());
     173      438185 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     174             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     175      438185 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     176      438185 :   if (!p.feedback().IsValid()) {
     177             :     Callable callable =
     178      180288 :         Builtins::CallableFor(isolate(), Builtins::kGetProperty);
     179      360576 :     ReplaceWithStubCall(node, callable, flags);
     180             :     return;
     181             :   }
     182      515794 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     183      257897 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     184             :     Callable callable = Builtins::CallableFor(
     185             :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     186             :                        ? Builtins::kLoadICTrampoline_Megamorphic
     187      255002 :                        : Builtins::kLoadICTrampoline);
     188      510004 :     ReplaceWithStubCall(node, callable, flags);
     189             :   } else {
     190             :     Callable callable =
     191             :         Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
     192             :                                              ? Builtins::kLoadIC_Megamorphic
     193        2895 :                                              : Builtins::kLoadIC);
     194        2895 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     195        2895 :     node->InsertInput(zone(), 3, vector);
     196        5790 :     ReplaceWithStubCall(node, callable, flags);
     197             :   }
     198             : }
     199             : 
     200      560129 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
     201      560129 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     202      560129 :   const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
     203      560129 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     204             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     205      560129 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     206     1120258 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     207      560129 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     208      548168 :     Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
     209     1096336 :     ReplaceWithStubCall(node, callable, flags);
     210             :   } else {
     211             :     Callable callable =
     212       11961 :         CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
     213       11961 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     214       11961 :     node->InsertInput(zone(), 2, vector);
     215       23922 :     ReplaceWithStubCall(node, callable, flags);
     216             :   }
     217      560129 : }
     218             : 
     219        8815 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
     220        8815 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     221        8815 :   PropertyAccess const& p = PropertyAccessOf(node->op());
     222        8815 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     223             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     224       17630 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     225        8815 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     226             :     Callable callable =
     227        8563 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
     228       17126 :     ReplaceWithStubCall(node, callable, flags);
     229             :   } else {
     230             :     Callable callable =
     231         252 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
     232         252 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     233         252 :     node->InsertInput(zone(), 4, vector);
     234         504 :     ReplaceWithStubCall(node, callable, flags);
     235             :   }
     236        8815 : }
     237             : 
     238       82230 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
     239       82230 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     240       82230 :   NamedAccess const& p = NamedAccessOf(node->op());
     241       82230 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     242             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     243       82230 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     244       82230 :   if (!p.feedback().IsValid()) {
     245       19341 :     ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
     246       19341 :     return;
     247             :   }
     248      125778 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     249       62889 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     250             :     Callable callable =
     251       57523 :         Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
     252      115046 :     ReplaceWithStubCall(node, callable, flags);
     253             :   } else {
     254        5366 :     Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
     255        5366 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     256        5366 :     node->InsertInput(zone(), 4, vector);
     257       10732 :     ReplaceWithStubCall(node, callable, flags);
     258             :   }
     259             : }
     260             : 
     261       30649 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
     262       30649 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     263       30649 :   StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
     264       30649 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     265             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     266       30649 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     267       61297 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     268       30649 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     269       30616 :     Callable callable = CodeFactory::StoreOwnIC(isolate());
     270       61231 :     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       30649 : }
     278             : 
     279      208302 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
     280      208302 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     281      208302 :   const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
     282      208302 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     283             :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     284      208302 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     285      416604 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     286      208302 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     287             :     Callable callable =
     288      208265 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
     289      416530 :     ReplaceWithStubCall(node, callable, flags);
     290             :   } else {
     291             :     Callable callable =
     292          37 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
     293          37 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     294          37 :     node->InsertInput(zone(), 3, vector);
     295          74 :     ReplaceWithStubCall(node, callable, flags);
     296             :   }
     297      208302 : }
     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       49519 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
     308             :   Callable callable =
     309       49519 :       Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
     310       49519 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     311       49519 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     312             :   RelaxControls(node);
     313       99038 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     314       49519 :   node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
     315       99038 :   ReplaceWithStubCall(node, callable, flags);
     316       49519 : }
     317             : 
     318        1113 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
     319        1113 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     320             :   Callable callable =
     321        1113 :       Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
     322        2226 :   ReplaceWithStubCall(node, callable, flags);
     323        1113 : }
     324             : 
     325          78 : void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
     326          78 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     327             :   Callable callable =
     328          78 :       Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
     329         156 :   ReplaceWithStubCall(node, callable, flags);
     330          78 : }
     331             : 
     332           0 : void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
     333           0 :   ReplaceWithRuntimeCall(node, Runtime::kHasInPrototypeChain);
     334           0 : }
     335             : 
     336        2875 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
     337        2875 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     338        2875 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
     339        5750 :   ReplaceWithStubCall(node, callable, flags);
     340        2875 : }
     341             : 
     342          88 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
     343          88 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     344             :   Callable callable =
     345          88 :       Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
     346         176 :   ReplaceWithStubCall(node, callable, flags);
     347          88 : }
     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         169 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
     384         169 :   CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
     385         169 :   int const arity = static_cast<int>(p.arity());
     386         338 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     387             :       zone(), ArrayConstructorDescriptor{}, arity + 1,
     388         169 :       CallDescriptor::kNeedsFrameState, node->op()->properties());
     389         169 :   Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
     390         169 :   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         252 :                                                : jsgraph()->UndefinedConstant();
     395         169 :   Node* receiver = jsgraph()->UndefinedConstant();
     396         169 :   node->InsertInput(zone(), 0, stub_code);
     397         169 :   node->InsertInput(zone(), 3, stub_arity);
     398         169 :   node->InsertInput(zone(), 4, type_info);
     399         169 :   node->InsertInput(zone(), 5, receiver);
     400         169 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     401         169 : }
     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         184 : void JSGenericLowering::LowerJSParseInt(Node* node) {
     431         184 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     432         184 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
     433         368 :   ReplaceWithStubCall(node, callable, flags);
     434         184 : }
     435             : 
     436         472 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
     437         472 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     438             :   Callable callable =
     439         472 :       Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
     440         944 :   ReplaceWithStubCall(node, callable, flags);
     441         472 : }
     442             : 
     443      410009 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
     444      410009 :   CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
     445             :   Handle<SharedFunctionInfo> const shared_info = p.shared_info();
     446      410009 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
     447      410010 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
     448      410010 :   node->RemoveInput(4);  // control
     449             : 
     450             :   // Use the FastNewClosure builtin only for functions allocated in new space.
     451      410010 :   if (p.allocation() == AllocationType::kYoung) {
     452             :     Callable callable =
     453      396515 :         Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
     454      396515 :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     455      793030 :     ReplaceWithStubCall(node, callable, flags);
     456             :   } else {
     457       13495 :     ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
     458             :   }
     459      410010 : }
     460             : 
     461             : 
     462        4774 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
     463             :   const CreateFunctionContextParameters& parameters =
     464        4774 :       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        4774 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     469             : 
     470        4774 :   if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
     471             :     Callable callable =
     472        4774 :         CodeFactory::FastNewFunctionContext(isolate(), scope_type);
     473        4774 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     474        4774 :     node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
     475        9548 :     ReplaceWithStubCall(node, callable, flags);
     476             :   } else {
     477           0 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     478           0 :     ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
     479             :   }
     480        4774 : }
     481             : 
     482         784 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
     483         784 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     484             :   Callable callable =
     485         784 :       Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
     486         784 :   node->RemoveInput(4);  // control
     487        1568 :   ReplaceWithStubCall(node, callable, flags);
     488         784 : }
     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         631 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
     507         631 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     508             :   Callable callable =
     509         631 :       Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
     510        1262 :   ReplaceWithStubCall(node, callable, flags);
     511         631 : }
     512             : 
     513        5617 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
     514        5617 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     515        5617 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     516        5617 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     517       11234 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     518        5617 :   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        5617 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     523             :       p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
     524             :     Callable callable =
     525        5220 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
     526       10440 :     ReplaceWithStubCall(node, callable, flags);
     527             :   } else {
     528         397 :     node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     529         397 :     ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
     530             :   }
     531        5617 : }
     532             : 
     533       21388 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
     534       21388 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     535       21388 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     536       21388 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     537       42776 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     538       21388 :   node->RemoveInput(4);  // control
     539             :   Callable callable =
     540       21388 :       Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
     541       42776 :   ReplaceWithStubCall(node, callable, flags);
     542       21388 : }
     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       12999 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
     552       12999 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     553       12999 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     554       12999 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     555       25998 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     556       12999 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     557       12999 :   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       12999 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     562             :       p.length() <=
     563             :           ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
     564             :     Callable callable =
     565       12412 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
     566       24824 :     ReplaceWithStubCall(node, callable, flags);
     567             :   } else {
     568         587 :     ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
     569             :   }
     570       12999 : }
     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          41 : void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) {
     615             :   ConstructForwardVarargsParameters p =
     616          41 :       ConstructForwardVarargsParametersOf(node->op());
     617          41 :   int const arg_count = static_cast<int>(p.arity() - 2);
     618          41 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     619          41 :   Callable callable = CodeFactory::ConstructForwardVarargs(isolate());
     620          82 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     621          82 :       zone(), callable.descriptor(), arg_count + 1, flags);
     622          41 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     623          41 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     624          41 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     625             :   Node* new_target = node->InputAt(arg_count + 1);
     626          41 :   Node* receiver = jsgraph()->UndefinedConstant();
     627          41 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     628          41 :   node->InsertInput(zone(), 0, stub_code);
     629          41 :   node->InsertInput(zone(), 2, new_target);
     630          41 :   node->InsertInput(zone(), 3, stub_arity);
     631          41 :   node->InsertInput(zone(), 4, start_index);
     632          41 :   node->InsertInput(zone(), 5, receiver);
     633          41 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     634          41 : }
     635             : 
     636       32858 : void JSGenericLowering::LowerJSConstruct(Node* node) {
     637       32858 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     638       32858 :   int const arg_count = static_cast<int>(p.arity() - 2);
     639       32858 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     640       32858 :   Callable callable = CodeFactory::Construct(isolate());
     641       65716 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     642       65716 :       zone(), callable.descriptor(), arg_count + 1, flags);
     643       32858 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     644       32858 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     645             :   Node* new_target = node->InputAt(arg_count + 1);
     646       32858 :   Node* receiver = jsgraph()->UndefinedConstant();
     647       32858 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     648       32858 :   node->InsertInput(zone(), 0, stub_code);
     649       32858 :   node->InsertInput(zone(), 2, new_target);
     650       32858 :   node->InsertInput(zone(), 3, stub_arity);
     651       32858 :   node->InsertInput(zone(), 4, receiver);
     652       32858 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     653       32858 : }
     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          66 : void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
     673          66 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     674          66 :   int const arg_count = static_cast<int>(p.arity() - 2);
     675             :   int const spread_index = arg_count;
     676          66 :   int const new_target_index = arg_count + 1;
     677          66 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     678          66 :   Callable callable = CodeFactory::ConstructWithSpread(isolate());
     679          66 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     680         132 :       zone(), callable.descriptor(), arg_count, flags);
     681          66 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     682          66 :   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          66 :   Node* receiver = jsgraph()->UndefinedConstant();
     686             :   DCHECK(new_target_index > spread_index);
     687          66 :   node->RemoveInput(new_target_index);  // Drop new target.
     688          66 :   node->RemoveInput(spread_index);
     689             : 
     690          66 :   node->InsertInput(zone(), 0, stub_code);
     691          66 :   node->InsertInput(zone(), 2, new_target);
     692          66 :   node->InsertInput(zone(), 3, stack_arg_count);
     693          66 :   node->InsertInput(zone(), 4, spread);
     694          66 :   node->InsertInput(zone(), 5, receiver);
     695          66 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     696          66 : }
     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      447923 : void JSGenericLowering::LowerJSCall(Node* node) {
     715      447923 :   CallParameters const& p = CallParametersOf(node->op());
     716      447923 :   int const arg_count = static_cast<int>(p.arity() - 2);
     717             :   ConvertReceiverMode const mode = p.convert_mode();
     718      447923 :   Callable callable = CodeFactory::Call(isolate(), mode);
     719      447923 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     720      895846 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     721      895846 :       zone(), callable.descriptor(), arg_count + 1, flags);
     722      447923 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     723      447923 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     724      447923 :   node->InsertInput(zone(), 0, stub_code);
     725      447923 :   node->InsertInput(zone(), 2, stub_arity);
     726      447923 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     727      447923 : }
     728             : 
     729         364 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
     730         364 :   Callable callable = CodeFactory::CallWithArrayLike(isolate());
     731         364 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     732             :   auto call_descriptor =
     733         728 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     734         364 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     735             :   Node* receiver = node->InputAt(1);
     736             :   Node* arguments_list = node->InputAt(2);
     737         364 :   node->InsertInput(zone(), 0, stub_code);
     738         364 :   node->ReplaceInput(3, receiver);
     739         364 :   node->ReplaceInput(2, arguments_list);
     740         364 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     741         364 : }
     742             : 
     743         891 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
     744         891 :   CallParameters const& p = CallParametersOf(node->op());
     745         891 :   int const arg_count = static_cast<int>(p.arity() - 2);
     746         891 :   int const spread_index = static_cast<int>(p.arity() + 1);
     747         891 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     748         891 :   Callable callable = CodeFactory::CallWithSpread(isolate());
     749         891 :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     750        1782 :       zone(), callable.descriptor(), arg_count, flags);
     751         891 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     752             :   // We pass the spread in a register, not on the stack.
     753         891 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     754         891 :   node->InsertInput(zone(), 0, stub_code);
     755         891 :   node->InsertInput(zone(), 2, stack_arg_count);
     756         891 :   node->InsertInput(zone(), 3, node->InputAt(spread_index));
     757         891 :   node->RemoveInput(spread_index + 1);
     758         891 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     759         891 : }
     760             : 
     761      315318 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
     762      315318 :   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
     763      315318 :   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
     764      315318 : }
     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      525375 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
     812      525375 :   Node* effect = NodeProperties::GetEffectInput(node);
     813      525375 :   Node* control = NodeProperties::GetControlInput(node);
     814             : 
     815      525377 :   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      525378 :   Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
     821             : 
     822      525378 :   Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
     823             :   Node* branch =
     824      525378 :       graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
     825             : 
     826      525377 :   Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
     827             :   Node* etrue = effect;
     828             : 
     829      525378 :   Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
     830      525379 :   NodeProperties::ReplaceControlInput(node, if_false);
     831      525374 :   NodeProperties::ReplaceEffectInput(node, effect);
     832             :   Node* efalse = if_false = node;
     833             : 
     834      525375 :   Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
     835      525377 :   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
     836             : 
     837             :   // Wire the new diamond into the graph, {node} can still throw.
     838      525376 :   NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
     839      525377 :   NodeProperties::ReplaceControlInput(merge, if_false, 1);
     840      525377 :   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     4184677 :   for (Edge edge : merge->use_edges()) {
     846     1829650 :     if (!NodeProperties::IsControlEdge(edge)) continue;
     847     1829649 :     if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
     848        7165 :       NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
     849        7165 :       NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
     850        7165 :       edge.UpdateTo(node);
     851             :     }
     852     1829650 :     if (edge.from()->opcode() == IrOpcode::kIfException) {
     853        7165 :       NodeProperties::ReplaceEffectInput(edge.from(), node);
     854        7165 :       edge.UpdateTo(node);
     855             :     }
     856             :   }
     857             : 
     858             :   // Turn the stack check into a runtime call.
     859      525377 :   ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
     860      525376 : }
     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      122028 : }  // namespace v8

Generated by: LCOV version 1.10