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