e870eede4cb5086943a038d401d670f0dc53e13b
[WebKit-https.git] / Source / JavaScriptCore / jit / JIT.h
1 /*
2  * Copyright (C) 2008-2017 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
14  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
17  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
24  */
25
26 #pragma once
27
28 #if ENABLE(JIT)
29
30 // We've run into some problems where changing the size of the class JIT leads to
31 // performance fluctuations.  Try forcing alignment in an attempt to stabalize this.
32 #if COMPILER(GCC_OR_CLANG)
33 #define JIT_CLASS_ALIGNMENT __attribute__ ((aligned (32)))
34 #else
35 #define JIT_CLASS_ALIGNMENT
36 #endif
37
38 #define ASSERT_JIT_OFFSET(actual, expected) ASSERT_WITH_MESSAGE(actual == expected, "JIT Offset \"%s\" should be %d, not %d.\n", #expected, static_cast<int>(expected), static_cast<int>(actual));
39
40 #include "CodeBlock.h"
41 #include "CompactJITCodeMap.h"
42 #include "JITDisassembler.h"
43 #include "JITInlineCacheGenerator.h"
44 #include "JITMathIC.h"
45 #include "JSInterfaceJIT.h"
46 #include "PCToCodeOriginMap.h"
47 #include "UnusedPointer.h"
48
49 namespace JSC {
50
51     enum OpcodeID : unsigned;
52
53     class ArrayAllocationProfile;
54     class CallLinkInfo;
55     class CodeBlock;
56     class FunctionExecutable;
57     class JIT;
58     class Identifier;
59     class Interpreter;
60     class MarkedAllocator;
61     class Register;
62     class StructureChain;
63     class StructureStubInfo;
64
65     struct Instruction;
66     struct OperandTypes;
67     struct SimpleJumpTable;
68     struct StringJumpTable;
69
70     struct CallRecord {
71         MacroAssembler::Call from;
72         unsigned bytecodeOffset;
73         void* to;
74
75         CallRecord()
76         {
77         }
78
79         CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)
80             : from(from)
81             , bytecodeOffset(bytecodeOffset)
82             , to(to)
83         {
84         }
85     };
86
87     struct JumpTable {
88         MacroAssembler::Jump from;
89         unsigned toBytecodeOffset;
90
91         JumpTable(MacroAssembler::Jump f, unsigned t)
92             : from(f)
93             , toBytecodeOffset(t)
94         {
95         }
96     };
97
98     struct SlowCaseEntry {
99         MacroAssembler::Jump from;
100         unsigned to;
101         
102         SlowCaseEntry(MacroAssembler::Jump f, unsigned t)
103             : from(f)
104             , to(t)
105         {
106         }
107     };
108
109     struct SwitchRecord {
110         enum Type {
111             Immediate,
112             Character,
113             String
114         };
115
116         Type type;
117
118         union {
119             SimpleJumpTable* simpleJumpTable;
120             StringJumpTable* stringJumpTable;
121         } jumpTable;
122
123         unsigned bytecodeOffset;
124         unsigned defaultOffset;
125
126         SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset, Type type)
127             : type(type)
128             , bytecodeOffset(bytecodeOffset)
129             , defaultOffset(defaultOffset)
130         {
131             this->jumpTable.simpleJumpTable = jumpTable;
132         }
133
134         SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset)
135             : type(String)
136             , bytecodeOffset(bytecodeOffset)
137             , defaultOffset(defaultOffset)
138         {
139             this->jumpTable.stringJumpTable = jumpTable;
140         }
141     };
142
143     struct ByValCompilationInfo {
144         ByValCompilationInfo() { }
145         
146         ByValCompilationInfo(ByValInfo* byValInfo, unsigned bytecodeIndex, MacroAssembler::PatchableJump notIndexJump, MacroAssembler::PatchableJump badTypeJump, JITArrayMode arrayMode, ArrayProfile* arrayProfile, MacroAssembler::Label doneTarget, MacroAssembler::Label nextHotPathTarget)
147             : byValInfo(byValInfo)
148             , bytecodeIndex(bytecodeIndex)
149             , notIndexJump(notIndexJump)
150             , badTypeJump(badTypeJump)
151             , arrayMode(arrayMode)
152             , arrayProfile(arrayProfile)
153             , doneTarget(doneTarget)
154             , nextHotPathTarget(nextHotPathTarget)
155         {
156         }
157
158         ByValInfo* byValInfo;
159         unsigned bytecodeIndex;
160         MacroAssembler::PatchableJump notIndexJump;
161         MacroAssembler::PatchableJump badTypeJump;
162         JITArrayMode arrayMode;
163         ArrayProfile* arrayProfile;
164         MacroAssembler::Label doneTarget;
165         MacroAssembler::Label nextHotPathTarget;
166         MacroAssembler::Label slowPathTarget;
167         MacroAssembler::Call returnAddress;
168     };
169
170     struct CallCompilationInfo {
171         MacroAssembler::DataLabelPtr hotPathBegin;
172         MacroAssembler::Call hotPathOther;
173         MacroAssembler::Call callReturnLocation;
174         CallLinkInfo* callLinkInfo;
175     };
176
177     void ctiPatchCallByReturnAddress(ReturnAddressPtr, FunctionPtr newCalleeFunction);
178
179     class JIT : private JSInterfaceJIT {
180         friend class JITSlowPathCall;
181         friend class JITStubCall;
182
183         using MacroAssembler::Jump;
184         using MacroAssembler::JumpList;
185         using MacroAssembler::Label;
186
187         static const uintptr_t patchGetByIdDefaultStructure = unusedPointer;
188         static const int patchGetByIdDefaultOffset = 0;
189         // Magic number - initial offset cannot be representable as a signed 8bit value, or the X86Assembler
190         // will compress the displacement, and we may not be able to fit a patched offset.
191         static const int patchPutByIdDefaultOffset = 256;
192
193     public:
194         JIT(VM*, CodeBlock* = 0, unsigned loopOSREntryBytecodeOffset = 0);
195         ~JIT();
196
197         void compileWithoutLinking(JITCompilationEffort);
198         CompilationResult link();
199
200         void doMainThreadPreparationBeforeCompile();
201         
202         static CompilationResult compile(VM* vm, CodeBlock* codeBlock, JITCompilationEffort effort, unsigned bytecodeOffset = 0)
203         {
204             return JIT(vm, codeBlock, bytecodeOffset).privateCompile(effort);
205         }
206         
207         static void compileGetByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
208         {
209             JIT jit(vm, codeBlock);
210             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
211             jit.privateCompileGetByVal(byValInfo, returnAddress, arrayMode);
212         }
213
214         static void compileGetByValWithCachedId(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, const Identifier& propertyName)
215         {
216             JIT jit(vm, codeBlock);
217             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
218             jit.privateCompileGetByValWithCachedId(byValInfo, returnAddress, propertyName);
219         }
220
221         static void compilePutByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
222         {
223             JIT jit(vm, codeBlock);
224             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
225             jit.privateCompilePutByVal(byValInfo, returnAddress, arrayMode);
226         }
227         
228         static void compileDirectPutByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
229         {
230             JIT jit(vm, codeBlock);
231             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
232             jit.privateCompilePutByVal(byValInfo, returnAddress, arrayMode);
233         }
234
235         static void compilePutByValWithCachedId(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, PutKind putKind, const Identifier& propertyName)
236         {
237             JIT jit(vm, codeBlock);
238             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
239             jit.privateCompilePutByValWithCachedId(byValInfo, returnAddress, putKind, propertyName);
240         }
241
242         static void compileHasIndexedProperty(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
243         {
244             JIT jit(vm, codeBlock);
245             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
246             jit.privateCompileHasIndexedProperty(byValInfo, returnAddress, arrayMode);
247         }
248
249         static CodeRef compileCTINativeCall(VM*, NativeFunction);
250
251         static unsigned frameRegisterCountFor(CodeBlock*);
252         static int stackPointerOffsetFor(CodeBlock*);
253
254         JS_EXPORT_PRIVATE static HashMap<CString, double> compileTimeStats();
255
256     private:
257         void privateCompileMainPass();
258         void privateCompileLinkPass();
259         void privateCompileSlowCases();
260         CompilationResult privateCompile(JITCompilationEffort);
261         
262         void privateCompileGetByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
263         void privateCompileGetByValWithCachedId(ByValInfo*, ReturnAddressPtr, const Identifier&);
264         void privateCompilePutByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
265         void privateCompilePutByValWithCachedId(ByValInfo*, ReturnAddressPtr, PutKind, const Identifier&);
266
267         void privateCompileHasIndexedProperty(ByValInfo*, ReturnAddressPtr, JITArrayMode);
268
269         Label privateCompileCTINativeCall(VM*, bool isConstruct = false);
270         CodeRef privateCompileCTINativeCall(VM*, NativeFunction);
271         void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);
272
273         // Add a call out from JIT code, without an exception check.
274         Call appendCall(const FunctionPtr& function)
275         {
276             Call functionCall = call();
277             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
278             return functionCall;
279         }
280
281 #if OS(WINDOWS) && CPU(X86_64)
282         Call appendCallWithSlowPathReturnType(const FunctionPtr& function)
283         {
284             Call functionCall = callWithSlowPathReturnType();
285             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
286             return functionCall;
287         }
288 #endif
289
290         void exceptionCheck(Jump jumpToHandler)
291         {
292             m_exceptionChecks.append(jumpToHandler);
293         }
294
295         void exceptionCheck()
296         {
297             m_exceptionChecks.append(emitExceptionCheck(*vm()));
298         }
299
300         void exceptionCheckWithCallFrameRollback()
301         {
302             m_exceptionChecksWithCallFrameRollback.append(emitExceptionCheck(*vm()));
303         }
304
305         void privateCompileExceptionHandlers();
306
307         void addSlowCase(Jump);
308         void addSlowCase(const JumpList&);
309         void addSlowCase();
310         void addJump(Jump, int);
311         void emitJumpSlowToHot(Jump, int);
312
313         void compileOpCall(OpcodeID, Instruction*, unsigned callLinkInfoIndex);
314         void compileOpCallSlowCase(OpcodeID, Instruction*, Vector<SlowCaseEntry>::iterator&, unsigned callLinkInfoIndex);
315         void compileSetupVarargsFrame(OpcodeID, Instruction*, CallLinkInfo*);
316         void compileCallEval(Instruction*);
317         void compileCallEvalSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&);
318         void emitPutCallResult(Instruction*);
319
320         enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
321         void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type);
322         bool isOperandConstantDouble(int src);
323         
324         void emitLoadDouble(int index, FPRegisterID value);
325         void emitLoadInt32ToDouble(int index, FPRegisterID value);
326         Jump emitJumpIfCellObject(RegisterID cellReg);
327         Jump emitJumpIfCellNotObject(RegisterID cellReg);
328
329         enum WriteBarrierMode { UnconditionalWriteBarrier, ShouldFilterBase, ShouldFilterValue, ShouldFilterBaseAndValue };
330         // value register in write barrier is used before any scratch registers
331         // so may safely be the same as either of the scratch registers.
332         void emitWriteBarrier(unsigned owner, unsigned value, WriteBarrierMode);
333         void emitWriteBarrier(JSCell* owner, unsigned value, WriteBarrierMode);
334         void emitWriteBarrier(JSCell* owner);
335
336         // This assumes that the value to profile is in regT0 and that regT3 is available for
337         // scratch.
338         void emitValueProfilingSite(ValueProfile*);
339         void emitValueProfilingSite(unsigned bytecodeOffset);
340         void emitValueProfilingSite();
341         void emitArrayProfilingSiteWithCell(RegisterID cell, RegisterID indexingType, ArrayProfile*);
342         void emitArrayProfilingSiteForBytecodeIndexWithCell(RegisterID cell, RegisterID indexingType, unsigned bytecodeIndex);
343         void emitArrayProfileStoreToHoleSpecialCase(ArrayProfile*);
344         void emitArrayProfileOutOfBoundsSpecialCase(ArrayProfile*);
345         
346         JITArrayMode chooseArrayMode(ArrayProfile*);
347         
348         // Property is in regT1, base is in regT0. regT2 contains indexing type.
349         // Property is int-checked and zero extended. Base is cell checked.
350         // Structure is already profiled. Returns the slow cases. Fall-through
351         // case contains result in regT0, and it is not yet profiled.
352         JumpList emitInt32Load(Instruction* instruction, PatchableJump& badType) { return emitContiguousLoad(instruction, badType, Int32Shape); }
353         JumpList emitDoubleLoad(Instruction*, PatchableJump& badType);
354         JumpList emitContiguousLoad(Instruction*, PatchableJump& badType, IndexingType expectedShape = ContiguousShape);
355         JumpList emitArrayStorageLoad(Instruction*, PatchableJump& badType);
356         JumpList emitLoadForArrayMode(Instruction*, JITArrayMode, PatchableJump& badType);
357
358         JumpList emitInt32GetByVal(Instruction* instruction, PatchableJump& badType) { return emitContiguousGetByVal(instruction, badType, Int32Shape); }
359         JumpList emitDoubleGetByVal(Instruction*, PatchableJump& badType);
360         JumpList emitContiguousGetByVal(Instruction*, PatchableJump& badType, IndexingType expectedShape = ContiguousShape);
361         JumpList emitArrayStorageGetByVal(Instruction*, PatchableJump& badType);
362         JumpList emitDirectArgumentsGetByVal(Instruction*, PatchableJump& badType);
363         JumpList emitScopedArgumentsGetByVal(Instruction*, PatchableJump& badType);
364         JumpList emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
365         JumpList emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
366         
367         // Property is in regT1, base is in regT0. regT2 contains indecing type.
368         // The value to store is not yet loaded. Property is int-checked and
369         // zero-extended. Base is cell checked. Structure is already profiled.
370         // returns the slow cases.
371         JumpList emitInt32PutByVal(Instruction* currentInstruction, PatchableJump& badType)
372         {
373             return emitGenericContiguousPutByVal(currentInstruction, badType, Int32Shape);
374         }
375         JumpList emitDoublePutByVal(Instruction* currentInstruction, PatchableJump& badType)
376         {
377             return emitGenericContiguousPutByVal(currentInstruction, badType, DoubleShape);
378         }
379         JumpList emitContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType)
380         {
381             return emitGenericContiguousPutByVal(currentInstruction, badType);
382         }
383         JumpList emitGenericContiguousPutByVal(Instruction*, PatchableJump& badType, IndexingType indexingShape = ContiguousShape);
384         JumpList emitArrayStoragePutByVal(Instruction*, PatchableJump& badType);
385         JumpList emitIntTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
386         JumpList emitFloatTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
387
388         // Identifier check helper for GetByVal and PutByVal.
389         void emitByValIdentifierCheck(ByValInfo*, RegisterID cell, RegisterID scratch, const Identifier&, JumpList& slowCases);
390
391         JITGetByIdGenerator emitGetByValWithCachedId(ByValInfo*, Instruction*, const Identifier&, Jump& fastDoneCase, Jump& slowDoneCase, JumpList& slowCases);
392         JITPutByIdGenerator emitPutByValWithCachedId(ByValInfo*, Instruction*, PutKind, const Identifier&, JumpList& doneCases, JumpList& slowCases);
393
394         enum FinalObjectMode { MayBeFinal, KnownNotFinal };
395
396         void emitGetVirtualRegister(int src, JSValueRegs dst);
397         void emitPutVirtualRegister(int dst, JSValueRegs src);
398
399         int32_t getOperandConstantInt(int src);
400         double getOperandConstantDouble(int src);
401
402 #if USE(JSVALUE32_64)
403         bool getOperandConstantInt(int op1, int op2, int& op, int32_t& constant);
404
405         void emitLoadTag(int index, RegisterID tag);
406         void emitLoadPayload(int index, RegisterID payload);
407
408         void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload);
409         void emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
410         void emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2);
411
412         void emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
413         void emitStore(int index, const JSValue constant, RegisterID base = callFrameRegister);
414         void emitStoreInt32(int index, RegisterID payload, bool indexIsInt32 = false);
415         void emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32 = false);
416         void emitStoreCell(int index, RegisterID payload, bool indexIsCell = false);
417         void emitStoreBool(int index, RegisterID payload, bool indexIsBool = false);
418         void emitStoreDouble(int index, FPRegisterID value);
419
420         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex);
421         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag);
422
423         void compileGetByIdHotPath(const Identifier*);
424
425         // Arithmetic opcode helpers
426         void emitBinaryDoubleOp(OpcodeID, int dst, int op1, int op2, OperandTypes, JumpList& notInt32Op1, JumpList& notInt32Op2, bool op1IsInRegisters = true, bool op2IsInRegisters = true);
427
428 #else // USE(JSVALUE32_64)
429         void emitGetVirtualRegister(int src, RegisterID dst);
430         void emitGetVirtualRegister(VirtualRegister src, RegisterID dst);
431         void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2);
432         void emitGetVirtualRegisters(VirtualRegister src1, RegisterID dst1, VirtualRegister src2, RegisterID dst2);
433         void emitPutVirtualRegister(int dst, RegisterID from = regT0);
434         void emitPutVirtualRegister(VirtualRegister dst, RegisterID from = regT0);
435         void emitStoreCell(int dst, RegisterID payload, bool /* only used in JSValue32_64 */ = false)
436         {
437             emitPutVirtualRegister(dst, payload);
438         }
439         void emitStoreCell(VirtualRegister dst, RegisterID payload)
440         {
441             emitPutVirtualRegister(dst, payload);
442         }
443
444         Jump emitJumpIfJSCell(RegisterID);
445         Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
446         void emitJumpSlowCaseIfJSCell(RegisterID);
447         void emitJumpSlowCaseIfNotJSCell(RegisterID);
448         void emitJumpSlowCaseIfNotJSCell(RegisterID, int VReg);
449         Jump emitJumpIfInt(RegisterID);
450         Jump emitJumpIfNotInt(RegisterID);
451         Jump emitJumpIfNotInt(RegisterID, RegisterID, RegisterID scratch);
452         PatchableJump emitPatchableJumpIfNotInt(RegisterID);
453         void emitJumpSlowCaseIfNotInt(RegisterID);
454         void emitJumpSlowCaseIfNotNumber(RegisterID);
455         void emitJumpSlowCaseIfNotInt(RegisterID, RegisterID, RegisterID scratch);
456
457         void emitTagBool(RegisterID);
458
459         void compileGetByIdHotPath(int baseVReg, const Identifier*);
460
461 #endif // USE(JSVALUE32_64)
462
463         void emit_compareAndJump(OpcodeID, int op1, int op2, unsigned target, RelationalCondition);
464         void emit_compareAndJumpSlow(int op1, int op2, unsigned target, DoubleCondition, size_t (JIT_OPERATION *operation)(ExecState*, EncodedJSValue, EncodedJSValue), bool invert, Vector<SlowCaseEntry>::iterator&);
465         
466         void assertStackPointerOffset();
467
468         void emit_op_add(Instruction*);
469         void emit_op_bitand(Instruction*);
470         void emit_op_bitor(Instruction*);
471         void emit_op_bitxor(Instruction*);
472         void emit_op_call(Instruction*);
473         void emit_op_tail_call(Instruction*);
474         void emit_op_call_eval(Instruction*);
475         void emit_op_call_varargs(Instruction*);
476         void emit_op_tail_call_varargs(Instruction*);
477         void emit_op_tail_call_forward_arguments(Instruction*);
478         void emit_op_construct_varargs(Instruction*);
479         void emit_op_catch(Instruction*);
480         void emit_op_construct(Instruction*);
481         void emit_op_create_this(Instruction*);
482         void emit_op_to_this(Instruction*);
483         void emit_op_create_direct_arguments(Instruction*);
484         void emit_op_create_scoped_arguments(Instruction*);
485         void emit_op_create_cloned_arguments(Instruction*);
486         void emit_op_get_argument(Instruction*);
487         void emit_op_argument_count(Instruction*);
488         void emit_op_create_rest(Instruction*);
489         void emit_op_get_rest_length(Instruction*);
490         void emit_op_check_tdz(Instruction*);
491         void emit_op_assert(Instruction*);
492         void emit_op_unreachable(Instruction*);
493         void emit_op_debug(Instruction*);
494         void emit_op_del_by_id(Instruction*);
495         void emit_op_del_by_val(Instruction*);
496         void emit_op_div(Instruction*);
497         void emit_op_end(Instruction*);
498         void emit_op_enter(Instruction*);
499         void emit_op_get_scope(Instruction*);
500         void emit_op_eq(Instruction*);
501         void emit_op_eq_null(Instruction*);
502         void emit_op_try_get_by_id(Instruction*);
503         void emit_op_get_by_id(Instruction*);
504         void emit_op_get_by_id_with_this(Instruction*);
505         void emit_op_get_by_val_with_this(Instruction*);
506         void emit_op_get_arguments_length(Instruction*);
507         void emit_op_get_by_val(Instruction*);
508         void emit_op_get_argument_by_val(Instruction*);
509         void emit_op_init_lazy_reg(Instruction*);
510         void emit_op_overrides_has_instance(Instruction*);
511         void emit_op_instanceof(Instruction*);
512         void emit_op_instanceof_custom(Instruction*);
513         void emit_op_is_empty(Instruction*);
514         void emit_op_is_undefined(Instruction*);
515         void emit_op_is_boolean(Instruction*);
516         void emit_op_is_number(Instruction*);
517         void emit_op_is_object(Instruction*);
518         void emit_op_is_cell_with_type(Instruction*);
519         void emit_op_jeq_null(Instruction*);
520         void emit_op_jfalse(Instruction*);
521         void emit_op_jmp(Instruction*);
522         void emit_op_jneq_null(Instruction*);
523         void emit_op_jneq_ptr(Instruction*);
524         void emit_op_jless(Instruction*);
525         void emit_op_jlesseq(Instruction*);
526         void emit_op_jgreater(Instruction*);
527         void emit_op_jgreatereq(Instruction*);
528         void emit_op_jnless(Instruction*);
529         void emit_op_jnlesseq(Instruction*);
530         void emit_op_jngreater(Instruction*);
531         void emit_op_jngreatereq(Instruction*);
532         void emit_op_jtrue(Instruction*);
533         void emit_op_loop_hint(Instruction*);
534         void emit_op_check_traps(Instruction*);
535         void emit_op_nop(Instruction*);
536         void emit_op_lshift(Instruction*);
537         void emit_op_mod(Instruction*);
538         void emit_op_mov(Instruction*);
539         void emit_op_mul(Instruction*);
540         void emit_op_negate(Instruction*);
541         void emit_op_neq(Instruction*);
542         void emit_op_neq_null(Instruction*);
543         void emit_op_new_array(Instruction*);
544         void emit_op_new_array_with_size(Instruction*);
545         void emit_op_new_array_buffer(Instruction*);
546         void emit_op_new_array_with_spread(Instruction*);
547         void emit_op_spread(Instruction*);
548         void emit_op_new_func(Instruction*);
549         void emit_op_new_func_exp(Instruction*);
550         void emit_op_new_generator_func(Instruction*);
551         void emit_op_new_generator_func_exp(Instruction*);
552         void emit_op_new_async_func(Instruction*);
553         void emit_op_new_async_func_exp(Instruction*);
554         void emit_op_new_object(Instruction*);
555         void emit_op_new_regexp(Instruction*);
556         void emit_op_not(Instruction*);
557         void emit_op_nstricteq(Instruction*);
558         void emit_op_dec(Instruction*);
559         void emit_op_inc(Instruction*);
560         void emit_op_pow(Instruction*);
561         void emit_op_profile_type(Instruction*);
562         void emit_op_profile_control_flow(Instruction*);
563         void emit_op_push_with_scope(Instruction*);
564         void emit_op_create_lexical_environment(Instruction*);
565         void emit_op_get_parent_scope(Instruction*);
566         void emit_op_put_by_id(Instruction*);
567         void emit_op_put_by_id_with_this(Instruction*);
568         void emit_op_put_by_index(Instruction*);
569         void emit_op_put_by_val(Instruction*);
570         void emit_op_put_by_val_with_this(Instruction*);
571         void emit_op_put_getter_by_id(Instruction*);
572         void emit_op_put_setter_by_id(Instruction*);
573         void emit_op_put_getter_setter_by_id(Instruction*);
574         void emit_op_put_getter_by_val(Instruction*);
575         void emit_op_put_setter_by_val(Instruction*);
576         void emit_op_define_data_property(Instruction*);
577         void emit_op_define_accessor_property(Instruction*);
578         void emit_op_ret(Instruction*);
579         void emit_op_rshift(Instruction*);
580         void emit_op_set_function_name(Instruction*);
581         void emit_op_strcat(Instruction*);
582         void emit_op_stricteq(Instruction*);
583         void emit_op_sub(Instruction*);
584         void emit_op_switch_char(Instruction*);
585         void emit_op_switch_imm(Instruction*);
586         void emit_op_switch_string(Instruction*);
587         void emit_op_tear_off_arguments(Instruction*);
588         void emit_op_throw(Instruction*);
589         void emit_op_throw_static_error(Instruction*);
590         void emit_op_to_number(Instruction*);
591         void emit_op_to_string(Instruction*);
592         void emit_op_to_primitive(Instruction*);
593         void emit_op_unexpected_load(Instruction*);
594         void emit_op_unsigned(Instruction*);
595         void emit_op_urshift(Instruction*);
596         void emit_op_get_enumerable_length(Instruction*);
597         void emit_op_has_generic_property(Instruction*);
598         void emit_op_has_structure_property(Instruction*);
599         void emit_op_has_indexed_property(Instruction*);
600         void emit_op_get_direct_pname(Instruction*);
601         void emit_op_get_property_enumerator(Instruction*);
602         void emit_op_enumerator_structure_pname(Instruction*);
603         void emit_op_enumerator_generic_pname(Instruction*);
604         void emit_op_to_index_string(Instruction*);
605         void emit_op_log_shadow_chicken_prologue(Instruction*);
606         void emit_op_log_shadow_chicken_tail(Instruction*);
607
608         void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
609         void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
610         void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
611         void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
612         void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
613         void emitSlow_op_tail_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
614         void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
615         void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
616         void emitSlow_op_tail_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
617         void emitSlow_op_tail_call_forward_arguments(Instruction*, Vector<SlowCaseEntry>::iterator&);
618         void emitSlow_op_construct_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
619         void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
620         void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
621         void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
622         void emitSlow_op_check_tdz(Instruction*, Vector<SlowCaseEntry>::iterator&);
623         void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
624         void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
625         void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
626         void emitSlow_op_try_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
627         void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
628         void emitSlow_op_get_by_id_with_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
629         void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
630         void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
631         void emitSlow_op_get_argument_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
632         void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
633         void emitSlow_op_instanceof_custom(Instruction*, Vector<SlowCaseEntry>::iterator&);
634         void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
635         void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
636         void emitSlow_op_jgreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
637         void emitSlow_op_jgreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
638         void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
639         void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
640         void emitSlow_op_jngreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
641         void emitSlow_op_jngreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
642         void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
643         void emitSlow_op_loop_hint(Instruction*, Vector<SlowCaseEntry>::iterator&);
644         void emitSlow_op_check_traps(Instruction*, Vector<SlowCaseEntry>::iterator&);
645         void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
646         void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
647         void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
648         void emitSlow_op_negate(Instruction*, Vector<SlowCaseEntry>::iterator&);
649         void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
650         void emitSlow_op_new_object(Instruction*, Vector<SlowCaseEntry>::iterator&);
651         void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
652         void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
653         void emitSlow_op_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
654         void emitSlow_op_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
655         void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
656         void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
657         void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
658         void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
659         void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
660         void emitSlow_op_to_number(Instruction*, Vector<SlowCaseEntry>::iterator&);
661         void emitSlow_op_to_string(Instruction*, Vector<SlowCaseEntry>::iterator&);
662         void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
663         void emitSlow_op_unsigned(Instruction*, Vector<SlowCaseEntry>::iterator&);
664         void emitSlow_op_urshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
665         void emitSlow_op_has_indexed_property(Instruction*, Vector<SlowCaseEntry>::iterator&);
666         void emitSlow_op_has_structure_property(Instruction*, Vector<SlowCaseEntry>::iterator&);
667         void emitSlow_op_get_direct_pname(Instruction*, Vector<SlowCaseEntry>::iterator&);
668
669         void emit_op_resolve_scope(Instruction*);
670         void emit_op_resolve_scope_for_hoisting_func_decl_in_eval(Instruction*);
671         void emit_op_get_from_scope(Instruction*);
672         void emit_op_put_to_scope(Instruction*);
673         void emit_op_get_from_arguments(Instruction*);
674         void emit_op_put_to_arguments(Instruction*);
675         void emitSlow_op_resolve_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
676         void emitSlow_op_get_from_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
677         void emitSlow_op_put_to_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
678
679         void emitRightShift(Instruction*, bool isUnsigned);
680         void emitRightShiftSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&, bool isUnsigned);
681
682         void emitNewFuncCommon(Instruction*);
683         void emitNewFuncExprCommon(Instruction*);
684         void emitVarInjectionCheck(bool needsVarInjectionChecks);
685         void emitResolveClosure(int dst, int scope, bool needsVarInjectionChecks, unsigned depth);
686         void emitLoadWithStructureCheck(int scope, Structure** structureSlot);
687 #if USE(JSVALUE64)
688         void emitGetVarFromPointer(JSValue* operand, GPRReg);
689         void emitGetVarFromIndirectPointer(JSValue** operand, GPRReg);
690 #else
691         void emitGetVarFromIndirectPointer(JSValue** operand, GPRReg tag, GPRReg payload);
692         void emitGetVarFromPointer(JSValue* operand, GPRReg tag, GPRReg payload);
693 #endif
694         void emitGetClosureVar(int scope, uintptr_t operand);
695         void emitNotifyWrite(WatchpointSet*);
696         void emitNotifyWrite(GPRReg pointerToSet);
697         void emitPutGlobalVariable(JSValue* operand, int value, WatchpointSet*);
698         void emitPutGlobalVariableIndirect(JSValue** addressOfOperand, int value, WatchpointSet**);
699         void emitPutClosureVar(int scope, uintptr_t operand, int value, WatchpointSet*);
700
701         void emitInitRegister(int dst);
702
703         void emitPutIntToCallFrameHeader(RegisterID from, int entry);
704
705         JSValue getConstantOperand(int src);
706         bool isOperandConstantInt(int src);
707         bool isOperandConstantChar(int src);
708
709         template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
710         void emitMathICFast(JITUnaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
711         template <typename Generator, typename ProfiledFunction, typename NonProfiledFunction>
712         void emitMathICFast(JITBinaryMathIC<Generator>*, Instruction*, ProfiledFunction, NonProfiledFunction);
713
714         template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
715         void emitMathICSlow(JITBinaryMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
716         template <typename Generator, typename ProfiledRepatchFunction, typename ProfiledFunction, typename RepatchFunction>
717         void emitMathICSlow(JITUnaryMathIC<Generator>*, Instruction*, ProfiledRepatchFunction, ProfiledFunction, RepatchFunction);
718
719         Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
720         {
721             return iter++->from;
722         }
723         void linkSlowCase(Vector<SlowCaseEntry>::iterator& iter)
724         {
725             if (iter->from.isSet())
726                 iter->from.link(this);
727             ++iter;
728         }
729         void linkDummySlowCase(Vector<SlowCaseEntry>::iterator& iter)
730         {
731             ASSERT(!iter->from.isSet());
732             ++iter;
733         }
734         void linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&, int virtualRegisterIndex);
735         void linkAllSlowCasesForBytecodeOffset(Vector<SlowCaseEntry>& slowCases,
736             Vector<SlowCaseEntry>::iterator&, unsigned bytecodeOffset);
737
738         MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr&);
739 #if OS(WINDOWS) && CPU(X86_64)
740         MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr&);
741 #endif
742         MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr&);
743         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr&, int);
744         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr&, int);
745         
746         enum WithProfileTag { WithProfile };
747         
748         MacroAssembler::Call callOperation(C_JITOperation_E);
749         MacroAssembler::Call callOperation(C_JITOperation_EO, GPRReg);
750         MacroAssembler::Call callOperation(C_JITOperation_EL, GPRReg);
751         MacroAssembler::Call callOperation(C_JITOperation_EL, TrustedImmPtr);
752         MacroAssembler::Call callOperation(C_JITOperation_ESt, Structure*);
753         MacroAssembler::Call callOperation(C_JITOperation_EZ, int32_t);
754         MacroAssembler::Call callOperation(Z_JITOperation_EJZZ, GPRReg, int32_t, int32_t);
755         MacroAssembler::Call callOperation(J_JITOperation_E, int);
756         MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg);
757         MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, GPRReg, int32_t);
758         MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, const JSValue*, int32_t);
759         MacroAssembler::Call callOperation(J_JITOperation_EC, int, JSCell*);
760         MacroAssembler::Call callOperation(V_JITOperation_EC, JSCell*);
761         MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg);
762         MacroAssembler::Call callOperation(J_JITOperation_EJ, JSValueRegs, JSValueRegs);
763 #if USE(JSVALUE64)
764         MacroAssembler::Call callOperation(J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
765         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
766         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJJI, int, StructureStubInfo*, GPRReg, GPRReg, UniquedStringImpl*);
767 #else
768         MacroAssembler::Call callOperation(J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, GPRReg, UniquedStringImpl*);
769         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, GPRReg, UniquedStringImpl*);
770         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJJI, int, StructureStubInfo*, GPRReg, GPRReg, GPRReg, GPRReg, UniquedStringImpl*);
771 #endif
772         MacroAssembler::Call callOperation(J_JITOperation_EJI, int, GPRReg, UniquedStringImpl*);
773         MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
774         MacroAssembler::Call callOperation(J_JITOperation_EJArp, JSValueRegs, JSValueRegs, ArithProfile*);
775         MacroAssembler::Call callOperation(J_JITOperation_EJJArp, JSValueRegs, JSValueRegs, JSValueRegs, ArithProfile*);
776         MacroAssembler::Call callOperation(J_JITOperation_EJJ, JSValueRegs, JSValueRegs, JSValueRegs);
777         MacroAssembler::Call callOperation(J_JITOperation_EJMic, JSValueRegs, JSValueRegs, TrustedImmPtr);
778         MacroAssembler::Call callOperation(J_JITOperation_EJJMic, JSValueRegs, JSValueRegs, JSValueRegs, TrustedImmPtr);
779         MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, ArrayProfile*);
780         MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, ByValInfo*);
781         MacroAssembler::Call callOperation(Z_JITOperation_EJOJ, GPRReg, GPRReg, GPRReg);
782         MacroAssembler::Call callOperation(C_JITOperation_EJsc, GPRReg);
783         MacroAssembler::Call callOperation(J_JITOperation_EJscC, int, GPRReg, JSCell*);
784         MacroAssembler::Call callOperation(J_JITOperation_EJscCJ, int, GPRReg, JSCell*, GPRReg);
785         MacroAssembler::Call callOperation(C_JITOperation_EJscZ, GPRReg, int32_t);
786         MacroAssembler::Call callOperation(C_JITOperation_EJscZ, int, GPRReg, int32_t);
787 #if USE(JSVALUE64)
788         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg);
789 #else
790         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
791 #endif
792         MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
793         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EPc, int, Instruction*);
794         MacroAssembler::Call callOperation(J_JITOperation_EPc, int, Instruction*);
795         MacroAssembler::Call callOperation(J_JITOperation_EZ, int, int32_t);
796         MacroAssembler::Call callOperation(J_JITOperation_EZZ, int, int32_t, int32_t);
797         MacroAssembler::Call callOperation(P_JITOperation_E);
798         MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, size_t);
799         MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
800         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID);
801         MacroAssembler::Call callOperation(S_JITOperation_EJI, GPRReg, UniquedStringImpl*);
802         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID);
803         MacroAssembler::Call callOperation(S_JITOperation_EOJss, RegisterID, RegisterID);
804         MacroAssembler::Call callOperation(Sprt_JITOperation_EZ, int32_t);
805         MacroAssembler::Call callOperation(V_JITOperation_E);
806         MacroAssembler::Call callOperation(V_JITOperation_EC, RegisterID);
807         MacroAssembler::Call callOperation(V_JITOperation_ECC, RegisterID, RegisterID);
808         MacroAssembler::Call callOperation(V_JITOperation_ECIZC, RegisterID, UniquedStringImpl*, int32_t, RegisterID);
809         MacroAssembler::Call callOperation(V_JITOperation_ECIZCC, RegisterID, UniquedStringImpl*, int32_t, RegisterID, RegisterID);
810 #if USE(JSVALUE64)
811         MacroAssembler::Call callOperation(V_JITOperation_ECJZC, RegisterID, RegisterID, int32_t, RegisterID);
812 #else
813         MacroAssembler::Call callOperation(V_JITOperation_ECJZC, RegisterID, RegisterID, RegisterID, int32_t, RegisterID);
814 #endif
815         MacroAssembler::Call callOperation(J_JITOperation_EE, RegisterID);
816         MacroAssembler::Call callOperation(V_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID);
817         MacroAssembler::Call callOperation(J_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID);
818         MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID);
819         MacroAssembler::Call callOperationNoExceptionCheck(Z_JITOperation_E);
820 #if USE(JSVALUE64)
821         MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID);
822 #else
823         MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID, RegisterID);
824 #endif
825 #if USE(JSVALUE64)
826         MacroAssembler::Call callOperation(F_JITOperation_EFJZZ, RegisterID, RegisterID, int32_t, RegisterID);
827         MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, UniquedStringImpl*);
828         MacroAssembler::Call callOperation(V_JITOperation_ECIZJJ, RegisterID, UniquedStringImpl*, int32_t, RegisterID, RegisterID);
829         MacroAssembler::Call callOperation(V_JITOperation_ECJ, RegisterID, RegisterID);
830 #else
831         MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, RegisterID, RegisterID, UniquedStringImpl*);
832         MacroAssembler::Call callOperation(V_JITOperation_ECJ, RegisterID, RegisterID, RegisterID);
833 #endif
834         MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID);
835         MacroAssembler::Call callOperation(V_JITOperation_EJJJAp, RegisterID, RegisterID, RegisterID, ArrayProfile*);
836         MacroAssembler::Call callOperation(V_JITOperation_EJJJBy, RegisterID, RegisterID, RegisterID, ByValInfo*);
837         MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, int32_t, RegisterID);
838         MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, int32_t);
839         MacroAssembler::Call callOperation(V_JITOperation_EPc, Instruction*);
840         MacroAssembler::Call callOperation(V_JITOperation_EZ, int32_t);
841         MacroAssembler::Call callOperation(V_JITOperation_EZJ, int, GPRReg);
842         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(J_JITOperation_E);
843         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb, CodeBlock*);
844         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(Z_JITOperation_E);
845 #if USE(JSVALUE32_64)
846         MacroAssembler::Call callOperation(F_JITOperation_EFJZZ, RegisterID, RegisterID, RegisterID, int32_t, RegisterID);
847         MacroAssembler::Call callOperation(Z_JITOperation_EJZZ, GPRReg, GPRReg, int32_t, int32_t);
848         MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg, GPRReg);
849         MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg, GPRReg);
850         MacroAssembler::Call callOperation(J_JITOperation_EJI, int, GPRReg, GPRReg, UniquedStringImpl*);
851         MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
852         MacroAssembler::Call callOperation(Z_JITOperation_EJOJ, GPRReg, GPRReg, GPRReg, GPRReg, GPRReg);
853         MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, GPRReg, GPRReg, ArrayProfile*);
854         MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, GPRReg, GPRReg, ByValInfo*);
855         MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, GPRReg, size_t);
856         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID, RegisterID);
857         MacroAssembler::Call callOperation(S_JITOperation_EJI, GPRReg, GPRReg, UniquedStringImpl*);
858         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID, RegisterID, RegisterID);
859         MacroAssembler::Call callOperation(V_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID, RegisterID);
860         MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID, RegisterID);
861         MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID);
862         MacroAssembler::Call callOperation(V_JITOperation_EJJJAp, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, ArrayProfile*);
863         MacroAssembler::Call callOperation(V_JITOperation_EJJJBy, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, ByValInfo*);
864         MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, RegisterID, int32_t);
865         MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, RegisterID, int32_t, RegisterID, RegisterID);
866         MacroAssembler::Call callOperation(V_JITOperation_EZJ, int32_t, RegisterID, RegisterID);
867         MacroAssembler::Call callOperation(J_JITOperation_EJscCJ, int, GPRReg, JSCell*, GPRReg, GPRReg);
868 #endif
869
870         template<typename SnippetGenerator>
871         void emitBitBinaryOpFastPath(Instruction* currentInstruction);
872
873         void emitRightShiftFastPath(Instruction* currentInstruction, OpcodeID);
874
875         Jump checkStructure(RegisterID reg, Structure* structure);
876
877         void updateTopCallFrame();
878
879         Call emitNakedCall(CodePtr function = CodePtr());
880         Call emitNakedTailCall(CodePtr function = CodePtr());
881
882         // Loads the character value of a single character string into dst.
883         void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
884         
885 #if ENABLE(DFG_JIT)
886         void emitEnterOptimizationCheck();
887 #else
888         void emitEnterOptimizationCheck() { }
889 #endif
890
891 #ifndef NDEBUG
892         void printBytecodeOperandTypes(int src1, int src2);
893 #endif
894
895 #if ENABLE(SAMPLING_FLAGS)
896         void setSamplingFlag(int32_t);
897         void clearSamplingFlag(int32_t);
898 #endif
899
900 #if ENABLE(SAMPLING_COUNTERS)
901         void emitCount(AbstractSamplingCounter&, int32_t = 1);
902 #endif
903
904 #if ENABLE(OPCODE_SAMPLING)
905         void sampleInstruction(Instruction*, bool = false);
906 #endif
907
908 #if ENABLE(CODEBLOCK_SAMPLING)
909         void sampleCodeBlock(CodeBlock*);
910 #else
911         void sampleCodeBlock(CodeBlock*) {}
912 #endif
913
914 #if ENABLE(DFG_JIT)
915         bool canBeOptimized() { return m_canBeOptimized; }
916         bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; }
917         bool shouldEmitProfiling() { return m_shouldEmitProfiling; }
918 #else
919         bool canBeOptimized() { return false; }
920         bool canBeOptimizedOrInlined() { return false; }
921         // Enables use of value profiler with tiered compilation turned off,
922         // in which case all code gets profiled.
923         bool shouldEmitProfiling() { return false; }
924 #endif
925
926         static bool reportCompileTimes();
927         static bool computeCompileTimes();
928         
929         // If you need to check the value of an instruction multiple times and the instruction is
930         // part of a LLInt inline cache, then you want to use this. It will give you the value of
931         // the instruction at the start of JITing.
932         Instruction* copiedInstruction(Instruction*);
933
934         Interpreter* m_interpreter;
935         
936         RefCountedArray<Instruction> m_instructions;
937
938         Vector<CallRecord> m_calls;
939         Vector<Label> m_labels;
940         Vector<JITGetByIdGenerator> m_getByIds;
941         Vector<JITGetByIdWithThisGenerator> m_getByIdsWithThis;
942         Vector<JITPutByIdGenerator> m_putByIds;
943         Vector<ByValCompilationInfo> m_byValCompilationInfo;
944         Vector<CallCompilationInfo> m_callCompilationInfo;
945         Vector<JumpTable> m_jmpTable;
946
947         unsigned m_bytecodeOffset;
948         Vector<SlowCaseEntry> m_slowCases;
949         Vector<SwitchRecord> m_switches;
950
951         JumpList m_exceptionChecks;
952         JumpList m_exceptionChecksWithCallFrameRollback;
953         Label m_exceptionHandler;
954
955         unsigned m_getByIdIndex;
956         unsigned m_getByIdWithThisIndex;
957         unsigned m_putByIdIndex;
958         unsigned m_byValInstructionIndex;
959         unsigned m_callLinkInfoIndex;
960         
961         Label m_arityCheck;
962         std::unique_ptr<LinkBuffer> m_linkBuffer;
963
964         std::unique_ptr<JITDisassembler> m_disassembler;
965         RefPtr<Profiler::Compilation> m_compilation;
966         WeakRandom m_randomGenerator;
967         static CodeRef stringGetByValStubGenerator(VM*);
968
969         PCToCodeOriginMapBuilder m_pcToCodeOriginMapBuilder;
970
971         HashMap<Instruction*, void*> m_instructionToMathIC;
972         HashMap<Instruction*, MathICGenerationState> m_instructionToMathICGenerationState;
973
974         bool m_canBeOptimized;
975         bool m_canBeOptimizedOrInlined;
976         bool m_shouldEmitProfiling;
977         unsigned m_loopOSREntryBytecodeOffset { 0 };
978     } JIT_CLASS_ALIGNMENT;
979
980 } // namespace JSC
981
982 #endif // ENABLE(JIT)