implement op_get_rest_length so that we can allocate the rest array with the right...
[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     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         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 isOperandConstantDouble(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         void emitGetVirtualRegister(int src, JSValueRegs dst);
404         void emitPutVirtualRegister(int dst, JSValueRegs src);
405
406         int32_t getOperandConstantInt(int src);
407
408 #if USE(JSVALUE32_64)
409         bool getOperandConstantInt(int op1, int op2, int& op, int32_t& constant);
410
411         void emitLoadTag(int index, RegisterID tag);
412         void emitLoadPayload(int index, RegisterID payload);
413
414         void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload);
415         void emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
416         void emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2);
417
418         void emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
419         void emitStore(int index, const JSValue constant, RegisterID base = callFrameRegister);
420         void emitStoreInt32(int index, RegisterID payload, bool indexIsInt32 = false);
421         void emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32 = false);
422         void emitStoreCell(int index, RegisterID payload, bool indexIsCell = false);
423         void emitStoreBool(int index, RegisterID payload, bool indexIsBool = false);
424         void emitStoreDouble(int index, FPRegisterID value);
425
426         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex);
427         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag);
428
429         void compileGetByIdHotPath(const Identifier*);
430
431         // Arithmetic opcode helpers
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         Jump emitJumpIfJSCell(RegisterID);
452         Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
453         void emitJumpSlowCaseIfJSCell(RegisterID);
454         void emitJumpSlowCaseIfNotJSCell(RegisterID);
455         void emitJumpSlowCaseIfNotJSCell(RegisterID, int VReg);
456         Jump emitJumpIfInt(RegisterID);
457         Jump emitJumpIfNotInt(RegisterID);
458         Jump emitJumpIfNotInt(RegisterID, RegisterID, RegisterID scratch);
459         PatchableJump emitPatchableJumpIfNotInt(RegisterID);
460         void emitJumpSlowCaseIfNotInt(RegisterID);
461         void emitJumpSlowCaseIfNotNumber(RegisterID);
462         void emitJumpSlowCaseIfNotInt(RegisterID, RegisterID, RegisterID scratch);
463
464         void emitTagBool(RegisterID);
465         void compileBinaryArithOpSlowCase(Instruction*, OpcodeID, Vector<SlowCaseEntry>::iterator&, int dst, int src1, int src2, OperandTypes, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase);
466
467         void compileGetByIdHotPath(int baseVReg, const Identifier*);
468
469 #endif // USE(JSVALUE32_64)
470
471         void emit_compareAndJump(OpcodeID, int op1, int op2, unsigned target, RelationalCondition);
472         void emit_compareAndJumpSlow(int op1, int op2, unsigned target, DoubleCondition, size_t (JIT_OPERATION *operation)(ExecState*, EncodedJSValue, EncodedJSValue), bool invert, Vector<SlowCaseEntry>::iterator&);
473         
474         void assertStackPointerOffset();
475
476         void emit_op_add(Instruction*);
477         void emit_op_bitand(Instruction*);
478         void emit_op_bitor(Instruction*);
479         void emit_op_bitxor(Instruction*);
480         void emit_op_call(Instruction*);
481         void emit_op_tail_call(Instruction*);
482         void emit_op_call_eval(Instruction*);
483         void emit_op_call_varargs(Instruction*);
484         void emit_op_tail_call_varargs(Instruction*);
485         void emit_op_construct_varargs(Instruction*);
486         void emit_op_catch(Instruction*);
487         void emit_op_construct(Instruction*);
488         void emit_op_create_this(Instruction*);
489         void emit_op_to_this(Instruction*);
490         void emit_op_create_direct_arguments(Instruction*);
491         void emit_op_create_scoped_arguments(Instruction*);
492         void emit_op_create_out_of_band_arguments(Instruction*);
493         void emit_op_copy_rest(Instruction*);
494         void emit_op_get_rest_length(Instruction*);
495         void emit_op_check_tdz(Instruction*);
496         void emit_op_assert(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_load_arrowfunction_this(Instruction*);
504         void emit_op_eq(Instruction*);
505         void emit_op_eq_null(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_check_has_instance(Instruction*);
512         void emit_op_instanceof(Instruction*);
513         void emit_op_is_undefined(Instruction*);
514         void emit_op_is_boolean(Instruction*);
515         void emit_op_is_number(Instruction*);
516         void emit_op_is_string(Instruction*);
517         void emit_op_is_object(Instruction*);
518         void emit_op_jeq_null(Instruction*);
519         void emit_op_jfalse(Instruction*);
520         void emit_op_jmp(Instruction*);
521         void emit_op_jneq_null(Instruction*);
522         void emit_op_jneq_ptr(Instruction*);
523         void emit_op_jless(Instruction*);
524         void emit_op_jlesseq(Instruction*);
525         void emit_op_jgreater(Instruction*);
526         void emit_op_jgreatereq(Instruction*);
527         void emit_op_jnless(Instruction*);
528         void emit_op_jnlesseq(Instruction*);
529         void emit_op_jngreater(Instruction*);
530         void emit_op_jngreatereq(Instruction*);
531         void emit_op_jtrue(Instruction*);
532         void emit_op_loop_hint(Instruction*);
533         void emit_op_lshift(Instruction*);
534         void emit_op_mod(Instruction*);
535         void emit_op_mov(Instruction*);
536         void emit_op_mul(Instruction*);
537         void emit_op_negate(Instruction*);
538         void emit_op_neq(Instruction*);
539         void emit_op_neq_null(Instruction*);
540         void emit_op_new_array(Instruction*);
541         void emit_op_new_array_with_size(Instruction*);
542         void emit_op_new_array_buffer(Instruction*);
543         void emit_op_new_func(Instruction*);
544         void emit_op_new_func_exp(Instruction*);
545         void emit_op_new_arrow_func_exp(Instruction*);
546         void emit_op_new_object(Instruction*);
547         void emit_op_new_regexp(Instruction*);
548         void emit_op_not(Instruction*);
549         void emit_op_nstricteq(Instruction*);
550         void emit_op_dec(Instruction*);
551         void emit_op_inc(Instruction*);
552         void emit_op_profile_did_call(Instruction*);
553         void emit_op_profile_will_call(Instruction*);
554         void emit_op_profile_type(Instruction*);
555         void emit_op_profile_control_flow(Instruction*);
556         void emit_op_push_with_scope(Instruction*);
557         void emit_op_create_lexical_environment(Instruction*);
558         void emit_op_get_parent_scope(Instruction*);
559         void emit_op_put_by_id(Instruction*);
560         void emit_op_put_by_index(Instruction*);
561         void emit_op_put_by_val(Instruction*);
562         void emit_op_put_getter_by_id(Instruction*);
563         void emit_op_put_setter_by_id(Instruction*);
564         void emit_op_put_getter_setter_by_id(Instruction*);
565         void emit_op_put_getter_by_val(Instruction*);
566         void emit_op_put_setter_by_val(Instruction*);
567         void emit_op_ret(Instruction*);
568         void emit_op_rshift(Instruction*);
569         void emit_op_strcat(Instruction*);
570         void emit_op_stricteq(Instruction*);
571         void emit_op_sub(Instruction*);
572         void emit_op_switch_char(Instruction*);
573         void emit_op_switch_imm(Instruction*);
574         void emit_op_switch_string(Instruction*);
575         void emit_op_tear_off_arguments(Instruction*);
576         void emit_op_throw(Instruction*);
577         void emit_op_throw_static_error(Instruction*);
578         void emit_op_to_number(Instruction*);
579         void emit_op_to_string(Instruction*);
580         void emit_op_to_primitive(Instruction*);
581         void emit_op_unexpected_load(Instruction*);
582         void emit_op_unsigned(Instruction*);
583         void emit_op_urshift(Instruction*);
584         void emit_op_get_enumerable_length(Instruction*);
585         void emit_op_has_generic_property(Instruction*);
586         void emit_op_has_structure_property(Instruction*);
587         void emit_op_has_indexed_property(Instruction*);
588         void emit_op_get_direct_pname(Instruction*);
589         void emit_op_get_property_enumerator(Instruction*);
590         void emit_op_enumerator_structure_pname(Instruction*);
591         void emit_op_enumerator_generic_pname(Instruction*);
592         void emit_op_to_index_string(Instruction*);
593
594         void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
595         void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
596         void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
597         void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
598         void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
599         void emitSlow_op_tail_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
600         void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
601         void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
602         void emitSlow_op_tail_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
603         void emitSlow_op_construct_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
604         void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
605         void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
606         void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
607         void emitSlow_op_check_tdz(Instruction*, Vector<SlowCaseEntry>::iterator&);
608         void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
609         void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
610         void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
611         void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
612         void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
613         void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
614         void emitSlow_op_get_argument_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
615         void emitSlow_op_check_has_instance(Instruction*, Vector<SlowCaseEntry>::iterator&);
616         void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
617         void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
618         void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
619         void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
620         void emitSlow_op_jgreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
621         void emitSlow_op_jgreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
622         void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
623         void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
624         void emitSlow_op_jngreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
625         void emitSlow_op_jngreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
626         void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
627         void emitSlow_op_loop_hint(Instruction*, Vector<SlowCaseEntry>::iterator&);
628         void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
629         void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
630         void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
631         void emitSlow_op_negate(Instruction*, Vector<SlowCaseEntry>::iterator&);
632         void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
633         void emitSlow_op_new_object(Instruction*, Vector<SlowCaseEntry>::iterator&);
634         void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
635         void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
636         void emitSlow_op_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
637         void emitSlow_op_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
638         void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
639         void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
640         void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
641         void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
642         void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
643         void emitSlow_op_to_number(Instruction*, Vector<SlowCaseEntry>::iterator&);
644         void emitSlow_op_to_string(Instruction*, Vector<SlowCaseEntry>::iterator&);
645         void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
646         void emitSlow_op_unsigned(Instruction*, Vector<SlowCaseEntry>::iterator&);
647         void emitSlow_op_urshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
648         void emitSlow_op_has_indexed_property(Instruction*, Vector<SlowCaseEntry>::iterator&);
649         void emitSlow_op_has_structure_property(Instruction*, Vector<SlowCaseEntry>::iterator&);
650         void emitSlow_op_get_direct_pname(Instruction*, Vector<SlowCaseEntry>::iterator&);
651
652         void emit_op_resolve_scope(Instruction*);
653         void emit_op_get_from_scope(Instruction*);
654         void emit_op_put_to_scope(Instruction*);
655         void emit_op_get_from_arguments(Instruction*);
656         void emit_op_put_to_arguments(Instruction*);
657         void emitSlow_op_resolve_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
658         void emitSlow_op_get_from_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
659         void emitSlow_op_put_to_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
660
661         void emitRightShift(Instruction*, bool isUnsigned);
662         void emitRightShiftSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&, bool isUnsigned);
663
664         void emitNewFuncExprCommon(Instruction*);
665         void emitVarInjectionCheck(bool needsVarInjectionChecks);
666         void emitResolveClosure(int dst, int scope, bool needsVarInjectionChecks, unsigned depth);
667         void emitLoadWithStructureCheck(int scope, Structure** structureSlot);
668 #if USE(JSVALUE64)
669         void emitGetVarFromPointer(JSValue* operand, GPRReg);
670         void emitGetVarFromIndirectPointer(JSValue** operand, GPRReg);
671 #else
672         void emitGetVarFromIndirectPointer(JSValue** operand, GPRReg tag, GPRReg payload);
673         void emitGetVarFromPointer(JSValue* operand, GPRReg tag, GPRReg payload);
674 #endif
675         void emitGetClosureVar(int scope, uintptr_t operand);
676         void emitNotifyWrite(WatchpointSet*);
677         void emitNotifyWrite(GPRReg pointerToSet);
678         void emitPutGlobalVariable(JSValue* operand, int value, WatchpointSet*);
679         void emitPutGlobalVariableIndirect(JSValue** addressOfOperand, int value, WatchpointSet**);
680         void emitPutClosureVar(int scope, uintptr_t operand, int value, WatchpointSet*);
681
682         void emitInitRegister(int dst);
683
684         void emitPutIntToCallFrameHeader(RegisterID from, JSStack::CallFrameHeaderEntry);
685
686         JSValue getConstantOperand(int src);
687         bool isOperandConstantInt(int src);
688         bool isOperandConstantChar(int src);
689
690         Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
691         {
692             return iter++->from;
693         }
694         void linkSlowCase(Vector<SlowCaseEntry>::iterator& iter)
695         {
696             iter->from.link(this);
697             ++iter;
698         }
699         void linkDummySlowCase(Vector<SlowCaseEntry>::iterator& iter)
700         {
701             ASSERT(!iter->from.isSet());
702             ++iter;
703         }
704         void linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&, int virtualRegisterIndex);
705         void linkAllSlowCasesForBytecodeOffset(Vector<SlowCaseEntry>& slowCases,
706             Vector<SlowCaseEntry>::iterator&, unsigned bytecodeOffset);
707
708         MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr&);
709 #if OS(WINDOWS) && CPU(X86_64)
710         MacroAssembler::Call appendCallWithExceptionCheckAndSlowPathReturnType(const FunctionPtr&);
711 #endif
712         MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr&);
713         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr&, int);
714         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr&, int);
715         
716         enum WithProfileTag { WithProfile };
717         
718         MacroAssembler::Call callOperation(C_JITOperation_E);
719         MacroAssembler::Call callOperation(C_JITOperation_EO, GPRReg);
720         MacroAssembler::Call callOperation(C_JITOperation_EL, GPRReg);
721         MacroAssembler::Call callOperation(C_JITOperation_EL, TrustedImmPtr);
722         MacroAssembler::Call callOperation(C_JITOperation_ESt, Structure*);
723         MacroAssembler::Call callOperation(C_JITOperation_EZ, int32_t);
724         MacroAssembler::Call callOperation(Z_JITOperation_EJZZ, GPRReg, int32_t, int32_t);
725         MacroAssembler::Call callOperation(J_JITOperation_E, int);
726         MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg);
727         MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, GPRReg, int32_t);
728         MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, const JSValue*, int32_t);
729         MacroAssembler::Call callOperation(J_JITOperation_EC, int, JSCell*);
730         MacroAssembler::Call callOperation(V_JITOperation_EC, JSCell*);
731         MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg);
732 #if USE(JSVALUE64)
733         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, UniquedStringImpl*);
734 #else
735         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, GPRReg, UniquedStringImpl*);
736 #endif
737         MacroAssembler::Call callOperation(J_JITOperation_EJIdc, int, GPRReg, const Identifier*);
738         MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
739         MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, ArrayProfile*);
740         MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, ByValInfo*);
741         MacroAssembler::Call callOperation(C_JITOperation_EJsc, GPRReg);
742         MacroAssembler::Call callOperation(J_JITOperation_EJscC, int, GPRReg, JSCell*);
743         MacroAssembler::Call callOperation(J_JITOperation_EJscCJ, int, GPRReg, JSCell*, GPRReg);
744         MacroAssembler::Call callOperation(C_JITOperation_EJscZ, GPRReg, int32_t);
745         MacroAssembler::Call callOperation(C_JITOperation_EJscZ, int, GPRReg, int32_t);
746 #if USE(JSVALUE64)
747         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg);
748 #else
749         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
750 #endif
751         MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
752         MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EPc, int, Instruction*);
753         MacroAssembler::Call callOperation(J_JITOperation_EPc, int, Instruction*);
754         MacroAssembler::Call callOperation(J_JITOperation_EZ, int, int32_t);
755         MacroAssembler::Call callOperation(J_JITOperation_EZZ, int, int32_t, int32_t);
756         MacroAssembler::Call callOperation(P_JITOperation_E);
757         MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, size_t);
758         MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
759         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID);
760         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID);
761         MacroAssembler::Call callOperation(S_JITOperation_EOJss, RegisterID, RegisterID);
762         MacroAssembler::Call callOperation(Sprt_JITOperation_EZ, int32_t);
763         MacroAssembler::Call callOperation(V_JITOperation_E);
764         MacroAssembler::Call callOperation(V_JITOperation_EC, RegisterID);
765         MacroAssembler::Call callOperation(V_JITOperation_ECC, RegisterID, RegisterID);
766         MacroAssembler::Call callOperation(V_JITOperation_ECIZC, RegisterID, UniquedStringImpl*, int32_t, RegisterID);
767         MacroAssembler::Call callOperation(V_JITOperation_ECIZCC, RegisterID, UniquedStringImpl*, int32_t, RegisterID, RegisterID);
768 #if USE(JSVALUE64)
769         MacroAssembler::Call callOperation(V_JITOperation_ECJZC, RegisterID, RegisterID, int32_t, RegisterID);
770 #else
771         MacroAssembler::Call callOperation(V_JITOperation_ECJZC, RegisterID, RegisterID, RegisterID, int32_t, RegisterID);
772 #endif
773         MacroAssembler::Call callOperation(J_JITOperation_EE, RegisterID);
774         MacroAssembler::Call callOperation(V_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID);
775         MacroAssembler::Call callOperation(J_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID);
776         MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID);
777         MacroAssembler::Call callOperationNoExceptionCheck(Z_JITOperation_E);
778 #if USE(JSVALUE64)
779         MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID);
780 #else
781         MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID, RegisterID);
782 #endif
783 #if USE(JSVALUE64)
784         MacroAssembler::Call callOperation(F_JITOperation_EFJZZ, RegisterID, RegisterID, int32_t, RegisterID);
785         MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, UniquedStringImpl*);
786         MacroAssembler::Call callOperation(V_JITOperation_ECIZJJ, RegisterID, UniquedStringImpl*, int32_t, RegisterID, RegisterID);
787 #else
788         MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, RegisterID, RegisterID, UniquedStringImpl*);
789 #endif
790         MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID);
791         MacroAssembler::Call callOperation(V_JITOperation_EJJJAp, RegisterID, RegisterID, RegisterID, ArrayProfile*);
792         MacroAssembler::Call callOperation(V_JITOperation_EJJJBy, RegisterID, RegisterID, RegisterID, ByValInfo*);
793         MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, int32_t, RegisterID);
794         MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, int32_t);
795         MacroAssembler::Call callOperation(V_JITOperation_EPc, Instruction*);
796         MacroAssembler::Call callOperation(V_JITOperation_EZ, int32_t);
797         MacroAssembler::Call callOperation(V_JITOperation_EZJ, int, GPRReg);
798         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(J_JITOperation_E);
799         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb, CodeBlock*);
800         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(Z_JITOperation_E);
801 #if USE(JSVALUE32_64)
802         MacroAssembler::Call callOperation(F_JITOperation_EFJZZ, RegisterID, RegisterID, RegisterID, int32_t, RegisterID);
803         MacroAssembler::Call callOperation(Z_JITOperation_EJZZ, GPRReg, GPRReg, int32_t, int32_t);
804         MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg, GPRReg);
805         MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg, GPRReg);
806         MacroAssembler::Call callOperation(J_JITOperation_EJIdc, int, GPRReg, GPRReg, const Identifier*);
807         MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
808         MacroAssembler::Call callOperation(J_JITOperation_EJJAp, int, GPRReg, GPRReg, GPRReg, GPRReg, ArrayProfile*);
809         MacroAssembler::Call callOperation(J_JITOperation_EJJBy, int, GPRReg, GPRReg, GPRReg, GPRReg, ByValInfo*);
810         MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, GPRReg, size_t);
811         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID, RegisterID);
812         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID, RegisterID, RegisterID);
813         MacroAssembler::Call callOperation(V_JITOperation_EZSymtabJ, int, SymbolTable*, RegisterID, RegisterID);
814         MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID, RegisterID);
815         MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID);
816         MacroAssembler::Call callOperation(V_JITOperation_EJJJAp, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, ArrayProfile*);
817         MacroAssembler::Call callOperation(V_JITOperation_EJJJBy, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, ByValInfo*);
818         MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, RegisterID, int32_t);
819         MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, RegisterID, int32_t, RegisterID, RegisterID);
820         MacroAssembler::Call callOperation(V_JITOperation_EZJ, int32_t, RegisterID, RegisterID);
821         MacroAssembler::Call callOperation(J_JITOperation_EJscCJ, int, GPRReg, JSCell*, GPRReg, GPRReg);
822 #endif
823
824         Jump checkStructure(RegisterID reg, Structure* structure);
825
826         void updateTopCallFrame();
827
828         Call emitNakedCall(CodePtr function = CodePtr());
829         Call emitNakedTailCall(CodePtr function = CodePtr());
830
831         // Loads the character value of a single character string into dst.
832         void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
833         
834 #if ENABLE(DFG_JIT)
835         void emitEnterOptimizationCheck();
836 #else
837         void emitEnterOptimizationCheck() { }
838 #endif
839
840 #ifndef NDEBUG
841         void printBytecodeOperandTypes(int src1, int src2);
842 #endif
843
844 #if ENABLE(SAMPLING_FLAGS)
845         void setSamplingFlag(int32_t);
846         void clearSamplingFlag(int32_t);
847 #endif
848
849 #if ENABLE(SAMPLING_COUNTERS)
850         void emitCount(AbstractSamplingCounter&, int32_t = 1);
851 #endif
852
853 #if ENABLE(OPCODE_SAMPLING)
854         void sampleInstruction(Instruction*, bool = false);
855 #endif
856
857 #if ENABLE(CODEBLOCK_SAMPLING)
858         void sampleCodeBlock(CodeBlock*);
859 #else
860         void sampleCodeBlock(CodeBlock*) {}
861 #endif
862
863 #if ENABLE(DFG_JIT)
864         bool canBeOptimized() { return m_canBeOptimized; }
865         bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; }
866         bool shouldEmitProfiling() { return m_shouldEmitProfiling; }
867 #else
868         bool canBeOptimized() { return false; }
869         bool canBeOptimizedOrInlined() { return false; }
870         // Enables use of value profiler with tiered compilation turned off,
871         // in which case all code gets profiled.
872         bool shouldEmitProfiling() { return false; }
873 #endif
874
875         Interpreter* m_interpreter;
876
877         Vector<CallRecord> m_calls;
878         Vector<Label> m_labels;
879         Vector<JITGetByIdGenerator> m_getByIds;
880         Vector<JITPutByIdGenerator> m_putByIds;
881         Vector<ByValCompilationInfo> m_byValCompilationInfo;
882         Vector<CallCompilationInfo> m_callCompilationInfo;
883         Vector<JumpTable> m_jmpTable;
884
885         unsigned m_bytecodeOffset;
886         Vector<SlowCaseEntry> m_slowCases;
887         Vector<SwitchRecord> m_switches;
888
889         JumpList m_exceptionChecks;
890         JumpList m_exceptionChecksWithCallFrameRollback;
891
892         unsigned m_getByIdIndex;
893         unsigned m_putByIdIndex;
894         unsigned m_byValInstructionIndex;
895         unsigned m_callLinkInfoIndex;
896
897         std::unique_ptr<JITDisassembler> m_disassembler;
898         RefPtr<Profiler::Compilation> m_compilation;
899         WeakRandom m_randomGenerator;
900         static CodeRef stringGetByValStubGenerator(VM*);
901
902         bool m_canBeOptimized;
903         bool m_canBeOptimizedOrInlined;
904         bool m_shouldEmitProfiling;
905     } JIT_CLASS_ALIGNMENT;
906
907 } // namespace JSC
908
909 #endif // ENABLE(JIT)
910
911 #endif // JIT_h