22f9ccc073d1eff57c0615a3f0674aab0292d21f
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGAbstractInterpreterInlines.h
1 /*
2  * Copyright (C) 2013-2015 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 #ifndef DFGAbstractInterpreterInlines_h
27 #define DFGAbstractInterpreterInlines_h
28
29 #if ENABLE(DFG_JIT)
30
31 #include "DFGAbstractInterpreter.h"
32 #include "GetByIdStatus.h"
33 #include "GetterSetter.h"
34 #include "JITOperations.h"
35 #include "MathCommon.h"
36 #include "Operations.h"
37 #include "PutByIdStatus.h"
38 #include "StringObject.h"
39
40 namespace JSC { namespace DFG {
41
42 template<typename AbstractStateType>
43 AbstractInterpreter<AbstractStateType>::AbstractInterpreter(Graph& graph, AbstractStateType& state)
44     : m_codeBlock(graph.m_codeBlock)
45     , m_graph(graph)
46     , m_state(state)
47 {
48     if (m_graph.m_form == SSA)
49         m_phiChildren = std::make_unique<PhiChildren>(m_graph);
50 }
51
52 template<typename AbstractStateType>
53 AbstractInterpreter<AbstractStateType>::~AbstractInterpreter()
54 {
55 }
56
57 template<typename AbstractStateType>
58 typename AbstractInterpreter<AbstractStateType>::BooleanResult
59 AbstractInterpreter<AbstractStateType>::booleanResult(
60     Node* node, AbstractValue& value)
61 {
62     JSValue childConst = value.value();
63     if (childConst) {
64         if (childConst.toBoolean(m_codeBlock->globalObjectFor(node->origin.semantic)->globalExec()))
65             return DefinitelyTrue;
66         return DefinitelyFalse;
67     }
68
69     // Next check if we can fold because we know that the source is an object or string and does not equal undefined.
70     if (isCellSpeculation(value.m_type) && !value.m_structure.isTop()) {
71         bool allTrue = true;
72         for (unsigned i = value.m_structure.size(); i--;) {
73             Structure* structure = value.m_structure[i];
74             if (structure->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
75                 || structure->typeInfo().type() == StringType) {
76                 allTrue = false;
77                 break;
78             }
79         }
80         if (allTrue)
81             return DefinitelyTrue;
82     }
83     
84     return UnknownBooleanResult;
85 }
86
87 template<typename AbstractStateType>
88 void AbstractInterpreter<AbstractStateType>::startExecuting()
89 {
90     ASSERT(m_state.block());
91     ASSERT(m_state.isValid());
92     
93     m_state.setDidClobber(false);
94 }
95
96 template<typename AbstractStateType>
97 void AbstractInterpreter<AbstractStateType>::executeEdges(Node* node)
98 {
99     DFG_NODE_DO_TO_CHILDREN(m_graph, node, filterEdgeByUse);
100 }
101
102 template<typename AbstractStateType>
103 void AbstractInterpreter<AbstractStateType>::executeEdges(unsigned indexInBlock)
104 {
105     executeEdges(m_state.block()->at(indexInBlock));
106 }
107
108 template<typename AbstractStateType>
109 void AbstractInterpreter<AbstractStateType>::verifyEdge(Node* node, Edge edge)
110 {
111     if (!(forNode(edge).m_type & ~typeFilterFor(edge.useKind())))
112         return;
113     
114     DFG_CRASH(m_graph, node, toCString("Edge verification error: ", node, "->", edge, " was expected to have type ", SpeculationDump(typeFilterFor(edge.useKind())), " but has type ", SpeculationDump(forNode(edge).m_type), " (", forNode(edge).m_type, ")").data());
115 }
116
117 template<typename AbstractStateType>
118 void AbstractInterpreter<AbstractStateType>::verifyEdges(Node* node)
119 {
120     DFG_NODE_DO_TO_CHILDREN(m_graph, node, verifyEdge);
121 }
122
123 template<typename AbstractStateType>
124 bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimit, Node* node)
125 {
126     if (!ASSERT_DISABLED)
127         verifyEdges(node);
128     
129     m_state.createValueForNode(node);
130     
131     switch (node->op()) {
132     case JSConstant:
133     case DoubleConstant:
134     case Int52Constant: {
135         setBuiltInConstant(node, *node->constant());
136         break;
137     }
138         
139     case Identity: {
140         forNode(node) = forNode(node->child1());
141         if (forNode(node).value())
142             m_state.setFoundConstants(true);
143         break;
144     }
145         
146     case ExtractOSREntryLocal: {
147         forNode(node).makeBytecodeTop();
148         break;
149     }
150             
151     case GetLocal: {
152         VariableAccessData* variableAccessData = node->variableAccessData();
153         AbstractValue value = m_state.variables().operand(variableAccessData->local().offset());
154         // The value in the local should already be checked.
155         DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(variableAccessData->flushFormat())));
156         if (value.value())
157             m_state.setFoundConstants(true);
158         forNode(node) = value;
159         break;
160     }
161         
162     case GetStack: {
163         StackAccessData* data = node->stackAccessData();
164         AbstractValue value = m_state.variables().operand(data->local);
165         // The value in the local should already be checked.
166         DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(data->format)));
167         if (value.value())
168             m_state.setFoundConstants(true);
169         forNode(node) = value;
170         break;
171     }
172         
173     case GetLocalUnlinked: {
174         AbstractValue value = m_state.variables().operand(node->unlinkedLocal().offset());
175         if (value.value())
176             m_state.setFoundConstants(true);
177         forNode(node) = value;
178         break;
179     }
180         
181     case SetLocal: {
182         m_state.variables().operand(node->local()) = forNode(node->child1());
183         break;
184     }
185         
186     case PutStack: {
187         m_state.variables().operand(node->stackAccessData()->local) = forNode(node->child1());
188         break;
189     }
190         
191     case MovHint: {
192         // Don't need to do anything. A MovHint only informs us about what would have happened
193         // in bytecode, but this code is just concerned with what is actually happening during
194         // DFG execution.
195         break;
196     }
197         
198     case KillStack: {
199         // This is just a hint telling us that the OSR state of the local is no longer inside the
200         // flushed data.
201         break;
202     }
203         
204     case SetArgument:
205         // Assert that the state of arguments has been set. SetArgument means that someone set
206         // the argument values out-of-band, and currently this always means setting to a
207         // non-clear value.
208         ASSERT(!m_state.variables().operand(node->local()).isClear());
209         break;
210         
211     case LoadVarargs:
212     case ForwardVarargs: {
213         // FIXME: ForwardVarargs should check if the count becomes known, and if it does, it should turn
214         // itself into a straight-line sequence of GetStack/PutStack.
215         // https://bugs.webkit.org/show_bug.cgi?id=143071
216         clobberWorld(node->origin.semantic, clobberLimit);
217         LoadVarargsData* data = node->loadVarargsData();
218         m_state.variables().operand(data->count).setType(SpecInt32);
219         for (unsigned i = data->limit - 1; i--;)
220             m_state.variables().operand(data->start.offset() + i).makeHeapTop();
221         break;
222     }
223             
224     case BitAnd:
225     case BitOr:
226     case BitXor:
227     case BitRShift:
228     case BitLShift:
229     case BitURShift: {
230         JSValue left = forNode(node->child1()).value();
231         JSValue right = forNode(node->child2()).value();
232         if (left && right && left.isInt32() && right.isInt32()) {
233             int32_t a = left.asInt32();
234             int32_t b = right.asInt32();
235             switch (node->op()) {
236             case BitAnd:
237                 setConstant(node, JSValue(a & b));
238                 break;
239             case BitOr:
240                 setConstant(node, JSValue(a | b));
241                 break;
242             case BitXor:
243                 setConstant(node, JSValue(a ^ b));
244                 break;
245             case BitRShift:
246                 setConstant(node, JSValue(a >> static_cast<uint32_t>(b)));
247                 break;
248             case BitLShift:
249                 setConstant(node, JSValue(a << static_cast<uint32_t>(b)));
250                 break;
251             case BitURShift:
252                 setConstant(node, JSValue(static_cast<uint32_t>(a) >> static_cast<uint32_t>(b)));
253                 break;
254             default:
255                 RELEASE_ASSERT_NOT_REACHED();
256                 break;
257             }
258             break;
259         }
260         forNode(node).setType(SpecInt32);
261         break;
262     }
263         
264     case UInt32ToNumber: {
265         JSValue child = forNode(node->child1()).value();
266         if (doesOverflow(node->arithMode())) {
267             if (child && child.isInt32()) {
268                 uint32_t value = child.asInt32();
269                 setConstant(node, jsNumber(value));
270                 break;
271             }
272             forNode(node).setType(SpecInt52AsDouble);
273             break;
274         }
275         if (child && child.isInt32()) {
276             int32_t value = child.asInt32();
277             if (value >= 0) {
278                 setConstant(node, jsNumber(value));
279                 break;
280             }
281         }
282         forNode(node).setType(SpecInt32);
283         break;
284     }
285         
286     case BooleanToNumber: {
287         JSValue concreteValue = forNode(node->child1()).value();
288         if (concreteValue) {
289             if (concreteValue.isBoolean())
290                 setConstant(node, jsNumber(concreteValue.asBoolean()));
291             else
292                 setConstant(node, *m_graph.freeze(concreteValue));
293             break;
294         }
295         AbstractValue& value = forNode(node);
296         value = forNode(node->child1());
297         if (node->child1().useKind() == UntypedUse && !(value.m_type & ~SpecBoolean))
298             m_state.setFoundConstants(true);
299         if (value.m_type & SpecBoolean) {
300             value.merge(SpecInt32);
301             value.filter(~SpecBoolean);
302         }
303         break;
304     }
305             
306     case DoubleAsInt32: {
307         JSValue child = forNode(node->child1()).value();
308         if (child && child.isNumber()) {
309             double asDouble = child.asNumber();
310             int32_t asInt = JSC::toInt32(asDouble);
311             if (bitwise_cast<int64_t>(static_cast<double>(asInt)) == bitwise_cast<int64_t>(asDouble)) {
312                 setConstant(node, JSValue(asInt));
313                 break;
314             }
315         }
316         forNode(node).setType(SpecInt32);
317         break;
318     }
319             
320     case ValueToInt32: {
321         JSValue child = forNode(node->child1()).value();
322         if (child) {
323             if (child.isNumber()) {
324                 if (child.isInt32())
325                     setConstant(node, child);
326                 else
327                     setConstant(node, JSValue(JSC::toInt32(child.asDouble())));
328                 break;
329             }
330             if (child.isBoolean()) {
331                 setConstant(node, jsNumber(child.asBoolean()));
332                 break;
333             }
334             if (child.isUndefinedOrNull()) {
335                 setConstant(node, jsNumber(0));
336                 break;
337             }
338         }
339         
340         forNode(node).setType(SpecInt32);
341         break;
342     }
343         
344     case DoubleRep: {
345         JSValue child = forNode(node->child1()).value();
346         if (child && child.isNumber()) {
347             setConstant(node, jsDoubleNumber(child.asNumber()));
348             break;
349         }
350         forNode(node).setType(m_graph, forNode(node->child1()).m_type);
351         forNode(node).fixTypeForRepresentation(node);
352         break;
353     }
354         
355     case Int52Rep: {
356         JSValue child = forNode(node->child1()).value();
357         if (child && child.isMachineInt()) {
358             setConstant(node, child);
359             break;
360         }
361         
362         forNode(node).setType(SpecInt32);
363         break;
364     }
365         
366     case ValueRep: {
367         JSValue value = forNode(node->child1()).value();
368         if (value) {
369             setConstant(node, value);
370             break;
371         }
372         
373         forNode(node).setType(m_graph, forNode(node->child1()).m_type & ~SpecDoubleImpureNaN);
374         forNode(node).fixTypeForRepresentation(node);
375         break;
376     }
377         
378     case ValueAdd: {
379         ASSERT(node->binaryUseKind() == UntypedUse);
380         clobberWorld(node->origin.semantic, clobberLimit);
381         forNode(node).setType(m_graph, SpecString | SpecBytecodeNumber);
382         break;
383     }
384         
385     case ArithAdd: {
386         JSValue left = forNode(node->child1()).value();
387         JSValue right = forNode(node->child2()).value();
388         switch (node->binaryUseKind()) {
389         case Int32Use:
390             if (left && right && left.isInt32() && right.isInt32()) {
391                 if (!shouldCheckOverflow(node->arithMode())) {
392                     setConstant(node, jsNumber(left.asInt32() + right.asInt32()));
393                     break;
394                 }
395                 JSValue result = jsNumber(left.asNumber() + right.asNumber());
396                 if (result.isInt32()) {
397                     setConstant(node, result);
398                     break;
399                 }
400             }
401             forNode(node).setType(SpecInt32);
402             break;
403         case Int52RepUse:
404             if (left && right && left.isMachineInt() && right.isMachineInt()) {
405                 JSValue result = jsNumber(left.asMachineInt() + right.asMachineInt());
406                 if (result.isMachineInt()) {
407                     setConstant(node, result);
408                     break;
409                 }
410             }
411             forNode(node).setType(SpecMachineInt);
412             break;
413         case DoubleRepUse:
414             if (left && right && left.isNumber() && right.isNumber()) {
415                 setConstant(node, jsDoubleNumber(left.asNumber() + right.asNumber()));
416                 break;
417             }
418             forNode(node).setType(
419                 typeOfDoubleSum(
420                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
421             break;
422         default:
423             RELEASE_ASSERT_NOT_REACHED();
424             break;
425         }
426         break;
427     }
428
429     case ArithClz32: {
430         JSValue operand = forNode(node->child1()).value();
431         if (operand && operand.isNumber()) {
432             uint32_t value = toUInt32(operand.asNumber());
433             setConstant(node, jsNumber(clz32(value)));
434             break;
435         }
436         forNode(node).setType(SpecInt32);
437         break;
438     }
439
440     case MakeRope: {
441         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
442         break;
443     }
444             
445     case ArithSub: {
446         JSValue left = forNode(node->child1()).value();
447         JSValue right = forNode(node->child2()).value();
448         switch (node->binaryUseKind()) {
449         case Int32Use:
450             if (left && right && left.isInt32() && right.isInt32()) {
451                 if (!shouldCheckOverflow(node->arithMode())) {
452                     setConstant(node, jsNumber(left.asInt32() - right.asInt32()));
453                     break;
454                 }
455                 JSValue result = jsNumber(left.asNumber() - right.asNumber());
456                 if (result.isInt32()) {
457                     setConstant(node, result);
458                     break;
459                 }
460             }
461             forNode(node).setType(SpecInt32);
462             break;
463         case Int52RepUse:
464             if (left && right && left.isMachineInt() && right.isMachineInt()) {
465                 JSValue result = jsNumber(left.asMachineInt() - right.asMachineInt());
466                 if (result.isMachineInt() || !shouldCheckOverflow(node->arithMode())) {
467                     setConstant(node, result);
468                     break;
469                 }
470             }
471             forNode(node).setType(SpecMachineInt);
472             break;
473         case DoubleRepUse:
474             if (left && right && left.isNumber() && right.isNumber()) {
475                 setConstant(node, jsDoubleNumber(left.asNumber() - right.asNumber()));
476                 break;
477             }
478             forNode(node).setType(
479                 typeOfDoubleDifference(
480                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
481             break;
482         default:
483             RELEASE_ASSERT_NOT_REACHED();
484             break;
485         }
486         break;
487     }
488         
489     case ArithNegate: {
490         JSValue child = forNode(node->child1()).value();
491         switch (node->child1().useKind()) {
492         case Int32Use:
493             if (child && child.isInt32()) {
494                 if (!shouldCheckOverflow(node->arithMode())) {
495                     setConstant(node, jsNumber(-child.asInt32()));
496                     break;
497                 }
498                 double doubleResult;
499                 if (shouldCheckNegativeZero(node->arithMode()))
500                     doubleResult = -child.asNumber();
501                 else
502                     doubleResult = 0 - child.asNumber();
503                 JSValue valueResult = jsNumber(doubleResult);
504                 if (valueResult.isInt32()) {
505                     setConstant(node, valueResult);
506                     break;
507                 }
508             }
509             forNode(node).setType(SpecInt32);
510             break;
511         case Int52RepUse:
512             if (child && child.isMachineInt()) {
513                 double doubleResult;
514                 if (shouldCheckNegativeZero(node->arithMode()))
515                     doubleResult = -child.asNumber();
516                 else
517                     doubleResult = 0 - child.asNumber();
518                 JSValue valueResult = jsNumber(doubleResult);
519                 if (valueResult.isMachineInt()) {
520                     setConstant(node, valueResult);
521                     break;
522                 }
523             }
524             forNode(node).setType(SpecMachineInt);
525             break;
526         case DoubleRepUse:
527             if (child && child.isNumber()) {
528                 setConstant(node, jsDoubleNumber(-child.asNumber()));
529                 break;
530             }
531             forNode(node).setType(
532                 typeOfDoubleNegation(
533                     forNode(node->child1()).m_type));
534             break;
535         default:
536             RELEASE_ASSERT_NOT_REACHED();
537             break;
538         }
539         break;
540     }
541         
542     case ArithMul: {
543         JSValue left = forNode(node->child1()).value();
544         JSValue right = forNode(node->child2()).value();
545         switch (node->binaryUseKind()) {
546         case Int32Use:
547             if (left && right && left.isInt32() && right.isInt32()) {
548                 if (!shouldCheckOverflow(node->arithMode())) {
549                     setConstant(node, jsNumber(left.asInt32() * right.asInt32()));
550                     break;
551                 }
552                 double doubleResult = left.asNumber() * right.asNumber();
553                 if (!shouldCheckNegativeZero(node->arithMode()))
554                     doubleResult += 0; // Sanitizes zero.
555                 JSValue valueResult = jsNumber(doubleResult);
556                 if (valueResult.isInt32()) {
557                     setConstant(node, valueResult);
558                     break;
559                 }
560             }
561             forNode(node).setType(SpecInt32);
562             break;
563         case Int52RepUse:
564             if (left && right && left.isMachineInt() && right.isMachineInt()) {
565                 double doubleResult = left.asNumber() * right.asNumber();
566                 if (!shouldCheckNegativeZero(node->arithMode()))
567                     doubleResult += 0;
568                 JSValue valueResult = jsNumber(doubleResult);
569                 if (valueResult.isMachineInt()) {
570                     setConstant(node, valueResult);
571                     break;
572                 }
573             }
574             forNode(node).setType(SpecMachineInt);
575             break;
576         case DoubleRepUse:
577             if (left && right && left.isNumber() && right.isNumber()) {
578                 setConstant(node, jsDoubleNumber(left.asNumber() * right.asNumber()));
579                 break;
580             }
581             forNode(node).setType(
582                 typeOfDoubleProduct(
583                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
584             break;
585         default:
586             RELEASE_ASSERT_NOT_REACHED();
587             break;
588         }
589         break;
590     }
591         
592     case ArithDiv: {
593         JSValue left = forNode(node->child1()).value();
594         JSValue right = forNode(node->child2()).value();
595         switch (node->binaryUseKind()) {
596         case Int32Use:
597             if (left && right && left.isInt32() && right.isInt32()) {
598                 double doubleResult = left.asNumber() / right.asNumber();
599                 if (!shouldCheckOverflow(node->arithMode()))
600                     doubleResult = toInt32(doubleResult);
601                 else if (!shouldCheckNegativeZero(node->arithMode()))
602                     doubleResult += 0; // Sanitizes zero.
603                 JSValue valueResult = jsNumber(doubleResult);
604                 if (valueResult.isInt32()) {
605                     setConstant(node, valueResult);
606                     break;
607                 }
608             }
609             forNode(node).setType(SpecInt32);
610             break;
611         case DoubleRepUse:
612             if (left && right && left.isNumber() && right.isNumber()) {
613                 setConstant(node, jsDoubleNumber(left.asNumber() / right.asNumber()));
614                 break;
615             }
616             forNode(node).setType(
617                 typeOfDoubleQuotient(
618                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
619             break;
620         default:
621             RELEASE_ASSERT_NOT_REACHED();
622             break;
623         }
624         break;
625     }
626
627     case ArithMod: {
628         JSValue left = forNode(node->child1()).value();
629         JSValue right = forNode(node->child2()).value();
630         switch (node->binaryUseKind()) {
631         case Int32Use:
632             if (left && right && left.isInt32() && right.isInt32()) {
633                 double doubleResult = fmod(left.asNumber(), right.asNumber());
634                 if (!shouldCheckOverflow(node->arithMode()))
635                     doubleResult = toInt32(doubleResult);
636                 else if (!shouldCheckNegativeZero(node->arithMode()))
637                     doubleResult += 0; // Sanitizes zero.
638                 JSValue valueResult = jsNumber(doubleResult);
639                 if (valueResult.isInt32()) {
640                     setConstant(node, valueResult);
641                     break;
642                 }
643             }
644             forNode(node).setType(SpecInt32);
645             break;
646         case DoubleRepUse:
647             if (left && right && left.isNumber() && right.isNumber()) {
648                 setConstant(node, jsDoubleNumber(fmod(left.asNumber(), right.asNumber())));
649                 break;
650             }
651             forNode(node).setType(
652                 typeOfDoubleBinaryOp(
653                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
654             break;
655         default:
656             RELEASE_ASSERT_NOT_REACHED();
657             break;
658         }
659         break;
660     }
661
662     case ArithMin: {
663         JSValue left = forNode(node->child1()).value();
664         JSValue right = forNode(node->child2()).value();
665         switch (node->binaryUseKind()) {
666         case Int32Use:
667             if (left && right && left.isInt32() && right.isInt32()) {
668                 setConstant(node, jsNumber(std::min(left.asInt32(), right.asInt32())));
669                 break;
670             }
671             forNode(node).setType(SpecInt32);
672             break;
673         case DoubleRepUse:
674             if (left && right && left.isNumber() && right.isNumber()) {
675                 double a = left.asNumber();
676                 double b = right.asNumber();
677                 setConstant(node, jsDoubleNumber(a < b ? a : (b <= a ? b : a + b)));
678                 break;
679             }
680             forNode(node).setType(
681                 typeOfDoubleMinMax(
682                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
683             break;
684         default:
685             RELEASE_ASSERT_NOT_REACHED();
686             break;
687         }
688         break;
689     }
690             
691     case ArithMax: {
692         JSValue left = forNode(node->child1()).value();
693         JSValue right = forNode(node->child2()).value();
694         switch (node->binaryUseKind()) {
695         case Int32Use:
696             if (left && right && left.isInt32() && right.isInt32()) {
697                 setConstant(node, jsNumber(std::max(left.asInt32(), right.asInt32())));
698                 break;
699             }
700             forNode(node).setType(SpecInt32);
701             break;
702         case DoubleRepUse:
703             if (left && right && left.isNumber() && right.isNumber()) {
704                 double a = left.asNumber();
705                 double b = right.asNumber();
706                 setConstant(node, jsDoubleNumber(a > b ? a : (b >= a ? b : a + b)));
707                 break;
708             }
709             forNode(node).setType(
710                 typeOfDoubleMinMax(
711                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
712             break;
713         default:
714             RELEASE_ASSERT_NOT_REACHED();
715             break;
716         }
717         break;
718     }
719             
720     case ArithAbs: {
721         JSValue child = forNode(node->child1()).value();
722         switch (node->child1().useKind()) {
723         case Int32Use:
724             if (child && child.isInt32()) {
725                 JSValue result = jsNumber(fabs(child.asNumber()));
726                 if (result.isInt32()) {
727                     setConstant(node, result);
728                     break;
729                 }
730             }
731             forNode(node).setType(SpecInt32);
732             break;
733         case DoubleRepUse:
734             if (child && child.isNumber()) {
735                 setConstant(node, jsDoubleNumber(child.asNumber()));
736                 break;
737             }
738             forNode(node).setType(typeOfDoubleAbs(forNode(node->child1()).m_type));
739             break;
740         default:
741             RELEASE_ASSERT_NOT_REACHED();
742             break;
743         }
744         break;
745     }
746
747     case ArithPow: {
748         JSValue childY = forNode(node->child2()).value();
749         if (childY && childY.isNumber()) {
750             if (!childY.asNumber()) {
751                 setConstant(node, jsDoubleNumber(1));
752                 break;
753             }
754
755             JSValue childX = forNode(node->child1()).value();
756             if (childX && childX.isNumber()) {
757                 setConstant(node, jsDoubleNumber(operationMathPow(childX.asNumber(), childY.asNumber())));
758                 break;
759             }
760         }
761         forNode(node).setType(typeOfDoublePow(forNode(node->child1()).m_type, forNode(node->child2()).m_type));
762         break;
763     }
764             
765     case ArithSqrt: {
766         JSValue child = forNode(node->child1()).value();
767         if (child && child.isNumber()) {
768             setConstant(node, jsDoubleNumber(sqrt(child.asNumber())));
769             break;
770         }
771         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
772         break;
773     }
774         
775     case ArithFRound: {
776         JSValue child = forNode(node->child1()).value();
777         if (child && child.isNumber()) {
778             setConstant(node, jsDoubleNumber(static_cast<float>(child.asNumber())));
779             break;
780         }
781         forNode(node).setType(typeOfDoubleFRound(forNode(node->child1()).m_type));
782         break;
783     }
784         
785     case ArithSin: {
786         JSValue child = forNode(node->child1()).value();
787         if (false && child && child.isNumber()) {
788             setConstant(node, jsDoubleNumber(sin(child.asNumber())));
789             break;
790         }
791         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
792         break;
793     }
794     
795     case ArithCos: {
796         JSValue child = forNode(node->child1()).value();
797         if (false && child && child.isNumber()) {
798             setConstant(node, jsDoubleNumber(cos(child.asNumber())));
799             break;
800         }
801         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
802         break;
803     }
804
805     case ArithLog: {
806         JSValue child = forNode(node->child1()).value();
807         if (child && child.isNumber()) {
808             setConstant(node, jsDoubleNumber(log(child.asNumber())));
809             break;
810         }
811         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
812         break;
813     }
814             
815     case LogicalNot: {
816         switch (booleanResult(node, forNode(node->child1()))) {
817         case DefinitelyTrue:
818             setConstant(node, jsBoolean(false));
819             break;
820         case DefinitelyFalse:
821             setConstant(node, jsBoolean(true));
822             break;
823         default:
824             forNode(node).setType(SpecBoolean);
825             break;
826         }
827         break;
828     }
829         
830     case IsUndefined:
831     case IsBoolean:
832     case IsNumber:
833     case IsString:
834     case IsObject:
835     case IsObjectOrNull:
836     case IsFunction: {
837         JSValue child = forNode(node->child1()).value();
838         if (child) {
839             bool constantWasSet = true;
840             switch (node->op()) {
841             case IsUndefined:
842                 setConstant(node, jsBoolean(
843                     child.isCell()
844                     ? child.asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
845                     : child.isUndefined()));
846                 break;
847             case IsBoolean:
848                 setConstant(node, jsBoolean(child.isBoolean()));
849                 break;
850             case IsNumber:
851                 setConstant(node, jsBoolean(child.isNumber()));
852                 break;
853             case IsString:
854                 setConstant(node, jsBoolean(isJSString(child)));
855                 break;
856             case IsObject:
857                 setConstant(node, jsBoolean(child.isObject()));
858                 break;
859             case IsObjectOrNull:
860                 if (child.isNull() || !child.isObject()) {
861                     setConstant(node, jsBoolean(child.isNull()));
862                     break;
863                 }
864                 constantWasSet = false;
865                 break;
866             default:
867                 constantWasSet = false;
868                 break;
869             }
870             if (constantWasSet)
871                 break;
872         }
873
874         forNode(node).setType(SpecBoolean);
875         break;
876     }
877
878     case TypeOf: {
879         VM* vm = m_codeBlock->vm();
880         JSValue child = forNode(node->child1()).value();
881         AbstractValue& abstractChild = forNode(node->child1());
882         if (child) {
883             JSValue typeString = jsTypeStringForValue(*vm, m_codeBlock->globalObjectFor(node->origin.semantic), child);
884             setConstant(node, *m_graph.freeze(typeString));
885             break;
886         }
887         
888         if (isFullNumberSpeculation(abstractChild.m_type)) {
889             setConstant(node, *m_graph.freeze(vm->smallStrings.numberString()));
890             break;
891         }
892         
893         if (isStringSpeculation(abstractChild.m_type)) {
894             setConstant(node, *m_graph.freeze(vm->smallStrings.stringString()));
895             break;
896         }
897         
898         if (isFinalObjectSpeculation(abstractChild.m_type) || isArraySpeculation(abstractChild.m_type) || isDirectArgumentsSpeculation(abstractChild.m_type) || isScopedArgumentsSpeculation(abstractChild.m_type)) {
899             setConstant(node, *m_graph.freeze(vm->smallStrings.objectString()));
900             break;
901         }
902         
903         if (isFunctionSpeculation(abstractChild.m_type)) {
904             setConstant(node, *m_graph.freeze(vm->smallStrings.functionString()));
905             break;
906         }
907         
908         if (isBooleanSpeculation(abstractChild.m_type)) {
909             setConstant(node, *m_graph.freeze(vm->smallStrings.booleanString()));
910             break;
911         }
912
913         forNode(node).setType(m_graph, SpecStringIdent);
914         break;
915     }
916             
917     case CompareLess:
918     case CompareLessEq:
919     case CompareGreater:
920     case CompareGreaterEq:
921     case CompareEq:
922     case CompareEqConstant: {
923         JSValue leftConst = forNode(node->child1()).value();
924         JSValue rightConst = forNode(node->child2()).value();
925         if (leftConst && rightConst) {
926             if (leftConst.isNumber() && rightConst.isNumber()) {
927                 double a = leftConst.asNumber();
928                 double b = rightConst.asNumber();
929                 switch (node->op()) {
930                 case CompareLess:
931                     setConstant(node, jsBoolean(a < b));
932                     break;
933                 case CompareLessEq:
934                     setConstant(node, jsBoolean(a <= b));
935                     break;
936                 case CompareGreater:
937                     setConstant(node, jsBoolean(a > b));
938                     break;
939                 case CompareGreaterEq:
940                     setConstant(node, jsBoolean(a >= b));
941                     break;
942                 case CompareEq:
943                     setConstant(node, jsBoolean(a == b));
944                     break;
945                 default:
946                     RELEASE_ASSERT_NOT_REACHED();
947                     break;
948                 }
949                 break;
950             }
951             
952             if (node->op() == CompareEq && leftConst.isString() && rightConst.isString()) {
953                 const StringImpl* a = asString(leftConst)->tryGetValueImpl();
954                 const StringImpl* b = asString(rightConst)->tryGetValueImpl();
955                 if (a && b) {
956                     setConstant(node, jsBoolean(WTF::equal(a, b)));
957                     break;
958                 }
959             }
960         }
961         
962         if (node->op() == CompareEqConstant || node->op() == CompareEq) {
963             SpeculatedType leftType = forNode(node->child1()).m_type;
964             SpeculatedType rightType = forNode(node->child2()).m_type;
965             if (!valuesCouldBeEqual(leftType, rightType)) {
966                 setConstant(node, jsBoolean(false));
967                 break;
968             }
969         }
970         
971         forNode(node).setType(SpecBoolean);
972         break;
973     }
974             
975     case CompareStrictEq: {
976         Node* leftNode = node->child1().node();
977         Node* rightNode = node->child2().node();
978         JSValue left = forNode(leftNode).value();
979         JSValue right = forNode(rightNode).value();
980         if (left && right) {
981             if (left.isString() && right.isString()) {
982                 // We need this case because JSValue::strictEqual is otherwise too racy for
983                 // string comparisons.
984                 const StringImpl* a = asString(left)->tryGetValueImpl();
985                 const StringImpl* b = asString(right)->tryGetValueImpl();
986                 if (a && b) {
987                     setConstant(node, jsBoolean(WTF::equal(a, b)));
988                     break;
989                 }
990             } else {
991                 setConstant(node, jsBoolean(JSValue::strictEqual(0, left, right)));
992                 break;
993             }
994         }
995         
996         SpeculatedType leftLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(leftNode).m_type);
997         SpeculatedType rightLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(rightNode).m_type);
998         if (!(leftLUB & rightLUB)) {
999             setConstant(node, jsBoolean(false));
1000             break;
1001         }
1002         
1003         forNode(node).setType(SpecBoolean);
1004         break;
1005     }
1006         
1007     case StringCharCodeAt:
1008         forNode(node).setType(SpecInt32);
1009         break;
1010         
1011     case StringFromCharCode:
1012         forNode(node).setType(m_graph, SpecString);
1013         break;
1014
1015     case StringCharAt:
1016         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1017         break;
1018             
1019     case GetByVal: {
1020         switch (node->arrayMode().type()) {
1021         case Array::SelectUsingPredictions:
1022         case Array::Unprofiled:
1023         case Array::Undecided:
1024             RELEASE_ASSERT_NOT_REACHED();
1025             break;
1026         case Array::ForceExit:
1027             m_state.setIsValid(false);
1028             break;
1029         case Array::Generic:
1030             clobberWorld(node->origin.semantic, clobberLimit);
1031             forNode(node).makeHeapTop();
1032             break;
1033         case Array::String:
1034             if (node->arrayMode().isOutOfBounds()) {
1035                 // If the watchpoint was still valid we could totally set this to be
1036                 // SpecString | SpecOther. Except that we'd have to be careful. If we
1037                 // tested the watchpoint state here then it could change by the time
1038                 // we got to the backend. So to do this right, we'd have to get the
1039                 // fixup phase to check the watchpoint state and then bake into the
1040                 // GetByVal operation the fact that we're using a watchpoint, using
1041                 // something like Array::SaneChain (except not quite, because that
1042                 // implies an in-bounds access). None of this feels like it's worth it,
1043                 // so we're going with TOP for now. The same thing applies to
1044                 // clobbering the world.
1045                 clobberWorld(node->origin.semantic, clobberLimit);
1046                 forNode(node).makeHeapTop();
1047             } else
1048                 forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1049             break;
1050         case Array::DirectArguments:
1051         case Array::ScopedArguments:
1052             forNode(node).makeHeapTop();
1053             break;
1054         case Array::Int32:
1055             if (node->arrayMode().isOutOfBounds()) {
1056                 clobberWorld(node->origin.semantic, clobberLimit);
1057                 forNode(node).makeHeapTop();
1058             } else
1059                 forNode(node).setType(SpecInt32);
1060             break;
1061         case Array::Double:
1062             if (node->arrayMode().isOutOfBounds()) {
1063                 clobberWorld(node->origin.semantic, clobberLimit);
1064                 forNode(node).makeHeapTop();
1065             } else if (node->arrayMode().isSaneChain())
1066                 forNode(node).setType(SpecBytecodeDouble);
1067             else
1068                 forNode(node).setType(SpecDoubleReal);
1069             break;
1070         case Array::Contiguous:
1071         case Array::ArrayStorage:
1072         case Array::SlowPutArrayStorage:
1073             if (node->arrayMode().isOutOfBounds())
1074                 clobberWorld(node->origin.semantic, clobberLimit);
1075             forNode(node).makeHeapTop();
1076             break;
1077         case Array::Int8Array:
1078             forNode(node).setType(SpecInt32);
1079             break;
1080         case Array::Int16Array:
1081             forNode(node).setType(SpecInt32);
1082             break;
1083         case Array::Int32Array:
1084             forNode(node).setType(SpecInt32);
1085             break;
1086         case Array::Uint8Array:
1087             forNode(node).setType(SpecInt32);
1088             break;
1089         case Array::Uint8ClampedArray:
1090             forNode(node).setType(SpecInt32);
1091             break;
1092         case Array::Uint16Array:
1093             forNode(node).setType(SpecInt32);
1094             break;
1095         case Array::Uint32Array:
1096             if (node->shouldSpeculateInt32())
1097                 forNode(node).setType(SpecInt32);
1098             else if (enableInt52() && node->shouldSpeculateMachineInt())
1099                 forNode(node).setType(SpecInt52);
1100             else
1101                 forNode(node).setType(SpecInt52AsDouble);
1102             break;
1103         case Array::Float32Array:
1104             forNode(node).setType(SpecFullDouble);
1105             break;
1106         case Array::Float64Array:
1107             forNode(node).setType(SpecFullDouble);
1108             break;
1109         default:
1110             RELEASE_ASSERT_NOT_REACHED();
1111             break;
1112         }
1113         break;
1114     }
1115             
1116     case PutByValDirect:
1117     case PutByVal:
1118     case PutByValAlias: {
1119         switch (node->arrayMode().modeForPut().type()) {
1120         case Array::ForceExit:
1121             m_state.setIsValid(false);
1122             break;
1123         case Array::Generic:
1124             clobberWorld(node->origin.semantic, clobberLimit);
1125             break;
1126         case Array::Int32:
1127             if (node->arrayMode().isOutOfBounds())
1128                 clobberWorld(node->origin.semantic, clobberLimit);
1129             break;
1130         case Array::Double:
1131             if (node->arrayMode().isOutOfBounds())
1132                 clobberWorld(node->origin.semantic, clobberLimit);
1133             break;
1134         case Array::Contiguous:
1135         case Array::ArrayStorage:
1136             if (node->arrayMode().isOutOfBounds())
1137                 clobberWorld(node->origin.semantic, clobberLimit);
1138             break;
1139         case Array::SlowPutArrayStorage:
1140             if (node->arrayMode().mayStoreToHole())
1141                 clobberWorld(node->origin.semantic, clobberLimit);
1142             break;
1143         default:
1144             break;
1145         }
1146         break;
1147     }
1148             
1149     case ArrayPush:
1150         clobberWorld(node->origin.semantic, clobberLimit);
1151         forNode(node).setType(SpecBytecodeNumber);
1152         break;
1153             
1154     case ArrayPop:
1155         clobberWorld(node->origin.semantic, clobberLimit);
1156         forNode(node).makeHeapTop();
1157         break;
1158         
1159     case GetMyArgumentByVal: {
1160         JSValue index = forNode(node->child2()).m_value;
1161         InlineCallFrame* inlineCallFrame = node->child1()->origin.semantic.inlineCallFrame;
1162
1163         if (index && index.isInt32()) {
1164             // This pretends to return TOP for accesses that are actually proven out-of-bounds because
1165             // that's the conservative thing to do. Otherwise we'd need to write more code to mark such
1166             // paths as unreachable, and it's almost certainly not worth the effort.
1167             
1168             if (inlineCallFrame) {
1169                 if (index.asUInt32() < inlineCallFrame->arguments.size() - 1) {
1170                     forNode(node) = m_state.variables().operand(
1171                         virtualRegisterForArgument(index.asInt32() + 1) + inlineCallFrame->stackOffset);
1172                     m_state.setFoundConstants(true);
1173                     break;
1174                 }
1175             } else {
1176                 if (index.asUInt32() < m_state.variables().numberOfArguments() - 1) {
1177                     forNode(node) = m_state.variables().argument(index.asInt32() + 1);
1178                     m_state.setFoundConstants(true);
1179                     break;
1180                 }
1181             }
1182         }
1183         
1184         if (inlineCallFrame) {
1185             // We have a bound on the types even though it's random access. Take advantage of this.
1186             
1187             AbstractValue result;
1188             for (unsigned i = inlineCallFrame->arguments.size(); i-- > 1;) {
1189                 result.merge(
1190                     m_state.variables().operand(
1191                         virtualRegisterForArgument(i) + inlineCallFrame->stackOffset));
1192             }
1193             
1194             if (result.value())
1195                 m_state.setFoundConstants(true);
1196             forNode(node) = result;
1197             break;
1198         }
1199         
1200         forNode(node).makeHeapTop();
1201         break;
1202     }
1203             
1204     case RegExpExec:
1205         forNode(node).makeHeapTop();
1206         break;
1207
1208     case RegExpTest:
1209         forNode(node).setType(SpecBoolean);
1210         break;
1211             
1212     case Jump:
1213         break;
1214             
1215     case Branch: {
1216         Node* child = node->child1().node();
1217         BooleanResult result = booleanResult(node, forNode(child));
1218         if (result == DefinitelyTrue) {
1219             m_state.setBranchDirection(TakeTrue);
1220             break;
1221         }
1222         if (result == DefinitelyFalse) {
1223             m_state.setBranchDirection(TakeFalse);
1224             break;
1225         }
1226         // FIXME: The above handles the trivial cases of sparse conditional
1227         // constant propagation, but we can do better:
1228         // We can specialize the source variable's value on each direction of
1229         // the branch.
1230         m_state.setBranchDirection(TakeBoth);
1231         break;
1232     }
1233         
1234     case Switch: {
1235         // Nothing to do for now.
1236         // FIXME: Do sparse conditional things.
1237         break;
1238     }
1239             
1240     case Return:
1241         m_state.setIsValid(false);
1242         break;
1243         
1244     case Throw:
1245     case ThrowReferenceError:
1246         m_state.setIsValid(false);
1247         break;
1248             
1249     case ToPrimitive: {
1250         JSValue childConst = forNode(node->child1()).value();
1251         if (childConst && childConst.isNumber()) {
1252             setConstant(node, childConst);
1253             break;
1254         }
1255         
1256         ASSERT(node->child1().useKind() == UntypedUse);
1257         
1258         if (!forNode(node->child1()).m_type) {
1259             m_state.setIsValid(false);
1260             break;
1261         }
1262         
1263         if (!(forNode(node->child1()).m_type & ~(SpecFullNumber | SpecBoolean | SpecString | SpecCellOther))) {
1264             m_state.setFoundConstants(true);
1265             forNode(node) = forNode(node->child1());
1266             break;
1267         }
1268         
1269         clobberWorld(node->origin.semantic, clobberLimit);
1270         
1271         forNode(node).setType(m_graph, (SpecHeapTop & ~SpecCell) | SpecString | SpecCellOther);
1272         break;
1273     }
1274         
1275     case ToString:
1276     case CallStringConstructor: {
1277         switch (node->child1().useKind()) {
1278         case StringObjectUse:
1279             // This also filters that the StringObject has the primordial StringObject
1280             // structure.
1281             filter(
1282                 node->child1(),
1283                 m_graph.globalObjectFor(node->origin.semantic)->stringObjectStructure());
1284             break;
1285         case StringOrStringObjectUse:
1286             break;
1287         case CellUse:
1288         case UntypedUse:
1289             clobberWorld(node->origin.semantic, clobberLimit);
1290             break;
1291         default:
1292             RELEASE_ASSERT_NOT_REACHED();
1293             break;
1294         }
1295         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1296         break;
1297     }
1298         
1299     case NewStringObject: {
1300         ASSERT(node->structure()->classInfo() == StringObject::info());
1301         forNode(node).set(m_graph, node->structure());
1302         break;
1303     }
1304             
1305     case NewArray:
1306         forNode(node).set(
1307             m_graph,
1308             m_graph.globalObjectFor(node->origin.semantic)->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
1309         break;
1310         
1311     case NewArrayBuffer:
1312         forNode(node).set(
1313             m_graph,
1314             m_graph.globalObjectFor(node->origin.semantic)->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
1315         break;
1316
1317     case NewArrayWithSize:
1318         forNode(node).setType(m_graph, SpecArray);
1319         break;
1320         
1321     case NewTypedArray:
1322         switch (node->child1().useKind()) {
1323         case Int32Use:
1324             break;
1325         case UntypedUse:
1326             clobberWorld(node->origin.semantic, clobberLimit);
1327             break;
1328         default:
1329             RELEASE_ASSERT_NOT_REACHED();
1330             break;
1331         }
1332         forNode(node).set(
1333             m_graph,
1334             m_graph.globalObjectFor(node->origin.semantic)->typedArrayStructure(
1335                 node->typedArrayType()));
1336         break;
1337             
1338     case NewRegexp:
1339         forNode(node).set(m_graph, m_graph.globalObjectFor(node->origin.semantic)->regExpStructure());
1340         break;
1341             
1342     case ToThis: {
1343         AbstractValue& source = forNode(node->child1());
1344         AbstractValue& destination = forNode(node);
1345             
1346         if (m_graph.executableFor(node->origin.semantic)->isStrictMode())
1347             destination.makeHeapTop();
1348         else {
1349             destination = source;
1350             destination.merge(SpecObject);
1351         }
1352         break;
1353     }
1354
1355     case CreateThis: {
1356         // FIXME: We can fold this to NewObject if the incoming callee is a constant.
1357         forNode(node).setType(m_graph, SpecFinalObject);
1358         break;
1359     }
1360         
1361     case NewObject:
1362         ASSERT(node->structure());
1363         forNode(node).set(m_graph, node->structure());
1364         break;
1365         
1366     case PhantomNewObject:
1367     case PhantomNewFunction:
1368     case PhantomDirectArguments:
1369     case PhantomClonedArguments:
1370     case BottomValue:
1371         m_state.setDidClobber(true); // Prevent constant folding.
1372         // This claims to return bottom.
1373         break;
1374         
1375     case PutHint:
1376         break;
1377         
1378     case MaterializeNewObject: {
1379         StructureSet set;
1380         
1381         m_phiChildren->forAllTransitiveIncomingValues(
1382             m_graph.varArgChild(node, 0).node(),
1383             [&] (Node* incoming) {
1384                 set.add(incoming->castConstant<Structure*>());
1385             });
1386         
1387         forNode(node).set(m_graph, set);
1388         break;
1389     }
1390         
1391     case CreateActivation:
1392         forNode(node).set(
1393             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->activationStructure());
1394         break;
1395         
1396     case CreateDirectArguments:
1397         forNode(node).set(m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->directArgumentsStructure());
1398         break;
1399         
1400     case CreateScopedArguments:
1401         forNode(node).set(m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->scopedArgumentsStructure());
1402         break;
1403         
1404     case CreateClonedArguments:
1405         forNode(node).setType(m_graph, SpecObjectOther);
1406         break;
1407         
1408     case NewFunction:
1409         forNode(node).set(
1410             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->functionStructure());
1411         break;
1412         
1413     case GetCallee:
1414         if (FunctionExecutable* executable = jsDynamicCast<FunctionExecutable*>(m_codeBlock->ownerExecutable())) {
1415             InferredValue* singleton = executable->singletonFunction();
1416             if (JSValue value = singleton->inferredValue()) {
1417                 m_graph.watchpoints().addLazily(singleton);
1418                 JSFunction* function = jsCast<JSFunction*>(value);
1419                 setConstant(node, *m_graph.freeze(function));
1420                 break;
1421             }
1422         }
1423         forNode(node).setType(m_graph, SpecFunction);
1424         break;
1425         
1426     case GetArgumentCount:
1427         forNode(node).setType(SpecInt32);
1428         break;
1429         
1430     case GetGetter: {
1431         JSValue base = forNode(node->child1()).m_value;
1432         if (base) {
1433             GetterSetter* getterSetter = jsCast<GetterSetter*>(base);
1434             if (!getterSetter->isGetterNull()) {
1435                 setConstant(node, *m_graph.freeze(getterSetter->getterConcurrently()));
1436                 break;
1437             }
1438         }
1439         
1440         forNode(node).setType(m_graph, SpecObject);
1441         break;
1442     }
1443         
1444     case GetSetter: {
1445         JSValue base = forNode(node->child1()).m_value;
1446         if (base) {
1447             GetterSetter* getterSetter = jsCast<GetterSetter*>(base);
1448             if (!getterSetter->isSetterNull()) {
1449                 setConstant(node, *m_graph.freeze(getterSetter->setterConcurrently()));
1450                 break;
1451             }
1452         }
1453         
1454         forNode(node).setType(m_graph, SpecObject);
1455         break;
1456     }
1457         
1458     case GetScope:
1459         if (JSValue base = forNode(node->child1()).m_value) {
1460             if (JSFunction* function = jsDynamicCast<JSFunction*>(base)) {
1461                 setConstant(node, *m_graph.freeze(function->scope()));
1462                 break;
1463             }
1464         }
1465         forNode(node).setType(m_graph, SpecObjectOther);
1466         break;
1467
1468     case SkipScope: {
1469         JSValue child = forNode(node->child1()).value();
1470         if (child) {
1471             setConstant(node, *m_graph.freeze(JSValue(jsCast<JSScope*>(child.asCell())->next())));
1472             break;
1473         }
1474         forNode(node).setType(m_graph, SpecObjectOther);
1475         break;
1476     }
1477
1478     case GetClosureVar:
1479         if (JSValue value = m_graph.tryGetConstantClosureVar(forNode(node->child1()), node->scopeOffset())) {
1480             setConstant(node, *m_graph.freeze(value));
1481             break;
1482         }
1483         forNode(node).makeHeapTop();
1484         break;
1485             
1486     case PutClosureVar:
1487         break;
1488         
1489     case GetFromArguments:
1490         forNode(node).makeHeapTop();
1491         break;
1492         
1493     case PutToArguments:
1494         break;
1495             
1496     case GetById:
1497     case GetByIdFlush: {
1498         if (!node->prediction()) {
1499             m_state.setIsValid(false);
1500             break;
1501         }
1502         
1503         AbstractValue& value = forNode(node->child1());
1504         if (!value.m_structure.isTop() && !value.m_structure.isClobbered()
1505             && (node->child1().useKind() == CellUse || !(value.m_type & ~SpecCell))) {
1506             GetByIdStatus status = GetByIdStatus::computeFor(
1507                 value.m_structure.set(), m_graph.identifiers()[node->identifierNumber()]);
1508             if (status.isSimple()) {
1509                 // Figure out what the result is going to be - is it TOP, a constant, or maybe
1510                 // something more subtle?
1511                 AbstractValue result;
1512                 for (unsigned i = status.numVariants(); i--;) {
1513                     DFG_ASSERT(m_graph, node, !status[i].alternateBase());
1514                     JSValue constantResult =
1515                         m_graph.tryGetConstantProperty(value, status[i].offset());
1516                     if (!constantResult) {
1517                         result.makeHeapTop();
1518                         break;
1519                     }
1520                     
1521                     AbstractValue thisResult;
1522                     thisResult.set(
1523                         m_graph, *m_graph.freeze(constantResult),
1524                         m_state.structureClobberState());
1525                     result.merge(thisResult);
1526                 }
1527                 if (status.numVariants() == 1 || isFTL(m_graph.m_plan.mode))
1528                     m_state.setFoundConstants(true);
1529                 forNode(node) = result;
1530                 break;
1531             }
1532         }
1533
1534         clobberWorld(node->origin.semantic, clobberLimit);
1535         forNode(node).makeHeapTop();
1536         break;
1537     }
1538             
1539     case GetArrayLength: {
1540         JSArrayBufferView* view = m_graph.tryGetFoldableView(
1541             forNode(node->child1()).m_value, node->arrayMode());
1542         if (view) {
1543             setConstant(node, jsNumber(view->length()));
1544             break;
1545         }
1546         forNode(node).setType(SpecInt32);
1547         break;
1548     }
1549         
1550     case CheckStructure: {
1551         AbstractValue& value = forNode(node->child1());
1552         ASSERT(!(value.m_type & ~SpecCell)); // Edge filtering should have already ensured this.
1553
1554         StructureSet& set = node->structureSet();
1555         
1556         // It's interesting that we could have proven that the object has a larger structure set
1557         // that includes the set we're testing. In that case we could make the structure check
1558         // more efficient. We currently don't.
1559         
1560         if (value.m_structure.isSubsetOf(set)) {
1561             m_state.setFoundConstants(true);
1562             break;
1563         }
1564
1565         filter(value, set);
1566         break;
1567     }
1568         
1569     case CheckStructureImmediate: {
1570         // FIXME: This currently can only reason about one structure at a time.
1571         // https://bugs.webkit.org/show_bug.cgi?id=136988
1572         
1573         AbstractValue& value = forNode(node->child1());
1574         StructureSet& set = node->structureSet();
1575         
1576         if (value.value()) {
1577             if (Structure* structure = jsDynamicCast<Structure*>(value.value())) {
1578                 if (set.contains(structure)) {
1579                     m_state.setFoundConstants(true);
1580                     break;
1581                 }
1582             }
1583             m_state.setIsValid(false);
1584             break;
1585         }
1586         
1587         if (m_phiChildren) {
1588             bool allGood = true;
1589             m_phiChildren->forAllTransitiveIncomingValues(
1590                 node,
1591                 [&] (Node* incoming) {
1592                     if (Structure* structure = incoming->dynamicCastConstant<Structure*>()) {
1593                         if (set.contains(structure))
1594                             return;
1595                     }
1596                     allGood = false;
1597                 });
1598             if (allGood) {
1599                 m_state.setFoundConstants(true);
1600                 break;
1601             }
1602         }
1603             
1604         if (Structure* structure = set.onlyStructure()) {
1605             filterByValue(node->child1(), *m_graph.freeze(structure));
1606             break;
1607         }
1608         
1609         // Aw shucks, we can't do anything!
1610         break;
1611     }
1612         
1613     case PutStructure:
1614         if (!forNode(node->child1()).m_structure.isClear()) {
1615             if (forNode(node->child1()).m_structure.onlyStructure() == node->transition()->next)
1616                 m_state.setFoundConstants(true);
1617             else {
1618                 observeTransition(
1619                     clobberLimit, node->transition()->previous, node->transition()->next);
1620                 forNode(node->child1()).changeStructure(m_graph, node->transition()->next);
1621             }
1622         }
1623         break;
1624     case GetButterfly:
1625     case AllocatePropertyStorage:
1626     case ReallocatePropertyStorage:
1627         forNode(node).clear(); // The result is not a JS value.
1628         break;
1629     case CheckArray: {
1630         if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
1631             m_state.setFoundConstants(true);
1632             break;
1633         }
1634         switch (node->arrayMode().type()) {
1635         case Array::String:
1636             filter(node->child1(), SpecString);
1637             break;
1638         case Array::Int32:
1639         case Array::Double:
1640         case Array::Contiguous:
1641         case Array::ArrayStorage:
1642         case Array::SlowPutArrayStorage:
1643             break;
1644         case Array::DirectArguments:
1645             filter(node->child1(), SpecDirectArguments);
1646             break;
1647         case Array::ScopedArguments:
1648             filter(node->child1(), SpecScopedArguments);
1649             break;
1650         case Array::Int8Array:
1651             filter(node->child1(), SpecInt8Array);
1652             break;
1653         case Array::Int16Array:
1654             filter(node->child1(), SpecInt16Array);
1655             break;
1656         case Array::Int32Array:
1657             filter(node->child1(), SpecInt32Array);
1658             break;
1659         case Array::Uint8Array:
1660             filter(node->child1(), SpecUint8Array);
1661             break;
1662         case Array::Uint8ClampedArray:
1663             filter(node->child1(), SpecUint8ClampedArray);
1664             break;
1665         case Array::Uint16Array:
1666             filter(node->child1(), SpecUint16Array);
1667             break;
1668         case Array::Uint32Array:
1669             filter(node->child1(), SpecUint32Array);
1670             break;
1671         case Array::Float32Array:
1672             filter(node->child1(), SpecFloat32Array);
1673             break;
1674         case Array::Float64Array:
1675             filter(node->child1(), SpecFloat64Array);
1676             break;
1677         default:
1678             RELEASE_ASSERT_NOT_REACHED();
1679             break;
1680         }
1681         filterArrayModes(node->child1(), node->arrayMode().arrayModesThatPassFiltering());
1682         break;
1683     }
1684     case Arrayify: {
1685         if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
1686             m_state.setFoundConstants(true);
1687             break;
1688         }
1689         ASSERT(node->arrayMode().conversion() == Array::Convert);
1690         clobberStructures(clobberLimit);
1691         filterArrayModes(node->child1(), node->arrayMode().arrayModesThatPassFiltering());
1692         break;
1693     }
1694     case ArrayifyToStructure: {
1695         AbstractValue& value = forNode(node->child1());
1696         if (value.m_structure.isSubsetOf(StructureSet(node->structure())))
1697             m_state.setFoundConstants(true);
1698         clobberStructures(clobberLimit);
1699         
1700         // We have a bunch of options of how to express the abstract set at this point. Let set S
1701         // be the set of structures that the value had before clobbering and assume that all of
1702         // them are watchable. The new value should be the least expressible upper bound of the
1703         // intersection of "values that currently have structure = node->structure()" and "values
1704         // that have structure in S plus any structure transition-reachable from S". Assume that
1705         // node->structure() is not in S but it is transition-reachable from S. Then we would
1706         // like to say that the result is "values that have structure = node->structure() until
1707         // we invalidate", but there is no way to express this using the AbstractValue syntax. So
1708         // we must choose between:
1709         //
1710         // 1) "values that currently have structure = node->structure()". This is a valid
1711         //    superset of the value that we really want, and it's specific enough to satisfy the
1712         //    preconditions of the array access that this is guarding. It's also specific enough
1713         //    to allow relevant optimizations in the case that we didn't have a contradiction
1714         //    like in this example. Notice that in the abscence of any contradiction, this result
1715         //    is precise rather than being a conservative LUB.
1716         //
1717         // 2) "values that currently hava structure in S plus any structure transition-reachable
1718         //    from S". This is also a valid superset of the value that we really want, but it's
1719         //    not specific enough to satisfy the preconditions of the array access that this is
1720         //    guarding - so playing such shenanigans would preclude us from having assertions on
1721         //    the typing preconditions of any array accesses. This would also not be a desirable
1722         //    answer in the absence of a contradiction.
1723         //
1724         // Note that it's tempting to simply say that the resulting value is BOTTOM because of
1725         // the contradiction. That would be wrong, since we haven't hit an invalidation point,
1726         // yet.
1727         value.set(m_graph, node->structure());
1728         break;
1729     }
1730     case GetIndexedPropertyStorage: {
1731         JSArrayBufferView* view = m_graph.tryGetFoldableView(
1732             forNode(node->child1()).m_value, node->arrayMode());
1733         if (view)
1734             m_state.setFoundConstants(true);
1735         forNode(node).clear();
1736         break;
1737     }
1738     case ConstantStoragePointer: {
1739         forNode(node).clear();
1740         break; 
1741     }
1742         
1743     case GetTypedArrayByteOffset: {
1744         JSArrayBufferView* view = m_graph.tryGetFoldableView(forNode(node->child1()).m_value);
1745         if (view) {
1746             setConstant(node, jsNumber(view->byteOffset()));
1747             break;
1748         }
1749         forNode(node).setType(SpecInt32);
1750         break;
1751     }
1752         
1753     case GetByOffset: {
1754         StorageAccessData& data = node->storageAccessData();
1755         JSValue result = m_graph.tryGetConstantProperty(forNode(node->child2()), data.offset);
1756         if (result) {
1757             setConstant(node, *m_graph.freeze(result));
1758             break;
1759         }
1760         
1761         forNode(node).makeHeapTop();
1762         break;
1763     }
1764         
1765     case GetGetterSetterByOffset: {
1766         StorageAccessData& data = node->storageAccessData();
1767         JSValue result = m_graph.tryGetConstantProperty(forNode(node->child2()), data.offset);
1768         if (result && jsDynamicCast<GetterSetter*>(result)) {
1769             setConstant(node, *m_graph.freeze(result));
1770             break;
1771         }
1772         
1773         forNode(node).set(m_graph, m_graph.m_vm.getterSetterStructure.get());
1774         break;
1775     }
1776         
1777     case MultiGetByOffset: {
1778         // This code will filter the base value in a manner that is possibly different (either more
1779         // or less precise) than the way it would be filtered if this was strength-reduced to a
1780         // CheckStructure. This is fine. It's legal for different passes over the code to prove
1781         // different things about the code, so long as all of them are sound. That even includes
1782         // one guy proving that code should never execute (due to a contradiction) and another guy
1783         // not finding that contradiction. If someone ever proved that there would be a
1784         // contradiction then there must always be a contradiction even if subsequent passes don't
1785         // realize it. This is the case here.
1786         
1787         // Ordinarily you have to be careful with calling setFoundConstants()
1788         // because of the effect on compile times, but this node is FTL-only.
1789         m_state.setFoundConstants(true);
1790         
1791         AbstractValue base = forNode(node->child1());
1792         StructureSet baseSet;
1793         AbstractValue result;
1794         for (unsigned i = node->multiGetByOffsetData().variants.size(); i--;) {
1795             GetByIdVariant& variant = node->multiGetByOffsetData().variants[i];
1796             StructureSet set = variant.structureSet();
1797             set.filter(base);
1798             if (set.isEmpty())
1799                 continue;
1800             baseSet.merge(set);
1801             
1802             JSValue baseForLoad;
1803             if (variant.alternateBase())
1804                 baseForLoad = variant.alternateBase();
1805             else
1806                 baseForLoad = base.m_value;
1807             JSValue constantResult =
1808                 m_graph.tryGetConstantProperty(
1809                     baseForLoad, variant.baseStructure(), variant.offset());
1810             if (!constantResult) {
1811                 result.makeHeapTop();
1812                 continue;
1813             }
1814             AbstractValue thisResult;
1815             thisResult.set(
1816                 m_graph,
1817                 *m_graph.freeze(constantResult),
1818                 m_state.structureClobberState());
1819             result.merge(thisResult);
1820         }
1821         
1822         if (forNode(node->child1()).changeStructure(m_graph, baseSet) == Contradiction)
1823             m_state.setIsValid(false);
1824         
1825         forNode(node) = result;
1826         break;
1827     }
1828             
1829     case PutByOffset: {
1830         break;
1831     }
1832         
1833     case MultiPutByOffset: {
1834         StructureSet newSet;
1835         TransitionVector transitions;
1836         
1837         // Ordinarily you have to be careful with calling setFoundConstants()
1838         // because of the effect on compile times, but this node is FTL-only.
1839         m_state.setFoundConstants(true);
1840         
1841         AbstractValue base = forNode(node->child1());
1842         
1843         for (unsigned i = node->multiPutByOffsetData().variants.size(); i--;) {
1844             const PutByIdVariant& variant = node->multiPutByOffsetData().variants[i];
1845             StructureSet thisSet = variant.oldStructure();
1846             thisSet.filter(base);
1847             if (thisSet.isEmpty())
1848                 continue;
1849             if (variant.kind() == PutByIdVariant::Transition) {
1850                 if (thisSet.onlyStructure() != variant.newStructure()) {
1851                     transitions.append(
1852                         Transition(variant.oldStructureForTransition(), variant.newStructure()));
1853                 } // else this is really a replace.
1854                 newSet.add(variant.newStructure());
1855             } else {
1856                 ASSERT(variant.kind() == PutByIdVariant::Replace);
1857                 newSet.merge(thisSet);
1858             }
1859         }
1860         
1861         observeTransitions(clobberLimit, transitions);
1862         if (forNode(node->child1()).changeStructure(m_graph, newSet) == Contradiction)
1863             m_state.setIsValid(false);
1864         break;
1865     }
1866         
1867     case GetExecutable: {
1868         JSValue value = forNode(node->child1()).value();
1869         if (value) {
1870             JSFunction* function = jsDynamicCast<JSFunction*>(value);
1871             if (function) {
1872                 setConstant(node, *m_graph.freeze(function->executable()));
1873                 break;
1874             }
1875         }
1876         forNode(node).setType(m_graph, SpecCellOther);
1877         break;
1878     }
1879     
1880     case CheckCell: {
1881         JSValue value = forNode(node->child1()).value();
1882         if (value == node->cellOperand()->value()) {
1883             m_state.setFoundConstants(true);
1884             ASSERT(value);
1885             break;
1886         }
1887         filterByValue(node->child1(), *node->cellOperand());
1888         break;
1889     }
1890
1891     case CheckNotEmpty: {
1892         AbstractValue& value = forNode(node->child1());
1893         if (!(value.m_type & SpecEmpty)) {
1894             m_state.setFoundConstants(true);
1895             break;
1896         }
1897         
1898         filter(value, ~SpecEmpty);
1899         break;
1900     }
1901
1902     case CheckInBounds: {
1903         JSValue left = forNode(node->child1()).value();
1904         JSValue right = forNode(node->child2()).value();
1905         if (left && right && left.isInt32() && right.isInt32()
1906             && static_cast<uint32_t>(left.asInt32()) < static_cast<uint32_t>(right.asInt32())) {
1907             m_state.setFoundConstants(true);
1908             break;
1909         }
1910         break;
1911     }
1912         
1913     case PutById:
1914     case PutByIdFlush:
1915     case PutByIdDirect: {
1916         AbstractValue& value = forNode(node->child1());
1917         if (!value.m_structure.isTop() && !value.m_structure.isClobbered()) {
1918             PutByIdStatus status = PutByIdStatus::computeFor(
1919                 m_graph.globalObjectFor(node->origin.semantic),
1920                 value.m_structure.set(),
1921                 m_graph.identifiers()[node->identifierNumber()],
1922                 node->op() == PutByIdDirect);
1923             
1924             if (status.isSimple()) {
1925                 StructureSet newSet;
1926                 TransitionVector transitions;
1927                 
1928                 for (unsigned i = status.numVariants(); i--;) {
1929                     const PutByIdVariant& variant = status[i];
1930                     if (variant.kind() == PutByIdVariant::Transition) {
1931                         transitions.append(
1932                             Transition(
1933                                 variant.oldStructureForTransition(), variant.newStructure()));
1934                         m_graph.registerStructure(variant.newStructure());
1935                         newSet.add(variant.newStructure());
1936                     } else {
1937                         ASSERT(variant.kind() == PutByIdVariant::Replace);
1938                         newSet.merge(variant.oldStructure());
1939                     }
1940                 }
1941                 
1942                 if (status.numVariants() == 1 || isFTL(m_graph.m_plan.mode))
1943                     m_state.setFoundConstants(true);
1944                 
1945                 observeTransitions(clobberLimit, transitions);
1946                 if (forNode(node->child1()).changeStructure(m_graph, newSet) == Contradiction)
1947                     m_state.setIsValid(false);
1948                 break;
1949             }
1950         }
1951         
1952         clobberWorld(node->origin.semantic, clobberLimit);
1953         break;
1954     }
1955         
1956     case In: {
1957         // FIXME: We can determine when the property definitely exists based on abstract
1958         // value information.
1959         clobberWorld(node->origin.semantic, clobberLimit);
1960         forNode(node).setType(SpecBoolean);
1961         break;
1962     }
1963             
1964     case GetEnumerableLength: {
1965         forNode(node).setType(SpecInt32);
1966         break;
1967     }
1968     case HasGenericProperty: {
1969         forNode(node).setType(SpecBoolean);
1970         break;
1971     }
1972     case HasStructureProperty: {
1973         forNode(node).setType(SpecBoolean);
1974         break;
1975     }
1976     case HasIndexedProperty: {
1977         ArrayMode mode = node->arrayMode();
1978         switch (mode.type()) {
1979         case Array::Int32:
1980         case Array::Double:
1981         case Array::Contiguous:
1982         case Array::ArrayStorage: {
1983             break;
1984         }
1985         default: {
1986             clobberWorld(node->origin.semantic, clobberLimit);
1987             break;
1988         }
1989         }
1990         forNode(node).setType(SpecBoolean);
1991         break;
1992     }
1993     case GetDirectPname: {
1994         clobberWorld(node->origin.semantic, clobberLimit);
1995         forNode(node).makeHeapTop();
1996         break;
1997     }
1998     case GetPropertyEnumerator: {
1999         forNode(node).setType(m_graph, SpecCell);
2000         break;
2001     }
2002     case GetEnumeratorStructurePname: {
2003         forNode(node).setType(m_graph, SpecString | SpecOther);
2004         break;
2005     }
2006     case GetEnumeratorGenericPname: {
2007         forNode(node).setType(m_graph, SpecString | SpecOther);
2008         break;
2009     }
2010     case ToIndexString: {
2011         forNode(node).setType(m_graph, SpecString);
2012         break;
2013     }
2014
2015     case GetGlobalVar:
2016         forNode(node).makeHeapTop();
2017         break;
2018         
2019     case VarInjectionWatchpoint:
2020     case PutGlobalVar:
2021     case NotifyWrite:
2022         break;
2023             
2024     case CheckHasInstance:
2025         // Sadly, we don't propagate the fact that we've done CheckHasInstance
2026         break;
2027             
2028     case InstanceOf:
2029         // Again, sadly, we don't propagate the fact that we've done InstanceOf
2030         forNode(node).setType(SpecBoolean);
2031         break;
2032             
2033     case Phi:
2034         RELEASE_ASSERT(m_graph.m_form == SSA);
2035         // The state of this node would have already been decided, but it may have become a
2036         // constant, in which case we'd like to know.
2037         if (forNode(node).m_value)
2038             m_state.setFoundConstants(true);
2039         break;
2040         
2041     case Upsilon: {
2042         m_state.createValueForNode(node->phi());
2043         forNode(node->phi()) = forNode(node->child1());
2044         break;
2045     }
2046         
2047     case Flush:
2048     case PhantomLocal:
2049         break;
2050             
2051     case Call:
2052     case Construct:
2053     case NativeCall:
2054     case NativeConstruct:
2055     case CallVarargs:
2056     case CallForwardVarargs:
2057     case ConstructVarargs:
2058     case ConstructForwardVarargs:
2059         clobberWorld(node->origin.semantic, clobberLimit);
2060         forNode(node).makeHeapTop();
2061         break;
2062
2063     case ForceOSRExit:
2064     case CheckBadCell:
2065         m_state.setIsValid(false);
2066         break;
2067         
2068     case InvalidationPoint:
2069         forAllValues(clobberLimit, AbstractValue::observeInvalidationPointFor);
2070         m_state.setStructureClobberState(StructuresAreWatched);
2071         break;
2072
2073     case CheckWatchdogTimer:
2074         break;
2075
2076     case Breakpoint:
2077     case ProfileWillCall:
2078     case ProfileDidCall:
2079     case ProfileType:
2080     case ProfileControlFlow:
2081     case Phantom:
2082     case CountExecution:
2083     case CheckTierUpInLoop:
2084     case CheckTierUpAtReturn:
2085         break;
2086
2087     case Check: {
2088         // Simplify out checks that don't actually do checking.
2089         for (unsigned i = 0; i < AdjacencyList::Size; ++i) {
2090             Edge edge = node->children.child(i);
2091             if (!edge)
2092                 break;
2093             if (edge.isProved() || edge.willNotHaveCheck()) {
2094                 m_state.setFoundConstants(true);
2095                 break;
2096             }
2097         }
2098         break;
2099     }
2100
2101     case StoreBarrier: {
2102         filter(node->child1(), SpecCell);
2103         break;
2104     }
2105
2106     case StoreBarrierWithNullCheck: {
2107         break;
2108     }
2109
2110     case CheckTierUpAndOSREnter:
2111     case LoopHint:
2112     case ZombieHint:
2113         break;
2114
2115     case Unreachable:
2116     case LastNodeType:
2117     case ArithIMul:
2118     case FiatInt52:
2119         DFG_CRASH(m_graph, node, "Unexpected node type");
2120         break;
2121     }
2122     
2123     return m_state.isValid();
2124 }
2125
2126 template<typename AbstractStateType>
2127 bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned indexInBlock)
2128 {
2129     return executeEffects(indexInBlock, m_state.block()->at(indexInBlock));
2130 }
2131
2132 template<typename AbstractStateType>
2133 bool AbstractInterpreter<AbstractStateType>::execute(unsigned indexInBlock)
2134 {
2135     Node* node = m_state.block()->at(indexInBlock);
2136     
2137     startExecuting();
2138     executeEdges(node);
2139     return executeEffects(indexInBlock, node);
2140 }
2141
2142 template<typename AbstractStateType>
2143 bool AbstractInterpreter<AbstractStateType>::execute(Node* node)
2144 {
2145     startExecuting();
2146     executeEdges(node);
2147     return executeEffects(UINT_MAX, node);
2148 }
2149
2150 template<typename AbstractStateType>
2151 void AbstractInterpreter<AbstractStateType>::clobberWorld(
2152     const CodeOrigin&, unsigned clobberLimit)
2153 {
2154     clobberStructures(clobberLimit);
2155 }
2156
2157 template<typename AbstractStateType>
2158 template<typename Functor>
2159 void AbstractInterpreter<AbstractStateType>::forAllValues(
2160     unsigned clobberLimit, Functor& functor)
2161 {
2162     SamplingRegion samplingRegion("DFG AI For All Values");
2163     if (clobberLimit >= m_state.block()->size())
2164         clobberLimit = m_state.block()->size();
2165     else
2166         clobberLimit++;
2167     ASSERT(clobberLimit <= m_state.block()->size());
2168     for (size_t i = clobberLimit; i--;)
2169         functor(forNode(m_state.block()->at(i)));
2170     if (m_graph.m_form == SSA) {
2171         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtHead.begin();
2172         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtHead.end();
2173         for (; iter != end; ++iter)
2174             functor(forNode(*iter));
2175     }
2176     for (size_t i = m_state.variables().numberOfArguments(); i--;)
2177         functor(m_state.variables().argument(i));
2178     for (size_t i = m_state.variables().numberOfLocals(); i--;)
2179         functor(m_state.variables().local(i));
2180 }
2181
2182 template<typename AbstractStateType>
2183 void AbstractInterpreter<AbstractStateType>::clobberStructures(unsigned clobberLimit)
2184 {
2185     SamplingRegion samplingRegion("DFG AI Clobber Structures");
2186     forAllValues(clobberLimit, AbstractValue::clobberStructuresFor);
2187     setDidClobber();
2188 }
2189
2190 template<typename AbstractStateType>
2191 void AbstractInterpreter<AbstractStateType>::observeTransition(
2192     unsigned clobberLimit, Structure* from, Structure* to)
2193 {
2194     AbstractValue::TransitionObserver transitionObserver(from, to);
2195     forAllValues(clobberLimit, transitionObserver);
2196     
2197     ASSERT(!from->dfgShouldWatch()); // We don't need to claim to be in a clobbered state because 'from' was never watchable (during the time we were compiling), hence no constants ever introduced into the DFG IR that ever had a watchable structure would ever have the same structure as from.
2198 }
2199
2200 template<typename AbstractStateType>
2201 void AbstractInterpreter<AbstractStateType>::observeTransitions(
2202     unsigned clobberLimit, const TransitionVector& vector)
2203 {
2204     AbstractValue::TransitionsObserver transitionsObserver(vector);
2205     forAllValues(clobberLimit, transitionsObserver);
2206     
2207     if (!ASSERT_DISABLED) {
2208         // We don't need to claim to be in a clobbered state because none of the Transition::previous structures are watchable.
2209         for (unsigned i = vector.size(); i--;)
2210             ASSERT(!vector[i].previous->dfgShouldWatch());
2211     }
2212 }
2213
2214 template<typename AbstractStateType>
2215 void AbstractInterpreter<AbstractStateType>::setDidClobber()
2216 {
2217     m_state.setDidClobber(true);
2218     m_state.setStructureClobberState(StructuresAreClobbered);
2219 }
2220
2221 template<typename AbstractStateType>
2222 void AbstractInterpreter<AbstractStateType>::dump(PrintStream& out) const
2223 {
2224     const_cast<AbstractInterpreter<AbstractStateType>*>(this)->dump(out);
2225 }
2226
2227 template<typename AbstractStateType>
2228 void AbstractInterpreter<AbstractStateType>::dump(PrintStream& out)
2229 {
2230     CommaPrinter comma(" ");
2231     HashSet<Node*> seen;
2232     if (m_graph.m_form == SSA) {
2233         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtHead.begin();
2234         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtHead.end();
2235         for (; iter != end; ++iter) {
2236             Node* node = *iter;
2237             seen.add(node);
2238             AbstractValue& value = forNode(node);
2239             if (value.isClear())
2240                 continue;
2241             out.print(comma, node, ":", value);
2242         }
2243     }
2244     for (size_t i = 0; i < m_state.block()->size(); ++i) {
2245         Node* node = m_state.block()->at(i);
2246         seen.add(node);
2247         AbstractValue& value = forNode(node);
2248         if (value.isClear())
2249             continue;
2250         out.print(comma, node, ":", value);
2251     }
2252     if (m_graph.m_form == SSA) {
2253         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtTail.begin();
2254         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtTail.end();
2255         for (; iter != end; ++iter) {
2256             Node* node = *iter;
2257             if (seen.contains(node))
2258                 continue;
2259             AbstractValue& value = forNode(node);
2260             if (value.isClear())
2261                 continue;
2262             out.print(comma, node, ":", value);
2263         }
2264     }
2265 }
2266
2267 template<typename AbstractStateType>
2268 FiltrationResult AbstractInterpreter<AbstractStateType>::filter(
2269     AbstractValue& value, const StructureSet& set)
2270 {
2271     if (value.filter(m_graph, set) == FiltrationOK)
2272         return FiltrationOK;
2273     m_state.setIsValid(false);
2274     return Contradiction;
2275 }
2276
2277 template<typename AbstractStateType>
2278 FiltrationResult AbstractInterpreter<AbstractStateType>::filterArrayModes(
2279     AbstractValue& value, ArrayModes arrayModes)
2280 {
2281     if (value.filterArrayModes(arrayModes) == FiltrationOK)
2282         return FiltrationOK;
2283     m_state.setIsValid(false);
2284     return Contradiction;
2285 }
2286
2287 template<typename AbstractStateType>
2288 FiltrationResult AbstractInterpreter<AbstractStateType>::filter(
2289     AbstractValue& value, SpeculatedType type)
2290 {
2291     if (value.filter(type) == FiltrationOK)
2292         return FiltrationOK;
2293     m_state.setIsValid(false);
2294     return Contradiction;
2295 }
2296
2297 template<typename AbstractStateType>
2298 FiltrationResult AbstractInterpreter<AbstractStateType>::filterByValue(
2299     AbstractValue& abstractValue, FrozenValue concreteValue)
2300 {
2301     if (abstractValue.filterByValue(concreteValue) == FiltrationOK)
2302         return FiltrationOK;
2303     m_state.setIsValid(false);
2304     return Contradiction;
2305 }
2306
2307 } } // namespace JSC::DFG
2308
2309 #endif // ENABLE(DFG_JIT)
2310
2311 #endif // DFGAbstractInterpreterInlines_h
2312