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 3394479 : return OperatorProperties::HasFrameStateInput(node->op())
28 : ? CallDescriptor::kNeedsFrameState
29 3394491 : : CallDescriptor::kNoFlags;
30 : }
31 :
32 : } // namespace
33 :
34 464403 : JSGenericLowering::JSGenericLowering(JSGraph* jsgraph, Editor* editor)
35 464403 : : AdvancedReducer(editor), jsgraph_(jsgraph) {}
36 :
37 : JSGenericLowering::~JSGenericLowering() = default;
38 :
39 :
40 44348259 : Reduction JSGenericLowering::Reduce(Node* node) {
41 44348259 : switch (node->opcode()) {
42 : #define DECLARE_CASE(x) \
43 : case IrOpcode::k##x: \
44 : Lower##x(node); \
45 : break;
46 12077 : 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 173195 : REPLACE_STUB_CALL(Add)
62 26160 : REPLACE_STUB_CALL(Subtract)
63 29860 : REPLACE_STUB_CALL(Multiply)
64 53700 : REPLACE_STUB_CALL(Divide)
65 3105 : REPLACE_STUB_CALL(Modulus)
66 755 : REPLACE_STUB_CALL(Exponentiate)
67 35835 : REPLACE_STUB_CALL(BitwiseAnd)
68 44850 : REPLACE_STUB_CALL(BitwiseOr)
69 1285 : REPLACE_STUB_CALL(BitwiseXor)
70 10405 : REPLACE_STUB_CALL(ShiftLeft)
71 2640 : REPLACE_STUB_CALL(ShiftRight)
72 4800 : REPLACE_STUB_CALL(ShiftRightLogical)
73 95980 : REPLACE_STUB_CALL(LessThan)
74 7265 : REPLACE_STUB_CALL(LessThanOrEqual)
75 85325 : REPLACE_STUB_CALL(GreaterThan)
76 7835 : REPLACE_STUB_CALL(GreaterThanOrEqual)
77 660 : REPLACE_STUB_CALL(BitwiseNot)
78 10260 : REPLACE_STUB_CALL(Decrement)
79 52305 : REPLACE_STUB_CALL(Increment)
80 19685 : REPLACE_STUB_CALL(Negate)
81 7935 : REPLACE_STUB_CALL(HasProperty)
82 45965 : REPLACE_STUB_CALL(Equal)
83 135 : REPLACE_STUB_CALL(ToLength)
84 38065 : REPLACE_STUB_CALL(ToNumber)
85 360 : REPLACE_STUB_CALL(ToNumberConvertBigInt)
86 15080 : REPLACE_STUB_CALL(ToNumeric)
87 5425 : REPLACE_STUB_CALL(ToName)
88 0 : REPLACE_STUB_CALL(ToObject)
89 10705 : REPLACE_STUB_CALL(ToString)
90 7210 : REPLACE_STUB_CALL(ForInEnumerate)
91 620 : REPLACE_STUB_CALL(AsyncFunctionEnter)
92 535 : 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 2016081 : void JSGenericLowering::ReplaceWithStubCall(Node* node,
102 : Callable callable,
103 : CallDescriptor::Flags flags) {
104 4032167 : ReplaceWithStubCall(node, callable, flags, node->op()->properties());
105 2016086 : }
106 :
107 2103515 : 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 2103515 : properties);
115 2103517 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
116 2103519 : node->InsertInput(zone(), 0, stub_code);
117 2103524 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
118 2103520 : }
119 :
120 :
121 875276 : void JSGenericLowering::ReplaceWithRuntimeCall(Node* node,
122 : Runtime::FunctionId f,
123 : int nargs_override) {
124 875285 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
125 875285 : Operator::Properties properties = node->op()->properties();
126 875285 : const Runtime::Function* fun = Runtime::FunctionForId(f);
127 875275 : int nargs = (nargs_override < 0) ? fun->nargs : nargs_override;
128 : auto call_descriptor =
129 875275 : Linkage::GetRuntimeCallDescriptor(zone(), f, nargs, properties, flags);
130 875281 : Node* ref = jsgraph()->ExternalConstant(ExternalReference::Create(f));
131 875285 : Node* arity = jsgraph()->Int32Constant(nargs);
132 875281 : node->InsertInput(zone(), 0, jsgraph()->CEntryStubConstant(fun->result_size));
133 875285 : node->InsertInput(zone(), nargs + 1, ref);
134 875287 : node->InsertInput(zone(), nargs + 2, arity);
135 875285 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
136 875281 : }
137 :
138 87434 : void JSGenericLowering::LowerJSStrictEqual(Node* node) {
139 : // The === operator doesn't need the current context.
140 87434 : NodeProperties::ReplaceContextInput(node, jsgraph()->NoContextConstant());
141 87434 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kStrictEqual);
142 87434 : node->RemoveInput(4); // control
143 87434 : ReplaceWithStubCall(node, callable, CallDescriptor::kNoFlags,
144 87434 : Operator::kEliminatable);
145 87434 : }
146 :
147 39258 : void JSGenericLowering::LowerJSLoadProperty(Node* node) {
148 39258 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
149 39258 : const PropertyAccess& p = PropertyAccessOf(node->op());
150 39258 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
151 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
152 78516 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
153 39258 : if (outer_state->opcode() != IrOpcode::kFrameState) {
154 : Callable callable = Builtins::CallableFor(
155 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
156 : ? Builtins::kKeyedLoadICTrampoline_Megamorphic
157 36991 : : Builtins::kKeyedLoadICTrampoline);
158 73982 : ReplaceWithStubCall(node, callable, flags);
159 : } else {
160 : Callable callable = Builtins::CallableFor(
161 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
162 : ? Builtins::kKeyedLoadIC_Megamorphic
163 2267 : : Builtins::kKeyedLoadIC);
164 2267 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
165 2267 : node->InsertInput(zone(), 3, vector);
166 4534 : ReplaceWithStubCall(node, callable, flags);
167 : }
168 39258 : }
169 :
170 438952 : void JSGenericLowering::LowerJSLoadNamed(Node* node) {
171 438953 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
172 438953 : NamedAccess const& p = NamedAccessOf(node->op());
173 438952 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
174 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
175 438951 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
176 438952 : if (!p.feedback().IsValid()) {
177 : Callable callable =
178 180343 : Builtins::CallableFor(isolate(), Builtins::kGetProperty);
179 360686 : ReplaceWithStubCall(node, callable, flags);
180 : return;
181 : }
182 517216 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
183 258609 : if (outer_state->opcode() != IrOpcode::kFrameState) {
184 : Callable callable = Builtins::CallableFor(
185 : isolate(), p.feedback().ic_state() == MEGAMORPHIC
186 : ? Builtins::kLoadICTrampoline_Megamorphic
187 255741 : : Builtins::kLoadICTrampoline);
188 511481 : ReplaceWithStubCall(node, callable, flags);
189 : } else {
190 : Callable callable =
191 : Builtins::CallableFor(isolate(), p.feedback().ic_state() == MEGAMORPHIC
192 : ? Builtins::kLoadIC_Megamorphic
193 2868 : : Builtins::kLoadIC);
194 2868 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
195 2868 : node->InsertInput(zone(), 3, vector);
196 5736 : ReplaceWithStubCall(node, callable, flags);
197 : }
198 : }
199 :
200 560332 : void JSGenericLowering::LowerJSLoadGlobal(Node* node) {
201 560332 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
202 560332 : const LoadGlobalParameters& p = LoadGlobalParametersOf(node->op());
203 560332 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
204 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
205 560332 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
206 1120665 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
207 560333 : if (outer_state->opcode() != IrOpcode::kFrameState) {
208 548433 : Callable callable = CodeFactory::LoadGlobalIC(isolate(), p.typeof_mode());
209 1096865 : ReplaceWithStubCall(node, callable, flags);
210 : } else {
211 : Callable callable =
212 11900 : CodeFactory::LoadGlobalICInOptimizedCode(isolate(), p.typeof_mode());
213 11900 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
214 11900 : node->InsertInput(zone(), 2, vector);
215 23800 : ReplaceWithStubCall(node, callable, flags);
216 : }
217 560333 : }
218 :
219 8809 : void JSGenericLowering::LowerJSStoreProperty(Node* node) {
220 8809 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
221 8809 : PropertyAccess const& p = PropertyAccessOf(node->op());
222 8809 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
223 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
224 17618 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
225 8809 : if (outer_state->opcode() != IrOpcode::kFrameState) {
226 : Callable callable =
227 8557 : Builtins::CallableFor(isolate(), Builtins::kKeyedStoreICTrampoline);
228 17114 : 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 8809 : }
237 :
238 82639 : void JSGenericLowering::LowerJSStoreNamed(Node* node) {
239 82639 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
240 82639 : NamedAccess const& p = NamedAccessOf(node->op());
241 82639 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
242 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
243 82639 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
244 82639 : if (!p.feedback().IsValid()) {
245 19343 : ReplaceWithRuntimeCall(node, Runtime::kSetNamedProperty);
246 19343 : return;
247 : }
248 126592 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
249 63296 : if (outer_state->opcode() != IrOpcode::kFrameState) {
250 : Callable callable =
251 57925 : Builtins::CallableFor(isolate(), Builtins::kStoreICTrampoline);
252 115850 : ReplaceWithStubCall(node, callable, flags);
253 : } else {
254 5371 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kStoreIC);
255 5371 : Node* vector = jsgraph()->HeapConstant(p.feedback().vector());
256 5371 : node->InsertInput(zone(), 4, vector);
257 10742 : ReplaceWithStubCall(node, callable, flags);
258 : }
259 : }
260 :
261 30697 : void JSGenericLowering::LowerJSStoreNamedOwn(Node* node) {
262 30697 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
263 30697 : StoreNamedOwnParameters const& p = StoreNamedOwnParametersOf(node->op());
264 30697 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
265 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
266 30697 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.name()));
267 61394 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
268 30697 : if (outer_state->opcode() != IrOpcode::kFrameState) {
269 30664 : Callable callable = CodeFactory::StoreOwnIC(isolate());
270 61328 : 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 30697 : }
278 :
279 208370 : void JSGenericLowering::LowerJSStoreGlobal(Node* node) {
280 208370 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
281 208370 : const StoreGlobalParameters& p = StoreGlobalParametersOf(node->op());
282 208370 : Node* frame_state = NodeProperties::GetFrameStateInput(node);
283 : Node* outer_state = frame_state->InputAt(kFrameStateOuterStateInput);
284 208370 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.name()));
285 416740 : node->InsertInput(zone(), 2, jsgraph()->SmiConstant(p.feedback().index()));
286 208370 : if (outer_state->opcode() != IrOpcode::kFrameState) {
287 : Callable callable =
288 208334 : Builtins::CallableFor(isolate(), Builtins::kStoreGlobalICTrampoline);
289 416668 : 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 208370 : }
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 49724 : void JSGenericLowering::LowerJSStoreInArrayLiteral(Node* node) {
308 : Callable callable =
309 49724 : Builtins::CallableFor(isolate(), Builtins::kStoreInArrayLiteralIC);
310 49725 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
311 49725 : FeedbackParameter const& p = FeedbackParameterOf(node->op());
312 : RelaxControls(node);
313 99450 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.feedback().index()));
314 49725 : node->InsertInput(zone(), 4, jsgraph()->HeapConstant(p.feedback().vector()));
315 99450 : ReplaceWithStubCall(node, callable, flags);
316 49725 : }
317 :
318 1055 : void JSGenericLowering::LowerJSDeleteProperty(Node* node) {
319 1055 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
320 : Callable callable =
321 1055 : Builtins::CallableFor(isolate(), Builtins::kDeleteProperty);
322 2110 : ReplaceWithStubCall(node, callable, flags);
323 1055 : }
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 2884 : void JSGenericLowering::LowerJSInstanceOf(Node* node) {
337 2884 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
338 2884 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kInstanceOf);
339 5768 : ReplaceWithStubCall(node, callable, flags);
340 2884 : }
341 :
342 89 : void JSGenericLowering::LowerJSOrdinaryHasInstance(Node* node) {
343 89 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
344 : Callable callable =
345 89 : Builtins::CallableFor(isolate(), Builtins::kOrdinaryHasInstance);
346 178 : ReplaceWithStubCall(node, callable, flags);
347 89 : }
348 :
349 0 : void JSGenericLowering::LowerJSLoadContext(Node* node) {
350 0 : UNREACHABLE(); // Eliminated in typed lowering.
351 : }
352 :
353 :
354 0 : void JSGenericLowering::LowerJSStoreContext(Node* node) {
355 0 : UNREACHABLE(); // Eliminated in typed lowering.
356 : }
357 :
358 :
359 276 : void JSGenericLowering::LowerJSCreate(Node* node) {
360 276 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
361 : Callable callable =
362 276 : Builtins::CallableFor(isolate(), Builtins::kFastNewObject);
363 552 : ReplaceWithStubCall(node, callable, flags);
364 276 : }
365 :
366 :
367 8 : void JSGenericLowering::LowerJSCreateArguments(Node* node) {
368 8 : CreateArgumentsType const type = CreateArgumentsTypeOf(node->op());
369 8 : switch (type) {
370 : case CreateArgumentsType::kMappedArguments:
371 8 : ReplaceWithRuntimeCall(node, Runtime::kNewSloppyArguments_Generic);
372 8 : break;
373 : case CreateArgumentsType::kUnmappedArguments:
374 0 : ReplaceWithRuntimeCall(node, Runtime::kNewStrictArguments);
375 0 : break;
376 : case CreateArgumentsType::kRestParameter:
377 0 : ReplaceWithRuntimeCall(node, Runtime::kNewRestParameter);
378 0 : break;
379 : }
380 8 : }
381 :
382 :
383 167 : void JSGenericLowering::LowerJSCreateArray(Node* node) {
384 167 : CreateArrayParameters const& p = CreateArrayParametersOf(node->op());
385 167 : int const arity = static_cast<int>(p.arity());
386 334 : auto call_descriptor = Linkage::GetStubCallDescriptor(
387 : zone(), ArrayConstructorDescriptor{}, arity + 1,
388 167 : CallDescriptor::kNeedsFrameState, node->op()->properties());
389 167 : Node* stub_code = jsgraph()->ArrayConstructorStubConstant();
390 167 : Node* stub_arity = jsgraph()->Int32Constant(arity);
391 : MaybeHandle<AllocationSite> const maybe_site = p.site();
392 : Handle<AllocationSite> site;
393 : Node* type_info = maybe_site.ToHandle(&site) ? jsgraph()->HeapConstant(site)
394 248 : : jsgraph()->UndefinedConstant();
395 167 : Node* receiver = jsgraph()->UndefinedConstant();
396 167 : node->InsertInput(zone(), 0, stub_code);
397 167 : node->InsertInput(zone(), 3, stub_arity);
398 167 : node->InsertInput(zone(), 4, type_info);
399 167 : node->InsertInput(zone(), 5, receiver);
400 167 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
401 167 : }
402 :
403 0 : void JSGenericLowering::LowerJSCreateArrayIterator(Node* node) {
404 0 : UNREACHABLE(); // Eliminated in typed lowering.
405 : }
406 :
407 0 : void JSGenericLowering::LowerJSCreateAsyncFunctionObject(Node* node) {
408 0 : UNREACHABLE(); // Eliminated in typed lowering.
409 : }
410 :
411 0 : void JSGenericLowering::LowerJSCreateCollectionIterator(Node* node) {
412 0 : UNREACHABLE(); // Eliminated in typed lowering.
413 : }
414 :
415 0 : void JSGenericLowering::LowerJSCreateBoundFunction(Node* node) {
416 0 : UNREACHABLE(); // Eliminated in typed lowering.
417 : }
418 :
419 0 : void JSGenericLowering::LowerJSObjectIsArray(Node* node) {
420 0 : UNREACHABLE(); // Eliminated in typed lowering.
421 : }
422 :
423 60 : void JSGenericLowering::LowerJSCreateObject(Node* node) {
424 60 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
425 : Callable callable = Builtins::CallableFor(
426 60 : isolate(), Builtins::kCreateObjectWithoutProperties);
427 120 : ReplaceWithStubCall(node, callable, flags);
428 60 : }
429 :
430 185 : void JSGenericLowering::LowerJSParseInt(Node* node) {
431 185 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
432 185 : Callable callable = Builtins::CallableFor(isolate(), Builtins::kParseInt);
433 370 : ReplaceWithStubCall(node, callable, flags);
434 185 : }
435 :
436 479 : void JSGenericLowering::LowerJSRegExpTest(Node* node) {
437 479 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
438 : Callable callable =
439 479 : Builtins::CallableFor(isolate(), Builtins::kRegExpPrototypeTestFast);
440 958 : ReplaceWithStubCall(node, callable, flags);
441 479 : }
442 :
443 410236 : void JSGenericLowering::LowerJSCreateClosure(Node* node) {
444 410236 : CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
445 : Handle<SharedFunctionInfo> const shared_info = p.shared_info();
446 410239 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(shared_info));
447 410241 : node->InsertInput(zone(), 1, jsgraph()->HeapConstant(p.feedback_cell()));
448 410241 : node->RemoveInput(4); // control
449 :
450 : // Use the FastNewClosure builtin only for functions allocated in new space.
451 410241 : if (p.allocation() == AllocationType::kYoung) {
452 : Callable callable =
453 396745 : Builtins::CallableFor(isolate(), Builtins::kFastNewClosure);
454 396743 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
455 793488 : ReplaceWithStubCall(node, callable, flags);
456 : } else {
457 13496 : ReplaceWithRuntimeCall(node, Runtime::kNewClosure_Tenured);
458 : }
459 410241 : }
460 :
461 :
462 4775 : void JSGenericLowering::LowerJSCreateFunctionContext(Node* node) {
463 : const CreateFunctionContextParameters& parameters =
464 4775 : CreateFunctionContextParametersOf(node->op());
465 : Handle<ScopeInfo> scope_info = parameters.scope_info();
466 : int slot_count = parameters.slot_count();
467 : ScopeType scope_type = parameters.scope_type();
468 4775 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
469 :
470 4775 : if (slot_count <= ConstructorBuiltins::MaximumFunctionContextSlots()) {
471 : Callable callable =
472 4775 : CodeFactory::FastNewFunctionContext(isolate(), scope_type);
473 4775 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
474 4775 : node->InsertInput(zone(), 1, jsgraph()->Int32Constant(slot_count));
475 9550 : ReplaceWithStubCall(node, callable, flags);
476 : } else {
477 0 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(scope_info));
478 0 : ReplaceWithRuntimeCall(node, Runtime::kNewFunctionContext);
479 : }
480 4775 : }
481 :
482 792 : void JSGenericLowering::LowerJSCreateGeneratorObject(Node* node) {
483 792 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
484 : Callable callable =
485 792 : Builtins::CallableFor(isolate(), Builtins::kCreateGeneratorObject);
486 792 : node->RemoveInput(4); // control
487 1584 : ReplaceWithStubCall(node, callable, flags);
488 792 : }
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 615 : void JSGenericLowering::LowerJSCreateTypedArray(Node* node) {
507 615 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
508 : Callable callable =
509 615 : Builtins::CallableFor(isolate(), Builtins::kCreateTypedArray);
510 1230 : ReplaceWithStubCall(node, callable, flags);
511 615 : }
512 :
513 5617 : void JSGenericLowering::LowerJSCreateLiteralArray(Node* node) {
514 5617 : CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
515 5618 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
516 5618 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
517 11236 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
518 5618 : 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 5618 : if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
523 : p.length() < ConstructorBuiltins::kMaximumClonedShallowArrayElements) {
524 : Callable callable =
525 5221 : Builtins::CallableFor(isolate(), Builtins::kCreateShallowArrayLiteral);
526 10441 : ReplaceWithStubCall(node, callable, flags);
527 : } else {
528 397 : node->InsertInput(zone(), 3, jsgraph()->SmiConstant(p.flags()));
529 397 : ReplaceWithRuntimeCall(node, Runtime::kCreateArrayLiteral);
530 : }
531 5618 : }
532 :
533 21419 : void JSGenericLowering::LowerJSCreateEmptyLiteralArray(Node* node) {
534 21419 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
535 21419 : FeedbackParameter const& p = FeedbackParameterOf(node->op());
536 21419 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
537 42838 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
538 21419 : node->RemoveInput(4); // control
539 : Callable callable =
540 21419 : Builtins::CallableFor(isolate(), Builtins::kCreateEmptyArrayLiteral);
541 42838 : ReplaceWithStubCall(node, callable, flags);
542 21419 : }
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 13021 : void JSGenericLowering::LowerJSCreateLiteralObject(Node* node) {
552 13021 : CreateLiteralParameters const& p = CreateLiteralParametersOf(node->op());
553 13021 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
554 13021 : node->InsertInput(zone(), 0, jsgraph()->HeapConstant(p.feedback().vector()));
555 26042 : node->InsertInput(zone(), 1, jsgraph()->SmiConstant(p.feedback().index()));
556 13021 : node->InsertInput(zone(), 2, jsgraph()->HeapConstant(p.constant()));
557 13021 : 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 13021 : if ((p.flags() & AggregateLiteral::kIsShallow) != 0 &&
562 : p.length() <=
563 : ConstructorBuiltins::kMaximumClonedShallowObjectProperties) {
564 : Callable callable =
565 12433 : Builtins::CallableFor(isolate(), Builtins::kCreateShallowObjectLiteral);
566 24866 : ReplaceWithStubCall(node, callable, flags);
567 : } else {
568 588 : ReplaceWithRuntimeCall(node, Runtime::kCreateObjectLiteral);
569 : }
570 13021 : }
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 32886 : void JSGenericLowering::LowerJSConstruct(Node* node) {
637 32886 : ConstructParameters const& p = ConstructParametersOf(node->op());
638 32886 : int const arg_count = static_cast<int>(p.arity() - 2);
639 32887 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
640 32887 : Callable callable = CodeFactory::Construct(isolate());
641 65772 : auto call_descriptor = Linkage::GetStubCallDescriptor(
642 65772 : zone(), callable.descriptor(), arg_count + 1, flags);
643 32886 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
644 32887 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
645 : Node* new_target = node->InputAt(arg_count + 1);
646 32887 : Node* receiver = jsgraph()->UndefinedConstant();
647 32887 : node->RemoveInput(arg_count + 1); // Drop new target.
648 32887 : node->InsertInput(zone(), 0, stub_code);
649 32887 : node->InsertInput(zone(), 2, new_target);
650 32887 : node->InsertInput(zone(), 3, stub_arity);
651 32887 : node->InsertInput(zone(), 4, receiver);
652 32887 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
653 32887 : }
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 448401 : void JSGenericLowering::LowerJSCall(Node* node) {
715 448401 : CallParameters const& p = CallParametersOf(node->op());
716 448401 : int const arg_count = static_cast<int>(p.arity() - 2);
717 : ConvertReceiverMode const mode = p.convert_mode();
718 448401 : Callable callable = CodeFactory::Call(isolate(), mode);
719 448401 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
720 896802 : auto call_descriptor = Linkage::GetStubCallDescriptor(
721 896802 : zone(), callable.descriptor(), arg_count + 1, flags);
722 448401 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
723 448401 : Node* stub_arity = jsgraph()->Int32Constant(arg_count);
724 448401 : node->InsertInput(zone(), 0, stub_code);
725 448401 : node->InsertInput(zone(), 2, stub_arity);
726 448400 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
727 448400 : }
728 :
729 358 : void JSGenericLowering::LowerJSCallWithArrayLike(Node* node) {
730 358 : Callable callable = CodeFactory::CallWithArrayLike(isolate());
731 358 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
732 : auto call_descriptor =
733 716 : Linkage::GetStubCallDescriptor(zone(), callable.descriptor(), 1, flags);
734 358 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
735 : Node* receiver = node->InputAt(1);
736 : Node* arguments_list = node->InputAt(2);
737 358 : node->InsertInput(zone(), 0, stub_code);
738 358 : node->ReplaceInput(3, receiver);
739 358 : node->ReplaceInput(2, arguments_list);
740 358 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
741 358 : }
742 :
743 893 : void JSGenericLowering::LowerJSCallWithSpread(Node* node) {
744 893 : CallParameters const& p = CallParametersOf(node->op());
745 893 : int const arg_count = static_cast<int>(p.arity() - 2);
746 893 : int const spread_index = static_cast<int>(p.arity() + 1);
747 893 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
748 893 : Callable callable = CodeFactory::CallWithSpread(isolate());
749 893 : auto call_descriptor = Linkage::GetStubCallDescriptor(
750 1786 : zone(), callable.descriptor(), arg_count, flags);
751 893 : Node* stub_code = jsgraph()->HeapConstant(callable.code());
752 : // We pass the spread in a register, not on the stack.
753 893 : Node* stack_arg_count = jsgraph()->Int32Constant(arg_count - 1);
754 893 : node->InsertInput(zone(), 0, stub_code);
755 893 : node->InsertInput(zone(), 2, stack_arg_count);
756 893 : node->InsertInput(zone(), 3, node->InputAt(spread_index));
757 893 : node->RemoveInput(spread_index + 1);
758 893 : NodeProperties::ChangeOp(node, common()->Call(call_descriptor));
759 893 : }
760 :
761 314930 : void JSGenericLowering::LowerJSCallRuntime(Node* node) {
762 314930 : const CallRuntimeParameters& p = CallRuntimeParametersOf(node->op());
763 314930 : ReplaceWithRuntimeCall(node, p.id(), static_cast<int>(p.arity()));
764 314930 : }
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 526068 : void JSGenericLowering::LowerJSStackCheck(Node* node) {
812 526068 : Node* effect = NodeProperties::GetEffectInput(node);
813 526074 : Node* control = NodeProperties::GetControlInput(node);
814 :
815 526077 : 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 526076 : Node* pointer = graph()->NewNode(machine()->LoadStackPointer());
821 :
822 526075 : Node* check = graph()->NewNode(machine()->UintLessThan(), limit, pointer);
823 : Node* branch =
824 526077 : graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
825 :
826 526074 : Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
827 : Node* etrue = effect;
828 :
829 526076 : Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
830 526075 : NodeProperties::ReplaceControlInput(node, if_false);
831 526072 : NodeProperties::ReplaceEffectInput(node, effect);
832 : Node* efalse = if_false = node;
833 :
834 526076 : Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
835 526075 : Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
836 :
837 : // Wire the new diamond into the graph, {node} can still throw.
838 526072 : NodeProperties::ReplaceUses(node, node, ephi, merge, merge);
839 526077 : NodeProperties::ReplaceControlInput(merge, if_false, 1);
840 526074 : 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 4189517 : for (Edge edge : merge->use_edges()) {
846 1831721 : if (!NodeProperties::IsControlEdge(edge)) continue;
847 1831733 : if (edge.from()->opcode() == IrOpcode::kIfSuccess) {
848 7167 : NodeProperties::ReplaceUses(edge.from(), nullptr, nullptr, merge);
849 7167 : NodeProperties::ReplaceControlInput(merge, edge.from(), 1);
850 7167 : edge.UpdateTo(node);
851 : }
852 1831720 : if (edge.from()->opcode() == IrOpcode::kIfException) {
853 7167 : NodeProperties::ReplaceEffectInput(edge.from(), node);
854 7167 : edge.UpdateTo(node);
855 : }
856 : }
857 :
858 : // Turn the stack check into a runtime call.
859 526075 : ReplaceWithRuntimeCall(node, Runtime::kStackGuard);
860 526071 : }
861 :
862 914 : void JSGenericLowering::LowerJSDebugger(Node* node) {
863 914 : CallDescriptor::Flags flags = FrameStateFlagForCall(node);
864 914 : Callable callable = CodeFactory::HandleDebuggerStatement(isolate());
865 1828 : ReplaceWithStubCall(node, callable, flags);
866 914 : }
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 122036 : } // namespace v8
|