Line data Source code
1 : // Copyright 2014 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/compiler/js-generic-lowering.h"
6 :
7 : #include "src/ast/ast.h"
8 : #include "src/builtins/builtins-constructor.h"
9 : #include "src/code-factory.h"
10 : #include "src/compiler/common-operator.h"
11 : #include "src/compiler/js-graph.h"
12 : #include "src/compiler/machine-operator.h"
13 : #include "src/compiler/node-matchers.h"
14 : #include "src/compiler/node-properties.h"
15 : #include "src/compiler/operator-properties.h"
16 : #include "src/feedback-vector.h"
17 : #include "src/objects/feedback-cell.h"
18 : #include "src/objects/scope-info.h"
19 :
20 : namespace v8 {
21 : namespace internal {
22 : namespace compiler {
23 :
24 : namespace {
25 :
26 : CallDescriptor::Flags FrameStateFlagForCall(Node* node) {
27 3390497 : return OperatorProperties::HasFrameStateInput(node->op())
28 : ? CallDescriptor::kNeedsFrameState
29 3390502 : : CallDescriptor::kNoFlags;
30 : }
31 :
32 : } // namespace
33 :
34 464079 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor)
35 464079 : : AdvancedReducer(editor), jsgraph_(jsgraph) {}
36 :
37 : JSGenericLowering::~JSGenericLowering() = default;
38 :
39 :
40 44293178 : Reduction JSGenericLowering::Reduce(Node* node) {
41 44293178 : switch (node->opcode()) {
42 : #define DECLARE_CASE(x) \
43 : case IrOpcode::k##x: \
44 : Lower##x(node); \
45 : break;
46 12071 : JS_OP_LIST(DECLARE_CASE)
47 : #undef DECLARE_CASE
48 : default:
49 : // Nothing to see.
50 : return NoChange();
51 : }
52 : return Changed(node);
53 : }
54 :
55 : #define REPLACE_STUB_CALL(Name) \
56 : void JSGenericLowering::LowerJS##Name(Node* node) { \
57 : CallDescriptor::Flags flags = FrameStateFlagForCall(node); \
58 : Callable callable = Builtins::CallableFor(isolate(), Builtins::k##Name); \
59 : ReplaceWithStubCall(node, callable, flags); \
60 : }
61 173140 : REPLACE_STUB_CALL(Add)
62 26120 : REPLACE_STUB_CALL(Subtract)
63 29830 : REPLACE_STUB_CALL(Multiply)
64 53690 : REPLACE_STUB_CALL(Divide)
65 3100 : REPLACE_STUB_CALL(Modulus)
66 755 : REPLACE_STUB_CALL(Exponentiate)
67 35805 : REPLACE_STUB_CALL(BitwiseAnd)
68 44770 : REPLACE_STUB_CALL(BitwiseOr)
69 1285 : REPLACE_STUB_CALL(BitwiseXor)
70 10345 : REPLACE_STUB_CALL(ShiftLeft)
71 2640 : REPLACE_STUB_CALL(ShiftRight)
72 4780 : REPLACE_STUB_CALL(ShiftRightLogical)
73 95895 : REPLACE_STUB_CALL(LessThan)
74 7275 : REPLACE_STUB_CALL(LessThanOrEqual)
75 85100 : REPLACE_STUB_CALL(GreaterThan)
76 7825 : REPLACE_STUB_CALL(GreaterThanOrEqual)
77 660 : REPLACE_STUB_CALL(BitwiseNot)
78 10245 : REPLACE_STUB_CALL(Decrement)
79 52235 : REPLACE_STUB_CALL(Increment)
80 19685 : REPLACE_STUB_CALL(Negate)
81 7890 : REPLACE_STUB_CALL(HasProperty)
82 45970 : REPLACE_STUB_CALL(Equal)
83 135 : REPLACE_STUB_CALL(ToLength)
84 38065 : REPLACE_STUB_CALL(ToNumber)
85 360 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
86 15025 : REPLACE_STUB_CALL(ToNumeric)
87 5430 : REPLACE_STUB_CALL(ToName)
88 0 : REPLACE_STUB_CALL(ToObject)
89 10615 : REPLACE_STUB_CALL(ToString)
90 7250 : REPLACE_STUB_CALL(ForInEnumerate)
91 615 : REPLACE_STUB_CALL(AsyncFunctionEnter)
92 530 : REPLACE_STUB_CALL(AsyncFunctionReject)
93 555 : REPLACE_STUB_CALL(AsyncFunctionResolve)
94 3745 : REPLACE_STUB_CALL(FulfillPromise)
95 885 : REPLACE_STUB_CALL(PerformPromiseThen)
96 470 : REPLACE_STUB_CALL(PromiseResolve)
97 5445 : REPLACE_STUB_CALL(RejectPromise)
98 1415 : REPLACE_STUB_CALL(ResolvePromise)
99 : #undef REPLACE_STUB_CALL
100 :
101 2014048 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
102 : Callable callable,
103 : CallDescriptor::Flags flags) {
104 4028097 : ReplaceWithStubCall(node, callable, flags, node->op()->properties());
105 2014049 : }
106 :
107 2101517 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
108 : Callable callable,
109 : CallDescriptor::Flags flags,
110 : Operator::Properties properties) {
111 : const CallInterfaceDescriptor& descriptor = callable.descriptor();
112 : auto call_descriptor = Linkage::GetStubCallDescriptor(
113 : zone(), descriptor, descriptor.GetStackParameterCount(), flags,
114 2101517 : properties);
115 2101518 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
116 2101520 : node->InsertInput(zone(), 0, stub_code);
117 2101520 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
118 2101518 : }
119 :
120 :
121 873820 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
122 : Runtime::FunctionId f,
123 : int nargs_override) {
124 873825 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
125 873825 : Operator::Properties properties = node->op()->properties();
126 873825 : const Runtime::Function* fun = Runtime::FunctionForId(f);
127 873820 : int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
128 : auto call_descriptor =
129 873820 : Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
130 873826 : Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
131 873825 : Node* arity = jsgraph()->Int32Constant(nargs);
132 873824 : node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
133 873826 : node->InsertInput(zone(), nargs + 1, ref);
134 873827 : node->InsertInput(zone(), nargs + 2, arity);
135 873828 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
136 873825 : }
137 :
138 87469 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
139 : // The === operator doesn't need the current context.
140 87469 : NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
141 87469 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
142 87469 : node->RemoveInput(4); // control
143 87469 : ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
144 87469 : Operator::kEliminatable);
145 87469 : }
146 :
147 39253 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
148 39253 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
149 39253 : const PropertyAccess& p = PropertyAccessOf(node->op());
150 39253 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
151 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
152 78506 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
153 39253 : if (outer_state->opcode() != IrOpcode::kFrameState) {
154 : Callable callable = Builtins::CallableFor(
155 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
156 : ? Builtins::kKeyedLoadICTrampoline_Megamorphic
157 36990 : : Builtins::kKeyedLoadICTrampoline);
158 73980 : ReplaceWithStubCall(node, callable, flags);
159 : } else {
160 : Callable callable = Builtins::CallableFor(
161 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
162 : ? Builtins::kKeyedLoadIC_Megamorphic
163 2263 : : Builtins::kKeyedLoadIC);
164 2263 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
165 2263 : node->InsertInput(zone(), 3, vector);
166 4526 : ReplaceWithStubCall(node, callable, flags);
167 : }
168 39253 : }
169 :
170 438102 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
171 438102 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
172 438102 : NamedAccess const& p = NamedAccessOf(node->op());
173 438102 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
174 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
175 438102 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
176 438102 : if (!p.feedback().IsValid()) {
177 : Callable callable =
178 180270 : Builtins::CallableFor(isolate(), Builtins::kGetProperty);
179 360540 : ReplaceWithStubCall(node, callable, flags);
180 : return;
181 : }
182 515664 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
183 257832 : if (outer_state->opcode() != IrOpcode::kFrameState) {
184 : Callable callable = Builtins::CallableFor(
185 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
186 : ? Builtins::kLoadICTrampoline_Megamorphic
187 254981 : : Builtins::kLoadICTrampoline);
188 509962 : ReplaceWithStubCall(node, callable, flags);
189 : } else {
190 : Callable callable =
191 : Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
192 : ? Builtins::kLoadIC_Megamorphic
193 2851 : : Builtins::kLoadIC);
194 2851 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
195 2851 : node->InsertInput(zone(), 3, vector);
196 5702 : ReplaceWithStubCall(node, callable, flags);
197 : }
198 : }
199 :
200 560063 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
201 560063 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
202 560063 : const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
203 560063 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
204 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
205 560063 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
206 1120126 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
207 560063 : if (outer_state->opcode() != IrOpcode::kFrameState) {
208 548149 : Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
209 1096298 : ReplaceWithStubCall(node, callable, flags);
210 : } else {
211 : Callable callable =
212 11914 : CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
213 11914 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
214 11914 : node->InsertInput(zone(), 2, vector);
215 23828 : ReplaceWithStubCall(node, callable, flags);
216 : }
217 560063 : }
218 :
219 8802 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
220 8802 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
221 8802 : PropertyAccess const& p = PropertyAccessOf(node->op());
222 8802 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
223 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
224 17604 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
225 8802 : if (outer_state->opcode() != IrOpcode::kFrameState) {
226 : Callable callable =
227 8550 : Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
228 17100 : ReplaceWithStubCall(node, callable, flags);
229 : } else {
230 : Callable callable =
231 252 : Builtins::CallableFor(isolate(), Builtins::kKeyedStoreIC);
232 252 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
233 252 : node->InsertInput(zone(), 4, vector);
234 504 : ReplaceWithStubCall(node, callable, flags);
235 : }
236 8802 : }
237 :
238 82494 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
239 82494 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
240 82494 : NamedAccess const& p = NamedAccessOf(node->op());
241 82494 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
242 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
243 82494 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
244 82494 : if (!p.feedback().IsValid()) {
245 19341 : ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
246 19341 : return;
247 : }
248 126306 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
249 63153 : if (outer_state->opcode() != IrOpcode::kFrameState) {
250 : Callable callable =
251 57780 : Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
252 115560 : ReplaceWithStubCall(node, callable, flags);
253 : } else {
254 5373 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
255 5373 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
256 5373 : node->InsertInput(zone(), 4, vector);
257 10746 : ReplaceWithStubCall(node, callable, flags);
258 : }
259 : }
260 :
261 30649 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
262 30649 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
263 30649 : StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
264 30649 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
265 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
266 30649 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
267 61298 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
268 30649 : if (outer_state->opcode() != IrOpcode::kFrameState) {
269 30616 : Callable callable = CodeFactory::StoreOwnIC(isolate());
270 61232 : ReplaceWithStubCall(node, callable, flags);
271 : } else {
272 33 : Callable callable = CodeFactory::StoreOwnICInOptimizedCode(isolate());
273 33 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
274 33 : node->InsertInput(zone(), 4, vector);
275 66 : ReplaceWithStubCall(node, callable, flags);
276 : }
277 30649 : }
278 :
279 208301 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
280 208301 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
281 208301 : const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
282 208301 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
283 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
284 208301 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
285 416602 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
286 208301 : if (outer_state->opcode() != IrOpcode::kFrameState) {
287 : Callable callable =
288 208265 : Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
289 416530 : ReplaceWithStubCall(node, callable, flags);
290 : } else {
291 : Callable callable =
292 36 : Builtins::CallableFor(isolate(), Builtins::kStoreGlobalIC);
293 36 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
294 36 : node->InsertInput(zone(), 3, vector);
295 72 : ReplaceWithStubCall(node, callable, flags);
296 : }
297 208301 : }
298 :
299 448 : void JSGenericLowering::LowerJSStoreDataPropertyInLiteral(Node* node) {
300 448 : FeedbackParameter const& p = FeedbackParameterOf(node->op());
301 448 : node->InsertInputs(zone(), 4, 2);
302 448 : node->ReplaceInput(4, jsgraph()->HeapConstant(p.feedback().vector()));
303 896 : node->ReplaceInput(5, jsgraph()->SmiConstant(p.feedback().index()));
304 448 : ReplaceWithRuntimeCall(node, Runtime::kDefineDataPropertyInLiteral);
305 448 : }
306 :
307 49520 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
308 : Callable callable =
309 49520 : Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
310 49520 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
311 49520 : FeedbackParameter const& p = FeedbackParameterOf(node->op());
312 : RelaxControls(node);
313 99040 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
314 49520 : node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
315 99040 : ReplaceWithStubCall(node, callable, flags);
316 49520 : }
317 :
318 1072 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
319 1072 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
320 : Callable callable =
321 1072 : Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
322 2144 : ReplaceWithStubCall(node, callable, flags);
323 1072 : }
324 :
325 78 : void JSGenericLowering::LowerJSGetSuperConstructor(Node* node) {
326 78 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
327 : Callable callable =
328 78 : Builtins::CallableFor(isolate(), Builtins::kGetSuperConstructor);
329 156 : ReplaceWithStubCall(node, callable, flags);
330 78 : }
331 :
332 0 : void JSGenericLowering::LowerJSHasInPrototypeChain(Node* node) {
333 0 : ReplaceWithRuntimeCall(node, Runtime::kHasInPrototypeChain);
334 0 : }
335 :
336 2877 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
337 2877 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
338 2877 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
339 5754 : ReplaceWithStubCall(node, callable, flags);
340 2877 : }
341 :
342 88 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
343 88 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
344 : Callable callable =
345 88 : Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
346 176 : ReplaceWithStubCall(node, callable, flags);
347 88 : }
348 :
349 0 : void JSGenericLowering::LowerJSLoadContext(Node* node) {
350 0 : UNREACHABLE(); // Eliminated in typed lowering.
351 : }
352 :
353 :
354 0 : void JSGenericLowering::LowerJSStoreContext(Node* node) {
355 0 : UNREACHABLE(); // Eliminated in typed lowering.
356 : }
357 :
358 :
359 276 : void JSGenericLowering::LowerJSCreate(Node* node) {
360 276 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
361 : Callable callable =
362 276 : Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
363 552 : ReplaceWithStubCall(node, callable, flags);
364 276 : }
365 :
366 :
367 8 : void JSGenericLowering::LowerJSCreateArguments(Node* node) {
368 8 : CreateArgumentsType const type = CreateArgumentsTypeOf(node->op());
369 8 : switch (type) {
370 : case CreateArgumentsType::kMappedArguments:
371 8 : ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
372 8 : break;
373 : case CreateArgumentsType::kUnmappedArguments:
374 0 : ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments);
375 0 : break;
376 : case CreateArgumentsType::kRestParameter:
377 0 : ReplaceWithRuntimeCall(node, Runtime::kNewRestParameter);
378 0 : break;
379 : }
380 8 : }
381 :
382 :
383 169 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
384 169 : CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
385 169 : int const arity = static_cast<int>(p.arity());
386 338 : auto call_descriptor = Linkage::GetStubCallDescriptor(
387 : zone(), ArrayConstructorDescriptor{}, arity + 1,
388 169 : CallDescriptor::kNeedsFrameState, node->op()->properties());
389 169 : Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
390 169 : Node* stub_arity = jsgraph()->Int32Constant(arity);
391 : MaybeHandle<AllocationSite> const maybe_site = p.site();
392 : Handle<AllocationSite> site;
393 : Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
394 252 : : jsgraph()->UndefinedConstant();
395 169 : Node* receiver = jsgraph()->UndefinedConstant();
396 169 : node->InsertInput(zone(), 0, stub_code);
397 169 : node->InsertInput(zone(), 3, stub_arity);
398 169 : node->InsertInput(zone(), 4, type_info);
399 169 : node->InsertInput(zone(), 5, receiver);
400 169 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
401 169 : }
402 :
403 0 : void JSGenericLowering::LowerJSCreateArrayIterator(Node* node) {
404 0 : UNREACHABLE(); // Eliminated in typed lowering.
405 : }
406 :
407 0 : void JSGenericLowering::LowerJSCreateAsyncFunctionObject(Node* node) {
408 0 : UNREACHABLE(); // Eliminated in typed lowering.
409 : }
410 :
411 0 : void JSGenericLowering::LowerJSCreateCollectionIterator(Node* node) {
412 0 : UNREACHABLE(); // Eliminated in typed lowering.
413 : }
414 :
415 0 : void JSGenericLowering::LowerJSCreateBoundFunction(Node* node) {
416 0 : UNREACHABLE(); // Eliminated in typed lowering.
417 : }
418 :
419 0 : void JSGenericLowering::LowerJSObjectIsArray(Node* node) {
420 0 : UNREACHABLE(); // Eliminated in typed lowering.
421 : }
422 :
423 60 : void JSGenericLowering::LowerJSCreateObject(Node* node) {
424 60 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
425 : Callable callable = Builtins::CallableFor(
426 60 : isolate(), Builtins::kCreateObjectWithoutProperties);
427 120 : ReplaceWithStubCall(node, callable, flags);
428 60 : }
429 :
430 186 : void JSGenericLowering::LowerJSParseInt(Node* node) {
431 186 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
432 186 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
433 372 : ReplaceWithStubCall(node, callable, flags);
434 186 : }
435 :
436 484 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
437 484 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
438 : Callable callable =
439 484 : Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
440 968 : ReplaceWithStubCall(node, callable, flags);
441 484 : }
442 :
443 410001 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
444 410001 : CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
445 : Handle<SharedFunctionInfo> const shared_info = p.shared_info();
446 410002 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
447 410005 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
448 410005 : node->RemoveInput(4); // control
449 :
450 : // Use the FastNewClosure builtin only for functions allocated in new space.
451 410004 : if (p.allocation() == AllocationType::kYoung) {
452 : Callable callable =
453 396510 : Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
454 396508 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
455 793018 : ReplaceWithStubCall(node, callable, flags);
456 : } else {
457 13494 : ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
458 : }
459 410004 : }
460 :
461 :
462 4774 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
463 : const CreateFunctionContextParameters& parameters =
464 4774 : CreateFunctionContextParametersOf(node->op());
465 : Handle<ScopeInfo> scope_info = parameters.scope_info();
466 : int slot_count = parameters.slot_count();
467 : ScopeType scope_type = parameters.scope_type();
468 4774 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
469 :
470 4774 : if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
471 : Callable callable =
472 4774 : CodeFactory::FastNewFunctionContext(isolate(), scope_type);
473 4774 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
474 4774 : node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
475 9548 : ReplaceWithStubCall(node, callable, flags);
476 : } else {
477 0 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
478 0 : ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
479 : }
480 4774 : }
481 :
482 784 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
483 784 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
484 : Callable callable =
485 784 : Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
486 784 : node->RemoveInput(4); // control
487 1568 : ReplaceWithStubCall(node, callable, flags);
488 784 : }
489 :
490 0 : void JSGenericLowering::LowerJSCreateIterResultObject(Node* node) {
491 0 : UNREACHABLE(); // Eliminated in typed lowering.
492 : }
493 :
494 0 : void JSGenericLowering::LowerJSCreateStringIterator(Node* node) {
495 0 : UNREACHABLE(); // Eliminated in typed lowering.
496 : }
497 :
498 0 : void JSGenericLowering::LowerJSCreateKeyValueArray(Node* node) {
499 0 : UNREACHABLE(); // Eliminated in typed lowering.
500 : }
501 :
502 0 : void JSGenericLowering::LowerJSCreatePromise(Node* node) {
503 0 : UNREACHABLE(); // Eliminated in typed lowering.
504 : }
505 :
506 619 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
507 619 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
508 : Callable callable =
509 619 : Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
510 1238 : ReplaceWithStubCall(node, callable, flags);
511 619 : }
512 :
513 5620 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
514 5620 : CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
515 5620 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
516 5620 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
517 11240 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
518 5620 : 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 5620 : if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
523 : p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
524 : Callable callable =
525 5223 : Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
526 10446 : ReplaceWithStubCall(node, callable, flags);
527 : } else {
528 397 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
529 397 : ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
530 : }
531 5620 : }
532 :
533 21388 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
534 21388 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
535 21388 : FeedbackParameter const& p = FeedbackParameterOf(node->op());
536 21388 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
537 42776 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
538 21388 : node->RemoveInput(4); // control
539 : Callable callable =
540 21388 : Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
541 42776 : ReplaceWithStubCall(node, callable, flags);
542 21388 : }
543 :
544 545 : void JSGenericLowering::LowerJSCreateArrayFromIterable(Node* node) {
545 545 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
546 : Callable callable = Builtins::CallableFor(
547 545 : isolate(), Builtins::kIterableToListWithSymbolLookup);
548 1090 : ReplaceWithStubCall(node, callable, flags);
549 545 : }
550 :
551 13005 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
552 13005 : CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
553 13005 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
554 13005 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
555 26010 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
556 13005 : node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
557 13005 : 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 13005 : if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
562 : p.length() <=
563 : ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
564 : Callable callable =
565 12418 : Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
566 24836 : ReplaceWithStubCall(node, callable, flags);
567 : } else {
568 587 : ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
569 : }
570 13005 : }
571 :
572 94 : void JSGenericLowering::LowerJSCloneObject(Node* node) {
573 94 : CloneObjectParameters const& p = CloneObjectParametersOf(node->op());
574 94 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
575 : Callable callable =
576 94 : Builtins::CallableFor(isolate(), Builtins::kCloneObjectIC);
577 94 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.flags()));
578 188 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
579 94 : node->InsertInput(zone(), 3, jsgraph()->HeapConstant(p.feedback().vector()));
580 188 : ReplaceWithStubCall(node, callable, flags);
581 94 : }
582 :
583 0 : void JSGenericLowering::LowerJSCreateEmptyLiteralObject(Node* node) {
584 0 : UNREACHABLE(); // Eliminated in typed lowering.
585 : }
586 :
587 5899 : void JSGenericLowering::LowerJSCreateLiteralRegExp(Node* node) {
588 5899 : CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
589 5899 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
590 : Callable callable =
591 5899 : Builtins::CallableFor(isolate(), Builtins::kCreateRegExpLiteral);
592 5899 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
593 11798 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
594 5899 : node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
595 5899 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
596 11798 : ReplaceWithStubCall(node, callable, flags);
597 5899 : }
598 :
599 :
600 0 : void JSGenericLowering::LowerJSCreateCatchContext(Node* node) {
601 0 : UNREACHABLE(); // Eliminated in typed lowering.
602 : }
603 :
604 0 : void JSGenericLowering::LowerJSCreateWithContext(Node* node) {
605 0 : UNREACHABLE(); // Eliminated in typed lowering.
606 : }
607 :
608 0 : void JSGenericLowering::LowerJSCreateBlockContext(Node* node) {
609 0 : Handle<ScopeInfo> scope_info = ScopeInfoOf(node->op());
610 0 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
611 0 : ReplaceWithRuntimeCall(node, Runtime::kPushBlockContext);
612 0 : }
613 :
614 41 : void JSGenericLowering::LowerJSConstructForwardVarargs(Node* node) {
615 : ConstructForwardVarargsParameters p =
616 41 : ConstructForwardVarargsParametersOf(node->op());
617 41 : int const arg_count = static_cast<int>(p.arity() - 2);
618 41 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
619 41 : Callable callable = CodeFactory::ConstructForwardVarargs(isolate());
620 82 : auto call_descriptor = Linkage::GetStubCallDescriptor(
621 82 : zone(), callable.descriptor(), arg_count + 1, flags);
622 41 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
623 41 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
624 41 : Node* start_index = jsgraph()->Uint32Constant(p.start_index());
625 : Node* new_target = node->InputAt(arg_count + 1);
626 41 : Node* receiver = jsgraph()->UndefinedConstant();
627 41 : node->RemoveInput(arg_count + 1); // Drop new target.
628 41 : node->InsertInput(zone(), 0, stub_code);
629 41 : node->InsertInput(zone(), 2, new_target);
630 41 : node->InsertInput(zone(), 3, stub_arity);
631 41 : node->InsertInput(zone(), 4, start_index);
632 41 : node->InsertInput(zone(), 5, receiver);
633 41 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
634 41 : }
635 :
636 32844 : void JSGenericLowering::LowerJSConstruct(Node* node) {
637 32844 : ConstructParameters const& p = ConstructParametersOf(node->op());
638 32844 : int const arg_count = static_cast<int>(p.arity() - 2);
639 32844 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
640 32844 : Callable callable = CodeFactory::Construct(isolate());
641 65688 : auto call_descriptor = Linkage::GetStubCallDescriptor(
642 65688 : zone(), callable.descriptor(), arg_count + 1, flags);
643 32844 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
644 32844 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
645 : Node* new_target = node->InputAt(arg_count + 1);
646 32844 : Node* receiver = jsgraph()->UndefinedConstant();
647 32844 : node->RemoveInput(arg_count + 1); // Drop new target.
648 32844 : node->InsertInput(zone(), 0, stub_code);
649 32844 : node->InsertInput(zone(), 2, new_target);
650 32844 : node->InsertInput(zone(), 3, stub_arity);
651 32844 : node->InsertInput(zone(), 4, receiver);
652 32844 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
653 32844 : }
654 :
655 63 : void JSGenericLowering::LowerJSConstructWithArrayLike(Node* node) {
656 : Callable callable =
657 63 : Builtins::CallableFor(isolate(), Builtins::kConstructWithArrayLike);
658 63 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
659 : auto call_descriptor =
660 126 : Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
661 63 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
662 63 : Node* receiver = jsgraph()->UndefinedConstant();
663 : Node* arguments_list = node->InputAt(1);
664 : Node* new_target = node->InputAt(2);
665 63 : node->InsertInput(zone(), 0, stub_code);
666 63 : node->ReplaceInput(2, new_target);
667 63 : node->ReplaceInput(3, arguments_list);
668 63 : node->InsertInput(zone(), 4, receiver);
669 63 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
670 63 : }
671 :
672 66 : void JSGenericLowering::LowerJSConstructWithSpread(Node* node) {
673 66 : ConstructParameters const& p = ConstructParametersOf(node->op());
674 66 : int const arg_count = static_cast<int>(p.arity() - 2);
675 : int const spread_index = arg_count;
676 66 : int const new_target_index = arg_count + 1;
677 66 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
678 66 : Callable callable = CodeFactory::ConstructWithSpread(isolate());
679 66 : auto call_descriptor = Linkage::GetStubCallDescriptor(
680 132 : zone(), callable.descriptor(), arg_count, flags);
681 66 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
682 66 : Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
683 : Node* new_target = node->InputAt(new_target_index);
684 : Node* spread = node->InputAt(spread_index);
685 66 : Node* receiver = jsgraph()->UndefinedConstant();
686 : DCHECK(new_target_index > spread_index);
687 66 : node->RemoveInput(new_target_index); // Drop new target.
688 66 : node->RemoveInput(spread_index);
689 :
690 66 : node->InsertInput(zone(), 0, stub_code);
691 66 : node->InsertInput(zone(), 2, new_target);
692 66 : node->InsertInput(zone(), 3, stack_arg_count);
693 66 : node->InsertInput(zone(), 4, spread);
694 66 : node->InsertInput(zone(), 5, receiver);
695 66 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
696 66 : }
697 :
698 82 : void JSGenericLowering::LowerJSCallForwardVarargs(Node* node) {
699 82 : CallForwardVarargsParameters p = CallForwardVarargsParametersOf(node->op());
700 82 : int const arg_count = static_cast<int>(p.arity() - 2);
701 82 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
702 82 : Callable callable = CodeFactory::CallForwardVarargs(isolate());
703 164 : auto call_descriptor = Linkage::GetStubCallDescriptor(
704 164 : zone(), callable.descriptor(), arg_count + 1, flags);
705 82 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
706 82 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
707 82 : Node* start_index = jsgraph()->Uint32Constant(p.start_index());
708 82 : node->InsertInput(zone(), 0, stub_code);
709 82 : node->InsertInput(zone(), 2, stub_arity);
710 82 : node->InsertInput(zone(), 3, start_index);
711 82 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
712 82 : }
713 :
714 447943 : void JSGenericLowering::LowerJSCall(Node* node) {
715 447943 : CallParameters const& p = CallParametersOf(node->op());
716 447943 : int const arg_count = static_cast<int>(p.arity() - 2);
717 : ConvertReceiverMode const mode = p.convert_mode();
718 447943 : Callable callable = CodeFactory::Call(isolate(), mode);
719 447943 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
720 895886 : auto call_descriptor = Linkage::GetStubCallDescriptor(
721 895886 : zone(), callable.descriptor(), arg_count + 1, flags);
722 447943 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
723 447943 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
724 447943 : node->InsertInput(zone(), 0, stub_code);
725 447943 : node->InsertInput(zone(), 2, stub_arity);
726 447943 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
727 447943 : }
728 :
729 362 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
730 362 : Callable callable = CodeFactory::CallWithArrayLike(isolate());
731 362 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
732 : auto call_descriptor =
733 724 : Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
734 362 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
735 : Node* receiver = node->InputAt(1);
736 : Node* arguments_list = node->InputAt(2);
737 362 : node->InsertInput(zone(), 0, stub_code);
738 362 : node->ReplaceInput(3, receiver);
739 362 : node->ReplaceInput(2, arguments_list);
740 362 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
741 362 : }
742 :
743 903 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
744 903 : CallParameters const& p = CallParametersOf(node->op());
745 903 : int const arg_count = static_cast<int>(p.arity() - 2);
746 903 : int const spread_index = static_cast<int>(p.arity() + 1);
747 903 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
748 903 : Callable callable = CodeFactory::CallWithSpread(isolate());
749 903 : auto call_descriptor = Linkage::GetStubCallDescriptor(
750 1806 : zone(), callable.descriptor(), arg_count, flags);
751 903 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
752 : // We pass the spread in a register, not on the stack.
753 903 : Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
754 903 : node->InsertInput(zone(), 0, stub_code);
755 903 : node->InsertInput(zone(), 2, stack_arg_count);
756 903 : node->InsertInput(zone(), 3, node->InputAt(spread_index));
757 903 : node->RemoveInput(spread_index + 1);
758 903 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
759 903 : }
760 :
761 313790 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
762 313790 : const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
763 313790 : ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
764 313790 : }
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 525760 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
812 525760 : Node* effect = NodeProperties::GetEffectInput(node);
813 525761 : Node* control = NodeProperties::GetControlInput(node);
814 :
815 525761 : Node* limit = effect = graph()->NewNode(
816 : machine()->Load(MachineType::Pointer()),
817 : jsgraph()->ExternalConstant(
818 : ExternalReference::address_of_stack_limit(isolate())),
819 : jsgraph()->IntPtrConstant(0), effect, control);
820 525762 : Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
821 :
822 525762 : Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
823 : Node* branch =
824 525757 : graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
825 :
826 525761 : Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
827 : Node* etrue = effect;
828 :
829 525763 : Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
830 525762 : NodeProperties::ReplaceControlInput(node, if_false);
831 525761 : NodeProperties::ReplaceEffectInput(node, effect);
832 : Node* efalse = if_false = node;
833 :
834 525761 : Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
835 525760 : Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
836 :
837 : // Wire the new diamond into the graph, {node} can still throw.
838 525761 : NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
839 525761 : NodeProperties::ReplaceControlInput(merge, if_false, 1);
840 525761 : 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 4190786 : for (Edge edge : merge->use_edges()) {
846 1832513 : if (!NodeProperties::IsControlEdge(edge)) continue;
847 1832511 : if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
848 7171 : NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
849 7171 : NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
850 7171 : edge.UpdateTo(node);
851 : }
852 1832509 : if (edge.from()->opcode() == IrOpcode::kIfException) {
853 7171 : NodeProperties::ReplaceEffectInput(edge.from(), node);
854 7171 : edge.UpdateTo(node);
855 : }
856 : }
857 :
858 : // Turn the stack check into a runtime call.
859 525760 : ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
860 525760 : }
861 :
862 916 : void JSGenericLowering::LowerJSDebugger(Node* node) {
863 916 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
864 916 : Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
865 1832 : ReplaceWithStubCall(node, callable, flags);
866 916 : }
867 :
868 0 : Zone* JSGenericLowering::zone() const { return graph()->zone(); }
869 :
870 :
871 0 : Isolate* JSGenericLowering::isolate() const { return jsgraph()->isolate(); }
872 :
873 :
874 0 : Graph* JSGenericLowering::graph() const { return jsgraph()->graph(); }
875 :
876 :
877 0 : CommonOperatorBuilder* JSGenericLowering::common() const {
878 0 : return jsgraph()->common();
879 : }
880 :
881 :
882 0 : MachineOperatorBuilder* JSGenericLowering::machine() const {
883 0 : return jsgraph()->machine();
884 : }
885 :
886 : } // namespace compiler
887 : } // namespace internal
888 121996 : } // namespace v8
|