Replace all of the various non-working and non-compiling sampling profiler hacks...
[WebKit-https.git] / Source / JavaScriptCore / dfg / DFGAbstractInterpreterInlines.h
1 /*
2  * Copyright (C) 2013-2016 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #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     // Some use kinds are required to not have checks, because we know somehow that the incoming
112     // value will already have the type we want. In those cases, AI may not be smart enough to
113     // prove that this is indeed the case.
114     if (shouldNotHaveTypeCheck(edge.useKind()))
115         return;
116     
117     if (!(forNode(edge).m_type & ~typeFilterFor(edge.useKind())))
118         return;
119     
120     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());
121 }
122
123 template<typename AbstractStateType>
124 void AbstractInterpreter<AbstractStateType>::verifyEdges(Node* node)
125 {
126     DFG_NODE_DO_TO_CHILDREN(m_graph, node, verifyEdge);
127 }
128
129 template<typename AbstractStateType>
130 bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned clobberLimit, Node* node)
131 {
132     if (!ASSERT_DISABLED)
133         verifyEdges(node);
134     
135     m_state.createValueForNode(node);
136     
137     switch (node->op()) {
138     case JSConstant:
139     case DoubleConstant:
140     case Int52Constant: {
141         setBuiltInConstant(node, *node->constant());
142         break;
143     }
144
145     case LazyJSConstant: {
146         LazyJSValue value = node->lazyJSValue();
147         switch (value.kind()) {
148         case LazyJSValue::KnownValue:
149             setConstant(node, value.value()->value());
150             break;
151         case LazyJSValue::SingleCharacterString:
152         case LazyJSValue::KnownStringImpl:
153         case LazyJSValue::NewStringImpl:
154             forNode(node).setType(m_graph, SpecString);
155             break;
156         }
157         break;
158     }
159         
160     case Identity: {
161         forNode(node) = forNode(node->child1());
162         if (forNode(node).value())
163             m_state.setFoundConstants(true);
164         break;
165     }
166         
167     case ExtractOSREntryLocal: {
168         forNode(node).makeBytecodeTop();
169         break;
170     }
171             
172     case GetLocal: {
173         VariableAccessData* variableAccessData = node->variableAccessData();
174         AbstractValue value = m_state.variables().operand(variableAccessData->local().offset());
175         // The value in the local should already be checked.
176         DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(variableAccessData->flushFormat())));
177         if (value.value())
178             m_state.setFoundConstants(true);
179         forNode(node) = value;
180         break;
181     }
182         
183     case GetStack: {
184         StackAccessData* data = node->stackAccessData();
185         AbstractValue value = m_state.variables().operand(data->local);
186         // The value in the local should already be checked.
187         DFG_ASSERT(m_graph, node, value.isType(typeFilterFor(data->format)));
188         if (value.value())
189             m_state.setFoundConstants(true);
190         forNode(node) = value;
191         break;
192     }
193         
194     case GetLocalUnlinked: {
195         AbstractValue value = m_state.variables().operand(node->unlinkedLocal().offset());
196         if (value.value())
197             m_state.setFoundConstants(true);
198         forNode(node) = value;
199         break;
200     }
201         
202     case SetLocal: {
203         m_state.variables().operand(node->local()) = forNode(node->child1());
204         break;
205     }
206         
207     case PutStack: {
208         m_state.variables().operand(node->stackAccessData()->local) = forNode(node->child1());
209         break;
210     }
211         
212     case MovHint: {
213         // Don't need to do anything. A MovHint only informs us about what would have happened
214         // in bytecode, but this code is just concerned with what is actually happening during
215         // DFG execution.
216         break;
217     }
218         
219     case KillStack: {
220         // This is just a hint telling us that the OSR state of the local is no longer inside the
221         // flushed data.
222         break;
223     }
224         
225     case SetArgument:
226         // Assert that the state of arguments has been set. SetArgument means that someone set
227         // the argument values out-of-band, and currently this always means setting to a
228         // non-clear value.
229         ASSERT(!m_state.variables().operand(node->local()).isClear());
230         break;
231         
232     case LoadVarargs:
233     case ForwardVarargs: {
234         // FIXME: ForwardVarargs should check if the count becomes known, and if it does, it should turn
235         // itself into a straight-line sequence of GetStack/PutStack.
236         // https://bugs.webkit.org/show_bug.cgi?id=143071
237         clobberWorld(node->origin.semantic, clobberLimit);
238         LoadVarargsData* data = node->loadVarargsData();
239         m_state.variables().operand(data->count).setType(SpecInt32);
240         for (unsigned i = data->limit - 1; i--;)
241             m_state.variables().operand(data->start.offset() + i).makeHeapTop();
242         break;
243     }
244             
245     case BitAnd:
246     case BitOr:
247     case BitXor:
248     case BitRShift:
249     case BitLShift:
250     case BitURShift: {
251         if (node->child1().useKind() == UntypedUse || node->child2().useKind() == UntypedUse) {
252             clobberWorld(node->origin.semantic, clobberLimit);
253             forNode(node).setType(m_graph, SpecInt32);
254             break;
255         }
256
257         JSValue left = forNode(node->child1()).value();
258         JSValue right = forNode(node->child2()).value();
259         if (left && right && left.isInt32() && right.isInt32()) {
260             int32_t a = left.asInt32();
261             int32_t b = right.asInt32();
262             switch (node->op()) {
263             case BitAnd:
264                 setConstant(node, JSValue(a & b));
265                 break;
266             case BitOr:
267                 setConstant(node, JSValue(a | b));
268                 break;
269             case BitXor:
270                 setConstant(node, JSValue(a ^ b));
271                 break;
272             case BitRShift:
273                 setConstant(node, JSValue(a >> static_cast<uint32_t>(b)));
274                 break;
275             case BitLShift:
276                 setConstant(node, JSValue(a << static_cast<uint32_t>(b)));
277                 break;
278             case BitURShift:
279                 setConstant(node, JSValue(static_cast<uint32_t>(a) >> static_cast<uint32_t>(b)));
280                 break;
281             default:
282                 RELEASE_ASSERT_NOT_REACHED();
283                 break;
284             }
285             break;
286         }
287         
288         if (node->op() == BitAnd
289             && (isBoolInt32Speculation(forNode(node->child1()).m_type) ||
290                 isBoolInt32Speculation(forNode(node->child2()).m_type))) {
291             forNode(node).setType(SpecBoolInt32);
292             break;
293         }
294         
295         forNode(node).setType(SpecInt32);
296         break;
297     }
298         
299     case UInt32ToNumber: {
300         JSValue child = forNode(node->child1()).value();
301         if (doesOverflow(node->arithMode())) {
302             if (child && child.isInt32()) {
303                 uint32_t value = child.asInt32();
304                 setConstant(node, jsNumber(value));
305                 break;
306             }
307             forNode(node).setType(SpecInt52AsDouble);
308             break;
309         }
310         if (child && child.isInt32()) {
311             int32_t value = child.asInt32();
312             if (value >= 0) {
313                 setConstant(node, jsNumber(value));
314                 break;
315             }
316         }
317         forNode(node).setType(SpecInt32);
318         break;
319     }
320         
321     case BooleanToNumber: {
322         JSValue concreteValue = forNode(node->child1()).value();
323         if (concreteValue) {
324             if (concreteValue.isBoolean())
325                 setConstant(node, jsNumber(concreteValue.asBoolean()));
326             else
327                 setConstant(node, *m_graph.freeze(concreteValue));
328             break;
329         }
330         AbstractValue& value = forNode(node);
331         value = forNode(node->child1());
332         if (node->child1().useKind() == UntypedUse && !(value.m_type & ~SpecBoolean))
333             m_state.setFoundConstants(true);
334         if (value.m_type & SpecBoolean) {
335             value.merge(SpecBoolInt32);
336             value.filter(~SpecBoolean);
337         }
338         break;
339     }
340             
341     case DoubleAsInt32: {
342         JSValue child = forNode(node->child1()).value();
343         if (child && child.isNumber()) {
344             double asDouble = child.asNumber();
345             int32_t asInt = JSC::toInt32(asDouble);
346             if (bitwise_cast<int64_t>(static_cast<double>(asInt)) == bitwise_cast<int64_t>(asDouble)) {
347                 setConstant(node, JSValue(asInt));
348                 break;
349             }
350         }
351         forNode(node).setType(SpecInt32);
352         break;
353     }
354             
355     case ValueToInt32: {
356         JSValue child = forNode(node->child1()).value();
357         if (child) {
358             if (child.isNumber()) {
359                 if (child.isInt32())
360                     setConstant(node, child);
361                 else
362                     setConstant(node, JSValue(JSC::toInt32(child.asDouble())));
363                 break;
364             }
365             if (child.isBoolean()) {
366                 setConstant(node, jsNumber(child.asBoolean()));
367                 break;
368             }
369             if (child.isUndefinedOrNull()) {
370                 setConstant(node, jsNumber(0));
371                 break;
372             }
373         }
374         
375         if (isBooleanSpeculation(forNode(node->child1()).m_type)) {
376             forNode(node).setType(SpecBoolInt32);
377             break;
378         }
379         
380         forNode(node).setType(SpecInt32);
381         break;
382     }
383         
384     case DoubleRep: {
385         JSValue child = forNode(node->child1()).value();
386         if (child && child.isNumber()) {
387             setConstant(node, jsDoubleNumber(child.asNumber()));
388             break;
389         }
390
391         SpeculatedType type = forNode(node->child1()).m_type;
392         switch (node->child1().useKind()) {
393         case NotCellUse: {
394             if (type & SpecOther) {
395                 type &= ~SpecOther;
396                 type |= SpecDoublePureNaN | SpecBoolInt32; // Null becomes zero, undefined becomes NaN.
397             }
398             if (type & SpecBoolean) {
399                 type &= ~SpecBoolean;
400                 type |= SpecBoolInt32; // True becomes 1, false becomes 0.
401             }
402             type &= SpecBytecodeNumber;
403             break;
404         }
405
406         case Int52RepUse:
407         case NumberUse:
408         case RealNumberUse:
409             break;
410
411         default:
412             RELEASE_ASSERT_NOT_REACHED();
413         }
414         forNode(node).setType(type);
415         forNode(node).fixTypeForRepresentation(m_graph, node);
416         break;
417     }
418         
419     case Int52Rep: {
420         JSValue child = forNode(node->child1()).value();
421         if (child && child.isMachineInt()) {
422             setConstant(node, child);
423             break;
424         }
425         
426         forNode(node).setType(SpecInt32);
427         break;
428     }
429         
430     case ValueRep: {
431         JSValue value = forNode(node->child1()).value();
432         if (value) {
433             setConstant(node, value);
434             break;
435         }
436         
437         forNode(node).setType(m_graph, forNode(node->child1()).m_type & ~SpecDoubleImpureNaN);
438         forNode(node).fixTypeForRepresentation(m_graph, node);
439         break;
440     }
441         
442     case ValueAdd: {
443         ASSERT(node->binaryUseKind() == UntypedUse);
444         clobberWorld(node->origin.semantic, clobberLimit);
445         forNode(node).setType(m_graph, SpecString | SpecBytecodeNumber);
446         break;
447     }
448
449     case StrCat: {
450         forNode(node).setType(m_graph, SpecString);
451         break;
452     }
453         
454     case ArithAdd: {
455         JSValue left = forNode(node->child1()).value();
456         JSValue right = forNode(node->child2()).value();
457         switch (node->binaryUseKind()) {
458         case Int32Use:
459             if (left && right && left.isInt32() && right.isInt32()) {
460                 if (!shouldCheckOverflow(node->arithMode())) {
461                     setConstant(node, jsNumber(left.asInt32() + right.asInt32()));
462                     break;
463                 }
464                 JSValue result = jsNumber(left.asNumber() + right.asNumber());
465                 if (result.isInt32()) {
466                     setConstant(node, result);
467                     break;
468                 }
469             }
470             forNode(node).setType(SpecInt32);
471             break;
472         case Int52RepUse:
473             if (left && right && left.isMachineInt() && right.isMachineInt()) {
474                 JSValue result = jsNumber(left.asMachineInt() + right.asMachineInt());
475                 if (result.isMachineInt()) {
476                     setConstant(node, result);
477                     break;
478                 }
479             }
480             forNode(node).setType(SpecMachineInt);
481             break;
482         case DoubleRepUse:
483             if (left && right && left.isNumber() && right.isNumber()) {
484                 setConstant(node, jsDoubleNumber(left.asNumber() + right.asNumber()));
485                 break;
486             }
487             forNode(node).setType(
488                 typeOfDoubleSum(
489                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
490             break;
491         default:
492             RELEASE_ASSERT_NOT_REACHED();
493             break;
494         }
495         break;
496     }
497
498     case ArithClz32: {
499         JSValue operand = forNode(node->child1()).value();
500         if (operand && operand.isNumber()) {
501             uint32_t value = toUInt32(operand.asNumber());
502             setConstant(node, jsNumber(clz32(value)));
503             break;
504         }
505         forNode(node).setType(SpecInt32);
506         break;
507     }
508
509     case MakeRope: {
510         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
511         break;
512     }
513             
514     case ArithSub: {
515         JSValue left = forNode(node->child1()).value();
516         JSValue right = forNode(node->child2()).value();
517         switch (node->binaryUseKind()) {
518         case Int32Use:
519             if (left && right && left.isInt32() && right.isInt32()) {
520                 if (!shouldCheckOverflow(node->arithMode())) {
521                     setConstant(node, jsNumber(left.asInt32() - right.asInt32()));
522                     break;
523                 }
524                 JSValue result = jsNumber(left.asNumber() - right.asNumber());
525                 if (result.isInt32()) {
526                     setConstant(node, result);
527                     break;
528                 }
529             }
530             forNode(node).setType(SpecInt32);
531             break;
532         case Int52RepUse:
533             if (left && right && left.isMachineInt() && right.isMachineInt()) {
534                 JSValue result = jsNumber(left.asMachineInt() - right.asMachineInt());
535                 if (result.isMachineInt() || !shouldCheckOverflow(node->arithMode())) {
536                     setConstant(node, result);
537                     break;
538                 }
539             }
540             forNode(node).setType(SpecMachineInt);
541             break;
542         case DoubleRepUse:
543             if (left && right && left.isNumber() && right.isNumber()) {
544                 setConstant(node, jsDoubleNumber(left.asNumber() - right.asNumber()));
545                 break;
546             }
547             forNode(node).setType(
548                 typeOfDoubleDifference(
549                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
550             break;
551         case UntypedUse:
552             clobberWorld(node->origin.semantic, clobberLimit);
553             forNode(node).setType(m_graph, SpecBytecodeNumber);
554             break;
555         default:
556             RELEASE_ASSERT_NOT_REACHED();
557             break;
558         }
559         break;
560     }
561         
562     case ArithNegate: {
563         JSValue child = forNode(node->child1()).value();
564         switch (node->child1().useKind()) {
565         case Int32Use:
566             if (child && child.isInt32()) {
567                 if (!shouldCheckOverflow(node->arithMode())) {
568                     setConstant(node, jsNumber(-child.asInt32()));
569                     break;
570                 }
571                 double doubleResult;
572                 if (shouldCheckNegativeZero(node->arithMode()))
573                     doubleResult = -child.asNumber();
574                 else
575                     doubleResult = 0 - child.asNumber();
576                 JSValue valueResult = jsNumber(doubleResult);
577                 if (valueResult.isInt32()) {
578                     setConstant(node, valueResult);
579                     break;
580                 }
581             }
582             forNode(node).setType(SpecInt32);
583             break;
584         case Int52RepUse:
585             if (child && child.isMachineInt()) {
586                 double doubleResult;
587                 if (shouldCheckNegativeZero(node->arithMode()))
588                     doubleResult = -child.asNumber();
589                 else
590                     doubleResult = 0 - child.asNumber();
591                 JSValue valueResult = jsNumber(doubleResult);
592                 if (valueResult.isMachineInt()) {
593                     setConstant(node, valueResult);
594                     break;
595                 }
596             }
597             forNode(node).setType(SpecMachineInt);
598             break;
599         case DoubleRepUse:
600             if (child && child.isNumber()) {
601                 setConstant(node, jsDoubleNumber(-child.asNumber()));
602                 break;
603             }
604             forNode(node).setType(
605                 typeOfDoubleNegation(
606                     forNode(node->child1()).m_type));
607             break;
608         default:
609             RELEASE_ASSERT_NOT_REACHED();
610             break;
611         }
612         break;
613     }
614         
615     case ArithMul: {
616         JSValue left = forNode(node->child1()).value();
617         JSValue right = forNode(node->child2()).value();
618         switch (node->binaryUseKind()) {
619         case Int32Use:
620             if (left && right && left.isInt32() && right.isInt32()) {
621                 if (!shouldCheckOverflow(node->arithMode())) {
622                     setConstant(node, jsNumber(left.asInt32() * right.asInt32()));
623                     break;
624                 }
625                 double doubleResult = left.asNumber() * right.asNumber();
626                 if (!shouldCheckNegativeZero(node->arithMode()))
627                     doubleResult += 0; // Sanitizes zero.
628                 JSValue valueResult = jsNumber(doubleResult);
629                 if (valueResult.isInt32()) {
630                     setConstant(node, valueResult);
631                     break;
632                 }
633             }
634             forNode(node).setType(SpecInt32);
635             break;
636         case Int52RepUse:
637             if (left && right && left.isMachineInt() && right.isMachineInt()) {
638                 double doubleResult = left.asNumber() * right.asNumber();
639                 if (!shouldCheckNegativeZero(node->arithMode()))
640                     doubleResult += 0;
641                 JSValue valueResult = jsNumber(doubleResult);
642                 if (valueResult.isMachineInt()) {
643                     setConstant(node, valueResult);
644                     break;
645                 }
646             }
647             forNode(node).setType(SpecMachineInt);
648             break;
649         case DoubleRepUse:
650             if (left && right && left.isNumber() && right.isNumber()) {
651                 setConstant(node, jsDoubleNumber(left.asNumber() * right.asNumber()));
652                 break;
653             }
654             forNode(node).setType(
655                 typeOfDoubleProduct(
656                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
657             break;
658         case UntypedUse:
659             clobberWorld(node->origin.semantic, clobberLimit);
660             forNode(node).setType(m_graph, SpecBytecodeNumber);
661             break;
662         default:
663             RELEASE_ASSERT_NOT_REACHED();
664             break;
665         }
666         break;
667     }
668         
669     case ArithDiv: {
670         JSValue left = forNode(node->child1()).value();
671         JSValue right = forNode(node->child2()).value();
672         switch (node->binaryUseKind()) {
673         case Int32Use:
674             if (left && right && left.isInt32() && right.isInt32()) {
675                 double doubleResult = left.asNumber() / right.asNumber();
676                 if (!shouldCheckOverflow(node->arithMode()))
677                     doubleResult = toInt32(doubleResult);
678                 else if (!shouldCheckNegativeZero(node->arithMode()))
679                     doubleResult += 0; // Sanitizes zero.
680                 JSValue valueResult = jsNumber(doubleResult);
681                 if (valueResult.isInt32()) {
682                     setConstant(node, valueResult);
683                     break;
684                 }
685             }
686             forNode(node).setType(SpecInt32);
687             break;
688         case DoubleRepUse:
689             if (left && right && left.isNumber() && right.isNumber()) {
690                 setConstant(node, jsDoubleNumber(left.asNumber() / right.asNumber()));
691                 break;
692             }
693             forNode(node).setType(
694                 typeOfDoubleQuotient(
695                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
696             break;
697         case UntypedUse:
698             clobberWorld(node->origin.semantic, clobberLimit);
699             forNode(node).setType(m_graph, SpecBytecodeNumber);
700             break;
701         default:
702             RELEASE_ASSERT_NOT_REACHED();
703             break;
704         }
705         break;
706     }
707
708     case ArithMod: {
709         JSValue left = forNode(node->child1()).value();
710         JSValue right = forNode(node->child2()).value();
711         switch (node->binaryUseKind()) {
712         case Int32Use:
713             if (left && right && left.isInt32() && right.isInt32()) {
714                 double doubleResult = fmod(left.asNumber(), right.asNumber());
715                 if (!shouldCheckOverflow(node->arithMode()))
716                     doubleResult = toInt32(doubleResult);
717                 else if (!shouldCheckNegativeZero(node->arithMode()))
718                     doubleResult += 0; // Sanitizes zero.
719                 JSValue valueResult = jsNumber(doubleResult);
720                 if (valueResult.isInt32()) {
721                     setConstant(node, valueResult);
722                     break;
723                 }
724             }
725             forNode(node).setType(SpecInt32);
726             break;
727         case DoubleRepUse:
728             if (left && right && left.isNumber() && right.isNumber()) {
729                 setConstant(node, jsDoubleNumber(fmod(left.asNumber(), right.asNumber())));
730                 break;
731             }
732             forNode(node).setType(
733                 typeOfDoubleBinaryOp(
734                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
735             break;
736         default:
737             RELEASE_ASSERT_NOT_REACHED();
738             break;
739         }
740         break;
741     }
742
743     case ArithMin: {
744         JSValue left = forNode(node->child1()).value();
745         JSValue right = forNode(node->child2()).value();
746         switch (node->binaryUseKind()) {
747         case Int32Use:
748             if (left && right && left.isInt32() && right.isInt32()) {
749                 setConstant(node, jsNumber(std::min(left.asInt32(), right.asInt32())));
750                 break;
751             }
752             forNode(node).setType(SpecInt32);
753             break;
754         case DoubleRepUse:
755             if (left && right && left.isNumber() && right.isNumber()) {
756                 double a = left.asNumber();
757                 double b = right.asNumber();
758                 setConstant(node, jsDoubleNumber(a < b ? a : (b <= a ? b : a + b)));
759                 break;
760             }
761             forNode(node).setType(
762                 typeOfDoubleMinMax(
763                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
764             break;
765         default:
766             RELEASE_ASSERT_NOT_REACHED();
767             break;
768         }
769         break;
770     }
771             
772     case ArithMax: {
773         JSValue left = forNode(node->child1()).value();
774         JSValue right = forNode(node->child2()).value();
775         switch (node->binaryUseKind()) {
776         case Int32Use:
777             if (left && right && left.isInt32() && right.isInt32()) {
778                 setConstant(node, jsNumber(std::max(left.asInt32(), right.asInt32())));
779                 break;
780             }
781             forNode(node).setType(SpecInt32);
782             break;
783         case DoubleRepUse:
784             if (left && right && left.isNumber() && right.isNumber()) {
785                 double a = left.asNumber();
786                 double b = right.asNumber();
787                 setConstant(node, jsDoubleNumber(a > b ? a : (b >= a ? b : a + b)));
788                 break;
789             }
790             forNode(node).setType(
791                 typeOfDoubleMinMax(
792                     forNode(node->child1()).m_type, forNode(node->child2()).m_type));
793             break;
794         default:
795             RELEASE_ASSERT_NOT_REACHED();
796             break;
797         }
798         break;
799     }
800             
801     case ArithAbs: {
802         JSValue child = forNode(node->child1()).value();
803         switch (node->child1().useKind()) {
804         case Int32Use:
805             if (child && child.isInt32()) {
806                 JSValue result = jsNumber(fabs(child.asNumber()));
807                 if (result.isInt32()) {
808                     setConstant(node, result);
809                     break;
810                 }
811             }
812             forNode(node).setType(SpecInt32);
813             break;
814         case DoubleRepUse:
815             if (child && child.isNumber()) {
816                 setConstant(node, jsDoubleNumber(fabs(child.asNumber())));
817                 break;
818             }
819             forNode(node).setType(typeOfDoubleAbs(forNode(node->child1()).m_type));
820             break;
821         default:
822             RELEASE_ASSERT_NOT_REACHED();
823             break;
824         }
825         break;
826     }
827
828     case ArithPow: {
829         JSValue childY = forNode(node->child2()).value();
830         if (childY && childY.isNumber()) {
831             if (!childY.asNumber()) {
832                 setConstant(node, jsDoubleNumber(1));
833                 break;
834             }
835
836             JSValue childX = forNode(node->child1()).value();
837             if (childX && childX.isNumber()) {
838                 setConstant(node, jsDoubleNumber(operationMathPow(childX.asNumber(), childY.asNumber())));
839                 break;
840             }
841         }
842         forNode(node).setType(typeOfDoublePow(forNode(node->child1()).m_type, forNode(node->child2()).m_type));
843         break;
844     }
845
846     case ArithRandom: {
847         forNode(node).setType(m_graph, SpecDoubleReal);
848         break;
849     }
850
851     case ArithRound:
852     case ArithFloor:
853     case ArithCeil: {
854         JSValue operand = forNode(node->child1()).value();
855         if (operand && operand.isNumber()) {
856             double roundedValue = 0;
857             if (node->op() == ArithRound)
858                 roundedValue = jsRound(operand.asNumber());
859             else if (node->op() == ArithFloor)
860                 roundedValue = floor(operand.asNumber());
861             else {
862                 ASSERT(node->op() == ArithCeil);
863                 roundedValue = ceil(operand.asNumber());
864             }
865
866             if (producesInteger(node->arithRoundingMode())) {
867                 int32_t roundedValueAsInt32 = static_cast<int32_t>(roundedValue);
868                 if (roundedValueAsInt32 == roundedValue) {
869                     if (shouldCheckNegativeZero(node->arithRoundingMode())) {
870                         if (roundedValueAsInt32 || !std::signbit(roundedValue)) {
871                             setConstant(node, jsNumber(roundedValueAsInt32));
872                             break;
873                         }
874                     } else {
875                         setConstant(node, jsNumber(roundedValueAsInt32));
876                         break;
877                     }
878                 }
879             } else {
880                 setConstant(node, jsDoubleNumber(roundedValue));
881                 break;
882             }
883         }
884         if (producesInteger(node->arithRoundingMode()))
885             forNode(node).setType(SpecInt32);
886         else
887             forNode(node).setType(typeOfDoubleRounding(forNode(node->child1()).m_type));
888         break;
889     }
890             
891     case ArithSqrt: {
892         JSValue child = forNode(node->child1()).value();
893         if (child && child.isNumber()) {
894             setConstant(node, jsDoubleNumber(sqrt(child.asNumber())));
895             break;
896         }
897         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
898         break;
899     }
900         
901     case ArithFRound: {
902         JSValue child = forNode(node->child1()).value();
903         if (child && child.isNumber()) {
904             setConstant(node, jsDoubleNumber(static_cast<float>(child.asNumber())));
905             break;
906         }
907         forNode(node).setType(typeOfDoubleRounding(forNode(node->child1()).m_type));
908         break;
909     }
910         
911     case ArithSin: {
912         JSValue child = forNode(node->child1()).value();
913         if (child && child.isNumber()) {
914             setConstant(node, jsDoubleNumber(sin(child.asNumber())));
915             break;
916         }
917         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
918         break;
919     }
920     
921     case ArithCos: {
922         JSValue child = forNode(node->child1()).value();
923         if (child && child.isNumber()) {
924             setConstant(node, jsDoubleNumber(cos(child.asNumber())));
925             break;
926         }
927         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
928         break;
929     }
930
931     case ArithLog: {
932         JSValue child = forNode(node->child1()).value();
933         if (child && child.isNumber()) {
934             setConstant(node, jsDoubleNumber(log(child.asNumber())));
935             break;
936         }
937         forNode(node).setType(typeOfDoubleUnaryOp(forNode(node->child1()).m_type));
938         break;
939     }
940             
941     case LogicalNot: {
942         switch (booleanResult(node, forNode(node->child1()))) {
943         case DefinitelyTrue:
944             setConstant(node, jsBoolean(false));
945             break;
946         case DefinitelyFalse:
947             setConstant(node, jsBoolean(true));
948             break;
949         default:
950             forNode(node).setType(SpecBoolean);
951             break;
952         }
953         break;
954     }
955         
956     case IsUndefined:
957     case IsBoolean:
958     case IsNumber:
959     case IsString:
960     case IsObject:
961     case IsObjectOrNull:
962     case IsFunction: {
963         AbstractValue child = forNode(node->child1());
964         if (child.value()) {
965             bool constantWasSet = true;
966             switch (node->op()) {
967             case IsUndefined:
968                 setConstant(node, jsBoolean(
969                     child.value().isCell()
970                     ? child.value().asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))
971                     : child.value().isUndefined()));
972                 break;
973             case IsBoolean:
974                 setConstant(node, jsBoolean(child.value().isBoolean()));
975                 break;
976             case IsNumber:
977                 setConstant(node, jsBoolean(child.value().isNumber()));
978                 break;
979             case IsString:
980                 setConstant(node, jsBoolean(isJSString(child.value())));
981                 break;
982             case IsObject:
983                 setConstant(node, jsBoolean(child.value().isObject()));
984                 break;
985             case IsObjectOrNull:
986                 if (child.value().isObject()) {
987                     JSObject* object = asObject(child.value());
988                     if (object->type() == JSFunctionType)
989                         setConstant(node, jsBoolean(false));
990                     else if (!(object->inlineTypeFlags() & TypeOfShouldCallGetCallData))
991                         setConstant(node, jsBoolean(!child.value().asCell()->structure()->masqueradesAsUndefined(m_codeBlock->globalObjectFor(node->origin.semantic))));
992                     else {
993                         // FIXME: This could just call getCallData.
994                         // https://bugs.webkit.org/show_bug.cgi?id=144457
995                         constantWasSet = false;
996                     }
997                 } else
998                     setConstant(node, jsBoolean(child.value().isNull()));
999                 break;
1000             case IsFunction:
1001                 if (child.value().isObject()) {
1002                     JSObject* object = asObject(child.value());
1003                     if (object->type() == JSFunctionType)
1004                         setConstant(node, jsBoolean(true));
1005                     else if (!(object->inlineTypeFlags() & TypeOfShouldCallGetCallData))
1006                         setConstant(node, jsBoolean(false));
1007                     else {
1008                         // FIXME: This could just call getCallData.
1009                         // https://bugs.webkit.org/show_bug.cgi?id=144457
1010                         constantWasSet = false;
1011                     }
1012                 } else
1013                     setConstant(node, jsBoolean(false));
1014                 break;
1015             default:
1016                 constantWasSet = false;
1017                 break;
1018             }
1019             if (constantWasSet)
1020                 break;
1021         }
1022         
1023         // FIXME: This code should really use AbstractValue::isType() and
1024         // AbstractValue::couldBeType().
1025         // https://bugs.webkit.org/show_bug.cgi?id=146870
1026         
1027         bool constantWasSet = false;
1028         switch (node->op()) {
1029         case IsUndefined:
1030             // FIXME: Use the masquerades-as-undefined watchpoint thingy.
1031             // https://bugs.webkit.org/show_bug.cgi?id=144456
1032             
1033             if (!(child.m_type & (SpecOther | SpecObjectOther))) {
1034                 setConstant(node, jsBoolean(false));
1035                 constantWasSet = true;
1036                 break;
1037             }
1038             
1039             break;
1040         case IsBoolean:
1041             if (!(child.m_type & ~SpecBoolean)) {
1042                 setConstant(node, jsBoolean(true));
1043                 constantWasSet = true;
1044                 break;
1045             }
1046             
1047             if (!(child.m_type & SpecBoolean)) {
1048                 setConstant(node, jsBoolean(false));
1049                 constantWasSet = true;
1050                 break;
1051             }
1052             
1053             break;
1054         case IsNumber:
1055             if (!(child.m_type & ~SpecFullNumber)) {
1056                 setConstant(node, jsBoolean(true));
1057                 constantWasSet = true;
1058                 break;
1059             }
1060             
1061             if (!(child.m_type & SpecFullNumber)) {
1062                 setConstant(node, jsBoolean(false));
1063                 constantWasSet = true;
1064                 break;
1065             }
1066             
1067             break;
1068         case IsString:
1069             if (!(child.m_type & ~SpecString)) {
1070                 setConstant(node, jsBoolean(true));
1071                 constantWasSet = true;
1072                 break;
1073             }
1074             
1075             if (!(child.m_type & SpecString)) {
1076                 setConstant(node, jsBoolean(false));
1077                 constantWasSet = true;
1078                 break;
1079             }
1080             
1081             break;
1082         case IsObject:
1083             if (!(child.m_type & ~SpecObject)) {
1084                 setConstant(node, jsBoolean(true));
1085                 constantWasSet = true;
1086                 break;
1087             }
1088             
1089             if (!(child.m_type & SpecObject)) {
1090                 setConstant(node, jsBoolean(false));
1091                 constantWasSet = true;
1092                 break;
1093             }
1094             
1095             break;
1096         case IsObjectOrNull:
1097             // FIXME: Use the masquerades-as-undefined watchpoint thingy.
1098             // https://bugs.webkit.org/show_bug.cgi?id=144456
1099             
1100             // These expressions are complicated to parse. A helpful way to parse this is that
1101             // "!(T & ~S)" means "T is a subset of S". Conversely, "!(T & S)" means "T is a
1102             // disjoint set from S". Things like "T - S" means that, provided that S is a
1103             // subset of T, it's the "set of all things in T but not in S". Things like "T | S"
1104             // mean the "union of T and S".
1105             
1106             // Is the child's type an object that isn't an other-object (i.e. object that could
1107             // have masquaredes-as-undefined traps) and isn't a function?  Then: we should fold
1108             // this to true.
1109             if (!(child.m_type & ~(SpecObject - SpecObjectOther - SpecFunction))) {
1110                 setConstant(node, jsBoolean(true));
1111                 constantWasSet = true;
1112                 break;
1113             }
1114             
1115             // Is the child's type definitely not either of: an object that isn't a function,
1116             // or either undefined or null?  Then: we should fold this to false.  This means
1117             // for example that if it's any non-function object, including those that have
1118             // masquerades-as-undefined traps, then we don't fold. It also means we won't fold
1119             // if it's undefined-or-null, since the type bits don't distinguish between
1120             // undefined (which should fold to false) and null (which should fold to true).
1121             if (!(child.m_type & ((SpecObject - SpecFunction) | SpecOther))) {
1122                 setConstant(node, jsBoolean(false));
1123                 constantWasSet = true;
1124                 break;
1125             }
1126             
1127             break;
1128         case IsFunction:
1129             if (!(child.m_type & ~SpecFunction)) {
1130                 setConstant(node, jsBoolean(true));
1131                 constantWasSet = true;
1132                 break;
1133             }
1134             
1135             if (!(child.m_type & (SpecFunction | SpecObjectOther))) {
1136                 setConstant(node, jsBoolean(false));
1137                 constantWasSet = true;
1138                 break;
1139             }
1140             break;
1141         default:
1142             break;
1143         }
1144         if (constantWasSet)
1145             break;
1146         
1147         forNode(node).setType(SpecBoolean);
1148         break;
1149     }
1150
1151     case TypeOf: {
1152         VM* vm = m_codeBlock->vm();
1153         JSValue child = forNode(node->child1()).value();
1154         AbstractValue& abstractChild = forNode(node->child1());
1155         if (child) {
1156             JSValue typeString = jsTypeStringForValue(*vm, m_codeBlock->globalObjectFor(node->origin.semantic), child);
1157             setConstant(node, *m_graph.freeze(typeString));
1158             break;
1159         }
1160         
1161         if (isFullNumberSpeculation(abstractChild.m_type)) {
1162             setConstant(node, *m_graph.freeze(vm->smallStrings.numberString()));
1163             break;
1164         }
1165         
1166         if (isStringSpeculation(abstractChild.m_type)) {
1167             setConstant(node, *m_graph.freeze(vm->smallStrings.stringString()));
1168             break;
1169         }
1170
1171         // FIXME: We could use the masquerades-as-undefined watchpoint here.
1172         // https://bugs.webkit.org/show_bug.cgi?id=144456
1173         if (!(abstractChild.m_type & ~(SpecObject - SpecObjectOther))) {
1174             setConstant(node, *m_graph.freeze(vm->smallStrings.objectString()));
1175             break;
1176         }
1177         
1178         if (isFunctionSpeculation(abstractChild.m_type)) {
1179             setConstant(node, *m_graph.freeze(vm->smallStrings.functionString()));
1180             break;
1181         }
1182         
1183         if (isBooleanSpeculation(abstractChild.m_type)) {
1184             setConstant(node, *m_graph.freeze(vm->smallStrings.booleanString()));
1185             break;
1186         }
1187
1188         if (isSymbolSpeculation(abstractChild.m_type)) {
1189             setConstant(node, *m_graph.freeze(vm->smallStrings.symbolString()));
1190             break;
1191         }
1192
1193         forNode(node).setType(m_graph, SpecStringIdent);
1194         break;
1195     }
1196             
1197     case CompareLess:
1198     case CompareLessEq:
1199     case CompareGreater:
1200     case CompareGreaterEq:
1201     case CompareEq: {
1202         JSValue leftConst = forNode(node->child1()).value();
1203         JSValue rightConst = forNode(node->child2()).value();
1204         if (leftConst && rightConst) {
1205             if (leftConst.isNumber() && rightConst.isNumber()) {
1206                 double a = leftConst.asNumber();
1207                 double b = rightConst.asNumber();
1208                 switch (node->op()) {
1209                 case CompareLess:
1210                     setConstant(node, jsBoolean(a < b));
1211                     break;
1212                 case CompareLessEq:
1213                     setConstant(node, jsBoolean(a <= b));
1214                     break;
1215                 case CompareGreater:
1216                     setConstant(node, jsBoolean(a > b));
1217                     break;
1218                 case CompareGreaterEq:
1219                     setConstant(node, jsBoolean(a >= b));
1220                     break;
1221                 case CompareEq:
1222                     setConstant(node, jsBoolean(a == b));
1223                     break;
1224                 default:
1225                     RELEASE_ASSERT_NOT_REACHED();
1226                     break;
1227                 }
1228                 break;
1229             }
1230             
1231             if (node->op() == CompareEq && leftConst.isString() && rightConst.isString()) {
1232                 const StringImpl* a = asString(leftConst)->tryGetValueImpl();
1233                 const StringImpl* b = asString(rightConst)->tryGetValueImpl();
1234                 if (a && b) {
1235                     setConstant(node, jsBoolean(WTF::equal(a, b)));
1236                     break;
1237                 }
1238             }
1239
1240             if (node->op() == CompareEq && leftConst.isSymbol() && rightConst.isSymbol()) {
1241                 setConstant(node, jsBoolean(asSymbol(leftConst)->privateName() == asSymbol(rightConst)->privateName()));
1242                 break;
1243             }
1244         }
1245         
1246         if (node->op() == CompareEq) {
1247             SpeculatedType leftType = forNode(node->child1()).m_type;
1248             SpeculatedType rightType = forNode(node->child2()).m_type;
1249             if (!valuesCouldBeEqual(leftType, rightType)) {
1250                 setConstant(node, jsBoolean(false));
1251                 break;
1252             }
1253
1254             if (leftType == SpecOther)
1255                 std::swap(leftType, rightType);
1256             if (rightType == SpecOther) {
1257                 // Undefined and Null are always equal when compared to eachother.
1258                 if (!(leftType & ~SpecOther)) {
1259                     setConstant(node, jsBoolean(true));
1260                     break;
1261                 }
1262
1263                 // Any other type compared to Null or Undefined is always false
1264                 // as long as the MasqueradesAsUndefined watchpoint is valid.
1265                 //
1266                 // MasqueradesAsUndefined only matters for SpecObjectOther, other
1267                 // cases are always "false".
1268                 if (!(leftType & (SpecObjectOther | SpecOther))) {
1269                     setConstant(node, jsBoolean(false));
1270                     break;
1271                 }
1272
1273                 if (!(leftType & SpecOther) && m_graph.masqueradesAsUndefinedWatchpointIsStillValid(node->origin.semantic)) {
1274                     JSGlobalObject* globalObject = m_graph.globalObjectFor(node->origin.semantic);
1275                     m_graph.watchpoints().addLazily(globalObject->masqueradesAsUndefinedWatchpoint());
1276                     setConstant(node, jsBoolean(false));
1277                     break;
1278                 }
1279             }
1280         }
1281         
1282         if (node->child1() == node->child2()) {
1283             if (node->isBinaryUseKind(Int32Use) ||
1284                 node->isBinaryUseKind(Int52RepUse) ||
1285                 node->isBinaryUseKind(StringUse) ||
1286                 node->isBinaryUseKind(BooleanUse) ||
1287                 node->isBinaryUseKind(SymbolUse) ||
1288                 node->isBinaryUseKind(StringIdentUse) ||
1289                 node->isBinaryUseKind(ObjectUse) ||
1290                 node->isBinaryUseKind(ObjectUse, ObjectOrOtherUse) ||
1291                 node->isBinaryUseKind(ObjectOrOtherUse, ObjectUse)) {
1292                 switch (node->op()) {
1293                 case CompareLess:
1294                 case CompareGreater:
1295                     setConstant(node, jsBoolean(false));
1296                     break;
1297                 case CompareLessEq:
1298                 case CompareGreaterEq:
1299                 case CompareEq:
1300                     setConstant(node, jsBoolean(true));
1301                     break;
1302                 default:
1303                     DFG_CRASH(m_graph, node, "Unexpected node type");
1304                     break;
1305                 }
1306                 break;
1307             }
1308         }
1309         
1310         forNode(node).setType(SpecBoolean);
1311         break;
1312     }
1313             
1314     case CompareStrictEq: {
1315         Node* leftNode = node->child1().node();
1316         Node* rightNode = node->child2().node();
1317         JSValue left = forNode(leftNode).value();
1318         JSValue right = forNode(rightNode).value();
1319         if (left && right) {
1320             if (left.isString() && right.isString()) {
1321                 // We need this case because JSValue::strictEqual is otherwise too racy for
1322                 // string comparisons.
1323                 const StringImpl* a = asString(left)->tryGetValueImpl();
1324                 const StringImpl* b = asString(right)->tryGetValueImpl();
1325                 if (a && b) {
1326                     setConstant(node, jsBoolean(WTF::equal(a, b)));
1327                     break;
1328                 }
1329             } else {
1330                 setConstant(node, jsBoolean(JSValue::strictEqual(0, left, right)));
1331                 break;
1332             }
1333         }
1334         
1335         SpeculatedType leftLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(leftNode).m_type);
1336         SpeculatedType rightLUB = leastUpperBoundOfStrictlyEquivalentSpeculations(forNode(rightNode).m_type);
1337         if (!(leftLUB & rightLUB)) {
1338             setConstant(node, jsBoolean(false));
1339             break;
1340         }
1341         
1342         if (node->child1() == node->child2()) {
1343             if (node->isBinaryUseKind(BooleanUse) ||
1344                 node->isBinaryUseKind(Int32Use) ||
1345                 node->isBinaryUseKind(Int52RepUse) ||
1346                 node->isBinaryUseKind(StringUse) ||
1347                 node->isBinaryUseKind(StringIdentUse) ||
1348                 node->isBinaryUseKind(SymbolUse) ||
1349                 node->isBinaryUseKind(ObjectUse) ||
1350                 node->isBinaryUseKind(MiscUse, UntypedUse) ||
1351                 node->isBinaryUseKind(UntypedUse, MiscUse) ||
1352                 node->isBinaryUseKind(StringIdentUse, NotStringVarUse) ||
1353                 node->isBinaryUseKind(NotStringVarUse, StringIdentUse) ||
1354                 node->isBinaryUseKind(StringUse, UntypedUse) ||
1355                 node->isBinaryUseKind(UntypedUse, StringUse)) {
1356                 setConstant(node, jsBoolean(true));
1357                 break;
1358             }
1359         }
1360
1361         forNode(node).setType(SpecBoolean);
1362         break;
1363     }
1364         
1365     case StringCharCodeAt:
1366         forNode(node).setType(SpecInt32);
1367         break;
1368         
1369     case StringFromCharCode:
1370         forNode(node).setType(m_graph, SpecString);
1371         break;
1372
1373     case StringCharAt:
1374         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1375         break;
1376             
1377     case GetByVal: {
1378         switch (node->arrayMode().type()) {
1379         case Array::SelectUsingPredictions:
1380         case Array::Unprofiled:
1381         case Array::SelectUsingArguments:
1382             RELEASE_ASSERT_NOT_REACHED();
1383             break;
1384         case Array::ForceExit:
1385             m_state.setIsValid(false);
1386             break;
1387         case Array::Undecided: {
1388             JSValue index = forNode(node->child2()).value();
1389             if (index && index.isInt32() && index.asInt32() >= 0) {
1390                 setConstant(node, jsUndefined());
1391                 break;
1392             }
1393             forNode(node).setType(SpecOther);
1394             break;
1395         }
1396         case Array::Generic:
1397             clobberWorld(node->origin.semantic, clobberLimit);
1398             forNode(node).makeHeapTop();
1399             break;
1400         case Array::String:
1401             if (node->arrayMode().isOutOfBounds()) {
1402                 // If the watchpoint was still valid we could totally set this to be
1403                 // SpecString | SpecOther. Except that we'd have to be careful. If we
1404                 // tested the watchpoint state here then it could change by the time
1405                 // we got to the backend. So to do this right, we'd have to get the
1406                 // fixup phase to check the watchpoint state and then bake into the
1407                 // GetByVal operation the fact that we're using a watchpoint, using
1408                 // something like Array::SaneChain (except not quite, because that
1409                 // implies an in-bounds access). None of this feels like it's worth it,
1410                 // so we're going with TOP for now. The same thing applies to
1411                 // clobbering the world.
1412                 clobberWorld(node->origin.semantic, clobberLimit);
1413                 forNode(node).makeHeapTop();
1414             } else
1415                 forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1416             break;
1417         case Array::DirectArguments:
1418         case Array::ScopedArguments:
1419             forNode(node).makeHeapTop();
1420             break;
1421         case Array::Int32:
1422             if (node->arrayMode().isOutOfBounds()) {
1423                 clobberWorld(node->origin.semantic, clobberLimit);
1424                 forNode(node).makeHeapTop();
1425             } else
1426                 forNode(node).setType(SpecInt32);
1427             break;
1428         case Array::Double:
1429             if (node->arrayMode().isOutOfBounds()) {
1430                 clobberWorld(node->origin.semantic, clobberLimit);
1431                 forNode(node).makeHeapTop();
1432             } else if (node->arrayMode().isSaneChain())
1433                 forNode(node).setType(SpecBytecodeDouble);
1434             else
1435                 forNode(node).setType(SpecDoubleReal);
1436             break;
1437         case Array::Contiguous:
1438         case Array::ArrayStorage:
1439         case Array::SlowPutArrayStorage:
1440             if (node->arrayMode().isOutOfBounds())
1441                 clobberWorld(node->origin.semantic, clobberLimit);
1442             forNode(node).makeHeapTop();
1443             break;
1444         case Array::Int8Array:
1445             forNode(node).setType(SpecInt32);
1446             break;
1447         case Array::Int16Array:
1448             forNode(node).setType(SpecInt32);
1449             break;
1450         case Array::Int32Array:
1451             forNode(node).setType(SpecInt32);
1452             break;
1453         case Array::Uint8Array:
1454             forNode(node).setType(SpecInt32);
1455             break;
1456         case Array::Uint8ClampedArray:
1457             forNode(node).setType(SpecInt32);
1458             break;
1459         case Array::Uint16Array:
1460             forNode(node).setType(SpecInt32);
1461             break;
1462         case Array::Uint32Array:
1463             if (node->shouldSpeculateInt32())
1464                 forNode(node).setType(SpecInt32);
1465             else if (enableInt52() && node->shouldSpeculateMachineInt())
1466                 forNode(node).setType(SpecInt52);
1467             else
1468                 forNode(node).setType(SpecInt52AsDouble);
1469             break;
1470         case Array::Float32Array:
1471             forNode(node).setType(SpecFullDouble);
1472             break;
1473         case Array::Float64Array:
1474             forNode(node).setType(SpecFullDouble);
1475             break;
1476         default:
1477             RELEASE_ASSERT_NOT_REACHED();
1478             break;
1479         }
1480         break;
1481     }
1482             
1483     case PutByValDirect:
1484     case PutByVal:
1485     case PutByValAlias: {
1486         switch (node->arrayMode().modeForPut().type()) {
1487         case Array::ForceExit:
1488             m_state.setIsValid(false);
1489             break;
1490         case Array::Generic:
1491             clobberWorld(node->origin.semantic, clobberLimit);
1492             break;
1493         case Array::Int32:
1494             if (node->arrayMode().isOutOfBounds())
1495                 clobberWorld(node->origin.semantic, clobberLimit);
1496             break;
1497         case Array::Double:
1498             if (node->arrayMode().isOutOfBounds())
1499                 clobberWorld(node->origin.semantic, clobberLimit);
1500             break;
1501         case Array::Contiguous:
1502         case Array::ArrayStorage:
1503             if (node->arrayMode().isOutOfBounds())
1504                 clobberWorld(node->origin.semantic, clobberLimit);
1505             break;
1506         case Array::SlowPutArrayStorage:
1507             if (node->arrayMode().mayStoreToHole())
1508                 clobberWorld(node->origin.semantic, clobberLimit);
1509             break;
1510         default:
1511             break;
1512         }
1513         break;
1514     }
1515             
1516     case ArrayPush:
1517         clobberWorld(node->origin.semantic, clobberLimit);
1518         forNode(node).setType(SpecBytecodeNumber);
1519         break;
1520             
1521     case ArrayPop:
1522         clobberWorld(node->origin.semantic, clobberLimit);
1523         forNode(node).makeHeapTop();
1524         break;
1525         
1526     case GetMyArgumentByVal: {
1527         JSValue index = forNode(node->child2()).m_value;
1528         InlineCallFrame* inlineCallFrame = node->child1()->origin.semantic.inlineCallFrame;
1529
1530         if (index && index.isInt32()) {
1531             // This pretends to return TOP for accesses that are actually proven out-of-bounds because
1532             // that's the conservative thing to do. Otherwise we'd need to write more code to mark such
1533             // paths as unreachable, and it's almost certainly not worth the effort.
1534             
1535             if (inlineCallFrame) {
1536                 if (index.asUInt32() < inlineCallFrame->arguments.size() - 1) {
1537                     forNode(node) = m_state.variables().operand(
1538                         virtualRegisterForArgument(index.asInt32() + 1) + inlineCallFrame->stackOffset);
1539                     m_state.setFoundConstants(true);
1540                     break;
1541                 }
1542             } else {
1543                 if (index.asUInt32() < m_state.variables().numberOfArguments() - 1) {
1544                     forNode(node) = m_state.variables().argument(index.asInt32() + 1);
1545                     m_state.setFoundConstants(true);
1546                     break;
1547                 }
1548             }
1549         }
1550         
1551         if (inlineCallFrame) {
1552             // We have a bound on the types even though it's random access. Take advantage of this.
1553             
1554             AbstractValue result;
1555             for (unsigned i = inlineCallFrame->arguments.size(); i-- > 1;) {
1556                 result.merge(
1557                     m_state.variables().operand(
1558                         virtualRegisterForArgument(i) + inlineCallFrame->stackOffset));
1559             }
1560             
1561             if (result.value())
1562                 m_state.setFoundConstants(true);
1563             forNode(node) = result;
1564             break;
1565         }
1566         
1567         forNode(node).makeHeapTop();
1568         break;
1569     }
1570             
1571     case RegExpExec:
1572         if (node->child2().useKind() == RegExpObjectUse
1573             && node->child3().useKind() == StringUse) {
1574             // This doesn't clobber the world since there are no conversions to perform.
1575         } else
1576             clobberWorld(node->origin.semantic, clobberLimit);
1577         if (JSValue globalObjectValue = forNode(node->child1()).m_value) {
1578             if (JSGlobalObject* globalObject = jsDynamicCast<JSGlobalObject*>(globalObjectValue)) {
1579                 if (!globalObject->isHavingABadTime()) {
1580                     m_graph.watchpoints().addLazily(globalObject->havingABadTimeWatchpoint());
1581                     Structure* structure = globalObject->regExpMatchesArrayStructure();
1582                     m_graph.registerStructure(structure);
1583                     forNode(node).set(m_graph, structure);
1584                     forNode(node).merge(SpecOther);
1585                     break;
1586                 }
1587             }
1588         }
1589         forNode(node).setType(m_graph, SpecOther | SpecArray);
1590         break;
1591
1592     case RegExpTest:
1593         if (node->child2().useKind() == RegExpObjectUse
1594             && node->child3().useKind() == StringUse) {
1595             // This doesn't clobber the world since there are no conversions to perform.
1596         } else
1597             clobberWorld(node->origin.semantic, clobberLimit);
1598         forNode(node).setType(SpecBoolean);
1599         break;
1600             
1601     case StringReplace:
1602         if (node->child1().useKind() == StringUse
1603             && node->child2().useKind() == RegExpObjectUse
1604             && node->child3().useKind() == StringUse) {
1605             // This doesn't clobber the world. It just reads and writes regexp state.
1606         } else
1607             clobberWorld(node->origin.semantic, clobberLimit);
1608         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1609         break;
1610
1611     case Jump:
1612         break;
1613             
1614     case Branch: {
1615         Node* child = node->child1().node();
1616         BooleanResult result = booleanResult(node, forNode(child));
1617         if (result == DefinitelyTrue) {
1618             m_state.setBranchDirection(TakeTrue);
1619             break;
1620         }
1621         if (result == DefinitelyFalse) {
1622             m_state.setBranchDirection(TakeFalse);
1623             break;
1624         }
1625         // FIXME: The above handles the trivial cases of sparse conditional
1626         // constant propagation, but we can do better:
1627         // We can specialize the source variable's value on each direction of
1628         // the branch.
1629         m_state.setBranchDirection(TakeBoth);
1630         break;
1631     }
1632         
1633     case Switch: {
1634         // Nothing to do for now.
1635         // FIXME: Do sparse conditional things.
1636         break;
1637     }
1638             
1639     case Return:
1640         m_state.setIsValid(false);
1641         break;
1642
1643     case TailCall:
1644     case TailCallVarargs:
1645     case TailCallForwardVarargs:
1646         clobberWorld(node->origin.semantic, clobberLimit);
1647         m_state.setIsValid(false);
1648         break;
1649         
1650     case Throw:
1651     case ThrowReferenceError:
1652         m_state.setIsValid(false);
1653         break;
1654             
1655     case ToPrimitive: {
1656         JSValue childConst = forNode(node->child1()).value();
1657         if (childConst && childConst.isNumber()) {
1658             setConstant(node, childConst);
1659             break;
1660         }
1661         
1662         ASSERT(node->child1().useKind() == UntypedUse);
1663         
1664         if (!forNode(node->child1()).m_type) {
1665             m_state.setIsValid(false);
1666             break;
1667         }
1668         
1669         if (!(forNode(node->child1()).m_type & ~(SpecFullNumber | SpecBoolean | SpecString | SpecSymbol))) {
1670             m_state.setFoundConstants(true);
1671             forNode(node) = forNode(node->child1());
1672             break;
1673         }
1674         
1675         clobberWorld(node->origin.semantic, clobberLimit);
1676         
1677         forNode(node).setType(m_graph, SpecHeapTop & ~SpecObject);
1678         break;
1679     }
1680         
1681     case ToString:
1682     case CallStringConstructor: {
1683         switch (node->child1().useKind()) {
1684         case StringObjectUse:
1685             // This also filters that the StringObject has the primordial StringObject
1686             // structure.
1687             filter(
1688                 node->child1(),
1689                 m_graph.globalObjectFor(node->origin.semantic)->stringObjectStructure());
1690             break;
1691         case StringOrStringObjectUse:
1692             break;
1693         case CellUse:
1694         case UntypedUse:
1695             clobberWorld(node->origin.semantic, clobberLimit);
1696             break;
1697         default:
1698             RELEASE_ASSERT_NOT_REACHED();
1699             break;
1700         }
1701         forNode(node).set(m_graph, m_graph.m_vm.stringStructure.get());
1702         break;
1703     }
1704         
1705     case NewStringObject: {
1706         ASSERT(node->structure()->classInfo() == StringObject::info());
1707         forNode(node).set(m_graph, node->structure());
1708         break;
1709     }
1710             
1711     case NewArray:
1712         forNode(node).set(
1713             m_graph,
1714             m_graph.globalObjectFor(node->origin.semantic)->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
1715         break;
1716         
1717     case NewArrayBuffer:
1718         forNode(node).set(
1719             m_graph,
1720             m_graph.globalObjectFor(node->origin.semantic)->arrayStructureForIndexingTypeDuringAllocation(node->indexingType()));
1721         break;
1722
1723     case NewArrayWithSize:
1724         forNode(node).setType(m_graph, SpecArray);
1725         break;
1726         
1727     case NewTypedArray:
1728         switch (node->child1().useKind()) {
1729         case Int32Use:
1730             break;
1731         case UntypedUse:
1732             clobberWorld(node->origin.semantic, clobberLimit);
1733             break;
1734         default:
1735             RELEASE_ASSERT_NOT_REACHED();
1736             break;
1737         }
1738         forNode(node).set(
1739             m_graph,
1740             m_graph.globalObjectFor(node->origin.semantic)->typedArrayStructure(
1741                 node->typedArrayType()));
1742         break;
1743         
1744     case NewRegexp:
1745         forNode(node).set(m_graph, m_graph.globalObjectFor(node->origin.semantic)->regExpStructure());
1746         break;
1747             
1748     case ToThis: {
1749         AbstractValue& source = forNode(node->child1());
1750         AbstractValue& destination = forNode(node);
1751
1752         if (source.m_type == SpecStringObject) {
1753             m_state.setFoundConstants(true);
1754             destination = source;
1755             break;
1756         }
1757
1758         if (m_graph.executableFor(node->origin.semantic)->isStrictMode()) {
1759             if (!(source.m_type & ~(SpecFullNumber | SpecBoolean | SpecString | SpecSymbol))) {
1760                 m_state.setFoundConstants(true);
1761                 destination = source;
1762                 break;
1763             }
1764             destination.makeHeapTop();
1765         } else {
1766             destination = source;
1767             destination.merge(SpecObject);
1768         }
1769         break;
1770     }
1771
1772     case CreateThis: {
1773         // FIXME: We can fold this to NewObject if the incoming callee is a constant.
1774         forNode(node).setType(m_graph, SpecFinalObject);
1775         break;
1776     }
1777         
1778     case NewObject:
1779         ASSERT(node->structure());
1780         forNode(node).set(m_graph, node->structure());
1781         break;
1782         
1783     case PhantomNewObject:
1784     case PhantomNewFunction:
1785     case PhantomNewGeneratorFunction:
1786     case PhantomCreateActivation:
1787     case PhantomDirectArguments:
1788     case PhantomClonedArguments:
1789     case BottomValue:
1790         m_state.setDidClobber(true); // Prevent constant folding.
1791         // This claims to return bottom.
1792         break;
1793         
1794     case PutHint:
1795         break;
1796         
1797     case MaterializeNewObject: {
1798         StructureSet set;
1799         
1800         m_phiChildren->forAllTransitiveIncomingValues(
1801             m_graph.varArgChild(node, 0).node(),
1802             [&] (Node* incoming) {
1803                 set.add(incoming->castConstant<Structure*>());
1804             });
1805         
1806         forNode(node).set(m_graph, set);
1807         break;
1808     }
1809
1810     case CreateActivation:
1811     case MaterializeCreateActivation:
1812         forNode(node).set(
1813             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->activationStructure());
1814         break;
1815         
1816     case CreateDirectArguments:
1817         forNode(node).set(m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->directArgumentsStructure());
1818         break;
1819         
1820     case CreateScopedArguments:
1821         forNode(node).set(m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->scopedArgumentsStructure());
1822         break;
1823         
1824     case CreateClonedArguments:
1825         forNode(node).set(m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->clonedArgumentsStructure());
1826         break;
1827             
1828     case NewArrowFunction:
1829         forNode(node).set(
1830             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->functionStructure());
1831         break;
1832
1833     case NewGeneratorFunction:
1834         forNode(node).set(
1835             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->generatorFunctionStructure());
1836         break;
1837
1838     case NewFunction:
1839         forNode(node).set(
1840             m_graph, m_codeBlock->globalObjectFor(node->origin.semantic)->functionStructure());
1841         break;
1842         
1843     case GetCallee:
1844         if (FunctionExecutable* executable = jsDynamicCast<FunctionExecutable*>(m_codeBlock->ownerExecutable())) {
1845             InferredValue* singleton = executable->singletonFunction();
1846             if (JSValue value = singleton->inferredValue()) {
1847                 m_graph.watchpoints().addLazily(singleton);
1848                 JSFunction* function = jsCast<JSFunction*>(value);
1849                 setConstant(node, *m_graph.freeze(function));
1850                 break;
1851             }
1852         }
1853         forNode(node).setType(m_graph, SpecFunction);
1854         break;
1855         
1856     case GetArgumentCount:
1857         forNode(node).setType(SpecInt32);
1858         break;
1859         
1860     case GetRestLength:
1861         forNode(node).setType(SpecInt32);
1862         break;
1863         
1864     case GetGetter: {
1865         JSValue base = forNode(node->child1()).m_value;
1866         if (base) {
1867             GetterSetter* getterSetter = jsCast<GetterSetter*>(base);
1868             if (!getterSetter->isGetterNull()) {
1869                 setConstant(node, *m_graph.freeze(getterSetter->getterConcurrently()));
1870                 break;
1871             }
1872         }
1873         
1874         forNode(node).setType(m_graph, SpecObject);
1875         break;
1876     }
1877         
1878     case GetSetter: {
1879         JSValue base = forNode(node->child1()).m_value;
1880         if (base) {
1881             GetterSetter* getterSetter = jsCast<GetterSetter*>(base);
1882             if (!getterSetter->isSetterNull()) {
1883                 setConstant(node, *m_graph.freeze(getterSetter->setterConcurrently()));
1884                 break;
1885             }
1886         }
1887         
1888         forNode(node).setType(m_graph, SpecObject);
1889         break;
1890     }
1891         
1892     case GetScope:
1893         if (JSValue base = forNode(node->child1()).m_value) {
1894             if (JSFunction* function = jsDynamicCast<JSFunction*>(base)) {
1895                 setConstant(node, *m_graph.freeze(function->scope()));
1896                 break;
1897             }
1898         }
1899         forNode(node).setType(m_graph, SpecObjectOther);
1900         break;
1901
1902     case SkipScope: {
1903         JSValue child = forNode(node->child1()).value();
1904         if (child) {
1905             setConstant(node, *m_graph.freeze(JSValue(jsCast<JSScope*>(child.asCell())->next())));
1906             break;
1907         }
1908         forNode(node).setType(m_graph, SpecObjectOther);
1909         break;
1910     }
1911
1912     case GetGlobalObject: {
1913         JSValue child = forNode(node->child1()).value();
1914         if (child) {
1915             setConstant(node, *m_graph.freeze(JSValue(asObject(child)->globalObject())));
1916             break;
1917         }
1918
1919         if (forNode(node->child1()).m_structure.isFinite()) {
1920             JSGlobalObject* globalObject = nullptr;
1921             bool ok = true;
1922             forNode(node->child1()).m_structure.forEach(
1923                 [&] (Structure* structure) {
1924                     if (!globalObject)
1925                         globalObject = structure->globalObject();
1926                     else if (globalObject != structure->globalObject())
1927                         ok = false;
1928                 });
1929             if (globalObject && ok) {
1930                 setConstant(node, *m_graph.freeze(JSValue(globalObject)));
1931                 break;
1932             }
1933         }
1934
1935         forNode(node).setType(m_graph, SpecObjectOther);
1936         break;
1937     }
1938
1939     case GetClosureVar:
1940         if (JSValue value = m_graph.tryGetConstantClosureVar(forNode(node->child1()), node->scopeOffset())) {
1941             setConstant(node, *m_graph.freeze(value));
1942             break;
1943         }
1944         forNode(node).makeBytecodeTop();
1945         break;
1946             
1947     case PutClosureVar:
1948         break;
1949
1950     case GetRegExpObjectLastIndex:
1951         forNode(node).makeHeapTop();
1952         break;
1953
1954     case SetRegExpObjectLastIndex:
1955         break;
1956         
1957     case GetFromArguments:
1958         forNode(node).makeHeapTop();
1959         break;
1960         
1961     case PutToArguments:
1962         break;
1963             
1964     case GetById:
1965     case GetByIdFlush: {
1966         if (!node->prediction()) {
1967             m_state.setIsValid(false);
1968             break;
1969         }
1970         
1971         AbstractValue& value = forNode(node->child1());
1972         if (value.m_structure.isFinite()
1973             && (node->child1().useKind() == CellUse || !(value.m_type & ~SpecCell))) {
1974             UniquedStringImpl* uid = m_graph.identifiers()[node->identifierNumber()];
1975             GetByIdStatus status = GetByIdStatus::computeFor(value.m_structure.set(), uid);
1976             if (status.isSimple()) {
1977                 // Figure out what the result is going to be - is it TOP, a constant, or maybe
1978                 // something more subtle?
1979                 AbstractValue result;
1980                 for (unsigned i = status.numVariants(); i--;) {
1981                     // This thing won't give us a variant that involves prototypes. If it did, we'd
1982                     // have more work to do here.
1983                     DFG_ASSERT(m_graph, node, status[i].conditionSet().isEmpty());
1984
1985                     result.merge(
1986                         m_graph.inferredValueForProperty(
1987                             value, uid, status[i].offset(), m_state.structureClobberState()));
1988                 }
1989                 m_state.setFoundConstants(true);
1990                 forNode(node) = result;
1991                 break;
1992             }
1993         }
1994
1995         clobberWorld(node->origin.semantic, clobberLimit);
1996         forNode(node).makeHeapTop();
1997         break;
1998     }
1999             
2000     case GetArrayLength: {
2001         JSArrayBufferView* view = m_graph.tryGetFoldableView(
2002             forNode(node->child1()).m_value, node->arrayMode());
2003         if (view) {
2004             setConstant(node, jsNumber(view->length()));
2005             break;
2006         }
2007         forNode(node).setType(SpecInt32);
2008         break;
2009     }
2010         
2011     case CheckStructure: {
2012         AbstractValue& value = forNode(node->child1());
2013
2014         StructureSet& set = node->structureSet();
2015         
2016         // It's interesting that we could have proven that the object has a larger structure set
2017         // that includes the set we're testing. In that case we could make the structure check
2018         // more efficient. We currently don't.
2019         
2020         if (value.m_structure.isSubsetOf(set))
2021             m_state.setFoundConstants(true);
2022
2023         SpeculatedType admittedTypes = SpecNone;
2024         switch (node->child1().useKind()) {
2025         case CellUse:
2026         case KnownCellUse:
2027             admittedTypes = SpecNone;
2028             break;
2029         case CellOrOtherUse:
2030             admittedTypes = SpecOther;
2031             break;
2032         default:
2033             DFG_CRASH(m_graph, node, "Bad use kind");
2034             break;
2035         }
2036         
2037         filter(value, set, admittedTypes);
2038         break;
2039     }
2040         
2041     case CheckStructureImmediate: {
2042         // FIXME: This currently can only reason about one structure at a time.
2043         // https://bugs.webkit.org/show_bug.cgi?id=136988
2044         
2045         AbstractValue& value = forNode(node->child1());
2046         StructureSet& set = node->structureSet();
2047         
2048         if (value.value()) {
2049             if (Structure* structure = jsDynamicCast<Structure*>(value.value())) {
2050                 if (set.contains(structure)) {
2051                     m_state.setFoundConstants(true);
2052                     break;
2053                 }
2054             }
2055             m_state.setIsValid(false);
2056             break;
2057         }
2058         
2059         if (m_phiChildren) {
2060             bool allGood = true;
2061             m_phiChildren->forAllTransitiveIncomingValues(
2062                 node,
2063                 [&] (Node* incoming) {
2064                     if (Structure* structure = incoming->dynamicCastConstant<Structure*>()) {
2065                         if (set.contains(structure))
2066                             return;
2067                     }
2068                     allGood = false;
2069                 });
2070             if (allGood) {
2071                 m_state.setFoundConstants(true);
2072                 break;
2073             }
2074         }
2075             
2076         if (Structure* structure = set.onlyStructure()) {
2077             filterByValue(node->child1(), *m_graph.freeze(structure));
2078             break;
2079         }
2080         
2081         // Aw shucks, we can't do anything!
2082         break;
2083     }
2084         
2085     case PutStructure:
2086         if (!forNode(node->child1()).m_structure.isClear()) {
2087             if (forNode(node->child1()).m_structure.onlyStructure() == node->transition()->next)
2088                 m_state.setFoundConstants(true);
2089             else {
2090                 observeTransition(
2091                     clobberLimit, node->transition()->previous, node->transition()->next);
2092                 forNode(node->child1()).changeStructure(m_graph, node->transition()->next);
2093             }
2094         }
2095         break;
2096     case GetButterfly:
2097     case AllocatePropertyStorage:
2098     case ReallocatePropertyStorage:
2099         forNode(node).clear(); // The result is not a JS value.
2100         break;
2101     case CheckArray: {
2102         if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
2103             m_state.setFoundConstants(true);
2104             break;
2105         }
2106         switch (node->arrayMode().type()) {
2107         case Array::String:
2108             filter(node->child1(), SpecString);
2109             break;
2110         case Array::Int32:
2111         case Array::Double:
2112         case Array::Contiguous:
2113         case Array::Undecided:
2114         case Array::ArrayStorage:
2115         case Array::SlowPutArrayStorage:
2116             break;
2117         case Array::DirectArguments:
2118             filter(node->child1(), SpecDirectArguments);
2119             break;
2120         case Array::ScopedArguments:
2121             filter(node->child1(), SpecScopedArguments);
2122             break;
2123         case Array::Int8Array:
2124             filter(node->child1(), SpecInt8Array);
2125             break;
2126         case Array::Int16Array:
2127             filter(node->child1(), SpecInt16Array);
2128             break;
2129         case Array::Int32Array:
2130             filter(node->child1(), SpecInt32Array);
2131             break;
2132         case Array::Uint8Array:
2133             filter(node->child1(), SpecUint8Array);
2134             break;
2135         case Array::Uint8ClampedArray:
2136             filter(node->child1(), SpecUint8ClampedArray);
2137             break;
2138         case Array::Uint16Array:
2139             filter(node->child1(), SpecUint16Array);
2140             break;
2141         case Array::Uint32Array:
2142             filter(node->child1(), SpecUint32Array);
2143             break;
2144         case Array::Float32Array:
2145             filter(node->child1(), SpecFloat32Array);
2146             break;
2147         case Array::Float64Array:
2148             filter(node->child1(), SpecFloat64Array);
2149             break;
2150         case Array::AnyTypedArray:
2151             filter(node->child1(), SpecTypedArrayView);
2152             break;
2153         default:
2154             RELEASE_ASSERT_NOT_REACHED();
2155             break;
2156         }
2157         filterArrayModes(node->child1(), node->arrayMode().arrayModesThatPassFiltering());
2158         break;
2159     }
2160     case Arrayify: {
2161         if (node->arrayMode().alreadyChecked(m_graph, node, forNode(node->child1()))) {
2162             m_state.setFoundConstants(true);
2163             break;
2164         }
2165         ASSERT(node->arrayMode().conversion() == Array::Convert);
2166         clobberStructures(clobberLimit);
2167         filterArrayModes(node->child1(), node->arrayMode().arrayModesThatPassFiltering());
2168         break;
2169     }
2170     case ArrayifyToStructure: {
2171         AbstractValue& value = forNode(node->child1());
2172         if (value.m_structure.isSubsetOf(StructureSet(node->structure())))
2173             m_state.setFoundConstants(true);
2174         clobberStructures(clobberLimit);
2175         
2176         // We have a bunch of options of how to express the abstract set at this point. Let set S
2177         // be the set of structures that the value had before clobbering and assume that all of
2178         // them are watchable. The new value should be the least expressible upper bound of the
2179         // intersection of "values that currently have structure = node->structure()" and "values
2180         // that have structure in S plus any structure transition-reachable from S". Assume that
2181         // node->structure() is not in S but it is transition-reachable from S. Then we would
2182         // like to say that the result is "values that have structure = node->structure() until
2183         // we invalidate", but there is no way to express this using the AbstractValue syntax. So
2184         // we must choose between:
2185         //
2186         // 1) "values that currently have structure = node->structure()". This is a valid
2187         //    superset of the value that we really want, and it's specific enough to satisfy the
2188         //    preconditions of the array access that this is guarding. It's also specific enough
2189         //    to allow relevant optimizations in the case that we didn't have a contradiction
2190         //    like in this example. Notice that in the abscence of any contradiction, this result
2191         //    is precise rather than being a conservative LUB.
2192         //
2193         // 2) "values that currently hava structure in S plus any structure transition-reachable
2194         //    from S". This is also a valid superset of the value that we really want, but it's
2195         //    not specific enough to satisfy the preconditions of the array access that this is
2196         //    guarding - so playing such shenanigans would preclude us from having assertions on
2197         //    the typing preconditions of any array accesses. This would also not be a desirable
2198         //    answer in the absence of a contradiction.
2199         //
2200         // Note that it's tempting to simply say that the resulting value is BOTTOM because of
2201         // the contradiction. That would be wrong, since we haven't hit an invalidation point,
2202         // yet.
2203         value.set(m_graph, node->structure());
2204         break;
2205     }
2206     case GetIndexedPropertyStorage: {
2207         JSArrayBufferView* view = m_graph.tryGetFoldableView(
2208             forNode(node->child1()).m_value, node->arrayMode());
2209         if (view)
2210             m_state.setFoundConstants(true);
2211         forNode(node).clear();
2212         break;
2213     }
2214     case ConstantStoragePointer: {
2215         forNode(node).clear();
2216         break; 
2217     }
2218         
2219     case GetTypedArrayByteOffset: {
2220         JSArrayBufferView* view = m_graph.tryGetFoldableView(forNode(node->child1()).m_value);
2221         if (view) {
2222             setConstant(node, jsNumber(view->byteOffset()));
2223             break;
2224         }
2225         forNode(node).setType(SpecInt32);
2226         break;
2227     }
2228         
2229     case GetByOffset: {
2230         StorageAccessData& data = node->storageAccessData();
2231         UniquedStringImpl* uid = m_graph.identifiers()[data.identifierNumber];
2232
2233         // FIXME: The part of this that handles inferred property types relies on AI knowing the structure
2234         // right now. That's probably not optimal. In some cases, we may perform an optimization (usually
2235         // by something other than AI, maybe by CSE for example) that obscures AI's view of the structure
2236         // at the point where GetByOffset runs. Currently, when that happens, we'll have to rely entirely
2237         // on the type that ByteCodeParser was able to prove.
2238         AbstractValue value = m_graph.inferredValueForProperty(
2239             forNode(node->child2()), uid, data.offset, m_state.structureClobberState());
2240
2241         // It's possible that the type that ByteCodeParser came up with is better.
2242         AbstractValue typeFromParsing;
2243         typeFromParsing.set(m_graph, data.inferredType, m_state.structureClobberState());
2244         value.filter(typeFromParsing);
2245
2246         // If we decide that there does not exist any value that this can return, then it's probably
2247         // because the compilation was already invalidated.
2248         if (value.isClear())
2249             m_state.setIsValid(false);
2250
2251         forNode(node) = value;
2252         if (value.m_value)
2253             m_state.setFoundConstants(true);
2254         break;
2255     }
2256         
2257     case GetGetterSetterByOffset: {
2258         StorageAccessData& data = node->storageAccessData();
2259         JSValue result = m_graph.tryGetConstantProperty(forNode(node->child2()), data.offset);
2260         if (result && jsDynamicCast<GetterSetter*>(result)) {
2261             setConstant(node, *m_graph.freeze(result));
2262             break;
2263         }
2264         
2265         forNode(node).set(m_graph, m_graph.m_vm.getterSetterStructure.get());
2266         break;
2267     }
2268         
2269     case MultiGetByOffset: {
2270         // This code will filter the base value in a manner that is possibly different (either more
2271         // or less precise) than the way it would be filtered if this was strength-reduced to a
2272         // CheckStructure. This is fine. It's legal for different passes over the code to prove
2273         // different things about the code, so long as all of them are sound. That even includes
2274         // one guy proving that code should never execute (due to a contradiction) and another guy
2275         // not finding that contradiction. If someone ever proved that there would be a
2276         // contradiction then there must always be a contradiction even if subsequent passes don't
2277         // realize it. This is the case here.
2278         
2279         // Ordinarily you have to be careful with calling setFoundConstants()
2280         // because of the effect on compile times, but this node is FTL-only.
2281         m_state.setFoundConstants(true);
2282         
2283         UniquedStringImpl* uid = m_graph.identifiers()[node->multiGetByOffsetData().identifierNumber];
2284
2285         AbstractValue base = forNode(node->child1());
2286         StructureSet baseSet;
2287         AbstractValue result;
2288         for (const MultiGetByOffsetCase& getCase : node->multiGetByOffsetData().cases) {
2289             StructureSet set = getCase.set();
2290             set.filter(base);
2291             if (set.isEmpty())
2292                 continue;
2293             baseSet.merge(set);
2294
2295             switch (getCase.method().kind()) {
2296             case GetByOffsetMethod::Constant: {
2297                 AbstractValue thisResult;
2298                 thisResult.set(
2299                     m_graph,
2300                     *getCase.method().constant(),
2301                     m_state.structureClobberState());
2302                 result.merge(thisResult);
2303                 break;
2304             }
2305
2306             case GetByOffsetMethod::Load: {
2307                 result.merge(
2308                     m_graph.inferredValueForProperty(
2309                         set, uid, m_state.structureClobberState()));
2310                 break;
2311             }
2312
2313             default: {
2314                 result.makeHeapTop();
2315                 break;
2316             } }
2317         }
2318         
2319         if (forNode(node->child1()).changeStructure(m_graph, baseSet) == Contradiction)
2320             m_state.setIsValid(false);
2321         
2322         forNode(node) = result;
2323         break;
2324     }
2325             
2326     case PutByOffset: {
2327         break;
2328     }
2329         
2330     case MultiPutByOffset: {
2331         StructureSet newSet;
2332         TransitionVector transitions;
2333         
2334         // Ordinarily you have to be careful with calling setFoundConstants()
2335         // because of the effect on compile times, but this node is FTL-only.
2336         m_state.setFoundConstants(true);
2337         
2338         AbstractValue base = forNode(node->child1());
2339         AbstractValue originalValue = forNode(node->child2());
2340         AbstractValue resultingValue;
2341         
2342         for (unsigned i = node->multiPutByOffsetData().variants.size(); i--;) {
2343             const PutByIdVariant& variant = node->multiPutByOffsetData().variants[i];
2344             StructureSet thisSet = variant.oldStructure();
2345             thisSet.filter(base);
2346             if (thisSet.isEmpty())
2347                 continue;
2348
2349             AbstractValue thisValue = originalValue;
2350             thisValue.filter(m_graph, variant.requiredType());
2351             resultingValue.merge(thisValue);
2352             
2353             if (variant.kind() == PutByIdVariant::Transition) {
2354                 if (thisSet.onlyStructure() != variant.newStructure()) {
2355                     transitions.append(
2356                         Transition(variant.oldStructureForTransition(), variant.newStructure()));
2357                 } // else this is really a replace.
2358                 newSet.add(variant.newStructure());
2359             } else {
2360                 ASSERT(variant.kind() == PutByIdVariant::Replace);
2361                 newSet.merge(thisSet);
2362             }
2363         }
2364         
2365         observeTransitions(clobberLimit, transitions);
2366         if (forNode(node->child1()).changeStructure(m_graph, newSet) == Contradiction)
2367             m_state.setIsValid(false);
2368         forNode(node->child2()) = resultingValue;
2369         if (!!originalValue && !resultingValue)
2370             m_state.setIsValid(false);
2371         break;
2372     }
2373         
2374     case GetExecutable: {
2375         JSValue value = forNode(node->child1()).value();
2376         if (value) {
2377             JSFunction* function = jsDynamicCast<JSFunction*>(value);
2378             if (function) {
2379                 setConstant(node, *m_graph.freeze(function->executable()));
2380                 break;
2381             }
2382         }
2383         forNode(node).setType(m_graph, SpecCellOther);
2384         break;
2385     }
2386     
2387     case CheckCell: {
2388         JSValue value = forNode(node->child1()).value();
2389         if (value == node->cellOperand()->value()) {
2390             m_state.setFoundConstants(true);
2391             ASSERT(value);
2392             break;
2393         }
2394         filterByValue(node->child1(), *node->cellOperand());
2395         break;
2396     }
2397
2398     case CheckNotEmpty: {
2399         AbstractValue& value = forNode(node->child1());
2400         if (!(value.m_type & SpecEmpty)) {
2401             m_state.setFoundConstants(true);
2402             break;
2403         }
2404         
2405         filter(value, ~SpecEmpty);
2406         break;
2407     }
2408
2409     case CheckIdent: {
2410         AbstractValue& value = forNode(node->child1());
2411         UniquedStringImpl* uid = node->uidOperand();
2412         ASSERT(uid->isSymbol() ? !(value.m_type & ~SpecSymbol) : !(value.m_type & ~SpecStringIdent)); // Edge filtering should have already ensured this.
2413
2414         JSValue childConstant = value.value();
2415         if (childConstant) {
2416             if (uid->isSymbol()) {
2417                 ASSERT(childConstant.isSymbol());
2418                 if (asSymbol(childConstant)->privateName().uid() == uid) {
2419                     m_state.setFoundConstants(true);
2420                     break;
2421                 }
2422             } else {
2423                 ASSERT(childConstant.isString());
2424                 if (asString(childConstant)->tryGetValueImpl() == uid) {
2425                     m_state.setFoundConstants(true);
2426                     break;
2427                 }
2428             }
2429         }
2430
2431         filter(value, uid->isSymbol() ? SpecSymbol : SpecStringIdent);
2432         break;
2433     }
2434
2435     case CheckInBounds: {
2436         JSValue left = forNode(node->child1()).value();
2437         JSValue right = forNode(node->child2()).value();
2438         if (left && right && left.isInt32() && right.isInt32()
2439             && static_cast<uint32_t>(left.asInt32()) < static_cast<uint32_t>(right.asInt32())) {
2440             m_state.setFoundConstants(true);
2441             break;
2442         }
2443         break;
2444     }
2445         
2446     case PutById:
2447     case PutByIdFlush:
2448     case PutByIdDirect: {
2449         AbstractValue& value = forNode(node->child1());
2450         if (value.m_structure.isFinite()) {
2451             PutByIdStatus status = PutByIdStatus::computeFor(
2452                 m_graph.globalObjectFor(node->origin.semantic),
2453                 value.m_structure.set(),
2454                 m_graph.identifiers()[node->identifierNumber()],
2455                 node->op() == PutByIdDirect);
2456
2457             if (status.isSimple()) {
2458                 StructureSet newSet;
2459                 TransitionVector transitions;
2460                 
2461                 for (unsigned i = status.numVariants(); i--;) {
2462                     const PutByIdVariant& variant = status[i];
2463                     if (variant.kind() == PutByIdVariant::Transition) {
2464                         transitions.append(
2465                             Transition(
2466                                 variant.oldStructureForTransition(), variant.newStructure()));
2467                         m_graph.registerStructure(variant.newStructure());
2468                         newSet.add(variant.newStructure());
2469                     } else {
2470                         ASSERT(variant.kind() == PutByIdVariant::Replace);
2471                         newSet.merge(variant.oldStructure());
2472                     }
2473                 }
2474                 
2475                 if (status.numVariants() == 1 || isFTL(m_graph.m_plan.mode))
2476                     m_state.setFoundConstants(true);
2477                 
2478                 observeTransitions(clobberLimit, transitions);
2479                 if (forNode(node->child1()).changeStructure(m_graph, newSet) == Contradiction)
2480                     m_state.setIsValid(false);
2481                 break;
2482             }
2483         }
2484         
2485         clobberWorld(node->origin.semantic, clobberLimit);
2486         break;
2487     }
2488
2489     case PutGetterById:
2490     case PutSetterById:
2491     case PutGetterSetterById:
2492     case PutGetterByVal:
2493     case PutSetterByVal: {
2494         clobberWorld(node->origin.semantic, clobberLimit);
2495         break;
2496     }
2497         
2498     case In: {
2499         // FIXME: We can determine when the property definitely exists based on abstract
2500         // value information.
2501         clobberWorld(node->origin.semantic, clobberLimit);
2502         forNode(node).setType(SpecBoolean);
2503         break;
2504     }
2505             
2506     case GetEnumerableLength: {
2507         forNode(node).setType(SpecInt32);
2508         break;
2509     }
2510     case HasGenericProperty: {
2511         forNode(node).setType(SpecBoolean);
2512         break;
2513     }
2514     case HasStructureProperty: {
2515         forNode(node).setType(SpecBoolean);
2516         break;
2517     }
2518     case HasIndexedProperty: {
2519         ArrayMode mode = node->arrayMode();
2520         switch (mode.type()) {
2521         case Array::Int32:
2522         case Array::Double:
2523         case Array::Contiguous:
2524         case Array::ArrayStorage: {
2525             break;
2526         }
2527         default: {
2528             clobberWorld(node->origin.semantic, clobberLimit);
2529             break;
2530         }
2531         }
2532         forNode(node).setType(SpecBoolean);
2533         break;
2534     }
2535     case GetDirectPname: {
2536         clobberWorld(node->origin.semantic, clobberLimit);
2537         forNode(node).makeHeapTop();
2538         break;
2539     }
2540     case GetPropertyEnumerator: {
2541         forNode(node).setType(m_graph, SpecCell);
2542         break;
2543     }
2544     case GetEnumeratorStructurePname: {
2545         forNode(node).setType(m_graph, SpecString | SpecOther);
2546         break;
2547     }
2548     case GetEnumeratorGenericPname: {
2549         forNode(node).setType(m_graph, SpecString | SpecOther);
2550         break;
2551     }
2552     case ToIndexString: {
2553         forNode(node).setType(m_graph, SpecString);
2554         break;
2555     }
2556
2557     case GetGlobalVar:
2558         forNode(node).makeHeapTop();
2559         break;
2560     case GetGlobalLexicalVariable:
2561         forNode(node).makeBytecodeTop();
2562         break;
2563         
2564     case VarInjectionWatchpoint:
2565     case PutGlobalVariable:
2566     case NotifyWrite:
2567         break;
2568             
2569     case OverridesHasInstance:
2570         forNode(node).setType(SpecBoolean);
2571         break;
2572             
2573     case InstanceOf:
2574         // Sadly, we don't propagate the fact that we've done InstanceOf
2575         forNode(node).setType(SpecBoolean);
2576         break;
2577
2578     case InstanceOfCustom:
2579         clobberWorld(node->origin.semantic, clobberLimit);
2580         forNode(node).setType(SpecBoolean);
2581         break;
2582             
2583     case Phi:
2584         RELEASE_ASSERT(m_graph.m_form == SSA);
2585         // The state of this node would have already been decided, but it may have become a
2586         // constant, in which case we'd like to know.
2587         if (forNode(node).m_value)
2588             m_state.setFoundConstants(true);
2589         break;
2590         
2591     case Upsilon: {
2592         m_state.createValueForNode(node->phi());
2593         forNode(node->phi()) = forNode(node->child1());
2594         break;
2595     }
2596         
2597     case Flush:
2598     case PhantomLocal:
2599         break;
2600             
2601     case Call:
2602     case TailCallInlinedCaller:
2603     case Construct:
2604     case CallVarargs:
2605     case CallForwardVarargs:
2606     case TailCallVarargsInlinedCaller:
2607     case ConstructVarargs:
2608     case ConstructForwardVarargs:
2609     case TailCallForwardVarargsInlinedCaller:
2610         clobberWorld(node->origin.semantic, clobberLimit);
2611         forNode(node).makeHeapTop();
2612         break;
2613
2614     case ForceOSRExit:
2615     case CheckBadCell:
2616         m_state.setIsValid(false);
2617         break;
2618         
2619     case InvalidationPoint:
2620         forAllValues(clobberLimit, AbstractValue::observeInvalidationPointFor);
2621         m_state.setStructureClobberState(StructuresAreWatched);
2622         break;
2623
2624     case CheckWatchdogTimer:
2625         break;
2626
2627     case Breakpoint:
2628     case ProfileWillCall:
2629     case ProfileDidCall:
2630     case ProfileType:
2631     case ProfileControlFlow:
2632     case Phantom:
2633     case CountExecution:
2634     case CheckTierUpInLoop:
2635     case CheckTierUpAtReturn:
2636     case CheckTypeInfoFlags:
2637         break;
2638
2639     case CopyRest:
2640         break;
2641             
2642     case Check: {
2643         // Simplify out checks that don't actually do checking.
2644         for (unsigned i = 0; i < AdjacencyList::Size; ++i) {
2645             Edge edge = node->children.child(i);
2646             if (!edge)
2647                 break;
2648             if (edge.isProved() || edge.willNotHaveCheck()) {
2649                 m_state.setFoundConstants(true);
2650                 break;
2651             }
2652         }
2653         break;
2654     }
2655
2656     case SetFunctionName: {
2657         clobberWorld(node->origin.semantic, clobberLimit);
2658         break;
2659     }
2660
2661     case StoreBarrier: {
2662         filter(node->child1(), SpecCell);
2663         break;
2664     }
2665
2666     case CheckTierUpAndOSREnter:
2667     case LoopHint:
2668     case ZombieHint:
2669     case ExitOK:
2670         break;
2671
2672     case Unreachable:
2673     case LastNodeType:
2674     case ArithIMul:
2675     case FiatInt52:
2676         DFG_CRASH(m_graph, node, "Unexpected node type");
2677         break;
2678     }
2679     
2680     return m_state.isValid();
2681 }
2682
2683 template<typename AbstractStateType>
2684 bool AbstractInterpreter<AbstractStateType>::executeEffects(unsigned indexInBlock)
2685 {
2686     return executeEffects(indexInBlock, m_state.block()->at(indexInBlock));
2687 }
2688
2689 template<typename AbstractStateType>
2690 bool AbstractInterpreter<AbstractStateType>::execute(unsigned indexInBlock)
2691 {
2692     Node* node = m_state.block()->at(indexInBlock);
2693     
2694     startExecuting();
2695     executeEdges(node);
2696     return executeEffects(indexInBlock, node);
2697 }
2698
2699 template<typename AbstractStateType>
2700 bool AbstractInterpreter<AbstractStateType>::execute(Node* node)
2701 {
2702     startExecuting();
2703     executeEdges(node);
2704     return executeEffects(UINT_MAX, node);
2705 }
2706
2707 template<typename AbstractStateType>
2708 void AbstractInterpreter<AbstractStateType>::clobberWorld(
2709     const CodeOrigin&, unsigned clobberLimit)
2710 {
2711     clobberStructures(clobberLimit);
2712 }
2713
2714 template<typename AbstractStateType>
2715 template<typename Functor>
2716 void AbstractInterpreter<AbstractStateType>::forAllValues(
2717     unsigned clobberLimit, Functor& functor)
2718 {
2719     if (clobberLimit >= m_state.block()->size())
2720         clobberLimit = m_state.block()->size();
2721     else
2722         clobberLimit++;
2723     ASSERT(clobberLimit <= m_state.block()->size());
2724     for (size_t i = clobberLimit; i--;)
2725         functor(forNode(m_state.block()->at(i)));
2726     if (m_graph.m_form == SSA) {
2727         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtHead.begin();
2728         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtHead.end();
2729         for (; iter != end; ++iter)
2730             functor(forNode(*iter));
2731     }
2732     for (size_t i = m_state.variables().numberOfArguments(); i--;)
2733         functor(m_state.variables().argument(i));
2734     for (size_t i = m_state.variables().numberOfLocals(); i--;)
2735         functor(m_state.variables().local(i));
2736 }
2737
2738 template<typename AbstractStateType>
2739 void AbstractInterpreter<AbstractStateType>::clobberStructures(unsigned clobberLimit)
2740 {
2741     forAllValues(clobberLimit, AbstractValue::clobberStructuresFor);
2742     setDidClobber();
2743 }
2744
2745 template<typename AbstractStateType>
2746 void AbstractInterpreter<AbstractStateType>::observeTransition(
2747     unsigned clobberLimit, Structure* from, Structure* to)
2748 {
2749     AbstractValue::TransitionObserver transitionObserver(from, to);
2750     forAllValues(clobberLimit, transitionObserver);
2751     
2752     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.
2753 }
2754
2755 template<typename AbstractStateType>
2756 void AbstractInterpreter<AbstractStateType>::observeTransitions(
2757     unsigned clobberLimit, const TransitionVector& vector)
2758 {
2759     AbstractValue::TransitionsObserver transitionsObserver(vector);
2760     forAllValues(clobberLimit, transitionsObserver);
2761     
2762     if (!ASSERT_DISABLED) {
2763         // We don't need to claim to be in a clobbered state because none of the Transition::previous structures are watchable.
2764         for (unsigned i = vector.size(); i--;)
2765             ASSERT(!vector[i].previous->dfgShouldWatch());
2766     }
2767 }
2768
2769 template<typename AbstractStateType>
2770 void AbstractInterpreter<AbstractStateType>::setDidClobber()
2771 {
2772     m_state.setDidClobber(true);
2773     m_state.setStructureClobberState(StructuresAreClobbered);
2774 }
2775
2776 template<typename AbstractStateType>
2777 void AbstractInterpreter<AbstractStateType>::dump(PrintStream& out) const
2778 {
2779     const_cast<AbstractInterpreter<AbstractStateType>*>(this)->dump(out);
2780 }
2781
2782 template<typename AbstractStateType>
2783 void AbstractInterpreter<AbstractStateType>::dump(PrintStream& out)
2784 {
2785     CommaPrinter comma(" ");
2786     HashSet<Node*> seen;
2787     if (m_graph.m_form == SSA) {
2788         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtHead.begin();
2789         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtHead.end();
2790         for (; iter != end; ++iter) {
2791             Node* node = *iter;
2792             seen.add(node);
2793             AbstractValue& value = forNode(node);
2794             if (value.isClear())
2795                 continue;
2796             out.print(comma, node, ":", value);
2797         }
2798     }
2799     for (size_t i = 0; i < m_state.block()->size(); ++i) {
2800         Node* node = m_state.block()->at(i);
2801         seen.add(node);
2802         AbstractValue& value = forNode(node);
2803         if (value.isClear())
2804             continue;
2805         out.print(comma, node, ":", value);
2806     }
2807     if (m_graph.m_form == SSA) {
2808         HashSet<Node*>::iterator iter = m_state.block()->ssa->liveAtTail.begin();
2809         HashSet<Node*>::iterator end = m_state.block()->ssa->liveAtTail.end();
2810         for (; iter != end; ++iter) {
2811             Node* node = *iter;
2812             if (seen.contains(node))
2813                 continue;
2814             AbstractValue& value = forNode(node);
2815             if (value.isClear())
2816                 continue;
2817             out.print(comma, node, ":", value);
2818         }
2819     }
2820 }
2821
2822 template<typename AbstractStateType>
2823 FiltrationResult AbstractInterpreter<AbstractStateType>::filter(
2824     AbstractValue& value, const StructureSet& set, SpeculatedType admittedTypes)
2825 {
2826     if (value.filter(m_graph, set, admittedTypes) == FiltrationOK)
2827         return FiltrationOK;
2828     m_state.setIsValid(false);
2829     return Contradiction;
2830 }
2831
2832 template<typename AbstractStateType>
2833 FiltrationResult AbstractInterpreter<AbstractStateType>::filterArrayModes(
2834     AbstractValue& value, ArrayModes arrayModes)
2835 {
2836     if (value.filterArrayModes(arrayModes) == FiltrationOK)
2837         return FiltrationOK;
2838     m_state.setIsValid(false);
2839     return Contradiction;
2840 }
2841
2842 template<typename AbstractStateType>
2843 FiltrationResult AbstractInterpreter<AbstractStateType>::filter(
2844     AbstractValue& value, SpeculatedType type)
2845 {
2846     if (value.filter(type) == FiltrationOK)
2847         return FiltrationOK;
2848     m_state.setIsValid(false);
2849     return Contradiction;
2850 }
2851
2852 template<typename AbstractStateType>
2853 FiltrationResult AbstractInterpreter<AbstractStateType>::filterByValue(
2854     AbstractValue& abstractValue, FrozenValue concreteValue)
2855 {
2856     if (abstractValue.filterByValue(concreteValue) == FiltrationOK)
2857         return FiltrationOK;
2858     m_state.setIsValid(false);
2859     return Contradiction;
2860 }
2861
2862 } } // namespace JSC::DFG
2863
2864 #endif // ENABLE(DFG_JIT)
2865
2866 #endif // DFGAbstractInterpreterInlines_h
2867