LCOV - code coverage report
Current view: top level - src/compiler - js-generic-lowering.cc (source / functions) Hit Total Coverage
Test: app.info Lines: 512 577 88.7 %
Date: 2019-01-20 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     2843857 : CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
      27     2843857 :   return OperatorProperties::HasFrameStateInput(node->op())
      28             :              ? CallDescriptor::kNeedsFrameState
      29     2843887 :              : CallDescriptor::kNoFlags;
      30             : }
      31             : 
      32             : }  // namespace
      33             : 
      34      912206 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph) : jsgraph_(jsgraph) {}
      35             : 
      36             : JSGenericLowering::~JSGenericLowering() = default;
      37             : 
      38             : 
      39    39929738 : Reduction JSGenericLowering::Reduce(Node* node) {
      40    39929738 :   switch (node->opcode()) {
      41             : #define DECLARE_CASE(x)  \
      42             :     case IrOpcode::k##x: \
      43             :       Lower##x(node);    \
      44             :       break;
      45        9546 :     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      132264 : REPLACE_STUB_CALL(Add)
      61       16152 : REPLACE_STUB_CALL(Subtract)
      62       18632 : REPLACE_STUB_CALL(Multiply)
      63       41888 : REPLACE_STUB_CALL(Divide)
      64        3552 : REPLACE_STUB_CALL(Modulus)
      65         392 : REPLACE_STUB_CALL(Exponentiate)
      66       29988 : REPLACE_STUB_CALL(BitwiseAnd)
      67       36232 : REPLACE_STUB_CALL(BitwiseOr)
      68        1028 : REPLACE_STUB_CALL(BitwiseXor)
      69        1496 : REPLACE_STUB_CALL(ShiftLeft)
      70        2412 : REPLACE_STUB_CALL(ShiftRight)
      71        3528 : REPLACE_STUB_CALL(ShiftRightLogical)
      72       62040 : REPLACE_STUB_CALL(LessThan)
      73        3864 : REPLACE_STUB_CALL(LessThanOrEqual)
      74       60352 : REPLACE_STUB_CALL(GreaterThan)
      75        5792 : REPLACE_STUB_CALL(GreaterThanOrEqual)
      76         452 : REPLACE_STUB_CALL(BitwiseNot)
      77        7532 : REPLACE_STUB_CALL(Decrement)
      78       29300 : REPLACE_STUB_CALL(Increment)
      79       11000 : REPLACE_STUB_CALL(Negate)
      80        3696 : REPLACE_STUB_CALL(HasProperty)
      81       30592 : REPLACE_STUB_CALL(Equal)
      82         100 : REPLACE_STUB_CALL(ToLength)
      83       30204 : REPLACE_STUB_CALL(ToNumber)
      84         420 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
      85        5720 : REPLACE_STUB_CALL(ToNumeric)
      86        4144 : REPLACE_STUB_CALL(ToName)
      87           0 : REPLACE_STUB_CALL(ToObject)
      88        8068 : REPLACE_STUB_CALL(ToString)
      89        5780 : REPLACE_STUB_CALL(ForInEnumerate)
      90         492 : REPLACE_STUB_CALL(AsyncFunctionEnter)
      91         408 : REPLACE_STUB_CALL(AsyncFunctionReject)
      92         444 : REPLACE_STUB_CALL(AsyncFunctionResolve)
      93        2804 : REPLACE_STUB_CALL(FulfillPromise)
      94         672 : REPLACE_STUB_CALL(PerformPromiseThen)
      95         340 : REPLACE_STUB_CALL(PromiseResolve)
      96        4140 : REPLACE_STUB_CALL(RejectPromise)
      97        1112 : REPLACE_STUB_CALL(ResolvePromise)
      98             : #undef REPLACE_STUB_CALL
      99             : 
     100     1692591 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     101             :                                             Callable callable,
     102             :                                             CallDescriptor::Flags flags) {
     103     1692591 :   ReplaceWithStubCall(node, callable, flags, node->op()->properties());
     104     1692605 : }
     105             : 
     106     1774745 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
     107             :                                             Callable callable,
     108             :                                             CallDescriptor::Flags flags,
     109     1774742 :                                             Operator::Properties properties) {
     110             :   const CallInterfaceDescriptor& descriptor = callable.descriptor();
     111             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     112             :       zone(), descriptor, descriptor.GetStackParameterCount(), flags,
     113     1774745 :       properties);
     114     1774742 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     115     1774751 :   node->InsertInput(zone(), 0, stub_code);
     116     1774753 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     117     1774753 : }
     118             : 
     119             : 
     120     1691416 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
     121             :                                                Runtime::FunctionId f,
     122     2537170 :                                                int nargs_override) {
     123      845719 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     124      845719 :   Operator::Properties properties = node->op()->properties();
     125      845719 :   const Runtime::Function* fun = Runtime::FunctionForId(f);
     126      845696 :   int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
     127             :   auto call_descriptor =
     128      845696 :       Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
     129     1691428 :   Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
     130      845725 :   Node* arity = jsgraph()->Int32Constant(nargs);
     131     2537175 :   node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
     132     1691456 :   node->InsertInput(zone(), nargs + 1, ref);
     133     1691454 :   node->InsertInput(zone(), nargs + 2, arity);
     134      845720 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     135      845726 : }
     136             : 
     137       82148 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
     138             :   // The === operator doesn't need the current context.
     139       82148 :   NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
     140       82148 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
     141       82148 :   node->RemoveInput(4);  // control
     142             :   ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
     143       82148 :                       Operator::kEliminatable);
     144       82148 : }
     145             : 
     146      119275 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
     147       38871 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     148       38871 :   const PropertyAccess& p = PropertyAccessOf(node->op());
     149       38871 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     150       38871 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     151       77742 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     152       38871 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     153             :     Callable callable = Builtins::CallableFor(
     154       36209 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     155             :                        ? Builtins::kKeyedLoadICTrampoline_Megamorphic
     156       72418 :                        : Builtins::kKeyedLoadICTrampoline);
     157       36209 :     ReplaceWithStubCall(node, callable, flags);
     158             :   } else {
     159             :     Callable callable = Builtins::CallableFor(
     160        2662 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     161             :                        ? Builtins::kKeyedLoadIC_Megamorphic
     162        5324 :                        : Builtins::kKeyedLoadIC);
     163        2662 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     164        2662 :     node->InsertInput(zone(), 3, vector);
     165        2662 :     ReplaceWithStubCall(node, callable, flags);
     166             :   }
     167       38871 : }
     168             : 
     169     1282282 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
     170      351120 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     171      351120 :   NamedAccess const& p = NamedAccessOf(node->op());
     172      351121 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     173      225677 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     174      702242 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     175      351121 :   if (!p.feedback().IsValid()) {
     176             :     Callable callable =
     177      125444 :         Builtins::CallableFor(isolate(), Builtins::kGetProperty);
     178      125444 :     ReplaceWithStubCall(node, callable, flags);
     179      351120 :     return;
     180             :   }
     181      451354 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     182      225677 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     183             :     Callable callable = Builtins::CallableFor(
     184      222433 :         isolate(), p.feedback().ic_state() == MEGAMORPHIC
     185             :                        ? Builtins::kLoadICTrampoline_Megamorphic
     186      444866 :                        : Builtins::kLoadICTrampoline);
     187      222433 :     ReplaceWithStubCall(node, callable, flags);
     188             :   } else {
     189             :     Callable callable =
     190        3244 :         Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
     191             :                                              ? Builtins::kLoadIC_Megamorphic
     192        6488 :                                              : Builtins::kLoadIC);
     193        3244 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     194        3244 :     node->InsertInput(zone(), 3, vector);
     195        3244 :     ReplaceWithStubCall(node, callable, flags);
     196             :   }
     197             : }
     198             : 
     199     1624304 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
     200      406054 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     201      812108 :   const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
     202      406054 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     203      406054 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     204      812108 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     205      812108 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     206      406054 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     207      405966 :     Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
     208      405966 :     ReplaceWithStubCall(node, callable, flags);
     209             :   } else {
     210             :     Callable callable =
     211          88 :         CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
     212          88 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     213          88 :     node->InsertInput(zone(), 2, vector);
     214          88 :     ReplaceWithStubCall(node, callable, flags);
     215             :   }
     216      406054 : }
     217             : 
     218       24031 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
     219        7940 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     220        7940 :   PropertyAccess const& p = PropertyAccessOf(node->op());
     221        7940 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     222        7940 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     223       15880 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     224        7940 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     225             :     Callable callable =
     226        7729 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
     227        7729 :     ReplaceWithStubCall(node, callable, flags);
     228             :   } else {
     229             :     Callable callable =
     230         211 :         Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
     231         211 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     232         211 :     node->InsertInput(zone(), 4, vector);
     233         211 :     ReplaceWithStubCall(node, callable, flags);
     234             :   }
     235        7940 : }
     236             : 
     237      327271 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
     238       79946 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     239       98846 :   NamedAccess const& p = NamedAccessOf(node->op());
     240       79946 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     241       61046 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     242      159892 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     243       79946 :   if (!p.feedback().IsValid()) {
     244             :     node->InsertInput(
     245       37800 :         zone(), 3, jsgraph()->SmiConstant(static_cast<int>(p.language_mode())));
     246       18900 :     ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
     247       98845 :     return;
     248             :   }
     249      122092 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     250       61046 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     251             :     Callable callable =
     252       53559 :         Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
     253       53559 :     ReplaceWithStubCall(node, callable, flags);
     254             :   } else {
     255        7487 :     Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
     256        7487 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     257        7487 :     node->InsertInput(zone(), 4, vector);
     258        7487 :     ReplaceWithStubCall(node, callable, flags);
     259             :   }
     260             : }
     261             : 
     262      116435 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
     263       29099 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     264       29099 :   StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
     265       29099 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     266       29100 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     267       58200 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
     268       58200 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     269       29100 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     270       29063 :     Callable callable = CodeFactory::StoreOwnIC(isolate());
     271       29062 :     ReplaceWithStubCall(node, callable, flags);
     272             :   } else {
     273          37 :     Callable callable = CodeFactory::StoreOwnICInOptimizedCode(isolate());
     274          37 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     275          37 :     node->InsertInput(zone(), 4, vector);
     276          37 :     ReplaceWithStubCall(node, callable, flags);
     277             :   }
     278       29100 : }
     279             : 
     280      744462 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
     281      186112 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     282      186112 :   const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
     283      186112 :   Node* frame_state = NodeProperties::GetFrameStateInput(node);
     284      186112 :   Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
     285      372224 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
     286      372224 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     287      186112 :   if (outer_state->opcode() != IrOpcode::kFrameState) {
     288             :     Callable callable =
     289      186098 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
     290      186098 :     ReplaceWithStubCall(node, callable, flags);
     291             :   } else {
     292             :     Callable callable =
     293          14 :         Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
     294          14 :     Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
     295          14 :     node->InsertInput(zone(), 3, vector);
     296          14 :     ReplaceWithStubCall(node, callable, flags);
     297             :   }
     298      186112 : }
     299             : 
     300        1353 : void JSGenericLowering::LowerJSStoreDataPropertyInLiteral(Node* node) {
     301         451 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     302         451 :   node->InsertInputs(zone(), 4, 2);
     303         451 :   node->ReplaceInput(4, jsgraph()->HeapConstant(p.feedback().vector()));
     304         902 :   node->ReplaceInput(5, jsgraph()->SmiConstant(p.feedback().index()));
     305         451 :   ReplaceWithRuntimeCall(node, Runtime::kDefineDataPropertyInLiteral);
     306         451 : }
     307             : 
     308      160310 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
     309             :   Callable callable =
     310       40077 :       Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
     311       40077 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     312       40077 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     313       80154 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
     314       80156 :   node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
     315       40077 :   ReplaceWithStubCall(node, callable, flags);
     316       40078 : }
     317             : 
     318        1080 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
     319        1080 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     320             :   Callable callable =
     321        1080 :       Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
     322        1080 :   ReplaceWithStubCall(node, callable, flags);
     323        1080 : }
     324             : 
     325          83 : void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
     326          83 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     327             :   Callable callable =
     328          83 :       Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
     329          83 :   ReplaceWithStubCall(node, callable, flags);
     330          83 : }
     331             : 
     332           0 : void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
     333           0 :   ReplaceWithRuntimeCall(node, Runtime::kHasInPrototypeChain);
     334           0 : }
     335             : 
     336        1898 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
     337        1898 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     338        1898 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
     339        1898 :   ReplaceWithStubCall(node, callable, flags);
     340        1898 : }
     341             : 
     342         146 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
     343         146 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     344             :   Callable callable =
     345         146 :       Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
     346         146 :   ReplaceWithStubCall(node, callable, flags);
     347         146 : }
     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         273 : void JSGenericLowering::LowerJSCreate(Node* node) {
     360         273 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     361             :   Callable callable =
     362         273 :       Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
     363         273 :   ReplaceWithStubCall(node, callable, flags);
     364         273 : }
     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         822 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
     384         137 :   CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
     385         137 :   int const arity = static_cast<int>(p.arity());
     386             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     387             :       zone(), ArrayConstructorDescriptor{}, arity + 1,
     388         411 :       CallDescriptor::kNeedsFrameState, node->op()->properties());
     389         137 :   Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
     390         137 :   Node* stub_arity = jsgraph()->Int32Constant(arity);
     391             :   MaybeHandle<AllocationSite> const maybe_site = p.site();
     392             :   Handle<AllocationSite> site;
     393         229 :   Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
     394         319 :                                                : jsgraph()->UndefinedConstant();
     395         137 :   Node* receiver = jsgraph()->UndefinedConstant();
     396         137 :   node->InsertInput(zone(), 0, stub_code);
     397         137 :   node->InsertInput(zone(), 3, stub_arity);
     398         137 :   node->InsertInput(zone(), 4, type_info);
     399         137 :   node->InsertInput(zone(), 5, receiver);
     400         137 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     401         137 : }
     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          62 : void JSGenericLowering::LowerJSCreateObject(Node* node) {
     424          62 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     425             :   Callable callable = Builtins::CallableFor(
     426          62 :       isolate(), Builtins::kCreateObjectWithoutProperties);
     427          62 :   ReplaceWithStubCall(node, callable, flags);
     428          62 : }
     429             : 
     430         587 : void JSGenericLowering::LowerJSParseInt(Node* node) {
     431         587 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     432         587 :   Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
     433         587 :   ReplaceWithStubCall(node, callable, flags);
     434         587 : }
     435             : 
     436         497 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
     437         497 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     438             :   Callable callable =
     439         497 :       Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
     440         497 :   ReplaceWithStubCall(node, callable, flags);
     441         497 : }
     442             : 
     443     1166358 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
     444      777569 :   CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
     445             :   Handle<SharedFunctionInfo> const shared_info = p.shared_info();
     446      777577 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
     447      777586 :   node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
     448      388793 :   node->RemoveInput(4);  // control
     449             : 
     450             :   // Use the FastNewClosure builtin only for functions allocated in new space.
     451      388789 :   if (p.pretenure() == NOT_TENURED) {
     452             :     Callable callable =
     453      375653 :         Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
     454      375653 :     CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     455      375653 :     ReplaceWithStubCall(node, callable, flags);
     456             :   } else {
     457       13136 :     ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
     458             :   }
     459      388793 : }
     460             : 
     461             : 
     462       13902 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
     463        4634 :   const CreateFunctionContextParameters& parameters =
     464        4634 :       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        4634 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     469             : 
     470        4634 :   if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
     471             :     Callable callable =
     472        9268 :         CodeFactory::FastNewFunctionContext(isolate(), scope_type);
     473        9268 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     474        9268 :     node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
     475        4634 :     ReplaceWithStubCall(node, callable, flags);
     476             :   } else {
     477           0 :     node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
     478           0 :     ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
     479             :   }
     480        4634 : }
     481             : 
     482         780 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
     483         780 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     484             :   Callable callable =
     485         780 :       Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
     486         780 :   node->RemoveInput(4);  // control
     487         780 :   ReplaceWithStubCall(node, callable, flags);
     488         780 : }
     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         491 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
     507         491 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     508             :   Callable callable =
     509         491 :       Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
     510         491 :   ReplaceWithStubCall(node, callable, flags);
     511         491 : }
     512             : 
     513       22040 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
     514       15755 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     515        5397 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     516       10794 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     517       10794 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     518       10794 :   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       10358 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     523             :       p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
     524             :     Callable callable =
     525        4945 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
     526        4945 :     ReplaceWithStubCall(node, callable, flags);
     527             :   } else {
     528         452 :     node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     529         452 :     ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
     530             :   }
     531        5397 : }
     532             : 
     533       81224 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
     534       20306 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     535       20306 :   FeedbackParameter const& p = FeedbackParameterOf(node->op());
     536       40612 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     537       40612 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     538       20306 :   node->RemoveInput(4);  // control
     539             :   Callable callable =
     540       20306 :       Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
     541       20306 :   ReplaceWithStubCall(node, callable, flags);
     542       20306 : }
     543             : 
     544         530 : void JSGenericLowering::LowerJSCreateArrayFromIterable(Node* node) {
     545         530 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     546             :   Callable callable = Builtins::CallableFor(
     547         530 :       isolate(), Builtins::kIterableToListWithSymbolLookup);
     548         530 :   ReplaceWithStubCall(node, callable, flags);
     549         530 : }
     550             : 
     551       61080 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
     552       48302 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     553       12216 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     554       24432 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     555       24432 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     556       24432 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     557       12216 :   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       23870 :   if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
     562             :       p.length() <=
     563             :           ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
     564             :     Callable callable =
     565       11645 :         Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
     566       11645 :     ReplaceWithStubCall(node, callable, flags);
     567             :   } else {
     568         571 :     ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
     569             :   }
     570       12216 : }
     571             : 
     572         364 : void JSGenericLowering::LowerJSCloneObject(Node* node) {
     573         182 :   CloneObjectParameters const& p = CloneObjectParametersOf(node->op());
     574          91 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     575             :   Callable callable =
     576          91 :       Builtins::CallableFor(isolate(), Builtins::kCloneObjectIC);
     577          91 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.flags()));
     578         182 :   node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
     579         182 :   node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector()));
     580          91 :   ReplaceWithStubCall(node, callable, flags);
     581          91 : }
     582             : 
     583           0 : void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
     584           0 :   UNREACHABLE();  // Eliminated in typed lowering.
     585             : }
     586             : 
     587       29490 : void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
     588       11796 :   CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
     589        5898 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     590             :   Callable callable =
     591        5898 :       Builtins::CallableFor(isolate(), Builtins::kCreateRegExpLiteral);
     592       11796 :   node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
     593       11796 :   node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
     594       11796 :   node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
     595        5898 :   node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
     596        5898 :   ReplaceWithStubCall(node, callable, flags);
     597        5898 : }
     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         225 : void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) {
     615             :   ConstructForwardVarargsParameters p =
     616          45 :       ConstructForwardVarargsParametersOf(node->op());
     617          45 :   int const arg_count = static_cast<int>(p.arity() - 2);
     618          45 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     619          45 :   Callable callable = CodeFactory::ConstructForwardVarargs(isolate());
     620             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     621         135 :       zone(), callable.descriptor(), arg_count + 1, flags);
     622          45 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     623          45 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     624          45 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     625             :   Node* new_target = node->InputAt(arg_count + 1);
     626          45 :   Node* receiver = jsgraph()->UndefinedConstant();
     627          45 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     628          45 :   node->InsertInput(zone(), 0, stub_code);
     629          45 :   node->InsertInput(zone(), 2, new_target);
     630          45 :   node->InsertInput(zone(), 3, stub_arity);
     631          45 :   node->InsertInput(zone(), 4, start_index);
     632          45 :   node->InsertInput(zone(), 5, receiver);
     633          45 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     634          45 : }
     635             : 
     636       40493 : void JSGenericLowering::LowerJSConstruct(Node* node) {
     637       10123 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     638       10123 :   int const arg_count = static_cast<int>(p.arity() - 2);
     639       10124 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     640       10124 :   Callable callable = CodeFactory::Construct(isolate());
     641             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     642       30369 :       zone(), callable.descriptor(), arg_count + 1, flags);
     643       10123 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     644       10123 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     645             :   Node* new_target = node->InputAt(arg_count + 1);
     646       10124 :   Node* receiver = jsgraph()->UndefinedConstant();
     647       10124 :   node->RemoveInput(arg_count + 1);  // Drop new target.
     648       10124 :   node->InsertInput(zone(), 0, stub_code);
     649       10123 :   node->InsertInput(zone(), 2, new_target);
     650       10124 :   node->InsertInput(zone(), 3, stub_arity);
     651       10124 :   node->InsertInput(zone(), 4, receiver);
     652       10124 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     653       10124 : }
     654             : 
     655         147 : void JSGenericLowering::LowerJSConstructWithArrayLike(Node* node) {
     656             :   Callable callable =
     657          49 :       Builtins::CallableFor(isolate(), Builtins::kConstructWithArrayLike);
     658          49 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     659             :   auto call_descriptor =
     660          98 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     661          49 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     662          49 :   Node* receiver = jsgraph()->UndefinedConstant();
     663             :   Node* arguments_list = node->InputAt(1);
     664             :   Node* new_target = node->InputAt(2);
     665          49 :   node->InsertInput(zone(), 0, stub_code);
     666          49 :   node->ReplaceInput(2, new_target);
     667          49 :   node->ReplaceInput(3, arguments_list);
     668          49 :   node->InsertInput(zone(), 4, receiver);
     669          49 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     670          49 : }
     671             : 
     672         240 : void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
     673          60 :   ConstructParameters const& p = ConstructParametersOf(node->op());
     674          60 :   int const arg_count = static_cast<int>(p.arity() - 2);
     675             :   int const spread_index = arg_count;
     676          60 :   int const new_target_index = arg_count + 1;
     677          60 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     678          60 :   Callable callable = CodeFactory::ConstructWithSpread(isolate());
     679             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     680         120 :       zone(), callable.descriptor(), arg_count, flags);
     681          60 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     682         120 :   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          60 :   Node* receiver = jsgraph()->UndefinedConstant();
     686             :   DCHECK(new_target_index > spread_index);
     687          60 :   node->RemoveInput(new_target_index);  // Drop new target.
     688          60 :   node->RemoveInput(spread_index);
     689             : 
     690          60 :   node->InsertInput(zone(), 0, stub_code);
     691          60 :   node->InsertInput(zone(), 2, new_target);
     692          60 :   node->InsertInput(zone(), 3, stack_arg_count);
     693          60 :   node->InsertInput(zone(), 4, spread);
     694          60 :   node->InsertInput(zone(), 5, receiver);
     695          60 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     696          60 : }
     697             : 
     698         296 : void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) {
     699          74 :   CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op());
     700          74 :   int const arg_count = static_cast<int>(p.arity() - 2);
     701          74 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     702          74 :   Callable callable = CodeFactory::CallForwardVarargs(isolate());
     703             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     704         222 :       zone(), callable.descriptor(), arg_count + 1, flags);
     705          74 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     706          74 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     707          74 :   Node* start_index = jsgraph()->Uint32Constant(p.start_index());
     708          74 :   node->InsertInput(zone(), 0, stub_code);
     709          74 :   node->InsertInput(zone(), 2, stub_arity);
     710          74 :   node->InsertInput(zone(), 3, start_index);
     711          74 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     712          74 : }
     713             : 
     714      822168 : void JSGenericLowering::LowerJSCall(Node* node) {
     715      274056 :   CallParameters const& p = CallParametersOf(node->op());
     716      274056 :   int const arg_count = static_cast<int>(p.arity() - 2);
     717             :   ConvertReceiverMode const mode = p.convert_mode();
     718      274056 :   Callable callable = CodeFactory::Call(isolate(), mode);
     719      274054 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     720             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     721      822163 :       zone(), callable.descriptor(), arg_count + 1, flags);
     722      274055 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     723      274057 :   Node* stub_arity = jsgraph()->Int32Constant(arg_count);
     724      274057 :   node->InsertInput(zone(), 0, stub_code);
     725      274057 :   node->InsertInput(zone(), 2, stub_arity);
     726      274057 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     727      274057 : }
     728             : 
     729         704 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
     730         352 :   Callable callable = CodeFactory::CallWithArrayLike(isolate());
     731         352 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     732             :   auto call_descriptor =
     733         704 :       Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
     734         352 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     735             :   Node* receiver = node->InputAt(1);
     736             :   Node* arguments_list = node->InputAt(2);
     737         352 :   node->InsertInput(zone(), 0, stub_code);
     738         352 :   node->ReplaceInput(3, receiver);
     739         352 :   node->ReplaceInput(2, arguments_list);
     740         352 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     741         352 : }
     742             : 
     743        2667 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
     744         889 :   CallParameters const& p = CallParametersOf(node->op());
     745         889 :   int const arg_count = static_cast<int>(p.arity() - 2);
     746         889 :   int const spread_index = static_cast<int>(p.arity() + 1);
     747         889 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     748         889 :   Callable callable = CodeFactory::CallWithSpread(isolate());
     749             :   auto call_descriptor = Linkage::GetStubCallDescriptor(
     750        1778 :       zone(), callable.descriptor(), arg_count, flags);
     751         889 :   Node* stub_code = jsgraph()->HeapConstant(callable.code());
     752             :   // We pass the spread in a register, not on the stack.
     753        1778 :   Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
     754         889 :   node->InsertInput(zone(), 0, stub_code);
     755         889 :   node->InsertInput(zone(), 2, stack_arg_count);
     756         889 :   node->InsertInput(zone(), 3, node->InputAt(spread_index));
     757         889 :   node->RemoveInput(spread_index + 1);
     758         889 :   NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
     759         889 : }
     760             : 
     761      294145 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
     762      588290 :   const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
     763      588290 :   ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
     764      294146 : }
     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     1554118 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
     812      518029 :   Node* effect = NodeProperties::GetEffectInput(node);
     813      518056 :   Node* control = NodeProperties::GetControlInput(node);
     814             : 
     815             :   Node* limit = effect = graph()->NewNode(
     816             :       machine()->Load(MachineType::Pointer()),
     817             :       jsgraph()->ExternalConstant(
     818             :           ExternalReference::address_of_stack_limit(isolate())),
     819     2072208 :       jsgraph()->IntPtrConstant(0), effect, control);
     820      518064 :   Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
     821             : 
     822      518060 :   Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
     823             :   Node* branch =
     824      518063 :       graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
     825             : 
     826      518063 :   Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
     827             :   Node* etrue = effect;
     828             : 
     829      518061 :   Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
     830      518064 :   NodeProperties::ReplaceControlInput(node, if_false);
     831      518060 :   NodeProperties::ReplaceEffectInput(node, effect);
     832             :   Node* efalse = if_false = node;
     833             : 
     834      518058 :   Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
     835      518064 :   Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
     836             : 
     837             :   // Wire the new diamond into the graph, {node} can still throw.
     838      518061 :   NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
     839      518061 :   NodeProperties::ReplaceControlInput(merge, if_false, 1);
     840      518060 :   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     4736124 :   for (Edge edge : merge->use_edges()) {
     846     1850032 :     if (!NodeProperties::IsControlEdge(edge)) continue;
     847     5550150 :     if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
     848        8021 :       NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
     849       16042 :       NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
     850        8021 :       edge.UpdateTo(node);
     851             :     }
     852     5550174 :     if (edge.from()->opcode() == IrOpcode::kIfException) {
     853        8021 :       NodeProperties::ReplaceEffectInput(edge.from(), node);
     854        8021 :       edge.UpdateTo(node);
     855             :     }
     856             :   }
     857             : 
     858             :   // Turn the stack check into a runtime call.
     859      518042 :   ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
     860      518061 : }
     861             : 
     862         922 : void JSGenericLowering::LowerJSDebugger(Node* node) {
     863         922 :   CallDescriptor::Flags flags = FrameStateFlagForCall(node);
     864         922 :   Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
     865         922 :   ReplaceWithStubCall(node, callable, flags);
     866         922 : }
     867             : 
     868    10848395 : Zone* JSGenericLowering::zone() const { return graph()->zone(); }
     869             : 
     870             : 
     871     2578453 : Isolate* JSGenericLowering::isolate() const { return jsgraph()->isolate(); }
     872             : 
     873             : 
     874    14992791 : Graph* JSGenericLowering::graph() const { return jsgraph()->graph(); }
     875             : 
     876             : 
     877     5496569 : CommonOperatorBuilder* JSGenericLowering::common() const {
     878     5496569 :   return jsgraph()->common();
     879             : }
     880             : 
     881             : 
     882     1554187 : MachineOperatorBuilder* JSGenericLowering::machine() const {
     883     1554187 :   return jsgraph()->machine();
     884             : }
     885             : 
     886             : }  // namespace compiler
     887             : }  // namespace internal
     888      183867 : }  // namespace v8

Generated by: LCOV version 1.10