Remove poisoning of typed array vector
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGFixupPhase.cpp
1 /*
2  * Copyright (C) 2012-2017 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             if (node->child1()->shouldSpeculateNotCell()) {
130                 fixIntConvertingEdge(node->child1());
131                 node->clearFlags(NodeMustGenerate);
132             } else
133                 fixEdge<UntypedUse>(node->child1());
134             break;
135         }
136             
137         case UInt32ToNumber: {
138             fixIntConvertingEdge(node->child1());
139             if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
140                 node->convertToIdentity();
141             else if (node->canSpeculateInt32(FixupPass))
142                 node->setArithMode(Arith::CheckOverflow);
143             else {
144                 node->setArithMode(Arith::DoOverflow);
145                 node->setResult(enableInt52() ? NodeResultInt52 : NodeResultDouble);
146             }
147             break;
148         }
149             
150         case ValueAdd: {
151             if (attemptToMakeIntegerAdd(node)) {
152                 node->setOp(ArithAdd);
153                 break;
154             }
155             if (Node::shouldSpeculateNumberOrBooleanExpectingDefined(node->child1().node(), node->child2().node())) {
156                 fixDoubleOrBooleanEdge(node->child1());
157                 fixDoubleOrBooleanEdge(node->child2());
158                 node->setOp(ArithAdd);
159                 node->setResult(NodeResultDouble);
160                 break;
161             }
162             
163             if (attemptToMakeFastStringAdd(node))
164                 break;
165
166             Edge& child1 = node->child1();
167             Edge& child2 = node->child2();
168             if (child1->shouldSpeculateString() || child2->shouldSpeculateString()) {
169                 if (child1->shouldSpeculateInt32() || child2->shouldSpeculateInt32()) {
170                     auto convertString = [&](Node* node, Edge& edge) {
171                         if (edge->shouldSpeculateInt32())
172                             convertStringAddUse<Int32Use>(node, edge);
173                         else {
174                             ASSERT(edge->shouldSpeculateString());
175                             convertStringAddUse<StringUse>(node, edge);
176                         }
177                     };
178                     convertString(node, child1);
179                     convertString(node, child2);
180                     convertToMakeRope(node);
181                     break;
182                 }
183             }
184
185             fixEdge<UntypedUse>(child1);
186             fixEdge<UntypedUse>(child2);
187             node->setResult(NodeResultJS);
188             break;
189         }
190
191         case StrCat: {
192             if (attemptToMakeFastStringAdd(node))
193                 break;
194
195             // FIXME: Remove empty string arguments and possibly turn this into a ToString operation. That
196             // would require a form of ToString that takes a KnownPrimitiveUse. This is necessary because
197             // the implementation of StrCat doesn't dynamically optimize for empty strings.
198             // https://bugs.webkit.org/show_bug.cgi?id=148540
199             m_graph.doToChildren(
200                 node,
201                 [&] (Edge& edge) {
202                     fixEdge<KnownPrimitiveUse>(edge);
203                     // StrCat automatically coerces the values into strings before concatenating them.
204                     // The ECMA spec says that we're not allowed to automatically coerce a Symbol into
205                     // a string. If a Symbol is encountered, a TypeError will be thrown. As a result,
206                     // our runtime functions for this slow path expect that they will never be passed
207                     // Symbols.
208                     m_insertionSet.insertNode(
209                         m_indexInBlock, SpecNone, Check, node->origin,
210                         Edge(edge.node(), NotSymbolUse));
211                 });
212             break;
213         }
214             
215         case MakeRope: {
216             fixupMakeRope(node);
217             break;
218         }
219             
220         case ArithAdd:
221         case ArithSub: {
222             if (op == ArithSub
223                 && Node::shouldSpeculateUntypedForArithmetic(node->child1().node(), node->child2().node())) {
224                 fixEdge<UntypedUse>(node->child1());
225                 fixEdge<UntypedUse>(node->child2());
226                 node->setResult(NodeResultJS);
227                 break;
228             }
229             if (attemptToMakeIntegerAdd(node))
230                 break;
231             fixDoubleOrBooleanEdge(node->child1());
232             fixDoubleOrBooleanEdge(node->child2());
233             node->setResult(NodeResultDouble);
234             break;
235         }
236             
237         case ArithNegate: {
238             if (node->child1()->shouldSpeculateInt32OrBoolean() && node->canSpeculateInt32(FixupPass)) {
239                 fixIntOrBooleanEdge(node->child1());
240                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
241                     node->setArithMode(Arith::Unchecked);
242                 else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
243                     node->setArithMode(Arith::CheckOverflow);
244                 else
245                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
246                 node->setResult(NodeResultInt32);
247                 node->clearFlags(NodeMustGenerate);
248                 break;
249             }
250             if (m_graph.unaryArithShouldSpeculateAnyInt(node, FixupPass)) {
251                 fixEdge<Int52RepUse>(node->child1());
252                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
253                     node->setArithMode(Arith::CheckOverflow);
254                 else
255                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
256                 node->setResult(NodeResultInt52);
257                 node->clearFlags(NodeMustGenerate);
258                 break;
259             }
260             if (node->child1()->shouldSpeculateNotCell()) {
261                 fixDoubleOrBooleanEdge(node->child1());
262                 node->setResult(NodeResultDouble);
263                 node->clearFlags(NodeMustGenerate);
264             } else
265                 fixEdge<UntypedUse>(node->child1());
266             break;
267         }
268             
269         case ArithMul: {
270             Edge& leftChild = node->child1();
271             Edge& rightChild = node->child2();
272             if (Node::shouldSpeculateUntypedForArithmetic(leftChild.node(), rightChild.node())) {
273                 fixEdge<UntypedUse>(leftChild);
274                 fixEdge<UntypedUse>(rightChild);
275                 node->setResult(NodeResultJS);
276                 break;
277             }
278             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
279                 fixIntOrBooleanEdge(leftChild);
280                 fixIntOrBooleanEdge(rightChild);
281                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
282                     node->setArithMode(Arith::Unchecked);
283                 else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags())
284                     || leftChild.node() == rightChild.node())
285                     node->setArithMode(Arith::CheckOverflow);
286                 else
287                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
288                 break;
289             }
290             if (m_graph.binaryArithShouldSpeculateAnyInt(node, FixupPass)) {
291                 fixEdge<Int52RepUse>(leftChild);
292                 fixEdge<Int52RepUse>(rightChild);
293                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags())
294                     || leftChild.node() == rightChild.node())
295                     node->setArithMode(Arith::CheckOverflow);
296                 else
297                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
298                 node->setResult(NodeResultInt52);
299                 break;
300             }
301             fixDoubleOrBooleanEdge(leftChild);
302             fixDoubleOrBooleanEdge(rightChild);
303             node->setResult(NodeResultDouble);
304             break;
305         }
306
307         case ArithDiv:
308         case ArithMod: {
309             Edge& leftChild = node->child1();
310             Edge& rightChild = node->child2();
311             if (op == ArithDiv
312                 && Node::shouldSpeculateUntypedForArithmetic(leftChild.node(), rightChild.node())
313                 && m_graph.hasExitSite(node->origin.semantic, BadType)) {
314                 fixEdge<UntypedUse>(leftChild);
315                 fixEdge<UntypedUse>(rightChild);
316                 node->setResult(NodeResultJS);
317                 break;
318             }
319             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
320                 if (optimizeForX86() || optimizeForARM64() || optimizeForARMv7IDIVSupported()) {
321                     fixIntOrBooleanEdge(leftChild);
322                     fixIntOrBooleanEdge(rightChild);
323                     if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
324                         node->setArithMode(Arith::Unchecked);
325                     else if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
326                         node->setArithMode(Arith::CheckOverflow);
327                     else
328                         node->setArithMode(Arith::CheckOverflowAndNegativeZero);
329                     break;
330                 }
331                 
332                 // This will cause conversion nodes to be inserted later.
333                 fixDoubleOrBooleanEdge(leftChild);
334                 fixDoubleOrBooleanEdge(rightChild);
335                 
336                 // We don't need to do ref'ing on the children because we're stealing them from
337                 // the original division.
338                 Node* newDivision = m_insertionSet.insertNode(
339                     m_indexInBlock, SpecBytecodeDouble, *node);
340                 newDivision->setResult(NodeResultDouble);
341                 
342                 node->setOp(DoubleAsInt32);
343                 node->children.initialize(Edge(newDivision, DoubleRepUse), Edge(), Edge());
344                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
345                     node->setArithMode(Arith::CheckOverflow);
346                 else
347                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
348                 break;
349             }
350             fixDoubleOrBooleanEdge(leftChild);
351             fixDoubleOrBooleanEdge(rightChild);
352             node->setResult(NodeResultDouble);
353             break;
354         }
355             
356         case ArithMin:
357         case ArithMax: {
358             if (m_graph.binaryArithShouldSpeculateInt32(node, FixupPass)) {
359                 fixIntOrBooleanEdge(node->child1());
360                 fixIntOrBooleanEdge(node->child2());
361                 break;
362             }
363             fixDoubleOrBooleanEdge(node->child1());
364             fixDoubleOrBooleanEdge(node->child2());
365             node->setResult(NodeResultDouble);
366             break;
367         }
368             
369         case ArithAbs: {
370             if (node->child1()->shouldSpeculateInt32OrBoolean()
371                 && node->canSpeculateInt32(FixupPass)) {
372                 fixIntOrBooleanEdge(node->child1());
373                 if (bytecodeCanTruncateInteger(node->arithNodeFlags()))
374                     node->setArithMode(Arith::Unchecked);
375                 else
376                     node->setArithMode(Arith::CheckOverflow);
377                 node->clearFlags(NodeMustGenerate);
378                 node->setResult(NodeResultInt32);
379                 break;
380             }
381
382             if (node->child1()->shouldSpeculateNotCell()) {
383                 fixDoubleOrBooleanEdge(node->child1());
384                 node->clearFlags(NodeMustGenerate);
385             } else
386                 fixEdge<UntypedUse>(node->child1());
387             node->setResult(NodeResultDouble);
388             break;
389         }
390
391         case ArithPow: {
392             if (node->child2()->shouldSpeculateInt32OrBooleanForArithmetic()) {
393                 fixDoubleOrBooleanEdge(node->child1());
394                 fixIntOrBooleanEdge(node->child2());
395                 break;
396             }
397
398             fixDoubleOrBooleanEdge(node->child1());
399             fixDoubleOrBooleanEdge(node->child2());
400             break;
401         }
402
403         case ArithRandom: {
404             node->setResult(NodeResultDouble);
405             break;
406         }
407
408         case ArithRound:
409         case ArithFloor:
410         case ArithCeil:
411         case ArithTrunc: {
412             if (node->child1()->shouldSpeculateInt32OrBoolean() && m_graph.roundShouldSpeculateInt32(node, FixupPass)) {
413                 fixIntOrBooleanEdge(node->child1());
414                 insertCheck<Int32Use>(node->child1().node());
415                 node->convertToIdentity();
416                 break;
417             }
418             if (node->child1()->shouldSpeculateNotCell()) {
419                 fixDoubleOrBooleanEdge(node->child1());
420
421                 if (isInt32OrBooleanSpeculation(node->getHeapPrediction()) && m_graph.roundShouldSpeculateInt32(node, FixupPass)) {
422                     node->setResult(NodeResultInt32);
423                     if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
424                         node->setArithRoundingMode(Arith::RoundingMode::Int32);
425                     else
426                         node->setArithRoundingMode(Arith::RoundingMode::Int32WithNegativeZeroCheck);
427                 } else {
428                     node->setResult(NodeResultDouble);
429                     node->setArithRoundingMode(Arith::RoundingMode::Double);
430                 }
431                 node->clearFlags(NodeMustGenerate);
432             } else
433                 fixEdge<UntypedUse>(node->child1());
434             break;
435         }
436
437         case ArithFRound:
438         case ArithSqrt:
439         case ArithUnary: {
440             Edge& child1 = node->child1();
441             if (child1->shouldSpeculateNotCell()) {
442                 fixDoubleOrBooleanEdge(child1);
443                 node->clearFlags(NodeMustGenerate);
444             } else
445                 fixEdge<UntypedUse>(child1);
446             break;
447         }
448             
449         case LogicalNot: {
450             if (node->child1()->shouldSpeculateBoolean()) {
451                 if (node->child1()->result() == NodeResultBoolean) {
452                     // This is necessary in case we have a bytecode instruction implemented by:
453                     //
454                     // a: CompareEq(...)
455                     // b: LogicalNot(@a)
456                     //
457                     // In that case, CompareEq might have a side-effect. Then, we need to make
458                     // sure that we know that Branch does not exit.
459                     fixEdge<KnownBooleanUse>(node->child1());
460                 } else
461                     fixEdge<BooleanUse>(node->child1());
462             } else if (node->child1()->shouldSpeculateObjectOrOther())
463                 fixEdge<ObjectOrOtherUse>(node->child1());
464             else if (node->child1()->shouldSpeculateInt32OrBoolean())
465                 fixIntOrBooleanEdge(node->child1());
466             else if (node->child1()->shouldSpeculateNumber())
467                 fixEdge<DoubleRepUse>(node->child1());
468             else if (node->child1()->shouldSpeculateString())
469                 fixEdge<StringUse>(node->child1());
470             else if (node->child1()->shouldSpeculateStringOrOther())
471                 fixEdge<StringOrOtherUse>(node->child1());
472             else {
473                 WatchpointSet* masqueradesAsUndefinedWatchpoint = m_graph.globalObjectFor(node->origin.semantic)->masqueradesAsUndefinedWatchpoint();
474                 if (masqueradesAsUndefinedWatchpoint->isStillValid())
475                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
476             }
477             break;
478         }
479
480         case CompareEq:
481         case CompareLess:
482         case CompareLessEq:
483         case CompareGreater:
484         case CompareGreaterEq: {
485             if (node->op() == CompareEq
486                 && Node::shouldSpeculateBoolean(node->child1().node(), node->child2().node())) {
487                 fixEdge<BooleanUse>(node->child1());
488                 fixEdge<BooleanUse>(node->child2());
489                 node->clearFlags(NodeMustGenerate);
490                 break;
491             }
492             if (Node::shouldSpeculateInt32OrBoolean(node->child1().node(), node->child2().node())) {
493                 fixIntOrBooleanEdge(node->child1());
494                 fixIntOrBooleanEdge(node->child2());
495                 node->clearFlags(NodeMustGenerate);
496                 break;
497             }
498             if (enableInt52()
499                 && Node::shouldSpeculateAnyInt(node->child1().node(), node->child2().node())) {
500                 fixEdge<Int52RepUse>(node->child1());
501                 fixEdge<Int52RepUse>(node->child2());
502                 node->clearFlags(NodeMustGenerate);
503                 break;
504             }
505             if (Node::shouldSpeculateNumberOrBoolean(node->child1().node(), node->child2().node())) {
506                 fixDoubleOrBooleanEdge(node->child1());
507                 fixDoubleOrBooleanEdge(node->child2());
508             }
509             if (node->op() != CompareEq
510                 && node->child1()->shouldSpeculateNotCell()
511                 && node->child2()->shouldSpeculateNotCell()) {
512                 if (node->child1()->shouldSpeculateNumberOrBoolean())
513                     fixDoubleOrBooleanEdge(node->child1());
514                 else
515                     fixEdge<DoubleRepUse>(node->child1());
516                 if (node->child2()->shouldSpeculateNumberOrBoolean())
517                     fixDoubleOrBooleanEdge(node->child2());
518                 else
519                     fixEdge<DoubleRepUse>(node->child2());
520                 node->clearFlags(NodeMustGenerate);
521                 break;
522             }
523             if (node->child1()->shouldSpeculateStringIdent() && node->child2()->shouldSpeculateStringIdent()) {
524                 fixEdge<StringIdentUse>(node->child1());
525                 fixEdge<StringIdentUse>(node->child2());
526                 node->clearFlags(NodeMustGenerate);
527                 break;
528             }
529             if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && GPRInfo::numberOfRegisters >= 7) {
530                 fixEdge<StringUse>(node->child1());
531                 fixEdge<StringUse>(node->child2());
532                 node->clearFlags(NodeMustGenerate);
533                 break;
534             }
535
536             if (node->op() != CompareEq)
537                 break;
538             if (Node::shouldSpeculateSymbol(node->child1().node(), node->child2().node())) {
539                 fixEdge<SymbolUse>(node->child1());
540                 fixEdge<SymbolUse>(node->child2());
541                 node->clearFlags(NodeMustGenerate);
542                 break;
543             }
544             if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObject()) {
545                 fixEdge<ObjectUse>(node->child1());
546                 fixEdge<ObjectUse>(node->child2());
547                 node->clearFlags(NodeMustGenerate);
548                 break;
549             }
550
551             // If either child can be proved to be Null or Undefined, comparing them is greatly simplified.
552             bool oneArgumentIsUsedAsSpecOther = false;
553             if (node->child1()->isUndefinedOrNullConstant()) {
554                 fixEdge<OtherUse>(node->child1());
555                 oneArgumentIsUsedAsSpecOther = true;
556             } else if (node->child1()->shouldSpeculateOther()) {
557                 m_insertionSet.insertNode(m_indexInBlock, SpecNone, Check, node->origin,
558                     Edge(node->child1().node(), OtherUse));
559                 fixEdge<OtherUse>(node->child1());
560                 oneArgumentIsUsedAsSpecOther = true;
561             }
562             if (node->child2()->isUndefinedOrNullConstant()) {
563                 fixEdge<OtherUse>(node->child2());
564                 oneArgumentIsUsedAsSpecOther = true;
565             } else if (node->child2()->shouldSpeculateOther()) {
566                 m_insertionSet.insertNode(m_indexInBlock, SpecNone, Check, node->origin,
567                     Edge(node->child2().node(), OtherUse));
568                 fixEdge<OtherUse>(node->child2());
569                 oneArgumentIsUsedAsSpecOther = true;
570             }
571             if (oneArgumentIsUsedAsSpecOther) {
572                 node->clearFlags(NodeMustGenerate);
573                 break;
574             }
575
576             if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObjectOrOther()) {
577                 fixEdge<ObjectUse>(node->child1());
578                 fixEdge<ObjectOrOtherUse>(node->child2());
579                 node->clearFlags(NodeMustGenerate);
580                 break;
581             }
582             if (node->child1()->shouldSpeculateObjectOrOther() && node->child2()->shouldSpeculateObject()) {
583                 fixEdge<ObjectOrOtherUse>(node->child1());
584                 fixEdge<ObjectUse>(node->child2());
585                 node->clearFlags(NodeMustGenerate);
586                 break;
587             }
588
589             break;
590         }
591             
592         case CompareStrictEq: {
593             if (Node::shouldSpeculateBoolean(node->child1().node(), node->child2().node())) {
594                 fixEdge<BooleanUse>(node->child1());
595                 fixEdge<BooleanUse>(node->child2());
596                 break;
597             }
598             if (Node::shouldSpeculateInt32(node->child1().node(), node->child2().node())) {
599                 fixEdge<Int32Use>(node->child1());
600                 fixEdge<Int32Use>(node->child2());
601                 break;
602             }
603             if (enableInt52()
604                 && Node::shouldSpeculateAnyInt(node->child1().node(), node->child2().node())) {
605                 fixEdge<Int52RepUse>(node->child1());
606                 fixEdge<Int52RepUse>(node->child2());
607                 break;
608             }
609             if (Node::shouldSpeculateNumber(node->child1().node(), node->child2().node())) {
610                 fixEdge<DoubleRepUse>(node->child1());
611                 fixEdge<DoubleRepUse>(node->child2());
612                 break;
613             }
614             if (Node::shouldSpeculateSymbol(node->child1().node(), node->child2().node())) {
615                 fixEdge<SymbolUse>(node->child1());
616                 fixEdge<SymbolUse>(node->child2());
617                 break;
618             }
619             if (node->child1()->shouldSpeculateStringIdent() && node->child2()->shouldSpeculateStringIdent()) {
620                 fixEdge<StringIdentUse>(node->child1());
621                 fixEdge<StringIdentUse>(node->child2());
622                 break;
623             }
624             if (node->child1()->shouldSpeculateString() && node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 7) || isFTL(m_graph.m_plan.mode))) {
625                 fixEdge<StringUse>(node->child1());
626                 fixEdge<StringUse>(node->child2());
627                 break;
628             }
629             WatchpointSet* masqueradesAsUndefinedWatchpoint = m_graph.globalObjectFor(node->origin.semantic)->masqueradesAsUndefinedWatchpoint();
630             if (masqueradesAsUndefinedWatchpoint->isStillValid()) {
631                 
632                 if (node->child1()->shouldSpeculateObject()) {
633                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
634                     fixEdge<ObjectUse>(node->child1());
635                     break;
636                 }
637                 if (node->child2()->shouldSpeculateObject()) {
638                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
639                     fixEdge<ObjectUse>(node->child2());
640                     break;
641                 }
642                 
643             } else if (node->child1()->shouldSpeculateObject() && node->child2()->shouldSpeculateObject()) {
644                 fixEdge<ObjectUse>(node->child1());
645                 fixEdge<ObjectUse>(node->child2());
646                 break;
647             }
648             if (node->child1()->shouldSpeculateSymbol()) {
649                 fixEdge<SymbolUse>(node->child1());
650                 break;
651             }
652             if (node->child2()->shouldSpeculateSymbol()) {
653                 fixEdge<SymbolUse>(node->child2());
654                 break;
655             }
656             if (node->child1()->shouldSpeculateMisc()) {
657                 fixEdge<MiscUse>(node->child1());
658                 break;
659             }
660             if (node->child2()->shouldSpeculateMisc()) {
661                 fixEdge<MiscUse>(node->child2());
662                 break;
663             }
664             if (node->child1()->shouldSpeculateStringIdent()
665                 && node->child2()->shouldSpeculateNotStringVar()) {
666                 fixEdge<StringIdentUse>(node->child1());
667                 fixEdge<NotStringVarUse>(node->child2());
668                 break;
669             }
670             if (node->child2()->shouldSpeculateStringIdent()
671                 && node->child1()->shouldSpeculateNotStringVar()) {
672                 fixEdge<StringIdentUse>(node->child2());
673                 fixEdge<NotStringVarUse>(node->child1());
674                 break;
675             }
676             if (node->child1()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
677                 fixEdge<StringUse>(node->child1());
678                 break;
679             }
680             if (node->child2()->shouldSpeculateString() && ((GPRInfo::numberOfRegisters >= 8) || isFTL(m_graph.m_plan.mode))) {
681                 fixEdge<StringUse>(node->child2());
682                 break;
683             }
684             break;
685         }
686             
687         case StringFromCharCode:
688             if (node->child1()->shouldSpeculateInt32())
689                 fixEdge<Int32Use>(node->child1());
690             else
691                 fixEdge<UntypedUse>(node->child1());
692             break;
693
694         case StringCharAt:
695         case StringCharCodeAt: {
696             // Currently we have no good way of refining these.
697             ASSERT(node->arrayMode() == ArrayMode(Array::String));
698             blessArrayOperation(node->child1(), node->child2(), node->child3());
699             fixEdge<KnownCellUse>(node->child1());
700             fixEdge<Int32Use>(node->child2());
701             break;
702         }
703
704         case GetByVal: {
705             if (!node->prediction()) {
706                 m_insertionSet.insertNode(
707                     m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
708             }
709             
710             node->setArrayMode(
711                 node->arrayMode().refine(
712                     m_graph, node,
713                     m_graph.varArgChild(node, 0)->prediction(),
714                     m_graph.varArgChild(node, 1)->prediction(),
715                     SpecNone));
716             
717             blessArrayOperation(m_graph.varArgChild(node, 0), m_graph.varArgChild(node, 1), m_graph.varArgChild(node, 2));
718             
719             ArrayMode arrayMode = node->arrayMode();
720             switch (arrayMode.type()) {
721             case Array::Contiguous:
722             case Array::Double:
723                 if (arrayMode.arrayClass() == Array::OriginalArray
724                     && arrayMode.speculation() == Array::InBounds) {
725                     // Check if SaneChain will work on a per-type basis. Note that:
726                     //
727                     // 1) We don't want double arrays to sometimes return undefined, since
728                     // that would require a change to the return type and it would pessimise
729                     // things a lot. So, we'd only want to do that if we actually had
730                     // evidence that we could read from a hole. That's pretty annoying.
731                     // Likely the best way to handle that case is with an equivalent of
732                     // SaneChain for OutOfBounds. For now we just detect when Undefined and
733                     // NaN are indistinguishable according to backwards propagation, and just
734                     // use SaneChain in that case. This happens to catch a lot of cases.
735                     //
736                     // 2) We don't want int32 array loads to have to do a hole check just to
737                     // coerce to Undefined, since that would mean twice the checks.
738                     //
739                     // This has two implications. First, we have to do more checks than we'd
740                     // like. It's unfortunate that we have to do the hole check. Second,
741                     // some accesses that hit a hole will now need to take the full-blown
742                     // out-of-bounds slow path. We can fix that with:
743                     // https://bugs.webkit.org/show_bug.cgi?id=144668
744                     
745                     bool canDoSaneChain = false;
746                     switch (arrayMode.type()) {
747                     case Array::Contiguous:
748                         // This is happens to be entirely natural. We already would have
749                         // returned any JSValue, and now we'll return Undefined. We still do
750                         // the check but it doesn't require taking any kind of slow path.
751                         canDoSaneChain = true;
752                         break;
753                         
754                     case Array::Double:
755                         if (!(node->flags() & NodeBytecodeUsesAsOther)) {
756                             // Holes look like NaN already, so if the user doesn't care
757                             // about the difference between Undefined and NaN then we can
758                             // do this.
759                             canDoSaneChain = true;
760                         }
761                         break;
762                         
763                     default:
764                         break;
765                     }
766                     
767                     if (canDoSaneChain) {
768                         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
769                         Structure* arrayPrototypeStructure = globalObject->arrayPrototype()->structure();
770                         Structure* objectPrototypeStructure = globalObject->objectPrototype()->structure();
771                         if (arrayPrototypeStructure->transitionWatchpointSetIsStillValid()
772                             && objectPrototypeStructure->transitionWatchpointSetIsStillValid()
773                             && globalObject->arrayPrototypeChainIsSane()) {
774                             m_graph.registerAndWatchStructureTransition(arrayPrototypeStructure);
775                             m_graph.registerAndWatchStructureTransition(objectPrototypeStructure);
776                             node->setArrayMode(arrayMode.withSpeculation(Array::SaneChain));
777                         }
778                     }
779                 }
780                 break;
781                 
782             case Array::String:
783                 if ((node->prediction() & ~SpecString)
784                     || m_graph.hasExitSite(node->origin.semantic, OutOfBounds))
785                     node->setArrayMode(arrayMode.withSpeculation(Array::OutOfBounds));
786                 break;
787                 
788             default:
789                 break;
790             }
791             
792             arrayMode = node->arrayMode();
793             switch (arrayMode.type()) {
794             case Array::SelectUsingPredictions:
795             case Array::Unprofiled:
796                 RELEASE_ASSERT_NOT_REACHED();
797                 break;
798             case Array::Generic:
799                 if (m_graph.varArgChild(node, 0)->shouldSpeculateObject()) {
800                     if (m_graph.varArgChild(node, 1)->shouldSpeculateString()) {
801                         fixEdge<ObjectUse>(m_graph.varArgChild(node, 0));
802                         fixEdge<StringUse>(m_graph.varArgChild(node, 1));
803                         break;
804                     }
805
806                     if (m_graph.varArgChild(node, 1)->shouldSpeculateSymbol()) {
807                         fixEdge<ObjectUse>(m_graph.varArgChild(node, 0));
808                         fixEdge<SymbolUse>(m_graph.varArgChild(node, 1));
809                         break;
810                     }
811                 }
812 #if USE(JSVALUE32_64)
813                 fixEdge<CellUse>(m_graph.varArgChild(node, 0)); // Speculating cell due to register pressure on 32-bit.
814 #endif
815                 break;
816             case Array::ForceExit:
817                 break;
818             default:
819                 fixEdge<KnownCellUse>(m_graph.varArgChild(node, 0));
820                 fixEdge<Int32Use>(m_graph.varArgChild(node, 1));
821                 break;
822             }
823             
824             switch (arrayMode.type()) {
825             case Array::Double:
826                 if (!arrayMode.isOutOfBounds())
827                     node->setResult(NodeResultDouble);
828                 break;
829                 
830             case Array::Float32Array:
831             case Array::Float64Array:
832                 node->setResult(NodeResultDouble);
833                 break;
834                 
835             case Array::Uint32Array:
836                 if (node->shouldSpeculateInt32())
837                     break;
838                 if (node->shouldSpeculateAnyInt() && enableInt52())
839                     node->setResult(NodeResultInt52);
840                 else
841                     node->setResult(NodeResultDouble);
842                 break;
843                 
844             default:
845                 break;
846             }
847             
848             break;
849         }
850
851         case PutByValDirect:
852         case PutByVal:
853         case PutByValAlias: {
854             Edge& child1 = m_graph.varArgChild(node, 0);
855             Edge& child2 = m_graph.varArgChild(node, 1);
856             Edge& child3 = m_graph.varArgChild(node, 2);
857
858             node->setArrayMode(
859                 node->arrayMode().refine(
860                     m_graph, node,
861                     child1->prediction(),
862                     child2->prediction(),
863                     child3->prediction()));
864             
865             blessArrayOperation(child1, child2, m_graph.varArgChild(node, 3));
866             
867             switch (node->arrayMode().modeForPut().type()) {
868             case Array::SelectUsingPredictions:
869             case Array::SelectUsingArguments:
870             case Array::Unprofiled:
871             case Array::Undecided:
872                 RELEASE_ASSERT_NOT_REACHED();
873                 break;
874             case Array::ForceExit:
875             case Array::Generic:
876                 if (child1->shouldSpeculateCell()) {
877                     if (child2->shouldSpeculateString()) {
878                         fixEdge<CellUse>(child1);
879                         fixEdge<StringUse>(child2);
880                         break;
881                     }
882
883                     if (child2->shouldSpeculateSymbol()) {
884                         fixEdge<CellUse>(child1);
885                         fixEdge<SymbolUse>(child2);
886                         break;
887                     }
888                 }
889 #if USE(JSVALUE32_64)
890                 // Due to register pressure on 32-bit, we speculate cell and
891                 // ignore the base-is-not-cell case entirely by letting the
892                 // baseline JIT handle it.
893                 fixEdge<CellUse>(child1);
894 #endif
895                 break;
896             case Array::Int32:
897                 fixEdge<KnownCellUse>(child1);
898                 fixEdge<Int32Use>(child2);
899                 fixEdge<Int32Use>(child3);
900                 break;
901             case Array::Double:
902                 fixEdge<KnownCellUse>(child1);
903                 fixEdge<Int32Use>(child2);
904                 fixEdge<DoubleRepRealUse>(child3);
905                 break;
906             case Array::Int8Array:
907             case Array::Int16Array:
908             case Array::Int32Array:
909             case Array::Uint8Array:
910             case Array::Uint8ClampedArray:
911             case Array::Uint16Array:
912             case Array::Uint32Array:
913                 fixEdge<KnownCellUse>(child1);
914                 fixEdge<Int32Use>(child2);
915                 if (child3->shouldSpeculateInt32())
916                     fixIntOrBooleanEdge(child3);
917                 else if (child3->shouldSpeculateAnyInt())
918                     fixEdge<Int52RepUse>(child3);
919                 else
920                     fixDoubleOrBooleanEdge(child3);
921                 break;
922             case Array::Float32Array:
923             case Array::Float64Array:
924                 fixEdge<KnownCellUse>(child1);
925                 fixEdge<Int32Use>(child2);
926                 fixDoubleOrBooleanEdge(child3);
927                 break;
928             case Array::Contiguous:
929             case Array::ArrayStorage:
930             case Array::SlowPutArrayStorage:
931                 fixEdge<KnownCellUse>(child1);
932                 fixEdge<Int32Use>(child2);
933                 speculateForBarrier(child3);
934                 break;
935             default:
936                 fixEdge<KnownCellUse>(child1);
937                 fixEdge<Int32Use>(child2);
938                 break;
939             }
940             break;
941         }
942             
943         case AtomicsAdd:
944         case AtomicsAnd:
945         case AtomicsCompareExchange:
946         case AtomicsExchange:
947         case AtomicsLoad:
948         case AtomicsOr:
949         case AtomicsStore:
950         case AtomicsSub:
951         case AtomicsXor: {
952             Edge& base = m_graph.child(node, 0);
953             Edge& index = m_graph.child(node, 1);
954             
955             bool badNews = false;
956             for (unsigned i = numExtraAtomicsArgs(node->op()); i--;) {
957                 Edge& child = m_graph.child(node, 2 + i);
958                 // NOTE: DFG is not smart enough to handle double->int conversions in atomics. So, we
959                 // just call the function when that happens. But the FTL is totally cool with those
960                 // conversions.
961                 if (!child->shouldSpeculateInt32()
962                     && !child->shouldSpeculateAnyInt()
963                     && !(child->shouldSpeculateNumberOrBoolean() && isFTL(m_graph.m_plan.mode)))
964                     badNews = true;
965             }
966             
967             if (badNews) {
968                 node->setArrayMode(ArrayMode(Array::Generic));
969                 break;
970             }
971             
972             node->setArrayMode(
973                 node->arrayMode().refine(
974                     m_graph, node, base->prediction(), index->prediction()));
975             
976             if (node->arrayMode().type() == Array::Generic)
977                 break;
978             
979             for (unsigned i = numExtraAtomicsArgs(node->op()); i--;) {
980                 Edge& child = m_graph.child(node, 2 + i);
981                 if (child->shouldSpeculateInt32())
982                     fixIntOrBooleanEdge(child);
983                 else if (child->shouldSpeculateAnyInt())
984                     fixEdge<Int52RepUse>(child);
985                 else {
986                     RELEASE_ASSERT(child->shouldSpeculateNumberOrBoolean() && isFTL(m_graph.m_plan.mode));
987                     fixDoubleOrBooleanEdge(child);
988                 }
989             }
990             
991             blessArrayOperation(base, index, m_graph.child(node, 2 + numExtraAtomicsArgs(node->op())));
992             fixEdge<CellUse>(base);
993             fixEdge<Int32Use>(index);
994             
995             if (node->arrayMode().type() == Array::Uint32Array) {
996                 // NOTE: This means basically always doing Int52.
997                 if (node->shouldSpeculateAnyInt() && enableInt52())
998                     node->setResult(NodeResultInt52);
999                 else
1000                     node->setResult(NodeResultDouble);
1001             }
1002             break;
1003         }
1004             
1005         case AtomicsIsLockFree:
1006             if (node->child1()->shouldSpeculateInt32())
1007                 fixIntOrBooleanEdge(node->child1());
1008             break;
1009             
1010         case ArrayPush: {
1011             // May need to refine the array mode in case the value prediction contravenes
1012             // the array prediction. For example, we may have evidence showing that the
1013             // array is in Int32 mode, but the value we're storing is likely to be a double.
1014             // Then we should turn this into a conversion to Double array followed by the
1015             // push. On the other hand, we absolutely don't want to refine based on the
1016             // base prediction. If it has non-cell garbage in it, then we want that to be
1017             // ignored. That's because ArrayPush can't handle any array modes that aren't
1018             // array-related - so if refine() turned this into a "Generic" ArrayPush then
1019             // that would break things.
1020             Edge& storageEdge = m_graph.varArgChild(node, 0);
1021             Edge& arrayEdge = m_graph.varArgChild(node, 1);
1022             unsigned elementOffset = 2;
1023             unsigned elementCount = node->numChildren() - elementOffset;
1024             for (unsigned i = 0; i < elementCount; ++i) {
1025                 Edge& element = m_graph.varArgChild(node, i + elementOffset);
1026                 node->setArrayMode(
1027                     node->arrayMode().refine(
1028                         m_graph, node,
1029                         arrayEdge->prediction() & SpecCell,
1030                         SpecInt32Only,
1031                         element->prediction()));
1032             }
1033             blessArrayOperation(arrayEdge, Edge(), storageEdge);
1034             fixEdge<KnownCellUse>(arrayEdge);
1035
1036             // Convert `array.push()` to GetArrayLength.
1037             if (!elementCount && node->arrayMode().supportsSelfLength()) {
1038                 node->setOpAndDefaultFlags(GetArrayLength);
1039                 node->child1() = arrayEdge;
1040                 node->child2() = storageEdge;
1041                 fixEdge<KnownCellUse>(node->child1());
1042                 break;
1043             }
1044
1045             // We do not want to perform osr exit and retry for ArrayPush. We insert Check with appropriate type,
1046             // and ArrayPush uses the edge as known typed edge. Therefore, ArrayPush do not need to perform type checks.
1047             for (unsigned i = 0; i < elementCount; ++i) {
1048                 Edge& element = m_graph.varArgChild(node, i + elementOffset);
1049                 switch (node->arrayMode().type()) {
1050                 case Array::Int32:
1051                     insertCheck<Int32Use>(element.node());
1052                     fixEdge<KnownInt32Use>(element);
1053                     break;
1054                 case Array::Double:
1055                     insertCheck<DoubleRepRealUse>(element.node());
1056                     fixEdge<DoubleRepUse>(element);
1057                     break;
1058                 case Array::Contiguous:
1059                 case Array::ArrayStorage:
1060                     speculateForBarrier(element);
1061                     break;
1062                 default:
1063                     break;
1064                 }
1065                 ASSERT(shouldNotHaveTypeCheck(element.useKind()));
1066             }
1067             break;
1068         }
1069             
1070         case ArrayPop: {
1071             blessArrayOperation(node->child1(), Edge(), node->child2());
1072             fixEdge<KnownCellUse>(node->child1());
1073             break;
1074         }
1075
1076         case ArraySlice: {
1077             fixEdge<KnownCellUse>(m_graph.varArgChild(node, 0));
1078             if (node->numChildren() >= 3) {
1079                 fixEdge<Int32Use>(m_graph.varArgChild(node, 1));
1080                 if (node->numChildren() == 4)
1081                     fixEdge<Int32Use>(m_graph.varArgChild(node, 2));
1082             }
1083             break;
1084         }
1085
1086         case ArrayIndexOf:
1087             fixupArrayIndexOf(node);
1088             break;
1089             
1090         case RegExpExec:
1091         case RegExpTest: {
1092             fixEdge<KnownCellUse>(node->child1());
1093             
1094             if (node->child2()->shouldSpeculateRegExpObject()) {
1095                 fixEdge<RegExpObjectUse>(node->child2());
1096
1097                 if (node->child3()->shouldSpeculateString())
1098                     fixEdge<StringUse>(node->child3());
1099             }
1100             break;
1101         }
1102
1103         case RegExpMatchFast: {
1104             fixEdge<KnownCellUse>(node->child1());
1105             fixEdge<RegExpObjectUse>(node->child2());
1106             fixEdge<StringUse>(node->child3());
1107             break;
1108         }
1109
1110         case StringReplace:
1111         case StringReplaceRegExp: {
1112             if (node->child2()->shouldSpeculateString()) {
1113                 m_insertionSet.insertNode(
1114                     m_indexInBlock, SpecNone, Check, node->origin,
1115                     Edge(node->child2().node(), StringUse));
1116                 fixEdge<StringUse>(node->child2());
1117             } else if (op == StringReplace) {
1118                 if (node->child2()->shouldSpeculateRegExpObject())
1119                     addStringReplacePrimordialChecks(node->child2().node());
1120                 else 
1121                     m_insertionSet.insertNode(
1122                         m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
1123             }
1124
1125             if (node->child1()->shouldSpeculateString()
1126                 && node->child2()->shouldSpeculateRegExpObject()
1127                 && node->child3()->shouldSpeculateString()) {
1128
1129                 fixEdge<StringUse>(node->child1());
1130                 fixEdge<RegExpObjectUse>(node->child2());
1131                 fixEdge<StringUse>(node->child3());
1132                 break;
1133             }
1134             break;
1135         }
1136             
1137         case Branch: {
1138             if (node->child1()->shouldSpeculateBoolean()) {
1139                 if (node->child1()->result() == NodeResultBoolean) {
1140                     // This is necessary in case we have a bytecode instruction implemented by:
1141                     //
1142                     // a: CompareEq(...)
1143                     // b: Branch(@a)
1144                     //
1145                     // In that case, CompareEq might have a side-effect. Then, we need to make
1146                     // sure that we know that Branch does not exit.
1147                     fixEdge<KnownBooleanUse>(node->child1());
1148                 } else
1149                     fixEdge<BooleanUse>(node->child1());
1150             } else if (node->child1()->shouldSpeculateObjectOrOther())
1151                 fixEdge<ObjectOrOtherUse>(node->child1());
1152             else if (node->child1()->shouldSpeculateInt32OrBoolean())
1153                 fixIntOrBooleanEdge(node->child1());
1154             else if (node->child1()->shouldSpeculateNumber())
1155                 fixEdge<DoubleRepUse>(node->child1());
1156             else if (node->child1()->shouldSpeculateString())
1157                 fixEdge<StringUse>(node->child1());
1158             else if (node->child1()->shouldSpeculateStringOrOther())
1159                 fixEdge<StringOrOtherUse>(node->child1());
1160             else {
1161                 WatchpointSet* masqueradesAsUndefinedWatchpoint = m_graph.globalObjectFor(node->origin.semantic)->masqueradesAsUndefinedWatchpoint();
1162                 if (masqueradesAsUndefinedWatchpoint->isStillValid())
1163                     m_graph.watchpoints().addLazily(masqueradesAsUndefinedWatchpoint);
1164             }
1165             break;
1166         }
1167             
1168         case Switch: {
1169             SwitchData* data = node->switchData();
1170             switch (data->kind) {
1171             case SwitchImm:
1172                 if (node->child1()->shouldSpeculateInt32())
1173                     fixEdge<Int32Use>(node->child1());
1174                 break;
1175             case SwitchChar:
1176                 if (node->child1()->shouldSpeculateString())
1177                     fixEdge<StringUse>(node->child1());
1178                 break;
1179             case SwitchString:
1180                 if (node->child1()->shouldSpeculateStringIdent())
1181                     fixEdge<StringIdentUse>(node->child1());
1182                 else if (node->child1()->shouldSpeculateString())
1183                     fixEdge<StringUse>(node->child1());
1184                 break;
1185             case SwitchCell:
1186                 if (node->child1()->shouldSpeculateCell())
1187                     fixEdge<CellUse>(node->child1());
1188                 // else it's fine for this to have UntypedUse; we will handle this by just making
1189                 // non-cells take the default case.
1190                 break;
1191             }
1192             break;
1193         }
1194             
1195         case ToPrimitive: {
1196             fixupToPrimitive(node);
1197             break;
1198         }
1199
1200         case ToNumber: {
1201             fixupToNumber(node);
1202             break;
1203         }
1204             
1205         case ToString:
1206         case CallStringConstructor: {
1207             fixupToStringOrCallStringConstructor(node);
1208             break;
1209         }
1210             
1211         case NewStringObject: {
1212             fixEdge<KnownStringUse>(node->child1());
1213             break;
1214         }
1215
1216         case NewArrayWithSpread: {
1217             watchHavingABadTime(node);
1218             
1219             BitVector* bitVector = node->bitVector();
1220             for (unsigned i = node->numChildren(); i--;) {
1221                 if (bitVector->get(i))
1222                     fixEdge<KnownCellUse>(m_graph.m_varArgChildren[node->firstChild() + i]);
1223                 else
1224                     fixEdge<UntypedUse>(m_graph.m_varArgChildren[node->firstChild() + i]);
1225             }
1226
1227             break;
1228         }
1229
1230         case Spread: {
1231             // Note: We care about performing the protocol on our child's global object, not necessarily ours.
1232             
1233             watchHavingABadTime(node->child1().node());
1234
1235             JSGlobalObject* globalObject = m_graph.globalObjectFor(node->child1()->origin.semantic);
1236             // When we go down the fast path, we don't consult the prototype chain, so we must prove
1237             // that it doesn't contain any indexed properties, and that any holes will result in
1238             // jsUndefined().
1239             Structure* arrayPrototypeStructure = globalObject->arrayPrototype()->structure();
1240             Structure* objectPrototypeStructure = globalObject->objectPrototype()->structure();
1241             if (node->child1()->shouldSpeculateArray()
1242                 && arrayPrototypeStructure->transitionWatchpointSetIsStillValid()
1243                 && objectPrototypeStructure->transitionWatchpointSetIsStillValid()
1244                 && globalObject->arrayPrototypeChainIsSane()
1245                 && m_graph.isWatchingArrayIteratorProtocolWatchpoint(node->child1().node())
1246                 && m_graph.isWatchingHavingABadTimeWatchpoint(node->child1().node())) {
1247                 m_graph.registerAndWatchStructureTransition(objectPrototypeStructure);
1248                 m_graph.registerAndWatchStructureTransition(arrayPrototypeStructure);
1249                 fixEdge<ArrayUse>(node->child1());
1250             } else
1251                 fixEdge<CellUse>(node->child1());
1252             break;
1253         }
1254             
1255         case NewArray: {
1256             watchHavingABadTime(node);
1257             
1258             for (unsigned i = m_graph.varArgNumChildren(node); i--;) {
1259                 node->setIndexingType(
1260                     leastUpperBoundOfIndexingTypeAndType(
1261                         node->indexingType(), m_graph.varArgChild(node, i)->prediction()));
1262             }
1263             switch (node->indexingType()) {
1264             case ALL_BLANK_INDEXING_TYPES:
1265                 CRASH();
1266                 break;
1267             case ALL_UNDECIDED_INDEXING_TYPES:
1268                 if (node->numChildren()) {
1269                     // This will only happen if the children have no type predictions. We
1270                     // would have already exited by now, but insert a forced exit just to
1271                     // be safe.
1272                     m_insertionSet.insertNode(
1273                         m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
1274                 }
1275                 break;
1276             case ALL_INT32_INDEXING_TYPES:
1277                 for (unsigned operandIndex = 0; operandIndex < node->numChildren(); ++operandIndex)
1278                     fixEdge<Int32Use>(m_graph.m_varArgChildren[node->firstChild() + operandIndex]);
1279                 break;
1280             case ALL_DOUBLE_INDEXING_TYPES:
1281                 for (unsigned operandIndex = 0; operandIndex < node->numChildren(); ++operandIndex)
1282                     fixEdge<DoubleRepRealUse>(m_graph.m_varArgChildren[node->firstChild() + operandIndex]);
1283                 break;
1284             case ALL_CONTIGUOUS_INDEXING_TYPES:
1285             case ALL_ARRAY_STORAGE_INDEXING_TYPES:
1286                 break;
1287             default:
1288                 CRASH();
1289                 break;
1290             }
1291             break;
1292         }
1293             
1294         case NewTypedArray: {
1295             watchHavingABadTime(node);
1296             
1297             if (node->child1()->shouldSpeculateInt32()) {
1298                 fixEdge<Int32Use>(node->child1());
1299                 node->clearFlags(NodeMustGenerate);
1300                 break;
1301             }
1302             break;
1303         }
1304             
1305         case NewArrayWithSize: {
1306             watchHavingABadTime(node);
1307             fixEdge<Int32Use>(node->child1());
1308             break;
1309         }
1310
1311         case NewArrayBuffer: {
1312             watchHavingABadTime(node);
1313             break;
1314         }
1315
1316         case ToObject: {
1317             fixupToObject(node);
1318             break;
1319         }
1320
1321         case CallObjectConstructor: {
1322             fixupCallObjectConstructor(node);
1323             break;
1324         }
1325
1326         case ToThis: {
1327             fixupToThis(node);
1328             break;
1329         }
1330             
1331         case PutStructure: {
1332             fixEdge<KnownCellUse>(node->child1());
1333             break;
1334         }
1335             
1336         case GetClosureVar:
1337         case GetFromArguments: {
1338             fixEdge<KnownCellUse>(node->child1());
1339             break;
1340         }
1341
1342         case PutClosureVar:
1343         case PutToArguments: {
1344             fixEdge<KnownCellUse>(node->child1());
1345             speculateForBarrier(node->child2());
1346             break;
1347         }
1348
1349         case SkipScope:
1350         case GetScope:
1351         case GetGetter:
1352         case GetSetter:
1353         case GetGlobalObject: {
1354             fixEdge<KnownCellUse>(node->child1());
1355             break;
1356         }
1357             
1358         case AllocatePropertyStorage:
1359         case ReallocatePropertyStorage: {
1360             fixEdge<KnownCellUse>(node->child1());
1361             break;
1362         }
1363             
1364         case NukeStructureAndSetButterfly: {
1365             fixEdge<KnownCellUse>(node->child1());
1366             break;
1367         }
1368
1369         case TryGetById: {
1370             if (node->child1()->shouldSpeculateCell())
1371                 fixEdge<CellUse>(node->child1());
1372             break;
1373         }
1374
1375         case GetById:
1376         case GetByIdFlush: {
1377             // FIXME: This should be done in the ByteCodeParser based on reading the
1378             // PolymorphicAccess, which will surely tell us that this is a AccessCase::ArrayLength.
1379             // https://bugs.webkit.org/show_bug.cgi?id=154990
1380             auto uid = m_graph.identifiers()[node->identifierNumber()];
1381             if (node->child1()->shouldSpeculateCellOrOther()
1382                 && !m_graph.hasExitSite(node->origin.semantic, BadType)
1383                 && !m_graph.hasExitSite(node->origin.semantic, BadCache)
1384                 && !m_graph.hasExitSite(node->origin.semantic, BadIndexingType)
1385                 && !m_graph.hasExitSite(node->origin.semantic, ExoticObjectMode)) {
1386                 
1387                 if (uid == vm().propertyNames->length.impl()) {
1388                     attemptToMakeGetArrayLength(node);
1389                     break;
1390                 }
1391
1392                 if (uid == vm().propertyNames->lastIndex.impl()
1393                     && node->child1()->shouldSpeculateRegExpObject()) {
1394                     node->setOp(GetRegExpObjectLastIndex);
1395                     node->clearFlags(NodeMustGenerate);
1396                     fixEdge<RegExpObjectUse>(node->child1());
1397                     break;
1398                 }
1399             }
1400
1401             if (node->child1()->shouldSpeculateNumber()) {
1402                 if (uid == vm().propertyNames->toString.impl()) {
1403                     if (m_graph.isWatchingNumberToStringWatchpoint(node)) {
1404                         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
1405                         if (node->child1()->shouldSpeculateInt32()) {
1406                             insertCheck<Int32Use>(node->child1().node());
1407                             m_graph.convertToConstant(node, m_graph.freeze(globalObject->numberProtoToStringFunction()));
1408                             break;
1409                         }
1410
1411                         if (enableInt52() && node->child1()->shouldSpeculateAnyInt()) {
1412                             insertCheck<Int52RepUse>(node->child1().node());
1413                             m_graph.convertToConstant(node, m_graph.freeze(globalObject->numberProtoToStringFunction()));
1414                             break;
1415                         }
1416
1417                         ASSERT(node->child1()->shouldSpeculateNumber());
1418                         insertCheck<DoubleRepUse>(node->child1().node());
1419                         m_graph.convertToConstant(node, m_graph.freeze(globalObject->numberProtoToStringFunction()));
1420                         break;
1421                     }
1422                 }
1423             }
1424
1425             if (node->child1()->shouldSpeculateCell())
1426                 fixEdge<CellUse>(node->child1());
1427             break;
1428         }
1429         
1430         case GetByIdWithThis: {
1431             if (node->child1()->shouldSpeculateCell() && node->child2()->shouldSpeculateCell()) {
1432                 fixEdge<CellUse>(node->child1());
1433                 fixEdge<CellUse>(node->child2());
1434             }
1435             break;
1436         }
1437
1438         case PutById:
1439         case PutByIdFlush:
1440         case PutByIdDirect: {
1441             if (node->child1()->shouldSpeculateCellOrOther()
1442                 && !m_graph.hasExitSite(node->origin.semantic, BadType)
1443                 && !m_graph.hasExitSite(node->origin.semantic, BadCache)
1444                 && !m_graph.hasExitSite(node->origin.semantic, BadIndexingType)
1445                 && !m_graph.hasExitSite(node->origin.semantic, ExoticObjectMode)) {
1446                 
1447                 auto uid = m_graph.identifiers()[node->identifierNumber()];
1448                 
1449                 if (uid == vm().propertyNames->lastIndex.impl()
1450                     && node->child1()->shouldSpeculateRegExpObject()) {
1451                     node->convertToSetRegExpObjectLastIndex();
1452                     fixEdge<RegExpObjectUse>(node->child1());
1453                     speculateForBarrier(node->child2());
1454                     break;
1455                 }
1456             }
1457             
1458             fixEdge<CellUse>(node->child1());
1459             break;
1460         }
1461
1462         case PutGetterById:
1463         case PutSetterById: {
1464             fixEdge<KnownCellUse>(node->child1());
1465             fixEdge<KnownCellUse>(node->child2());
1466             break;
1467         }
1468
1469         case PutGetterSetterById: {
1470             fixEdge<KnownCellUse>(node->child1());
1471             break;
1472         }
1473
1474         case PutGetterByVal:
1475         case PutSetterByVal: {
1476             fixEdge<KnownCellUse>(node->child1());
1477             fixEdge<KnownCellUse>(node->child3());
1478             break;
1479         }
1480
1481         case GetExecutable: {
1482             fixEdge<FunctionUse>(node->child1());
1483             break;
1484         }
1485
1486         case OverridesHasInstance:
1487         case CheckStructure:
1488         case CheckCell:
1489         case CreateThis:
1490         case GetButterfly: {
1491             fixEdge<CellUse>(node->child1());
1492             break;
1493         }
1494
1495         case CheckStringIdent: {
1496             fixEdge<StringIdentUse>(node->child1());
1497             break;
1498         }
1499             
1500         case Arrayify:
1501         case ArrayifyToStructure: {
1502             fixEdge<CellUse>(node->child1());
1503             if (node->child2())
1504                 fixEdge<Int32Use>(node->child2());
1505             break;
1506         }
1507             
1508         case GetByOffset:
1509         case GetGetterSetterByOffset: {
1510             if (!node->child1()->hasStorageResult())
1511                 fixEdge<KnownCellUse>(node->child1());
1512             fixEdge<KnownCellUse>(node->child2());
1513             break;
1514         }
1515             
1516         case MultiGetByOffset: {
1517             fixEdge<CellUse>(node->child1());
1518             break;
1519         }
1520             
1521         case PutByOffset: {
1522             if (!node->child1()->hasStorageResult())
1523                 fixEdge<KnownCellUse>(node->child1());
1524             fixEdge<KnownCellUse>(node->child2());
1525             unsigned index = indexForChecks();
1526             insertInferredTypeCheck(
1527                 m_insertionSet, index, originForCheck(index), node->child3().node(),
1528                 node->storageAccessData().inferredType);
1529             speculateForBarrier(node->child3());
1530             break;
1531         }
1532             
1533         case MultiPutByOffset: {
1534             fixEdge<CellUse>(node->child1());
1535             break;
1536         }
1537             
1538         case InstanceOf: {
1539             if (!(node->child1()->prediction() & ~SpecCell))
1540                 fixEdge<CellUse>(node->child1());
1541             fixEdge<CellUse>(node->child2());
1542             break;
1543         }
1544
1545         case InstanceOfCustom:
1546             fixEdge<CellUse>(node->child2());
1547             break;
1548
1549         case In: {
1550             if (node->child2()->shouldSpeculateInt32()) {
1551                 convertToHasIndexedProperty(node);
1552                 break;
1553             }
1554
1555             fixEdge<CellUse>(node->child1());
1556             break;
1557         }
1558
1559         case HasOwnProperty: {
1560             fixEdge<ObjectUse>(node->child1());
1561 #if (CPU(X86) || CPU(MIPS)) && USE(JSVALUE32_64)
1562             // We don't have enough registers to do anything interesting on x86 and mips.
1563             fixEdge<UntypedUse>(node->child2());
1564 #else
1565             if (node->child2()->shouldSpeculateString())
1566                 fixEdge<StringUse>(node->child2());
1567             else if (node->child2()->shouldSpeculateSymbol())
1568                 fixEdge<SymbolUse>(node->child2());
1569             else
1570                 fixEdge<UntypedUse>(node->child2());
1571 #endif
1572             break;
1573         }
1574
1575         case CheckVarargs:
1576         case Check: {
1577             m_graph.doToChildren(
1578                 node,
1579                 [&] (Edge& edge) {
1580                     switch (edge.useKind()) {
1581                     case NumberUse:
1582                         if (edge->shouldSpeculateInt32ForArithmetic())
1583                             edge.setUseKind(Int32Use);
1584                         break;
1585                     default:
1586                         break;
1587                     }
1588                     observeUseKindOnEdge(edge);
1589                 });
1590             break;
1591         }
1592
1593         case Phantom:
1594             // Phantoms are meaningless past Fixup. We recreate them on-demand in the backend.
1595             node->remove(m_graph);
1596             break;
1597
1598         case FiatInt52: {
1599             RELEASE_ASSERT(enableInt52());
1600             node->convertToIdentity();
1601             fixEdge<Int52RepUse>(node->child1());
1602             node->setResult(NodeResultInt52);
1603             break;
1604         }
1605
1606         case GetArrayLength: {
1607             fixEdge<KnownCellUse>(node->child1());
1608             break;
1609         }
1610
1611         case GetTypedArrayByteOffset: {
1612             fixEdge<KnownCellUse>(node->child1());
1613             break;
1614         }
1615
1616         case CompareBelow:
1617         case CompareBelowEq: {
1618             fixEdge<Int32Use>(node->child1());
1619             fixEdge<Int32Use>(node->child2());
1620             break;
1621         }
1622
1623         case GetPrototypeOf: {
1624             fixupGetPrototypeOf(node);
1625             break;
1626         }
1627
1628         case Phi:
1629         case Upsilon:
1630         case EntrySwitch:
1631         case GetIndexedPropertyStorage:
1632         case LastNodeType:
1633         case CheckTierUpInLoop:
1634         case CheckTierUpAtReturn:
1635         case CheckTierUpAndOSREnter:
1636         case InvalidationPoint:
1637         case CheckArray:
1638         case CheckInBounds:
1639         case ConstantStoragePointer:
1640         case DoubleAsInt32:
1641         case ValueToInt32:
1642         case DoubleRep:
1643         case ValueRep:
1644         case Int52Rep:
1645         case Int52Constant:
1646         case Identity: // This should have been cleaned up.
1647         case BooleanToNumber:
1648         case PhantomNewObject:
1649         case PhantomNewFunction:
1650         case PhantomNewGeneratorFunction:
1651         case PhantomNewAsyncGeneratorFunction:
1652         case PhantomNewAsyncFunction:
1653         case PhantomCreateActivation:
1654         case PhantomDirectArguments:
1655         case PhantomCreateRest:
1656         case PhantomSpread:
1657         case PhantomNewArrayWithSpread:
1658         case PhantomNewArrayBuffer:
1659         case PhantomClonedArguments:
1660         case PhantomNewRegexp:
1661         case GetMyArgumentByVal:
1662         case GetMyArgumentByValOutOfBounds:
1663         case GetVectorLength:
1664         case PutHint:
1665         case CheckStructureImmediate:
1666         case CheckStructureOrEmpty:
1667         case MaterializeNewObject:
1668         case MaterializeCreateActivation:
1669         case PutStack:
1670         case KillStack:
1671         case GetStack:
1672         case StoreBarrier:
1673         case FencedStoreBarrier:
1674         case GetRegExpObjectLastIndex:
1675         case SetRegExpObjectLastIndex:
1676         case RecordRegExpCachedResult:
1677         case RegExpExecNonGlobalOrSticky:
1678         case RegExpMatchFastGlobal:
1679             // These are just nodes that we don't currently expect to see during fixup.
1680             // If we ever wanted to insert them prior to fixup, then we just have to create
1681             // fixup rules for them.
1682             DFG_CRASH(m_graph, node, "Unexpected node during fixup");
1683             break;
1684
1685         case PutGlobalVariable: {
1686             fixEdge<CellUse>(node->child1());
1687             speculateForBarrier(node->child2());
1688             break;
1689         }
1690
1691         case IsObject:
1692             if (node->child1()->shouldSpeculateObject()) {
1693                 m_insertionSet.insertNode(
1694                     m_indexInBlock, SpecNone, Check, node->origin,
1695                     Edge(node->child1().node(), ObjectUse));
1696                 m_graph.convertToConstant(node, jsBoolean(true));
1697                 observeUseKindOnNode<ObjectUse>(node);
1698             }
1699             break;
1700
1701         case IsCellWithType: {
1702             fixupIsCellWithType(node);
1703             break;
1704         }
1705
1706         case GetEnumerableLength: {
1707             fixEdge<CellUse>(node->child1());
1708             break;
1709         }
1710         case HasGenericProperty: {
1711             fixEdge<CellUse>(node->child2());
1712             break;
1713         }
1714         case HasStructureProperty: {
1715             fixEdge<StringUse>(node->child2());
1716             fixEdge<KnownCellUse>(node->child3());
1717             break;
1718         }
1719         case HasIndexedProperty: {
1720             node->setArrayMode(
1721                 node->arrayMode().refine(
1722                     m_graph, node,
1723                     node->child1()->prediction(),
1724                     node->child2()->prediction(),
1725                     SpecNone));
1726             
1727             blessArrayOperation(node->child1(), node->child2(), node->child3());
1728             fixEdge<CellUse>(node->child1());
1729             fixEdge<KnownInt32Use>(node->child2());
1730             break;
1731         }
1732         case GetDirectPname: {
1733             Edge& base = m_graph.varArgChild(node, 0);
1734             Edge& property = m_graph.varArgChild(node, 1);
1735             Edge& index = m_graph.varArgChild(node, 2);
1736             Edge& enumerator = m_graph.varArgChild(node, 3);
1737             fixEdge<CellUse>(base);
1738             fixEdge<KnownCellUse>(property);
1739             fixEdge<KnownInt32Use>(index);
1740             fixEdge<KnownCellUse>(enumerator);
1741             break;
1742         }
1743         case GetPropertyEnumerator: {
1744             if (node->child1()->shouldSpeculateCell())
1745                 fixEdge<CellUse>(node->child1());
1746             break;
1747         }
1748         case GetEnumeratorStructurePname: {
1749             fixEdge<KnownCellUse>(node->child1());
1750             fixEdge<KnownInt32Use>(node->child2());
1751             break;
1752         }
1753         case GetEnumeratorGenericPname: {
1754             fixEdge<KnownCellUse>(node->child1());
1755             fixEdge<KnownInt32Use>(node->child2());
1756             break;
1757         }
1758         case ToIndexString: {
1759             fixEdge<KnownInt32Use>(node->child1());
1760             break;
1761         }
1762         case ProfileType: {
1763             // We want to insert type checks based on the instructionTypeSet of the TypeLocation, not the globalTypeSet.
1764             // Because the instructionTypeSet is contained in globalTypeSet, if we produce a type check for
1765             // type T for the instructionTypeSet, the global type set must also have information for type T.
1766             // So if it the type check succeeds for type T in the instructionTypeSet, a type check for type T 
1767             // in the globalTypeSet would've also succeeded.
1768             // (The other direction does not hold in general).
1769
1770             RefPtr<TypeSet> typeSet = node->typeLocation()->m_instructionTypeSet;
1771             RuntimeTypeMask seenTypes = typeSet->seenTypes();
1772             if (typeSet->doesTypeConformTo(TypeAnyInt)) {
1773                 if (node->child1()->shouldSpeculateInt32()) {
1774                     fixEdge<Int32Use>(node->child1());
1775                     node->remove(m_graph);
1776                     break;
1777                 }
1778
1779                 if (enableInt52()) {
1780                     fixEdge<AnyIntUse>(node->child1());
1781                     node->remove(m_graph);
1782                     break;
1783                 }
1784
1785                 // Must not perform fixEdge<NumberUse> here since the type set only includes TypeAnyInt. Double values should be logged.
1786             }
1787
1788             if (typeSet->doesTypeConformTo(TypeNumber | TypeAnyInt)) {
1789                 fixEdge<NumberUse>(node->child1());
1790                 node->remove(m_graph);
1791             } else if (typeSet->doesTypeConformTo(TypeString)) {
1792                 fixEdge<StringUse>(node->child1());
1793                 node->remove(m_graph);
1794             } else if (typeSet->doesTypeConformTo(TypeBoolean)) {
1795                 fixEdge<BooleanUse>(node->child1());
1796                 node->remove(m_graph);
1797             } else if (typeSet->doesTypeConformTo(TypeUndefined | TypeNull) && (seenTypes & TypeUndefined) && (seenTypes & TypeNull)) {
1798                 fixEdge<OtherUse>(node->child1());
1799                 node->remove(m_graph);
1800             } else if (typeSet->doesTypeConformTo(TypeObject)) {
1801                 StructureSet set;
1802                 {
1803                     ConcurrentJSLocker locker(typeSet->m_lock);
1804                     set = typeSet->structureSet(locker);
1805                 }
1806                 if (!set.isEmpty()) {
1807                     fixEdge<CellUse>(node->child1());
1808                     node->convertToCheckStructure(m_graph.addStructureSet(set));
1809                 }
1810             }
1811
1812             break;
1813         }
1814
1815         case CreateClonedArguments: {
1816             watchHavingABadTime(node);
1817             break;
1818         }
1819
1820         case CreateScopedArguments:
1821         case CreateActivation:
1822         case NewFunction:
1823         case NewGeneratorFunction:
1824         case NewAsyncGeneratorFunction:
1825         case NewAsyncFunction: {
1826             // Child 1 is always the current scope, which is guaranteed to be an object
1827             // FIXME: should be KnownObjectUse once that exists (https://bugs.webkit.org/show_bug.cgi?id=175689)
1828             fixEdge<KnownCellUse>(node->child1());
1829             break;
1830         }
1831
1832         case PushWithScope: {
1833             // Child 1 is always the current scope, which is guaranteed to be an object
1834             // FIXME: should be KnownObjectUse once that exists (https://bugs.webkit.org/show_bug.cgi?id=175689)
1835             fixEdge<KnownCellUse>(node->child1());
1836             if (node->child2()->shouldSpeculateObject())
1837                 fixEdge<ObjectUse>(node->child2());
1838             break;
1839         }
1840
1841         case SetFunctionName: {
1842             // The first child is guaranteed to be a cell because op_set_function_name is only used
1843             // on a newly instantiated function object (the first child).
1844             fixEdge<KnownCellUse>(node->child1());
1845             fixEdge<UntypedUse>(node->child2());
1846             break;
1847         }
1848
1849         case CreateRest: {
1850             watchHavingABadTime(node);
1851             fixEdge<KnownInt32Use>(node->child1());
1852             break;
1853         }
1854
1855         case ResolveScopeForHoistingFuncDeclInEval: {
1856             fixEdge<KnownCellUse>(node->child1());
1857             break;
1858         }
1859         case ResolveScope:
1860         case GetDynamicVar:
1861         case PutDynamicVar: {
1862             fixEdge<KnownCellUse>(node->child1());
1863             break;
1864         }
1865
1866         case LogShadowChickenPrologue: {
1867             fixEdge<KnownCellUse>(node->child1());
1868             break;
1869         }
1870         case LogShadowChickenTail: {
1871             fixEdge<UntypedUse>(node->child1());
1872             fixEdge<KnownCellUse>(node->child2());
1873             break;
1874         }
1875
1876         case GetMapBucket:
1877             if (node->child1().useKind() == MapObjectUse)
1878                 fixEdge<MapObjectUse>(node->child1());
1879             else if (node->child1().useKind() == SetObjectUse)
1880                 fixEdge<SetObjectUse>(node->child1());
1881             else
1882                 RELEASE_ASSERT_NOT_REACHED();
1883
1884 #if USE(JSVALUE64)
1885             if (node->child2()->shouldSpeculateBoolean())
1886                 fixEdge<BooleanUse>(node->child2());
1887             else if (node->child2()->shouldSpeculateInt32())
1888                 fixEdge<Int32Use>(node->child2());
1889             else if (node->child2()->shouldSpeculateSymbol())
1890                 fixEdge<SymbolUse>(node->child2());
1891             else if (node->child2()->shouldSpeculateObject())
1892                 fixEdge<ObjectUse>(node->child2());
1893             else if (node->child2()->shouldSpeculateString())
1894                 fixEdge<StringUse>(node->child2());
1895             else if (node->child2()->shouldSpeculateCell())
1896                 fixEdge<CellUse>(node->child2());
1897             else
1898                 fixEdge<UntypedUse>(node->child2());
1899 #else
1900             fixEdge<UntypedUse>(node->child2());
1901 #endif // USE(JSVALUE64)
1902
1903             fixEdge<Int32Use>(node->child3());
1904             break;
1905
1906         case GetMapBucketHead:
1907             if (node->child1().useKind() == MapObjectUse)
1908                 fixEdge<MapObjectUse>(node->child1());
1909             else if (node->child1().useKind() == SetObjectUse)
1910                 fixEdge<SetObjectUse>(node->child1());
1911             else
1912                 RELEASE_ASSERT_NOT_REACHED();
1913             break;
1914
1915         case GetMapBucketNext:
1916         case LoadKeyFromMapBucket:
1917         case LoadValueFromMapBucket:
1918             fixEdge<CellUse>(node->child1());
1919             break;
1920
1921         case MapHash: {
1922 #if USE(JSVALUE64)
1923             if (node->child1()->shouldSpeculateBoolean()) {
1924                 fixEdge<BooleanUse>(node->child1());
1925                 break;
1926             }
1927
1928             if (node->child1()->shouldSpeculateInt32()) {
1929                 fixEdge<Int32Use>(node->child1());
1930                 break;
1931             }
1932
1933             if (node->child1()->shouldSpeculateSymbol()) {
1934                 fixEdge<SymbolUse>(node->child1());
1935                 break;
1936             }
1937
1938             if (node->child1()->shouldSpeculateObject()) {
1939                 fixEdge<ObjectUse>(node->child1());
1940                 break;
1941             }
1942
1943             if (node->child1()->shouldSpeculateString()) {
1944                 fixEdge<StringUse>(node->child1());
1945                 break;
1946             }
1947
1948             if (node->child1()->shouldSpeculateCell()) {
1949                 fixEdge<CellUse>(node->child1());
1950                 break;
1951             }
1952
1953             fixEdge<UntypedUse>(node->child1());
1954 #else
1955             fixEdge<UntypedUse>(node->child1());
1956 #endif // USE(JSVALUE64)
1957             break;
1958         }
1959
1960         case NormalizeMapKey: {
1961             fixupNormalizeMapKey(node);
1962             break;
1963         }
1964
1965         case WeakMapGet: {
1966             if (node->child1().useKind() == WeakMapObjectUse)
1967                 fixEdge<WeakMapObjectUse>(node->child1());
1968             else if (node->child1().useKind() == WeakSetObjectUse)
1969                 fixEdge<WeakSetObjectUse>(node->child1());
1970             else
1971                 RELEASE_ASSERT_NOT_REACHED();
1972             fixEdge<ObjectUse>(node->child2());
1973             fixEdge<Int32Use>(node->child3());
1974             break;
1975         }
1976
1977         case SetAdd: {
1978             fixEdge<SetObjectUse>(node->child1());
1979             fixEdge<Int32Use>(node->child3());
1980             break;
1981         }
1982
1983         case MapSet: {
1984             fixEdge<MapObjectUse>(m_graph.varArgChild(node, 0));
1985             fixEdge<Int32Use>(m_graph.varArgChild(node, 3));
1986             break;
1987         }
1988
1989         case WeakSetAdd: {
1990             fixEdge<WeakSetObjectUse>(node->child1());
1991             fixEdge<ObjectUse>(node->child2());
1992             fixEdge<Int32Use>(node->child3());
1993             break;
1994         }
1995
1996         case WeakMapSet: {
1997             fixEdge<WeakMapObjectUse>(m_graph.varArgChild(node, 0));
1998             fixEdge<ObjectUse>(m_graph.varArgChild(node, 1));
1999             fixEdge<Int32Use>(m_graph.varArgChild(node, 3));
2000             break;
2001         }
2002
2003         case DefineDataProperty: {
2004             fixEdge<CellUse>(m_graph.varArgChild(node, 0));
2005             Edge& propertyEdge = m_graph.varArgChild(node, 1);
2006             if (propertyEdge->shouldSpeculateSymbol())
2007                 fixEdge<SymbolUse>(propertyEdge);
2008             else if (propertyEdge->shouldSpeculateStringIdent())
2009                 fixEdge<StringIdentUse>(propertyEdge);
2010             else if (propertyEdge->shouldSpeculateString())
2011                 fixEdge<StringUse>(propertyEdge);
2012             else
2013                 fixEdge<UntypedUse>(propertyEdge);
2014             fixEdge<UntypedUse>(m_graph.varArgChild(node, 2));
2015             fixEdge<KnownInt32Use>(m_graph.varArgChild(node, 3));
2016             break;
2017         }
2018
2019         case StringSlice: {
2020             fixEdge<StringUse>(node->child1());
2021             fixEdge<Int32Use>(node->child2());
2022             if (node->child3())
2023                 fixEdge<Int32Use>(node->child3());
2024             break;
2025         }
2026
2027         case ToLowerCase: {
2028             // We currently only support StringUse since that will ensure that
2029             // ToLowerCase is a pure operation. If we decide to update this with
2030             // more types in the future, we need to ensure that the clobberize rules
2031             // are correct.
2032             fixEdge<StringUse>(node->child1());
2033             break;
2034         }
2035
2036         case NumberToStringWithRadix: {
2037             if (node->child1()->shouldSpeculateInt32())
2038                 fixEdge<Int32Use>(node->child1());
2039             else if (enableInt52() && node->child1()->shouldSpeculateAnyInt())
2040                 fixEdge<Int52RepUse>(node->child1());
2041             else
2042                 fixEdge<DoubleRepUse>(node->child1());
2043             fixEdge<Int32Use>(node->child2());
2044             break;
2045         }
2046
2047         case DefineAccessorProperty: {
2048             fixEdge<CellUse>(m_graph.varArgChild(node, 0));
2049             Edge& propertyEdge = m_graph.varArgChild(node, 1);
2050             if (propertyEdge->shouldSpeculateSymbol())
2051                 fixEdge<SymbolUse>(propertyEdge);
2052             else if (propertyEdge->shouldSpeculateStringIdent())
2053                 fixEdge<StringIdentUse>(propertyEdge);
2054             else if (propertyEdge->shouldSpeculateString())
2055                 fixEdge<StringUse>(propertyEdge);
2056             else
2057                 fixEdge<UntypedUse>(propertyEdge);
2058             fixEdge<CellUse>(m_graph.varArgChild(node, 2));
2059             fixEdge<CellUse>(m_graph.varArgChild(node, 3));
2060             fixEdge<KnownInt32Use>(m_graph.varArgChild(node, 4));
2061             break;
2062         }
2063
2064         case CheckSubClass: {
2065             fixupCheckSubClass(node);
2066             break;
2067         }
2068
2069         case CallDOMGetter: {
2070             DOMJIT::CallDOMGetterSnippet* snippet = node->callDOMGetterData()->snippet;
2071             fixEdge<CellUse>(node->child1()); // DOM.
2072             if (snippet && snippet->requireGlobalObject)
2073                 fixEdge<KnownCellUse>(node->child2()); // GlobalObject.
2074             break;
2075         }
2076
2077         case CallDOM: {
2078             fixupCallDOM(node);
2079             break;
2080         }
2081
2082         case Call: {
2083             attemptToMakeCallDOM(node);
2084             break;
2085         }
2086
2087         case ParseInt: {
2088             if (node->child1()->shouldSpeculateInt32() && !node->child2()) {
2089                 fixEdge<Int32Use>(node->child1());
2090                 node->convertToIdentity();
2091                 break;
2092             }
2093
2094             if (node->child1()->shouldSpeculateString()) {
2095                 fixEdge<StringUse>(node->child1());
2096                 node->clearFlags(NodeMustGenerate);
2097             }
2098
2099             if (node->child2())
2100                 fixEdge<Int32Use>(node->child2());
2101
2102             break;
2103         }
2104
2105         case IdentityWithProfile: {
2106             node->clearFlags(NodeMustGenerate);
2107             break;
2108         }
2109
2110         case ThrowStaticError:
2111             fixEdge<StringUse>(node->child1());
2112             break;
2113
2114         case NumberIsInteger:
2115             if (node->child1()->shouldSpeculateInt32()) {
2116                 m_insertionSet.insertNode(
2117                     m_indexInBlock, SpecNone, Check, node->origin,
2118                     Edge(node->child1().node(), Int32Use));
2119                 m_graph.convertToConstant(node, jsBoolean(true));
2120                 break;
2121             }
2122             break;
2123
2124 #if !ASSERT_DISABLED
2125         // Have these no-op cases here to ensure that nobody forgets to add handlers for new opcodes.
2126         case SetArgument:
2127         case JSConstant:
2128         case LazyJSConstant:
2129         case DoubleConstant:
2130         case GetLocal:
2131         case GetCallee:
2132         case GetArgumentCountIncludingThis:
2133         case SetArgumentCountIncludingThis:
2134         case GetRestLength:
2135         case GetArgument:
2136         case Flush:
2137         case PhantomLocal:
2138         case GetGlobalVar:
2139         case GetGlobalLexicalVariable:
2140         case NotifyWrite:
2141         case DirectCall:
2142         case CheckTypeInfoFlags:
2143         case TailCallInlinedCaller:
2144         case DirectTailCallInlinedCaller:
2145         case Construct:
2146         case DirectConstruct:
2147         case CallVarargs:
2148         case CallEval:
2149         case TailCallVarargsInlinedCaller:
2150         case ConstructVarargs:
2151         case CallForwardVarargs:
2152         case ConstructForwardVarargs:
2153         case TailCallForwardVarargs:
2154         case TailCallForwardVarargsInlinedCaller:
2155         case LoadVarargs:
2156         case ForwardVarargs:
2157         case ProfileControlFlow:
2158         case NewObject:
2159         case NewRegexp:
2160         case DeleteById:
2161         case DeleteByVal:
2162         case IsTypedArrayView:
2163         case IsEmpty:
2164         case IsUndefined:
2165         case IsBoolean:
2166         case IsNumber:
2167         case IsObjectOrNull:
2168         case IsFunction:
2169         case CreateDirectArguments:
2170         case Jump:
2171         case Return:
2172         case TailCall:
2173         case DirectTailCall:
2174         case TailCallVarargs:
2175         case Throw:
2176         case CountExecution:
2177         case SuperSamplerBegin:
2178         case SuperSamplerEnd:
2179         case ForceOSRExit:
2180         case CheckBadCell:
2181         case CheckNotEmpty:
2182         case AssertNotEmpty:
2183         case CheckTraps:
2184         case Unreachable:
2185         case ExtractOSREntryLocal:
2186         case ExtractCatchLocal:
2187         case LoopHint:
2188         case MovHint:
2189         case InitializeEntrypointArguments:
2190         case ZombieHint:
2191         case ExitOK:
2192         case BottomValue:
2193         case TypeOf:
2194         case PutByIdWithThis:
2195         case PutByValWithThis:
2196         case GetByValWithThis:
2197         case CompareEqPtr:
2198         case NumberToStringWithValidRadixConstant:
2199         case GetGlobalThis:
2200         case ExtractValueFromWeakMapGet:
2201         case CPUIntrinsic:
2202             break;
2203 #else
2204         default:
2205             break;
2206 #endif
2207         }
2208     }
2209
2210     void watchHavingABadTime(Node* node)
2211     {
2212         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
2213
2214         // If this global object is not having a bad time, watch it. We go down this path anytime the code
2215         // does an array allocation. The types of array allocations may change if we start to have a bad
2216         // time. It's easier to reason about this if we know that whenever the types change after we start
2217         // optimizing, the code just gets thrown out. Doing this at FixupPhase is just early enough, since
2218         // prior to this point nobody should have been doing optimizations based on the indexing type of
2219         // the allocation.
2220         if (!globalObject->isHavingABadTime()) {
2221             m_graph.watchpoints().addLazily(globalObject->havingABadTimeWatchpoint());
2222             m_graph.freeze(globalObject);
2223         }
2224     }
2225     
2226     template<UseKind useKind>
2227     void createToString(Node* node, Edge& edge)
2228     {
2229         Node* toString = m_insertionSet.insertNode(
2230             m_indexInBlock, SpecString, ToString, node->origin,
2231             Edge(edge.node(), useKind));
2232         switch (useKind) {
2233         case Int32Use:
2234         case Int52RepUse:
2235         case DoubleRepUse:
2236         case NotCellUse:
2237             toString->clearFlags(NodeMustGenerate);
2238             break;
2239         default:
2240             break;
2241         }
2242         edge.setNode(toString);
2243     }
2244     
2245     template<UseKind useKind>
2246     void attemptToForceStringArrayModeByToStringConversion(ArrayMode& arrayMode, Node* node)
2247     {
2248         ASSERT(arrayMode == ArrayMode(Array::Generic));
2249         
2250         if (!m_graph.canOptimizeStringObjectAccess(node->origin.semantic))
2251             return;
2252         
2253         createToString<useKind>(node, node->child1());
2254         arrayMode = ArrayMode(Array::String);
2255     }
2256     
2257     template<UseKind useKind>
2258     bool isStringObjectUse()
2259     {
2260         switch (useKind) {
2261         case StringObjectUse:
2262         case StringOrStringObjectUse:
2263             return true;
2264         default:
2265             return false;
2266         }
2267     }
2268     
2269     template<UseKind useKind>
2270     void convertStringAddUse(Node* node, Edge& edge)
2271     {
2272         if (useKind == StringUse) {
2273             observeUseKindOnNode<StringUse>(edge.node());
2274             m_insertionSet.insertNode(
2275                 m_indexInBlock, SpecNone, Check, node->origin,
2276                 Edge(edge.node(), StringUse));
2277             edge.setUseKind(KnownStringUse);
2278             return;
2279         }
2280         
2281         observeUseKindOnNode<useKind>(edge.node());
2282         createToString<useKind>(node, edge);
2283     }
2284     
2285     void convertToMakeRope(Node* node)
2286     {
2287         node->setOpAndDefaultFlags(MakeRope);
2288         fixupMakeRope(node);
2289     }
2290     
2291     void fixupMakeRope(Node* node)
2292     {
2293         for (unsigned i = 0; i < AdjacencyList::Size; ++i) {
2294             Edge& edge = node->children.child(i);
2295             if (!edge)
2296                 break;
2297             edge.setUseKind(KnownStringUse);
2298             JSString* string = edge->dynamicCastConstant<JSString*>(vm());
2299             if (!string)
2300                 continue;
2301             if (string->length())
2302                 continue;
2303             
2304             // Don't allow the MakeRope to have zero children.
2305             if (!i && !node->child2())
2306                 break;
2307             
2308             node->children.removeEdge(i--);
2309         }
2310         
2311         if (!node->child2()) {
2312             ASSERT(!node->child3());
2313             node->convertToIdentity();
2314         }
2315     }
2316
2317     void fixupIsCellWithType(Node* node)
2318     {
2319         switch (node->speculatedTypeForQuery()) {
2320         case SpecString:
2321             if (node->child1()->shouldSpeculateString()) {
2322                 m_insertionSet.insertNode(
2323                     m_indexInBlock, SpecNone, Check, node->origin,
2324                     Edge(node->child1().node(), StringUse));
2325                 m_graph.convertToConstant(node, jsBoolean(true));
2326                 observeUseKindOnNode<StringUse>(node);
2327                 return;
2328             }
2329             break;
2330
2331         case SpecProxyObject:
2332             if (node->child1()->shouldSpeculateProxyObject()) {
2333                 m_insertionSet.insertNode(
2334                     m_indexInBlock, SpecNone, Check, node->origin,
2335                     Edge(node->child1().node(), ProxyObjectUse));
2336                 m_graph.convertToConstant(node, jsBoolean(true));
2337                 observeUseKindOnNode<ProxyObjectUse>(node);
2338                 return;
2339             }
2340             break;
2341
2342         case SpecRegExpObject:
2343             if (node->child1()->shouldSpeculateRegExpObject()) {
2344                 m_insertionSet.insertNode(
2345                     m_indexInBlock, SpecNone, Check, node->origin,
2346                     Edge(node->child1().node(), RegExpObjectUse));
2347                 m_graph.convertToConstant(node, jsBoolean(true));
2348                 observeUseKindOnNode<RegExpObjectUse>(node);
2349                 return;
2350             }
2351             break;
2352
2353         case SpecArray:
2354             if (node->child1()->shouldSpeculateArray()) {
2355                 m_insertionSet.insertNode(
2356                     m_indexInBlock, SpecNone, Check, node->origin,
2357                     Edge(node->child1().node(), ArrayUse));
2358                 m_graph.convertToConstant(node, jsBoolean(true));
2359                 observeUseKindOnNode<ArrayUse>(node);
2360                 return;
2361             }
2362             break;
2363
2364         case SpecDerivedArray:
2365             if (node->child1()->shouldSpeculateDerivedArray()) {
2366                 m_insertionSet.insertNode(
2367                     m_indexInBlock, SpecNone, Check, node->origin,
2368                     Edge(node->child1().node(), DerivedArrayUse));
2369                 m_graph.convertToConstant(node, jsBoolean(true));
2370                 observeUseKindOnNode<DerivedArrayUse>(node);
2371                 return;
2372             }
2373             break;
2374         }
2375
2376         if (node->child1()->shouldSpeculateCell()) {
2377             fixEdge<CellUse>(node->child1());
2378             return;
2379         }
2380
2381         if (node->child1()->shouldSpeculateNotCell()) {
2382             m_insertionSet.insertNode(
2383                 m_indexInBlock, SpecNone, Check, node->origin,
2384                 Edge(node->child1().node(), NotCellUse));
2385             m_graph.convertToConstant(node, jsBoolean(false));
2386             observeUseKindOnNode<NotCellUse>(node);
2387             return;
2388         }
2389     }
2390
2391     void fixupGetPrototypeOf(Node* node)
2392     {
2393         // Reflect.getPrototypeOf only accepts Objects. For Reflect.getPrototypeOf, ByteCodeParser attaches ObjectUse edge filter before fixup phase.
2394         if (node->child1().useKind() != ObjectUse) {
2395             if (node->child1()->shouldSpeculateString()) {
2396                 insertCheck<StringUse>(node->child1().node());
2397                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->stringPrototype()));
2398                 return;
2399             }
2400             if (node->child1()->shouldSpeculateInt32()) {
2401                 insertCheck<Int32Use>(node->child1().node());
2402                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->numberPrototype()));
2403                 return;
2404             }
2405             if (enableInt52() && node->child1()->shouldSpeculateAnyInt()) {
2406                 insertCheck<Int52RepUse>(node->child1().node());
2407                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->numberPrototype()));
2408                 return;
2409             }
2410             if (node->child1()->shouldSpeculateNumber()) {
2411                 insertCheck<NumberUse>(node->child1().node());
2412                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->numberPrototype()));
2413                 return;
2414             }
2415             if (node->child1()->shouldSpeculateSymbol()) {
2416                 insertCheck<SymbolUse>(node->child1().node());
2417                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->symbolPrototype()));
2418                 return;
2419             }
2420             if (node->child1()->shouldSpeculateBoolean()) {
2421                 insertCheck<BooleanUse>(node->child1().node());
2422                 m_graph.convertToConstant(node, m_graph.freeze(m_graph.globalObjectFor(node->origin.semantic)->booleanPrototype()));
2423                 return;
2424             }
2425         }
2426
2427         if (node->child1()->shouldSpeculateFinalObject()) {
2428             fixEdge<FinalObjectUse>(node->child1());
2429             node->clearFlags(NodeMustGenerate);
2430             return;
2431         }
2432         if (node->child1()->shouldSpeculateArray()) {
2433             fixEdge<ArrayUse>(node->child1());
2434             node->clearFlags(NodeMustGenerate);
2435             return;
2436         }
2437         if (node->child1()->shouldSpeculateFunction()) {
2438             fixEdge<FunctionUse>(node->child1());
2439             node->clearFlags(NodeMustGenerate);
2440             return;
2441         }
2442     }
2443
2444     void fixupToThis(Node* node)
2445     {
2446         ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->isStrictMode() ? StrictMode : NotStrictMode;
2447
2448         if (ecmaMode == StrictMode) {
2449             if (node->child1()->shouldSpeculateBoolean()) {
2450                 fixEdge<BooleanUse>(node->child1());
2451                 node->convertToIdentity();
2452                 return;
2453             }
2454
2455             if (node->child1()->shouldSpeculateInt32()) {
2456                 fixEdge<Int32Use>(node->child1());
2457                 node->convertToIdentity();
2458                 return;
2459             }
2460
2461             if (enableInt52() && node->child1()->shouldSpeculateAnyInt()) {
2462                 fixEdge<Int52RepUse>(node->child1());
2463                 node->convertToIdentity();
2464                 node->setResult(NodeResultInt52);
2465                 return;
2466             }
2467
2468             if (node->child1()->shouldSpeculateNumber()) {
2469                 fixEdge<DoubleRepUse>(node->child1());
2470                 node->convertToIdentity();
2471                 node->setResult(NodeResultDouble);
2472                 return;
2473             }
2474
2475             if (node->child1()->shouldSpeculateSymbol()) {
2476                 fixEdge<SymbolUse>(node->child1());
2477                 node->convertToIdentity();
2478                 return;
2479             }
2480
2481             if (node->child1()->shouldSpeculateStringIdent()) {
2482                 fixEdge<StringIdentUse>(node->child1());
2483                 node->convertToIdentity();
2484                 return;
2485             }
2486
2487             if (node->child1()->shouldSpeculateString()) {
2488                 fixEdge<StringUse>(node->child1());
2489                 node->convertToIdentity();
2490                 return;
2491             }
2492         }
2493
2494         if (node->child1()->shouldSpeculateOther()) {
2495             if (ecmaMode == StrictMode) {
2496                 fixEdge<OtherUse>(node->child1());
2497                 node->convertToIdentity();
2498                 return;
2499             }
2500
2501             m_insertionSet.insertNode(
2502                 m_indexInBlock, SpecNone, Check, node->origin,
2503                 Edge(node->child1().node(), OtherUse));
2504             observeUseKindOnNode<OtherUse>(node->child1().node());
2505             m_graph.convertToConstant(
2506                 node, m_graph.globalThisObjectFor(node->origin.semantic));
2507             return;
2508         }
2509
2510         // FIXME: This should cover other use cases but we don't have use kinds for them. It's not critical,
2511         // however, since we cover all the missing cases in constant folding.
2512         // https://bugs.webkit.org/show_bug.cgi?id=157213
2513         if (node->child1()->shouldSpeculateStringObject()) {
2514             fixEdge<StringObjectUse>(node->child1());
2515             node->convertToIdentity();
2516             return;
2517         }
2518
2519         if (isFinalObjectSpeculation(node->child1()->prediction())) {
2520             fixEdge<FinalObjectUse>(node->child1());
2521             node->convertToIdentity();
2522             return;
2523         }
2524     }
2525     
2526     void fixupToPrimitive(Node* node)
2527     {
2528         if (node->child1()->shouldSpeculateInt32()) {
2529             fixEdge<Int32Use>(node->child1());
2530             node->convertToIdentity();
2531             return;
2532         }
2533         
2534         if (node->child1()->shouldSpeculateString()) {
2535             fixEdge<StringUse>(node->child1());
2536             node->convertToIdentity();
2537             return;
2538         }
2539         
2540         if (node->child1()->shouldSpeculateStringObject()
2541             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
2542             fixEdge<StringObjectUse>(node->child1());
2543             node->convertToToString();
2544             return;
2545         }
2546         
2547         if (node->child1()->shouldSpeculateStringOrStringObject()
2548             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
2549             fixEdge<StringOrStringObjectUse>(node->child1());
2550             node->convertToToString();
2551             return;
2552         }
2553     }
2554
2555     void fixupToNumber(Node* node)
2556     {
2557         // If the prediction of the child is Number, we attempt to convert ToNumber to Identity.
2558         if (node->child1()->shouldSpeculateNumber()) {
2559             if (isInt32Speculation(node->getHeapPrediction())) {
2560                 // If the both predictions of this node and the child is Int32, we just convert ToNumber to Identity, that's simple.
2561                 if (node->child1()->shouldSpeculateInt32()) {
2562                     fixEdge<Int32Use>(node->child1());
2563                     node->convertToIdentity();
2564                     return;
2565                 }
2566
2567                 // 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.
2568                 // 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.
2569                 fixEdge<DoubleRepUse>(node->child1());
2570                 node->setOp(DoubleAsInt32);
2571                 if (bytecodeCanIgnoreNegativeZero(node->arithNodeFlags()))
2572                     node->setArithMode(Arith::CheckOverflow);
2573                 else
2574                     node->setArithMode(Arith::CheckOverflowAndNegativeZero);
2575                 return;
2576             }
2577
2578             fixEdge<DoubleRepUse>(node->child1());
2579             node->convertToIdentity();
2580             node->setResult(NodeResultDouble);
2581             return;
2582         }
2583
2584         fixEdge<UntypedUse>(node->child1());
2585         node->setResult(NodeResultJS);
2586     }
2587
2588     void fixupToObject(Node* node)
2589     {
2590         if (node->child1()->shouldSpeculateObject()) {
2591             fixEdge<ObjectUse>(node->child1());
2592             node->convertToIdentity();
2593             return;
2594         }
2595
2596         // ToObject(Null/Undefined) can throw an error. We can emit filters to convert ToObject to CallObjectConstructor.
2597
2598         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
2599
2600         if (node->child1()->shouldSpeculateString()) {
2601             insertCheck<StringUse>(node->child1().node());
2602             fixEdge<KnownStringUse>(node->child1());
2603             node->convertToNewStringObject(m_graph.registerStructure(globalObject->stringObjectStructure()));
2604             return;
2605         }
2606
2607         if (node->child1()->shouldSpeculateSymbol()) {
2608             insertCheck<SymbolUse>(node->child1().node());
2609             node->convertToCallObjectConstructor(m_graph.freeze(globalObject));
2610             return;
2611         }
2612
2613         if (node->child1()->shouldSpeculateNumber()) {
2614             insertCheck<NumberUse>(node->child1().node());
2615             node->convertToCallObjectConstructor(m_graph.freeze(globalObject));
2616             return;
2617         }
2618
2619         if (node->child1()->shouldSpeculateBoolean()) {
2620             insertCheck<BooleanUse>(node->child1().node());
2621             node->convertToCallObjectConstructor(m_graph.freeze(globalObject));
2622             return;
2623         }
2624
2625         fixEdge<UntypedUse>(node->child1());
2626     }
2627
2628     void fixupCallObjectConstructor(Node* node)
2629     {
2630         if (node->child1()->shouldSpeculateObject()) {
2631             fixEdge<ObjectUse>(node->child1());
2632             node->convertToIdentity();
2633             return;
2634         }
2635
2636         if (node->child1()->shouldSpeculateString()) {
2637             auto* globalObject = jsCast<JSGlobalObject*>(node->cellOperand()->cell());
2638             insertCheck<StringUse>(node->child1().node());
2639             fixEdge<KnownStringUse>(node->child1());
2640             node->convertToNewStringObject(m_graph.registerStructure(globalObject->stringObjectStructure()));
2641             return;
2642         }
2643
2644         // While ToObject(Null/Undefined) throws an error, CallObjectConstructor(Null/Undefined) generates a new empty object.
2645         if (node->child1()->shouldSpeculateOther()) {
2646             insertCheck<OtherUse>(node->child1().node());
2647             node->convertToNewObject(m_graph.registerStructure(jsCast<JSGlobalObject*>(node->cellOperand()->cell())->objectStructureForObjectConstructor()));
2648             return;
2649         }
2650
2651         fixEdge<UntypedUse>(node->child1());
2652     }
2653     
2654     void fixupToStringOrCallStringConstructor(Node* node)
2655     {
2656         if (node->child1()->shouldSpeculateString()) {
2657             fixEdge<StringUse>(node->child1());
2658             node->convertToIdentity();
2659             return;
2660         }
2661         
2662         if (node->child1()->shouldSpeculateStringObject()
2663             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
2664             fixEdge<StringObjectUse>(node->child1());
2665             return;
2666         }
2667         
2668         if (node->child1()->shouldSpeculateStringOrStringObject()
2669             && m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
2670             fixEdge<StringOrStringObjectUse>(node->child1());
2671             return;
2672         }
2673         
2674         if (node->child1()->shouldSpeculateCell()) {
2675             fixEdge<CellUse>(node->child1());
2676             return;
2677         }
2678
2679         if (node->child1()->shouldSpeculateInt32()) {
2680             fixEdge<Int32Use>(node->child1());
2681             node->clearFlags(NodeMustGenerate);
2682             return;
2683         }
2684
2685         if (enableInt52() && node->child1()->shouldSpeculateAnyInt()) {
2686             fixEdge<Int52RepUse>(node->child1());
2687             node->clearFlags(NodeMustGenerate);
2688             return;
2689         }
2690
2691         if (node->child1()->shouldSpeculateNumber()) {
2692             fixEdge<DoubleRepUse>(node->child1());
2693             node->clearFlags(NodeMustGenerate);
2694             return;
2695         }
2696
2697         // ToString(Symbol) throws an error. So if the child1 can include Symbols,
2698         // we need to care about it in the clobberize. In the following case,
2699         // since NotCellUse edge filter is used and this edge filters Symbols,
2700         // we can say that ToString never throws an error!
2701         if (node->child1()->shouldSpeculateNotCell()) {
2702             fixEdge<NotCellUse>(node->child1());
2703             node->clearFlags(NodeMustGenerate);
2704             return;
2705         }
2706     }
2707
2708     bool attemptToMakeFastStringAdd(Node* node)
2709     {
2710         bool goodToGo = true;
2711         m_graph.doToChildren(
2712             node,
2713             [&] (Edge& edge) {
2714                 if (edge->shouldSpeculateString())
2715                     return;
2716                 if (m_graph.canOptimizeStringObjectAccess(node->origin.semantic)) {
2717                     if (edge->shouldSpeculateStringObject())
2718                         return;
2719                     if (edge->shouldSpeculateStringOrStringObject())
2720                         return;
2721                 }
2722                 goodToGo = false;
2723             });
2724         if (!goodToGo)
2725             return false;
2726
2727         m_graph.doToChildren(
2728             node,
2729             [&] (Edge& edge) {
2730                 if (edge->shouldSpeculateString()) {
2731                     convertStringAddUse<StringUse>(node, edge);
2732                     return;
2733                 }
2734                 ASSERT(m_graph.canOptimizeStringObjectAccess(node->origin.semantic));
2735                 if (edge->shouldSpeculateStringObject()) {
2736                     convertStringAddUse<StringObjectUse>(node, edge);
2737                     return;
2738                 }
2739                 if (edge->shouldSpeculateStringOrStringObject()) {
2740                     convertStringAddUse<StringOrStringObjectUse>(node, edge);
2741                     return;
2742                 }
2743                 RELEASE_ASSERT_NOT_REACHED();
2744             });
2745         
2746         convertToMakeRope(node);
2747         return true;
2748     }
2749
2750     void fixupGetAndSetLocalsInBlock(BasicBlock* block)
2751     {
2752         if (!block)
2753             return;
2754         ASSERT(block->isReachable);
2755         m_block = block;
2756         for (m_indexInBlock = 0; m_indexInBlock < block->size(); ++m_indexInBlock) {
2757             Node* node = m_currentNode = block->at(m_indexInBlock);
2758             if (node->op() != SetLocal && node->op() != GetLocal)
2759                 continue;
2760             
2761             VariableAccessData* variable = node->variableAccessData();
2762             switch (node->op()) {
2763             case GetLocal:
2764                 switch (variable->flushFormat()) {
2765                 case FlushedDouble:
2766                     node->setResult(NodeResultDouble);
2767                     break;
2768                 case FlushedInt52:
2769                     node->setResult(NodeResultInt52);
2770                     break;
2771                 default:
2772                     break;
2773                 }
2774                 break;
2775                 
2776             case SetLocal:
2777                 // NOTE: Any type checks we put here may get hoisted by fixupChecksInBlock(). So, if we
2778                 // add new type checking use kind for SetLocals, we need to modify that code as well.
2779                 
2780                 switch (variable->flushFormat()) {
2781                 case FlushedJSValue:
2782                     break;
2783                 case FlushedDouble:
2784                     fixEdge<DoubleRepUse>(node->child1());
2785                     break;
2786                 case FlushedInt32:
2787                     fixEdge<Int32Use>(node->child1());
2788                     break;
2789                 case FlushedInt52:
2790                     fixEdge<Int52RepUse>(node->child1());
2791                     break;
2792                 case FlushedCell:
2793                     fixEdge<CellUse>(node->child1());
2794                     break;
2795                 case FlushedBoolean:
2796                     fixEdge<BooleanUse>(node->child1());
2797                     break;
2798                 default:
2799                     RELEASE_ASSERT_NOT_REACHED();
2800                     break;
2801                 }
2802                 break;
2803                 
2804             default:
2805                 RELEASE_ASSERT_NOT_REACHED();
2806                 break;
2807             }
2808         }
2809         m_insertionSet.execute(block);
2810     }
2811     
2812     void addStringReplacePrimordialChecks(Node* searchRegExp)
2813     {
2814         Node* node = m_currentNode;
2815
2816         // Check that structure of searchRegExp is RegExp object
2817         m_insertionSet.insertNode(
2818             m_indexInBlock, SpecNone, Check, node->origin,
2819             Edge(searchRegExp, RegExpObjectUse));
2820
2821         auto emitPrimordialCheckFor = [&] (JSValue primordialProperty, UniquedStringImpl* propertyUID) {
2822             unsigned index = m_graph.identifiers().ensure(propertyUID);
2823
2824             Node* actualProperty = m_insertionSet.insertNode(
2825                 m_indexInBlock, SpecNone, TryGetById, node->origin,
2826                 OpInfo(index), OpInfo(SpecFunction), Edge(searchRegExp, CellUse));
2827
2828             m_insertionSet.insertNode(
2829                 m_indexInBlock, SpecNone, CheckCell, node->origin,
2830                 OpInfo(m_graph.freeze(primordialProperty)), Edge(actualProperty, CellUse));
2831         };
2832
2833         JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
2834
2835         // Check that searchRegExp.exec is the primordial RegExp.prototype.exec
2836         emitPrimordialCheckFor(globalObject->regExpProtoExecFunction(), vm().propertyNames->exec.impl());
2837         // Check that searchRegExp.global is the primordial RegExp.prototype.global
2838         emitPrimordialCheckFor(globalObject->regExpProtoGlobalGetter(), vm().propertyNames->global.impl());
2839         // Check that searchRegExp.unicode is the primordial RegExp.prototype.unicode
2840         emitPrimordialCheckFor(globalObject->regExpProtoUnicodeGetter(), vm().propertyNames->unicode.impl());
2841         // Check that searchRegExp[Symbol.match] is the primordial RegExp.prototype[Symbol.replace]
2842         emitPrimordialCheckFor(globalObject->regExpProtoSymbolReplaceFunction(), vm().propertyNames->replaceSymbol.impl());
2843     }
2844
2845     Node* checkArray(ArrayMode arrayMode, const NodeOrigin& origin, Node* array, Node* index, bool (*storageCheck)(const ArrayMode&) = canCSEStorage)
2846     {
2847         ASSERT(arrayMode.isSpecific());
2848         
2849         if (arrayMode.type() == Array::String) {
2850             m_insertionSet.insertNode(
2851                 m_indexInBlock, SpecNone, Check, origin, Edge(array, StringUse));
2852         } else {
2853             // Note that we only need to be using a structure check if we opt for SaneChain, since
2854             // that needs to protect against JSArray's __proto__ being changed.
2855             Structure* structure = arrayMode.originalArrayStructure(m_graph, origin.semantic);
2856         
2857             Edge indexEdge = index ? Edge(index, Int32Use) : Edge();
2858             
2859             if (arrayMode.doesConversion()) {
2860                 if (structure) {
2861                     m_insertionSet.insertNode(
2862                         m_indexInBlock, SpecNone, ArrayifyToStructure, origin,
2863                         OpInfo(m_graph.registerStructure(structure)), OpInfo(arrayMode.asWord()), Edge(array, CellUse), indexEdge);
2864                 } else {
2865                     m_insertionSet.insertNode(
2866                         m_indexInBlock, SpecNone, Arrayify, origin,
2867                         OpInfo(arrayMode.asWord()), Edge(array, CellUse), indexEdge);
2868                 }
2869             } else {
2870                 if (structure) {
2871                     m_insertionSet.insertNode(
2872                         m_indexInBlock, SpecNone, CheckStructure, origin,
2873                         OpInfo(m_graph.addStructureSet(structure)), Edge(array, CellUse));
2874                 } else {
2875                     m_insertionSet.insertNode(
2876                         m_indexInBlock, SpecNone, CheckArray, origin,
2877                         OpInfo(arrayMode.asWord()), Edge(array, CellUse));
2878                 }
2879             }
2880         }
2881         
2882         if (!storageCheck(arrayMode))
2883             return nullptr;
2884         
2885         if (arrayMode.usesButterfly()) {
2886             return m_insertionSet.insertNode(
2887                 m_indexInBlock, SpecNone, GetButterfly, origin, Edge(array, CellUse));
2888         }
2889         
2890         return m_insertionSet.insertNode(
2891             m_indexInBlock, SpecNone, GetIndexedPropertyStorage, origin,
2892             OpInfo(arrayMode.asWord()), Edge(array, KnownCellUse));
2893     }
2894     
2895     void blessArrayOperation(Edge base, Edge index, Edge& storageChild)
2896     {
2897         Node* node = m_currentNode;
2898         
2899         switch (node->arrayMode().type()) {
2900         case Array::ForceExit: {
2901             m_insertionSet.insertNode(
2902                 m_indexInBlock, SpecNone, ForceOSRExit, node->origin);
2903             return;
2904         }
2905             
2906         case Array::SelectUsingPredictions:
2907         case Array::Unprofiled:
2908             RELEASE_ASSERT_NOT_REACHED();
2909             return;
2910             
2911         case Array::Generic:
2912             return;
2913             
2914         default: {
2915             Node* storage = checkArray(node->arrayMode(), node->origin, base.node(), index.node());
2916             if (!storage)
2917                 return;
2918             
2919             storageChild = Edge(storage);
2920             return;
2921         } }
2922     }
2923     
2924     bool alwaysUnboxSimplePrimitives()
2925     {
2926 #if USE(JSVALUE64)
2927         return false;
2928 #else
2929         // Any boolean, int, or cell value is profitable to unbox on 32-bit because it
2930         // reduces traffic.
2931         return true;
2932 #endif
2933     }
2934
2935     template<UseKind useKind>
2936     void observeUseKindOnNode(Node* node)
2937     {
2938         if (useKind == UntypedUse)
2939             return;
2940         observeUseKindOnNode(node, useKind);
2941     }
2942
2943     void observeUseKindOnEdge(Edge edge)
2944     {
2945         observeUseKindOnNode(edge.node(), edge.useKind());
2946     }
2947
2948     void observeUseKindOnNode(Node* node, UseKind useKind)
2949     {
2950         if (node->op() != GetLocal)
2951             return;
2952         
2953         // FIXME: The way this uses alwaysUnboxSimplePrimitives() is suspicious.
2954         // https://bugs.webkit.org/show_bug.cgi?id=121518
2955         
2956         VariableAccessData* variable = node->variableAccessData();
2957         switch (useKind) {
2958         case Int32Use:
2959         case KnownInt32Use:
2960             if (alwaysUnboxSimplePrimitives()
2961                 || isInt32Speculation(variable->prediction()))
2962                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2963             break;
2964         case NumberUse:
2965         case RealNumberUse:
2966         case DoubleRepUse:
2967         case DoubleRepRealUse:
2968             if (variable->doubleFormatState() == UsingDoubleFormat)
2969                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2970             break;
2971         case BooleanUse:
2972         case KnownBooleanUse:
2973             if (alwaysUnboxSimplePrimitives()
2974                 || isBooleanSpeculation(variable->prediction()))
2975                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2976             break;
2977         case Int52RepUse:
2978             if (isAnyIntSpeculation(variable->prediction()))
2979                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2980             break;
2981         case CellUse:
2982         case KnownCellUse:
2983         case ObjectUse:
2984         case FunctionUse:
2985         case StringUse:
2986         case KnownStringUse:
2987         case SymbolUse:
2988         case StringObjectUse:
2989         case StringOrStringObjectUse:
2990             if (alwaysUnboxSimplePrimitives()
2991                 || isCellSpeculation(variable->prediction()))
2992                 m_profitabilityChanged |= variable->mergeIsProfitableToUnbox(true);
2993             break;
2994         default:
2995             break;
2996         }
2997     }
2998     
2999     template<UseKind useKind>
3000     void fixEdge(Edge& edge)
3001     {
3002         observeUseKindOnNode<useKind>(edge.node());
3003         edge.setUseKind(useKind);
3004     }
3005     
3006     unsigned indexForChecks()
3007     {
3008         unsigned index = m_indexInBlock;
3009         while (!m_block->at(index)->origin.exitOK)
3010             index--;
3011         return index;
3012     }
3013     
3014     NodeOrigin originForCheck(unsigned index)
3015     {
3016         return m_block->at(index)->origin.withSemantic(m_currentNode->origin.semantic);
3017     }
3018     
3019     void speculateForBarrier(Edge value)
3020     {
3021         // Currently, the DFG won't take advantage of this speculation. But, we want to do it in
3022         // the DFG anyway because if such a speculation would be wrong, we want to know before
3023         // we do an expensive compile.
3024         
3025         if (value->shouldSpeculateInt32()) {
3026             insertCheck<Int32Use>(value.node());
3027             return;
3028         }
3029             
3030         if (value->shouldSpeculateBoolean()) {
3031             insertCheck<BooleanUse>(value.node());
3032             return;
3033         }
3034             
3035         if (value->shouldSpeculateOther()) {
3036             insertCheck<OtherUse>(value.node());
3037             return;
3038         }
3039             
3040         if (value->shouldSpeculateNumber()) {
3041             insertCheck<NumberUse>(value.node());
3042             return;
3043         }
3044             
3045         if (value->shouldSpeculateNotCell()) {
3046             insertCheck<NotCellUse>(value.node());
3047             return;
3048         }
3049     }
3050     
3051     template<UseKind useKind>
3052     void insertCheck(Node* node)
3053     {
3054         observeUseKindOnNode<useKind>(node);
3055         unsigned index = indexForChecks();
3056         m_insertionSet.insertNode(index, SpecNone, Check, originForCheck(index), Edge(node, useKind));
3057     }
3058
3059     void fixIntConvertingEdge(Edge& edge)
3060     {
3061         Node* node = edge.node();
3062         if (node->shouldSpeculateInt32OrBoolean()) {
3063             fixIntOrBooleanEdge(edge);
3064             return;
3065         }
3066         
3067         UseKind useKind;
3068         if (node->shouldSpeculateAnyInt())
3069             useKind = Int52RepUse;
3070         else if (node->shouldSpeculateNumber())