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