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