[JSC] Shrink the Math inline caches some more
[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         ArithProfile* arithProfile = m_ftlState.graph.baselineCodeBlockFor(m_node->origin.semantic)->arithProfileForBytecodeOffset(m_node->origin.semantic.bytecodeIndex);
1557         JITAddIC* addIC = codeBlock()->addJITAddIC(arithProfile);
1558         auto repatchingFunction = operationValueAddOptimize;
1559         auto nonRepatchingFunction = operationValueAdd;
1560         compileMathIC(addIC, repatchingFunction, nonRepatchingFunction);
1561     }
1562
1563     template <typename Generator>
1564     void compileMathIC(JITBinaryMathIC<Generator>* mathIC, FunctionPtr repatchingFunction, FunctionPtr nonRepatchingFunction)
1565     {
1566         Node* node = m_node;
1567         
1568         LValue left = lowJSValue(node->child1());
1569         LValue right = lowJSValue(node->child2());
1570
1571         SnippetOperand leftOperand(m_state.forNode(node->child1()).resultType());
1572         SnippetOperand rightOperand(m_state.forNode(node->child2()).resultType());
1573             
1574         PatchpointValue* patchpoint = m_out.patchpoint(Int64);
1575         patchpoint->appendSomeRegister(left);
1576         patchpoint->appendSomeRegister(right);
1577         patchpoint->append(m_tagMask, ValueRep::lateReg(GPRInfo::tagMaskRegister));
1578         patchpoint->append(m_tagTypeNumber, ValueRep::lateReg(GPRInfo::tagTypeNumberRegister));
1579         RefPtr<PatchpointExceptionHandle> exceptionHandle =
1580             preparePatchpointForExceptions(patchpoint);
1581         patchpoint->numGPScratchRegisters = 1;
1582         patchpoint->numFPScratchRegisters = 2;
1583         patchpoint->clobber(RegisterSet::macroScratchRegisters());
1584         State* state = &m_ftlState;
1585         patchpoint->setGenerator(
1586             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
1587                 AllowMacroScratchRegisterUsage allowScratch(jit);
1588
1589                 Box<CCallHelpers::JumpList> exceptions =
1590                     exceptionHandle->scheduleExitCreation(params)->jumps(jit);
1591
1592 #if ENABLE(MATH_IC_STATS)
1593                 auto inlineStart = jit.label();
1594 #endif
1595
1596                 Box<MathICGenerationState> mathICGenerationState = Box<MathICGenerationState>::create();
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);
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             ArithProfile* arithProfile = m_ftlState.graph.baselineCodeBlockFor(m_node->origin.semantic)->arithProfileForBytecodeOffset(m_node->origin.semantic.bytecodeIndex);
1728             JITSubIC* subIC = codeBlock()->addJITSubIC(arithProfile);
1729             auto repatchingFunction = operationValueSubOptimize;
1730             auto nonRepatchingFunction = operationValueSub;
1731             compileMathIC(subIC, repatchingFunction, nonRepatchingFunction);
1732             break;
1733         }
1734
1735         default:
1736             DFG_CRASH(m_graph, m_node, "Bad use kind");
1737             break;
1738         }
1739     }
1740
1741     void compileArithClz32()
1742     {
1743         if (m_node->child1().useKind() == Int32Use || m_node->child1().useKind() == KnownInt32Use) {
1744             LValue operand = lowInt32(m_node->child1());
1745             setInt32(m_out.ctlz32(operand));
1746             return;
1747         }
1748         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
1749         LValue argument = lowJSValue(m_node->child1());
1750         LValue result = vmCall(Int32, m_out.operation(operationArithClz32), m_callFrame, argument);
1751         setInt32(result);
1752     }
1753     
1754     void compileArithMul()
1755     {
1756         switch (m_node->binaryUseKind()) {
1757         case Int32Use: {
1758             LValue left = lowInt32(m_node->child1());
1759             LValue right = lowInt32(m_node->child2());
1760             
1761             LValue result;
1762
1763             if (!shouldCheckOverflow(m_node->arithMode()))
1764                 result = m_out.mul(left, right);
1765             else {
1766                 CheckValue* speculation = m_out.speculateMul(left, right);
1767                 blessSpeculation(speculation, Overflow, noValue(), nullptr, m_origin);
1768                 result = speculation;
1769             }
1770             
1771             if (shouldCheckNegativeZero(m_node->arithMode())) {
1772                 LBasicBlock slowCase = m_out.newBlock();
1773                 LBasicBlock continuation = m_out.newBlock();
1774                 
1775                 m_out.branch(
1776                     m_out.notZero32(result), usually(continuation), rarely(slowCase));
1777                 
1778                 LBasicBlock lastNext = m_out.appendTo(slowCase, continuation);
1779                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(left, m_out.int32Zero));
1780                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(right, m_out.int32Zero));
1781                 m_out.jump(continuation);
1782                 m_out.appendTo(continuation, lastNext);
1783             }
1784             
1785             setInt32(result);
1786             break;
1787         }
1788             
1789         case Int52RepUse: {
1790             Int52Kind kind;
1791             LValue left = lowWhicheverInt52(m_node->child1(), kind);
1792             LValue right = lowInt52(m_node->child2(), opposite(kind));
1793
1794             CheckValue* result = m_out.speculateMul(left, right);
1795             blessSpeculation(result, Overflow, noValue(), nullptr, m_origin);
1796
1797             if (shouldCheckNegativeZero(m_node->arithMode())) {
1798                 LBasicBlock slowCase = m_out.newBlock();
1799                 LBasicBlock continuation = m_out.newBlock();
1800                 
1801                 m_out.branch(
1802                     m_out.notZero64(result), usually(continuation), rarely(slowCase));
1803                 
1804                 LBasicBlock lastNext = m_out.appendTo(slowCase, continuation);
1805                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(left, m_out.int64Zero));
1806                 speculate(NegativeZero, noValue(), nullptr, m_out.lessThan(right, m_out.int64Zero));
1807                 m_out.jump(continuation);
1808                 m_out.appendTo(continuation, lastNext);
1809             }
1810             
1811             setInt52(result);
1812             break;
1813         }
1814             
1815         case DoubleRepUse: {
1816             setDouble(
1817                 m_out.doubleMul(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1818             break;
1819         }
1820
1821         case UntypedUse: {
1822             ArithProfile* arithProfile = m_ftlState.graph.baselineCodeBlockFor(m_node->origin.semantic)->arithProfileForBytecodeOffset(m_node->origin.semantic.bytecodeIndex);
1823             JITMulIC* mulIC = codeBlock()->addJITMulIC(arithProfile);
1824             auto repatchingFunction = operationValueMulOptimize;
1825             auto nonRepatchingFunction = operationValueMul;
1826             compileMathIC(mulIC, repatchingFunction, nonRepatchingFunction);
1827             break;
1828         }
1829
1830         default:
1831             DFG_CRASH(m_graph, m_node, "Bad use kind");
1832             break;
1833         }
1834     }
1835
1836     void compileArithDiv()
1837     {
1838         switch (m_node->binaryUseKind()) {
1839         case Int32Use: {
1840             LValue numerator = lowInt32(m_node->child1());
1841             LValue denominator = lowInt32(m_node->child2());
1842
1843             if (shouldCheckNegativeZero(m_node->arithMode())) {
1844                 LBasicBlock zeroNumerator = m_out.newBlock();
1845                 LBasicBlock numeratorContinuation = m_out.newBlock();
1846
1847                 m_out.branch(
1848                     m_out.isZero32(numerator),
1849                     rarely(zeroNumerator), usually(numeratorContinuation));
1850
1851                 LBasicBlock innerLastNext = m_out.appendTo(zeroNumerator, numeratorContinuation);
1852
1853                 speculate(
1854                     NegativeZero, noValue(), 0, m_out.lessThan(denominator, m_out.int32Zero));
1855
1856                 m_out.jump(numeratorContinuation);
1857
1858                 m_out.appendTo(numeratorContinuation, innerLastNext);
1859             }
1860             
1861             if (shouldCheckOverflow(m_node->arithMode())) {
1862                 LBasicBlock unsafeDenominator = m_out.newBlock();
1863                 LBasicBlock continuation = m_out.newBlock();
1864
1865                 LValue adjustedDenominator = m_out.add(denominator, m_out.int32One);
1866                 m_out.branch(
1867                     m_out.above(adjustedDenominator, m_out.int32One),
1868                     usually(continuation), rarely(unsafeDenominator));
1869
1870                 LBasicBlock lastNext = m_out.appendTo(unsafeDenominator, continuation);
1871                 LValue neg2ToThe31 = m_out.constInt32(-2147483647-1);
1872                 speculate(Overflow, noValue(), nullptr, m_out.isZero32(denominator));
1873                 speculate(Overflow, noValue(), nullptr, m_out.equal(numerator, neg2ToThe31));
1874                 m_out.jump(continuation);
1875
1876                 m_out.appendTo(continuation, lastNext);
1877                 LValue result = m_out.div(numerator, denominator);
1878                 speculate(
1879                     Overflow, noValue(), 0,
1880                     m_out.notEqual(m_out.mul(result, denominator), numerator));
1881                 setInt32(result);
1882             } else
1883                 setInt32(m_out.chillDiv(numerator, denominator));
1884
1885             break;
1886         }
1887             
1888         case DoubleRepUse: {
1889             setDouble(m_out.doubleDiv(
1890                 lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1891             break;
1892         }
1893
1894         case UntypedUse: {
1895             emitBinarySnippet<JITDivGenerator, NeedScratchFPR>(operationValueDiv);
1896             break;
1897         }
1898
1899         default:
1900             DFG_CRASH(m_graph, m_node, "Bad use kind");
1901             break;
1902         }
1903     }
1904     
1905     void compileArithMod()
1906     {
1907         switch (m_node->binaryUseKind()) {
1908         case Int32Use: {
1909             LValue numerator = lowInt32(m_node->child1());
1910             LValue denominator = lowInt32(m_node->child2());
1911
1912             LValue remainder;
1913             if (shouldCheckOverflow(m_node->arithMode())) {
1914                 LBasicBlock unsafeDenominator = m_out.newBlock();
1915                 LBasicBlock continuation = m_out.newBlock();
1916
1917                 LValue adjustedDenominator = m_out.add(denominator, m_out.int32One);
1918                 m_out.branch(
1919                     m_out.above(adjustedDenominator, m_out.int32One),
1920                     usually(continuation), rarely(unsafeDenominator));
1921
1922                 LBasicBlock lastNext = m_out.appendTo(unsafeDenominator, continuation);
1923                 LValue neg2ToThe31 = m_out.constInt32(-2147483647-1);
1924                 speculate(Overflow, noValue(), nullptr, m_out.isZero32(denominator));
1925                 speculate(Overflow, noValue(), nullptr, m_out.equal(numerator, neg2ToThe31));
1926                 m_out.jump(continuation);
1927
1928                 m_out.appendTo(continuation, lastNext);
1929                 LValue result = m_out.mod(numerator, denominator);
1930                 remainder = result;
1931             } else
1932                 remainder = m_out.chillMod(numerator, denominator);
1933
1934             if (shouldCheckNegativeZero(m_node->arithMode())) {
1935                 LBasicBlock negativeNumerator = m_out.newBlock();
1936                 LBasicBlock numeratorContinuation = m_out.newBlock();
1937
1938                 m_out.branch(
1939                     m_out.lessThan(numerator, m_out.int32Zero),
1940                     unsure(negativeNumerator), unsure(numeratorContinuation));
1941
1942                 LBasicBlock innerLastNext = m_out.appendTo(negativeNumerator, numeratorContinuation);
1943
1944                 speculate(NegativeZero, noValue(), 0, m_out.isZero32(remainder));
1945
1946                 m_out.jump(numeratorContinuation);
1947
1948                 m_out.appendTo(numeratorContinuation, innerLastNext);
1949             }
1950
1951             setInt32(remainder);
1952             break;
1953         }
1954             
1955         case DoubleRepUse: {
1956             setDouble(
1957                 m_out.doubleMod(lowDouble(m_node->child1()), lowDouble(m_node->child2())));
1958             break;
1959         }
1960             
1961         default:
1962             DFG_CRASH(m_graph, m_node, "Bad use kind");
1963             break;
1964         }
1965     }
1966
1967     void compileArithMinOrMax()
1968     {
1969         switch (m_node->binaryUseKind()) {
1970         case Int32Use: {
1971             LValue left = lowInt32(m_node->child1());
1972             LValue right = lowInt32(m_node->child2());
1973             
1974             setInt32(
1975                 m_out.select(
1976                     m_node->op() == ArithMin
1977                         ? m_out.lessThan(left, right)
1978                         : m_out.lessThan(right, left),
1979                     left, right));
1980             break;
1981         }
1982             
1983         case DoubleRepUse: {
1984             LValue left = lowDouble(m_node->child1());
1985             LValue right = lowDouble(m_node->child2());
1986             
1987             LBasicBlock notLessThan = m_out.newBlock();
1988             LBasicBlock continuation = m_out.newBlock();
1989             
1990             Vector<ValueFromBlock, 2> results;
1991             
1992             results.append(m_out.anchor(left));
1993             m_out.branch(
1994                 m_node->op() == ArithMin
1995                     ? m_out.doubleLessThan(left, right)
1996                     : m_out.doubleGreaterThan(left, right),
1997                 unsure(continuation), unsure(notLessThan));
1998             
1999             LBasicBlock lastNext = m_out.appendTo(notLessThan, continuation);
2000             results.append(m_out.anchor(m_out.select(
2001                 m_node->op() == ArithMin
2002                     ? m_out.doubleGreaterThanOrEqual(left, right)
2003                     : m_out.doubleLessThanOrEqual(left, right),
2004                 right, m_out.constDouble(PNaN))));
2005             m_out.jump(continuation);
2006             
2007             m_out.appendTo(continuation, lastNext);
2008             setDouble(m_out.phi(Double, results));
2009             break;
2010         }
2011             
2012         default:
2013             DFG_CRASH(m_graph, m_node, "Bad use kind");
2014             break;
2015         }
2016     }
2017     
2018     void compileArithAbs()
2019     {
2020         switch (m_node->child1().useKind()) {
2021         case Int32Use: {
2022             LValue value = lowInt32(m_node->child1());
2023
2024             LValue mask = m_out.aShr(value, m_out.constInt32(31));
2025             LValue result = m_out.bitXor(mask, m_out.add(mask, value));
2026
2027             if (shouldCheckOverflow(m_node->arithMode()))
2028                 speculate(Overflow, noValue(), 0, m_out.lessThan(result, m_out.int32Zero));
2029
2030             setInt32(result);
2031             break;
2032         }
2033             
2034         case DoubleRepUse: {
2035             setDouble(m_out.doubleAbs(lowDouble(m_node->child1())));
2036             break;
2037         }
2038             
2039         default: {
2040             DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2041             LValue argument = lowJSValue(m_node->child1());
2042             LValue result = vmCall(Double, m_out.operation(operationArithAbs), m_callFrame, argument);
2043             setDouble(result);
2044             break;
2045         }
2046         }
2047     }
2048
2049     void compileArithSin()
2050     {
2051         if (m_node->child1().useKind() == DoubleRepUse) {
2052             setDouble(m_out.doubleSin(lowDouble(m_node->child1())));
2053             return;
2054         }
2055         LValue argument = lowJSValue(m_node->child1());
2056         LValue result = vmCall(Double, m_out.operation(operationArithSin), m_callFrame, argument);
2057         setDouble(result);
2058     }
2059
2060     void compileArithCos()
2061     {
2062         if (m_node->child1().useKind() == DoubleRepUse) {
2063             setDouble(m_out.doubleCos(lowDouble(m_node->child1())));
2064             return;
2065         }
2066         LValue argument = lowJSValue(m_node->child1());
2067         LValue result = vmCall(Double, m_out.operation(operationArithCos), m_callFrame, argument);
2068         setDouble(result);
2069     }
2070
2071     void compileArithTan()
2072     {
2073         if (m_node->child1().useKind() == DoubleRepUse) {
2074             setDouble(m_out.doubleTan(lowDouble(m_node->child1())));
2075             return;
2076         }
2077         LValue argument = lowJSValue(m_node->child1());
2078         LValue result = vmCall(Double, m_out.operation(operationArithTan), m_callFrame, argument);
2079         setDouble(result);
2080     }
2081
2082     void compileArithPow()
2083     {
2084         if (m_node->child2().useKind() == Int32Use)
2085             setDouble(m_out.doublePowi(lowDouble(m_node->child1()), lowInt32(m_node->child2())));
2086         else {
2087             LValue base = lowDouble(m_node->child1());
2088             LValue exponent = lowDouble(m_node->child2());
2089
2090             LBasicBlock integerExponentIsSmallBlock = m_out.newBlock();
2091             LBasicBlock integerExponentPowBlock = m_out.newBlock();
2092             LBasicBlock doubleExponentPowBlockEntry = m_out.newBlock();
2093             LBasicBlock nanExceptionBaseIsOne = m_out.newBlock();
2094             LBasicBlock nanExceptionExponentIsInfinity = m_out.newBlock();
2095             LBasicBlock testExponentIsOneHalf = m_out.newBlock();
2096             LBasicBlock handleBaseZeroExponentIsOneHalf = m_out.newBlock();
2097             LBasicBlock handleInfinityForExponentIsOneHalf = m_out.newBlock();
2098             LBasicBlock exponentIsOneHalfNormal = m_out.newBlock();
2099             LBasicBlock exponentIsOneHalfInfinity = m_out.newBlock();
2100             LBasicBlock testExponentIsNegativeOneHalf = m_out.newBlock();
2101             LBasicBlock testBaseZeroExponentIsNegativeOneHalf = m_out.newBlock();
2102             LBasicBlock handleBaseZeroExponentIsNegativeOneHalf = m_out.newBlock();
2103             LBasicBlock handleInfinityForExponentIsNegativeOneHalf = m_out.newBlock();
2104             LBasicBlock exponentIsNegativeOneHalfNormal = m_out.newBlock();
2105             LBasicBlock exponentIsNegativeOneHalfInfinity = m_out.newBlock();
2106             LBasicBlock powBlock = m_out.newBlock();
2107             LBasicBlock nanExceptionResultIsNaN = m_out.newBlock();
2108             LBasicBlock continuation = m_out.newBlock();
2109
2110             LValue integerExponent = m_out.doubleToInt(exponent);
2111             LValue integerExponentConvertedToDouble = m_out.intToDouble(integerExponent);
2112             LValue exponentIsInteger = m_out.doubleEqual(exponent, integerExponentConvertedToDouble);
2113             m_out.branch(exponentIsInteger, unsure(integerExponentIsSmallBlock), unsure(doubleExponentPowBlockEntry));
2114
2115             LBasicBlock lastNext = m_out.appendTo(integerExponentIsSmallBlock, integerExponentPowBlock);
2116             LValue integerExponentBelowMax = m_out.belowOrEqual(integerExponent, m_out.constInt32(maxExponentForIntegerMathPow));
2117             m_out.branch(integerExponentBelowMax, usually(integerExponentPowBlock), rarely(doubleExponentPowBlockEntry));
2118
2119             m_out.appendTo(integerExponentPowBlock, doubleExponentPowBlockEntry);
2120             ValueFromBlock powDoubleIntResult = m_out.anchor(m_out.doublePowi(base, integerExponent));
2121             m_out.jump(continuation);
2122
2123             // If y is NaN, the result is NaN.
2124             m_out.appendTo(doubleExponentPowBlockEntry, nanExceptionBaseIsOne);
2125             LValue exponentIsNaN;
2126             if (provenType(m_node->child2()) & SpecDoubleNaN)
2127                 exponentIsNaN = m_out.doubleNotEqualOrUnordered(exponent, exponent);
2128             else
2129                 exponentIsNaN = m_out.booleanFalse;
2130             m_out.branch(exponentIsNaN, rarely(nanExceptionResultIsNaN), usually(nanExceptionBaseIsOne));
2131
2132             // If abs(x) is 1 and y is +infinity, the result is NaN.
2133             // If abs(x) is 1 and y is -infinity, the result is NaN.
2134
2135             //     Test if base == 1.
2136             m_out.appendTo(nanExceptionBaseIsOne, nanExceptionExponentIsInfinity);
2137             LValue absoluteBase = m_out.doubleAbs(base);
2138             LValue absoluteBaseIsOne = m_out.doubleEqual(absoluteBase, m_out.constDouble(1));
2139             m_out.branch(absoluteBaseIsOne, rarely(nanExceptionExponentIsInfinity), usually(testExponentIsOneHalf));
2140
2141             //     Test if abs(y) == Infinity.
2142             m_out.appendTo(nanExceptionExponentIsInfinity, testExponentIsOneHalf);
2143             LValue absoluteExponent = m_out.doubleAbs(exponent);
2144             LValue absoluteExponentIsInfinity = m_out.doubleEqual(absoluteExponent, m_out.constDouble(std::numeric_limits<double>::infinity()));
2145             m_out.branch(absoluteExponentIsInfinity, rarely(nanExceptionResultIsNaN), usually(testExponentIsOneHalf));
2146
2147             // If y == 0.5 or y == -0.5, handle it through SQRT.
2148             // We have be carefuly with -0 and -Infinity.
2149
2150             //     Test if y == 0.5
2151             m_out.appendTo(testExponentIsOneHalf, handleBaseZeroExponentIsOneHalf);
2152             LValue exponentIsOneHalf = m_out.doubleEqual(exponent, m_out.constDouble(0.5));
2153             m_out.branch(exponentIsOneHalf, rarely(handleBaseZeroExponentIsOneHalf), usually(testExponentIsNegativeOneHalf));
2154
2155             //     Handle x == -0.
2156             m_out.appendTo(handleBaseZeroExponentIsOneHalf, handleInfinityForExponentIsOneHalf);
2157             LValue baseIsZeroExponentIsOneHalf = m_out.doubleEqual(base, m_out.doubleZero);
2158             ValueFromBlock zeroResultExponentIsOneHalf = m_out.anchor(m_out.doubleZero);
2159             m_out.branch(baseIsZeroExponentIsOneHalf, rarely(continuation), usually(handleInfinityForExponentIsOneHalf));
2160
2161             //     Test if abs(x) == Infinity.
2162             m_out.appendTo(handleInfinityForExponentIsOneHalf, exponentIsOneHalfNormal);
2163             LValue absoluteBaseIsInfinityOneHalf = m_out.doubleEqual(absoluteBase, m_out.constDouble(std::numeric_limits<double>::infinity()));
2164             m_out.branch(absoluteBaseIsInfinityOneHalf, rarely(exponentIsOneHalfInfinity), usually(exponentIsOneHalfNormal));
2165
2166             //     The exponent is 0.5, the base is finite or NaN, we can use SQRT.
2167             m_out.appendTo(exponentIsOneHalfNormal, exponentIsOneHalfInfinity);
2168             ValueFromBlock sqrtResult = m_out.anchor(m_out.doubleSqrt(base));
2169             m_out.jump(continuation);
2170
2171             //     The exponent is 0.5, the base is infinite, the result is always infinite.
2172             m_out.appendTo(exponentIsOneHalfInfinity, testExponentIsNegativeOneHalf);
2173             ValueFromBlock sqrtInfinityResult = m_out.anchor(m_out.constDouble(std::numeric_limits<double>::infinity()));
2174             m_out.jump(continuation);
2175
2176             //     Test if y == -0.5
2177             m_out.appendTo(testExponentIsNegativeOneHalf, testBaseZeroExponentIsNegativeOneHalf);
2178             LValue exponentIsNegativeOneHalf = m_out.doubleEqual(exponent, m_out.constDouble(-0.5));
2179             m_out.branch(exponentIsNegativeOneHalf, rarely(testBaseZeroExponentIsNegativeOneHalf), usually(powBlock));
2180
2181             //     Handle x == -0.
2182             m_out.appendTo(testBaseZeroExponentIsNegativeOneHalf, handleBaseZeroExponentIsNegativeOneHalf);
2183             LValue baseIsZeroExponentIsNegativeOneHalf = m_out.doubleEqual(base, m_out.doubleZero);
2184             m_out.branch(baseIsZeroExponentIsNegativeOneHalf, rarely(handleBaseZeroExponentIsNegativeOneHalf), usually(handleInfinityForExponentIsNegativeOneHalf));
2185
2186             m_out.appendTo(handleBaseZeroExponentIsNegativeOneHalf, handleInfinityForExponentIsNegativeOneHalf);
2187             ValueFromBlock oneOverSqrtZeroResult = m_out.anchor(m_out.constDouble(std::numeric_limits<double>::infinity()));
2188             m_out.jump(continuation);
2189
2190             //     Test if abs(x) == Infinity.
2191             m_out.appendTo(handleInfinityForExponentIsNegativeOneHalf, exponentIsNegativeOneHalfNormal);
2192             LValue absoluteBaseIsInfinityNegativeOneHalf = m_out.doubleEqual(absoluteBase, m_out.constDouble(std::numeric_limits<double>::infinity()));
2193             m_out.branch(absoluteBaseIsInfinityNegativeOneHalf, rarely(exponentIsNegativeOneHalfInfinity), usually(exponentIsNegativeOneHalfNormal));
2194
2195             //     The exponent is -0.5, the base is finite or NaN, we can use 1/SQRT.
2196             m_out.appendTo(exponentIsNegativeOneHalfNormal, exponentIsNegativeOneHalfInfinity);
2197             LValue sqrtBase = m_out.doubleSqrt(base);
2198             ValueFromBlock oneOverSqrtResult = m_out.anchor(m_out.div(m_out.constDouble(1.), sqrtBase));
2199             m_out.jump(continuation);
2200
2201             //     The exponent is -0.5, the base is infinite, the result is always zero.
2202             m_out.appendTo(exponentIsNegativeOneHalfInfinity, powBlock);
2203             ValueFromBlock oneOverSqrtInfinityResult = m_out.anchor(m_out.doubleZero);
2204             m_out.jump(continuation);
2205
2206             m_out.appendTo(powBlock, nanExceptionResultIsNaN);
2207             ValueFromBlock powResult = m_out.anchor(m_out.doublePow(base, exponent));
2208             m_out.jump(continuation);
2209
2210             m_out.appendTo(nanExceptionResultIsNaN, continuation);
2211             ValueFromBlock pureNan = m_out.anchor(m_out.constDouble(PNaN));
2212             m_out.jump(continuation);
2213
2214             m_out.appendTo(continuation, lastNext);
2215             setDouble(m_out.phi(Double, powDoubleIntResult, zeroResultExponentIsOneHalf, sqrtResult, sqrtInfinityResult, oneOverSqrtZeroResult, oneOverSqrtResult, oneOverSqrtInfinityResult, powResult, pureNan));
2216         }
2217     }
2218
2219     void compileArithRandom()
2220     {
2221         JSGlobalObject* globalObject = m_graph.globalObjectFor(m_node->origin.semantic);
2222
2223         // Inlined WeakRandom::advance().
2224         // uint64_t x = m_low;
2225         void* lowAddress = reinterpret_cast<uint8_t*>(globalObject) + JSGlobalObject::weakRandomOffset() + WeakRandom::lowOffset();
2226         LValue low = m_out.load64(m_out.absolute(lowAddress));
2227         // uint64_t y = m_high;
2228         void* highAddress = reinterpret_cast<uint8_t*>(globalObject) + JSGlobalObject::weakRandomOffset() + WeakRandom::highOffset();
2229         LValue high = m_out.load64(m_out.absolute(highAddress));
2230         // m_low = y;
2231         m_out.store64(high, m_out.absolute(lowAddress));
2232
2233         // x ^= x << 23;
2234         LValue phase1 = m_out.bitXor(m_out.shl(low, m_out.constInt64(23)), low);
2235
2236         // x ^= x >> 17;
2237         LValue phase2 = m_out.bitXor(m_out.lShr(phase1, m_out.constInt64(17)), phase1);
2238
2239         // x ^= y ^ (y >> 26);
2240         LValue phase3 = m_out.bitXor(m_out.bitXor(high, m_out.lShr(high, m_out.constInt64(26))), phase2);
2241
2242         // m_high = x;
2243         m_out.store64(phase3, m_out.absolute(highAddress));
2244
2245         // return x + y;
2246         LValue random64 = m_out.add(phase3, high);
2247
2248         // Extract random 53bit. [0, 53] bit is safe integer number ranges in double representation.
2249         LValue random53 = m_out.bitAnd(random64, m_out.constInt64((1ULL << 53) - 1));
2250
2251         LValue double53Integer = m_out.intToDouble(random53);
2252
2253         // Convert `(53bit double integer value) / (1 << 53)` to `(53bit double integer value) * (1.0 / (1 << 53))`.
2254         // In latter case, `1.0 / (1 << 53)` will become a double value represented as (mantissa = 0 & exp = 970, it means 1e-(2**54)).
2255         static const double scale = 1.0 / (1ULL << 53);
2256
2257         // Multiplying 1e-(2**54) with the double integer does not change anything of the mantissa part of the double integer.
2258         // It just reduces the exp part of the given 53bit double integer.
2259         // (Except for 0.0. This is specially handled and in this case, exp just becomes 0.)
2260         // Now we get 53bit precision random double value in [0, 1).
2261         LValue result = m_out.doubleMul(double53Integer, m_out.constDouble(scale));
2262
2263         setDouble(result);
2264     }
2265
2266     void compileArithRound()
2267     {
2268         if (m_node->child1().useKind() == DoubleRepUse) {
2269             LValue result = nullptr;
2270             if (producesInteger(m_node->arithRoundingMode()) && !shouldCheckNegativeZero(m_node->arithRoundingMode())) {
2271                 LValue value = lowDouble(m_node->child1());
2272                 result = m_out.doubleFloor(m_out.doubleAdd(value, m_out.constDouble(0.5)));
2273             } else {
2274                 LBasicBlock realPartIsMoreThanHalf = m_out.newBlock();
2275                 LBasicBlock continuation = m_out.newBlock();
2276
2277                 LValue value = lowDouble(m_node->child1());
2278                 LValue integerValue = m_out.doubleCeil(value);
2279                 ValueFromBlock integerValueResult = m_out.anchor(integerValue);
2280
2281                 LValue realPart = m_out.doubleSub(integerValue, value);
2282
2283                 m_out.branch(m_out.doubleGreaterThanOrUnordered(realPart, m_out.constDouble(0.5)), unsure(realPartIsMoreThanHalf), unsure(continuation));
2284
2285                 LBasicBlock lastNext = m_out.appendTo(realPartIsMoreThanHalf, continuation);
2286                 LValue integerValueRoundedDown = m_out.doubleSub(integerValue, m_out.constDouble(1));
2287                 ValueFromBlock integerValueRoundedDownResult = m_out.anchor(integerValueRoundedDown);
2288                 m_out.jump(continuation);
2289                 m_out.appendTo(continuation, lastNext);
2290
2291                 result = m_out.phi(Double, integerValueResult, integerValueRoundedDownResult);
2292             }
2293
2294             if (producesInteger(m_node->arithRoundingMode())) {
2295                 LValue integerValue = convertDoubleToInt32(result, shouldCheckNegativeZero(m_node->arithRoundingMode()));
2296                 setInt32(integerValue);
2297             } else
2298                 setDouble(result);
2299             return;
2300         }
2301
2302         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2303         LValue argument = lowJSValue(m_node->child1());
2304         setJSValue(vmCall(Int64, m_out.operation(operationArithRound), m_callFrame, argument));
2305     }
2306
2307     void compileArithFloor()
2308     {
2309         if (m_node->child1().useKind() == DoubleRepUse) {
2310             LValue value = lowDouble(m_node->child1());
2311             LValue integerValue = m_out.doubleFloor(value);
2312             if (producesInteger(m_node->arithRoundingMode()))
2313                 setInt32(convertDoubleToInt32(integerValue, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2314             else
2315                 setDouble(integerValue);
2316             return;
2317         }
2318         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2319         LValue argument = lowJSValue(m_node->child1());
2320         setJSValue(vmCall(Int64, m_out.operation(operationArithFloor), m_callFrame, argument));
2321     }
2322
2323     void compileArithCeil()
2324     {
2325         if (m_node->child1().useKind() == DoubleRepUse) {
2326             LValue value = lowDouble(m_node->child1());
2327             LValue integerValue = m_out.doubleCeil(value);
2328             if (producesInteger(m_node->arithRoundingMode()))
2329                 setInt32(convertDoubleToInt32(integerValue, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2330             else
2331                 setDouble(integerValue);
2332             return;
2333         }
2334         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2335         LValue argument = lowJSValue(m_node->child1());
2336         setJSValue(vmCall(Int64, m_out.operation(operationArithCeil), m_callFrame, argument));
2337     }
2338
2339     void compileArithTrunc()
2340     {
2341         if (m_node->child1().useKind() == DoubleRepUse) {
2342             LValue value = lowDouble(m_node->child1());
2343             LValue result = m_out.doubleTrunc(value);
2344             if (producesInteger(m_node->arithRoundingMode()))
2345                 setInt32(convertDoubleToInt32(result, shouldCheckNegativeZero(m_node->arithRoundingMode())));
2346             else
2347                 setDouble(result);
2348             return;
2349         }
2350         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == UntypedUse);
2351         LValue argument = lowJSValue(m_node->child1());
2352         setJSValue(vmCall(Int64, m_out.operation(operationArithTrunc), m_callFrame, argument));
2353     }
2354
2355     void compileArithSqrt()
2356     {
2357         if (m_node->child1().useKind() == DoubleRepUse) {
2358             setDouble(m_out.doubleSqrt(lowDouble(m_node->child1())));
2359             return;
2360         }
2361         LValue argument = lowJSValue(m_node->child1());
2362         LValue result = vmCall(Double, m_out.operation(operationArithSqrt), m_callFrame, argument);
2363         setDouble(result);
2364     }
2365
2366     void compileArithLog()
2367     {
2368         if (m_node->child1().useKind() == DoubleRepUse) {
2369             setDouble(m_out.doubleLog(lowDouble(m_node->child1())));
2370             return;
2371         }
2372         LValue argument = lowJSValue(m_node->child1());
2373         LValue result = vmCall(Double, m_out.operation(operationArithLog), m_callFrame, argument);
2374         setDouble(result);
2375     }
2376     
2377     void compileArithFRound()
2378     {
2379         if (m_node->child1().useKind() == DoubleRepUse) {
2380             setDouble(m_out.fround(lowDouble(m_node->child1())));
2381             return;
2382         }
2383         LValue argument = lowJSValue(m_node->child1());
2384         LValue result = vmCall(Double, m_out.operation(operationArithFRound), m_callFrame, argument);
2385         setDouble(result);
2386     }
2387     
2388     void compileArithNegate()
2389     {
2390         switch (m_node->child1().useKind()) {
2391         case Int32Use: {
2392             LValue value = lowInt32(m_node->child1());
2393             
2394             LValue result;
2395             if (!shouldCheckOverflow(m_node->arithMode()))
2396                 result = m_out.neg(value);
2397             else if (!shouldCheckNegativeZero(m_node->arithMode())) {
2398                 CheckValue* check = m_out.speculateSub(m_out.int32Zero, value);
2399                 blessSpeculation(check, Overflow, noValue(), nullptr, m_origin);
2400                 result = check;
2401             } else {
2402                 speculate(Overflow, noValue(), 0, m_out.testIsZero32(value, m_out.constInt32(0x7fffffff)));
2403                 result = m_out.neg(value);
2404             }
2405
2406             setInt32(result);
2407             break;
2408         }
2409             
2410         case Int52RepUse: {
2411             if (!abstractValue(m_node->child1()).couldBeType(SpecInt52Only)) {
2412                 Int52Kind kind;
2413                 LValue value = lowWhicheverInt52(m_node->child1(), kind);
2414                 LValue result = m_out.neg(value);
2415                 if (shouldCheckNegativeZero(m_node->arithMode()))
2416                     speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
2417                 setInt52(result, kind);
2418                 break;
2419             }
2420             
2421             LValue value = lowInt52(m_node->child1());
2422             CheckValue* result = m_out.speculateSub(m_out.int64Zero, value);
2423             blessSpeculation(result, Int52Overflow, noValue(), nullptr, m_origin);
2424             speculate(NegativeZero, noValue(), 0, m_out.isZero64(result));
2425             setInt52(result);
2426             break;
2427         }
2428             
2429         case DoubleRepUse: {
2430             setDouble(m_out.doubleNeg(lowDouble(m_node->child1())));
2431             break;
2432         }
2433             
2434         default:
2435             DFG_CRASH(m_graph, m_node, "Bad use kind");
2436             break;
2437         }
2438     }
2439     
2440     void compileBitAnd()
2441     {
2442         if (m_node->isBinaryUseKind(UntypedUse)) {
2443             emitBinaryBitOpSnippet<JITBitAndGenerator>(operationValueBitAnd);
2444             return;
2445         }
2446         setInt32(m_out.bitAnd(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2447     }
2448     
2449     void compileBitOr()
2450     {
2451         if (m_node->isBinaryUseKind(UntypedUse)) {
2452             emitBinaryBitOpSnippet<JITBitOrGenerator>(operationValueBitOr);
2453             return;
2454         }
2455         setInt32(m_out.bitOr(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2456     }
2457     
2458     void compileBitXor()
2459     {
2460         if (m_node->isBinaryUseKind(UntypedUse)) {
2461             emitBinaryBitOpSnippet<JITBitXorGenerator>(operationValueBitXor);
2462             return;
2463         }
2464         setInt32(m_out.bitXor(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2465     }
2466     
2467     void compileBitRShift()
2468     {
2469         if (m_node->isBinaryUseKind(UntypedUse)) {
2470             emitRightShiftSnippet(JITRightShiftGenerator::SignedShift);
2471             return;
2472         }
2473         setInt32(m_out.aShr(
2474             lowInt32(m_node->child1()),
2475             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2476     }
2477     
2478     void compileBitLShift()
2479     {
2480         if (m_node->isBinaryUseKind(UntypedUse)) {
2481             emitBinaryBitOpSnippet<JITLeftShiftGenerator>(operationValueBitLShift);
2482             return;
2483         }
2484         setInt32(m_out.shl(
2485             lowInt32(m_node->child1()),
2486             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2487     }
2488     
2489     void compileBitURShift()
2490     {
2491         if (m_node->isBinaryUseKind(UntypedUse)) {
2492             emitRightShiftSnippet(JITRightShiftGenerator::UnsignedShift);
2493             return;
2494         }
2495         setInt32(m_out.lShr(
2496             lowInt32(m_node->child1()),
2497             m_out.bitAnd(lowInt32(m_node->child2()), m_out.constInt32(31))));
2498     }
2499     
2500     void compileUInt32ToNumber()
2501     {
2502         LValue value = lowInt32(m_node->child1());
2503
2504         if (doesOverflow(m_node->arithMode())) {
2505             setStrictInt52(m_out.zeroExtPtr(value));
2506             return;
2507         }
2508
2509         speculate(Overflow, noValue(), 0, m_out.lessThan(value, m_out.int32Zero));
2510         setInt32(value);
2511     }
2512     
2513     void compileCheckStructure()
2514     {
2515         ExitKind exitKind;
2516         if (m_node->child1()->hasConstant())
2517             exitKind = BadConstantCache;
2518         else
2519             exitKind = BadCache;
2520
2521         switch (m_node->child1().useKind()) {
2522         case CellUse:
2523         case KnownCellUse: {
2524             LValue cell = lowCell(m_node->child1());
2525             
2526             checkStructure(
2527                 m_out.load32(cell, m_heaps.JSCell_structureID), jsValueValue(cell),
2528                 exitKind, m_node->structureSet(),
2529                 [&] (Structure* structure) {
2530                     return weakStructureID(structure);
2531                 });
2532             return;
2533         }
2534
2535         case CellOrOtherUse: {
2536             LValue value = lowJSValue(m_node->child1(), ManualOperandSpeculation);
2537
2538             LBasicBlock cellCase = m_out.newBlock();
2539             LBasicBlock notCellCase = m_out.newBlock();
2540             LBasicBlock continuation = m_out.newBlock();
2541
2542             m_out.branch(
2543                 isCell(value, provenType(m_node->child1())), unsure(cellCase), unsure(notCellCase));
2544
2545             LBasicBlock lastNext = m_out.appendTo(cellCase, notCellCase);
2546             checkStructure(
2547                 m_out.load32(value, m_heaps.JSCell_structureID), jsValueValue(value),
2548                 exitKind, m_node->structureSet(),
2549                 [&] (Structure* structure) {
2550                     return weakStructureID(structure);
2551                 });
2552             m_out.jump(continuation);
2553
2554             m_out.appendTo(notCellCase, continuation);
2555             FTL_TYPE_CHECK(jsValueValue(value), m_node->child1(), SpecCell | SpecOther, isNotOther(value));
2556             m_out.jump(continuation);
2557
2558             m_out.appendTo(continuation, lastNext);
2559             return;
2560         }
2561
2562         default:
2563             DFG_CRASH(m_graph, m_node, "Bad use kind");
2564             return;
2565         }
2566     }
2567     
2568     void compileCheckCell()
2569     {
2570         LValue cell = lowCell(m_node->child1());
2571         
2572         speculate(
2573             BadCell, jsValueValue(cell), m_node->child1().node(),
2574             m_out.notEqual(cell, weakPointer(m_node->cellOperand()->cell())));
2575     }
2576     
2577     void compileCheckBadCell()
2578     {
2579         terminate(BadCell);
2580     }
2581
2582     void compileCheckNotEmpty()
2583     {
2584         speculate(TDZFailure, noValue(), nullptr, m_out.isZero64(lowJSValue(m_node->child1())));
2585     }
2586
2587     void compileCheckStringIdent()
2588     {
2589         UniquedStringImpl* uid = m_node->uidOperand();
2590         LValue string = lowStringIdent(m_node->child1());
2591         LValue stringImpl = m_out.loadPtr(string, m_heaps.JSString_value);
2592         speculate(BadIdent, noValue(), nullptr, m_out.notEqual(stringImpl, m_out.constIntPtr(uid)));
2593     }
2594
2595     void compileGetExecutable()
2596     {
2597         LValue cell = lowCell(m_node->child1());
2598         speculateFunction(m_node->child1(), cell);
2599         setJSValue(m_out.loadPtr(cell, m_heaps.JSFunction_executable));
2600     }
2601     
2602     void compileArrayifyToStructure()
2603     {
2604         LValue cell = lowCell(m_node->child1());
2605         LValue property = !!m_node->child2() ? lowInt32(m_node->child2()) : 0;
2606         
2607         LBasicBlock unexpectedStructure = m_out.newBlock();
2608         LBasicBlock continuation = m_out.newBlock();
2609         
2610         LValue structureID = m_out.load32(cell, m_heaps.JSCell_structureID);
2611         
2612         m_out.branch(
2613             m_out.notEqual(structureID, weakStructureID(m_node->structure())),
2614             rarely(unexpectedStructure), usually(continuation));
2615         
2616         LBasicBlock lastNext = m_out.appendTo(unexpectedStructure, continuation);
2617         
2618         if (property) {
2619             switch (m_node->arrayMode().type()) {
2620             case Array::Int32:
2621             case Array::Double:
2622             case Array::Contiguous:
2623                 speculate(
2624                     Uncountable, noValue(), 0,
2625                     m_out.aboveOrEqual(property, m_out.constInt32(MIN_SPARSE_ARRAY_INDEX)));
2626                 break;
2627             default:
2628                 break;
2629             }
2630         }
2631         
2632         switch (m_node->arrayMode().type()) {
2633         case Array::Int32:
2634             vmCall(Void, m_out.operation(operationEnsureInt32), m_callFrame, cell);
2635             break;
2636         case Array::Double:
2637             vmCall(Void, m_out.operation(operationEnsureDouble), m_callFrame, cell);
2638             break;
2639         case Array::Contiguous:
2640             vmCall(Void, m_out.operation(operationEnsureContiguous), m_callFrame, cell);
2641             break;
2642         case Array::ArrayStorage:
2643         case Array::SlowPutArrayStorage:
2644             vmCall(Void, m_out.operation(operationEnsureArrayStorage), m_callFrame, cell);
2645             break;
2646         default:
2647             DFG_CRASH(m_graph, m_node, "Bad array type");
2648             break;
2649         }
2650         
2651         structureID = m_out.load32(cell, m_heaps.JSCell_structureID);
2652         speculate(
2653             BadIndexingType, jsValueValue(cell), 0,
2654             m_out.notEqual(structureID, weakStructureID(m_node->structure())));
2655         m_out.jump(continuation);
2656         
2657         m_out.appendTo(continuation, lastNext);
2658     }
2659     
2660     void compilePutStructure()
2661     {
2662         m_ftlState.jitCode->common.notifyCompilingStructureTransition(m_graph.m_plan, codeBlock(), m_node);
2663
2664         Structure* oldStructure = m_node->transition()->previous;
2665         Structure* newStructure = m_node->transition()->next;
2666         ASSERT_UNUSED(oldStructure, oldStructure->indexingType() == newStructure->indexingType());
2667         ASSERT(oldStructure->typeInfo().inlineTypeFlags() == newStructure->typeInfo().inlineTypeFlags());
2668         ASSERT(oldStructure->typeInfo().type() == newStructure->typeInfo().type());
2669
2670         LValue cell = lowCell(m_node->child1()); 
2671         m_out.store32(
2672             weakStructureID(newStructure),
2673             cell, m_heaps.JSCell_structureID);
2674     }
2675     
2676     void compileGetById(AccessType type)
2677     {
2678         ASSERT(type == AccessType::Get || type == AccessType::GetPure);
2679         switch (m_node->child1().useKind()) {
2680         case CellUse: {
2681             setJSValue(getById(lowCell(m_node->child1()), type));
2682             return;
2683         }
2684             
2685         case UntypedUse: {
2686             // This is pretty weird, since we duplicate the slow path both here and in the
2687             // code generated by the IC. We should investigate making this less bad.
2688             // https://bugs.webkit.org/show_bug.cgi?id=127830
2689             LValue value = lowJSValue(m_node->child1());
2690             
2691             LBasicBlock cellCase = m_out.newBlock();
2692             LBasicBlock notCellCase = m_out.newBlock();
2693             LBasicBlock continuation = m_out.newBlock();
2694             
2695             m_out.branch(
2696                 isCell(value, provenType(m_node->child1())), unsure(cellCase), unsure(notCellCase));
2697             
2698             LBasicBlock lastNext = m_out.appendTo(cellCase, notCellCase);
2699             ValueFromBlock cellResult = m_out.anchor(getById(value, type));
2700             m_out.jump(continuation);
2701
2702             J_JITOperation_EJI getByIdFunction;
2703             if (type == AccessType::Get)
2704                 getByIdFunction = operationGetByIdGeneric;
2705             else
2706                 getByIdFunction = operationTryGetByIdGeneric;
2707
2708             m_out.appendTo(notCellCase, continuation);
2709             ValueFromBlock notCellResult = m_out.anchor(vmCall(
2710                 Int64, m_out.operation(getByIdFunction),
2711                 m_callFrame, value,
2712                 m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()])));
2713             m_out.jump(continuation);
2714             
2715             m_out.appendTo(continuation, lastNext);
2716             setJSValue(m_out.phi(Int64, cellResult, notCellResult));
2717             return;
2718         }
2719             
2720         default:
2721             DFG_CRASH(m_graph, m_node, "Bad use kind");
2722             return;
2723         }
2724     }
2725
2726     void compileGetByIdWithThis()
2727     {
2728         LValue base = lowJSValue(m_node->child1());
2729         LValue thisValue = lowJSValue(m_node->child2());
2730         LValue result = vmCall(Int64, m_out.operation(operationGetByIdWithThis), m_callFrame, base, thisValue, m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()]));
2731         setJSValue(result);
2732     }
2733
2734     void compileGetByValWithThis()
2735     {
2736         LValue base = lowJSValue(m_node->child1());
2737         LValue thisValue = lowJSValue(m_node->child2());
2738         LValue subscript = lowJSValue(m_node->child3());
2739
2740         LValue result = vmCall(Int64, m_out.operation(operationGetByValWithThis), m_callFrame, base, thisValue, subscript);
2741         setJSValue(result);
2742     }
2743
2744     void compilePutByIdWithThis()
2745     {
2746         LValue base = lowJSValue(m_node->child1());
2747         LValue thisValue = lowJSValue(m_node->child2());
2748         LValue value = lowJSValue(m_node->child3());
2749
2750         vmCall(Void, m_out.operation(m_graph.isStrictModeFor(m_node->origin.semantic) ? operationPutByIdWithThisStrict : operationPutByIdWithThis),
2751             m_callFrame, base, thisValue, value, m_out.constIntPtr(m_graph.identifiers()[m_node->identifierNumber()]));
2752     }
2753
2754     void compilePutByValWithThis()
2755     {
2756         LValue base = lowJSValue(m_graph.varArgChild(m_node, 0));
2757         LValue thisValue = lowJSValue(m_graph.varArgChild(m_node, 1));
2758         LValue property = lowJSValue(m_graph.varArgChild(m_node, 2));
2759         LValue value = lowJSValue(m_graph.varArgChild(m_node, 3));
2760
2761         vmCall(Void, m_out.operation(m_graph.isStrictModeFor(m_node->origin.semantic) ? operationPutByValWithThisStrict : operationPutByValWithThis),
2762             m_callFrame, base, thisValue, property, value);
2763     }
2764     
2765     void compilePutById()
2766     {
2767         DFG_ASSERT(m_graph, m_node, m_node->child1().useKind() == CellUse);
2768
2769         Node* node = m_node;
2770         LValue base = lowCell(node->child1());
2771         LValue value = lowJSValue(node->child2());
2772         auto uid = m_graph.identifiers()[node->identifierNumber()];
2773
2774         B3::PatchpointValue* patchpoint = m_out.patchpoint(Void);
2775         patchpoint->appendSomeRegister(base);
2776         patchpoint->appendSomeRegister(value);
2777         patchpoint->append(m_tagMask, ValueRep::reg(GPRInfo::tagMaskRegister));
2778         patchpoint->append(m_tagTypeNumber, ValueRep::reg(GPRInfo::tagTypeNumberRegister));
2779         patchpoint->clobber(RegisterSet::macroScratchRegisters());
2780
2781         // FIXME: If this is a PutByIdFlush, we might want to late-clobber volatile registers.
2782         // https://bugs.webkit.org/show_bug.cgi?id=152848
2783
2784         RefPtr<PatchpointExceptionHandle> exceptionHandle =
2785             preparePatchpointForExceptions(patchpoint);
2786
2787         State* state = &m_ftlState;
2788         ECMAMode ecmaMode = m_graph.executableFor(node->origin.semantic)->ecmaMode();
2789         
2790         patchpoint->setGenerator(
2791             [=] (CCallHelpers& jit, const StackmapGenerationParams& params) {
2792                 AllowMacroScratchRegisterUsage allowScratch(jit);
2793
2794                 CallSiteIndex callSiteIndex =
2795                     state->jitCode->common.addUniqueCallSiteIndex(node->origin.semantic);
2796
2797                 Box<CCallHelpers::JumpList> exceptions =
2798                     exceptionHandle->scheduleExitCreation(params)->jumps(jit);
2799
2800                 // JS setter call ICs generated by the PutById IC will need this.
2801                 exceptionHandle->scheduleExitCreationForUnwind(params, callSiteIndex);
2802
2803                 auto generator = Box<JITPutByIdGenerator>::create(
2804                     jit.codeBlock(), node->origin.semantic, callSiteIndex,
2805                     params.unavailableRegisters(), JSValueRegs(params[0].gpr()),
2806                     JSValueRegs(params[1].gpr()), GPRInfo::patchpointScratchRegister, ecmaMode,
2807                     node->op() == PutByIdDirect ? Direct : NotDirect);
2808
2809                 generator->generateFastPath(jit);
2810                 CCallHelpers::Label done = jit.label();
2811
2812                 params.addLatePath(
2813                     [=] (CCallHelpers& jit) {
2814                         AllowMacroScratchRegisterUsage allowScratch(jit);
2815
2816                         generator->slowPathJump().link(&jit);
2817                         CCallHelpers::Label slowPathBegin = jit.label();
2818                         CCallHelpers::Call slowPathCall = callOperation(
2819                             *state, params.unavailableRegisters(), jit, node->origin.semantic,
2820                             exceptions.get(), generator->slowPathFunction(), InvalidGPRReg,
2821                             CCallHelpers::TrustedImmPtr(generator->stubInfo()), params[1].gpr(),
2822                             params[0].gpr(), CCallHelpers::TrustedImmPtr(uid)).call();
2823                         jit.jump().linkTo(done, &jit);
2824
2825                         generator->reportSlowPathCall(slowPathBegin, slowPathCall);
2826
2827                         jit.addLinkTask(
2828                             [=] (LinkBuffer& linkBuffer) {
2829                                 generator->finalize(linkBuffer);
2830                             });
2831                     });
2832             });
2833     }
2834     
2835     void compileGetButterfly()
2836     {
2837         setStorage(m_out.loadPtr(lowCell(m_node->child1()), m_heaps.JSObject_butterfly));
2838     }
2839
2840     void compileConstantStoragePointer()
2841     {
2842         setStorage(m_out.constIntPtr(m_node->storagePointer()));
2843     }
2844     
2845     void compileGetIndexedPropertyStorage()
2846     {
2847         LValue cell = lowCell(m_node->child1());
2848         
2849         if (m_node->arrayMode().type() == Array::String) {
2850             LBasicBlock slowPath = m_out.newBlock();
2851             LBasicBlock continuation = m_out.newBlock();
2852
2853             LValue fastResultValue = m_out.loadPtr(cell, m_heaps.JSString_value);
2854             ValueFromBlock fastResult = m_out.anchor(fastResultValue);
2855             
2856             m_out.branch(
2857                 m_out.notNull(fastResultValue), usually(continuation), rarely(slowPath));
2858             
2859             LBasicBlock lastNext = m_out.appendTo(slowPath, continuation);
2860             
2861             ValueFromBlock slowResult = m_out.anchor(
2862                 vmCall(pointerType(), m_out.operation(operationResolveRope), m_callFrame, cell));
2863             
2864             m_out.jump(continuation);
2865             
2866             m_out.appendTo(continuation, lastNext);
2867             
2868             setStorage(m_out.loadPtr(m_out.phi(pointerType(), fastResult, slowResult), m_heaps.StringImpl_data));
2869             return;
2870         }
2871
2872         DFG_ASSERT(m_graph, m_node, isTypedView(m_node->arrayMode().typedArrayType()));
2873         setStorage(m_out.loadPtr(cell, m_heaps.JSArrayBufferView_vector));
2874     }
2875     
2876     void compileCheckArray()
2877     {
2878         Edge edge = m_node->child1();
2879         LValue cell = lowCell(edge);
2880         
2881         if (m_node->arrayMode().alreadyChecked(m_graph, m_node, abstractValue(edge)))
2882             return;
2883         
2884         speculate(
2885             BadIndexingType, jsValueValue(cell), 0,
2886             m_out.logicalNot(isArrayType(cell, m_node->arrayMode())));
2887     }
2888
2889     void compileGetTypedArrayByteOffset()
2890     {
2891         LValue basePtr = lowCell(m_node->child1());    
2892
2893         LBasicBlock simpleCase = m_out.newBlock();
2894         LBasicBlock wastefulCase = m_out.newBlock();
2895         LBasicBlock continuation = m_out.newBlock();
2896         
2897         LValue mode = m_out.load32(basePtr, m_heaps.JSArrayBufferView_mode);
2898         m_out.branch(
2899             m_out.notEqual(mode, m_out.constInt32(WastefulTypedArray)),
2900             unsure(simpleCase), unsure(wastefulCase));
2901
2902         LBasicBlock lastNext = m_out.appendTo(simpleCase, wastefulCase);
2903
2904         ValueFromBlock simpleOut = m_out.anchor(m_out.constIntPtr(0));
2905
2906         m_out.jump(continuation);
2907
2908         m_out.appendTo(wastefulCase, continuation);
2909
2910         LValue vectorPtr = m_out.loadPtr(basePtr, m_heaps.JSArrayBufferView_vector);
2911         LValue butterflyPtr = m_out.loadPtr(basePtr, m_heaps.JSObject_butterfly);
2912         LValue arrayBufferPtr = m_out.loadPtr(butterflyPtr, m_heaps.Butterfly_arrayBuffer);
2913         LValue dataPtr = m_out.loadPtr(arrayBufferPtr, m_heaps.ArrayBuffer_data);
2914
2915         ValueFromBlock wastefulOut = m_out.anchor(m_out.sub(vectorPtr, dataPtr));
2916
2917         m_out.jump(continuation);
2918         m_out.appendTo(continuation, lastNext);
2919
2920         setInt32(m_out.castToInt32(m_out.phi(pointerType(), simpleOut, wastefulOut)));
2921     }
2922     
2923     void compileGetArrayLength()
2924     {
2925         switch (m_node->arrayMode().type()) {
2926         case Array::Undecided:
2927         case Array::Int32:
2928         case Array::Double:
2929         case Array::Contiguous: {
2930             setInt32(m_out.load32NonNegative(lowStorage(m_node->child2()), m_heaps.Butterfly_publicLength));
2931             return;
2932         }
2933             
2934         case Array::String: {
2935             LValue string = lowCell(m_node->child1());
2936             setInt32(m_out.load32NonNegative(string, m_heaps.JSString_length));
2937             return;
2938         }
2939             
2940         case Array::DirectArguments: {
2941             LValue arguments = lowCell(m_node->child1());
2942             speculate(
2943                 ExoticObjectMode, noValue(), nullptr,
2944                 m_out.notNull(m_out.loadPtr(arguments, m_heaps.DirectArguments_overrides)));
2945             setInt32(m_out.load32NonNegative(arguments, m_heaps.DirectArguments_length));
2946             return;
2947         }
2948             
2949         case Array::ScopedArguments: {
2950             LValue arguments = lowCell(m_node->child1());
2951             speculate(
2952                 ExoticObjectMode, noValue(), nullptr,
2953                 m_out.notZero32(m_out.load8ZeroExt32(arguments, m_heaps.ScopedArguments_overrodeThings)));
2954             setInt32(m_out.load32NonNegative(arguments, m_heaps.ScopedArguments_totalLength));
2955             return;
2956         }
2957             
2958         default:
2959             if (m_node->arrayMode().isSomeTypedArrayView()) {
2960                 setInt32(
2961                     m_out.load32NonNegative(lowCell(m_node->child1()), m_heaps.JSArrayBufferView_length));
2962                 return;
2963             }
2964             
2965             DFG_CRASH(m_graph, m_node, "Bad array type");
2966             return;
2967         }
2968     }
2969     
2970     void compileCheckInBounds()
2971     {
2972         speculate(
2973             OutOfBounds, noValue(), 0,
2974             m_out.aboveOrEqual(lowInt32(m_node->child1()), lowInt32(m_node->child2())));
2975     }
2976     
2977     void compileGetByVal()
2978     {
2979         switch (m_node->arrayMode().type()) {
2980         case Array::Int32:
2981         case Array::Contiguous: {
2982             LValue index = lowInt32(m_node->child2());
2983             LValue storage = lowStorage(m_node->child3());
2984             
2985             IndexedAbstractHeap& heap = m_node->arrayMode().type() == Array::Int32 ?
2986                 m_heaps.indexedInt32Properties : m_heaps.indexedContiguousProperties;
2987             
2988             if (m_node->arrayMode().isInBounds()) {
2989                 LValue result = m_out.load64(baseIndex(heap, storage, index, m_node->child2()));
2990                 LValue isHole = m_out.isZero64(result);
2991                 if (m_node->arrayMode().isSaneChain()) {
2992                     DFG_ASSERT(
2993                         m_graph, m_node, m_node->arrayMode().type() == Array::Contiguous);
2994                     result = m_out.select(
2995                         isHole, m_out.constInt64(JSValue::encode(jsUndefined())), result);
2996                 } else
2997                     speculate(LoadFromHole, noValue(), 0, isHole);
2998                 setJSValue(result);
2999                 return;
3000             }
3001             
3002             LValue base = lowCell(m_node->child1());
3003             
3004             LBasicBlock fastCase = m_out.newBlock();
3005             LBasicBlock slowCase = m_out.newBlock();
3006             LBasicBlock continuation = m_out.newBlock();
3007             
3008             m_out.branch(
3009                 m_out.aboveOrEqual(
3010                     index, m_out.load32NonNegative(storage, m_heaps.Butterfly_publicLength)),
3011                 rarely(slowCase), usually(fastCase));
3012             
3013             LBasicBlock lastNext = m_out.appendTo(fastCase, slowCase);
3014
3015             LValue fastResultValue = m_out.load64(baseIndex(heap, storage, index, m_node->child2()));
3016             ValueFromBlock fastResult = m_out.anchor(fastResultValue);
3017             m_out.branch(
3018                 m_out.isZero64(fastResultValue), rarely(slowCase), usually(continuation));
3019             
3020             m_out.appendTo(slowCase, continuation);
3021             ValueFromBlock slowResult = m_out.anchor(
3022                 vmCall(Int64, m_out.operation(operationGetByValArrayInt), m_callFrame, base, index));
3023             m_out.jump(continuation);
3024             
3025             m_out.appendTo(continuation, lastNext);
3026             setJSValue(m_out.phi(Int64, fastResult, slowResult));
3027             return;
3028         }
3029             
3030         case Array::Double: {
3031             LValue index = lowInt32(m_node->child2());
3032             LValue storage = lowStorage(m_node->child3());
3033             
3034             IndexedAbstractHeap& heap = m_heaps.indexedDoubleProperties;
3035             
3036             if (m_node->arrayMode().isInBounds()) {
3037                 LValue result = m_out.loadDouble(
3038                     baseIndex(heap, storage, index, m_node->child2()));
3039                 
3040                 if (!m_node->arrayMode().isSaneChain()) {
3041                     speculate(
3042                         LoadFromHole, noValue(), 0,
3043                         m_out.doubleNotEqualOrUnordered(result, result));
3044                 }
3045                 setDouble(result);
3046                 break;
3047             }
3048             
3049             LValue base = lowCell(m_node->child1());
3050             
3051             LBasicBlock inBounds = m_out.newBlock();
3052             LBasicBlock boxPath = m_out.newBlock();
3053             LBasicBlock slowCase = m_out.newBlock();
3054             LBasicBlock continuation = m_out.newBlock();
3055             
3056             m_out.branch(
3057                 m_out.aboveOrEqual(
3058                     index, m_out.load32NonNegative(storage, m_heaps.Butterfly_publicLength)),
3059                 rarely(slowCase), usually(inBounds));
3060             
3061             LBasicBlock lastNext = m_out.appendTo(inBounds, boxPath);
3062             LValue doubleValue = m_out.loadDouble(
3063                 baseIndex(heap, storage, index, m_node->child2()));
3064             m_out.branch(
3065                 m_out.doubleNotEqualOrUnordered(doubleValue, doubleValue),
3066                 rarely(slowCase), usually(boxPath));
3067             
3068             m_out.appendTo(boxPath, slowCase);
3069             ValueFromBlock fastResult = m_out.anchor(boxDouble(doubleValue));
3070             m_out.jump(continuation);
3071             
3072             m_out.appendTo(slowCase, continuation);
3073             ValueFromBlock slowResult = m_out.anchor(
3074                 vmCall(Int64, m_out.operation(operationGetByValArrayInt), m_callFrame, base, index));
3075             m_out.jump(continuation);
3076             
3077             m_out.appendTo(continuation, lastNext);
3078             setJSValue(m_out.phi(Int64, fastResult, slowResult));
3079             return;
3080         }
3081
3082         case Array::Undecided: {
3083             LValue index = lowInt32(m_node->child2());
3084
3085             speculate(OutOfBounds, noValue(), m_node, m_out.lessThan(index, m_out.int32Zero));
3086             setJSValue(m_out.constInt64(ValueUndefined));
3087             return;
3088         }
3089             
3090         case Array::DirectArguments: {
3091             LValue base = lowCell(m_node->child1());
3092             LValue index = lowInt32(m_node->child2());
3093             
3094             speculate(
3095                 ExoticObjectMode, noValue(), nullptr,
3096                 m_out.notNull(m_out.loadPtr(base, m_heaps.DirectArguments_overrides)));
3097             speculate(
3098                 ExoticObjectMode, noValue(), nullptr,
3099                 m_out.aboveOrEqual(
3100                     index,
3101                     m_out.load32NonNegative(base, m_heaps.DirectArguments_length)));
3102
3103             TypedPointer address = m_out.baseIndex(
3104                 m_heaps.DirectArguments_storage, base, m_out.zeroExtPtr(index));
3105             setJSValue(m_out.load64(address));
3106             return;
3107         }
3108             
3109         case Array::ScopedArguments: {
3110             LValue base = lowCell(m_node->child1());
3111             LValue index = lowInt32(m_node->child2());
3112             
3113             speculate(
3114                 ExoticObjectMode, noValue(), nullptr,
3115                 m_out.aboveOrEqual(
3116                     index,
3117                     m_out.load32NonNegative(base, m_heaps.ScopedArguments_totalLength)));
3118             
3119             LValue table = m_out.loadPtr(base, m_heaps.ScopedArguments_table);
3120             LValue namedLength = m_out.load32(table, m_heaps.ScopedArgumentsTable_length);
3121             
3122             LBasicBlock namedCase = m_out.newBlock();
3123             LBasicBlock overflowCase = m_out.newBlock();
3124             LBasicBlock continuation = m_out.newBlock();
3125             
3126             m_out.branch(
3127                 m_out.aboveOrEqual(index, namedLength), unsure(overflowCase), unsure(namedCase));
3128             
3129             LBasicBlock lastNext = m_out.appendTo(namedCase, overflowCase);
3130             
3131             LValue scope = m_out.loadPtr(base, m_heaps.ScopedArguments_scope);
3132             LValue arguments = m_out.loadPtr(table, m_heaps.ScopedArgumentsTable_arguments);
3133             
3134             TypedPointer address = m_out.baseIndex(
3135                 m_heaps.scopedArgumentsTableArguments, arguments, m_out.zeroExtPtr(index));
3136             LValue scopeOffset = m_out.load32(address);
3137             
3138             speculate(
3139                 ExoticObjectMode, noValue(), nullptr,
3140                 m_out.equal(scopeOffset, m_out.constInt32(ScopeOffset::invalidOffset)));
3141             
3142             address = m_out.baseIndex(
3143                 m_heaps.JSEnvironmentRecord_variables, scope, m_out.zeroExtPtr(scopeOffset));
3144             ValueFromBlock namedResult = m_out.anchor(m_out.load64(address));
3145             m_out.jump(continuation);
3146             
3147             m_out.appendTo(overflowCase, continuation);
3148             
3149             address = m_out.baseIndex(