AX: Progress: [Mac] Content in label element should be used as AXTitle or AXDescription
[WebKit-https.git] / Source / JavaScriptCore / ftl / FTLLowerDFGToB3.cpp
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 #include "config.h"
27 #include "FTLLowerDFGToB3.h"
28
29 #if ENABLE(FTL_JIT)
30
31 #include "AirGenerationContext.h"
32 #include "AllowMacroScratchRegisterUsage.h"
33 #include "B3CheckValue.h"
34 #include "B3PatchpointValue.h"
35 #include "B3SlotBaseValue.h"
36 #include "B3StackmapGenerationParams.h"
37 #include "B3ValueInlines.h"
38 #include "CallFrameShuffler.h"
39 #include "CodeBlockWithJITType.h"
40 #include "DFGAbstractInterpreterInlines.h"
41 #include "DFGCapabilities.h"
42 #include "DFGDominators.h"
43 #include "DFGInPlaceAbstractState.h"
44 #include "DFGOSRAvailabilityAnalysisPhase.h"
45 #include "DFGOSRExitFuzz.h"
46 #include "DirectArguments.h"
47 #include "FTLAbstractHeapRepository.h"
48 #include "FTLAvailableRecovery.h"
49 #include "FTLExceptionTarget.h"
50 #include "FTLForOSREntryJITCode.h"
51 #include "FTLFormattedValue.h"
52 #include "FTLLazySlowPathCall.h"
53 #include "FTLLoweredNodeValue.h"
54 #include "FTLOperations.h"
55 #include "FTLOutput.h"
56 #include "FTLPatchpointExceptionHandle.h"
57 #include "FTLThunks.h"
58 #include "FTLWeightedTarget.h"
59 #include "JITAddGenerator.h"
60 #include "JITBitAndGenerator.h"
61 #include "JITBitOrGenerator.h"
62 #include "JITBitXorGenerator.h"
63 #include "JITDivGenerator.h"
64 #include "JITInlineCacheGenerator.h"
65 #include "JITLeftShiftGenerator.h"
66 #include "JITMathIC.h"
67 #include "JITMulGenerator.h"
68 #include "JITRightShiftGenerator.h"
69 #include "JITSubGenerator.h"
70 #include "JSCInlines.h"
71 #include "JSGeneratorFunction.h"
72 #include "JSLexicalEnvironment.h"
73 #include "JSMap.h"
74 #include "OperandsInlines.h"
75 #include "ScopedArguments.h"
76 #include "ScopedArgumentsTable.h"
77 #include "ScratchRegisterAllocator.h"
78 #include "SetupVarargsFrame.h"
79 #include "ShadowChicken.h"
80 #include "StructureStubInfo.h"
81 #include "VirtualRegister.h"
82 #include "Watchdog.h"
83 #include <atomic>
84 #if !OS(WINDOWS)
85 #include <dlfcn.h>
86 #endif
87 #include <unordered_set>
88 #include <wtf/Box.h>
89 #include <wtf/ProcessID.h>
90
91 namespace JSC { namespace FTL {
92
93 using namespace B3;
94 using namespace DFG;
95
96 namespace {
97
98 std::atomic<int> compileCounter;
99
100 #if !ASSERT_DISABLED
101 NO_RETURN_DUE_TO_CRASH static void ftlUnreachable(
102     CodeBlock* codeBlock, BlockIndex blockIndex, unsigned nodeIndex)
103 {
104     dataLog("Crashing in thought-to-be-unreachable FTL-generated code for ", pointerDump(codeBlock), " at basic block #", blockIndex);
105     if (nodeIndex != UINT_MAX)
106         dataLog(", node @", nodeIndex);
107     dataLog(".\n");
108     CRASH();
109 }
110 #endif
111
112 // Using this instead of typeCheck() helps to reduce the load on B3, by creating
113 // significantly less dead code.
114 #define FTL_TYPE_CHECK_WITH_EXIT_KIND(exitKind, lowValue, highValue, typesPassedThrough, failCondition) do { \
115         FormattedValue _ftc_lowValue = (lowValue);                      \
116         Edge _ftc_highValue = (highValue);                              \
117         SpeculatedType _ftc_typesPassedThrough = (typesPassedThrough);  \
118         if (!m_interpreter.needsTypeCheck(_ftc_highValue, _ftc_typesPassedThrough)) \
119             break;                                                      \
120         typeCheck(_ftc_lowValue, _ftc_highValue, _ftc_typesPassedThrough, (failCondition), exitKind); \
121     } while (false)
122
123 #define FTL_TYPE_CHECK(lowValue, highValue, typesPassedThrough, failCondition) \
124     FTL_TYPE_CHECK_WITH_EXIT_KIND(BadType, lowValue, highValue, typesPassedThrough, failCondition)
125
126 class LowerDFGToB3 {
127     WTF_MAKE_NONCOPYABLE(LowerDFGToB3);
128 public:
129     LowerDFGToB3(State& state)
130         : m_graph(state.graph)
131         , m_ftlState(state)
132         , m_out(state)
133         , m_proc(*state.proc)
134         , m_state(state.graph)
135         , m_interpreter(state.graph, m_state)
136     {
137     }
138     
139     void lower()
140     {
141         State* state = &m_ftlState;
142         
143         CString name;
144         if (verboseCompilationEnabled()) {
145             name = toCString(
146                 "jsBody_", ++compileCounter, "_", codeBlock()->inferredName(),
147                 "_", codeBlock()->hash());
148         } else
149             name = "jsBody";
150         
151         m_graph.ensureDominators();
152
153         if (verboseCompilationEnabled())
154             dataLog("Function ready, beginning lowering.\n");
155
156         m_out.initialize(m_heaps);
157
158         // We use prologue frequency for all of the initialization code.
159         m_out.setFrequency(1);
160         
161         m_prologue = m_out.newBlock();
162         m_handleExceptions = m_out.newBlock();
163
164         for (BlockIndex blockIndex = 0; blockIndex < m_graph.numBlocks(); ++blockIndex) {
165             m_highBlock = m_graph.block(blockIndex);
166             if (!m_highBlock)
167                 continue;
168             m_out.setFrequency(m_highBlock->executionCount);
169             m_blocks.add(m_highBlock, m_out.newBlock());
170         }
171
172         // Back to prologue frequency for any bocks that get sneakily created in the initialization code.
173         m_out.setFrequency(1);
174         
175         m_out.appendTo(m_prologue, m_handleExceptions);
176         m_out.initializeConstants(m_proc, m_prologue);
177         createPhiVariables();
178
179         size_t sizeOfCaptured = sizeof(JSValue) * m_graph.m_nextMachineLocal;
180         B3::SlotBaseValue* capturedBase = m_out.lockedStackSlot(sizeOfCaptured);
181         m_captured = m_out.add(capturedBase, m_out.constIntPtr(sizeOfCaptured));
182         state->capturedValue = capturedBase->slot();
183
184         auto preOrder = m_graph.blocksInPreOrder();
185
186         m_callFrame = m_out.framePointer();
187         m_tagTypeNumber = m_out.constInt64(TagTypeNumber);
188         m_tagMask = m_out.constInt64(TagMask);
189
190         // Make sure that B3 knows that we really care about the mask registers. This forces the
191         // constants to be materialized in registers.
192         m_proc.addFastConstant(m_tagTypeNumber->key());
193         m_proc.addFastConstant(m_tagMask->key());
194         
195         m_out.storePtr(m_out.constIntPtr(codeBlock()), addressFor(CallFrameSlot::codeBlock));
196
197         // Stack Overflow Check.
198         unsigned exitFrameSize = m_graph.requiredRegisterCountForExit() * sizeof(Register);
199         MacroAssembler::AbsoluteAddress addressOfStackLimit(vm().addressOfSoftStackLimit());
200         PatchpointValue* stackOverflowHandler = m_out.patchpoint(Void);
201         CallSiteIndex callSiteIndex = callSiteIndexForCodeOrigin(m_ftlState, CodeOrigin(0));
202         stackOverflowHandler->appendSomeRegister(m_callFrame);
203         stackOverflowHandler->clobber(RegisterSet::macroScratchRegisters());
204         stackOverflowHandler->numGPScratchRegisters = 1;
205         stackOverflowHandler->setGenerator(
206             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
207                 AllowMacroScratchRegisterUsage allowScratch(jit);
208                 GPRReg fp = params[0].gpr();
209                 GPRReg scratch = params.gpScratch(0);
210
211                 unsigned ftlFrameSize = params.proc().frameSize();
212
213                 jit.addPtr(MacroAssembler::TrustedImm32(-std::max(exitFrameSize, ftlFrameSize)), fp, scratch);
214                 MacroAssembler::Jump stackOverflow = jit.branchPtr(MacroAssembler::Above, addressOfStackLimit, scratch);
215
216                 params.addLatePath([=] (CCallHelpers& jit) {
217                     AllowMacroScratchRegisterUsage allowScratch(jit);
218
219                     stackOverflow.link(&jit);
220                     jit.store32(
221                         MacroAssembler::TrustedImm32(callSiteIndex.bits()),
222                         CCallHelpers::tagFor(VirtualRegister(CallFrameSlot::argumentCount)));
223                     jit.copyCalleeSavesToVMEntryFrameCalleeSavesBuffer();
224
225                     jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR0);
226                     jit.move(CCallHelpers::TrustedImmPtr(jit.codeBlock()), GPRInfo::argumentGPR1);
227                     CCallHelpers::Call throwCall = jit.call();
228
229                     jit.move(CCallHelpers::TrustedImmPtr(jit.vm()), GPRInfo::argumentGPR0);
230                     jit.move(GPRInfo::callFrameRegister, GPRInfo::argumentGPR1);
231                     CCallHelpers::Call lookupExceptionHandlerCall = jit.call();
232                     jit.jumpToExceptionHandler();
233
234                     jit.addLinkTask(
235                         [=] (LinkBuffer& linkBuffer) {
236                             linkBuffer.link(throwCall, FunctionPtr(operationThrowStackOverflowError));
237                             linkBuffer.link(lookupExceptionHandlerCall, FunctionPtr(lookupExceptionHandlerFromCallerFrame));
238                     });
239                 });
240             });
241
242         LBasicBlock firstDFGBasicBlock = lowBlock(m_graph.block(0));
243         // Check Arguments.
244         availabilityMap().clear();
245         availabilityMap().m_locals = Operands<Availability>(codeBlock()->numParameters(), 0);
246         for (unsigned i = codeBlock()->numParameters(); i--;) {
247             availabilityMap().m_locals.argument(i) =
248                 Availability(FlushedAt(FlushedJSValue, virtualRegisterForArgument(i)));
249         }
250         m_node = nullptr;
251         m_origin = NodeOrigin(CodeOrigin(0), CodeOrigin(0), true);
252         for (unsigned i = codeBlock()->numParameters(); i--;) {
253             Node* node = m_graph.m_arguments[i];
254             VirtualRegister operand = virtualRegisterForArgument(i);
255             
256             LValue jsValue = m_out.load64(addressFor(operand));
257             
258             if (node) {
259                 DFG_ASSERT(m_graph, node, operand == node->stackAccessData()->machineLocal);
260                 
261                 // This is a hack, but it's an effective one. It allows us to do CSE on the
262                 // primordial load of arguments. This assumes that the GetLocal that got put in
263                 // place of the original SetArgument doesn't have any effects before it. This
264                 // should hold true.
265                 m_loadedArgumentValues.add(node, jsValue);
266             }
267             
268             switch (m_graph.m_argumentFormats[i]) {
269             case FlushedInt32:
270                 speculate(BadType, jsValueValue(jsValue), node, isNotInt32(jsValue));
271                 break;
272             case FlushedBoolean:
273                 speculate(BadType, jsValueValue(jsValue), node, isNotBoolean(jsValue));
274                 break;
275             case FlushedCell:
276                 speculate(BadType, jsValueValue(jsValue), node, isNotCell(jsValue));
277                 break;
278             case FlushedJSValue:
279                 break;
280             default:
281                 DFG_CRASH(m_graph, node, "Bad flush format for argument");
282                 break;
283             }
284         }
285         m_out.jump(firstDFGBasicBlock);
286
287         m_out.appendTo(m_handleExceptions, firstDFGBasicBlock);
288         Box<CCallHelpers::Label> exceptionHandler = state->exceptionHandler;
289         m_out.patchpoint(Void)->setGenerator(
290             [=] (CCallHelpers& jit, const StackmapGenerationParams&) {
291                 CCallHelpers::Jump jump = jit.jump();
292                 jit.addLinkTask(
293                     [=] (LinkBuffer& linkBuffer) {
294                         linkBuffer.link(jump, linkBuffer.locationOf(*exceptionHandler));
295                     });
296             });
297         m_out.unreachable();
298
299         for (DFG::BasicBlock* block : preOrder)
300             compileBlock(block);
301
302         // Make sure everything is decorated. This does a bunch of deferred decorating. This has
303         // to happen last because our abstract heaps are generated lazily. They have to be
304         // generated lazily because we have an infiniten number of numbered, indexed, and
305         // absolute heaps. We only become aware of the ones we actually mention while lowering.
306         m_heaps.computeRangesAndDecorateInstructions();
307
308         // We create all Phi's up front, but we may then decide not to compile the basic block
309         // that would have contained one of them. So this creates orphans, which triggers B3
310         // validation failures. Calling this fixes the issue.
311         //
312         // Note that you should avoid the temptation to make this call conditional upon
313         // validation being enabled. B3 makes no guarantees of any kind of correctness when
314         // dealing with IR that would have failed validation. For example, it would be valid to
315         // write a B3 phase that so aggressively assumes the lack of orphans that it would crash
316         // if any orphans were around. We might even have such phases already.
317         m_proc.deleteOrphans();
318
319         // We put the blocks into the B3 procedure in a super weird order. Now we reorder them.
320         m_out.applyBlockOrder();
321     }
322
323 private:
324     
325     void createPhiVariables()
326     {
327         for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
328             DFG::BasicBlock* block = m_graph.block(blockIndex);
329             if (!block)
330                 continue;
331             for (unsigned nodeIndex = block->size(); nodeIndex--;) {
332                 Node* node = block->at(nodeIndex);
333                 if (node->op() != DFG::Phi)
334                     continue;
335                 LType type;
336                 switch (node->flags() & NodeResultMask) {
337                 case NodeResultDouble:
338                     type = Double;
339                     break;
340                 case NodeResultInt32:
341                     type = Int32;
342                     break;
343                 case NodeResultInt52:
344                     type = Int64;
345                     break;
346                 case NodeResultBoolean:
347                     type = Int32;
348                     break;
349                 case NodeResultJS:
350                     type = Int64;
351                     break;
352                 default:
353                     DFG_CRASH(m_graph, node, "Bad Phi node result type");
354                     break;
355                 }
356                 m_phis.add(node, m_proc.add<Value>(B3::Phi, type, Origin(node)));
357             }
358         }
359     }
360     
361     void compileBlock(DFG::BasicBlock* block)
362     {
363         if (!block)
364             return;
365         
366         if (verboseCompilationEnabled())
367             dataLog("Compiling block ", *block, "\n");
368         
369         m_highBlock = block;
370         
371         // Make sure that any blocks created while lowering code in the high block have the frequency of
372         // the high block. This is appropriate because B3 doesn't need precise frequencies. It just needs
373         // something roughly approximate for things like register allocation.
374         m_out.setFrequency(m_highBlock->executionCount);
375         
376         LBasicBlock lowBlock = m_blocks.get(m_highBlock);
377         
378         m_nextHighBlock = 0;
379         for (BlockIndex nextBlockIndex = m_highBlock->index + 1; nextBlockIndex < m_graph.numBlocks(); ++nextBlockIndex) {
380             m_nextHighBlock = m_graph.block(nextBlockIndex);
381             if (m_nextHighBlock)
382                 break;
383         }
384         m_nextLowBlock = m_nextHighBlock ? m_blocks.get(m_nextHighBlock) : 0;
385         
386         // All of this effort to find the next block gives us the ability to keep the
387         // generated IR in roughly program order. This ought not affect the performance
388         // of the generated code (since we expect B3 to reorder things) but it will
389         // make IR dumps easier to read.
390         m_out.appendTo(lowBlock, m_nextLowBlock);
391         
392         if (Options::ftlCrashes())
393             m_out.trap();
394         
395         if (!m_highBlock->cfaHasVisited) {
396             if (verboseCompilationEnabled())
397                 dataLog("Bailing because CFA didn't reach.\n");
398             crash(m_highBlock, nullptr);
399             return;
400         }
401         
402         m_availabilityCalculator.beginBlock(m_highBlock);
403         
404         m_state.reset();
405         m_state.beginBasicBlock(m_highBlock);
406         
407         for (m_nodeIndex = 0; m_nodeIndex < m_highBlock->size(); ++m_nodeIndex) {
408             if (!compileNode(m_nodeIndex))
409                 break;
410         }
411     }
412
413     void safelyInvalidateAfterTermination()
414     {
415         if (verboseCompilationEnabled())
416             dataLog("Bailing.\n");
417         crash();
418
419         // Invalidate dominated blocks. Under normal circumstances we would expect
420         // them to be invalidated already. But you can have the CFA become more
421         // precise over time because the structures of objects change on the main
422         // thread. Failing to do this would result in weird crashes due to a value
423         // being used but not defined. Race conditions FTW!
424         for (BlockIndex blockIndex = m_graph.numBlocks(); blockIndex--;) {
425             DFG::BasicBlock* target = m_graph.block(blockIndex);
426             if (!target)
427                 continue;
428             if (m_graph.m_dominators->dominates(m_highBlock, target)) {
429                 if (verboseCompilationEnabled())
430                     dataLog("Block ", *target, " will bail also.\n");
431                 target->cfaHasVisited = false;
432             }
433         }
434     }
435
436     bool compileNode(unsigned nodeIndex)
437     {
438         if (!m_state.isValid()) {
439             safelyInvalidateAfterTermination();
440             return false;
441         }
442         
443         m_node = m_highBlock->at(nodeIndex);
444         m_origin = m_node->origin;
445         m_out.setOrigin(m_node);
446         
447         if (verboseCompilationEnabled())
448             dataLog("Lowering ", m_node, "\n");
449         
450         m_availableRecoveries.resize(0);
451         
452         m_interpreter.startExecuting();
453         m_interpreter.executeKnownEdgeTypes(m_node);
454         
455         switch (m_node->op()) {
456         case DFG::Upsilon:
457             compileUpsilon();
458             break;
459         case DFG::Phi:
460             compilePhi();
461             break;
462         case JSConstant:
463             break;
464         case DoubleConstant:
465             compileDoubleConstant();
466             break;
467         case Int52Constant:
468             compileInt52Constant();
469             break;
470         case LazyJSConstant:
471             compileLazyJSConstant();
472             break;
473         case DoubleRep:
474             compileDoubleRep();
475             break;
476         case DoubleAsInt32:
477             compileDoubleAsInt32();
478             break;
479         case DFG::ValueRep:
480             compileValueRep();
481             break;
482         case Int52Rep:
483             compileInt52Rep();
484             break;
485         case ValueToInt32:
486             compileValueToInt32();
487             break;
488         case BooleanToNumber:
489             compileBooleanToNumber();
490             break;
491         case ExtractOSREntryLocal:
492             compileExtractOSREntryLocal();
493             break;
494         case GetStack:
495             compileGetStack();
496             break;
497         case PutStack:
498             compilePutStack();
499             break;
500         case DFG::Check:
501             compileNoOp();
502             break;
503         case CallObjectConstructor:
504             compileCallObjectConstructor();
505             break;
506         case ToThis:
507             compileToThis();
508             break;
509         case ValueAdd:
510             compileValueAdd();
511             break;
512         case StrCat:
513             compileStrCat();
514             break;
515         case ArithAdd:
516         case ArithSub:
517             compileArithAddOrSub();
518             break;
519         case ArithClz32:
520             compileArithClz32();
521             break;
522         case ArithMul:
523             compileArithMul();
524             break;
525         case ArithDiv:
526             compileArithDiv();
527             break;
528         case ArithMod:
529             compileArithMod();
530             break;
531         case ArithMin:
532         case ArithMax:
533             compileArithMinOrMax();
534             break;
535         case ArithAbs:
536             compileArithAbs();
537             break;
538         case ArithSin:
539             compileArithSin();
540             break;
541         case ArithCos:
542             compileArithCos();
543             break;
544         case ArithTan:
545             compileArithTan();
546             break;
547         case ArithPow:
548             compileArithPow();
549             break;
550         case ArithRandom:
551             compileArithRandom();
552             break;
553         case ArithRound:
554             compileArithRound();
555             break;
556         case ArithFloor:
557             compileArithFloor();
558             break;
559         case ArithCeil:
560             compileArithCeil();
561             break;
562         case ArithTrunc:
563             compileArithTrunc();
564             break;
565         case ArithSqrt:
566             compileArithSqrt();
567             break;
568         case ArithLog:
569             compileArithLog();
570             break;
571         case ArithFRound:
572             compileArithFRound();
573             break;
574         case ArithNegate:
575             compileArithNegate();
576             break;
577         case DFG::BitAnd:
578             compileBitAnd();
579             break;
580         case DFG::BitOr:
581             compileBitOr();
582             break;
583         case DFG::BitXor:
584             compileBitXor();
585             break;
586         case BitRShift:
587             compileBitRShift();
588             break;
589         case BitLShift:
590             compileBitLShift();
591             break;
592         case BitURShift:
593             compileBitURShift();
594             break;
595         case UInt32ToNumber:
596             compileUInt32ToNumber();
597             break;
598         case CheckStructure:
599             compileCheckStructure();
600             break;
601         case CheckCell:
602             compileCheckCell();
603             break;
604         case CheckNotEmpty:
605             compileCheckNotEmpty();
606             break;
607         case CheckBadCell:
608             compileCheckBadCell();
609             break;
610         case CheckStringIdent:
611             compileCheckStringIdent();
612             break;
613         case GetExecutable:
614             compileGetExecutable();
615             break;
616         case ArrayifyToStructure:
617             compileArrayifyToStructure();
618             break;
619         case PutStructure:
620             compilePutStructure();
621             break;
622         case TryGetById:
623             compileGetById(AccessType::GetPure);
624             break;
625         case GetById:
626         case GetByIdFlush:
627             compileGetById(AccessType::Get);
628             break;
629         case GetByIdWithThis:
630             compileGetByIdWithThis();
631             break;
632         case In:
633             compileIn();
634             break;
635         case HasOwnProperty:
636             compileHasOwnProperty();
637             break;
638         case PutById:
639         case PutByIdDirect:
640         case PutByIdFlush:
641             compilePutById();
642             break;
643         case PutByIdWithThis:
644             compilePutByIdWithThis();
645             break;
646         case PutGetterById:
647         case PutSetterById:
648             compilePutAccessorById();
649             break;
650         case PutGetterSetterById:
651             compilePutGetterSetterById();
652             break;
653         case PutGetterByVal:
654         case PutSetterByVal:
655             compilePutAccessorByVal();
656             break;
657         case GetButterfly:
658             compileGetButterfly();
659             break;
660         case ConstantStoragePointer:
661             compileConstantStoragePointer();
662             break;
663         case GetIndexedPropertyStorage:
664             compileGetIndexedPropertyStorage();
665             break;
666         case CheckArray:
667             compileCheckArray();
668             break;
669         case GetArrayLength:
670             compileGetArrayLength();
671             break;
672         case CheckInBounds:
673             compileCheckInBounds();
674             break;
675         case GetByVal:
676             compileGetByVal();
677             break;
678         case GetMyArgumentByVal:
679         case GetMyArgumentByValOutOfBounds:
680             compileGetMyArgumentByVal();
681             break;
682         case GetByValWithThis:
683             compileGetByValWithThis();
684             break;
685         case PutByVal:
686         case PutByValAlias:
687         case PutByValDirect:
688             compilePutByVal();
689             break;
690         case PutByValWithThis:
691             compilePutByValWithThis();
692             break;
693         case ArrayPush:
694             compileArrayPush();
695             break;
696         case ArrayPop:
697             compileArrayPop();
698             break;
699         case CreateActivation:
700             compileCreateActivation();
701             break;
702         case NewFunction:
703         case NewGeneratorFunction:
704             compileNewFunction();
705             break;
706         case CreateDirectArguments:
707             compileCreateDirectArguments();
708             break;
709         case CreateScopedArguments:
710             compileCreateScopedArguments();
711             break;
712         case CreateClonedArguments:
713             compileCreateClonedArguments();
714             break;
715         case NewObject:
716             compileNewObject();
717             break;
718         case NewArray:
719             compileNewArray();
720             break;
721         case NewArrayBuffer:
722             compileNewArrayBuffer();
723             break;
724         case NewArrayWithSize:
725             compileNewArrayWithSize();
726             break;
727         case NewTypedArray:
728             compileNewTypedArray();
729             break;
730         case GetTypedArrayByteOffset:
731             compileGetTypedArrayByteOffset();
732             break;
733         case AllocatePropertyStorage:
734             compileAllocatePropertyStorage();
735             break;
736         case ReallocatePropertyStorage:
737             compileReallocatePropertyStorage();
738             break;
739         case ToNumber:
740             compileToNumber();
741             break;
742         case ToString:
743         case CallStringConstructor:
744             compileToStringOrCallStringConstructor();
745             break;
746         case ToPrimitive:
747             compileToPrimitive();
748             break;
749         case MakeRope:
750             compileMakeRope();
751             break;
752         case StringCharAt:
753             compileStringCharAt();
754             break;
755         case StringCharCodeAt:
756             compileStringCharCodeAt();
757             break;
758         case StringFromCharCode:
759             compileStringFromCharCode();
760             break;
761         case GetByOffset:
762         case GetGetterSetterByOffset:
763             compileGetByOffset();
764             break;
765         case GetGetter:
766             compileGetGetter();
767             break;
768         case GetSetter:
769             compileGetSetter();
770             break;
771         case MultiGetByOffset:
772             compileMultiGetByOffset();
773             break;
774         case PutByOffset:
775             compilePutByOffset();
776             break;
777         case MultiPutByOffset:
778             compileMultiPutByOffset();
779             break;
780         case GetGlobalVar:
781         case GetGlobalLexicalVariable:
782             compileGetGlobalVariable();
783             break;
784         case PutGlobalVariable:
785             compilePutGlobalVariable();
786             break;
787         case NotifyWrite:
788             compileNotifyWrite();
789             break;
790         case GetCallee:
791             compileGetCallee();
792             break;
793         case GetArgumentCountIncludingThis:
794             compileGetArgumentCountIncludingThis();
795             break;
796         case GetScope:
797             compileGetScope();
798             break;
799         case SkipScope:
800             compileSkipScope();
801             break;
802         case GetGlobalObject:
803             compileGetGlobalObject();
804             break;
805         case GetClosureVar:
806             compileGetClosureVar();
807             break;
808         case PutClosureVar:
809             compilePutClosureVar();
810             break;
811         case GetFromArguments:
812             compileGetFromArguments();
813             break;
814         case PutToArguments:
815             compilePutToArguments();
816             break;
817         case CompareEq:
818             compileCompareEq();
819             break;
820         case CompareStrictEq:
821             compileCompareStrictEq();
822             break;
823         case CompareLess:
824             compileCompareLess();
825             break;
826         case CompareLessEq:
827             compileCompareLessEq();
828             break;
829         case CompareGreater:
830             compileCompareGreater();
831             break;
832         case CompareGreaterEq:
833             compileCompareGreaterEq();
834             break;
835         case CompareEqPtr:
836             compileCompareEqPtr();
837             break;
838         case LogicalNot:
839             compileLogicalNot();
840             break;
841         case Call:
842         case TailCallInlinedCaller:
843         case Construct:
844             compileCallOrConstruct();
845             break;
846         case TailCall:
847             compileTailCall();
848             break;
849         case CallVarargs:
850         case CallForwardVarargs:
851         case TailCallVarargs:
852         case TailCallVarargsInlinedCaller:
853         case TailCallForwardVarargs:
854         case TailCallForwardVarargsInlinedCaller:
855         case ConstructVarargs:
856         case ConstructForwardVarargs:
857             compileCallOrConstructVarargs();
858             break;
859         case CallEval:
860             compileCallEval();
861             break;
862         case LoadVarargs:
863             compileLoadVarargs();
864             break;
865         case ForwardVarargs:
866             compileForwardVarargs();
867             break;
868         case DFG::Jump:
869             compileJump();
870             break;
871         case DFG::Branch:
872             compileBranch();
873             break;
874         case DFG::Switch:
875             compileSwitch();
876             break;
877         case DFG::Return:
878             compileReturn();
879             break;
880         case ForceOSRExit:
881             compileForceOSRExit();
882             break;
883         case Throw:
884         case ThrowReferenceError:
885             compileThrow();
886             break;
887         case InvalidationPoint:
888             compileInvalidationPoint();
889             break;
890         case IsEmpty:
891             compileIsEmpty();
892             break;
893         case IsUndefined:
894             compileIsUndefined();
895             break;
896         case IsBoolean:
897             compileIsBoolean();
898             break;
899         case IsNumber:
900             compileIsNumber();
901             break;
902         case IsCellWithType:
903             compileIsCellWithType();
904             break;
905         case MapHash:
906             compileMapHash();
907             break;
908         case GetMapBucket:
909             compileGetMapBucket();
910             break;
911         case LoadFromJSMapBucket:
912             compileLoadFromJSMapBucket();
913             break;
914         case IsNonEmptyMapBucket:
915             compileIsNonEmptyMapBucket();
916             break;
917         case IsObject:
918             compileIsObject();
919             break;
920         case IsObjectOrNull:
921             compileIsObjectOrNull();
922             break;
923         case IsFunction:
924             compileIsFunction();
925             break;
926         case IsTypedArrayView:
927             compileIsTypedArrayView();
928             break;
929         case TypeOf:
930             compileTypeOf();
931             break;
932         case CheckTypeInfoFlags:
933             compileCheckTypeInfoFlags();
934             break;
935         case OverridesHasInstance:
936             compileOverridesHasInstance();
937             break;
938         case InstanceOf:
939             compileInstanceOf();
940             break;
941         case InstanceOfCustom:
942             compileInstanceOfCustom();
943             break;
944         case CountExecution:
945             compileCountExecution();
946             break;
947         case StoreBarrier:
948             compileStoreBarrier();
949             break;
950         case HasIndexedProperty:
951             compileHasIndexedProperty();
952             break;
953         case HasGenericProperty:
954             compileHasGenericProperty();
955             break;
956         case HasStructureProperty:
957             compileHasStructureProperty();
958             break;
959         case GetDirectPname:
960             compileGetDirectPname();
961             break;
962         case GetEnumerableLength:
963             compileGetEnumerableLength();
964             break;
965         case GetPropertyEnumerator:
966             compileGetPropertyEnumerator();
967             break;
968         case GetEnumeratorStructurePname:
969             compileGetEnumeratorStructurePname();
970             break;
971         case GetEnumeratorGenericPname:
972             compileGetEnumeratorGenericPname();
973             break;
974         case ToIndexString:
975             compileToIndexString();
976             break;
977         case CheckStructureImmediate:
978             compileCheckStructureImmediate();
979             break;
980         case MaterializeNewObject:
981             compileMaterializeNewObject();
982             break;
983         case MaterializeCreateActivation:
984             compileMaterializeCreateActivation();
985             break;
986         case CheckWatchdogTimer:
987             compileCheckWatchdogTimer();
988             break;
989         case CreateRest:
990             compileCreateRest();
991             break;
992         case GetRestLength:
993             compileGetRestLength();
994             break;
995         case RegExpExec:
996             compileRegExpExec();
997             break;
998         case RegExpTest:
999             compileRegExpTest();
1000             break;
1001         case NewRegexp:
1002             compileNewRegexp();
1003             break;
1004         case SetFunctionName:
1005             compileSetFunctionName();
1006             break;
1007         case StringReplace:
1008         case StringReplaceRegExp:
1009             compileStringReplace();
1010             break;
1011         case GetRegExpObjectLastIndex:
1012             compileGetRegExpObjectLastIndex();
1013             break;
1014         case SetRegExpObjectLastIndex:
1015             compileSetRegExpObjectLastIndex();
1016             break;
1017         case LogShadowChickenPrologue:
1018             compileLogShadowChickenPrologue();
1019             break;
1020         case LogShadowChickenTail:
1021             compileLogShadowChickenTail();
1022             break;
1023         case RecordRegExpCachedResult:
1024             compileRecordRegExpCachedResult();
1025             break;
1026         case ResolveScope:
1027             compileResolveScope();
1028             break;
1029         case GetDynamicVar:
1030             compileGetDynamicVar();
1031             break;
1032         case PutDynamicVar:
1033             compilePutDynamicVar();
1034             break;
1035         case Unreachable:
1036             compileUnreachable();
1037             break;
1038
1039         case PhantomLocal:
1040         case LoopHint:
1041         case MovHint:
1042         case ZombieHint:
1043         case ExitOK:
1044         case PhantomNewObject:
1045         case PhantomNewFunction:
1046         case PhantomNewGeneratorFunction:
1047         case PhantomCreateActivation:
1048         case PhantomDirectArguments:
1049         case PhantomClonedArguments:
1050         case PutHint:
1051         case BottomValue:
1052         case KillStack:
1053             break;
1054         default:
1055             DFG_CRASH(m_graph, m_node, "Unrecognized node in FTL backend");
1056             break;
1057         }
1058         
1059         if (m_node->isTerminal())
1060             return false;
1061         
1062         if (!m_state.isValid()) {
1063             safelyInvalidateAfterTermination();
1064             return false;
1065         }
1066
1067         m_availabilityCalculator.executeNode(m_node);
1068         m_interpreter.executeEffects(nodeIndex);
1069         
1070         return true;
1071     }
1072
1073     void compileUpsilon()
1074     {
1075         LValue upsilonValue = nullptr;
1076         switch (m_node->child1().useKind()) {
1077         case DoubleRepUse:
1078             upsilonValue = lowDouble(m_node->child1());
1079             break;
1080         case Int32Use:
1081         case KnownInt32Use:
1082             upsilonValue = lowInt32(m_node->child1());
1083             break;
1084         case Int52RepUse:
1085             upsilonValue = lowInt52(m_node->child1());
1086             break;
1087         case BooleanUse:
1088         case KnownBooleanUse:
1089             upsilonValue = lowBoolean(m_node->child1());
1090             break;
1091         case CellUse:
1092         case KnownCellUse:
1093             upsilonValue = lowCell(m_node->child1());
1094             break;
1095         case UntypedUse:
1096             upsilonValue = lowJSValue(m_node->child1());
1097             break;
1098         default:
1099             DFG_CRASH(m_graph, m_node, "Bad use kind");
1100             break;
1101         }
1102         ValueFromBlock upsilon = m_out.anchor(upsilonValue);
1103         LValue phiNode = m_phis.get(m_node->phi());
1104         m_out.addIncomingToPhi(phiNode, upsilon);
1105     }
1106     
1107     void compilePhi()
1108     {
1109         LValue phi = m_phis.get(m_node);
1110         m_out.m_block->append(phi);
1111
1112         switch (m_node->flags() & NodeResultMask) {
1113         case NodeResultDouble:
1114             setDouble(phi);
1115             break;
1116         case NodeResultInt32:
1117             setInt32(phi);
1118             break;
1119         case NodeResultInt52:
1120             setInt52(phi);
1121             break;
1122         case NodeResultBoolean:
1123             setBoolean(phi);
1124             break;
1125         case NodeResultJS:
1126             setJSValue(phi);
1127             break;
1128         default:
1129             DFG_CRASH(m_graph, m_node, "Bad use kind");
1130             break;
1131         }
1132     }
1133     
1134     void compileDoubleConstant()
1135     {
1136         setDouble(m_out.constDouble(m_node->asNumber()));
1137     }
1138     
1139     void compileInt52Constant()
1140     {
1141         int64_t value = m_node->asAnyInt();
1142         
1143         setInt52(m_out.constInt64(value << JSValue::int52ShiftAmount));
1144         setStrictInt52(m_out.constInt64(value));
1145     }
1146
1147     void compileLazyJSConstant()
1148     {
1149         PatchpointValue* patchpoint = m_out.patchpoint(Int64);
1150         LazyJSValue value = m_node->lazyJSValue();
1151         patchpoint->setGenerator(
1152             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
1153                 value.emit(jit, JSValueRegs(params[0].gpr()));
1154             });
1155         patchpoint->effects = Effects::none();
1156         setJSValue(patchpoint);
1157     }
1158
1159     void compileDoubleRep()
1160     {
1161         switch (m_node->child1().useKind()) {
1162         case RealNumberUse: {
1163             LValue value = lowJSValue(m_node->child1(), ManualOperandSpeculation);
1164             
1165             LValue doubleValue = unboxDouble(value);
1166             
1167             LBasicBlock intCase = m_out.newBlock();
1168             LBasicBlock continuation = m_out.newBlock();
1169             
1170             ValueFromBlock fastResult = m_out.anchor(doubleValue);
1171             m_out.branch(
1172                 m_out.doubleEqual(doubleValue, doubleValue),
1173                 usually(continuation), rarely(intCase));
1174             
1175             LBasicBlock lastNext = m_out.appendTo(intCase, continuation);
1176
1177             FTL_TYPE_CHECK(
1178                 jsValueValue(value), m_node->child1(), SpecBytecodeRealNumber,
1179                 isNotInt32(value, provenType(m_node->child1()) & ~SpecDoubleReal));
1180             ValueFromBlock slowResult = m_out.anchor(m_out.intToDouble(unboxInt32(value)));
1181             m_out.jump(continuation);
1182             
1183             m_out.appendTo(continuation, lastNext);
1184             
1185             setDouble(m_out.phi(Double, fastResult, slowResult));
1186             return;
1187         }
1188             
1189         case NotCellUse:
1190         case NumberUse: {
1191             bool shouldConvertNonNumber = m_node->child1().useKind() == NotCellUse;
1192             
1193             LValue value = lowJSValue(m_node->child1(), ManualOperandSpeculation);
1194
1195             LBasicBlock intCase = m_out.newBlock();
1196             LBasicBlock doubleTesting = m_out.newBlock();
1197             LBasicBlock doubleCase = m_out.newBlock();
1198             LBasicBlock nonDoubleCase = m_out.newBlock();
1199             LBasicBlock continuation = m_out.newBlock();
1200             
1201             m_out.branch(
1202                 isNotInt32(value, provenType(m_node->child1())),
1203                 unsure(doubleTesting), unsure(intCase));
1204             
1205             LBasicBlock lastNext = m_out.appendTo(intCase, doubleTesting);
1206             
1207             ValueFromBlock intToDouble = m_out.anchor(
1208                 m_out.intToDouble(unboxInt32(value)));
1209             m_out.jump(continuation);
1210             
1211             m_out.appendTo(doubleTesting, doubleCase);
1212             LValue valueIsNumber = isNumber(value, provenType(m_node->child1()));
1213             m_out.branch(valueIsNumber, usually(doubleCase), rarely(nonDoubleCase));
1214
1215             m_out.appendTo(doubleCase, nonDoubleCase);
1216             ValueFromBlock unboxedDouble = m_out.anchor(unboxDouble(value));
1217             m_out.jump(continuation);
1218
1219             if (shouldConvertNonNumber) {
1220                 LBasicBlock undefinedCase = m_out.newBlock();
1221                 LBasicBlock testNullCase = m_out.newBlock();
1222                 LBasicBlock nullCase = m_out.newBlock();
1223                 LBasicBlock testBooleanTrueCase = m_out.newBlock();
1224                 LBasicBlock convertBooleanTrueCase = m_out.newBlock();
1225                 LBasicBlock convertBooleanFalseCase = m_out.newBlock();
1226
1227                 m_out.appendTo(nonDoubleCase, undefinedCase);
1228                 LValue valueIsUndefined = m_out.equal(value, m_out.constInt64(ValueUndefined));
1229                 m_out.branch(valueIsUndefined, unsure(undefinedCase), unsure(testNullCase));
1230
1231                 m_out.appendTo(undefinedCase, testNullCase);
1232                 ValueFromBlock convertedUndefined = m_out.anchor(m_out.constDouble(PNaN));
1233                 m_out.jump(continuation);
1234
1235                 m_out.appendTo(testNullCase, nullCase);
1236                 LValue valueIsNull = m_out.equal(value, m_out.constInt64(ValueNull));
1237                 m_out.branch(valueIsNull, unsure(nullCase), unsure(testBooleanTrueCase));
1238
1239                 m_out.appendTo(nullCase, testBooleanTrueCase);
1240                 ValueFromBlock convertedNull = m_out.anchor(m_out.constDouble(0));
1241                 m_out.jump(continuation);
1242
1243                 m_out.appendTo(testBooleanTrueCase, convertBooleanTrueCase);
1244                 LValue valueIsBooleanTrue = m_out.equal(value, m_out.constInt64(ValueTrue));
1245                 m_out.branch(valueIsBooleanTrue, unsure(convertBooleanTrueCase), unsure(convertBooleanFalseCase));
1246
1247                 m_out.appendTo(convertBooleanTrueCase, convertBooleanFalseCase);
1248                 ValueFromBlock convertedTrue = m_out.anchor(m_out.constDouble(1));
1249                 m_out.jump(continuation);
1250
1251                 m_out.appendTo(convertBooleanFalseCase, continuation);
1252
1253                 LValue valueIsNotBooleanFalse = m_out.notEqual(value, m_out.constInt64(ValueFalse));
1254                 FTL_TYPE_CHECK(jsValueValue(value), m_node->child1(), ~SpecCell, valueIsNotBooleanFalse);
1255                 ValueFromBlock convertedFalse = m_out.anchor(m_out.constDouble(0));
1256                 m_out.jump(continuation);
1257
1258                 m_out.appendTo(continuation, lastNext);
1259                 setDouble(m_out.phi(Double, intToDouble, unboxedDouble, convertedUndefined, convertedNull, convertedTrue, convertedFalse));
1260                 return;
1261             }
1262             m_out.appendTo(nonDoubleCase, continuation);
1263             FTL_TYPE_CHECK(jsValueValue(value), m_node->child1(), SpecBytecodeNumber, m_out.booleanTrue);
1264             m_out.unreachable();
1265
1266             m_out.appendTo(continuation, lastNext);
1267
1268             setDouble(m_out.phi(Double, intToDouble, unboxedDouble));
1269             return;
1270         }
1271             
1272         case Int52RepUse: {
1273             setDouble(strictInt52ToDouble(lowStrictInt52(m_node->child1())));
1274             return;
1275         }
1276             
1277         default:
1278             DFG_CRASH(m_graph, m_node, "Bad use kind");
1279         }
1280     }
1281
1282     void compileDoubleAsInt32()
1283     {
1284         LValue integerValue = convertDoubleToInt32(lowDouble(m_node->child1()), shouldCheckNegativeZero(m_node->arithMode()));
1285         setInt32(integerValue);
1286     }
1287
1288     void compileValueRep()
1289     {
1290         switch (m_node->child1().useKind()) {
1291         case DoubleRepUse: {
1292             LValue value = lowDouble(m_node->child1());
1293             
1294             if (m_interpreter.needsTypeCheck(m_node->child1(), ~SpecDoubleImpureNaN)) {
1295                 value = m_out.select(
1296                     m_out.doubleEqual(value, value), value, m_out.constDouble(PNaN));
1297             }
1298             
1299             setJSValue(boxDouble(value));
1300             return;
1301         }
1302             
1303         case Int52RepUse: {
1304             setJSValue(strictInt52ToJSValue(lowStrictInt52(m_node->child1())));
1305             return;
1306         }
1307             
1308         default:
1309             DFG_CRASH(m_graph, m_node, "Bad use kind");
1310         }
1311     }
1312     
1313     void compileInt52Rep()
1314     {
1315         switch (m_node->child1().useKind()) {
1316         case Int32Use:
1317             setStrictInt52(m_out.signExt32To64(lowInt32(m_node->child1())));
1318             return;
1319             
1320         case AnyIntUse:
1321             setStrictInt52(
1322                 jsValueToStrictInt52(
1323                     m_node->child1(), lowJSValue(m_node->child1(), ManualOperandSpeculation)));
1324             return;
1325             
1326         case DoubleRepAnyIntUse:
1327             setStrictInt52(
1328                 doubleToStrictInt52(
1329                     m_node->child1(), lowDouble(m_node->child1())));
1330             return;
1331             
1332         default:
1333             RELEASE_ASSERT_NOT_REACHED();
1334         }
1335     }
1336     
1337     void compileValueToInt32()
1338     {
1339         switch (m_node->child1().useKind()) {
1340         case Int52RepUse:
1341             setInt32(m_out.castToInt32(lowStrictInt52(m_node->child1())));
1342             break;
1343             
1344         case DoubleRepUse:
1345             setInt32(doubleToInt32(lowDouble(m_node->child1())));
1346             break;
1347             
1348         case NumberUse:
1349         case NotCellUse: {
1350             LoweredNodeValue value = m_int32Values.get(m_node->child1().node());
1351             if (isValid(value)) {
1352                 setInt32(value.value());
1353                 break;
1354             }
1355             
1356             value = m_jsValueValues.get(m_node->child1().node());
1357             if (isValid(value)) {
1358                 setInt32(numberOrNotCellToInt32(m_node->child1(), value.value()));
1359                 break;
1360             }
1361             
1362             // We'll basically just get here for constants. But it's good to have this
1363             // catch-all since we often add new representations into the mix.
1364             setInt32(
1365                 numberOrNotCellToInt32(
1366                     m_node->child1(),
1367                     lowJSValue(m_node->child1(), ManualOperandSpeculation)));
1368             break;
1369         }
1370             
1371         default:
1372             DFG_CRASH(m_graph, m_node, "Bad use kind");
1373             break;
1374         }
1375     }
1376     
1377     void compileBooleanToNumber()
1378     {
1379         switch (m_node->child1().useKind()) {
1380         case BooleanUse: {
1381             setInt32(m_out.zeroExt(lowBoolean(m_node->child1()), Int32));
1382             return;
1383         }
1384             
1385         case UntypedUse: {
1386             LValue value = lowJSValue(m_node->child1());
1387             
1388             if (!m_interpreter.needsTypeCheck(m_node->child1(), SpecBoolInt32 | SpecBoolean)) {
1389                 setInt32(m_out.bitAnd(m_out.castToInt32(value), m_out.int32One));
1390                 return;
1391             }
1392             
1393             LBasicBlock booleanCase = m_out.newBlock();
1394             LBasicBlock continuation = m_out.newBlock();
1395             
1396             ValueFromBlock notBooleanResult = m_out.anchor(value);
1397             m_out.branch(
1398                 isBoolean(value, provenType(m_node->child1())),
1399                 unsure(booleanCase), unsure(continuation));
1400             
1401             LBasicBlock lastNext = m_out.appendTo(booleanCase, continuation);
1402             ValueFromBlock booleanResult = m_out.anchor(m_out.bitOr(
1403                 m_out.zeroExt(unboxBoolean(value), Int64), m_tagTypeNumber));
1404             m_out.jump(continuation);
1405             
1406             m_out.appendTo(continuation, lastNext);
1407             setJSValue(m_out.phi(Int64, booleanResult, notBooleanResult));
1408             return;
1409         }
1410             
1411         default:
1412             RELEASE_ASSERT_NOT_REACHED();
1413             return;
1414         }
1415     }
1416
1417     void compileExtractOSREntryLocal()
1418     {
1419         EncodedJSValue* buffer = static_cast<EncodedJSValue*>(
1420             m_ftlState.jitCode->ftlForOSREntry()->entryBuffer()->dataBuffer());
1421         setJSValue(m_out.load64(m_out.absolute(buffer + m_node->unlinkedLocal().toLocal())));
1422     }
1423     
1424     void compileGetStack()
1425     {
1426         // GetLocals arise only for captured variables and arguments. For arguments, we might have
1427         // already loaded it.
1428         if (LValue value = m_loadedArgumentValues.get(m_node)) {
1429             setJSValue(value);
1430             return;
1431         }
1432         
1433         StackAccessData* data = m_node->stackAccessData();
1434         AbstractValue& value = m_state.variables().operand(data->local);
1435         
1436         DFG_ASSERT(m_graph, m_node, isConcrete(data->format));
1437         DFG_ASSERT(m_graph, m_node, data->format != FlushedDouble); // This just happens to not arise for GetStacks, right now. It would be trivial to support.
1438         
1439         if (isInt32Speculation(value.m_type))
1440             setInt32(m_out.load32(payloadFor(data->machineLocal)));
1441         else
1442             setJSValue(m_out.load64(addressFor(data->machineLocal)));
1443     }
1444     
1445     void compilePutStack()
1446     {
1447         StackAccessData* data = m_node->stackAccessData();
1448         switch (data->format) {
1449         case FlushedJSValue: {
1450             LValue value = lowJSValue(m_node->child1());
1451             m_out.store64(value, addressFor(data->machineLocal));
1452             break;
1453         }
1454             
1455         case FlushedDouble: {
1456             LValue value = lowDouble(m_node->child1());
1457             m_out.storeDouble(value, addressFor(data->machineLocal));
1458             break;
1459         }
1460             
1461         case FlushedInt32: {
1462             LValue value = lowInt32(m_node->child1());
1463             m_out.store32(value, payloadFor(data->machineLocal));
1464             break;
1465         }
1466             
1467         case FlushedInt52: {
1468             LValue value = lowInt52(m_node->child1());
1469             m_out.store64(value, addressFor(data->machineLocal));
1470             break;
1471         }
1472             
1473         case FlushedCell: {
1474             LValue value = lowCell(m_node->child1());
1475             m_out.store64(value, addressFor(data->machineLocal));
1476             break;
1477         }
1478             
1479         case FlushedBoolean: {
1480             speculateBoolean(m_node->child1());
1481             m_out.store64(
1482                 lowJSValue(m_node->child1(), ManualOperandSpeculation),
1483                 addressFor(data->machineLocal));
1484             break;
1485         }
1486             
1487         default:
1488             DFG_CRASH(m_graph, m_node, "Bad flush format");
1489             break;
1490         }
1491     }
1492     
1493     void compileNoOp()
1494     {
1495         DFG_NODE_DO_TO_CHILDREN(m_graph, m_node, speculate);
1496     }
1497
1498     void compileCallObjectConstructor()
1499     {
1500         JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic);
1501         LValue value = lowJSValue(m_node->child1());
1502
1503         LBasicBlock isCellCase = m_out.newBlock();
1504         LBasicBlock slowCase = m_out.newBlock();
1505         LBasicBlock continuation = m_out.newBlock();
1506
1507         m_out.branch(isCell(value, provenType(m_node->child1())), usually(isCellCase), rarely(slowCase));
1508
1509         LBasicBlock lastNext = m_out.appendTo(isCellCase, slowCase);
1510         ValueFromBlock fastResult = m_out.anchor(value);
1511         m_out.branch(isObject(value), usually(continuation), rarely(slowCase));
1512
1513         m_out.appendTo(slowCase, continuation);
1514         ValueFromBlock slowResult = m_out.anchor(vmCall(Int64, m_out.operation(operationObjectConstructor), m_callFrame, m_out.constIntPtr(globalObject), value));
1515         m_out.jump(continuation);
1516
1517         m_out.appendTo(continuation, lastNext);
1518         setJSValue(m_out.phi(Int64, fastResult, slowResult));
1519     }
1520     
1521     void compileToThis()
1522     {
1523         LValue value = lowJSValue(m_node->child1());
1524         
1525         LBasicBlock isCellCase = m_out.newBlock();
1526         LBasicBlock slowCase = m_out.newBlock();
1527         LBasicBlock continuation = m_out.newBlock();
1528         
1529         m_out.branch(
1530             isCell(value, provenType(m_node->child1())), usually(isCellCase), rarely(slowCase));
1531         
1532         LBasicBlock lastNext = m_out.appendTo(isCellCase, slowCase);
1533         ValueFromBlock fastResult = m_out.anchor(value);
1534         m_out.branch(
1535             m_out.testIsZero32(
1536                 m_out.load8ZeroExt32(value, m_heaps.JSCell_typeInfoFlags),
1537                 m_out.constInt32(OverridesToThis)),
1538             usually(continuation), rarely(slowCase));
1539         
1540         m_out.appendTo(slowCase, continuation);
1541         J_JITOperation_EJ function;
1542         if (m_graph.isStrictModeFor(m_node->origin.semantic))
1543             function = operationToThisStrict;
1544         else
1545             function = operationToThis;
1546         ValueFromBlock slowResult = m_out.anchor(
1547             vmCall(Int64, m_out.operation(function), m_callFrame, value));
1548         m_out.jump(continuation);
1549         
1550         m_out.appendTo(continuation, lastNext);
1551         setJSValue(m_out.phi(Int64, fastResult, slowResult));
1552     }
1553
1554     void compileValueAdd()
1555     {
1556         JITAddIC* addIC = codeBlock()->addJITAddIC();
1557         auto repatchingFunction = operationValueAddOptimize;
1558         auto nonRepatchingFunction = operationValueAdd;
1559         compileMathIC(addIC, repatchingFunction, nonRepatchingFunction);
1560     }
1561
1562     template <typename Generator>
1563     void compileMathIC(JITBinaryMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
1564     {
1565         Node* node = m_node;
1566         
1567         LValue left = lowJSValue(node->child1());
1568         LValue right = lowJSValue(node->child2());
1569
1570         SnippetOperand leftOperand(m_state.forNode(node->child1()).resultType());
1571         SnippetOperand rightOperand(m_state.forNode(node->child2()).resultType());
1572             
1573         PatchpointValue* patchpoint = m_out.patchpoint(Int64);
1574         patchpoint->appendSomeRegister(left);
1575         patchpoint->appendSomeRegister(right);
1576         patchpoint->append(m_tagMask, ValueRep::lateReg(GPRInfo::tagMaskRegister));
1577         patchpoint->append(m_tagTypeNumber, ValueRep::lateReg(GPRInfo::tagTypeNumberRegister));
1578         RefPtr<PatchpointExceptionHandle> exceptionHandle =
1579             preparePatchpointForExceptions(patchpoint);
1580         patchpoint->numGPScratchRegisters = 1;
1581         patchpoint->numFPScratchRegisters = 2;
1582         patchpoint->clobber(RegisterSet::macroScratchRegisters());
1583         State* state = &m_ftlState;
1584         patchpoint->setGenerator(
1585             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
1586                 AllowMacroScratchRegisterUsage allowScratch(jit);
1587
1588                 Box<CCallHelpers::JumpList> exceptions =
1589                     exceptionHandle->scheduleExitCreation(params)->jumps(jit);
1590
1591 #if ENABLE(MATH_IC_STATS)
1592                 auto inlineStart = jit.label();
1593 #endif
1594
1595                 Box<MathICGenerationState> mathICGenerationState = Box<MathICGenerationState>::create();
1596                 ArithProfile* arithProfile = state->graph.baselineCodeBlockFor(node->origin.semantic)->arithProfileForBytecodeOffset(node->origin.semantic.bytecodeIndex);
1597                 mathIC->m_generator = Generator(leftOperand, rightOperand, JSValueRegs(params[0].gpr()),
1598                     JSValueRegs(params[1].gpr()), JSValueRegs(params[2].gpr()), params.fpScratch(0),
1599                     params.fpScratch(1), params.gpScratch(0), InvalidFPRReg, arithProfile);
1600
1601                 bool shouldEmitProfiling = false;
1602                 bool generatedInline = mathIC->generateInline(jit, *mathICGenerationState, shouldEmitProfiling);
1603
1604                 if (generatedInline) {
1605                     ASSERT(!mathICGenerationState->slowPathJumps.empty());
1606                     auto done = jit.label();
1607                     params.addLatePath([=] (CCallHelpers& jit) {
1608                         AllowMacroScratchRegisterUsage allowScratch(jit);
1609                         mathICGenerationState->slowPathJumps.link(&jit);
1610                         mathICGenerationState->slowPathStart = jit.label();
1611 #if ENABLE(MATH_IC_STATS)
1612                         auto slowPathStart = jit.label();
1613 #endif
1614
1615                         if (mathICGenerationState->shouldSlowPathRepatch) {
1616                             SlowPathCall call = callOperation(*state, params.unavailableRegisters(), jit, node->origin.semantic, exceptions.get(),
1617                                 repatchingFunction, params[0].gpr(), params[1].gpr(), params[2].gpr(), CCallHelpers::TrustedImmPtr(mathIC));
1618                             mathICGenerationState->slowPathCall = call.call();
1619                         } else {
1620                             SlowPathCall call = callOperation(*state, params.unavailableRegisters(), jit, node->origin.semantic,
1621                                 exceptions.get(), nonRepatchingFunction, params[0].gpr(), params[1].gpr(), params[2].gpr());
1622                             mathICGenerationState->slowPathCall = call.call();
1623                         }
1624                         jit.jump().linkTo(done, &jit);
1625
1626                         jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
1627                             mathIC->finalizeInlineCode(*mathICGenerationState, linkBuffer);
1628                         });
1629
1630 #if ENABLE(MATH_IC_STATS)
1631                         auto slowPathEnd = jit.label();
1632                         jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
1633                             size_t size = static_cast<char*>(linkBuffer.locationOf(slowPathEnd).executableAddress()) - static_cast<char*>(linkBuffer.locationOf(slowPathStart).executableAddress());
1634                             mathIC->m_generatedCodeSize += size;
1635                         });
1636 #endif
1637                     });
1638                 } else {
1639                     callOperation(
1640                         *state, params.unavailableRegisters(), jit, node->origin.semantic, exceptions.get(),
1641                         nonRepatchingFunction, params[0].gpr(), params[1].gpr(), params[2].gpr());
1642                 }
1643
1644 #if ENABLE(MATH_IC_STATS)
1645                 auto inlineEnd = jit.label();
1646                 jit.addLinkTask([=] (LinkBuffer& linkBuffer) {
1647                     size_t size = static_cast<char*>(linkBuffer.locationOf(inlineEnd).executableAddress()) - static_cast<char*>(linkBuffer.locationOf(inlineStart).executableAddress());
1648                     mathIC->m_generatedCodeSize += size;
1649                 });
1650 #endif
1651             });
1652
1653         setJSValue(patchpoint);
1654     }
1655     
1656     void compileStrCat()
1657     {
1658         LValue result;
1659         if (m_node->child3()) {
1660             result = vmCall(
1661                 Int64, m_out.operation(operationStrCat3), m_callFrame,
1662                 lowJSValue(m_node->child1(), ManualOperandSpeculation),
1663                 lowJSValue(m_node->child2(), ManualOperandSpeculation),
1664                 lowJSValue(m_node->child3(), ManualOperandSpeculation));
1665         } else {
1666             result = vmCall(
1667                 Int64, m_out.operation(operationStrCat2), m_callFrame,
1668                 lowJSValue(m_node->child1(), ManualOperandSpeculation),
1669                 lowJSValue(m_node->child2(), ManualOperandSpeculation));
1670         }
1671         setJSValue(result);
1672     }
1673     
1674     void compileArithAddOrSub()
1675     {
1676         bool isSub =  m_node->op() == ArithSub;
1677         switch (m_node->binaryUseKind()) {
1678         case Int32Use: {
1679             LValue left = lowInt32(m_node->child1());
1680             LValue right = lowInt32(m_node->child2());
1681
1682             if (!shouldCheckOverflow(m_node->arithMode())) {
1683                 setInt32(isSub ? m_out.sub(left, right) : m_out.add(left, right));
1684                 break;
1685             }
1686
1687             CheckValue* result =
1688                 isSub ? m_out.speculateSub(left, right) : m_out.speculateAdd(left, right);
1689             blessSpeculation(result, Overflow, noValue(), nullptr, m_origin);
1690             setInt32(result);
1691             break;
1692         }
1693             
1694         case Int52RepUse: {
1695             if (!abstractValue(m_node->child1()).couldBeType(SpecInt52Only)
1696                 && !abstractValue(m_node->child2()).couldBeType(SpecInt52Only)) {
1697                 Int52Kind kind;
1698                 LValue left = lowWhicheverInt52(m_node->child1(), kind);
1699                 LValue right = lowInt52(m_node->child2(), kind);
1700                 setInt52(isSub ? m_out.sub(left, right) : m_out.add(left, right), kind);
1701                 break;
1702             }
1703
1704             LValue left = lowInt52(m_node->child1());
1705             LValue right = lowInt52(m_node->child2());
1706             CheckValue* result =
1707                 isSub ? m_out.speculateSub(left, right) : m_out.speculateAdd(left, right);
1708             blessSpeculation(result, Overflow, noValue(), nullptr, m_origin);
1709             setInt52(result);
1710             break;
1711         }
1712             
1713         case DoubleRepUse: {
1714             LValue C1 = lowDouble(m_node->child1());
1715             LValue C2 = lowDouble(m_node->child2());
1716
1717             setDouble(isSub ? m_out.doubleSub(C1, C2) : m_out.doubleAdd(C1, C2));
1718             break;
1719         }
1720
1721         case UntypedUse: {
1722             if (!isSub) {
1723                 DFG_CRASH(m_graph, m_node, "Bad use kind");
1724                 break;
1725             }
1726
1727             JITSubIC* subIC = codeBlock()->addJITSubIC();
1728             auto repatchingFunction = operationValueSubOptimize;
1729             auto nonRepatchingFunction = operationValueSub;
1730             compileMathIC(subIC, repatchingFunction, nonRepatchingFunction);
1731             break;
1732         }
1733
1734         default:
1735             DFG_CRASH(m_graph, m_node, "Bad use kind");
1736             break;
1737         }
1738     }
1739
1740     void compileArithClz32()
1741     {
1742         if (m_node->child1().useKind() == Int32Use || m_node->child1().useKind() == KnownInt32Use) {
1743             LValue operand = lowInt32(m_node->child1());
1744             setInt32(m_out.ctlz32(operand));
1745             return;
1746         }
1747         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
1748         LValue argument = lowJSValue(m_node->child1());
1749         LValue result = vmCall(Int32, m_out.operation(operationArithClz32), m_callFrame, argument);
1750         setInt32(result);
1751     }
1752     
1753     void compileArithMul()
1754     {
1755         switch (m_node->binaryUseKind()) {
1756         case Int32Use: {
1757             LValue left = lowInt32(m_node->child1());
1758             LValue right = lowInt32(m_node->child2());
1759             
1760             LValue result;
1761
1762             if (!shouldCheckOverflow(m_node->arithMode()))
1763                 result = m_out.mul(left, right);
1764             else {
1765                 CheckValue* speculation = m_out.speculateMul(left, right);
1766                 blessSpeculation(speculation, Overflow, noValue(), nullptr, m_origin);
1767                 result = speculation;
1768             }
1769             
1770             if (shouldCheckNegativeZero(m_node->arithMode())) {
1771                 LBasicBlock slowCase = m_out.newBlock();
1772                 LBasicBlock continuation = m_out.newBlock();
1773                 
1774                 m_out.branch(
1775                     m_out.notZero32(result), usually(continuation), rarely(slowCase));
1776                 
1777                 LBasicBlock lastNext = m_out.appendTo(slowCase, continuation);
1778                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(left, m_out.int32Zero));
1779                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(right, m_out.int32Zero));
1780                 m_out.jump(continuation);
1781                 m_out.appendTo(continuation, lastNext);
1782             }
1783             
1784             setInt32(result);
1785             break;
1786         }
1787             
1788         case Int52RepUse: {
1789             Int52Kind kind;
1790             LValue left = lowWhicheverInt52(m_node->child1(), kind);
1791             LValue right = lowInt52(m_node->child2(), opposite(kind));
1792
1793             CheckValue* result = m_out.speculateMul(left, right);
1794             blessSpeculation(result, Overflow, noValue(), nullptr, m_origin);
1795
1796             if (shouldCheckNegativeZero(m_node->arithMode())) {
1797                 LBasicBlock slowCase = m_out.newBlock();
1798                 LBasicBlock continuation = m_out.newBlock();
1799                 
1800                 m_out.branch(
1801                     m_out.notZero64(result), usually(continuation), rarely(slowCase));
1802                 
1803                 LBasicBlock lastNext = m_out.appendTo(slowCase, continuation);
1804                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(left, m_out.int64Zero));
1805                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(right, m_out.int64Zero));
1806                 m_out.jump(continuation);
1807                 m_out.appendTo(continuation, lastNext);
1808             }
1809             
1810             setInt52(result);
1811             break;
1812         }
1813             
1814         case DoubleRepUse: {
1815             setDouble(
1816                 m_out.doubleMul(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1817             break;
1818         }
1819
1820         case UntypedUse: {
1821             JITMulIC* mulIC = codeBlock()->addJITMulIC();
1822             auto repatchingFunction = operationValueMulOptimize;
1823             auto nonRepatchingFunction = operationValueMul;
1824             compileMathIC(mulIC, repatchingFunction, nonRepatchingFunction);
1825             break;
1826         }
1827
1828         default:
1829             DFG_CRASH(m_graph, m_node, "Bad use kind");
1830             break;
1831         }
1832     }
1833
1834     void compileArithDiv()
1835     {
1836         switch (m_node->binaryUseKind()) {
1837         case Int32Use: {
1838             LValue numerator = lowInt32(m_node->child1());
1839             LValue denominator = lowInt32(m_node->child2());
1840
1841             if (shouldCheckNegativeZero(m_node->arithMode())) {
1842                 LBasicBlock zeroNumerator = m_out.newBlock();
1843                 LBasicBlock numeratorContinuation = m_out.newBlock();
1844
1845                 m_out.branch(
1846                     m_out.isZero32(numerator),
1847                     rarely(zeroNumerator), usually(numeratorContinuation));
1848
1849                 LBasicBlock innerLastNext = m_out.appendTo(zeroNumerator, numeratorContinuation);
1850
1851                 speculate(
1852                     NegativeZero, noValue(), 0, m_out.lessThan(denominator, m_out.int32Zero));
1853
1854                 m_out.jump(numeratorContinuation);
1855
1856                 m_out.appendTo(numeratorContinuation, innerLastNext);
1857             }
1858             
1859             if (shouldCheckOverflow(m_node->arithMode())) {
1860                 LBasicBlock unsafeDenominator = m_out.newBlock();
1861                 LBasicBlock continuation = m_out.newBlock();
1862
1863                 LValue adjustedDenominator = m_out.add(denominator, m_out.int32One);
1864                 m_out.branch(
1865                     m_out.above(adjustedDenominator, m_out.int32One),
1866                     usually(continuation), rarely(unsafeDenominator));
1867
1868                 LBasicBlock lastNext = m_out.appendTo(unsafeDenominator, continuation);
1869                 LValue neg2ToThe31 = m_out.constInt32(-2147483647-1);
1870                 speculate(Overflow, noValue(), nullptr, m_out.isZero32(denominator));
1871                 speculate(Overflow, noValue(), nullptr, m_out.equal(numerator, neg2ToThe31));
1872                 m_out.jump(continuation);
1873
1874                 m_out.appendTo(continuation, lastNext);
1875                 LValue result = m_out.div(numerator, denominator);
1876                 speculate(
1877                     Overflow, noValue(), 0,
1878                     m_out.notEqual(m_out.mul(result, denominator), numerator));
1879                 setInt32(result);
1880             } else
1881                 setInt32(m_out.chillDiv(numerator, denominator));
1882
1883             break;
1884         }
1885             
1886         case DoubleRepUse: {
1887             setDouble(m_out.doubleDiv(
1888                 lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1889             break;
1890         }
1891
1892         case UntypedUse: {
1893             emitBinarySnippet<JITDivGenerator, NeedScratchFPR>(operationValueDiv);
1894             break;
1895         }
1896
1897         default:
1898             DFG_CRASH(m_graph, m_node, "Bad use kind");
1899             break;
1900         }
1901     }
1902     
1903     void compileArithMod()
1904     {
1905         switch (m_node->binaryUseKind()) {
1906         case Int32Use: {
1907             LValue numerator = lowInt32(m_node->child1());
1908             LValue denominator = lowInt32(m_node->child2());
1909
1910             LValue remainder;
1911             if (shouldCheckOverflow(m_node->arithMode())) {
1912                 LBasicBlock unsafeDenominator = m_out.newBlock();
1913                 LBasicBlock continuation = m_out.newBlock();
1914
1915                 LValue adjustedDenominator = m_out.add(denominator, m_out.int32One);
1916                 m_out.branch(
1917                     m_out.above(adjustedDenominator, m_out.int32One),
1918                     usually(continuation), rarely(unsafeDenominator));
1919
1920                 LBasicBlock lastNext = m_out.appendTo(unsafeDenominator, continuation);
1921                 LValue neg2ToThe31 = m_out.constInt32(-2147483647-1);
1922                 speculate(Overflow, noValue(), nullptr, m_out.isZero32(denominator));
1923                 speculate(Overflow, noValue(), nullptr, m_out.equal(numerator, neg2ToThe31));
1924                 m_out.jump(continuation);
1925
1926                 m_out.appendTo(continuation, lastNext);
1927                 LValue result = m_out.mod(numerator, denominator);
1928                 remainder = result;
1929             } else
1930                 remainder = m_out.chillMod(numerator, denominator);
1931
1932             if (shouldCheckNegativeZero(m_node->arithMode())) {
1933                 LBasicBlock negativeNumerator = m_out.newBlock();
1934                 LBasicBlock numeratorContinuation = m_out.newBlock();
1935
1936                 m_out.branch(
1937                     m_out.lessThan(numerator, m_out.int32Zero),
1938                     unsure(negativeNumerator), unsure(numeratorContinuation));
1939
1940                 LBasicBlock innerLastNext = m_out.appendTo(negativeNumerator, numeratorContinuation);
1941
1942                 speculate(NegativeZero, noValue(), 0, m_out.isZero32(remainder));
1943
1944                 m_out.jump(numeratorContinuation);
1945
1946                 m_out.appendTo(numeratorContinuation, innerLastNext);
1947             }
1948
1949             setInt32(remainder);
1950             break;
1951         }
1952             
1953         case DoubleRepUse: {
1954             setDouble(
1955                 m_out.doubleMod(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1956             break;
1957         }
1958             
1959         default:
1960             DFG_CRASH(m_graph, m_node, "Bad use kind");
1961             break;
1962         }
1963     }
1964
1965     void compileArithMinOrMax()
1966     {
1967         switch (m_node->binaryUseKind()) {
1968         case Int32Use: {
1969             LValue left = lowInt32(m_node->child1());
1970             LValue right = lowInt32(m_node->child2());
1971             
1972             setInt32(
1973                 m_out.select(
1974                     m_node->op() == ArithMin
1975                         ? m_out.lessThan(left, right)
1976                         : m_out.lessThan(right, left),
1977                     left, right));
1978             break;
1979         }
1980             
1981         case DoubleRepUse: {
1982             LValue left = lowDouble(m_node->child1());
1983             LValue right = lowDouble(m_node->child2());
1984             
1985             LBasicBlock notLessThan = m_out.newBlock();
1986             LBasicBlock continuation = m_out.newBlock();
1987             
1988             Vector<ValueFromBlock, 2> results;
1989             
1990             results.append(m_out.anchor(left));
1991             m_out.branch(
1992                 m_node->op() == ArithMin
1993                     ? m_out.doubleLessThan(left, right)
1994                     : m_out.doubleGreaterThan(left, right),
1995                 unsure(continuation), unsure(notLessThan));
1996             
1997             LBasicBlock lastNext = m_out.appendTo(notLessThan, continuation);
1998             results.append(m_out.anchor(m_out.select(
1999                 m_node->op() == ArithMin
2000                     ? m_out.doubleGreaterThanOrEqual(left, right)
2001                     : m_out.doubleLessThanOrEqual(left, right),
2002                 right, m_out.constDouble(PNaN))));
2003             m_out.jump(continuation);
2004             
2005             m_out.appendTo(continuation, lastNext);
2006             setDouble(m_out.phi(Double, results));
2007             break;
2008         }
2009             
2010         default:
2011             DFG_CRASH(m_graph, m_node, "Bad use kind");
2012             break;
2013         }
2014     }
2015     
2016     void compileArithAbs()
2017     {
2018         switch (m_node->child1().useKind()) {
2019         case Int32Use: {
2020             LValue value = lowInt32(m_node->child1());
2021
2022             LValue mask = m_out.aShr(value, m_out.constInt32(31));
2023             LValue result = m_out.bitXor(mask, m_out.add(mask, value));
2024
2025             if (shouldCheckOverflow(m_node->arithMode()))
2026                 speculate(Overflow, noValue(), 0, m_out.lessThan(result, m_out.int32Zero));
2027
2028             setInt32(result);
2029             break;
2030         }
2031             
2032         case DoubleRepUse: {
2033             setDouble(m_out.doubleAbs(lowDouble(m_node->child1())));
2034             break;
2035         }
2036             
2037         default: {
2038             DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2039             LValue argument = lowJSValue(m_node->child1());
2040             LValue result = vmCall(Double, m_out.operation(operationArithAbs), m_callFrame, argument);
2041             setDouble(result);
2042             break;
2043         }
2044         }
2045     }
2046
2047     void compileArithSin()
2048     {
2049         if (m_node->child1().useKind() == DoubleRepUse) {
2050             setDouble(m_out.doubleSin(lowDouble(m_node->child1())));
2051             return;
2052         }
2053         LValue argument = lowJSValue(m_node->child1());
2054         LValue result = vmCall(Double, m_out.operation(operationArithSin), m_callFrame, argument);
2055         setDouble(result);
2056     }
2057
2058     void compileArithCos()
2059     {
2060         if (m_node->child1().useKind() == DoubleRepUse) {
2061             setDouble(m_out.doubleCos(lowDouble(m_node->child1())));
2062             return;
2063         }
2064         LValue argument = lowJSValue(m_node->child1());
2065         LValue result = vmCall(Double, m_out.operation(operationArithCos), m_callFrame, argument);
2066         setDouble(result);
2067     }
2068
2069     void compileArithTan()
2070     {
2071         if (m_node->child1().useKind() == DoubleRepUse) {
2072             setDouble(m_out.doubleTan(lowDouble(m_node->child1())));
2073             return;
2074         }
2075         LValue argument = lowJSValue(m_node->child1());
2076         LValue result = vmCall(Double, m_out.operation(operationArithTan), m_callFrame, argument);
2077         setDouble(result);
2078     }
2079
2080     void compileArithPow()
2081     {
2082         if (m_node->child2().useKind() == Int32Use)
2083             setDouble(m_out.doublePowi(lowDouble(m_node->child1()), lowInt32(m_node->child2())));
2084         else {
2085             LValue base = lowDouble(m_node->child1());
2086             LValue exponent = lowDouble(m_node->child2());
2087
2088             LBasicBlock integerExponentIsSmallBlock = m_out.newBlock();
2089             LBasicBlock integerExponentPowBlock = m_out.newBlock();
2090             LBasicBlock doubleExponentPowBlockEntry = m_out.newBlock();
2091             LBasicBlock nanExceptionBaseIsOne = m_out.newBlock();
2092             LBasicBlock nanExceptionExponentIsInfinity = m_out.newBlock();
2093             LBasicBlock testExponentIsOneHalf = m_out.newBlock();
2094             LBasicBlock handleBaseZeroExponentIsOneHalf = m_out.newBlock();
2095             LBasicBlock handleInfinityForExponentIsOneHalf = m_out.newBlock();
2096             LBasicBlock exponentIsOneHalfNormal = m_out.newBlock();
2097             LBasicBlock exponentIsOneHalfInfinity = m_out.newBlock();
2098             LBasicBlock testExponentIsNegativeOneHalf = m_out.newBlock();
2099             LBasicBlock testBaseZeroExponentIsNegativeOneHalf = m_out.newBlock();
2100             LBasicBlock handleBaseZeroExponentIsNegativeOneHalf = m_out.newBlock();
2101             LBasicBlock handleInfinityForExponentIsNegativeOneHalf = m_out.newBlock();
2102             LBasicBlock exponentIsNegativeOneHalfNormal = m_out.newBlock();
2103             LBasicBlock exponentIsNegativeOneHalfInfinity = m_out.newBlock();
2104             LBasicBlock powBlock = m_out.newBlock();
2105             LBasicBlock nanExceptionResultIsNaN = m_out.newBlock();
2106             LBasicBlock continuation = m_out.newBlock();
2107
2108             LValue integerExponent = m_out.doubleToInt(exponent);
2109             LValue integerExponentConvertedToDouble = m_out.intToDouble(integerExponent);
2110             LValue exponentIsInteger = m_out.doubleEqual(exponent, integerExponentConvertedToDouble);
2111             m_out.branch(exponentIsInteger, unsure(integerExponentIsSmallBlock), unsure(doubleExponentPowBlockEntry));
2112
2113             LBasicBlock lastNext = m_out.appendTo(integerExponentIsSmallBlock, integerExponentPowBlock);
2114             LValue integerExponentBelowMax = m_out.belowOrEqual(integerExponent, m_out.constInt32(maxExponentForIntegerMathPow));
2115             m_out.branch(integerExponentBelowMax, usually(integerExponentPowBlock), rarely(doubleExponentPowBlockEntry));
2116
2117             m_out.appendTo(integerExponentPowBlock, doubleExponentPowBlockEntry);
2118             ValueFromBlock powDoubleIntResult = m_out.anchor(m_out.doublePowi(base, integerExponent));
2119             m_out.jump(continuation);
2120
2121             // If y is NaN, the result is NaN.
2122             m_out.appendTo(doubleExponentPowBlockEntry, nanExceptionBaseIsOne);
2123             LValue exponentIsNaN;
2124             if (provenType(m_node->child2()) & SpecDoubleNaN)
2125                 exponentIsNaN = m_out.doubleNotEqualOrUnordered(exponent, exponent);
2126             else
2127                 exponentIsNaN = m_out.booleanFalse;
2128             m_out.branch(exponentIsNaN, rarely(nanExceptionResultIsNaN), usually(nanExceptionBaseIsOne));
2129
2130             // If abs(x) is 1 and y is +infinity, the result is NaN.
2131             // If abs(x) is 1 and y is -infinity, the result is NaN.
2132
2133             //     Test if base == 1.
2134             m_out.appendTo(nanExceptionBaseIsOne, nanExceptionExponentIsInfinity);
2135             LValue absoluteBase = m_out.doubleAbs(base);
2136             LValue absoluteBaseIsOne = m_out.doubleEqual(absoluteBase, m_out.constDouble(1));
2137             m_out.branch(absoluteBaseIsOne, rarely(nanExceptionExponentIsInfinity), usually(testExponentIsOneHalf));
2138
2139             //     Test if abs(y) == Infinity.
2140             m_out.appendTo(nanExceptionExponentIsInfinity, testExponentIsOneHalf);
2141             LValue absoluteExponent = m_out.doubleAbs(exponent);
2142             LValue absoluteExponentIsInfinity = m_out.doubleEqual(absoluteExponent, m_out.constDouble(std::numeric_limits<double>::infinity()));
2143             m_out.branch(absoluteExponentIsInfinity, rarely(nanExceptionResultIsNaN), usually(testExponentIsOneHalf));
2144
2145             // If y == 0.5 or y == -0.5, handle it through SQRT.
2146             // We have be carefuly with -0 and -Infinity.
2147
2148             //     Test if y == 0.5
2149             m_out.appendTo(testExponentIsOneHalf, handleBaseZeroExponentIsOneHalf);
2150             LValue exponentIsOneHalf = m_out.doubleEqual(exponent, m_out.constDouble(0.5));
2151             m_out.branch(exponentIsOneHalf, rarely(handleBaseZeroExponentIsOneHalf), usually(testExponentIsNegativeOneHalf));
2152
2153             //     Handle x == -0.
2154             m_out.appendTo(handleBaseZeroExponentIsOneHalf, handleInfinityForExponentIsOneHalf);
2155             LValue baseIsZeroExponentIsOneHalf = m_out.doubleEqual(base, m_out.doubleZero);
2156             ValueFromBlock zeroResultExponentIsOneHalf = m_out.anchor(m_out.doubleZero);
2157             m_out.branch(baseIsZeroExponentIsOneHalf, rarely(continuation), usually(handleInfinityForExponentIsOneHalf));
2158
2159             //     Test if abs(x) == Infinity.
2160             m_out.appendTo(handleInfinityForExponentIsOneHalf, exponentIsOneHalfNormal);
2161             LValue absoluteBaseIsInfinityOneHalf = m_out.doubleEqual(absoluteBase, m_out.constDouble(std::numeric_limits<double>::infinity()));
2162             m_out.branch(absoluteBaseIsInfinityOneHalf, rarely(exponentIsOneHalfInfinity), usually(exponentIsOneHalfNormal));
2163
2164             //     The exponent is 0.5, the base is finite or NaN, we can use SQRT.
2165             m_out.appendTo(exponentIsOneHalfNormal, exponentIsOneHalfInfinity);
2166             ValueFromBlock sqrtResult = m_out.anchor(m_out.doubleSqrt(base));
2167             m_out.jump(continuation);
2168
2169             //     The exponent is 0.5, the base is infinite, the result is always infinite.
2170             m_out.appendTo(exponentIsOneHalfInfinity, testExponentIsNegativeOneHalf);
2171             ValueFromBlock sqrtInfinityResult = m_out.anchor(m_out.constDouble(std::numeric_limits<double>::infinity()));
2172             m_out.jump(continuation);
2173
2174             //     Test if y == -0.5
2175             m_out.appendTo(testExponentIsNegativeOneHalf, testBaseZeroExponentIsNegativeOneHalf);
2176             LValue exponentIsNegativeOneHalf = m_out.doubleEqual(exponent, m_out.constDouble(-0.5));
2177             m_out.branch(exponentIsNegativeOneHalf, rarely(testBaseZeroExponentIsNegativeOneHalf), usually(powBlock));
2178
2179             //     Handle x == -0.
2180             m_out.appendTo(testBaseZeroExponentIsNegativeOneHalf, handleBaseZeroExponentIsNegativeOneHalf);
2181             LValue baseIsZeroExponentIsNegativeOneHalf = m_out.doubleEqual(base, m_out.doubleZero);
2182             m_out.branch(baseIsZeroExponentIsNegativeOneHalf, rarely(handleBaseZeroExponentIsNegativeOneHalf), usually(handleInfinityForExponentIsNegativeOneHalf));
2183
2184             m_out.appendTo(handleBaseZeroExponentIsNegativeOneHalf, handleInfinityForExponentIsNegativeOneHalf);
2185             ValueFromBlock oneOverSqrtZeroResult = m_out.anchor(m_out.constDouble(std::numeric_limits<double>::infinity()));
2186             m_out.jump(continuation);
2187
2188             //     Test if abs(x) == Infinity.
2189             m_out.appendTo(handleInfinityForExponentIsNegativeOneHalf, exponentIsNegativeOneHalfNormal);
2190             LValue absoluteBaseIsInfinityNegativeOneHalf = m_out.doubleEqual(absoluteBase, m_out.constDouble(std::numeric_limits<double>::infinity()));
2191             m_out.branch(absoluteBaseIsInfinityNegativeOneHalf, rarely(exponentIsNegativeOneHalfInfinity), usually(exponentIsNegativeOneHalfNormal));
2192
2193             //     The exponent is -0.5, the base is finite or NaN, we can use 1/SQRT.
2194             m_out.appendTo(exponentIsNegativeOneHalfNormal, exponentIsNegativeOneHalfInfinity);
2195             LValue sqrtBase = m_out.doubleSqrt(base);
2196             ValueFromBlock oneOverSqrtResult = m_out.anchor(m_out.div(m_out.constDouble(1.), sqrtBase));
2197             m_out.jump(continuation);
2198
2199             //     The exponent is -0.5, the base is infinite, the result is always zero.
2200             m_out.appendTo(exponentIsNegativeOneHalfInfinity, powBlock);
2201             ValueFromBlock oneOverSqrtInfinityResult = m_out.anchor(m_out.doubleZero);
2202             m_out.jump(continuation);
2203
2204             m_out.appendTo(powBlock, nanExceptionResultIsNaN);
2205             ValueFromBlock powResult = m_out.anchor(m_out.doublePow(base, exponent));
2206             m_out.jump(continuation);
2207
2208             m_out.appendTo(nanExceptionResultIsNaN, continuation);
2209             ValueFromBlock pureNan = m_out.anchor(m_out.constDouble(PNaN));
2210             m_out.jump(continuation);
2211
2212             m_out.appendTo(continuation, lastNext);
2213             setDouble(m_out.phi(Double, powDoubleIntResult, zeroResultExponentIsOneHalf, sqrtResult, sqrtInfinityResult, oneOverSqrtZeroResult, oneOverSqrtResult, oneOverSqrtInfinityResult, powResult, pureNan));
2214         }
2215     }
2216
2217     void compileArithRandom()
2218     {
2219         JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic);
2220
2221         // Inlined WeakRandom::advance().
2222         // uint64_t x = m_low;
2223         void* lowAddress = reinterpret_cast<uint8_t*>(globalObject) + JSGlobalObject::weakRandomOffset() + WeakRandom::lowOffset();
2224         LValue low = m_out.load64(m_out.absolute(lowAddress));
2225         // uint64_t y = m_high;
2226         void* highAddress = reinterpret_cast<uint8_t*>(globalObject) + JSGlobalObject::weakRandomOffset() + WeakRandom::highOffset();
2227         LValue high = m_out.load64(m_out.absolute(highAddress));
2228         // m_low = y;
2229         m_out.store64(high, m_out.absolute(lowAddress));
2230
2231         // x ^= x << 23;
2232         LValue phase1 = m_out.bitXor(m_out.shl(low, m_out.constInt64(23)), low);
2233
2234         // x ^= x >> 17;
2235         LValue phase2 = m_out.bitXor(m_out.lShr(phase1, m_out.constInt64(17)), phase1);
2236
2237         // x ^= y ^ (y >> 26);
2238         LValue phase3 = m_out.bitXor(m_out.bitXor(high, m_out.lShr(high, m_out.constInt64(26))), phase2);
2239
2240         // m_high = x;
2241         m_out.store64(phase3, m_out.absolute(highAddress));
2242
2243         // return x + y;
2244         LValue random64 = m_out.add(phase3, high);
2245
2246         // Extract random 53bit. [0, 53] bit is safe integer number ranges in double representation.
2247         LValue random53 = m_out.bitAnd(random64, m_out.constInt64((1ULL << 53) - 1));
2248
2249         LValue double53Integer = m_out.intToDouble(random53);
2250
2251         // Convert `(53bit double integer value) / (1 << 53)` to `(53bit double integer value) * (1.0 / (1 << 53))`.
2252         // In latter case, `1.0 / (1 << 53)` will become a double value represented as (mantissa = 0 & exp = 970, it means 1e-(2**54)).
2253         static const double scale = 1.0 / (1ULL << 53);
2254
2255         // Multiplying 1e-(2**54) with the double integer does not change anything of the mantissa part of the double integer.
2256         // It just reduces the exp part of the given 53bit double integer.
2257         // (Except for 0.0. This is specially handled and in this case, exp just becomes 0.)
2258         // Now we get 53bit precision random double value in [0, 1).
2259         LValue result = m_out.doubleMul(double53Integer, m_out.constDouble(scale));
2260
2261         setDouble(result);
2262     }
2263
2264     void compileArithRound()
2265     {
2266         if (m_node->child1().useKind() == DoubleRepUse) {
2267             LValue result = nullptr;
2268             if (producesInteger(m_node->arithRoundingMode()) && !shouldCheckNegativeZero(m_node->arithRoundingMode())) {
2269                 LValue value = lowDouble(m_node->child1());
2270                 result = m_out.doubleFloor(m_out.doubleAdd(value, m_out.constDouble(0.5)));
2271             } else {
2272                 LBasicBlock realPartIsMoreThanHalf = m_out.newBlock();
2273                 LBasicBlock continuation = m_out.newBlock();
2274
2275                 LValue value = lowDouble(m_node->child1());
2276                 LValue integerValue = m_out.doubleCeil(value);
2277                 ValueFromBlock integerValueResult = m_out.anchor(integerValue);
2278
2279                 LValue realPart = m_out.doubleSub(integerValue, value);
2280
2281                 m_out.branch(m_out.doubleGreaterThanOrUnordered(realPart, m_out.constDouble(0.5)), unsure(realPartIsMoreThanHalf), unsure(continuation));
2282
2283                 LBasicBlock lastNext = m_out.appendTo(realPartIsMoreThanHalf, continuation);
2284                 LValue integerValueRoundedDown = m_out.doubleSub(integerValue, m_out.constDouble(1));
2285                 ValueFromBlock integerValueRoundedDownResult = m_out.anchor(integerValueRoundedDown);
2286                 m_out.jump(continuation);
2287                 m_out.appendTo(continuation, lastNext);
2288
2289                 result = m_out.phi(Double, integerValueResult, integerValueRoundedDownResult);
2290             }
2291
2292             if (producesInteger(m_node->arithRoundingMode())) {
2293                 LValue integerValue = convertDoubleToInt32(result, shouldCheckNegativeZero(m_node->arithRoundingMode()));
2294                 setInt32(integerValue);
2295             } else
2296                 setDouble(result);
2297             return;
2298         }
2299
2300         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2301         LValue argument = lowJSValue(m_node->child1());
2302         setJSValue(vmCall(Int64, m_out.operation(operationArithRound), m_callFrame, argument));
2303     }
2304
2305     void compileArithFloor()
2306     {
2307         if (m_node->child1().useKind() == DoubleRepUse) {
2308             LValue value = lowDouble(m_node->child1());
2309             LValue integerValue = m_out.doubleFloor(value);
2310             if (producesInteger(m_node->arithRoundingMode()))
2311                 setInt32(convertDoubleToInt32(integerValue, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2312             else
2313                 setDouble(integerValue);
2314             return;
2315         }
2316         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2317         LValue argument = lowJSValue(m_node->child1());
2318         setJSValue(vmCall(Int64, m_out.operation(operationArithFloor), m_callFrame, argument));
2319     }
2320
2321     void compileArithCeil()
2322     {
2323         if (m_node->child1().useKind() == DoubleRepUse) {
2324             LValue value = lowDouble(m_node->child1());
2325             LValue integerValue = m_out.doubleCeil(value);
2326             if (producesInteger(m_node->arithRoundingMode()))
2327                 setInt32(convertDoubleToInt32(integerValue, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2328             else
2329                 setDouble(integerValue);
2330             return;
2331         }
2332         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2333         LValue argument = lowJSValue(m_node->child1());
2334         setJSValue(vmCall(Int64, m_out.operation(operationArithCeil), m_callFrame, argument));
2335     }
2336
2337     void compileArithTrunc()
2338     {
2339         if (m_node->child1().useKind() == DoubleRepUse) {
2340             LValue value = lowDouble(m_node->child1());
2341             LValue result = m_out.doubleTrunc(value);
2342             if (producesInteger(m_node->arithRoundingMode()))
2343                 setInt32(convertDoubleToInt32(result, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2344             else
2345                 setDouble(result);
2346             return;
2347         }
2348         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2349         LValue argument = lowJSValue(m_node->child1());
2350         setJSValue(vmCall(Int64, m_out.operation(operationArithTrunc), m_callFrame, argument));
2351     }
2352
2353     void compileArithSqrt()
2354     {
2355         if (m_node->child1().useKind() == DoubleRepUse) {
2356             setDouble(m_out.doubleSqrt(lowDouble(m_node->child1())));
2357             return;
2358         }
2359         LValue argument = lowJSValue(m_node->child1());
2360         LValue result = vmCall(Double, m_out.operation(operationArithSqrt), m_callFrame, argument);
2361         setDouble(result);
2362     }
2363
2364     void compileArithLog()
2365     {
2366         if (m_node->child1().useKind() == DoubleRepUse) {
2367             setDouble(m_out.doubleLog(lowDouble(m_node->child1())));
2368             return;
2369         }
2370         LValue argument = lowJSValue(m_node->child1());
2371         LValue result = vmCall(Double, m_out.operation(operationArithLog), m_callFrame, argument);
2372         setDouble(result);
2373     }
2374     
2375     void compileArithFRound()
2376     {
2377         if (m_node->child1().useKind() == DoubleRepUse) {
2378             setDouble(m_out.fround(lowDouble(m_node->child1())));
2379             return;
2380         }
2381         LValue argument = lowJSValue(m_node->child1());
2382         LValue result = vmCall(Double, m_out.operation(operationArithFRound), m_callFrame, argument);
2383         setDouble(result);
2384     }
2385     
2386     void compileArithNegate()
2387     {
2388         switch (m_node->child1().useKind()) {
2389         case Int32Use: {
2390             LValue value = lowInt32(m_node->child1());
2391             
2392             LValue result;
2393             if (!shouldCheckOverflow(m_node->arithMode()))
2394                 result = m_out.neg(value);
2395             else if (!shouldCheckNegativeZero(m_node->arithMode())) {
2396                 CheckValue* check = m_out.speculateSub(m_out.int32Zero, value);
2397                 blessSpeculation(check, Overflow, noValue(), nullptr, m_origin);
2398                 result = check;
2399             } else {
2400                 speculate(Overflow, noValue(), 0, m_out.testIsZero32(value, m_out.constInt32(0x7fffffff)));
2401                 result = m_out.neg(value);
2402             }
2403
2404             setInt32(result);
2405             break;
2406         }
2407             
2408         case Int52RepUse: {
2409             if (!abstractValue(m_node->child1()).couldBeType(SpecInt52Only)) {
2410                 Int52Kind kind;
2411                 LValue value = lowWhicheverInt52(m_node->child1(), kind);
2412                 LValue result = m_out.neg(value);
2413                 if (shouldCheckNegativeZero(m_node->arithMode()))
2414                     speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
2415                 setInt52(result, kind);
2416                 break;
2417             }
2418             
2419             LValue value = lowInt52(m_node->child1());
2420             CheckValue* result = m_out.speculateSub(m_out.int64Zero, value);
2421             blessSpeculation(result, Int52Overflow, noValue(), nullptr, m_origin);
2422             speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
2423             setInt52(result);
2424             break;
2425         }
2426             
2427         case DoubleRepUse: {
2428             setDouble(m_out.doubleNeg(lowDouble(m_node->child1())));
2429             break;
2430         }
2431             
2432         default:
2433             DFG_CRASH(m_graph, m_node, "Bad use kind");
2434             break;
2435         }
2436     }
2437     
2438     void compileBitAnd()
2439     {
2440         if (m_node->isBinaryUseKind(UntypedUse)) {
2441             emitBinaryBitOpSnippet<JITBitAndGenerator>(operationValueBitAnd);
2442             return;
2443         }
2444         setInt32(m_out.bitAnd(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2445     }
2446     
2447     void compileBitOr()
2448     {
2449         if (m_node->isBinaryUseKind(UntypedUse)) {
2450             emitBinaryBitOpSnippet<JITBitOrGenerator>(operationValueBitOr);
2451             return;
2452         }
2453         setInt32(m_out.bitOr(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2454     }
2455     
2456     void compileBitXor()
2457     {
2458         if (m_node->isBinaryUseKind(UntypedUse)) {
2459             emitBinaryBitOpSnippet<JITBitXorGenerator>(operationValueBitXor);
2460             return;
2461         }
2462         setInt32(m_out.bitXor(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2463     }
2464     
2465     void compileBitRShift()
2466     {
2467         if (m_node->isBinaryUseKind(UntypedUse)) {
2468             emitRightShiftSnippet(JITRightShiftGenerator::SignedShift);
2469             return;
2470         }
2471         setInt32(m_out.aShr(
2472             lowInt32(m_node->child1()),
2473             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2474     }
2475     
2476     void compileBitLShift()
2477     {
2478         if (m_node->isBinaryUseKind(UntypedUse)) {
2479             emitBinaryBitOpSnippet<JITLeftShiftGenerator>(operationValueBitLShift);
2480             return;
2481         }
2482         setInt32(m_out.shl(
2483             lowInt32(m_node->child1()),
2484             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2485     }
2486     
2487     void compileBitURShift()
2488     {
2489         if (m_node->isBinaryUseKind(UntypedUse)) {
2490             emitRightShiftSnippet(JITRightShiftGenerator::UnsignedShift);
2491             return;
2492         }
2493         setInt32(m_out.lShr(
2494             lowInt32(m_node->child1()),
2495             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2496     }
2497     
2498     void compileUInt32ToNumber()
2499     {
2500         LValue value = lowInt32(m_node->child1());
2501
2502         if (doesOverflow(m_node->arithMode())) {
2503             setStrictInt52(m_out.zeroExtPtr(value));
2504             return;
2505         }
2506
2507         speculate(Overflow, noValue(), 0, m_out.lessThan(value, m_out.int32Zero));
2508         setInt32(value);
2509     }
2510     
2511     void compileCheckStructure()
2512     {
2513         ExitKind exitKind;
2514         if (m_node->child1()->hasConstant())
2515             exitKind = BadConstantCache;
2516         else
2517             exitKind = BadCache;
2518
2519         switch (m_node->child1().useKind()) {
2520         case CellUse:
2521         case KnownCellUse: {
2522             LValue cell = lowCell(m_node->child1());
2523             
2524             checkStructure(
2525                 m_out.load32(cell, m_heaps.JSCell_structureID), jsValueValue(cell),
2526                 exitKind, m_node->structureSet(),
2527                 [&] (Structure* structure) {
2528                     return weakStructureID(structure);
2529                 });
2530             return;
2531         }
2532
2533         case CellOrOtherUse: {
2534             LValue value = lowJSValue(m_node->child1(), ManualOperandSpeculation);
2535
2536             LBasicBlock cellCase = m_out.newBlock();
2537             LBasicBlock notCellCase = m_out.newBlock();
2538             LBasicBlock continuation = m_out.newBlock();
2539
2540             m_out.branch(
2541                 isCell(value, provenType(m_node->child1())), unsure(cellCase), unsure(notCellCase));
2542
2543             LBasicBlock lastNext = m_out.appendTo(cellCase, notCellCase);
2544             checkStructure(
2545                 m_out.load32(value, m_heaps.JSCell_structureID), jsValueValue(value),
2546                 exitKind, m_node->structureSet(),
2547                 [&] (Structure* structure) {
2548                     return weakStructureID(structure);
2549                 });
2550             m_out.jump(continuation);
2551
2552             m_out.appendTo(notCellCase, continuation);
2553             FTL_TYPE_CHECK(jsValueValue(value), m_node->child1(), SpecCell | SpecOther, isNotOther(value));
2554             m_out.jump(continuation);
2555
2556             m_out.appendTo(continuation, lastNext);
2557             return;
2558         }
2559
2560         default:
2561             DFG_CRASH(m_graph, m_node, "Bad use kind");
2562             return;
2563         }
2564     }
2565     
2566     void compileCheckCell()
2567     {
2568         LValue cell = lowCell(m_node->child1());
2569         
2570         speculate(
2571             BadCell, jsValueValue(cell), m_node->child1().node(),
2572             m_out.notEqual(cell, weakPointer(m_node->cellOperand()->cell())));
2573     }
2574     
2575     void compileCheckBadCell()
2576     {
2577         terminate(BadCell);
2578     }
2579
2580     void compileCheckNotEmpty()
2581     {
2582         speculate(TDZFailure, noValue(), nullptr, m_out.isZero64(lowJSValue(m_node->child1())));
2583     }
2584
2585     void compileCheckStringIdent()
2586     {
2587         UniquedStringImpl* uid = m_node->uidOperand();
2588         LValue string = lowStringIdent(m_node->child1());
2589         LValue stringImpl = m_out.loadPtr(string, m_heaps.JSString_value);
2590         speculate(BadIdent, noValue(), nullptr, m_out.notEqual(stringImpl, m_out.constIntPtr(uid)));
2591     }
2592
2593     void compileGetExecutable()
2594     {
2595         LValue cell = lowCell(m_node->child1());
2596         speculateFunction(m_node->child1(), cell);
2597         setJSValue(m_out.loadPtr(cell, m_heaps.JSFunction_executable));
2598     }
2599     
2600     void compileArrayifyToStructure()
2601     {
2602         LValue cell = lowCell(m_node->child1());
2603         LValue property = !!m_node->child2() ? lowInt32(m_node->child2()) : 0;
2604         
2605         LBasicBlock unexpectedStructure = m_out.newBlock();
2606         LBasicBlock continuation = m_out.newBlock();
2607         
2608         LValue structureID = m_out.load32(cell, m_heaps.JSCell_structureID);
2609         
2610         m_out.branch(
2611             m_out.notEqual(structureID, weakStructureID(m_node->structure())),
2612             rarely(unexpectedStructure), usually(continuation));
2613         
2614         LBasicBlock lastNext = m_out.appendTo(unexpectedStructure, continuation);
2615         
2616         if (property) {
2617             switch (m_node->arrayMode().type()) {
2618             case Array::Int32:
2619             case Array::Double:
2620             case Array::Contiguous:
2621                 speculate(
2622                     Uncountable, noValue(), 0,
2623                     m_out.aboveOrEqual(property, m_out.constInt32(MIN_SPARSE_ARRAY_INDEX)));
2624                 break;
2625             default:
2626                 break;
2627             }
2628         }
2629         
2630         switch (m_node->arrayMode().type()) {
2631         case Array::Int32:
2632             vmCall(Void, m_out.operation(operationEnsureInt32), m_callFrame, cell);
2633             break;
2634         case Array::Double:
2635             vmCall(Void, m_out.operation(operationEnsureDouble), m_callFrame, cell);
2636             break;
2637         case Array::Contiguous:
2638             vmCall(Void, m_out.operation(operationEnsureContiguous), m_callFrame, cell);
2639             break;
2640         case Array::ArrayStorage:
2641         case Array::SlowPutArrayStorage:
2642             vmCall(Void, m_out.operation(operationEnsureArrayStorage), m_callFrame, cell);
2643             break;
2644         default:
2645             DFG_CRASH(m_graph, m_node, "Bad array type");
2646             break;
2647         }
2648         
2649         structureID = m_out.load32(cell, m_heaps.JSCell_structureID);
2650         speculate(
2651             BadIndexingType, jsValueValue(cell), 0,
2652             m_out.notEqual(structureID, weakStructureID(m_node->structure())));
2653         m_out.jump(continuation);
2654         
2655         m_out.appendTo(continuation, lastNext);
2656     }
2657     
2658     void compilePutStructure()
2659     {
2660         m_ftlState.jitCode->common.notifyCompilingStructureTransition(m_graph.m_plan, codeBlock(), m_node);
2661
2662         Structure* oldStructure = m_node->transition()->previous;
2663         Structure* newStructure = m_node->transition()->next;
2664         ASSERT_UNUSED(oldStructure, oldStructure->indexingType() == newStructure->indexingType());
2665         ASSERT(oldStructure->typeInfo().inlineTypeFlags() == newStructure->typeInfo().inlineTypeFlags());
2666         ASSERT(oldStructure->typeInfo().type() == newStructure->typeInfo().type());
2667
2668         LValue cell = lowCell(m_node->child1()); 
2669         m_out.store32(
2670             weakStructureID(newStructure),
2671             cell, m_heaps.JSCell_structureID);
2672     }
2673     
2674     void compileGetById(AccessType type)
2675     {
2676         ASSERT(type == AccessType::Get || type == AccessType::GetPure);
2677         switch (m_node->child1().useKind()) {
2678         case CellUse: {
2679             setJSValue(getById(lowCell(m_node->child1()), type));
2680             return;
2681         }
2682             
2683         case UntypedUse: {
2684             // This is pretty weird, since we duplicate the slow path both here and in the
2685             // code generated by the IC. We should investigate making this less bad.
2686             // https://bugs.webkit.org/show_bug.cgi?id=127830
2687             LValue value = lowJSValue(m_node->child1());
2688             
2689             LBasicBlock cellCase = m_out.newBlock();
2690             LBasicBlock notCellCase = m_out.newBlock();
2691             LBasicBlock continuation = m_out.newBlock();
2692             
2693             m_out.branch(
2694                 isCell(value, provenType(m_node->child1())), unsure(cellCase), unsure(notCellCase));
2695             
2696             LBasicBlock lastNext = m_out.appendTo(cellCase, notCellCase);
2697             ValueFromBlock cellResult = m_out.anchor(getById(value, type));
2698             m_out.jump(continuation);
2699
2700             J_JITOperation_EJI getByIdFunction;
2701             if (type == AccessType::Get)
2702                 getByIdFunction = operationGetByIdGeneric;
2703             else
2704                 getByIdFunction = operationTryGetByIdGeneric;
2705
2706             m_out.appendTo(notCellCase, continuation);
2707             ValueFromBlock notCellResult = m_out.anchor(vmCall(
2708                 Int64, m_out.operation(getByIdFunction),
2709                 m_callFrame, value,
2710                 m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()])));
2711             m_out.jump(continuation);
2712             
2713             m_out.appendTo(continuation, lastNext);
2714             setJSValue(m_out.phi(Int64, cellResult, notCellResult));
2715             return;
2716         }
2717             
2718         default:
2719             DFG_CRASH(m_graph, m_node, "Bad use kind");
2720             return;
2721         }
2722     }
2723
2724     void compileGetByIdWithThis()
2725     {
2726         LValue base = lowJSValue(m_node->child1());
2727         LValue thisValue = lowJSValue(m_node->child2());
2728         LValue result = vmCall(Int64, m_out.operation(operationGetByIdWithThis), m_callFrame, base, thisValue, m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()]));
2729         setJSValue(result);
2730     }
2731
2732     void compileGetByValWithThis()
2733     {
2734         LValue base = lowJSValue(m_node->child1());
2735         LValue thisValue = lowJSValue(m_node->child2());
2736         LValue subscript = lowJSValue(m_node->child3());
2737
2738         LValue result = vmCall(Int64, m_out.operation(operationGetByValWithThis), m_callFrame, base, thisValue, subscript);
2739         setJSValue(result);
2740     }
2741
2742     void compilePutByIdWithThis()
2743     {
2744         LValue base = lowJSValue(m_node->child1());
2745         LValue thisValue = lowJSValue(m_node->child2());
2746         LValue value = lowJSValue(m_node->child3());
2747
2748         vmCall(Void, m_out.operation(m_graph.isStrictModeFor(m_node->origin.semantic) ? operationPutByIdWithThisStrict : operationPutByIdWithThis),
2749             m_callFrame, base, thisValue, value, m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()]));
2750     }
2751
2752     void compilePutByValWithThis()
2753     {
2754         LValue base = lowJSValue(m_graph.varArgChild(m_node, 0));
2755         LValue thisValue = lowJSValue(m_graph.varArgChild(m_node, 1));
2756         LValue property = lowJSValue(m_graph.varArgChild(m_node, 2));
2757         LValue value = lowJSValue(m_graph.varArgChild(m_node, 3));
2758
2759         vmCall(Void, m_out.operation(m_graph.isStrictModeFor(m_node->origin.semantic) ? operationPutByValWithThisStrict : operationPutByValWithThis),
2760             m_callFrame, base, thisValue, property, value);
2761     }
2762     
2763     void compilePutById()
2764     {
2765         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == CellUse);
2766
2767         Node* node = m_node;
2768         LValue base = lowCell(node->child1());
2769         LValue value = lowJSValue(node->child2());
2770         auto uid = m_graph.identifiers()[node->identifierNumber()];
2771
2772         B3::PatchpointValue* patchpoint = m_out.patchpoint(Void);
2773         patchpoint->appendSomeRegister(base);
2774         patchpoint->appendSomeRegister(value);
2775         patchpoint->append(m_tagMask, ValueRep::reg(GPRInfo::tagMaskRegister));
2776         patchpoint->append(m_tagTypeNumber, ValueRep::reg(GPRInfo::tagTypeNumberRegister));
2777         patchpoint->clobber(RegisterSet::macroScratchRegisters());
2778
2779         // FIXME: If this is a PutByIdFlush, we might want to late-clobber volatile registers.
2780         // https://bugs.webkit.org/show_bug.cgi?id=152848
2781
2782         RefPtr<PatchpointExceptionHandle> exceptionHandle =
2783             preparePatchpointForExceptions(patchpoint);
2784
2785         State* state = &m_ftlState;
2786         ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->ecmaMode();
2787         
2788         patchpoint->setGenerator(
2789             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
2790                 AllowMacroScratchRegisterUsage allowScratch(jit);
2791
2792                 CallSiteIndex callSiteIndex =
2793                     state->jitCode->common.addUniqueCallSiteIndex(node->origin.semantic);
2794
2795                 Box<CCallHelpers::JumpList> exceptions =
2796                     exceptionHandle->scheduleExitCreation(params)->jumps(jit);
2797
2798                 // JS setter call ICs generated by the PutById IC will need this.
2799                 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex);
2800
2801                 auto generator = Box<JITPutByIdGenerator>::create(
2802                     jit.codeBlock(), node->origin.semantic, callSiteIndex,
2803                     params.unavailableRegisters(), JSValueRegs(params[0].gpr()),
2804                     JSValueRegs(params[1].gpr()), GPRInfo::patchpointScratchRegister, ecmaMode,
2805                     node->op() == PutByIdDirect ? Direct : NotDirect);
2806
2807                 generator->generateFastPath(jit);
2808                 CCallHelpers::Label done = jit.label();
2809
2810                 params.addLatePath(
2811                     [=] (CCallHelpers& jit) {
2812                         AllowMacroScratchRegisterUsage allowScratch(jit);
2813
2814                         generator->slowPathJump().link(&jit);
2815                         CCallHelpers::Label slowPathBegin = jit.label();
2816                         CCallHelpers::Call slowPathCall = callOperation(
2817                             *state, params.unavailableRegisters(), jit, node->origin.semantic,
2818                             exceptions.get(), generator->slowPathFunction(), InvalidGPRReg,
2819                             CCallHelpers::TrustedImmPtr(generator->stubInfo()), params[1].gpr(),
2820                             params[0].gpr(), CCallHelpers::TrustedImmPtr(uid)).call();
2821                         jit.jump().linkTo(done, &jit);
2822
2823                         generator->reportSlowPathCall(slowPathBegin, slowPathCall);
2824
2825                         jit.addLinkTask(
2826                             [=] (LinkBuffer& linkBuffer) {
2827                                 generator->finalize(linkBuffer);
2828                             });
2829                     });
2830             });
2831     }
2832     
2833     void compileGetButterfly()
2834     {
2835         setStorage(m_out.loadPtr(lowCell(m_node->child1()), m_heaps.JSObject_butterfly));
2836     }
2837
2838     void compileConstantStoragePointer()
2839     {
2840         setStorage(m_out.constIntPtr(m_node->storagePointer()));
2841     }
2842     
2843     void compileGetIndexedPropertyStorage()
2844     {
2845         LValue cell = lowCell(m_node->child1());
2846         
2847         if (m_node->arrayMode().type() == Array::String) {
2848             LBasicBlock slowPath = m_out.newBlock();
2849             LBasicBlock continuation = m_out.newBlock();
2850
2851             LValue fastResultValue = m_out.loadPtr(cell, m_heaps.JSString_value);
2852             ValueFromBlock fastResult = m_out.anchor(fastResultValue);
2853             
2854             m_out.branch(
2855                 m_out.notNull(fastResultValue), usually(continuation), rarely(slowPath));
2856             
2857             LBasicBlock lastNext = m_out.appendTo(slowPath, continuation);
2858             
2859             ValueFromBlock slowResult = m_out.anchor(
2860                 vmCall(pointerType(), m_out.operation(operationResolveRope), m_callFrame, cell));
2861             
2862             m_out.jump(continuation);
2863             
2864             m_out.appendTo(continuation, lastNext);
2865             
2866             setStorage(m_out.loadPtr(m_out.phi(pointerType(), fastResult, slowResult), m_heaps.StringImpl_data));
2867             return;
2868         }
2869
2870         DFG_ASSERT(m_graph, m_node, isTypedView(m_node->arrayMode().typedArrayType()));
2871         setStorage(m_out.loadPtr(cell, m_heaps.JSArrayBufferView_vector));
2872     }
2873     
2874     void compileCheckArray()
2875     {
2876         Edge edge = m_node->child1();
2877         LValue cell = lowCell(edge);
2878         
2879         if (m_node->arrayMode().alreadyChecked(m_graph, m_node, abstractValue(edge)))
2880             return;
2881         
2882         speculate(
2883             BadIndexingType, jsValueValue(cell), 0,
2884             m_out.logicalNot(isArrayType(cell, m_node->arrayMode())));
2885     }
2886
2887     void compileGetTypedArrayByteOffset()
2888     {
2889         LValue basePtr = lowCell(m_node->child1());    
2890
2891         LBasicBlock simpleCase = m_out.newBlock();
2892         LBasicBlock wastefulCase = m_out.newBlock();
2893         LBasicBlock continuation = m_out.newBlock();
2894         
2895         LValue mode = m_out.load32(basePtr, m_heaps.JSArrayBufferView_mode);
2896         m_out.branch(
2897             m_out.notEqual(mode, m_out.constInt32(WastefulTypedArray)),
2898             unsure(simpleCase), unsure(wastefulCase));
2899
2900         LBasicBlock lastNext = m_out.appendTo(simpleCase, wastefulCase);
2901
2902         ValueFromBlock simpleOut = m_out.anchor(m_out.constIntPtr(0));
2903
2904         m_out.jump(continuation);
2905
2906         m_out.appendTo(wastefulCase, continuation);
2907
2908         LValue vectorPtr = m_out.loadPtr(basePtr, m_heaps.JSArrayBufferView_vector);
2909         LValue butterflyPtr = m_out.loadPtr(basePtr, m_heaps.JSObject_butterfly);
2910         LValue arrayBufferPtr = m_out.loadPtr(butterflyPtr, m_heaps.Butterfly_arrayBuffer);
2911         LValue dataPtr = m_out.loadPtr(arrayBufferPtr, m_heaps.ArrayBuffer_data);
2912
2913         ValueFromBlock wastefulOut = m_out.anchor(m_out.sub(vectorPtr, dataPtr));
2914
2915         m_out.jump(continuation);
2916         m_out.appendTo(continuation, lastNext);
2917
2918         setInt32(m_out.castToInt32(m_out.phi(pointerType(), simpleOut, wastefulOut)));
2919     }
2920     
2921     void compileGetArrayLength()
2922     {
2923         switch (m_node->arrayMode().type()) {
2924         case Array::Undecided:
2925         case Array::Int32:
2926         case Array::Double:
2927         case Array::Contiguous: {
2928             setInt32(m_out.load32NonNegative(lowStorage(m_node->child2()), m_heaps.Butterfly_publicLength));
2929             return;
2930         }
2931             
2932         case Array::String: {
2933             LValue string = lowCell(m_node->child1());
2934             setInt32(m_out.load32NonNegative(string, m_heaps.JSString_length));
2935             return;
2936         }
2937             
2938         case Array::DirectArguments: {
2939             LValue arguments = lowCell(m_node->child1());
2940             speculate(
2941                 ExoticObjectMode, noValue(), nullptr,
2942                 m_out.notNull(m_out.loadPtr(arguments, m_heaps.DirectArguments_overrides)));
2943             setInt32(m_out.load32NonNegative(arguments, m_heaps.DirectArguments_length));
2944             return;
2945         }
2946             
2947         case Array::ScopedArguments: {
2948             LValue arguments = lowCell(m_node->child1());
2949             speculate(
2950                 ExoticObjectMode, noValue(), nullptr,
2951                 m_out.notZero32(m_out.load8ZeroExt32(arguments, m_heaps.ScopedArguments_overrodeThings)));
2952             setInt32(m_out.load32NonNegative(arguments, m_heaps.ScopedArguments_totalLength));
2953             return;
2954         }
2955             
2956         default:
2957             if (m_node->arrayMode().isSomeTypedArrayView()) {
2958                 setInt32(
2959                     m_out.load32NonNegative(lowCell(m_node->child1()), m_heaps.JSArrayBufferView_length));
2960                 return;
2961             }
2962             
2963             DFG_CRASH(m_graph, m_node, "Bad array type");
2964             return;
2965         }
2966     }
2967     
2968     void compileCheckInBounds()
2969     {
2970         speculate(
2971             OutOfBounds, noValue(), 0,
2972             m_out.aboveOrEqual(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2973     }
2974     
2975     void compileGetByVal()
2976     {
2977         switch (m_node->arrayMode().type()) {
2978         case Array::Int32:
2979         case Array::Contiguous: {
2980             LValue index = lowInt32(m_node->child2());
2981             LValue storage = lowStorage(m_node->child3());
2982             
2983             IndexedAbstractHeap& heap = m_node->arrayMode().type() == Array::Int32 ?
2984                 m_heaps.indexedInt32Properties : m_heaps.indexedContiguousProperties;
2985             
2986             if (m_node->arrayMode().isInBounds()) {
2987                 LValue result = m_out.load64(baseIndex(heap, storage, index, m_node->child2()));
2988                 LValue isHole = m_out.isZero64(result);
2989                 if (m_node->arrayMode().isSaneChain()) {
2990                     DFG_ASSERT(
2991                         m_graph, m_node, m_node->arrayMode().type() == Array::Contiguous);
2992                     result = m_out.select(
2993                         isHole, m_out.constInt64(JSValue::encode(jsUndefined())), result);
2994                 } else
2995                     speculate(LoadFromHole, noValue(), 0, isHole);
2996                 setJSValue(result);
2997                 return;
2998             }
2999             
3000             LValue base = lowCell(m_node->child1());
3001             
3002             LBasicBlock fastCase = m_out.newBlock();
3003             LBasicBlock slowCase = m_out.newBlock();
3004             LBasicBlock continuation = m_out.newBlock();
3005             
3006             m_out.branch(
3007                 m_out.aboveOrEqual(
3008                     index, m_out.load32NonNegative(storage, m_heaps.Butterfly_publicLength)),
3009                 rarely(slowCase), usually(fastCase));
3010             
3011             LBasicBlock lastNext = m_out.appendTo(fastCase, slowCase);
3012
3013             LValue fastResultValue = m_out.load64(baseIndex(heap, storage, index, m_node->child2()));
3014             ValueFromBlock fastResult = m_out.anchor(fastResultValue);
3015             m_out.branch(
3016                 m_out.isZero64(fastResultValue), rarely(slowCase), usually(continuation));
3017             
3018             m_out.appendTo(slowCase, continuation);
3019             ValueFromBlock slowResult = m_out.anchor(
3020                 vmCall(Int64, m_out.operation(operationGetByValArrayInt), m_callFrame, base, index));
3021             m_out.jump(continuation);
3022             
3023             m_out.appendTo(continuation, lastNext);
3024             setJSValue(m_out.phi(Int64, fastResult, slowResult));
3025             return;
3026         }
3027             
3028         case Array::Double: {
3029             LValue index = lowInt32(m_node->child2());
3030             LValue storage = lowStorage(m_node->child3());
3031             
3032             IndexedAbstractHeap& heap = m_heaps.indexedDoubleProperties;
3033             
3034             if (m_node->arrayMode().isInBounds()) {
3035                 LValue result = m_out.loadDouble(
3036                     baseIndex(heap, storage, index, m_node->child2()));
3037                 
3038                 if (!m_node->arrayMode().isSaneChain()) {
3039                     speculate(
3040                         LoadFromHole, noValue(), 0,
3041                         m_out.doubleNotEqualOrUnordered(result, result));
3042                 }
3043                 setDouble(result);
3044                 break;
3045             }
3046             
3047             LValue base = lowCell(m_node->child1());
3048             
3049             LBasicBlock inBounds = m_out.newBlock();
3050             LBasicBlock boxPath = m_out.newBlock();
3051             LBasicBlock slowCase = m_out.newBlock();
3052             LBasicBlock continuation = m_out.newBlock();
3053             
3054             m_out.branch(
3055                 m_out.aboveOrEqual(
3056                     index, m_out.load32NonNegative(storage, m_heaps.Butterfly_publicLength)),
3057                 rarely(slowCase), usually(inBounds));
3058             
3059             LBasicBlock lastNext = m_out.appendTo(inBounds, boxPath);
3060             LValue doubleValue = m_out.loadDouble(
3061                 baseIndex(heap, storage, index, m_node->child2()));
3062             m_out.branch(
3063                 m_out.doubleNotEqualOrUnordered(doubleValue, doubleValue),
3064                 rarely(slowCase), usually(boxPath));
3065             
3066             m_out.appendTo(boxPath, slowCase);
3067             ValueFromBlock fastResult = m_out.anchor(boxDouble(doubleValue));
3068             m_out.jump(continuation);
3069             
3070             m_out.appendTo(slowCase, continuation);
3071             ValueFromBlock slowResult = m_out.anchor(
3072                 vmCall(Int64, m_out.operation(operationGetByValArrayInt), m_callFrame, base, index));
3073             m_out.jump(continuation);
3074             
3075             m_out.appendTo(continuation, lastNext);
3076             setJSValue(m_out.phi(Int64, fastResult, slowResult));
3077             return;
3078         }
3079
3080         case Array::Undecided: {
3081             LValue index = lowInt32(m_node->child2());
3082
3083             speculate(OutOfBounds, noValue(), m_node, m_out.lessThan(index, m_out.int32Zero));
3084             setJSValue(m_out.constInt64(ValueUndefined));
3085             return;
3086         }
3087             
3088         case Array::DirectArguments: {
3089             LValue base = lowCell(m_node->child1());
3090             LValue index = lowInt32(m_node->child2());
3091             
3092             speculate(
3093                 ExoticObjectMode, noValue(), nullptr,
3094                 m_out.notNull(m_out.loadPtr(base, m_heaps.DirectArguments_overrides)));
3095             speculate(
3096                 ExoticObjectMode, noValue(), nullptr,
3097                 m_out.aboveOrEqual(
3098                     index,
3099                     m_out.load32NonNegative(base, m_heaps.DirectArguments_length)));
3100
3101             TypedPointer address = m_out.baseIndex(
3102                 m_heaps.DirectArguments_storage, base, m_out.zeroExtPtr(index));
3103             setJSValue(m_out.load64(address));
3104             return;
3105         }
3106             
3107         case Array::ScopedArguments: {
3108             LValue base = lowCell(m_node->child1());
3109             LValue index = lowInt32(m_node->child2());
3110             
3111             speculate(
3112                 ExoticObjectMode, noValue(), nullptr,
3113                 m_out.aboveOrEqual(
3114                     index,
3115                     m_out.load32NonNegative(base, m_heaps.ScopedArguments_totalLength)));
3116             
3117             LValue table = m_out.loadPtr(base, m_heaps.ScopedArguments_table);
3118             LValue namedLength = m_out.load32(table, m_heaps.ScopedArgumentsTable_length);
3119             
3120             LBasicBlock namedCase = m_out.newBlock();
3121             LBasicBlock overflowCase = m_out.newBlock();
3122             LBasicBlock continuation = m_out.newBlock();
3123             
3124             m_out.branch(
3125                 m_out.aboveOrEqual(index, namedLength), unsure(overflowCase), unsure(namedCase));
3126             
3127             LBasicBlock lastNext = m_out.appendTo(namedCase, overflowCase);
3128             
3129             LValue scope = m_out.loadPtr(base, m_heaps.ScopedArguments_scope);
3130             LValue arguments = m_out.loadPtr(table, m_heaps.ScopedArgumentsTable_arguments);
3131             
3132             TypedPointer address = m_out.baseIndex(
3133                 m_heaps.scopedArgumentsTableArguments, arguments, m_out.zeroExtPtr(index));
3134             LValue scopeOffset = m_out.load32(address);
3135             
3136             speculate(
3137                 ExoticObjectMode, noValue(), nullptr,
3138                 m_out.equal(scopeOffset, m_out.constInt32(ScopeOffset::invalidOffset)));
3139             
3140             address = m_out.baseIndex(
3141                 m_heaps.JSEnvironmentRecord_variables, scope, m_out.zeroExtPtr(scopeOffset));
3142             ValueFromBlock namedResult = m_out.anchor(m_out.load64(address));
3143             m_out.jump(continuation);
3144             
3145             m_out.appendTo(overflowCase, continuation);
3146             
3147             address = m_out.baseIndex(
3148                 m_heaps.ScopedArguments_overflowStorage, base,
3149                 m_out.zeroExtPtr(m_out.sub(index, namedLength)));
3150          &