[DFG] Should not fixup AnyIntUse in 32_64
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGFixupPhase.cpp
1 /*
2  * Copyright (C) 2012-2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #include "config.h"
27 #include "DFGFixupPhase.h"
28
29 #if ENABLE(DFG_JIT)
30
31 #include "ArrayPrototype.h"
32 #include "DFGGraph.h"
33 #include "DFGInferredTypeCheck.h"
34 #include "DFGInsertionSet.h"
35 #include "DFGPhase.h"
36 #include "DFGPredictionPropagationPhase.h"
37 #include "DFGVariableAccessDataDump.h"
38 #include "JSCInlines.h"
39 #include "TypeLocation.h"
40
41 namespace JSC { namespace DFG {
42
43 class FixupPhase : public Phase {
44 public:
45     FixupPhase(Graph& graph)
46         : Phase(graph, "fixup")
47         , m_insertionSet(graph)
48     {
49     }
50     
51     bool run()
52     {
53         ASSERT(m_graph.m_fixpointState == BeforeFixpoint);
54         ASSERT(m_graph.m_form == ThreadedCPS);
55         
56         m_profitabilityChanged = false;
57         for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex)
58             fixupBlock(m_graph.block(blockIndex));
59         
60         while (m_profitabilityChanged) {
61             m_profitabilityChanged = false;
62             
63             for (unsigned i = m_graph.m_argumentPositions.size(); i--;)
64                 m_graph.m_argumentPositions[i].mergeArgumentUnboxingAwareness();
65             
66             for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex)
67                 fixupGetAndSetLocalsInBlock(m_graph.block(blockIndex));
68         }
69         
70         for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex)
71             fixupChecksInBlock(m_graph.block(blockIndex));
72
73         m_graph.m_planStage = PlanStage::AfterFixup;
74
75         return true;
76     }
77
78 private:
79     void fixupBlock(BasicBlock* block)
80     {
81         if (!block)
82             return;
83         ASSERT(block->isReachable);
84         m_block = block;
85         for (m_indexInBlock = 0; m_indexInBlock < block->size(); ++m_indexInBlock) {
86             m_currentNode = block->at(m_indexInBlock);
87             fixupNode(m_currentNode);
88         }
89         m_insertionSet.execute(block);
90     }
91     
92     void fixupNode(Node* node)
93     {
94         NodeType op = node->op();
95
96         switch (op) {
97         case SetLocal: {
98             // This gets handled by fixupGetAndSetLocalsInBlock().
99             return;
100         }
101             
102         case BitAnd:
103         case BitOr:
104         case BitXor:
105         case BitRShift:
106         case BitLShift:
107         case BitURShift: {
108             if (Node::shouldSpeculateUntypedForBitOps(node->child1().node(), node->child2().node())) {
109                 fixEdge<UntypedUse>(node->child1());
110                 fixEdge<UntypedUse>(node->child2());
111                 break;
112             }
113             fixIntConvertingEdge(node->child1());
114             fixIntConvertingEdge(node->child2());
115             break;
116         }
117
118         case ArithIMul: {
119             fixIntConvertingEdge(node->child1());
120             fixIntConvertingEdge(node->child2());
121             node->setOp(ArithMul);
122             node->setArithMode(Arith::Unchecked);
123             node->child1().setUseKind(Int32Use);
124             node->child2().setUseKind(Int32Use);
125             break;
126         }
127
128         case ArithClz32: {
129             fixIntConvertingEdge(node->child1());
130             node->setArithMode(Arith::Unchecked);
131             break;
132         }
133             
134         case UInt32ToNumber: {
135             fixIntConvertingEdge(node->child1());
136             if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
137                 node->convertToIdentity();
138             else if (node->canSpeculateInt32(FixupPass))
139                 node->setArithMode(Arith::CheckOverflow);
140             else {
141                 node->setArithMode(Arith::DoOverflow);
142                 node->clearFlags(NodeMustGenerate);
143                 node->setResult(enableInt52() ? NodeResultInt52 : NodeResultDouble);
144             }
145             break;
146         }
147             
148         case ValueAdd: {
149             if (attemptToMakeIntegerAdd(node)) {
150                 node->setOp(ArithAdd);
151                 break;
152             }
153             if (Node::shouldSpeculateNumberOrBooleanExpectingDefined(node->child1().node(), node->child2().node())) {
154                 fixDoubleOrBooleanEdge(node->child1());
155                 fixDoubleOrBooleanEdge(node->child2());
156                 node->setOp(ArithAdd);
157                 node->setResult(NodeResultDouble);
158                 break;
159             }
160             
161             if (attemptToMakeFastStringAdd(node))
162                 break;
163
164             fixEdge<UntypedUse>(node->child1());
165             fixEdge<UntypedUse>(node->child2());
166             node->setResult(NodeResultJS);
167             break;
168         }
169
170         case StrCat: {
171             if (attemptToMakeFastStringAdd(node))
172                 break;
173
174             // FIXME: Remove empty string arguments and possibly turn this into a ToString operation. That
175             // would require a form of ToString that takes a KnownPrimitiveUse. This is necessary because
176             // the implementation of StrCat doesn't dynamically optimize for empty strings.
177             // https://bugs.webkit.org/show_bug.cgi?id=148540
178             m_graph.doToChildren(
179                 node,
180                 [&] (Edge& edge) {
181                     fixEdge<KnownPrimitiveUse>(edge);
182                 });
183             break;
184         }
185             
186         case MakeRope: {
187             fixupMakeRope(node);
188             break;
189         }
190             
191         case ArithAdd:
192         case ArithSub: {
193             if (op == ArithSub
194                 && Node::shouldSpeculateUntypedForArithmetic(node->child1().node(), node->child2().node())) {
195                 fixEdge<UntypedUse>(node->child1());
196                 fixEdge<UntypedUse>(node->child2());
197                 node->setResult(NodeResultJS);
198                 break;
199             }
200             if (attemptToMakeIntegerAdd(node))
201                 break;
202             fixDoubleOrBooleanEdge(node->child1());
203             fixDoubleOrBooleanEdge(node->child2());
204             node->setResult(NodeResultDouble);
205             break;
206         }
207             
208         case ArithNegate: {
209             if (m_graph.unaryArithShouldSpeculateInt32(node, FixupPass)) {
210                 fixIntOrBooleanEdge(node->child1());
211                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
212                     node->setArithMode(Arith::Unchecked);
213                 else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
214                     node->setArithMode(Arith::CheckOverflow);
215                 else
216                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
217                 break;
218             }
219             if (m_graph.unaryArithShouldSpeculateAnyInt(node, FixupPass)) {
220                 fixEdge<Int52RepUse>(node->child1());
221                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
222                     node->setArithMode(Arith::CheckOverflow);
223                 else
224                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
225                 node->setResult(NodeResultInt52);
226                 break;
227             }
228             fixDoubleOrBooleanEdge(node->child1());
229             node->setResult(NodeResultDouble);
230             break;
231         }
232             
233         case ArithMul: {
234             Edge& leftChild = node->child1();
235             Edge& rightChild = node->child2();
236             if (Node::shouldSpeculateUntypedForArithmetic(leftChild.node(), rightChild.node())) {
237                 fixEdge<UntypedUse>(leftChild);
238                 fixEdge<UntypedUse>(rightChild);
239                 node->setResult(NodeResultJS);
240                 break;
241             }
242             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
243                 fixIntOrBooleanEdge(leftChild);
244                 fixIntOrBooleanEdge(rightChild);
245                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
246                     node->setArithMode(Arith::Unchecked);
247                 else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags())
248                     || leftChild.node() == rightChild.node())
249                     node->setArithMode(Arith::CheckOverflow);
250                 else
251                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
252                 break;
253             }
254             if (m_graph.binaryArithShouldSpeculateAnyInt(node, FixupPass)) {
255                 fixEdge<Int52RepUse>(leftChild);
256                 fixEdge<Int52RepUse>(rightChild);
257                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags())
258                     || leftChild.node() == rightChild.node())
259                     node->setArithMode(Arith::CheckOverflow);
260                 else
261                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
262                 node->setResult(NodeResultInt52);
263                 break;
264             }
265             fixDoubleOrBooleanEdge(leftChild);
266             fixDoubleOrBooleanEdge(rightChild);
267             node->setResult(NodeResultDouble);
268             break;
269         }
270
271         case ArithDiv:
272         case ArithMod: {
273             Edge& leftChild = node->child1();
274             Edge& rightChild = node->child2();
275             if (op == ArithDiv
276                 && Node::shouldSpeculateUntypedForArithmetic(leftChild.node(), rightChild.node())
277                 && m_graph.hasExitSite(node->origin.semantic, BadType)) {
278                 fixEdge<UntypedUse>(leftChild);
279                 fixEdge<UntypedUse>(rightChild);
280                 node->setResult(NodeResultJS);
281                 break;
282             }
283             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
284                 if (optimizeForX86() || optimizeForARM64() || optimizeForARMv7IDIVSupported()) {
285                     fixIntOrBooleanEdge(leftChild);
286                     fixIntOrBooleanEdge(rightChild);
287                     if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
288                         node->setArithMode(Arith::Unchecked);
289                     else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
290                         node->setArithMode(Arith::CheckOverflow);
291                     else
292                         node->setArithMode(Arith::CheckOverflowAndNegativeZero);
293                     break;
294                 }
295                 
296                 // This will cause conversion nodes to be inserted later.
297                 fixDoubleOrBooleanEdge(leftChild);
298                 fixDoubleOrBooleanEdge(rightChild);
299                 
300                 // We don't need to do ref'ing on the children because we're stealing them from
301                 // the original division.
302                 Node* newDivision = m_insertionSet.insertNode(
303                     m_indexInBlock, SpecBytecodeDouble, *node);
304                 newDivision->setResult(NodeResultDouble);
305                 
306                 node->setOp(DoubleAsInt32);
307                 node->children.initialize(Edge(newDivision, DoubleRepUse), Edge(), Edge());
308                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
309                     node->setArithMode(Arith::CheckOverflow);
310                 else
311                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
312                 break;
313             }
314             fixDoubleOrBooleanEdge(leftChild);
315             fixDoubleOrBooleanEdge(rightChild);
316             node->setResult(NodeResultDouble);
317             break;
318         }
319             
320         case ArithMin:
321         case ArithMax: {
322             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
323                 fixIntOrBooleanEdge(node->child1());
324                 fixIntOrBooleanEdge(node->child2());
325                 break;
326             }
327             fixDoubleOrBooleanEdge(node->child1());
328             fixDoubleOrBooleanEdge(node->child2());
329             node->setResult(NodeResultDouble);
330             break;
331         }
332             
333         case ArithAbs: {
334             if (m_graph.unaryArithShouldSpeculateInt32(node, FixupPass)) {
335                 fixIntOrBooleanEdge(node->child1());
336                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
337                     node->setArithMode(Arith::Unchecked);
338                 else
339                     node->setArithMode(Arith::CheckOverflow);
340                 break;
341             }
342             fixDoubleOrBooleanEdge(node->child1());
343             node->setResult(NodeResultDouble);
344             break;
345         }
346
347         case ArithPow: {
348             if (node->child2()->shouldSpeculateInt32OrBooleanForArithmetic()) {
349                 fixDoubleOrBooleanEdge(node->child1());
350                 fixIntOrBooleanEdge(node->child2());
351                 break;
352             }
353
354             fixDoubleOrBooleanEdge(node->child1());
355             fixDoubleOrBooleanEdge(node->child2());
356             break;
357         }
358
359         case ArithRandom: {
360             node->setResult(NodeResultDouble);
361             break;
362         }
363
364         case ArithRound:
365         case ArithFloor:
366         case ArithCeil:
367         case ArithTrunc: {
368             if (m_graph.unaryArithShouldSpeculateInt32(node, FixupPass)) {
369                 fixIntOrBooleanEdge(node->child1());
370                 insertCheck<Int32Use>(m_indexInBlock, node->child1().node());
371                 node->convertToIdentity();
372                 break;
373             }
374             fixDoubleOrBooleanEdge(node->child1());
375
376             if (isInt32OrBooleanSpeculation(node->getHeapPrediction()) && m_graph.roundShouldSpeculateInt32(node, FixupPass)) {
377                 node->setResult(NodeResultInt32);
378                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
379                     node->setArithRoundingMode(Arith::RoundingMode::Int32);
380                 else
381                     node->setArithRoundingMode(Arith::RoundingMode::Int32WithNegativeZeroCheck);
382             } else {
383                 node->setResult(NodeResultDouble);
384                 node->setArithRoundingMode(Arith::RoundingMode::Double);
385             }
386             break;
387         }
388             
389         case ArithSqrt: {
390             Edge& child1 = node->child1();
391             if (child1->shouldSpeculateNumberOrBoolean())
392                 fixDoubleOrBooleanEdge(child1);
393             else
394                 fixEdge<UntypedUse>(child1);
395             break;
396         }
397         case ArithFRound:
398         case ArithSin:
399         case ArithCos:
400         case ArithLog: {
401             fixDoubleOrBooleanEdge(node->child1());
402             node->setResult(NodeResultDouble);
403             break;
404         }
405             
406         case LogicalNot: {
407             if (node->child1()->shouldSpeculateBoolean()) {
408                 if (node->child1()->result() == NodeResultBoolean) {
409                     // This is necessary in case we have a bytecode instruction implemented by:
410                     //
411                     // a: CompareEq(...)
412                     // b: LogicalNot(@a)
413                     //
414                     // In that case, CompareEq might have a side-effect. Then, we need to make
415                     // sure that we know that Branch does not exit.
416                     fixEdge<KnownBooleanUse>(node->child1());
417                 } else
418                     fixEdge<BooleanUse>(node->child1());
419             } else if (node->child1()->shouldSpeculateObjectOrOther())
420                 fixEdge<ObjectOrOtherUse>(node->child1());
421             else if (node->child1()->shouldSpeculateInt32OrBoolean())
422                 fixIntOrBooleanEdge(node->child1());
423             else if (node->child1()->shouldSpeculateNumber())
424                 fixEdge<DoubleRepUse>(node->child1());
425             else if (node->child1()->shouldSpeculateString())
426                 fixEdge<StringUse>(node->child1());
427             else if (node->child1()->shouldSpeculateStringOrOther())
428                 fixEdge<StringOrOtherUse>(node->child1());
429             break;
430         }
431
432         case CompareEq:
433         case CompareLess:
434         case CompareLessEq:
435         case CompareGreater:
436         case CompareGreaterEq: {
437             if (node->op() == CompareEq
438                 && Node::shouldSpeculateBoolean(node->child1().node(), node->child2().node())) {
439                 fixEdge<BooleanUse>(node->child1());
440                 fixEdge<BooleanUse>(node->child2());
441                 node->clearFlags(NodeMustGenerate);
442                 break;
443             }
444             if (Node::shouldSpeculateInt32OrBoolean(node->child1().node(), node->child2().node())) {
445                 fixIntOrBooleanEdge(node->child1());
446                 fixIntOrBooleanEdge(node->child2());
447                 node->clearFlags(NodeMustGenerate);
448                 break;
449             }
450             if (enableInt52()
451                 && Node::shouldSpeculateAnyInt(node->child1().node(), node->child2().node())) {
452                 fixEdge<Int52RepUse>(node->child1());
453                 fixEdge<Int52RepUse>(node->child2());
454                 node->clearFlags(NodeMustGenerate);
455                 break;
456             }
457             if (Node::shouldSpeculateNumberOrBoolean(node->child1().node(), node->child2().node())) {
458                 fixDoubleOrBooleanEdge(node->child1());
459                 fixDoubleOrBooleanEdge(node->child2());
460             }
461             if (node->op() != CompareEq
462                 && node->child1()->shouldSpeculateNotCell()
463                 && node->child2()->shouldSpeculateNotCell()) {
464                 if (node->child1()->shouldSpeculateNumberOrBoolean())
465                     fixDoubleOrBooleanEdge(node->child1());
466                 else
467                     fixEdge<DoubleRepUse>(node->child1());
468                 if (node->child2()->shouldSpeculateNumberOrBoolean())
469                     fixDoubleOrBooleanEdge(node->child2());
470                 else
471                     fixEdge<DoubleRepUse>(node->child2());
472                 node->clearFlags(NodeMustGenerate);
473                 break;
474             }
475             if (node->child1()->shouldSpeculateStringIdent() && node->child2()->shouldSpeculateStringIdent()) {
476                 fixEdge<StringIdentUse>(node->child1());
477                 fixEdge<StringIdentUse>(node->child2());
478                 node->clearFlags(NodeMustGenerate);
479                 break;
480             }
481             if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && GPRInfo::numberOfRegisters >= 7) {
482                 fixEdge<StringUse>(node->child1());
483                 fixEdge<StringUse>(node->child2());
484                 node->clearFlags(NodeMustGenerate);
485                 break;
486             }
487
488             if (node->op() != CompareEq)
489                 break;
490             if (Node::shouldSpeculateSymbol(node->child1().node(), node->child2().node())) {
491                 fixEdge<SymbolUse>(node->child1());
492                 fixEdge<SymbolUse>(node->child2());
493                 node->clearFlags(NodeMustGenerate);
494                 break;
495             }
496             if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObject()) {
497                 fixEdge<ObjectUse>(node->child1());
498                 fixEdge<ObjectUse>(node->child2());
499                 node->clearFlags(NodeMustGenerate);
500                 break;
501             }
502
503             // If either child can be proved to be Null or Undefined, comparing them is greatly simplified.
504             bool oneArgumentIsUsedAsSpecOther = false;
505             if (node->child1()->isUndefinedOrNullConstant()) {
506                 fixEdge<OtherUse>(node->child1());
507                 oneArgumentIsUsedAsSpecOther = true;
508             } else if (node->child1()->shouldSpeculateOther()) {
509                 m_insertionSet.insertNode(m_indexInBlock, SpecNone, Check, node->origin,
510                     Edge(node->child1().node(), OtherUse));
511                 fixEdge<OtherUse>(node->child1());
512                 oneArgumentIsUsedAsSpecOther = true;
513             }
514             if (node->child2()->isUndefinedOrNullConstant()) {
515                 fixEdge<OtherUse>(node->child2());
516                 oneArgumentIsUsedAsSpecOther = true;
517             } else if (node->child2()->shouldSpeculateOther()) {
518                 m_insertionSet.insertNode(m_indexInBlock, SpecNone, Check, node->origin,
519                     Edge(node->child2().node(), OtherUse));
520                 fixEdge<OtherUse>(node->child2());
521                 oneArgumentIsUsedAsSpecOther = true;
522             }
523             if (oneArgumentIsUsedAsSpecOther) {
524                 node->clearFlags(NodeMustGenerate);
525                 break;
526             }
527
528             if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObjectOrOther()) {
529                 fixEdge<ObjectUse>(node->child1());
530                 fixEdge<ObjectOrOtherUse>(node->child2());
531                 node->clearFlags(NodeMustGenerate);
532                 break;
533             }
534             if (node->child1()->shouldSpeculateObjectOrOther() && node->child2()->shouldSpeculateObject()) {
535                 fixEdge<ObjectOrOtherUse>(node->child1());
536                 fixEdge<ObjectUse>(node->child2());
537                 node->clearFlags(NodeMustGenerate);
538                 break;
539             }
540
541             break;
542         }
543             
544         case CompareStrictEq: {
545             if (Node::shouldSpeculateBoolean(node->child1().node(), node->child2().node())) {
546                 fixEdge<BooleanUse>(node->child1());
547                 fixEdge<BooleanUse>(node->child2());
548                 break;
549             }
550             if (Node::shouldSpeculateInt32(node->child1().node(), node->child2().node())) {
551                 fixEdge<Int32Use>(node->child1());
552                 fixEdge<Int32Use>(node->child2());
553                 break;
554             }
555             if (enableInt52()
556                 && Node::shouldSpeculateAnyInt(node->child1().node(), node->child2().node())) {
557                 fixEdge<Int52RepUse>(node->child1());
558                 fixEdge<Int52RepUse>(node->child2());
559                 break;
560             }
561             if (Node::shouldSpeculateNumber(node->child1().node(), node->child2().node())) {
562                 fixEdge<DoubleRepUse>(node->child1());
563                 fixEdge<DoubleRepUse>(node->child2());
564                 break;
565             }
566             if (Node::shouldSpeculateSymbol(node->child1().node(), node->child2().node())) {
567                 fixEdge<SymbolUse>(node->child1());
568                 fixEdge<SymbolUse>(node->child2());
569                 break;
570             }
571             if (node->child1()->shouldSpeculateStringIdent() && node->child2()->shouldSpeculateStringIdent()) {
572                 fixEdge<StringIdentUse>(node->child1());
573                 fixEdge<StringIdentUse>(node->child2());
574                 break;
575             }
576             if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 7) || isFTL(m_graph.m_plan.mode))) {
577                 fixEdge<StringUse>(node->child1());
578                 fixEdge<StringUse>(node->child2());
579                 break;
580             }
581             WatchpointSet* masqueradesAsUndefinedWatchpoint = m_graph.globalObjectFor(node->origin.semantic)->masqueradesAsUndefinedWatchpoint();
582             if (masqueradesAsUndefinedWatchpoint->isStillValid()) {
583                 
584                 if (node->child1()->shouldSpeculateObject()) {
585                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
586                     fixEdge<ObjectUse>(node->child1());
587                     break;
588                 }
589                 if (node->child2()->shouldSpeculateObject()) {
590                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
591                     fixEdge<ObjectUse>(node->child2());
592                     break;
593                 }
594                 
595             } else if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObject()) {
596                 fixEdge<ObjectUse>(node->child1());
597                 fixEdge<ObjectUse>(node->child2());
598                 break;
599             }
600             if (node->child1()->shouldSpeculateSymbol()) {
601                 fixEdge<SymbolUse>(node->child1());
602                 break;
603             }
604             if (node->child2()->shouldSpeculateSymbol()) {
605                 fixEdge<SymbolUse>(node->child2());
606                 break;
607             }
608             if (node->child1()->shouldSpeculateMisc()) {
609                 fixEdge<MiscUse>(node->child1());
610                 break;
611             }
612             if (node->child2()->shouldSpeculateMisc()) {
613                 fixEdge<MiscUse>(node->child2());
614                 break;
615             }
616             if (node->child1()->shouldSpeculateStringIdent()
617                 && node->child2()->shouldSpeculateNotStringVar()) {
618                 fixEdge<StringIdentUse>(node->child1());
619                 fixEdge<NotStringVarUse>(node->child2());
620                 break;
621             }
622             if (node->child2()->shouldSpeculateStringIdent()
623                 && node->child1()->shouldSpeculateNotStringVar()) {
624                 fixEdge<StringIdentUse>(node->child2());
625                 fixEdge<NotStringVarUse>(node->child1());
626                 break;
627             }
628             if (node->child1()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
629                 fixEdge<StringUse>(node->child1());
630                 break;
631             }
632             if (node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
633                 fixEdge<StringUse>(node->child2());
634                 break;
635             }
636             break;
637         }
638             
639         case StringFromCharCode:
640             if (node->child1()->shouldSpeculateInt32())
641                 fixEdge<Int32Use>(node->child1());
642             else
643                 fixEdge<UntypedUse>(node->child1());
644             break;
645
646         case StringCharAt:
647         case StringCharCodeAt: {
648             // Currently we have no good way of refining these.
649             ASSERT(node->arrayMode() == ArrayMode(Array::String));
650             blessArrayOperation(node->child1(), node->child2(), node->child3());
651             fixEdge<KnownCellUse>(node->child1());
652             fixEdge<Int32Use>(node->child2());
653             break;
654         }
655
656         case GetByVal: {
657             if (!node->prediction()) {
658                 m_insertionSet.insertNode(
659                     m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
660             }
661             
662             node->setArrayMode(
663                 node->arrayMode().refine(
664                     m_graph, node,
665                     node->child1()->prediction(),
666                     node->child2()->prediction(),
667                     SpecNone));
668             
669             blessArrayOperation(node->child1(), node->child2(), node->child3());
670             
671             ArrayMode arrayMode = node->arrayMode();
672             switch (arrayMode.type()) {
673             case Array::Contiguous:
674             case Array::Double:
675                 if (arrayMode.arrayClass() == Array::OriginalArray
676                     && arrayMode.speculation() == Array::InBounds) {
677                     JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
678                     if (globalObject->arrayPrototypeChainIsSane()) {
679                         // Check if SaneChain will work on a per-type basis. Note that:
680                         //
681                         // 1) We don't want double arrays to sometimes return undefined, since
682                         // that would require a change to the return type and it would pessimise
683                         // things a lot. So, we'd only want to do that if we actually had
684                         // evidence that we could read from a hole. That's pretty annoying.
685                         // Likely the best way to handle that case is with an equivalent of
686                         // SaneChain for OutOfBounds. For now we just detect when Undefined and
687                         // NaN are indistinguishable according to backwards propagation, and just
688                         // use SaneChain in that case. This happens to catch a lot of cases.
689                         //
690                         // 2) We don't want int32 array loads to have to do a hole check just to
691                         // coerce to Undefined, since that would mean twice the checks.
692                         //
693                         // This has two implications. First, we have to do more checks than we'd
694                         // like. It's unfortunate that we have to do the hole check. Second,
695                         // some accesses that hit a hole will now need to take the full-blown
696                         // out-of-bounds slow path. We can fix that with:
697                         // https://bugs.webkit.org/show_bug.cgi?id=144668
698                         
699                         bool canDoSaneChain = false;
700                         switch (arrayMode.type()) {
701                         case Array::Contiguous:
702                             // This is happens to be entirely natural. We already would have
703                             // returned any JSValue, and now we'll return Undefined. We still do
704                             // the check but it doesn't require taking any kind of slow path.
705                             canDoSaneChain = true;
706                             break;
707                             
708                         case Array::Double:
709                             if (!(node->flags() & NodeBytecodeUsesAsOther)) {
710                                 // Holes look like NaN already, so if the user doesn't care
711                                 // about the difference between Undefined and NaN then we can
712                                 // do this.
713                                 canDoSaneChain = true;
714                             }
715                             break;
716                             
717                         default:
718                             break;
719                         }
720                         
721                         if (canDoSaneChain) {
722                             m_graph.watchpoints().addLazily(
723                                 globalObject->arrayPrototype()->structure()->transitionWatchpointSet());
724                             m_graph.watchpoints().addLazily(
725                                 globalObject->objectPrototype()->structure()->transitionWatchpointSet());
726                             if (globalObject->arrayPrototypeChainIsSane())
727                                 node->setArrayMode(arrayMode.withSpeculation(Array::SaneChain));
728                         }
729                     }
730                 }
731                 break;
732                 
733             case Array::String:
734                 if ((node->prediction() & ~SpecString)
735                     || m_graph.hasExitSite(node->origin.semantic, OutOfBounds))
736                     node->setArrayMode(arrayMode.withSpeculation(Array::OutOfBounds));
737                 break;
738                 
739             default:
740                 break;
741             }
742             
743             arrayMode = node->arrayMode();
744             switch (arrayMode.type()) {
745             case Array::SelectUsingPredictions:
746             case Array::Unprofiled:
747                 RELEASE_ASSERT_NOT_REACHED();
748                 break;
749             case Array::Generic:
750 #if USE(JSVALUE32_64)
751                 fixEdge<CellUse>(node->child1()); // Speculating cell due to register pressure on 32-bit.
752 #endif
753                 break;
754             case Array::ForceExit:
755                 break;
756             default:
757                 fixEdge<KnownCellUse>(node->child1());
758                 fixEdge<Int32Use>(node->child2());
759                 break;
760             }
761             
762             switch (arrayMode.type()) {
763             case Array::Double:
764                 if (!arrayMode.isOutOfBounds())
765                     node->setResult(NodeResultDouble);
766                 break;
767                 
768             case Array::Float32Array:
769             case Array::Float64Array:
770                 node->setResult(NodeResultDouble);
771                 break;
772                 
773             case Array::Uint32Array:
774                 if (node->shouldSpeculateInt32())
775                     break;
776                 if (node->shouldSpeculateAnyInt() && enableInt52())
777                     node->setResult(NodeResultInt52);
778                 else
779                     node->setResult(NodeResultDouble);
780                 break;
781                 
782             default:
783                 break;
784             }
785             
786             break;
787         }
788
789         case PutByValDirect:
790         case PutByVal:
791         case PutByValAlias: {
792             Edge& child1 = m_graph.varArgChild(node, 0);
793             Edge& child2 = m_graph.varArgChild(node, 1);
794             Edge& child3 = m_graph.varArgChild(node, 2);
795
796             node->setArrayMode(
797                 node->arrayMode().refine(
798                     m_graph, node,
799                     child1->prediction(),
800                     child2->prediction(),
801                     child3->prediction()));
802             
803             blessArrayOperation(child1, child2, m_graph.varArgChild(node, 3));
804             
805             switch (node->arrayMode().modeForPut().type()) {
806             case Array::SelectUsingPredictions:
807             case Array::SelectUsingArguments:
808             case Array::Unprofiled:
809             case Array::Undecided:
810                 RELEASE_ASSERT_NOT_REACHED();
811                 break;
812             case Array::ForceExit:
813             case Array::Generic:
814 #if USE(JSVALUE32_64)
815                 // Due to register pressure on 32-bit, we speculate cell and
816                 // ignore the base-is-not-cell case entirely by letting the
817                 // baseline JIT handle it.
818                 fixEdge<CellUse>(child1);
819 #endif
820                 break;
821             case Array::Int32:
822                 fixEdge<KnownCellUse>(child1);
823                 fixEdge<Int32Use>(child2);
824                 fixEdge<Int32Use>(child3);
825                 break;
826             case Array::Double:
827                 fixEdge<KnownCellUse>(child1);
828                 fixEdge<Int32Use>(child2);
829                 fixEdge<DoubleRepRealUse>(child3);
830                 break;
831             case Array::Int8Array:
832             case Array::Int16Array:
833             case Array::Int32Array:
834             case Array::Uint8Array:
835             case Array::Uint8ClampedArray:
836             case Array::Uint16Array:
837             case Array::Uint32Array:
838                 fixEdge<KnownCellUse>(child1);
839                 fixEdge<Int32Use>(child2);
840                 if (child3->shouldSpeculateInt32())
841                     fixIntOrBooleanEdge(child3);
842                 else if (child3->shouldSpeculateAnyInt())
843                     fixEdge<Int52RepUse>(child3);
844                 else
845                     fixDoubleOrBooleanEdge(child3);
846                 break;
847             case Array::Float32Array:
848             case Array::Float64Array:
849                 fixEdge<KnownCellUse>(child1);
850                 fixEdge<Int32Use>(child2);
851                 fixDoubleOrBooleanEdge(child3);
852                 break;
853             case Array::Contiguous:
854             case Array::ArrayStorage:
855             case Array::SlowPutArrayStorage:
856                 fixEdge<KnownCellUse>(child1);
857                 fixEdge<Int32Use>(child2);
858                 speculateForBarrier(child3);
859                 break;
860             default:
861                 fixEdge<KnownCellUse>(child1);
862                 fixEdge<Int32Use>(child2);
863                 break;
864             }
865             break;
866         }
867             
868         case ArrayPush: {
869             // May need to refine the array mode in case the value prediction contravenes
870             // the array prediction. For example, we may have evidence showing that the
871             // array is in Int32 mode, but the value we're storing is likely to be a double.
872             // Then we should turn this into a conversion to Double array followed by the
873             // push. On the other hand, we absolutely don't want to refine based on the
874             // base prediction. If it has non-cell garbage in it, then we want that to be
875             // ignored. That's because ArrayPush can't handle any array modes that aren't
876             // array-related - so if refine() turned this into a "Generic" ArrayPush then
877             // that would break things.
878             node->setArrayMode(
879                 node->arrayMode().refine(
880                     m_graph, node,
881                     node->child1()->prediction() & SpecCell,
882                     SpecInt32Only,
883                     node->child2()->prediction()));
884             blessArrayOperation(node->child1(), Edge(), node->child3());
885             fixEdge<KnownCellUse>(node->child1());
886             
887             switch (node->arrayMode().type()) {
888             case Array::Int32:
889                 fixEdge<Int32Use>(node->child2());
890                 break;
891             case Array::Double:
892                 fixEdge<DoubleRepRealUse>(node->child2());
893                 break;
894             case Array::Contiguous:
895             case Array::ArrayStorage:
896                 speculateForBarrier(node->child2());
897                 break;
898             default:
899                 break;
900             }
901             break;
902         }
903             
904         case ArrayPop: {
905             blessArrayOperation(node->child1(), Edge(), node->child2());
906             fixEdge<KnownCellUse>(node->child1());
907             break;
908         }
909             
910         case RegExpExec:
911         case RegExpTest: {
912             fixEdge<KnownCellUse>(node->child1());
913             
914             if (node->child2()->shouldSpeculateRegExpObject()) {
915                 fixEdge<RegExpObjectUse>(node->child2());
916
917                 if (node->child3()->shouldSpeculateString())
918                     fixEdge<StringUse>(node->child3());
919             }
920             break;
921         }
922
923         case StringReplace:
924         case StringReplaceRegExp: {
925             if (node->child2()->shouldSpeculateString()) {
926                 m_insertionSet.insertNode(
927                     m_indexInBlock, SpecNone, Check, node->origin,
928                     Edge(node->child2().node(), StringUse));
929                 fixEdge<StringUse>(node->child2());
930             } else if (op == StringReplace) {
931                 if (node->child2()->shouldSpeculateRegExpObject())
932                     addStringReplacePrimordialChecks(node->child2().node());
933                 else 
934                     m_insertionSet.insertNode(
935                         m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
936             }
937
938             if (node->child1()->shouldSpeculateString()
939                 && node->child2()->shouldSpeculateRegExpObject()
940                 && node->child3()->shouldSpeculateString()) {
941
942                 fixEdge<StringUse>(node->child1());
943                 fixEdge<RegExpObjectUse>(node->child2());
944                 fixEdge<StringUse>(node->child3());
945                 break;
946             }
947             break;
948         }
949             
950         case Branch: {
951             if (node->child1()->shouldSpeculateBoolean()) {
952                 if (node->child1()->result() == NodeResultBoolean) {
953                     // This is necessary in case we have a bytecode instruction implemented by:
954                     //
955                     // a: CompareEq(...)
956                     // b: Branch(@a)
957                     //
958                     // In that case, CompareEq might have a side-effect. Then, we need to make
959                     // sure that we know that Branch does not exit.
960                     fixEdge<KnownBooleanUse>(node->child1());
961                 } else
962                     fixEdge<BooleanUse>(node->child1());
963             } else if (node->child1()->shouldSpeculateObjectOrOther())
964                 fixEdge<ObjectOrOtherUse>(node->child1());
965             else if (node->child1()->shouldSpeculateInt32OrBoolean())
966                 fixIntOrBooleanEdge(node->child1());
967             else if (node->child1()->shouldSpeculateNumber())
968                 fixEdge<DoubleRepUse>(node->child1());
969             else if (node->child1()->shouldSpeculateString())
970                 fixEdge<StringUse>(node->child1());
971             else if (node->child1()->shouldSpeculateStringOrOther())
972                 fixEdge<StringOrOtherUse>(node->child1());
973             break;
974         }
975             
976         case Switch: {
977             SwitchData* data = node->switchData();
978             switch (data->kind) {
979             case SwitchImm:
980                 if (node->child1()->shouldSpeculateInt32())
981                     fixEdge<Int32Use>(node->child1());
982                 break;
983             case SwitchChar:
984                 if (node->child1()->shouldSpeculateString())
985                     fixEdge<StringUse>(node->child1());
986                 break;
987             case SwitchString:
988                 if (node->child1()->shouldSpeculateStringIdent())
989                     fixEdge<StringIdentUse>(node->child1());
990                 else if (node->child1()->shouldSpeculateString())
991                     fixEdge<StringUse>(node->child1());
992                 break;
993             case SwitchCell:
994                 if (node->child1()->shouldSpeculateCell())
995                     fixEdge<CellUse>(node->child1());
996                 // else it's fine for this to have UntypedUse; we will handle this by just making
997                 // non-cells take the default case.
998                 break;
999             }
1000             break;
1001         }
1002             
1003         case ToPrimitive: {
1004             fixupToPrimitive(node);
1005             break;
1006         }
1007
1008         case ToNumber: {
1009             fixupToNumber(node);
1010             break;
1011         }
1012             
1013         case ToString:
1014         case CallStringConstructor: {
1015             fixupToStringOrCallStringConstructor(node);
1016             break;
1017         }
1018             
1019         case NewStringObject: {
1020             fixEdge<KnownStringUse>(node->child1());
1021             break;
1022         }
1023             
1024         case NewArray: {
1025             watchHavingABadTime(node);
1026             
1027             for (unsigned i = m_graph.varArgNumChildren(node); i--;) {
1028                 node->setIndexingType(
1029                     leastUpperBoundOfIndexingTypeAndType(
1030                         node->indexingType(), m_graph.varArgChild(node, i)->prediction()));
1031             }
1032             switch (node->indexingType()) {
1033             case ALL_BLANK_INDEXING_TYPES:
1034                 CRASH();
1035                 break;
1036             case ALL_UNDECIDED_INDEXING_TYPES:
1037                 if (node->numChildren()) {
1038                     // This will only happen if the children have no type predictions. We
1039                     // would have already exited by now, but insert a forced exit just to
1040                     // be safe.
1041                     m_insertionSet.insertNode(
1042                         m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
1043                 }
1044                 break;
1045             case ALL_INT32_INDEXING_TYPES:
1046                 for (unsigned operandIndex = 0; operandIndex < node->numChildren(); ++operandIndex)
1047                     fixEdge<Int32Use>(m_graph.m_varArgChildren[node->firstChild() + operandIndex]);
1048                 break;
1049             case ALL_DOUBLE_INDEXING_TYPES:
1050                 for (unsigned operandIndex = 0; operandIndex < node->numChildren(); ++operandIndex)
1051                     fixEdge<DoubleRepRealUse>(m_graph.m_varArgChildren[node->firstChild() + operandIndex]);
1052                 break;
1053             case ALL_CONTIGUOUS_INDEXING_TYPES:
1054             case ALL_ARRAY_STORAGE_INDEXING_TYPES:
1055                 break;
1056             default:
1057                 CRASH();
1058                 break;
1059             }
1060             break;
1061         }
1062             
1063         case NewTypedArray: {
1064             watchHavingABadTime(node);
1065             
1066             if (node->child1()->shouldSpeculateInt32()) {
1067                 fixEdge<Int32Use>(node->child1());
1068                 node->clearFlags(NodeMustGenerate);
1069                 break;
1070             }
1071             break;
1072         }
1073             
1074         case NewArrayWithSize: {
1075             watchHavingABadTime(node);
1076             fixEdge<Int32Use>(node->child1());
1077             break;
1078         }
1079
1080         case CallObjectConstructor: {
1081             if (node->child1()->shouldSpeculateObject()) {
1082                 fixEdge<ObjectUse>(node->child1());
1083                 node->convertToIdentity();
1084                 break;
1085             }
1086
1087             fixEdge<UntypedUse>(node->child1());
1088             break;
1089         }
1090
1091         case ToThis: {
1092             fixupToThis(node);
1093             break;
1094         }
1095             
1096         case PutStructure: {
1097             fixEdge<KnownCellUse>(node->child1());
1098             break;
1099         }
1100             
1101         case GetClosureVar:
1102         case GetFromArguments: {
1103             fixEdge<KnownCellUse>(node->child1());
1104             break;
1105         }
1106
1107         case PutClosureVar:
1108         case PutToArguments: {
1109             fixEdge<KnownCellUse>(node->child1());
1110             speculateForBarrier(node->child2());
1111             break;
1112         }
1113
1114         case SkipScope:
1115         case GetScope:
1116         case GetGetter:
1117         case GetSetter:
1118         case GetGlobalObject: {
1119             fixEdge<KnownCellUse>(node->child1());
1120             break;
1121         }
1122             
1123         case AllocatePropertyStorage:
1124         case ReallocatePropertyStorage: {
1125             fixEdge<KnownCellUse>(node->child1());
1126             break;
1127         }
1128
1129         case TryGetById: {
1130             if (node->child1()->shouldSpeculateCell())
1131                 fixEdge<CellUse>(node->child1());
1132             break;
1133         }
1134
1135         case GetById:
1136         case GetByIdFlush: {
1137             // FIXME: This should be done in the ByteCodeParser based on reading the
1138             // PolymorphicAccess, which will surely tell us that this is a AccessCase::ArrayLength.
1139             // https://bugs.webkit.org/show_bug.cgi?id=154990
1140             if (node->child1()->shouldSpeculateCellOrOther()
1141                 && !m_graph.hasExitSite(node->origin.semantic, BadType)
1142                 && !m_graph.hasExitSite(node->origin.semantic, BadCache)
1143                 && !m_graph.hasExitSite(node->origin.semantic, BadIndexingType)
1144                 && !m_graph.hasExitSite(node->origin.semantic, ExoticObjectMode)) {
1145                 
1146                 auto uid = m_graph.identifiers()[node->identifierNumber()];
1147                 
1148                 if (uid == vm().propertyNames->length.impl()) {
1149                     attemptToMakeGetArrayLength(node);
1150                     break;
1151                 }
1152
1153                 if (uid == vm().propertyNames->lastIndex.impl()
1154                     && node->child1()->shouldSpeculateRegExpObject()) {
1155                     node->setOp(GetRegExpObjectLastIndex);
1156                     node->clearFlags(NodeMustGenerate);
1157                     fixEdge<RegExpObjectUse>(node->child1());
1158                     break;
1159                 }
1160             }
1161
1162             if (node->child1()->shouldSpeculateCell())
1163                 fixEdge<CellUse>(node->child1());
1164             break;
1165         }
1166
1167         case PutById:
1168         case PutByIdFlush:
1169         case PutByIdDirect: {
1170             if (node->child1()->shouldSpeculateCellOrOther()
1171                 && !m_graph.hasExitSite(node->origin.semantic, BadType)
1172                 && !m_graph.hasExitSite(node->origin.semantic, BadCache)
1173                 && !m_graph.hasExitSite(node->origin.semantic, BadIndexingType)
1174                 && !m_graph.hasExitSite(node->origin.semantic, ExoticObjectMode)) {
1175                 
1176                 auto uid = m_graph.identifiers()[node->identifierNumber()];
1177                 
1178                 if (uid == vm().propertyNames->lastIndex.impl()
1179                     && node->child1()->shouldSpeculateRegExpObject()) {
1180                     node->setOp(SetRegExpObjectLastIndex);
1181                     fixEdge<RegExpObjectUse>(node->child1());
1182                     speculateForBarrier(node->child2());
1183                     break;
1184                 }
1185             }
1186             
1187             fixEdge<CellUse>(node->child1());
1188             break;
1189         }
1190
1191         case PutGetterById:
1192         case PutSetterById: {
1193             fixEdge<KnownCellUse>(node->child1());
1194             fixEdge<KnownCellUse>(node->child2());
1195             break;
1196         }
1197
1198         case PutGetterSetterById: {
1199             fixEdge<KnownCellUse>(node->child1());
1200             break;
1201         }
1202
1203         case PutGetterByVal:
1204         case PutSetterByVal: {
1205             fixEdge<KnownCellUse>(node->child1());
1206             fixEdge<KnownCellUse>(node->child3());
1207             break;
1208         }
1209
1210         case GetExecutable: {
1211             fixEdge<FunctionUse>(node->child1());
1212             break;
1213         }
1214
1215         case OverridesHasInstance:
1216         case CheckStructure:
1217         case CheckCell:
1218         case CreateThis:
1219         case GetButterfly: {
1220             fixEdge<CellUse>(node->child1());
1221             break;
1222         }
1223
1224         case CheckStringIdent: {
1225             fixEdge<StringIdentUse>(node->child1());
1226             break;
1227         }
1228             
1229         case Arrayify:
1230         case ArrayifyToStructure: {
1231             fixEdge<CellUse>(node->child1());
1232             if (node->child2())
1233                 fixEdge<Int32Use>(node->child2());
1234             break;
1235         }
1236             
1237         case GetByOffset:
1238         case GetGetterSetterByOffset: {
1239             if (!node->child1()->hasStorageResult())
1240                 fixEdge<KnownCellUse>(node->child1());
1241             fixEdge<KnownCellUse>(node->child2());
1242             break;
1243         }
1244             
1245         case MultiGetByOffset: {
1246             fixEdge<CellUse>(node->child1());
1247             break;
1248         }
1249             
1250         case PutByOffset: {
1251             if (!node->child1()->hasStorageResult())
1252                 fixEdge<KnownCellUse>(node->child1());
1253             fixEdge<KnownCellUse>(node->child2());
1254             insertInferredTypeCheck(
1255                 m_insertionSet, m_indexInBlock, node->origin, node->child3().node(),
1256                 node->storageAccessData().inferredType);
1257             speculateForBarrier(node->child3());
1258             break;
1259         }
1260             
1261         case MultiPutByOffset: {
1262             fixEdge<CellUse>(node->child1());
1263             speculateForBarrier(node->child2());
1264             break;
1265         }
1266             
1267         case InstanceOf: {
1268             if (!(node->child1()->prediction() & ~SpecCell))
1269                 fixEdge<CellUse>(node->child1());
1270             fixEdge<CellUse>(node->child2());
1271             break;
1272         }
1273
1274         case InstanceOfCustom:
1275             fixEdge<CellUse>(node->child2());
1276             break;
1277
1278         case In: {
1279             // FIXME: We should at some point have array profiling on op_in, in which
1280             // case we would be able to turn this into a kind of GetByVal.
1281             
1282             fixEdge<CellUse>(node->child2());
1283             break;
1284         }
1285
1286         case Check: {
1287             m_graph.doToChildren(
1288                 node,
1289                 [&] (Edge& edge) {
1290                     switch (edge.useKind()) {
1291                     case NumberUse:
1292                         if (edge->shouldSpeculateInt32ForArithmetic())
1293                             edge.setUseKind(Int32Use);
1294                         break;
1295                     default:
1296                         break;
1297                     }
1298                     observeUseKindOnEdge(edge);
1299                 });
1300             break;
1301         }
1302
1303         case Phantom:
1304             // Phantoms are meaningless past Fixup. We recreate them on-demand in the backend.
1305             node->remove();
1306             break;
1307
1308         case FiatInt52: {
1309             RELEASE_ASSERT(enableInt52());
1310             node->convertToIdentity();
1311             fixEdge<Int52RepUse>(node->child1());
1312             node->setResult(NodeResultInt52);
1313             break;
1314         }
1315
1316         case GetArrayLength: {
1317             fixEdge<KnownCellUse>(node->child1());
1318             break;
1319         }
1320
1321         case GetTypedArrayByteOffset: {
1322             fixEdge<KnownCellUse>(node->child1());
1323             break;
1324         }
1325
1326         case Phi:
1327         case Upsilon:
1328         case GetIndexedPropertyStorage:
1329         case LastNodeType:
1330         case CheckTierUpInLoop:
1331         case CheckTierUpAtReturn:
1332         case CheckTierUpAndOSREnter:
1333         case InvalidationPoint:
1334         case CheckArray:
1335         case CheckInBounds:
1336         case ConstantStoragePointer:
1337         case DoubleAsInt32:
1338         case ValueToInt32:
1339         case DoubleRep:
1340         case ValueRep:
1341         case Int52Rep:
1342         case Int52Constant:
1343         case Identity: // This should have been cleaned up.
1344         case BooleanToNumber:
1345         case PhantomNewObject:
1346         case PhantomNewFunction:
1347         case PhantomNewGeneratorFunction:
1348         case PhantomCreateActivation:
1349         case PhantomDirectArguments:
1350         case PhantomClonedArguments:
1351         case GetMyArgumentByVal:
1352         case GetMyArgumentByValOutOfBounds:
1353         case PutHint:
1354         case CheckStructureImmediate:
1355         case MaterializeNewObject:
1356         case MaterializeCreateActivation:
1357         case PutStack:
1358         case KillStack:
1359         case GetStack:
1360         case StoreBarrier:
1361         case GetRegExpObjectLastIndex:
1362         case SetRegExpObjectLastIndex:
1363         case RecordRegExpCachedResult:
1364             // These are just nodes that we don't currently expect to see during fixup.
1365             // If we ever wanted to insert them prior to fixup, then we just have to create
1366             // fixup rules for them.
1367             DFG_CRASH(m_graph, node, "Unexpected node during fixup");
1368             break;
1369         
1370         case PutGlobalVariable: {
1371             fixEdge<CellUse>(node->child1());
1372             speculateForBarrier(node->child2());
1373             break;
1374         }
1375
1376         case IsString:
1377             if (node->child1()->shouldSpeculateString()) {
1378                 m_insertionSet.insertNode(
1379                     m_indexInBlock, SpecNone, Check, node->origin,
1380                     Edge(node->child1().node(), StringUse));
1381                 m_graph.convertToConstant(node, jsBoolean(true));
1382                 observeUseKindOnNode<StringUse>(node);
1383             }
1384             break;
1385
1386         case IsObject:
1387             if (node->child1()->shouldSpeculateObject()) {
1388                 m_insertionSet.insertNode(
1389                     m_indexInBlock, SpecNone, Check, node->origin,
1390                     Edge(node->child1().node(), ObjectUse));
1391                 m_graph.convertToConstant(node, jsBoolean(true));
1392                 observeUseKindOnNode<ObjectUse>(node);
1393             }
1394             break;
1395
1396         case GetEnumerableLength: {
1397             fixEdge<CellUse>(node->child1());
1398             break;
1399         }
1400         case HasGenericProperty: {
1401             fixEdge<CellUse>(node->child2());
1402             break;
1403         }
1404         case HasStructureProperty: {
1405             fixEdge<StringUse>(node->child2());
1406             fixEdge<KnownCellUse>(node->child3());
1407             break;
1408         }
1409         case HasIndexedProperty: {
1410             node->setArrayMode(
1411                 node->arrayMode().refine(
1412                     m_graph, node,
1413                     node->child1()->prediction(),
1414                     node->child2()->prediction(),
1415                     SpecNone));
1416             
1417             blessArrayOperation(node->child1(), node->child2(), node->child3());
1418             fixEdge<CellUse>(node->child1());
1419             fixEdge<KnownInt32Use>(node->child2());
1420             break;
1421         }
1422         case GetDirectPname: {
1423             Edge& base = m_graph.varArgChild(node, 0);
1424             Edge& property = m_graph.varArgChild(node, 1);
1425             Edge& index = m_graph.varArgChild(node, 2);
1426             Edge& enumerator = m_graph.varArgChild(node, 3);
1427             fixEdge<CellUse>(base);
1428             fixEdge<KnownCellUse>(property);
1429             fixEdge<KnownInt32Use>(index);
1430             fixEdge<KnownCellUse>(enumerator);
1431             break;
1432         }
1433         case GetPropertyEnumerator: {
1434             fixEdge<CellUse>(node->child1());
1435             break;
1436         }
1437         case GetEnumeratorStructurePname: {
1438             fixEdge<KnownCellUse>(node->child1());
1439             fixEdge<KnownInt32Use>(node->child2());
1440             break;
1441         }
1442         case GetEnumeratorGenericPname: {
1443             fixEdge<KnownCellUse>(node->child1());
1444             fixEdge<KnownInt32Use>(node->child2());
1445             break;
1446         }
1447         case ToIndexString: {
1448             fixEdge<KnownInt32Use>(node->child1());
1449             break;
1450         }
1451         case ProfileType: {
1452             // We want to insert type checks based on the instructionTypeSet of the TypeLocation, not the globalTypeSet.
1453             // Because the instructionTypeSet is contained in globalTypeSet, if we produce a type check for
1454             // type T for the instructionTypeSet, the global type set must also have information for type T.
1455             // So if it the type check succeeds for type T in the instructionTypeSet, a type check for type T 
1456             // in the globalTypeSet would've also succeeded.
1457             // (The other direction does not hold in general).
1458
1459             RefPtr<TypeSet> typeSet = node->typeLocation()->m_instructionTypeSet;
1460             RuntimeTypeMask seenTypes = typeSet->seenTypes();
1461             if (typeSet->doesTypeConformTo(TypeAnyInt)) {
1462                 if (node->child1()->shouldSpeculateInt32()) {
1463                     fixEdge<Int32Use>(node->child1());
1464                     node->remove();
1465                     break;
1466                 }
1467
1468                 if (enableInt52()) {
1469                     fixEdge<AnyIntUse>(node->child1());
1470                     node->remove();
1471                     break;
1472                 }
1473
1474                 // Must not perform fixEdge<NumberUse> here since the type set only includes TypeAnyInt. Double values should be logged.
1475             }
1476
1477             if (typeSet->doesTypeConformTo(TypeNumber | TypeAnyInt)) {
1478                 fixEdge<NumberUse>(node->child1());
1479                 node->remove();
1480             } else if (typeSet->doesTypeConformTo(TypeString)) {
1481                 fixEdge<StringUse>(node->child1());
1482                 node->remove();
1483             } else if (typeSet->doesTypeConformTo(TypeBoolean)) {
1484                 fixEdge<BooleanUse>(node->child1());
1485                 node->remove();
1486             } else if (typeSet->doesTypeConformTo(TypeUndefined | TypeNull) && (seenTypes & TypeUndefined) && (seenTypes & TypeNull)) {
1487                 fixEdge<OtherUse>(node->child1());
1488                 node->remove();
1489             } else if (typeSet->doesTypeConformTo(TypeObject)) {
1490                 StructureSet set;
1491                 {
1492                     ConcurrentJITLocker locker(typeSet->m_lock);
1493                     set = typeSet->structureSet(locker);
1494                 }
1495                 if (!set.isEmpty()) {
1496                     fixEdge<CellUse>(node->child1());
1497                     node->convertToCheckStructure(m_graph.addStructureSet(set));
1498                 }
1499             }
1500
1501             break;
1502         }
1503
1504         case CreateScopedArguments:
1505         case CreateActivation:
1506         case NewFunction:
1507         case NewGeneratorFunction: {
1508             fixEdge<CellUse>(node->child1());
1509             break;
1510         }
1511
1512         case SetFunctionName: {
1513             // The first child is guaranteed to be a cell because op_set_function_name is only used
1514             // on a newly instantiated function object (the first child).
1515             fixEdge<KnownCellUse>(node->child1());
1516             fixEdge<UntypedUse>(node->child2());
1517             break;
1518         }
1519
1520         case CreateRest: {
1521             watchHavingABadTime(node);
1522             fixEdge<KnownInt32Use>(node->child1());
1523             break;
1524         }
1525
1526         case ResolveScope:
1527         case GetDynamicVar:
1528         case PutDynamicVar: {
1529             fixEdge<KnownCellUse>(node->child1());
1530             break;
1531         }
1532
1533         case LogShadowChickenPrologue: {
1534             fixEdge<KnownCellUse>(node->child1());
1535             break;
1536         }
1537         case LogShadowChickenTail: {
1538             fixEdge<UntypedUse>(node->child1());
1539             fixEdge<KnownCellUse>(node->child2());
1540             break;
1541         }
1542
1543 #if !ASSERT_DISABLED
1544         // Have these no-op cases here to ensure that nobody forgets to add handlers for new opcodes.
1545         case SetArgument:
1546         case JSConstant:
1547         case LazyJSConstant:
1548         case DoubleConstant:
1549         case GetLocal:
1550         case GetCallee:
1551         case GetArgumentCountIncludingThis:
1552         case GetRestLength:
1553         case Flush:
1554         case PhantomLocal:
1555         case GetLocalUnlinked:
1556         case GetGlobalVar:
1557         case GetGlobalLexicalVariable:
1558         case NotifyWrite:
1559         case Call:
1560         case CheckTypeInfoFlags:
1561         case TailCallInlinedCaller:
1562         case Construct:
1563         case CallVarargs:
1564         case CallEval:
1565         case TailCallVarargsInlinedCaller:
1566         case ConstructVarargs:
1567         case CallForwardVarargs:
1568         case ConstructForwardVarargs:
1569         case TailCallForwardVarargs:
1570         case TailCallForwardVarargsInlinedCaller:
1571         case LoadVarargs:
1572         case ForwardVarargs:
1573         case ProfileControlFlow:
1574         case NewObject:
1575         case NewArrayBuffer:
1576         case NewRegexp:
1577         case DeleteById:
1578         case DeleteByVal:
1579         case IsJSArray:
1580         case IsTypedArrayView:
1581         case IsEmpty:
1582         case IsUndefined:
1583         case IsBoolean:
1584         case IsNumber:
1585         case IsObjectOrNull:
1586         case IsFunction:
1587         case IsRegExpObject:
1588         case CreateDirectArguments:
1589         case CreateClonedArguments:
1590         case Jump:
1591         case Return:
1592         case TailCall:
1593         case TailCallVarargs:
1594         case Throw:
1595         case ThrowReferenceError:
1596         case CountExecution:
1597         case ForceOSRExit:
1598         case CheckBadCell:
1599         case CheckNotEmpty:
1600         case CheckWatchdogTimer:
1601         case Unreachable:
1602         case ExtractOSREntryLocal:
1603         case LoopHint:
1604         case MovHint:
1605         case ZombieHint:
1606         case ExitOK:
1607         case BottomValue:
1608         case TypeOf:
1609         case GetByIdWithThis:
1610         case PutByIdWithThis:
1611         case PutByValWithThis:
1612         case GetByValWithThis:
1613         case CompareEqPtr:
1614             break;
1615             
1616             break;
1617 #else
1618         default:
1619             break;
1620 #endif
1621         }
1622     }
1623
1624     void watchHavingABadTime(Node* node)
1625     {
1626         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
1627
1628         // If this global object is not having a bad time, watch it. We go down this path anytime the code
1629         // does an array allocation. The types of array allocations may change if we start to have a bad
1630         // time. It's easier to reason about this if we know that whenever the types change after we start
1631         // optimizing, the code just gets thrown out. Doing this at FixupPhase is just early enough, since
1632         // prior to this point nobody should have been doing optimizations based on the indexing type of
1633         // the allocation.
1634         if (!globalObject->isHavingABadTime())
1635             m_graph.watchpoints().addLazily(globalObject->havingABadTimeWatchpoint());
1636     }
1637     
1638     template<UseKind useKind>
1639     void createToString(Node* node, Edge& edge)
1640     {
1641         edge.setNode(m_insertionSet.insertNode(
1642             m_indexInBlock, SpecString, ToString, node->origin,
1643             Edge(edge.node(), useKind)));
1644     }
1645     
1646     template<UseKind useKind>
1647     void attemptToForceStringArrayModeByToStringConversion(ArrayMode& arrayMode, Node* node)
1648     {
1649         ASSERT(arrayMode == ArrayMode(Array::Generic));
1650         
1651         if (!m_graph.canOptimizeStringObjectAccess(node->origin.semantic))
1652             return;
1653         
1654         createToString<useKind>(node, node->child1());
1655         arrayMode = ArrayMode(Array::String);
1656     }
1657     
1658     template<UseKind useKind>
1659     bool isStringObjectUse()
1660     {
1661         switch (useKind) {
1662         case StringObjectUse:
1663         case StringOrStringObjectUse:
1664             return true;
1665         default:
1666             return false;
1667         }
1668     }
1669     
1670     template<UseKind useKind>
1671     void convertStringAddUse(Node* node, Edge& edge)
1672     {
1673         if (useKind == StringUse) {
1674             observeUseKindOnNode<StringUse>(edge.node());
1675             m_insertionSet.insertNode(
1676                 m_indexInBlock, SpecNone, Check, node->origin,
1677                 Edge(edge.node(), StringUse));
1678             edge.setUseKind(KnownStringUse);
1679             return;
1680         }
1681         
1682         observeUseKindOnNode<useKind>(edge.node());
1683         createToString<useKind>(node, edge);
1684     }
1685     
1686     void convertToMakeRope(Node* node)
1687     {
1688         node->setOpAndDefaultFlags(MakeRope);
1689         fixupMakeRope(node);
1690     }
1691     
1692     void fixupMakeRope(Node* node)
1693     {
1694         for (unsigned i = 0; i < AdjacencyList::Size; ++i) {
1695             Edge& edge = node->children.child(i);
1696             if (!edge)
1697                 break;
1698             edge.setUseKind(KnownStringUse);
1699             JSString* string = edge->dynamicCastConstant<JSString*>();
1700             if (!string)
1701                 continue;
1702             if (string->length())
1703                 continue;
1704             
1705             // Don't allow the MakeRope to have zero children.
1706             if (!i && !node->child2())
1707                 break;
1708             
1709             node->children.removeEdge(i--);
1710         }
1711         
1712         if (!node->child2()) {
1713             ASSERT(!node->child3());
1714             node->convertToIdentity();
1715         }
1716     }
1717
1718     void fixupToThis(Node* node)
1719     {
1720         ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->isStrictMode() ? StrictMode : NotStrictMode;
1721
1722         if (ecmaMode == StrictMode) {
1723             if (node->child1()->shouldSpeculateBoolean()) {
1724                 fixEdge<BooleanUse>(node->child1());
1725                 node->convertToIdentity();
1726                 return;
1727             }
1728
1729             if (node->child1()->shouldSpeculateInt32()) {
1730                 fixEdge<Int32Use>(node->child1());
1731                 node->convertToIdentity();
1732                 return;
1733             }
1734
1735             if (enableInt52() && node->child1()->shouldSpeculateAnyInt()) {
1736                 fixEdge<Int52RepUse>(node->child1());
1737                 node->convertToIdentity();
1738                 node->setResult(NodeResultInt52);
1739                 return;
1740             }
1741
1742             if (node->child1()->shouldSpeculateNumber()) {
1743                 fixEdge<DoubleRepUse>(node->child1());
1744                 node->convertToIdentity();
1745                 node->setResult(NodeResultDouble);
1746                 return;
1747             }
1748
1749             if (node->child1()->shouldSpeculateSymbol()) {
1750                 fixEdge<SymbolUse>(node->child1());
1751                 node->convertToIdentity();
1752                 return;
1753             }
1754
1755             if (node->child1()->shouldSpeculateStringIdent()) {
1756                 fixEdge<StringIdentUse>(node->child1());
1757                 node->convertToIdentity();
1758                 return;
1759             }
1760
1761             if (node->child1()->shouldSpeculateString()) {
1762                 fixEdge<StringUse>(node->child1());
1763                 node->convertToIdentity();
1764                 return;
1765             }
1766         }
1767
1768         if (node->child1()->shouldSpeculateOther()) {
1769             if (ecmaMode == StrictMode) {
1770                 fixEdge<OtherUse>(node->child1());
1771                 node->convertToIdentity();
1772                 return;
1773             }
1774
1775             m_insertionSet.insertNode(
1776                 m_indexInBlock, SpecNone, Check, node->origin,
1777                 Edge(node->child1().node(), OtherUse));
1778             observeUseKindOnNode<OtherUse>(node->child1().node());
1779             m_graph.convertToConstant(
1780                 node, m_graph.globalThisObjectFor(node->origin.semantic));
1781             return;
1782         }
1783
1784         // FIXME: This should cover other use cases but we don't have use kinds for them. It's not critical,
1785         // however, since we cover all the missing cases in constant folding.
1786         // https://bugs.webkit.org/show_bug.cgi?id=157213
1787         if (node->child1()->shouldSpeculateStringObject()) {
1788             fixEdge<StringObjectUse>(node->child1());
1789             node->convertToIdentity();
1790             return;
1791         }
1792
1793         if (isFinalObjectSpeculation(node->child1()->prediction())) {
1794             fixEdge<FinalObjectUse>(node->child1());
1795             node->convertToIdentity();
1796             return;
1797         }
1798     }
1799     
1800     void fixupToPrimitive(Node* node)
1801     {
1802         if (node->child1()->shouldSpeculateInt32()) {
1803             fixEdge<Int32Use>(node->child1());
1804             node->convertToIdentity();
1805             return;
1806         }
1807         
1808         if (node->child1()->shouldSpeculateString()) {
1809             fixEdge<StringUse>(node->child1());
1810             node->convertToIdentity();
1811             return;
1812         }
1813         
1814         if (node->child1()->shouldSpeculateStringObject()
1815             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
1816             fixEdge<StringObjectUse>(node->child1());
1817             node->convertToToString();
1818             return;
1819         }
1820         
1821         if (node->child1()->shouldSpeculateStringOrStringObject()
1822             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
1823             fixEdge<StringOrStringObjectUse>(node->child1());
1824             node->convertToToString();
1825             return;
1826         }
1827     }
1828
1829     void fixupToNumber(Node* node)
1830     {
1831         // If the prediction of the child is Number, we attempt to convert ToNumber to Identity.
1832         if (node->child1()->shouldSpeculateNumber()) {
1833             if (isInt32Speculation(node->getHeapPrediction())) {
1834                 // If the both predictions of this node and the child is Int32, we just convert ToNumber to Identity, that's simple.
1835                 if (node->child1()->shouldSpeculateInt32()) {
1836                     fixEdge<Int32Use>(node->child1());
1837                     node->convertToIdentity();
1838                     return;
1839                 }
1840
1841                 // The another case is that the predicted type of the child is Int32, but the heap prediction tell the users that this will produce non Int32 values.
1842                 // In that case, let's receive the child value as a Double value and convert it to Int32. This case happens in misc-bugs-847389-jpeg2000.
1843                 fixEdge<DoubleRepUse>(node->child1());
1844                 node->setOp(DoubleAsInt32);
1845                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
1846                     node->setArithMode(Arith::CheckOverflow);
1847                 else
1848                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
1849                 return;
1850             }
1851
1852             fixEdge<DoubleRepUse>(node->child1());
1853             node->convertToIdentity();
1854             node->setResult(NodeResultDouble);
1855             return;
1856         }
1857
1858         fixEdge<UntypedUse>(node->child1());
1859         node->setResult(NodeResultJS);
1860     }
1861     
1862     void fixupToStringOrCallStringConstructor(Node* node)
1863     {
1864         if (node->child1()->shouldSpeculateString()) {
1865             fixEdge<StringUse>(node->child1());
1866             node->convertToIdentity();
1867             return;
1868         }
1869         
1870         if (node->child1()->shouldSpeculateStringObject()
1871             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
1872             fixEdge<StringObjectUse>(node->child1());
1873             return;
1874         }
1875         
1876         if (node->child1()->shouldSpeculateStringOrStringObject()
1877             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
1878             fixEdge<StringOrStringObjectUse>(node->child1());
1879             return;
1880         }
1881         
1882         if (node->child1()->shouldSpeculateCell()) {
1883             fixEdge<CellUse>(node->child1());
1884             return;
1885         }
1886     }
1887
1888     bool attemptToMakeFastStringAdd(Node* node)
1889     {
1890         bool goodToGo = true;
1891         m_graph.doToChildren(
1892             node,
1893             [&] (Edge& edge) {
1894                 if (edge->shouldSpeculateString())
1895                     return;
1896                 if (m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
1897                     if (edge->shouldSpeculateStringObject())
1898                         return;
1899                     if (edge->shouldSpeculateStringOrStringObject())
1900                         return;
1901                 }
1902                 goodToGo = false;
1903             });
1904         if (!goodToGo)
1905             return false;
1906
1907         m_graph.doToChildren(
1908             node,
1909             [&] (Edge& edge) {
1910                 if (edge->shouldSpeculateString()) {
1911                     convertStringAddUse<StringUse>(node, edge);
1912                     return;
1913                 }
1914                 ASSERT(m_graph.canOptimizeStringObjectAccess(node->origin.semantic));
1915                 if (edge->shouldSpeculateStringObject()) {
1916                     convertStringAddUse<StringObjectUse>(node, edge);
1917                     return;
1918                 }
1919                 if (edge->shouldSpeculateStringOrStringObject()) {
1920                     convertStringAddUse<StringOrStringObjectUse>(node, edge);
1921                     return;
1922                 }
1923                 RELEASE_ASSERT_NOT_REACHED();
1924             });
1925         
1926         convertToMakeRope(node);
1927         return true;
1928     }
1929
1930     void fixupGetAndSetLocalsInBlock(BasicBlock* block)
1931     {
1932         if (!block)
1933             return;
1934         ASSERT(block->isReachable);
1935         m_block = block;
1936         for (m_indexInBlock = 0; m_indexInBlock < block->size(); ++m_indexInBlock) {
1937             Node* node = m_currentNode = block->at(m_indexInBlock);
1938             if (node->op() != SetLocal && node->op() != GetLocal)
1939                 continue;
1940             
1941             VariableAccessData* variable = node->variableAccessData();
1942             switch (node->op()) {
1943             case GetLocal:
1944                 switch (variable->flushFormat()) {
1945                 case FlushedDouble:
1946                     node->setResult(NodeResultDouble);
1947                     break;
1948                 case FlushedInt52:
1949                     node->setResult(NodeResultInt52);
1950                     break;
1951                 default:
1952                     break;
1953                 }
1954                 break;
1955                 
1956             case SetLocal:
1957                 // NOTE: Any type checks we put here may get hoisted by fixupChecksInBlock(). So, if we
1958                 // add new type checking use kind for SetLocals, we need to modify that code as well.
1959                 
1960                 switch (variable->flushFormat()) {
1961                 case FlushedJSValue:
1962                     break;
1963                 case FlushedDouble:
1964                     fixEdge<DoubleRepUse>(node->child1());
1965                     break;
1966                 case FlushedInt32:
1967                     fixEdge<Int32Use>(node->child1());
1968                     break;
1969                 case FlushedInt52:
1970                     fixEdge<Int52RepUse>(node->child1());
1971                     break;
1972                 case FlushedCell:
1973                     fixEdge<CellUse>(node->child1());
1974                     break;
1975                 case FlushedBoolean:
1976                     fixEdge<BooleanUse>(node->child1());
1977                     break;
1978                 default:
1979                     RELEASE_ASSERT_NOT_REACHED();
1980                     break;
1981                 }
1982                 break;
1983                 
1984             default:
1985                 RELEASE_ASSERT_NOT_REACHED();
1986                 break;
1987             }
1988         }
1989         m_insertionSet.execute(block);
1990     }
1991     
1992     void addStringReplacePrimordialChecks(Node* searchRegExp)
1993     {
1994         Node* node = m_currentNode;
1995
1996         // Check that structure of searchRegExp is RegExp object
1997         m_insertionSet.insertNode(
1998             m_indexInBlock, SpecNone, Check, node->origin,
1999             Edge(searchRegExp, RegExpObjectUse));
2000
2001         auto emitPrimordialCheckFor = [&] (JSValue primordialProperty, UniquedStringImpl* propertyUID) {
2002             unsigned index = m_graph.identifiers().ensure(propertyUID);
2003
2004             Node* actualProperty = m_insertionSet.insertNode(
2005                 m_indexInBlock, SpecNone, TryGetById, node->origin,
2006                 OpInfo(index), OpInfo(SpecFunction), Edge(searchRegExp, CellUse));
2007
2008             m_insertionSet.insertNode(
2009                 m_indexInBlock, SpecNone, CheckCell, node->origin,
2010                 OpInfo(m_graph.freeze(primordialProperty)), Edge(actualProperty, CellUse));
2011         };
2012
2013         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
2014
2015         // Check that searchRegExp.exec is the primordial RegExp.prototype.exec
2016         emitPrimordialCheckFor(globalObject->regExpProtoExecFunction(), vm().propertyNames->exec.impl());
2017         // Check that searchRegExp.global is the primordial RegExp.prototype.global
2018         emitPrimordialCheckFor(globalObject->regExpProtoGlobalGetter(), vm().propertyNames->global.impl());
2019         // Check that searchRegExp.unicode is the primordial RegExp.prototype.unicode
2020         emitPrimordialCheckFor(globalObject->regExpProtoUnicodeGetter(), vm().propertyNames->unicode.impl());
2021         // Check that searchRegExp[Symbol.match] is the primordial RegExp.prototype[Symbol.replace]
2022         emitPrimordialCheckFor(globalObject->regExpProtoSymbolReplaceFunction(), vm().propertyNames->replaceSymbol.impl());
2023     }
2024
2025     Node* checkArray(ArrayMode arrayMode, const NodeOrigin& origin, Node* array, Node* index, bool (*storageCheck)(const ArrayMode&) = canCSEStorage)
2026     {
2027         ASSERT(arrayMode.isSpecific());
2028         
2029         if (arrayMode.type() == Array::String) {
2030             m_insertionSet.insertNode(
2031                 m_indexInBlock, SpecNone, Check, origin, Edge(array, StringUse));
2032         } else {
2033             // Note that we only need to be using a structure check if we opt for SaneChain, since
2034             // that needs to protect against JSArray's __proto__ being changed.
2035             Structure* structure = arrayMode.originalArrayStructure(m_graph, origin.semantic);
2036         
2037             Edge indexEdge = index ? Edge(index, Int32Use) : Edge();
2038             
2039             if (arrayMode.doesConversion()) {
2040                 if (structure) {
2041                     m_insertionSet.insertNode(
2042                         m_indexInBlock, SpecNone, ArrayifyToStructure, origin,
2043                         OpInfo(structure), OpInfo(arrayMode.asWord()), Edge(array, CellUse), indexEdge);
2044                 } else {
2045                     m_insertionSet.insertNode(
2046                         m_indexInBlock, SpecNone, Arrayify, origin,
2047                         OpInfo(arrayMode.asWord()), Edge(array, CellUse), indexEdge);
2048                 }
2049             } else {
2050                 if (structure) {
2051                     m_insertionSet.insertNode(
2052                         m_indexInBlock, SpecNone, CheckStructure, origin,
2053                         OpInfo(m_graph.addStructureSet(structure)), Edge(array, CellUse));
2054                 } else {
2055                     m_insertionSet.insertNode(
2056                         m_indexInBlock, SpecNone, CheckArray, origin,
2057                         OpInfo(arrayMode.asWord()), Edge(array, CellUse));
2058                 }
2059             }
2060         }
2061         
2062         if (!storageCheck(arrayMode))
2063             return 0;
2064         
2065         if (arrayMode.usesButterfly()) {
2066             return m_insertionSet.insertNode(
2067                 m_indexInBlock, SpecNone, GetButterfly, origin, Edge(array, CellUse));
2068         }
2069         
2070         return m_insertionSet.insertNode(
2071             m_indexInBlock, SpecNone, GetIndexedPropertyStorage, origin,
2072             OpInfo(arrayMode.asWord()), Edge(array, KnownCellUse));
2073     }
2074     
2075     void blessArrayOperation(Edge base, Edge index, Edge& storageChild)
2076     {
2077         Node* node = m_currentNode;
2078         
2079         switch (node->arrayMode().type()) {
2080         case Array::ForceExit: {
2081             m_insertionSet.insertNode(
2082                 m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
2083             return;
2084         }
2085             
2086         case Array::SelectUsingPredictions:
2087         case Array::Unprofiled:
2088             RELEASE_ASSERT_NOT_REACHED();
2089             return;
2090             
2091         case Array::Generic:
2092             return;
2093             
2094         default: {
2095             Node* storage = checkArray(node->arrayMode(), node->origin, base.node(), index.node());
2096             if (!storage)
2097                 return;
2098             
2099             storageChild = Edge(storage);
2100             return;
2101         } }
2102     }
2103     
2104     bool alwaysUnboxSimplePrimitives()
2105     {
2106 #if USE(JSVALUE64)
2107         return false;
2108 #else
2109         // Any boolean, int, or cell value is profitable to unbox on 32-bit because it
2110         // reduces traffic.
2111         return true;
2112 #endif
2113     }
2114
2115     template<UseKind useKind>
2116     void observeUseKindOnNode(Node* node)
2117     {
2118         if (useKind == UntypedUse)
2119             return;
2120         observeUseKindOnNode(node, useKind);
2121     }
2122
2123     void observeUseKindOnEdge(Edge edge)
2124     {
2125         observeUseKindOnNode(edge.node(), edge.useKind());
2126     }
2127
2128     void observeUseKindOnNode(Node* node, UseKind useKind)
2129     {
2130         if (node->op() != GetLocal)
2131             return;
2132         
2133         // FIXME: The way this uses alwaysUnboxSimplePrimitives() is suspicious.
2134         // https://bugs.webkit.org/show_bug.cgi?id=121518
2135         
2136         VariableAccessData* variable = node->variableAccessData();
2137         switch (useKind) {
2138         case Int32Use:
2139         case KnownInt32Use:
2140             if (alwaysUnboxSimplePrimitives()
2141                 || isInt32Speculation(variable->prediction()))
2142                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2143             break;
2144         case NumberUse:
2145         case RealNumberUse:
2146         case DoubleRepUse:
2147         case DoubleRepRealUse:
2148             if (variable->doubleFormatState() == UsingDoubleFormat)
2149                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2150             break;
2151         case BooleanUse:
2152         case KnownBooleanUse:
2153             if (alwaysUnboxSimplePrimitives()
2154                 || isBooleanSpeculation(variable->prediction()))
2155                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2156             break;
2157         case Int52RepUse:
2158             if (isAnyIntSpeculation(variable->prediction()))
2159                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2160             break;
2161         case CellUse:
2162         case KnownCellUse:
2163         case ObjectUse:
2164         case FunctionUse:
2165         case StringUse:
2166         case KnownStringUse:
2167         case SymbolUse:
2168         case StringObjectUse:
2169         case StringOrStringObjectUse:
2170             if (alwaysUnboxSimplePrimitives()
2171                 || isCellSpeculation(variable->prediction()))
2172                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2173             break;
2174         default:
2175             break;
2176         }
2177     }
2178     
2179     template<UseKind useKind>
2180     void fixEdge(Edge& edge)
2181     {
2182         observeUseKindOnNode<useKind>(edge.node());
2183         edge.setUseKind(useKind);
2184     }
2185     
2186     void speculateForBarrier(Edge value)
2187     {
2188         // Currently, the DFG won't take advantage of this speculation. But, we want to do it in
2189         // the DFG anyway because if such a speculation would be wrong, we want to know before
2190         // we do an expensive compile.
2191         
2192         if (value->shouldSpeculateInt32()) {
2193             insertCheck<Int32Use>(m_indexInBlock, value.node());
2194             return;
2195         }
2196             
2197         if (value->shouldSpeculateBoolean()) {
2198             insertCheck<BooleanUse>(m_indexInBlock, value.node());
2199             return;
2200         }
2201             
2202         if (value->shouldSpeculateOther()) {
2203             insertCheck<OtherUse>(m_indexInBlock, value.node());
2204             return;
2205         }
2206             
2207         if (value->shouldSpeculateNumber()) {
2208             insertCheck<NumberUse>(m_indexInBlock, value.node());
2209             return;
2210         }
2211             
2212         if (value->shouldSpeculateNotCell()) {
2213             insertCheck<NotCellUse>(m_indexInBlock, value.node());
2214             return;
2215         }
2216     }
2217     
2218     template<UseKind useKind>
2219     void insertCheck(unsigned indexInBlock, Node* node)
2220     {
2221         observeUseKindOnNode<useKind>(node);
2222         m_insertionSet.insertNode(
2223             indexInBlock, SpecNone, Check, m_currentNode->origin, Edge(node, useKind));
2224     }
2225
2226     void fixIntConvertingEdge(Edge& edge)
2227     {
2228         Node* node = edge.node();
2229         if (node->shouldSpeculateInt32OrBoolean()) {
2230             fixIntOrBooleanEdge(edge);
2231             return;
2232         }
2233         
2234         UseKind useKind;
2235         if (node->shouldSpeculateAnyInt())
2236             useKind = Int52RepUse;
2237         else if (node->shouldSpeculateNumber())
2238             useKind = DoubleRepUse;
2239         else
2240             useKind = NotCellUse;
2241         Node* newNode = m_insertionSet.insertNode(
2242             m_indexInBlock, SpecInt32Only, ValueToInt32, m_currentNode->origin,
2243             Edge(node, useKind));
2244         observeUseKindOnNode(node, useKind);
2245         
2246         edge = Edge(newNode, KnownInt32Use);
2247     }
2248     
2249     void fixIntOrBooleanEdge(Edge& edge)
2250     {
2251         Node* node = edge.node();
2252         if (!node->sawBooleans()) {
2253             fixEdge<Int32Use>(edge);
2254             return;
2255         }
2256         
2257         UseKind useKind;
2258         if (node->shouldSpeculateBoolean())
2259             useKind = BooleanUse;
2260         else
2261             useKind = UntypedUse;
2262         Node* newNode = m_insertionSet.insertNode(
2263             m_indexInBlock, SpecInt32Only, BooleanToNumber, m_currentNode->origin,
2264             Edge(node, useKind));
2265         observeUseKindOnNode(node, useKind);
2266         
2267         edge = Edge(newNode, Int32Use);
2268     }
2269     
2270     void fixDoubleOrBooleanEdge(Edge& edge)
2271     {
2272         Node* node = edge.node();
2273         if (!node->sawBooleans()) {
2274             fixEdge<DoubleRepUse>(edge);
2275             return;
2276         }
2277         
2278         UseKind useKind;
2279         if (node->shouldSpeculateBoolean())
2280             useKind = BooleanUse;
2281         else
2282             useKind = UntypedUse;
2283         Node* newNode = m_insertionSet.insertNode(
2284             m_indexInBlock, SpecInt32Only, BooleanToNumber, m_currentNode->origin,
2285             Edge(node, useKind));
2286         observeUseKindOnNode(node, useKind);
2287         
2288         edge = Edge(newNode, DoubleRepUse);
2289     }
2290     
2291     void truncateConstantToInt32(Edge& edge)
2292     {
2293         Node* oldNode = edge.node();
2294         
2295         JSValue value = oldNode->asJSValue();
2296         if (value.isInt32())
2297             return;
2298         
2299         value = jsNumber(JSC::toInt32(value.asNumber()));
2300         ASSERT(value.isInt32());
2301         edge.setNode(m_insertionSet.insertNode(
2302             m_indexInBlock, SpecInt32Only, JSConstant, m_currentNode->origin,
2303             OpInfo(m_graph.freeze(value))));
2304     }
2305     
2306     void truncateConstantsIfNecessary(Node* node, AddSpeculationMode mode)
2307     {
2308         if (mode != SpeculateInt32AndTruncateConstants)
2309             return;
2310         
2311         ASSERT(node->child1()->hasConstant() || node->child2()->hasConstant());
2312         if (node->child1()->hasConstant())
2313             truncateConstantToInt32(node->child1());
2314         else
2315             truncateConstantToInt32(node->child2());
2316     }
2317     
2318     bool attemptToMakeIntegerAdd(Node* node)
2319     {
2320         AddSpeculationMode mode = m_graph.addSpeculationMode(node, FixupPass);
2321         if (mode != DontSpeculateInt32) {
2322             truncateConstantsIfNecessary(node, mode);
2323             fixIntOrBooleanEdge(node->child1());
2324             fixIntOrBooleanEdge(node->child2());
2325             if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
2326                 node->setArithMode(Arith::Unchecked);
2327             else
2328                 node->setArithMode(Arith::CheckOverflow);
2329             return true;
2330         }
2331         
2332         if (m_graph.addShouldSpeculateAnyInt(node)) {
2333             fixEdge<Int52RepUse>(node->child1());
2334             fixEdge<Int52RepUse>(node->child2());
2335             node->setArithMode(Arith::CheckOverflow);
2336             node->setResult(NodeResultInt52);
2337             return true;
2338         }
2339         
2340         return false;
2341     }
2342     
2343     bool attemptToMakeGetArrayLength(Node* node)
2344     {
2345         if (!isInt32Speculation(node->prediction()))
2346             return false;
2347         CodeBlock* profiledBlock = m_graph.baselineCodeBlockFor(node->origin.semantic);
2348         ArrayProfile* arrayProfile = 
2349             profiledBlock->getArrayProfile(node->origin.semantic.bytecodeIndex);
2350         ArrayMode arrayMode = ArrayMode(Array::SelectUsingPredictions);
2351         if (arrayProfile) {
2352             ConcurrentJITLocker locker(profiledBlock->m_lock);
2353             arrayProfile->computeUpdatedPrediction(locker, profiledBlock);
2354             arrayMode = ArrayMode::fromObserved(locker, arrayProfile, Array::Read, false);
2355             if (arrayMode.type() == Array::Unprofiled) {
2356                 // For normal array operations, it makes sense to treat Unprofiled
2357                 // accesses as ForceExit and get more data rather than using
2358                 // predictions and then possibly ending up with a Generic. But here,
2359                 // we treat anything that is Unprofiled as Generic and keep the
2360                 // GetById. I.e. ForceExit = Generic. So, there is no harm - and only
2361                 // profit - from treating the Unprofiled case as
2362                 // SelectUsingPredictions.
2363                 arrayMode = ArrayMode(Array::SelectUsingPredictions);
2364             }
2365         }
2366             
2367         arrayMode = arrayMode.refine(
2368             m_graph, node, node->child1()->prediction(), node->prediction());
2369             
2370         if (arrayMode.type() == Array::Generic) {
2371             // Check if the input is something that we can't get array length for, but for which we
2372             // could insert some conversions in order to transform it into something that we can do it
2373             // for.
2374             if (node->child1()->shouldSpeculateStringObject())
2375                 attemptToForceStringArrayModeByToStringConversion<StringObjectUse>(arrayMode, node);
2376             else if (node->child1()->shouldSpeculateStringOrStringObject())
2377                 attemptToForceStringArrayModeByToStringConversion<StringOrStringObjectUse>(arrayMode, node);
2378         }
2379             
2380         if (!arrayMode.supportsSelfLength())
2381             return false;
2382         
2383         convertToGetArrayLength(node, arrayMode);
2384         return true;
2385     }
2386
2387     void convertToGetArrayLength(Node* node, ArrayMode arrayMode)
2388     {
2389         node->setOp(GetArrayLength);
2390         node->clearFlags(NodeMustGenerate);
2391         fixEdge<KnownCellUse>(node->child1());
2392         node->setArrayMode(arrayMode);
2393             
2394         Node* storage = checkArray(arrayMode, node->origin, node->child1().node(), 0, lengthNeedsStorage);
2395         if (!storage)
2396             return;
2397             
2398         node->child2() = Edge(storage);
2399     }
2400     
2401     Node* prependGetArrayLength(NodeOrigin origin, Node* child, ArrayMode arrayMode)
2402     {
2403         Node* storage = checkArray(arrayMode, origin, child, 0, lengthNeedsStorage);
2404         return m_insertionSet.insertNode(
2405             m_indexInBlock, SpecInt32Only, GetArrayLength, origin,
2406             OpInfo(arrayMode.asWord()), Edge(child, KnownCellUse), Edge(storage));
2407     }
2408     
2409     void fixupChecksInBlock(BasicBlock* block)
2410     {
2411         if (!block)
2412             return;
2413         ASSERT(block->isReachable);
2414         m_block = block;
2415         unsigned indexForChecks = UINT_MAX;
2416         NodeOrigin originForChecks;
2417         for (unsigned indexInBlock = 0; indexInBlock < block->size(); ++indexInBlock) {
2418             Node* node = block->at(indexInBlock);
2419
2420             // If this is a node at which we could exit, then save its index. If nodes after this one
2421             // cannot exit, then we will hoist checks to here.
2422             if (node->origin.exitOK) {
2423                 indexForChecks = indexInBlock;
2424                 originForChecks = node->origin;
2425             }
2426
2427             originForChecks = originForChecks.withSemantic(node->origin.semantic);
2428
2429             // First, try to relax the representational demands of each node, in order to have
2430             // fewer conversions.
2431             switch (node->op()) {
2432             case MovHint:
2433             case Check:
2434                 m_graph.doToChildren(
2435                     node,
2436                     [&] (Edge& edge) {
2437                         switch (edge.useKind()) {
2438                         case DoubleRepUse:
2439                         case DoubleRepRealUse:
2440                             if (edge->hasDoubleResult())
2441                                 break;
2442             
2443                             if (edge->hasInt52Result())
2444                                 edge.setUseKind(Int52RepUse);
2445                             else if (edge.useKind() == DoubleRepUse)
2446                                 edge.setUseKind(NumberUse);
2447                             break;
2448             
2449                         case Int52RepUse:
2450                             // Nothing we can really do.
2451                             break;
2452             
2453                         case UntypedUse:
2454                         case NumberUse:
2455                             if (edge->hasDoubleResult())
2456                                 edge.setUseKind(DoubleRepUse);
2457                             else if (edge->hasInt52Result())
2458                                 edge.setUseKind(Int52RepUse);
2459                             break;
2460             
2461                         case RealNumberUse:
2462                             if (edge->hasDoubleResult())
2463                                 edge.setUseKind(DoubleRepRealUse);
2464                             else if (edge->hasInt52Result())
2465                                 edge.setUseKind(Int52RepUse);
2466                             break;
2467             
2468                         default:
2469                             break;
2470                         }
2471                     });
2472                 break;
2473                 
2474             case ValueToInt32:
2475                 if (node->child1().useKind() == DoubleRepUse
2476                     && !node->child1()->hasDoubleResult()) {
2477                     node->child1().setUseKind(NumberUse);
2478                     break;
2479                 }
2480                 break;
2481                 
2482             default:
2483                 break;
2484             }
2485
2486             // Now, insert type conversions if necessary.
2487             m_graph.doToChildren(
2488                 node,
2489                 [&] (Edge& edge) {
2490                     Node* result = nullptr;
2491
2492                     switch (edge.useKind()) {
2493                     case DoubleRepUse:
2494                     case DoubleRepRealUse:
2495                     case DoubleRepAnyIntUse: {
2496                         if (edge->hasDoubleResult())
2497                             break;
2498             
2499                         if (edge->isNumberConstant()) {
2500                             result = m_insertionSet.insertNode(
2501                                 indexForChecks, SpecBytecodeDouble, DoubleConstant, originForChecks,
2502                                 OpInfo(m_graph.freeze(jsDoubleNumber(edge->asNumber()))));
2503                         } else if (edge->hasInt52Result()) {
2504                             result = m_insertionSet.insertNode(
2505                                 indexForChecks, SpecAnyIntAsDouble, DoubleRep, originForChecks,
2506                                 Edge(edge.node(), Int52RepUse));
2507                         } else {
2508                             UseKind useKind;
2509                             if (edge->shouldSpeculateDoubleReal())
2510                                 useKind = RealNumberUse;
2511                             else if (edge->shouldSpeculateNumber())
2512                                 useKind = NumberUse;
2513                             else
2514                                 useKind = NotCellUse;
2515
2516                             result = m_insertionSet.insertNode(
2517                                 indexForChecks, SpecBytecodeDouble, DoubleRep, originForChecks,
2518                                 Edge(edge.node(), useKind));
2519                         }
2520
2521                         edge.setNode(result);
2522                         break;
2523                     }
2524             
2525                     case Int52RepUse: {
2526                         if (edge->hasInt52Result())
2527                             break;
2528             
2529                         if (edge->isAnyIntConstant()) {
2530                             result = m_insertionSet.insertNode(
2531                                 indexForChecks, SpecAnyInt, Int52Constant, originForChecks,
2532                                 OpInfo(edge->constant()));
2533                         } else if (edge->hasDoubleResult()) {
2534                             result = m_insertionSet.insertNode(
2535                                 indexForChecks, SpecAnyInt, Int52Rep, originForChecks,
2536                                 Edge(edge.node(), DoubleRepAnyIntUse));
2537                         } else if (edge->shouldSpeculateInt32ForArithmetic()) {
2538                             result = m_insertionSet.insertNode(
2539                                 indexForChecks, SpecInt32Only, Int52Rep, originForChecks,
2540                                 Edge(edge.node(), Int32Use));
2541                         } else {
2542                             result = m_insertionSet.insertNode(
2543                                 indexForChecks, SpecAnyInt, Int52Rep, originForChecks,
2544                                 Edge(edge.node(), AnyIntUse));
2545                         }
2546
2547                         edge.setNode(result);
2548                         break;
2549                     }
2550
2551                     default: {
2552                         if (!edge->hasDoubleResult() && !edge->hasInt52Result())
2553                             break;
2554             
2555                         if (edge->hasDoubleResult()) {
2556                             result = m_insertionSet.insertNode(
2557                                 indexForChecks, SpecBytecodeDouble, ValueRep, originForChecks,
2558                                 Edge(edge.node(), DoubleRepUse));
2559                         } else {
2560                             result = m_insertionSet.insertNode(
2561                                 indexForChecks, SpecInt32Only | SpecAnyIntAsDouble, ValueRep,
2562                                 originForChecks, Edge(edge.node(), Int52RepUse));
2563                         }
2564
2565                         edge.setNode(result);
2566                         break;
2567                     } }
2568
2569                     // It's remotely possible that this node cannot do type checks, but we now have a
2570                     // type check on this node. We don't have to handle the general form of this
2571                     // problem. It only arises when ByteCodeParser emits an immediate SetLocal, rather
2572                     // than a delayed one. So, we only worry about those checks that we may have put on
2573                     // a SetLocal. Note that "indexForChecks != indexInBlock" is just another way of
2574                     // saying "!node->origin.exitOK".
2575                     if (indexForChecks != indexInBlock && mayHaveTypeCheck(edge.useKind())) {
2576                         UseKind knownUseKind;
2577                         
2578                         switch (edge.useKind()) {
2579                         case Int32Use:
2580                             knownUseKind = KnownInt32Use;
2581                             break;
2582                         case CellUse:
2583                             knownUseKind = KnownCellUse;
2584                             break;
2585                         case BooleanUse:
2586                             knownUseKind = KnownBooleanUse;
2587                             break;
2588                         default:
2589                             // This can only arise if we have a Check node, and in that case, we can
2590                             // just remove the original check.
2591                             DFG_ASSERT(m_graph, node, node->op() == Check);
2592                             knownUseKind = UntypedUse;
2593                             break;
2594                         }
2595
2596                         m_insertionSet.insertNode(
2597                             indexForChecks, SpecNone, Check, originForChecks, edge);
2598
2599                         edge.setUseKind(knownUseKind);
2600                     }
2601                 });
2602         }
2603         
2604         m_insertionSet.execute(block);
2605     }
2606     
2607     BasicBlock* m_block;
2608     unsigned m_indexInBlock;
2609     Node* m_currentNode;
2610     InsertionSet m_insertionSet;
2611     bool m_profitabilityChanged;
2612 };
2613     
2614 bool performFixup(Graph& graph)
2615 {
2616     return runPhase<FixupPhase>(graph);
2617 }
2618
2619 } } // namespace JSC::DFG
2620
2621 #endif // ENABLE(DFG_JIT)
2622