LCOV - code coverage report
Current view: top level - src/compiler - js-generic-lowering.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 511 576 88.7 %
Date: 2019-02-19 Functions: 85 118 72.0 %

          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     3613206 : CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
      27     3613206 :   return OperatorProperties::HasFrameStateInput(node->op())
      28             :              ? CallDescriptor::kNeedsFrameState
      29     3613212 :              : CallDescriptor::kNoFlags;
      30             : }
      31             : 
      32             : }  // namespace
      33             : 
      34      913390 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
      35             : 
      36             : JSGenericLowering::~JSGenericLowering() = default;
      37             : 
      38             : 
      39    44858523 : Reduction JSGenericLowering::Reduce(Node* node) {
      40    44858523 :   switch (node->opcode()) {
      41             : #define DECLARE_CASE(x)  \
      42             :     case IrOpcode::k##x: \
      43             :       Lower##x(node);    \
      44             :       break;
      45       11739 :     JS_OP_LIST(DECLARE_CASE)
      46             : #undef DECLARE_CASE
      47             :     default:
      48             :       // Nothing to see.
      49             :       return NoChange();
      50             :   }
      51             :   return Changed(node);
      52             : }
      53             : 
      54             : #define REPLACE_STUB_CALL(Name)                                              \
      55             :   void JSGenericLowering::LowerJS##Name(Node* node) {                        \
      56             :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);               \
      57             :     Callable callable = Builtins::CallableFor(isolate(), Builtins::k##Name); \
      58             :     ReplaceWithStubCall(node, callable, flags);                              \
      59             :   }
      60      134964 : REPLACE_STUB_CALL(Add)
      61       17148 : REPLACE_STUB_CALL(Subtract)
      62       20252 : REPLACE_STUB_CALL(Multiply)
      63       44564 : REPLACE_STUB_CALL(Divide)
      64        3632 : REPLACE_STUB_CALL(Modulus)
      65         600 : REPLACE_STUB_CALL(Exponentiate)
      66       30320 : REPLACE_STUB_CALL(BitwiseAnd)
      67       36856 : REPLACE_STUB_CALL(BitwiseOr)
      68        1032 : REPLACE_STUB_CALL(BitwiseXor)
      69        1504 : REPLACE_STUB_CALL(ShiftLeft)
      70        2600 : REPLACE_STUB_CALL(ShiftRight)
      71        3760 : REPLACE_STUB_CALL(ShiftRightLogical)
      72       72748 : REPLACE_STUB_CALL(LessThan)
      73        5828 : REPLACE_STUB_CALL(LessThanOrEqual)
      74       64460 : REPLACE_STUB_CALL(GreaterThan)
      75        5052 : REPLACE_STUB_CALL(GreaterThanOrEqual)
      76         524 : REPLACE_STUB_CALL(BitwiseNot)
      77        8144 : REPLACE_STUB_CALL(Decrement)
      78       35496 : REPLACE_STUB_CALL(Increment)
      79       15776 : REPLACE_STUB_CALL(Negate)
      80        3628 : REPLACE_STUB_CALL(HasProperty)
      81       35980 : REPLACE_STUB_CALL(Equal)
      82         108 : REPLACE_STUB_CALL(ToLength)
      83       30656 : REPLACE_STUB_CALL(ToNumber)
      84         288 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
      85        6184 : REPLACE_STUB_CALL(ToNumeric)
      86        4280 : REPLACE_STUB_CALL(ToName)
      87           0 : REPLACE_STUB_CALL(ToObject)
      88        8212 : REPLACE_STUB_CALL(ToString)
      89        5764 : REPLACE_STUB_CALL(ForInEnumerate)
      90         492 : REPLACE_STUB_CALL(AsyncFunctionEnter)
      91         424 : REPLACE_STUB_CALL(AsyncFunctionReject)
      92         444 : REPLACE_STUB_CALL(AsyncFunctionResolve)
      93        2788 : REPLACE_STUB_CALL(FulfillPromise)
      94         656 : REPLACE_STUB_CALL(PerformPromiseThen)
      95         336 : REPLACE_STUB_CALL(PromiseResolve)
      96        4144 : REPLACE_STUB_CALL(RejectPromise)
      97        1112 : REPLACE_STUB_CALL(ResolvePromise)
      98             : #undef REPLACE_STUB_CALL
      99             : 
     100     2256330 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     101             :                                             Callable callable,
     102             :                                             CallDescriptor::Flags flags) {
     103     2256330 :   ReplaceWithStubCall(node, callable, flags, node->op()->properties());
     104     2256333 : }
     105             : 
     106     2342738 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     107             :                                             Callable callable,
     108             :                                             CallDescriptor::Flags flags,
     109     2342738 :                                             Operator::Properties properties) {
     110             :   const CallInterfaceDescriptor& descriptor = callable.descriptor();
     111             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     112             :       zone(), descriptor, descriptor.GetStackParameterCount(), flags,
     113     2342738 :       properties);
     114     2342738 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     115     2342743 :   node->InsertInput(zone(), 0, stub_code);
     116     2342742 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     117     2342741 : }
     118             : 
     119             : 
     120     1710090 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
     121             :                                                Runtime::FunctionId f,
     122     2565148 :                                                int nargs_override) {
     123      855048 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     124      855048 :   Operator::Properties properties = node->op()->properties();
     125      855048 :   const Runtime::Function* fun = Runtime::FunctionForId(f);
     126      855043 :   int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
     127             :   auto call_descriptor =
     128      855043 :       Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
     129     1710094 :   Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
     130      855050 :   Node* arity = jsgraph()->Int32Constant(nargs);
     131     2565150 :   node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
     132     1710102 :   node->InsertInput(zone(), nargs + 1, ref);
     133     1710102 :   node->InsertInput(zone(), nargs + 2, arity);
     134      855051 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     135      855051 : }
     136             : 
     137       86408 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
     138             :   // The === operator doesn't need the current context.
     139       86408 :   NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
     140       86408 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
     141       86408 :   node->RemoveInput(4);  // control
     142             :   ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
     143       86408 :                       Operator::kEliminatable);
     144       86408 : }
     145             : 
     146      120723 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
     147       39474 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     148       39474 :   const PropertyAccess& p = PropertyAccessOf(node->op());
     149       39474 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     150       39474 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     151       78948 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     152       39474 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     153             :     Callable callable = Builtins::CallableFor(
     154       37173 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     155             :                        ? Builtins::kKeyedLoadICTrampoline_Megamorphic
     156       74346 :                        : Builtins::kKeyedLoadICTrampoline);
     157       37173 :     ReplaceWithStubCall(node, callable, flags);
     158             :   } else {
     159             :     Callable callable = Builtins::CallableFor(
     160        2301 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     161             :                        ? Builtins::kKeyedLoadIC_Megamorphic
     162        4602 :                        : Builtins::kKeyedLoadIC);
     163        2301 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     164        2301 :     node->InsertInput(zone(), 3, vector);
     165        2301 :     ReplaceWithStubCall(node, callable, flags);
     166             :   }
     167       39474 : }
     168             : 
     169     1483422 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
     170      414985 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     171      414985 :   NamedAccess const& p = NamedAccessOf(node->op());
     172      414985 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     173      235436 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     174      829970 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     175      414985 :   if (!p.feedback().IsValid()) {
     176             :     Callable callable =
     177      179548 :         Builtins::CallableFor(isolate(), Builtins::kGetProperty);
     178      179548 :     ReplaceWithStubCall(node, callable, flags);
     179      414984 :     return;
     180             :   }
     181      470874 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     182      235436 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     183             :     Callable callable = Builtins::CallableFor(
     184      232406 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     185             :                        ? Builtins::kLoadICTrampoline_Megamorphic
     186      464812 :                        : Builtins::kLoadICTrampoline);
     187      232406 :     ReplaceWithStubCall(node, callable, flags);
     188             :   } else {
     189             :     Callable callable =
     190        3030 :         Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
     191             :                                              ? Builtins::kLoadIC_Megamorphic
     192        6060 :                                              : Builtins::kLoadIC);
     193        3030 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     194        3030 :     node->InsertInput(zone(), 3, vector);
     195        3030 :     ReplaceWithStubCall(node, callable, flags);
     196             :   }
     197             : }
     198             : 
     199     3451374 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
     200      859868 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     201     1719736 :   const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
     202      859868 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     203      859868 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     204     1719736 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     205     1719736 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     206      859868 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     207      847966 :     Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
     208      847966 :     ReplaceWithStubCall(node, callable, flags);
     209             :   } else {
     210             :     Callable callable =
     211       11902 :         CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
     212       11902 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     213       11902 :     node->InsertInput(zone(), 2, vector);
     214       11902 :     ReplaceWithStubCall(node, callable, flags);
     215             :   }
     216      859868 : }
     217             : 
     218       23831 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
     219        7879 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     220        7879 :   PropertyAccess const& p = PropertyAccessOf(node->op());
     221        7879 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     222        7879 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     223       15758 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     224        7879 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     225             :     Callable callable =
     226        7685 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
     227        7685 :     ReplaceWithStubCall(node, callable, flags);
     228             :   } else {
     229             :     Callable callable =
     230         194 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
     231         194 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     232         194 :     node->InsertInput(zone(), 4, vector);
     233         194 :     ReplaceWithStubCall(node, callable, flags);
     234             :   }
     235        7879 : }
     236             : 
     237      298532 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
     238       78037 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     239       78037 :   NamedAccess const& p = NamedAccessOf(node->op());
     240       78037 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     241       59068 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     242      156074 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     243       78037 :   if (!p.feedback().IsValid()) {
     244       18969 :     ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
     245       97006 :     return;
     246             :   }
     247      118136 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     248       59068 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     249             :     Callable callable =
     250       53715 :         Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
     251       53715 :     ReplaceWithStubCall(node, callable, flags);
     252             :   } else {
     253        5353 :     Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
     254        5353 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     255        5353 :     node->InsertInput(zone(), 4, vector);
     256        5353 :     ReplaceWithStubCall(node, callable, flags);
     257             :   }
     258             : }
     259             : 
     260      118873 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
     261       29710 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     262       29710 :   StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
     263       29710 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     264       29710 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     265       59420 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     266       59420 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     267       29710 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     268       29677 :     Callable callable = CodeFactory::StoreOwnIC(isolate());
     269       29677 :     ReplaceWithStubCall(node, callable, flags);
     270             :   } else {
     271          33 :     Callable callable = CodeFactory::StoreOwnICInOptimizedCode(isolate());
     272          33 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     273          33 :     node->InsertInput(zone(), 4, vector);
     274          33 :     ReplaceWithStubCall(node, callable, flags);
     275             :   }
     276       29710 : }
     277             : 
     278      813611 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
     279      203394 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     280      203394 :   const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
     281      203394 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     282      203394 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     283      406788 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     284      406788 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     285      203394 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     286             :     Callable callable =
     287      203359 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
     288      203359 :     ReplaceWithStubCall(node, callable, flags);
     289             :   } else {
     290             :     Callable callable =
     291          35 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
     292          35 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     293          35 :     node->InsertInput(zone(), 3, vector);
     294          35 :     ReplaceWithStubCall(node, callable, flags);
     295             :   }
     296      203394 : }
     297             : 
     298        1332 : void JSGenericLowering::LowerJSStoreDataPropertyInLiteral(Node* node) {
     299         444 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     300         444 :   node->InsertInputs(zone(), 4, 2);
     301         444 :   node->ReplaceInput(4, jsgraph()->HeapConstant(p.feedback().vector()));
     302         888 :   node->ReplaceInput(5, jsgraph()->SmiConstant(p.feedback().index()));
     303         444 :   ReplaceWithRuntimeCall(node, Runtime::kDefineDataPropertyInLiteral);
     304         444 : }
     305             : 
     306      164608 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
     307             :   Callable callable =
     308       41152 :       Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
     309       41152 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     310       41152 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     311       82304 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     312       82304 :   node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
     313       41152 :   ReplaceWithStubCall(node, callable, flags);
     314       41152 : }
     315             : 
     316        1050 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
     317        1050 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     318             :   Callable callable =
     319        1050 :       Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
     320        1050 :   ReplaceWithStubCall(node, callable, flags);
     321        1050 : }
     322             : 
     323          76 : void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
     324          76 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     325             :   Callable callable =
     326          76 :       Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
     327          76 :   ReplaceWithStubCall(node, callable, flags);
     328          76 : }
     329             : 
     330           0 : void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
     331           0 :   ReplaceWithRuntimeCall(node, Runtime::kHasInPrototypeChain);
     332           0 : }
     333             : 
     334        2744 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
     335        2744 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     336        2744 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
     337        2744 :   ReplaceWithStubCall(node, callable, flags);
     338        2744 : }
     339             : 
     340         136 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
     341         136 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     342             :   Callable callable =
     343         136 :       Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
     344         136 :   ReplaceWithStubCall(node, callable, flags);
     345         136 : }
     346             : 
     347           0 : void JSGenericLowering::LowerJSLoadContext(Node* node) {
     348           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     349             : }
     350             : 
     351             : 
     352           0 : void JSGenericLowering::LowerJSStoreContext(Node* node) {
     353           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     354             : }
     355             : 
     356             : 
     357         268 : void JSGenericLowering::LowerJSCreate(Node* node) {
     358         268 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     359             :   Callable callable =
     360         268 :       Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
     361         268 :   ReplaceWithStubCall(node, callable, flags);
     362         268 : }
     363             : 
     364             : 
     365           8 : void JSGenericLowering::LowerJSCreateArguments(Node* node) {
     366           8 :   CreateArgumentsType const type = CreateArgumentsTypeOf(node->op());
     367           8 :   switch (type) {
     368             :     case CreateArgumentsType::kMappedArguments:
     369           8 :       ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
     370           8 :       break;
     371             :     case CreateArgumentsType::kUnmappedArguments:
     372           0 :       ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments);
     373           0 :       break;
     374             :     case CreateArgumentsType::kRestParameter:
     375           0 :       ReplaceWithRuntimeCall(node, Runtime::kNewRestParameter);
     376           0 :       break;
     377             :   }
     378           8 : }
     379             : 
     380             : 
     381         720 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
     382         120 :   CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
     383         120 :   int const arity = static_cast<int>(p.arity());
     384             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     385             :       zone(), ArrayConstructorDescriptor{}, arity + 1,
     386         360 :       CallDescriptor::kNeedsFrameState, node->op()->properties());
     387         120 :   Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
     388         120 :   Node* stub_arity = jsgraph()->Int32Constant(arity);
     389             :   MaybeHandle<AllocationSite> const maybe_site = p.site();
     390             :   Handle<AllocationSite> site;
     391         211 :   Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
     392         269 :                                                : jsgraph()->UndefinedConstant();
     393         120 :   Node* receiver = jsgraph()->UndefinedConstant();
     394         120 :   node->InsertInput(zone(), 0, stub_code);
     395         120 :   node->InsertInput(zone(), 3, stub_arity);
     396         120 :   node->InsertInput(zone(), 4, type_info);
     397         120 :   node->InsertInput(zone(), 5, receiver);
     398         120 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     399         120 : }
     400             : 
     401           0 : void JSGenericLowering::LowerJSCreateArrayIterator(Node* node) {
     402           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     403             : }
     404             : 
     405           0 : void JSGenericLowering::LowerJSCreateAsyncFunctionObject(Node* node) {
     406           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     407             : }
     408             : 
     409           0 : void JSGenericLowering::LowerJSCreateCollectionIterator(Node* node) {
     410           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     411             : }
     412             : 
     413           0 : void JSGenericLowering::LowerJSCreateBoundFunction(Node* node) {
     414           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     415             : }
     416             : 
     417           0 : void JSGenericLowering::LowerJSObjectIsArray(Node* node) {
     418           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     419             : }
     420             : 
     421          62 : void JSGenericLowering::LowerJSCreateObject(Node* node) {
     422          62 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     423             :   Callable callable = Builtins::CallableFor(
     424          62 :       isolate(), Builtins::kCreateObjectWithoutProperties);
     425          62 :   ReplaceWithStubCall(node, callable, flags);
     426          62 : }
     427             : 
     428         201 : void JSGenericLowering::LowerJSParseInt(Node* node) {
     429         201 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     430         201 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
     431         201 :   ReplaceWithStubCall(node, callable, flags);
     432         201 : }
     433             : 
     434         479 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
     435         479 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     436             :   Callable callable =
     437         479 :       Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
     438         479 :   ReplaceWithStubCall(node, callable, flags);
     439         479 : }
     440             : 
     441     1216205 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
     442      810803 :   CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
     443             :   Handle<SharedFunctionInfo> const shared_info = p.shared_info();
     444      810805 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
     445      810806 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
     446      405403 :   node->RemoveInput(4);  // control
     447             : 
     448             :   // Use the FastNewClosure builtin only for functions allocated in new space.
     449      405403 :   if (p.pretenure() == NOT_TENURED) {
     450             :     Callable callable =
     451      392192 :         Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
     452      392189 :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     453      392189 :     ReplaceWithStubCall(node, callable, flags);
     454             :   } else {
     455       13211 :     ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
     456             :   }
     457      405403 : }
     458             : 
     459             : 
     460       14007 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
     461        4669 :   const CreateFunctionContextParameters& parameters =
     462        4669 :       CreateFunctionContextParametersOf(node->op());
     463             :   Handle<ScopeInfo> scope_info = parameters.scope_info();
     464             :   int slot_count = parameters.slot_count();
     465             :   ScopeType scope_type = parameters.scope_type();
     466        4669 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     467             : 
     468        4669 :   if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
     469             :     Callable callable =
     470        9338 :         CodeFactory::FastNewFunctionContext(isolate(), scope_type);
     471        9338 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     472        9338 :     node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
     473        4669 :     ReplaceWithStubCall(node, callable, flags);
     474             :   } else {
     475           0 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     476           0 :     ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
     477             :   }
     478        4669 : }
     479             : 
     480         780 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
     481         780 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     482             :   Callable callable =
     483         780 :       Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
     484         780 :   node->RemoveInput(4);  // control
     485         780 :   ReplaceWithStubCall(node, callable, flags);
     486         780 : }
     487             : 
     488           0 : void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
     489           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     490             : }
     491             : 
     492           0 : void JSGenericLowering::LowerJSCreateStringIterator(Node* node) {
     493           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     494             : }
     495             : 
     496           0 : void JSGenericLowering::LowerJSCreateKeyValueArray(Node* node) {
     497           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     498             : }
     499             : 
     500           0 : void JSGenericLowering::LowerJSCreatePromise(Node* node) {
     501           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     502             : }
     503             : 
     504         480 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
     505         480 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     506             :   Callable callable =
     507         480 :       Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
     508         480 :   ReplaceWithStubCall(node, callable, flags);
     509         480 : }
     510             : 
     511       21778 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
     512       15660 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     513        5346 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     514       10692 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     515       10692 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     516       10692 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     517             : 
     518             :   // Use the CreateShallowArrayLiteratlr builtin only for shallow boilerplates
     519             :   // without properties up to the number of elements that the stubs can handle.
     520       10314 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     521             :       p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
     522             :     Callable callable =
     523        4952 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
     524        4952 :     ReplaceWithStubCall(node, callable, flags);
     525             :   } else {
     526         394 :     node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     527         394 :     ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
     528             :   }
     529        5346 : }
     530             : 
     531       82724 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
     532       20681 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     533       20681 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     534       41362 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     535       41362 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     536       20681 :   node->RemoveInput(4);  // control
     537             :   Callable callable =
     538       20681 :       Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
     539       20681 :   ReplaceWithStubCall(node, callable, flags);
     540       20681 : }
     541             : 
     542         534 : void JSGenericLowering::LowerJSCreateArrayFromIterable(Node* node) {
     543         534 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     544             :   Callable callable = Builtins::CallableFor(
     545         534 :       isolate(), Builtins::kIterableToListWithSymbolLookup);
     546         534 :   ReplaceWithStubCall(node, callable, flags);
     547         534 : }
     548             : 
     549       62555 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
     550       49483 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     551       12511 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     552       25022 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     553       25022 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     554       25022 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     555       12511 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     556             : 
     557             :   // Use the CreateShallowObjectLiteratal builtin only for shallow boilerplates
     558             :   // without elements up to the number of properties that the stubs can handle.
     559       24461 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     560             :       p.length() <=
     561             :           ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
     562             :     Callable callable =
     563       11941 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
     564       11941 :     ReplaceWithStubCall(node, callable, flags);
     565             :   } else {
     566         570 :     ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
     567             :   }
     568       12511 : }
     569             : 
     570         368 : void JSGenericLowering::LowerJSCloneObject(Node* node) {
     571         184 :   CloneObjectParameters const& p = CloneObjectParametersOf(node->op());
     572          92 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     573             :   Callable callable =
     574          92 :       Builtins::CallableFor(isolate(), Builtins::kCloneObjectIC);
     575          92 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.flags()));
     576         184 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     577         184 :   node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector()));
     578          92 :   ReplaceWithStubCall(node, callable, flags);
     579          92 : }
     580             : 
     581           0 : void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
     582           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     583             : }
     584             : 
     585       29370 : void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
     586       11748 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     587        5874 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     588             :   Callable callable =
     589        5874 :       Builtins::CallableFor(isolate(), Builtins::kCreateRegExpLiteral);
     590       11748 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     591       11748 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     592       11748 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     593        5874 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     594        5874 :   ReplaceWithStubCall(node, callable, flags);
     595        5874 : }
     596             : 
     597             : 
     598           0 : void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
     599           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     600             : }
     601             : 
     602           0 : void JSGenericLowering::LowerJSCreateWithContext(Node* node) {
     603           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     604             : }
     605             : 
     606           0 : void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
     607           0 :   Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
     608           0 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     609           0 :   ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
     610           0 : }
     611             : 
     612         190 : void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) {
     613             :   ConstructForwardVarargsParameters p =
     614          38 :       ConstructForwardVarargsParametersOf(node->op());
     615          38 :   int const arg_count = static_cast<int>(p.arity() - 2);
     616          38 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     617          38 :   Callable callable = CodeFactory::ConstructForwardVarargs(isolate());
     618             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     619         114 :       zone(), callable.descriptor(), arg_count + 1, flags);
     620          38 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     621          38 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     622          38 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     623             :   Node* new_target = node->InputAt(arg_count + 1);
     624          38 :   Node* receiver = jsgraph()->UndefinedConstant();
     625          38 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     626          38 :   node->InsertInput(zone(), 0, stub_code);
     627          38 :   node->InsertInput(zone(), 2, new_target);
     628          38 :   node->InsertInput(zone(), 3, stub_arity);
     629          38 :   node->InsertInput(zone(), 4, start_index);
     630          38 :   node->InsertInput(zone(), 5, receiver);
     631          38 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     632          38 : }
     633             : 
     634      124784 : void JSGenericLowering::LowerJSConstruct(Node* node) {
     635       31196 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     636       31196 :   int const arg_count = static_cast<int>(p.arity() - 2);
     637       31196 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     638       31196 :   Callable callable = CodeFactory::Construct(isolate());
     639             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     640       93588 :       zone(), callable.descriptor(), arg_count + 1, flags);
     641       31196 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     642       31196 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     643             :   Node* new_target = node->InputAt(arg_count + 1);
     644       31196 :   Node* receiver = jsgraph()->UndefinedConstant();
     645       31196 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     646       31196 :   node->InsertInput(zone(), 0, stub_code);
     647       31196 :   node->InsertInput(zone(), 2, new_target);
     648       31196 :   node->InsertInput(zone(), 3, stub_arity);
     649       31196 :   node->InsertInput(zone(), 4, receiver);
     650       31196 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     651       31196 : }
     652             : 
     653         147 : void JSGenericLowering::LowerJSConstructWithArrayLike(Node* node) {
     654             :   Callable callable =
     655          49 :       Builtins::CallableFor(isolate(), Builtins::kConstructWithArrayLike);
     656          49 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     657             :   auto call_descriptor =
     658          98 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     659          49 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     660          49 :   Node* receiver = jsgraph()->UndefinedConstant();
     661             :   Node* arguments_list = node->InputAt(1);
     662             :   Node* new_target = node->InputAt(2);
     663          49 :   node->InsertInput(zone(), 0, stub_code);
     664          49 :   node->ReplaceInput(2, new_target);
     665          49 :   node->ReplaceInput(3, arguments_list);
     666          49 :   node->InsertInput(zone(), 4, receiver);
     667          49 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     668          49 : }
     669             : 
     670         256 : void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
     671          64 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     672          64 :   int const arg_count = static_cast<int>(p.arity() - 2);
     673             :   int const spread_index = arg_count;
     674          64 :   int const new_target_index = arg_count + 1;
     675          64 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     676          64 :   Callable callable = CodeFactory::ConstructWithSpread(isolate());
     677             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     678         128 :       zone(), callable.descriptor(), arg_count, flags);
     679          64 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     680         128 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     681             :   Node* new_target = node->InputAt(new_target_index);
     682             :   Node* spread = node->InputAt(spread_index);
     683          64 :   Node* receiver = jsgraph()->UndefinedConstant();
     684             :   DCHECK(new_target_index > spread_index);
     685          64 :   node->RemoveInput(new_target_index);  // Drop new target.
     686          64 :   node->RemoveInput(spread_index);
     687             : 
     688          64 :   node->InsertInput(zone(), 0, stub_code);
     689          64 :   node->InsertInput(zone(), 2, new_target);
     690          64 :   node->InsertInput(zone(), 3, stack_arg_count);
     691          64 :   node->InsertInput(zone(), 4, spread);
     692          64 :   node->InsertInput(zone(), 5, receiver);
     693          64 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     694          64 : }
     695             : 
     696         304 : void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) {
     697          76 :   CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op());
     698          76 :   int const arg_count = static_cast<int>(p.arity() - 2);
     699          76 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     700          76 :   Callable callable = CodeFactory::CallForwardVarargs(isolate());
     701             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     702         228 :       zone(), callable.descriptor(), arg_count + 1, flags);
     703          76 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     704          76 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     705          76 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     706          76 :   node->InsertInput(zone(), 0, stub_code);
     707          76 :   node->InsertInput(zone(), 2, stub_arity);
     708          76 :   node->InsertInput(zone(), 3, start_index);
     709          76 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     710          76 : }
     711             : 
     712     1347730 : void JSGenericLowering::LowerJSCall(Node* node) {
     713      449244 :   CallParameters const& p = CallParametersOf(node->op());
     714      449244 :   int const arg_count = static_cast<int>(p.arity() - 2);
     715             :   ConvertReceiverMode const mode = p.convert_mode();
     716      449244 :   Callable callable = CodeFactory::Call(isolate(), mode);
     717      449244 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     718             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     719     1347731 :       zone(), callable.descriptor(), arg_count + 1, flags);
     720      449243 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     721      449243 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     722      449243 :   node->InsertInput(zone(), 0, stub_code);
     723      449242 :   node->InsertInput(zone(), 2, stub_arity);
     724      449242 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     725      449242 : }
     726             : 
     727         672 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
     728         336 :   Callable callable = CodeFactory::CallWithArrayLike(isolate());
     729         336 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     730             :   auto call_descriptor =
     731         672 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     732         336 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     733             :   Node* receiver = node->InputAt(1);
     734             :   Node* arguments_list = node->InputAt(2);
     735         336 :   node->InsertInput(zone(), 0, stub_code);
     736         336 :   node->ReplaceInput(3, receiver);
     737         336 :   node->ReplaceInput(2, arguments_list);
     738         336 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     739         336 : }
     740             : 
     741        2685 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
     742         895 :   CallParameters const& p = CallParametersOf(node->op());
     743         895 :   int const arg_count = static_cast<int>(p.arity() - 2);
     744         895 :   int const spread_index = static_cast<int>(p.arity() + 1);
     745         895 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     746         895 :   Callable callable = CodeFactory::CallWithSpread(isolate());
     747             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     748        1790 :       zone(), callable.descriptor(), arg_count, flags);
     749         895 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     750             :   // We pass the spread in a register, not on the stack.
     751        1790 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     752         895 :   node->InsertInput(zone(), 0, stub_code);
     753         895 :   node->InsertInput(zone(), 2, stack_arg_count);
     754         895 :   node->InsertInput(zone(), 3, node->InputAt(spread_index));
     755         895 :   node->RemoveInput(spread_index + 1);
     756         895 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     757         895 : }
     758             : 
     759      301829 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
     760      603658 :   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
     761      603658 :   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
     762      301829 : }
     763             : 
     764           0 : void JSGenericLowering::LowerJSForInNext(Node* node) {
     765           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     766             : }
     767             : 
     768           0 : void JSGenericLowering::LowerJSForInPrepare(Node* node) {
     769           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     770             : }
     771             : 
     772           0 : void JSGenericLowering::LowerJSLoadMessage(Node* node) {
     773           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     774             : }
     775             : 
     776             : 
     777           0 : void JSGenericLowering::LowerJSStoreMessage(Node* node) {
     778           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     779             : }
     780             : 
     781           0 : void JSGenericLowering::LowerJSLoadModule(Node* node) {
     782           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     783             : }
     784             : 
     785           0 : void JSGenericLowering::LowerJSStoreModule(Node* node) {
     786           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     787             : }
     788             : 
     789           0 : void JSGenericLowering::LowerJSGeneratorStore(Node* node) {
     790           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     791             : }
     792             : 
     793           0 : void JSGenericLowering::LowerJSGeneratorRestoreContinuation(Node* node) {
     794           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     795             : }
     796             : 
     797           0 : void JSGenericLowering::LowerJSGeneratorRestoreContext(Node* node) {
     798           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     799             : }
     800             : 
     801           0 : void JSGenericLowering::LowerJSGeneratorRestoreInputOrDebugPos(Node* node) {
     802           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     803             : }
     804             : 
     805           0 : void JSGenericLowering::LowerJSGeneratorRestoreRegister(Node* node) {
     806           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     807             : }
     808             : 
     809     1558863 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
     810      519619 :   Node* effect = NodeProperties::GetEffectInput(node);
     811      519626 :   Node* control = NodeProperties::GetControlInput(node);
     812             : 
     813             :   Node* limit = effect = graph()->NewNode(
     814             :       machine()->Load(MachineType::Pointer()),
     815             :       jsgraph()->ExternalConstant(
     816             :           ExternalReference::address_of_stack_limit(isolate())),
     817     2078495 :       jsgraph()->IntPtrConstant(0), effect, control);
     818      519625 :   Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
     819             : 
     820      519625 :   Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
     821             :   Node* branch =
     822      519623 :       graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
     823             : 
     824      519625 :   Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
     825             :   Node* etrue = effect;
     826             : 
     827      519626 :   Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
     828      519626 :   NodeProperties::ReplaceControlInput(node, if_false);
     829      519623 :   NodeProperties::ReplaceEffectInput(node, effect);
     830             :   Node* efalse = if_false = node;
     831             : 
     832      519621 :   Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
     833      519626 :   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
     834             : 
     835             :   // Wire the new diamond into the graph, {node} can still throw.
     836      519625 :   NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
     837      519619 :   NodeProperties::ReplaceControlInput(merge, if_false, 1);
     838      519623 :   NodeProperties::ReplaceEffectInput(ephi, efalse, 1);
     839             : 
     840             :   // This iteration cuts out potential {IfSuccess} or {IfException} projection
     841             :   // uses of the original node and places them inside the diamond, so that we
     842             :   // can change the original {node} into the slow-path runtime call.
     843     4650634 :   for (Edge edge : merge->use_edges()) {
     844     1805695 :     if (!NodeProperties::IsControlEdge(edge)) continue;
     845     5417112 :     if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
     846        8071 :       NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
     847       16142 :       NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
     848        8071 :       edge.UpdateTo(node);
     849             :     }
     850     5417109 :     if (edge.from()->opcode() == IrOpcode::kIfException) {
     851        8071 :       NodeProperties::ReplaceEffectInput(edge.from(), node);
     852        8071 :       edge.UpdateTo(node);
     853             :     }
     854             :   }
     855             : 
     856             :   // Turn the stack check into a runtime call.
     857      519626 :   ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
     858      519626 : }
     859             : 
     860         906 : void JSGenericLowering::LowerJSDebugger(Node* node) {
     861         906 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     862         906 :   Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
     863         906 :   ReplaceWithStubCall(node, callable, flags);
     864         906 : }
     865             : 
     866    13693474 : Zone* JSGenericLowering::zone() const { return graph()->zone(); }
     867             : 
     868             : 
     869     3344266 : Isolate* JSGenericLowering::isolate() const { return jsgraph()->isolate(); }
     870             : 
     871             : 
     872    17850437 : Graph* JSGenericLowering::graph() const { return jsgraph()->graph(); }
     873             : 
     874             : 
     875     6277930 : CommonOperatorBuilder* JSGenericLowering::common() const {
     876     6277930 :   return jsgraph()->common();
     877             : }
     878             : 
     879             : 
     880     1558876 : MachineOperatorBuilder* JSGenericLowering::machine() const {
     881     1558876 :   return jsgraph()->machine();
     882             : }
     883             : 
     884             : }  // namespace compiler
     885             : }  // namespace internal
     886      178779 : }  // namespace v8

Generated by: LCOV version 1.10