1443ddddc81734d71c397f34c944e63eca08129e
[WebKit-https.git] / Source / JavaScriptCore / jit / JIT.h
1 /*
2  * Copyright (C) 2008, 2012, 2013 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)
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 "JSInterfaceJIT.h"
46 #include "LegacyProfiler.h"
47 #include "Opcode.h"
48 #include "ResultType.h"
49 #include "UnusedPointer.h"
50 #include <bytecode/SamplingTool.h>
51
52 namespace JSC {
53
54     class CodeBlock;
55     class FunctionExecutable;
56     class JIT;
57     class JSPropertyNameIterator;
58     class Interpreter;
59     class JSScope;
60     class JSStack;
61     class MarkedAllocator;
62     class Register;
63     class StructureChain;
64
65     struct CallLinkInfo;
66     struct Instruction;
67     struct OperandTypes;
68     struct PolymorphicAccessStructureList;
69     struct SimpleJumpTable;
70     struct StringJumpTable;
71     struct StructureStubInfo;
72
73     struct CallRecord {
74         MacroAssembler::Call from;
75         unsigned bytecodeOffset;
76         void* to;
77
78         CallRecord()
79         {
80         }
81
82         CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)
83             : from(from)
84             , bytecodeOffset(bytecodeOffset)
85             , to(to)
86         {
87         }
88     };
89
90     struct JumpTable {
91         MacroAssembler::Jump from;
92         unsigned toBytecodeOffset;
93
94         JumpTable(MacroAssembler::Jump f, unsigned t)
95             : from(f)
96             , toBytecodeOffset(t)
97         {
98         }
99     };
100
101     struct SlowCaseEntry {
102         MacroAssembler::Jump from;
103         unsigned to;
104         unsigned hint;
105         
106         SlowCaseEntry(MacroAssembler::Jump f, unsigned t, unsigned h = 0)
107             : from(f)
108             , to(t)
109             , hint(h)
110         {
111         }
112     };
113
114     struct SwitchRecord {
115         enum Type {
116             Immediate,
117             Character,
118             String
119         };
120
121         Type type;
122
123         union {
124             SimpleJumpTable* simpleJumpTable;
125             StringJumpTable* stringJumpTable;
126         } jumpTable;
127
128         unsigned bytecodeOffset;
129         unsigned defaultOffset;
130
131         SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset, Type type)
132             : type(type)
133             , bytecodeOffset(bytecodeOffset)
134             , defaultOffset(defaultOffset)
135         {
136             this->jumpTable.simpleJumpTable = jumpTable;
137         }
138
139         SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset)
140             : type(String)
141             , bytecodeOffset(bytecodeOffset)
142             , defaultOffset(defaultOffset)
143         {
144             this->jumpTable.stringJumpTable = jumpTable;
145         }
146     };
147
148     enum PropertyStubGetById_T { PropertyStubGetById };
149     enum PropertyStubPutById_T { PropertyStubPutById };
150
151     struct PropertyStubCompilationInfo {
152         enum Type { GetById, PutById } m_type;
153     
154         unsigned bytecodeIndex;
155         MacroAssembler::Call callReturnLocation;
156         MacroAssembler::Label hotPathBegin;
157         MacroAssembler::DataLabelPtr getStructureToCompare;
158         MacroAssembler::PatchableJump getStructureCheck;
159         MacroAssembler::ConvertibleLoadLabel propertyStorageLoad;
160 #if USE(JSVALUE64)
161         MacroAssembler::DataLabelCompact getDisplacementLabel;
162 #else
163         MacroAssembler::DataLabelCompact getDisplacementLabel1;
164         MacroAssembler::DataLabelCompact getDisplacementLabel2;
165 #endif
166         MacroAssembler::Label getPutResult;
167         MacroAssembler::Label getColdPathBegin;
168         MacroAssembler::DataLabelPtr putStructureToCompare;
169 #if USE(JSVALUE64)
170         MacroAssembler::DataLabel32 putDisplacementLabel;
171 #else
172         MacroAssembler::DataLabel32 putDisplacementLabel1;
173         MacroAssembler::DataLabel32 putDisplacementLabel2;
174 #endif
175
176 #if !ASSERT_DISABLED
177         PropertyStubCompilationInfo()
178             : bytecodeIndex(std::numeric_limits<unsigned>::max())
179         {
180         }
181 #endif
182
183
184         PropertyStubCompilationInfo(
185             PropertyStubGetById_T, unsigned bytecodeIndex, MacroAssembler::Label hotPathBegin,
186             MacroAssembler::DataLabelPtr structureToCompare,
187             MacroAssembler::PatchableJump structureCheck,
188             MacroAssembler::ConvertibleLoadLabel propertyStorageLoad,
189 #if USE(JSVALUE64)
190             MacroAssembler::DataLabelCompact displacementLabel,
191 #else
192             MacroAssembler::DataLabelCompact displacementLabel1,
193             MacroAssembler::DataLabelCompact displacementLabel2,
194 #endif
195             MacroAssembler::Label putResult)
196             : m_type(GetById)
197             , bytecodeIndex(bytecodeIndex)
198             , hotPathBegin(hotPathBegin)
199             , getStructureToCompare(structureToCompare)
200             , getStructureCheck(structureCheck)
201             , propertyStorageLoad(propertyStorageLoad)
202 #if USE(JSVALUE64)
203             , getDisplacementLabel(displacementLabel)
204 #else
205             , getDisplacementLabel1(displacementLabel1)
206             , getDisplacementLabel2(displacementLabel2)
207 #endif
208             , getPutResult(putResult)
209         {
210         }
211
212         PropertyStubCompilationInfo(
213             PropertyStubPutById_T, unsigned bytecodeIndex, MacroAssembler::Label hotPathBegin,
214             MacroAssembler::DataLabelPtr structureToCompare,
215             MacroAssembler::ConvertibleLoadLabel propertyStorageLoad,
216 #if USE(JSVALUE64)
217             MacroAssembler::DataLabel32 displacementLabel
218 #else
219             MacroAssembler::DataLabel32 displacementLabel1,
220             MacroAssembler::DataLabel32 displacementLabel2
221 #endif
222             )
223             : m_type(PutById)
224             , bytecodeIndex(bytecodeIndex)
225             , hotPathBegin(hotPathBegin)
226             , propertyStorageLoad(propertyStorageLoad)
227             , putStructureToCompare(structureToCompare)
228 #if USE(JSVALUE64)
229             , putDisplacementLabel(displacementLabel)
230 #else
231             , putDisplacementLabel1(displacementLabel1)
232             , putDisplacementLabel2(displacementLabel2)
233 #endif
234         {
235         }
236
237         void slowCaseInfo(PropertyStubGetById_T, MacroAssembler::Label coldPathBegin, MacroAssembler::Call call)
238         {
239             ASSERT(m_type == GetById);
240             callReturnLocation = call;
241             getColdPathBegin = coldPathBegin;
242         }
243
244         void slowCaseInfo(PropertyStubPutById_T, MacroAssembler::Call call)
245         {
246             ASSERT(m_type == PutById);
247             callReturnLocation = call;
248         }
249
250         void copyToStubInfo(StructureStubInfo& info, LinkBuffer &patchBuffer);
251     };
252
253     struct ByValCompilationInfo {
254         ByValCompilationInfo() { }
255         
256         ByValCompilationInfo(unsigned bytecodeIndex, MacroAssembler::PatchableJump badTypeJump, JITArrayMode arrayMode, MacroAssembler::Label doneTarget)
257             : bytecodeIndex(bytecodeIndex)
258             , badTypeJump(badTypeJump)
259             , arrayMode(arrayMode)
260             , doneTarget(doneTarget)
261         {
262         }
263         
264         unsigned bytecodeIndex;
265         MacroAssembler::PatchableJump badTypeJump;
266         JITArrayMode arrayMode;
267         MacroAssembler::Label doneTarget;
268         MacroAssembler::Label slowPathTarget;
269         MacroAssembler::Call returnAddress;
270     };
271
272     struct StructureStubCompilationInfo {
273         MacroAssembler::DataLabelPtr hotPathBegin;
274         MacroAssembler::Call hotPathOther;
275         MacroAssembler::Call callReturnLocation;
276         CallLinkInfo::CallType callType;
277         unsigned bytecodeIndex;
278     };
279
280     // Near calls can only be patched to other JIT code, regular calls can be patched to JIT code or relinked to stub functions.
281     void ctiPatchNearCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, MacroAssemblerCodePtr newCalleeFunction);
282     void ctiPatchCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, MacroAssemblerCodePtr newCalleeFunction);
283     void ctiPatchCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, FunctionPtr newCalleeFunction);
284
285     class JIT : private JSInterfaceJIT {
286         friend class JITSlowPathCall;
287         friend class JITStubCall;
288         friend struct PropertyStubCompilationInfo;
289
290         using MacroAssembler::Jump;
291         using MacroAssembler::JumpList;
292         using MacroAssembler::Label;
293
294         static const uintptr_t patchGetByIdDefaultStructure = unusedPointer;
295         static const int patchGetByIdDefaultOffset = 0;
296         // Magic number - initial offset cannot be representable as a signed 8bit value, or the X86Assembler
297         // will compress the displacement, and we may not be able to fit a patched offset.
298         static const int patchPutByIdDefaultOffset = 256;
299
300     public:
301         static CompilationResult compile(VM* vm, CodeBlock* codeBlock, JITCompilationEffort effort)
302         {
303             return JIT(vm, codeBlock).privateCompile(effort);
304         }
305         
306         static void compileClosureCall(VM* vm, CallLinkInfo* callLinkInfo, CodeBlock* callerCodeBlock, CodeBlock* calleeCodeBlock, Structure* expectedStructure, ExecutableBase* expectedExecutable, MacroAssemblerCodePtr codePtr)
307         {
308             JIT jit(vm, callerCodeBlock);
309             jit.m_bytecodeOffset = callLinkInfo->codeOrigin.bytecodeIndex;
310             jit.privateCompileClosureCall(callLinkInfo, calleeCodeBlock, expectedStructure, expectedExecutable, codePtr);
311         }
312
313         static void compileGetByIdProto(VM* vm, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, Structure* prototypeStructure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress)
314         {
315             JIT jit(vm, codeBlock);
316             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
317             jit.privateCompileGetByIdProto(stubInfo, structure, prototypeStructure, ident, slot, cachedOffset, returnAddress, callFrame);
318         }
319
320         static void compileGetByIdSelfList(VM* vm, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* polymorphicStructures, int currentIndex, Structure* structure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset)
321         {
322             JIT jit(vm, codeBlock);
323             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
324             jit.privateCompileGetByIdSelfList(stubInfo, polymorphicStructures, currentIndex, structure, ident, slot, cachedOffset);
325         }
326         static void compileGetByIdProtoList(VM* vm, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructureList, int currentIndex, Structure* structure, Structure* prototypeStructure, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset)
327         {
328             JIT jit(vm, codeBlock);
329             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
330             jit.privateCompileGetByIdProtoList(stubInfo, prototypeStructureList, currentIndex, structure, prototypeStructure, ident, slot, cachedOffset, callFrame);
331         }
332         static void compileGetByIdChainList(VM* vm, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructureList, int currentIndex, Structure* structure, StructureChain* chain, size_t count, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset)
333         {
334             JIT jit(vm, codeBlock);
335             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
336             jit.privateCompileGetByIdChainList(stubInfo, prototypeStructureList, currentIndex, structure, chain, count, ident, slot, cachedOffset, callFrame);
337         }
338
339         static void compileGetByIdChain(VM* vm, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, StructureChain* chain, size_t count, const Identifier& ident, const PropertySlot& slot, PropertyOffset cachedOffset, ReturnAddressPtr returnAddress)
340         {
341             JIT jit(vm, codeBlock);
342             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
343             jit.privateCompileGetByIdChain(stubInfo, structure, chain, count, ident, slot, cachedOffset, returnAddress, callFrame);
344         }
345         
346         static void compilePutByIdTransition(VM* vm, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, PropertyOffset cachedOffset, StructureChain* chain, ReturnAddressPtr returnAddress, bool direct)
347         {
348             JIT jit(vm, codeBlock);
349             jit.m_bytecodeOffset = stubInfo->codeOrigin.bytecodeIndex;
350             jit.privateCompilePutByIdTransition(stubInfo, oldStructure, newStructure, cachedOffset, chain, returnAddress, direct);
351         }
352         
353         static void compileGetByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
354         {
355             JIT jit(vm, codeBlock);
356             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
357             jit.privateCompileGetByVal(byValInfo, returnAddress, arrayMode);
358         }
359
360         static void compilePutByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
361         {
362             JIT jit(vm, codeBlock);
363             jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
364             jit.privateCompilePutByVal(byValInfo, returnAddress, arrayMode);
365         }
366
367         static CodeRef compileCTINativeCall(VM* vm, NativeFunction func)
368         {
369             if (!vm->canUseJIT()) {
370 #if ENABLE(LLINT)
371                 return CodeRef::createLLIntCodeRef(llint_native_call_trampoline);
372 #else
373                 return CodeRef();
374 #endif
375             }
376             JIT jit(vm, 0);
377             return jit.privateCompileCTINativeCall(vm, func);
378         }
379
380         static void resetPatchGetById(RepatchBuffer&, StructureStubInfo*);
381         static void resetPatchPutById(RepatchBuffer&, StructureStubInfo*);
382         static void patchGetByIdSelf(CodeBlock*, StructureStubInfo*, Structure*, PropertyOffset cachedOffset, ReturnAddressPtr);
383         static void patchPutByIdReplace(CodeBlock*, StructureStubInfo*, Structure*, PropertyOffset cachedOffset, ReturnAddressPtr, bool direct);
384
385         static void compilePatchGetArrayLength(VM* vm, CodeBlock* codeBlock, ReturnAddressPtr returnAddress)
386         {
387             JIT jit(vm, codeBlock);
388 #if ENABLE(DFG_JIT)
389             // Force profiling to be enabled during stub generation.
390             jit.m_canBeOptimized = true;
391             jit.m_canBeOptimizedOrInlined = true;
392             jit.m_shouldEmitProfiling = true;
393 #endif // ENABLE(DFG_JIT)
394             return jit.privateCompilePatchGetArrayLength(returnAddress);
395         }
396
397         static void linkFor(ExecState*, JSFunction* callee, CodeBlock* callerCodeBlock, CodeBlock* calleeCodeBlock, CodePtr, CallLinkInfo*, VM*, CodeSpecializationKind);
398         static void linkSlowCall(CodeBlock* callerCodeBlock, CallLinkInfo*);
399
400     private:
401         JIT(VM*, CodeBlock* = 0);
402
403         void privateCompileMainPass();
404         void privateCompileLinkPass();
405         void privateCompileSlowCases();
406         CompilationResult privateCompile(JITCompilationEffort);
407         
408         void privateCompileClosureCall(CallLinkInfo*, CodeBlock* calleeCodeBlock, Structure*, ExecutableBase*, MacroAssemblerCodePtr);
409         
410         void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, const Identifier&, const PropertySlot&, PropertyOffset cachedOffset, ReturnAddressPtr, CallFrame*);
411         void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, const Identifier&, const PropertySlot&, PropertyOffset cachedOffset);
412         void privateCompileGetByIdProtoList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, Structure* prototypeStructure, const Identifier&, const PropertySlot&, PropertyOffset cachedOffset, CallFrame*);
413         void privateCompileGetByIdChainList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, StructureChain*, size_t count, const Identifier&, const PropertySlot&, PropertyOffset cachedOffset, CallFrame*);
414         void privateCompileGetByIdChain(StructureStubInfo*, Structure*, StructureChain*, size_t count, const Identifier&, const PropertySlot&, PropertyOffset cachedOffset, ReturnAddressPtr, CallFrame*);
415         void privateCompilePutByIdTransition(StructureStubInfo*, Structure*, Structure*, PropertyOffset cachedOffset, StructureChain*, ReturnAddressPtr, bool direct);
416         
417         void privateCompileGetByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
418         void privateCompilePutByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
419
420         Label privateCompileCTINativeCall(VM*, bool isConstruct = false);
421         CodeRef privateCompileCTINativeCall(VM*, NativeFunction);
422         void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);
423
424         static bool isDirectPutById(StructureStubInfo*);
425
426         void addSlowCase(Jump);
427         void addSlowCase(JumpList);
428         void addSlowCase();
429         void addJump(Jump, int);
430         void emitJumpSlowToHot(Jump, int);
431
432         void compileOpCall(OpcodeID, Instruction*, unsigned callLinkInfoIndex);
433         void compileOpCallSlowCase(OpcodeID, Instruction*, Vector<SlowCaseEntry>::iterator&, unsigned callLinkInfoIndex);
434         void compileLoadVarargs(Instruction*);
435         void compileCallEval(Instruction*);
436         void compileCallEvalSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&);
437         void emitPutCallResult(Instruction*);
438
439         enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
440         void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type);
441         bool isOperandConstantImmediateDouble(int src);
442         
443         void emitLoadDouble(int index, FPRegisterID value);
444         void emitLoadInt32ToDouble(int index, FPRegisterID value);
445         Jump emitJumpIfNotObject(RegisterID structureReg);
446
447         Jump addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, RegisterID scratch);
448         void addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, JumpList& failureCases, RegisterID scratch);
449         void testPrototype(JSValue, JumpList& failureCases, StructureStubInfo*);
450
451         enum WriteBarrierMode { UnconditionalWriteBarrier, ShouldFilterImmediates };
452         // value register in write barrier is used before any scratch registers
453         // so may safely be the same as either of the scratch registers.
454         void emitWriteBarrier(RegisterID owner, RegisterID valueTag, RegisterID scratch, RegisterID scratch2, WriteBarrierMode, WriteBarrierUseKind);
455         void emitWriteBarrier(JSCell* owner, RegisterID value, RegisterID scratch, WriteBarrierMode, WriteBarrierUseKind);
456
457         template<typename StructureType> // StructureType can be RegisterID or ImmPtr.
458         void emitAllocateJSObject(RegisterID allocator, StructureType, RegisterID result, RegisterID scratch);
459         
460 #if ENABLE(VALUE_PROFILER)
461         // This assumes that the value to profile is in regT0 and that regT3 is available for
462         // scratch.
463         void emitValueProfilingSite(ValueProfile*, RegisterID);
464         void emitValueProfilingSite(unsigned bytecodeOffset, RegisterID);
465         void emitValueProfilingSite(RegisterID);
466 #else
467         void emitValueProfilingSite(unsigned, RegisterID) { }
468         void emitValueProfilingSite(RegisterID) { }
469 #endif
470         void emitArrayProfilingSite(RegisterID structureAndIndexingType, RegisterID scratch, ArrayProfile*);
471         void emitArrayProfilingSiteForBytecodeIndex(RegisterID structureAndIndexingType, RegisterID scratch, unsigned bytecodeIndex);
472         void emitArrayProfileStoreToHoleSpecialCase(ArrayProfile*);
473         void emitArrayProfileOutOfBoundsSpecialCase(ArrayProfile*);
474         
475         JITArrayMode chooseArrayMode(ArrayProfile*);
476         
477         // Property is in regT1, base is in regT0. regT2 contains indexing type.
478         // Property is int-checked and zero extended. Base is cell checked.
479         // Structure is already profiled. Returns the slow cases. Fall-through
480         // case contains result in regT0, and it is not yet profiled.
481         JumpList emitInt32GetByVal(Instruction* instruction, PatchableJump& badType) { return emitContiguousGetByVal(instruction, badType, Int32Shape); }
482         JumpList emitDoubleGetByVal(Instruction*, PatchableJump& badType);
483         JumpList emitContiguousGetByVal(Instruction*, PatchableJump& badType, IndexingType expectedShape = ContiguousShape);
484         JumpList emitArrayStorageGetByVal(Instruction*, PatchableJump& badType);
485         JumpList emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
486         JumpList emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
487         
488         // Property is in regT0, base is in regT0. regT2 contains indecing type.
489         // The value to store is not yet loaded. Property is int-checked and
490         // zero-extended. Base is cell checked. Structure is already profiled.
491         // returns the slow cases.
492         JumpList emitInt32PutByVal(Instruction* currentInstruction, PatchableJump& badType)
493         {
494             return emitGenericContiguousPutByVal(currentInstruction, badType, Int32Shape);
495         }
496         JumpList emitDoublePutByVal(Instruction* currentInstruction, PatchableJump& badType)
497         {
498             return emitGenericContiguousPutByVal(currentInstruction, badType, DoubleShape);
499         }
500         JumpList emitContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType)
501         {
502             return emitGenericContiguousPutByVal(currentInstruction, badType);
503         }
504         JumpList emitGenericContiguousPutByVal(Instruction*, PatchableJump& badType, IndexingType indexingShape = ContiguousShape);
505         JumpList emitArrayStoragePutByVal(Instruction*, PatchableJump& badType);
506         JumpList emitIntTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
507         JumpList emitFloatTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
508         
509         enum FinalObjectMode { MayBeFinal, KnownNotFinal };
510
511 #if USE(JSVALUE32_64)
512         bool getOperandConstantImmediateInt(int op1, int op2, int& op, int32_t& constant);
513
514         void emitLoadTag(int index, RegisterID tag);
515         void emitLoadPayload(int index, RegisterID payload);
516
517         void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload);
518         void emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
519         void emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2);
520
521         void emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
522         void emitStore(int index, const JSValue constant, RegisterID base = callFrameRegister);
523         void emitStoreInt32(int index, RegisterID payload, bool indexIsInt32 = false);
524         void emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32 = false);
525         void emitStoreAndMapInt32(int index, RegisterID tag, RegisterID payload, bool indexIsInt32, size_t opcodeLength);
526         void emitStoreCell(int index, RegisterID payload, bool indexIsCell = false);
527         void emitStoreBool(int index, RegisterID payload, bool indexIsBool = false);
528         void emitStoreDouble(int index, FPRegisterID value);
529
530         bool isLabeled(unsigned bytecodeOffset);
531         void map(unsigned bytecodeOffset, int virtualRegisterIndex, RegisterID tag, RegisterID payload);
532         void unmap(RegisterID);
533         void unmap();
534         bool isMapped(int virtualRegisterIndex);
535         bool getMappedPayload(int virtualRegisterIndex, RegisterID& payload);
536         bool getMappedTag(int virtualRegisterIndex, RegisterID& tag);
537         
538         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex);
539         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag);
540
541         void compileGetByIdHotPath(const Identifier*);
542         void compileGetByIdSlowCase(int resultVReg, int baseVReg, const Identifier*, Vector<SlowCaseEntry>::iterator&);
543         void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
544         void compileGetDirectOffset(JSObject* base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
545         void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, RegisterID offset, FinalObjectMode = MayBeFinal);
546         void compilePutDirectOffset(RegisterID base, RegisterID valueTag, RegisterID valuePayload, PropertyOffset cachedOffset);
547
548         // Arithmetic opcode helpers
549         void emitAdd32Constant(int dst, int op, int32_t constant, ResultType opType);
550         void emitSub32Constant(int dst, int op, int32_t constant, ResultType opType);
551         void emitBinaryDoubleOp(OpcodeID, int dst, int op1, int op2, OperandTypes, JumpList& notInt32Op1, JumpList& notInt32Op2, bool op1IsInRegisters = true, bool op2IsInRegisters = true);
552
553 #if CPU(ARM_TRADITIONAL)
554         // sequenceOpCall
555         static const int sequenceOpCallInstructionSpace = 12;
556         static const int sequenceOpCallConstantSpace = 2;
557         // sequenceGetByIdHotPath
558         static const int sequenceGetByIdHotPathInstructionSpace = 36;
559         static const int sequenceGetByIdHotPathConstantSpace = 4;
560         // sequenceGetByIdSlowCase
561         static const int sequenceGetByIdSlowCaseInstructionSpace = 80;
562         static const int sequenceGetByIdSlowCaseConstantSpace = 4;
563         // sequencePutById
564         static const int sequencePutByIdInstructionSpace = 36;
565         static const int sequencePutByIdConstantSpace = 4;
566 #elif CPU(SH4)
567         // sequenceOpCall
568         static const int sequenceOpCallInstructionSpace = 12;
569         static const int sequenceOpCallConstantSpace = 2;
570         // sequenceGetByIdHotPath
571         static const int sequenceGetByIdHotPathInstructionSpace = 36;
572         static const int sequenceGetByIdHotPathConstantSpace = 5;
573         // sequenceGetByIdSlowCase
574         static const int sequenceGetByIdSlowCaseInstructionSpace = 38;
575         static const int sequenceGetByIdSlowCaseConstantSpace = 4;
576         // sequencePutById
577         static const int sequencePutByIdInstructionSpace = 36;
578         static const int sequencePutByIdConstantSpace = 5;
579 #endif
580
581 #else // USE(JSVALUE32_64)
582         /* This function is deprecated. */
583         void emitGetJITStubArg(int argumentNumber, RegisterID dst);
584
585         void emitGetVirtualRegister(int src, RegisterID dst);
586         void emitGetVirtualRegister(VirtualRegister src, RegisterID dst);
587         void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2);
588         void emitGetVirtualRegisters(VirtualRegister src1, RegisterID dst1, VirtualRegister src2, RegisterID dst2);
589         void emitPutVirtualRegister(int dst, RegisterID from = regT0);
590         void emitPutVirtualRegister(VirtualRegister dst, RegisterID from = regT0);
591         void emitStoreCell(int dst, RegisterID payload, bool /* only used in JSValue32_64 */ = false)
592         {
593             emitPutVirtualRegister(dst, payload);
594         }
595
596         int32_t getConstantOperandImmediateInt(int src);
597
598         void killLastResultRegister();
599
600         Jump emitJumpIfJSCell(RegisterID);
601         Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
602         void emitJumpSlowCaseIfJSCell(RegisterID);
603         void emitJumpSlowCaseIfNotJSCell(RegisterID);
604         void emitJumpSlowCaseIfNotJSCell(RegisterID, int VReg);
605         Jump emitJumpIfImmediateInteger(RegisterID);
606         Jump emitJumpIfNotImmediateInteger(RegisterID);
607         Jump emitJumpIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
608         void emitJumpSlowCaseIfNotImmediateInteger(RegisterID);
609         void emitJumpSlowCaseIfNotImmediateNumber(RegisterID);
610         void emitJumpSlowCaseIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
611
612         void emitFastArithReTagImmediate(RegisterID src, RegisterID dest);
613
614         void emitTagAsBoolImmediate(RegisterID reg);
615         void compileBinaryArithOp(OpcodeID, int dst, int src1, int src2, OperandTypes opi);
616         void compileBinaryArithOpSlowCase(Instruction*, OpcodeID, Vector<SlowCaseEntry>::iterator&, int dst, int src1, int src2, OperandTypes, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase);
617
618         void compileGetByIdHotPath(int baseVReg, const Identifier*);
619         void compileGetByIdSlowCase(int resultVReg, int baseVReg, const Identifier*, Vector<SlowCaseEntry>::iterator&);
620         void compileGetDirectOffset(RegisterID base, RegisterID result, PropertyOffset cachedOffset);
621         void compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffset cachedOffset);
622         void compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID offset, RegisterID scratch, FinalObjectMode = MayBeFinal);
623         void compilePutDirectOffset(RegisterID base, RegisterID value, PropertyOffset cachedOffset);
624
625 #endif // USE(JSVALUE32_64)
626
627 #if (defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL)
628 #define BEGIN_UNINTERRUPTED_SEQUENCE(name) do { beginUninterruptedSequence(name ## InstructionSpace, name ## ConstantSpace); } while (false)
629 #define END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, dst) do { endUninterruptedSequence(name ## InstructionSpace, name ## ConstantSpace, dst); } while (false)
630 #define END_UNINTERRUPTED_SEQUENCE(name) END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, 0)
631
632         void beginUninterruptedSequence(int, int);
633         void endUninterruptedSequence(int, int, int);
634
635 #else
636 #define BEGIN_UNINTERRUPTED_SEQUENCE(name)
637 #define END_UNINTERRUPTED_SEQUENCE(name)
638 #define END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, dst)
639 #endif
640
641         void emit_compareAndJump(OpcodeID, int op1, int op2, unsigned target, RelationalCondition);
642         void emit_compareAndJumpSlow(int op1, int op2, unsigned target, DoubleCondition, int (JIT_STUB *stub)(STUB_ARGS_DECLARATION), bool invert, Vector<SlowCaseEntry>::iterator&);
643
644         void emit_op_add(Instruction*);
645         void emit_op_bitand(Instruction*);
646         void emit_op_bitor(Instruction*);
647         void emit_op_bitxor(Instruction*);
648         void emit_op_call(Instruction*);
649         void emit_op_call_eval(Instruction*);
650         void emit_op_call_varargs(Instruction*);
651         void emit_op_catch(Instruction*);
652         void emit_op_construct(Instruction*);
653         void emit_op_get_callee(Instruction*);
654         void emit_op_create_this(Instruction*);
655         void emit_op_to_this(Instruction*);
656         void emit_op_create_arguments(Instruction*);
657         void emit_op_debug(Instruction*);
658         void emit_op_del_by_id(Instruction*);
659         void emit_op_div(Instruction*);
660         void emit_op_end(Instruction*);
661         void emit_op_enter(Instruction*);
662         void emit_op_create_activation(Instruction*);
663         void emit_op_eq(Instruction*);
664         void emit_op_eq_null(Instruction*);
665         void emit_op_get_by_id(Instruction*);
666         void emit_op_get_arguments_length(Instruction*);
667         void emit_op_get_by_val(Instruction*);
668         void emit_op_get_argument_by_val(Instruction*);
669         void emit_op_get_by_pname(Instruction*);
670         void emit_op_init_lazy_reg(Instruction*);
671         void emit_op_check_has_instance(Instruction*);
672         void emit_op_instanceof(Instruction*);
673         void emit_op_is_undefined(Instruction*);
674         void emit_op_is_boolean(Instruction*);
675         void emit_op_is_number(Instruction*);
676         void emit_op_is_string(Instruction*);
677         void emit_op_jeq_null(Instruction*);
678         void emit_op_jfalse(Instruction*);
679         void emit_op_jmp(Instruction*);
680         void emit_op_jneq_null(Instruction*);
681         void emit_op_jneq_ptr(Instruction*);
682         void emit_op_jless(Instruction*);
683         void emit_op_jlesseq(Instruction*);
684         void emit_op_jgreater(Instruction*);
685         void emit_op_jgreatereq(Instruction*);
686         void emit_op_jnless(Instruction*);
687         void emit_op_jnlesseq(Instruction*);
688         void emit_op_jngreater(Instruction*);
689         void emit_op_jngreatereq(Instruction*);
690         void emit_op_jtrue(Instruction*);
691         void emit_op_loop_hint(Instruction*);
692         void emit_op_lshift(Instruction*);
693         void emit_op_mod(Instruction*);
694         void emit_op_mov(Instruction*);
695         void emit_op_mul(Instruction*);
696         void emit_op_negate(Instruction*);
697         void emit_op_neq(Instruction*);
698         void emit_op_neq_null(Instruction*);
699         void emit_op_new_array(Instruction*);
700         void emit_op_new_array_with_size(Instruction*);
701         void emit_op_new_array_buffer(Instruction*);
702         void emit_op_new_func(Instruction*);
703         void emit_op_new_func_exp(Instruction*);
704         void emit_op_new_object(Instruction*);
705         void emit_op_new_regexp(Instruction*);
706         void emit_op_get_pnames(Instruction*);
707         void emit_op_next_pname(Instruction*);
708         void emit_op_not(Instruction*);
709         void emit_op_nstricteq(Instruction*);
710         void emit_op_pop_scope(Instruction*);
711         void emit_op_dec(Instruction*);
712         void emit_op_inc(Instruction*);
713         void emit_op_profile_did_call(Instruction*);
714         void emit_op_profile_will_call(Instruction*);
715         void emit_op_push_name_scope(Instruction*);
716         void emit_op_push_with_scope(Instruction*);
717         void emit_op_put_by_id(Instruction*);
718         void emit_op_put_by_index(Instruction*);
719         void emit_op_put_by_val(Instruction*);
720         void emit_op_put_getter_setter(Instruction*);
721         void emit_op_init_global_const(Instruction*);
722         void emit_op_ret(Instruction*);
723         void emit_op_ret_object_or_this(Instruction*);
724         void emit_op_rshift(Instruction*);
725         void emit_op_strcat(Instruction*);
726         void emit_op_stricteq(Instruction*);
727         void emit_op_sub(Instruction*);
728         void emit_op_switch_char(Instruction*);
729         void emit_op_switch_imm(Instruction*);
730         void emit_op_switch_string(Instruction*);
731         void emit_op_tear_off_activation(Instruction*);
732         void emit_op_tear_off_arguments(Instruction*);
733         void emit_op_throw(Instruction*);
734         void emit_op_throw_static_error(Instruction*);
735         void emit_op_to_number(Instruction*);
736         void emit_op_to_primitive(Instruction*);
737         void emit_op_unexpected_load(Instruction*);
738         void emit_op_urshift(Instruction*);
739
740         void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
741         void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
742         void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
743         void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
744         void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
745         void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
746         void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
747         void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
748         void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
749         void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
750         void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
751         void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
752         void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
753         void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
754         void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
755         void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
756         void emitSlow_op_get_argument_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
757         void emitSlow_op_get_by_pname(Instruction*, Vector<SlowCaseEntry>::iterator&);
758         void emitSlow_op_check_has_instance(Instruction*, Vector<SlowCaseEntry>::iterator&);
759         void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
760         void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
761         void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
762         void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
763         void emitSlow_op_jgreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
764         void emitSlow_op_jgreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
765         void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
766         void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
767         void emitSlow_op_jngreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
768         void emitSlow_op_jngreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
769         void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
770         void emitSlow_op_loop_hint(Instruction*, Vector<SlowCaseEntry>::iterator&);
771         void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
772         void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
773         void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
774         void emitSlow_op_negate(Instruction*, Vector<SlowCaseEntry>::iterator&);
775         void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
776         void emitSlow_op_new_object(Instruction*, Vector<SlowCaseEntry>::iterator&);
777         void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
778         void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
779         void emitSlow_op_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
780         void emitSlow_op_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
781         void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
782         void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
783         void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
784         void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
785         void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
786         void emitSlow_op_to_number(Instruction*, Vector<SlowCaseEntry>::iterator&);
787         void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
788         void emitSlow_op_urshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
789
790         void emit_op_resolve_scope(Instruction*);
791         void emit_op_get_from_scope(Instruction*);
792         void emit_op_put_to_scope(Instruction*);
793         void emitSlow_op_resolve_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
794         void emitSlow_op_get_from_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
795         void emitSlow_op_put_to_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
796
797         void emitRightShift(Instruction*, bool isUnsigned);
798         void emitRightShiftSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&, bool isUnsigned);
799
800         void emitVarInjectionCheck(bool needsVarInjectionChecks);
801         void emitResolveClosure(int dst, bool needsVarInjectionChecks, unsigned depth);
802         void emitLoadWithStructureCheck(int scope, Structure** structureSlot);
803         void emitGetGlobalProperty(uintptr_t* operandSlot);
804         void emitGetGlobalVar(uintptr_t operand);
805         void emitGetClosureVar(int scope, uintptr_t operand);
806         void emitPutGlobalProperty(uintptr_t* operandSlot, int value);
807         void emitPutGlobalVar(uintptr_t operand, int value);
808         void emitPutClosureVar(int scope, uintptr_t operand, int value);
809
810         void emitInitRegister(int dst);
811
812         void emitPutIntToCallFrameHeader(RegisterID from, JSStack::CallFrameHeaderEntry);
813         void emitGetFromCallFrameHeaderPtr(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
814         void emitGetFromCallFrameHeader32(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
815 #if USE(JSVALUE64)
816         void emitGetFromCallFrameHeader64(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
817 #endif
818
819         JSValue getConstantOperand(int src);
820         bool isOperandConstantImmediateInt(int src);
821         bool isOperandConstantImmediateChar(int src);
822
823         bool atJumpTarget();
824
825         Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
826         {
827             return iter++->from;
828         }
829         void linkSlowCase(Vector<SlowCaseEntry>::iterator& iter)
830         {
831             iter->from.link(this);
832             ++iter;
833         }
834         void linkDummySlowCase(Vector<SlowCaseEntry>::iterator& iter)
835         {
836             ASSERT(!iter->from.isSet());
837             ++iter;
838         }
839         void linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&, int virtualRegisterIndex);
840
841         Jump checkStructure(RegisterID reg, Structure* structure);
842
843         void restoreArgumentReferenceForTrampoline();
844         void updateTopCallFrame();
845
846         Call emitNakedCall(CodePtr function = CodePtr());
847
848         // Loads the character value of a single character string into dst.
849         void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
850         
851 #if ENABLE(DFG_JIT)
852         void emitEnterOptimizationCheck();
853 #else
854         void emitEnterOptimizationCheck() { }
855 #endif
856
857 #ifndef NDEBUG
858         void printBytecodeOperandTypes(int src1, int src2);
859 #endif
860
861 #if ENABLE(SAMPLING_FLAGS)
862         void setSamplingFlag(int32_t);
863         void clearSamplingFlag(int32_t);
864 #endif
865
866 #if ENABLE(SAMPLING_COUNTERS)
867         void emitCount(AbstractSamplingCounter&, int32_t = 1);
868 #endif
869
870 #if ENABLE(OPCODE_SAMPLING)
871         void sampleInstruction(Instruction*, bool = false);
872 #endif
873
874 #if ENABLE(CODEBLOCK_SAMPLING)
875         void sampleCodeBlock(CodeBlock*);
876 #else
877         void sampleCodeBlock(CodeBlock*) {}
878 #endif
879
880 #if ENABLE(DFG_JIT)
881         bool canBeOptimized() { return m_canBeOptimized; }
882         bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; }
883         bool shouldEmitProfiling() { return m_shouldEmitProfiling; }
884 #else
885         bool canBeOptimized() { return false; }
886         bool canBeOptimizedOrInlined() { return false; }
887         // Enables use of value profiler with tiered compilation turned off,
888         // in which case all code gets profiled.
889         bool shouldEmitProfiling() { return false; }
890 #endif
891
892         Interpreter* m_interpreter;
893
894         Vector<CallRecord> m_calls;
895         Vector<Label> m_labels;
896         Vector<PropertyStubCompilationInfo> m_propertyAccessCompilationInfo;
897         Vector<ByValCompilationInfo> m_byValCompilationInfo;
898         Vector<StructureStubCompilationInfo> m_callStructureStubCompilationInfo;
899         Vector<JumpTable> m_jmpTable;
900
901         unsigned m_bytecodeOffset;
902         Vector<SlowCaseEntry> m_slowCases;
903         Vector<SwitchRecord> m_switches;
904
905         unsigned m_propertyAccessInstructionIndex;
906         unsigned m_byValInstructionIndex;
907         unsigned m_callLinkInfoIndex;
908
909 #if USE(JSVALUE32_64)
910         unsigned m_jumpTargetIndex;
911         unsigned m_mappedBytecodeOffset;
912         int m_mappedVirtualRegisterIndex;
913         RegisterID m_mappedTag;
914         RegisterID m_mappedPayload;
915 #else
916         int m_lastResultBytecodeRegister;
917 #endif
918         unsigned m_jumpTargetsPosition;
919
920 #ifndef NDEBUG
921 #if defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL
922         Label m_uninterruptedInstructionSequenceBegin;
923         int m_uninterruptedConstantSequenceBegin;
924 #endif
925 #endif
926         OwnPtr<JITDisassembler> m_disassembler;
927         RefPtr<Profiler::Compilation> m_compilation;
928         WeakRandom m_randomGenerator;
929         static CodeRef stringGetByValStubGenerator(VM*);
930
931 #if ENABLE(VALUE_PROFILER)
932         bool m_canBeOptimized;
933         bool m_canBeOptimizedOrInlined;
934         bool m_shouldEmitProfiling;
935 #endif
936     } JIT_CLASS_ALIGNMENT;
937
938 } // namespace JSC
939
940 #endif // ENABLE(JIT)
941
942 #endif // JIT_h