68dee593778812344b45bc13410303c4c1c3f287
[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         // Add a call out from JIT code, without an exception check.
425         Call appendCall(const FunctionPtr& function)
426         {
427             Call functionCall = call();
428             m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
429             return functionCall;
430         }
431
432         void exceptionCheck(Jump jumpToHandler)
433         {
434             m_exceptionChecks.append(jumpToHandler);
435         }
436
437         void exceptionCheck()
438         {
439             m_exceptionChecks.append(emitExceptionCheck());
440         }
441
442         void exceptionCheckWithCallFrameRollback()
443         {
444             m_exceptionChecksWithCallFrameRollback.append(emitExceptionCheck());
445         }
446
447         void privateCompileExceptionHandlers();
448
449         static bool isDirectPutById(StructureStubInfo*);
450
451         void addSlowCase(Jump);
452         void addSlowCase(JumpList);
453         void addSlowCase();
454         void addJump(Jump, int);
455         void emitJumpSlowToHot(Jump, int);
456
457         void compileOpCall(OpcodeID, Instruction*, unsigned callLinkInfoIndex);
458         void compileOpCallSlowCase(OpcodeID, Instruction*, Vector<SlowCaseEntry>::iterator&, unsigned callLinkInfoIndex);
459         void compileLoadVarargs(Instruction*);
460         void compileCallEval(Instruction*);
461         void compileCallEvalSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&);
462         void emitPutCallResult(Instruction*);
463
464         enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
465         void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type);
466         bool isOperandConstantImmediateDouble(int src);
467         
468         void emitLoadDouble(int index, FPRegisterID value);
469         void emitLoadInt32ToDouble(int index, FPRegisterID value);
470         Jump emitJumpIfNotObject(RegisterID structureReg);
471
472         Jump addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, RegisterID scratch);
473         void addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, JumpList& failureCases, RegisterID scratch);
474         void testPrototype(JSValue, JumpList& failureCases, StructureStubInfo*);
475
476         enum WriteBarrierMode { UnconditionalWriteBarrier, ShouldFilterImmediates };
477         // value register in write barrier is used before any scratch registers
478         // so may safely be the same as either of the scratch registers.
479         void emitWriteBarrier(RegisterID owner, RegisterID valueTag, RegisterID scratch, RegisterID scratch2, WriteBarrierMode, WriteBarrierUseKind);
480         void emitWriteBarrier(JSCell* owner, RegisterID value, RegisterID scratch, WriteBarrierMode, WriteBarrierUseKind);
481
482         template<typename StructureType> // StructureType can be RegisterID or ImmPtr.
483         void emitAllocateJSObject(RegisterID allocator, StructureType, RegisterID result, RegisterID scratch);
484         
485 #if ENABLE(VALUE_PROFILER)
486         // This assumes that the value to profile is in regT0 and that regT3 is available for
487         // scratch.
488         void emitValueProfilingSite(ValueProfile*, RegisterID);
489         void emitValueProfilingSite(unsigned bytecodeOffset, RegisterID);
490         void emitValueProfilingSite(RegisterID);
491 #else
492         void emitValueProfilingSite(unsigned, RegisterID) { }
493         void emitValueProfilingSite(RegisterID) { }
494 #endif
495         void emitArrayProfilingSite(RegisterID structureAndIndexingType, RegisterID scratch, ArrayProfile*);
496         void emitArrayProfilingSiteForBytecodeIndex(RegisterID structureAndIndexingType, RegisterID scratch, unsigned bytecodeIndex);
497         void emitArrayProfileStoreToHoleSpecialCase(ArrayProfile*);
498         void emitArrayProfileOutOfBoundsSpecialCase(ArrayProfile*);
499         
500         JITArrayMode chooseArrayMode(ArrayProfile*);
501         
502         // Property is in regT1, base is in regT0. regT2 contains indexing type.
503         // Property is int-checked and zero extended. Base is cell checked.
504         // Structure is already profiled. Returns the slow cases. Fall-through
505         // case contains result in regT0, and it is not yet profiled.
506         JumpList emitInt32GetByVal(Instruction* instruction, PatchableJump& badType) { return emitContiguousGetByVal(instruction, badType, Int32Shape); }
507         JumpList emitDoubleGetByVal(Instruction*, PatchableJump& badType);
508         JumpList emitContiguousGetByVal(Instruction*, PatchableJump& badType, IndexingType expectedShape = ContiguousShape);
509         JumpList emitArrayStorageGetByVal(Instruction*, PatchableJump& badType);
510         JumpList emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
511         JumpList emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
512         
513         // Property is in regT0, base is in regT0. regT2 contains indecing type.
514         // The value to store is not yet loaded. Property is int-checked and
515         // zero-extended. Base is cell checked. Structure is already profiled.
516         // returns the slow cases.
517         JumpList emitInt32PutByVal(Instruction* currentInstruction, PatchableJump& badType)
518         {
519             return emitGenericContiguousPutByVal(currentInstruction, badType, Int32Shape);
520         }
521         JumpList emitDoublePutByVal(Instruction* currentInstruction, PatchableJump& badType)
522         {
523             return emitGenericContiguousPutByVal(currentInstruction, badType, DoubleShape);
524         }
525         JumpList emitContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType)
526         {
527             return emitGenericContiguousPutByVal(currentInstruction, badType);
528         }
529         JumpList emitGenericContiguousPutByVal(Instruction*, PatchableJump& badType, IndexingType indexingShape = ContiguousShape);
530         JumpList emitArrayStoragePutByVal(Instruction*, PatchableJump& badType);
531         JumpList emitIntTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
532         JumpList emitFloatTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
533         
534         enum FinalObjectMode { MayBeFinal, KnownNotFinal };
535
536 #if USE(JSVALUE32_64)
537         bool getOperandConstantImmediateInt(int op1, int op2, int& op, int32_t& constant);
538
539         void emitLoadTag(int index, RegisterID tag);
540         void emitLoadPayload(int index, RegisterID payload);
541
542         void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload);
543         void emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
544         void emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2);
545
546         void emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
547         void emitStore(int index, const JSValue constant, RegisterID base = callFrameRegister);
548         void emitStoreInt32(int index, RegisterID payload, bool indexIsInt32 = false);
549         void emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32 = false);
550         void emitStoreAndMapInt32(int index, RegisterID tag, RegisterID payload, bool indexIsInt32, size_t opcodeLength);
551         void emitStoreCell(int index, RegisterID payload, bool indexIsCell = false);
552         void emitStoreBool(int index, RegisterID payload, bool indexIsBool = false);
553         void emitStoreDouble(int index, FPRegisterID value);
554
555         bool isLabeled(unsigned bytecodeOffset);
556         void map(unsigned bytecodeOffset, int virtualRegisterIndex, RegisterID tag, RegisterID payload);
557         void unmap(RegisterID);
558         void unmap();
559         bool isMapped(int virtualRegisterIndex);
560         bool getMappedPayload(int virtualRegisterIndex, RegisterID& payload);
561         bool getMappedTag(int virtualRegisterIndex, RegisterID& tag);
562         
563         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex);
564         void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag);
565
566         void compileGetByIdHotPath(const Identifier*);
567         void compileGetByIdSlowCase(int resultVReg, int baseVReg, const Identifier*, Vector<SlowCaseEntry>::iterator&);
568         void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
569         void compileGetDirectOffset(JSObject* base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
570         void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, RegisterID offset, FinalObjectMode = MayBeFinal);
571         void compilePutDirectOffset(RegisterID base, RegisterID valueTag, RegisterID valuePayload, PropertyOffset cachedOffset);
572
573         // Arithmetic opcode helpers
574         void emitAdd32Constant(int dst, int op, int32_t constant, ResultType opType);
575         void emitSub32Constant(int dst, int op, int32_t constant, ResultType opType);
576         void emitBinaryDoubleOp(OpcodeID, int dst, int op1, int op2, OperandTypes, JumpList& notInt32Op1, JumpList& notInt32Op2, bool op1IsInRegisters = true, bool op2IsInRegisters = true);
577
578 #if CPU(ARM_TRADITIONAL)
579         // sequenceOpCall
580         static const int sequenceOpCallInstructionSpace = 12;
581         static const int sequenceOpCallConstantSpace = 2;
582         // sequenceGetByIdHotPath
583         static const int sequenceGetByIdHotPathInstructionSpace = 36;
584         static const int sequenceGetByIdHotPathConstantSpace = 4;
585         // sequenceGetByIdSlowCase
586         static const int sequenceGetByIdSlowCaseInstructionSpace = 80;
587         static const int sequenceGetByIdSlowCaseConstantSpace = 4;
588         // sequencePutById
589         static const int sequencePutByIdInstructionSpace = 36;
590         static const int sequencePutByIdConstantSpace = 4;
591 #elif CPU(SH4)
592         // sequenceOpCall
593         static const int sequenceOpCallInstructionSpace = 12;
594         static const int sequenceOpCallConstantSpace = 2;
595         // sequenceGetByIdHotPath
596         static const int sequenceGetByIdHotPathInstructionSpace = 36;
597         static const int sequenceGetByIdHotPathConstantSpace = 5;
598         // sequenceGetByIdSlowCase
599         static const int sequenceGetByIdSlowCaseInstructionSpace = 38;
600         static const int sequenceGetByIdSlowCaseConstantSpace = 4;
601         // sequencePutById
602         static const int sequencePutByIdInstructionSpace = 36;
603         static const int sequencePutByIdConstantSpace = 5;
604 #endif
605
606 #else // USE(JSVALUE32_64)
607         /* This function is deprecated. */
608         void emitGetJITStubArg(int argumentNumber, RegisterID dst);
609
610         void emitGetVirtualRegister(int src, RegisterID dst);
611         void emitGetVirtualRegister(VirtualRegister src, RegisterID dst);
612         void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2);
613         void emitGetVirtualRegisters(VirtualRegister src1, RegisterID dst1, VirtualRegister src2, RegisterID dst2);
614         void emitPutVirtualRegister(int dst, RegisterID from = regT0);
615         void emitPutVirtualRegister(VirtualRegister dst, RegisterID from = regT0);
616         void emitStoreCell(int dst, RegisterID payload, bool /* only used in JSValue32_64 */ = false)
617         {
618             emitPutVirtualRegister(dst, payload);
619         }
620
621         int32_t getConstantOperandImmediateInt(int src);
622
623         void killLastResultRegister();
624
625         Jump emitJumpIfJSCell(RegisterID);
626         Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
627         void emitJumpSlowCaseIfJSCell(RegisterID);
628         void emitJumpSlowCaseIfNotJSCell(RegisterID);
629         void emitJumpSlowCaseIfNotJSCell(RegisterID, int VReg);
630         Jump emitJumpIfImmediateInteger(RegisterID);
631         Jump emitJumpIfNotImmediateInteger(RegisterID);
632         Jump emitJumpIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
633         void emitJumpSlowCaseIfNotImmediateInteger(RegisterID);
634         void emitJumpSlowCaseIfNotImmediateNumber(RegisterID);
635         void emitJumpSlowCaseIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
636
637         void emitFastArithReTagImmediate(RegisterID src, RegisterID dest);
638
639         void emitTagAsBoolImmediate(RegisterID reg);
640         void compileBinaryArithOp(OpcodeID, int dst, int src1, int src2, OperandTypes opi);
641         void compileBinaryArithOpSlowCase(Instruction*, OpcodeID, Vector<SlowCaseEntry>::iterator&, int dst, int src1, int src2, OperandTypes, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase);
642
643         void compileGetByIdHotPath(int baseVReg, const Identifier*);
644         void compileGetByIdSlowCase(int resultVReg, int baseVReg, const Identifier*, Vector<SlowCaseEntry>::iterator&);
645         void compileGetDirectOffset(RegisterID base, RegisterID result, PropertyOffset cachedOffset);
646         void compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffset cachedOffset);
647         void compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID offset, RegisterID scratch, FinalObjectMode = MayBeFinal);
648         void compilePutDirectOffset(RegisterID base, RegisterID value, PropertyOffset cachedOffset);
649
650 #endif // USE(JSVALUE32_64)
651
652 #if (defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL)
653 #define BEGIN_UNINTERRUPTED_SEQUENCE(name) do { beginUninterruptedSequence(name ## InstructionSpace, name ## ConstantSpace); } while (false)
654 #define END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, dst) do { endUninterruptedSequence(name ## InstructionSpace, name ## ConstantSpace, dst); } while (false)
655 #define END_UNINTERRUPTED_SEQUENCE(name) END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, 0)
656
657         void beginUninterruptedSequence(int, int);
658         void endUninterruptedSequence(int, int, int);
659
660 #else
661 #define BEGIN_UNINTERRUPTED_SEQUENCE(name)
662 #define END_UNINTERRUPTED_SEQUENCE(name)
663 #define END_UNINTERRUPTED_SEQUENCE_FOR_PUT(name, dst)
664 #endif
665
666         void emit_compareAndJump(OpcodeID, int op1, int op2, unsigned target, RelationalCondition);
667         void emit_compareAndJumpSlow(int op1, int op2, unsigned target, DoubleCondition, size_t (JIT_OPERATION *operation)(ExecState*, EncodedJSValue, EncodedJSValue), bool invert, Vector<SlowCaseEntry>::iterator&);
668
669         void emit_op_add(Instruction*);
670         void emit_op_bitand(Instruction*);
671         void emit_op_bitor(Instruction*);
672         void emit_op_bitxor(Instruction*);
673         void emit_op_call(Instruction*);
674         void emit_op_call_eval(Instruction*);
675         void emit_op_call_varargs(Instruction*);
676         void emit_op_catch(Instruction*);
677         void emit_op_construct(Instruction*);
678         void emit_op_get_callee(Instruction*);
679         void emit_op_create_this(Instruction*);
680         void emit_op_to_this(Instruction*);
681         void emit_op_create_arguments(Instruction*);
682         void emit_op_debug(Instruction*);
683         void emit_op_del_by_id(Instruction*);
684         void emit_op_div(Instruction*);
685         void emit_op_end(Instruction*);
686         void emit_op_enter(Instruction*);
687         void emit_op_create_activation(Instruction*);
688         void emit_op_eq(Instruction*);
689         void emit_op_eq_null(Instruction*);
690         void emit_op_get_by_id(Instruction*);
691         void emit_op_get_arguments_length(Instruction*);
692         void emit_op_get_by_val(Instruction*);
693         void emit_op_get_argument_by_val(Instruction*);
694         void emit_op_get_by_pname(Instruction*);
695         void emit_op_init_lazy_reg(Instruction*);
696         void emit_op_check_has_instance(Instruction*);
697         void emit_op_instanceof(Instruction*);
698         void emit_op_is_undefined(Instruction*);
699         void emit_op_is_boolean(Instruction*);
700         void emit_op_is_number(Instruction*);
701         void emit_op_is_string(Instruction*);
702         void emit_op_jeq_null(Instruction*);
703         void emit_op_jfalse(Instruction*);
704         void emit_op_jmp(Instruction*);
705         void emit_op_jneq_null(Instruction*);
706         void emit_op_jneq_ptr(Instruction*);
707         void emit_op_jless(Instruction*);
708         void emit_op_jlesseq(Instruction*);
709         void emit_op_jgreater(Instruction*);
710         void emit_op_jgreatereq(Instruction*);
711         void emit_op_jnless(Instruction*);
712         void emit_op_jnlesseq(Instruction*);
713         void emit_op_jngreater(Instruction*);
714         void emit_op_jngreatereq(Instruction*);
715         void emit_op_jtrue(Instruction*);
716         void emit_op_loop_hint(Instruction*);
717         void emit_op_lshift(Instruction*);
718         void emit_op_mod(Instruction*);
719         void emit_op_mov(Instruction*);
720         void emit_op_mul(Instruction*);
721         void emit_op_negate(Instruction*);
722         void emit_op_neq(Instruction*);
723         void emit_op_neq_null(Instruction*);
724         void emit_op_new_array(Instruction*);
725         void emit_op_new_array_with_size(Instruction*);
726         void emit_op_new_array_buffer(Instruction*);
727         void emit_op_new_func(Instruction*);
728         void emit_op_new_func_exp(Instruction*);
729         void emit_op_new_object(Instruction*);
730         void emit_op_new_regexp(Instruction*);
731         void emit_op_get_pnames(Instruction*);
732         void emit_op_next_pname(Instruction*);
733         void emit_op_not(Instruction*);
734         void emit_op_nstricteq(Instruction*);
735         void emit_op_pop_scope(Instruction*);
736         void emit_op_dec(Instruction*);
737         void emit_op_inc(Instruction*);
738         void emit_op_profile_did_call(Instruction*);
739         void emit_op_profile_will_call(Instruction*);
740         void emit_op_push_name_scope(Instruction*);
741         void emit_op_push_with_scope(Instruction*);
742         void emit_op_put_by_id(Instruction*);
743         void emit_op_put_by_index(Instruction*);
744         void emit_op_put_by_val(Instruction*);
745         void emit_op_put_getter_setter(Instruction*);
746         void emit_op_init_global_const(Instruction*);
747         void emit_op_ret(Instruction*);
748         void emit_op_ret_object_or_this(Instruction*);
749         void emit_op_rshift(Instruction*);
750         void emit_op_strcat(Instruction*);
751         void emit_op_stricteq(Instruction*);
752         void emit_op_sub(Instruction*);
753         void emit_op_switch_char(Instruction*);
754         void emit_op_switch_imm(Instruction*);
755         void emit_op_switch_string(Instruction*);
756         void emit_op_tear_off_activation(Instruction*);
757         void emit_op_tear_off_arguments(Instruction*);
758         void emit_op_throw(Instruction*);
759         void emit_op_throw_static_error(Instruction*);
760         void emit_op_to_number(Instruction*);
761         void emit_op_to_primitive(Instruction*);
762         void emit_op_unexpected_load(Instruction*);
763         void emit_op_urshift(Instruction*);
764
765         void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
766         void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
767         void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
768         void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
769         void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
770         void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
771         void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
772         void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
773         void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
774         void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
775         void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
776         void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
777         void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
778         void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
779         void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
780         void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
781         void emitSlow_op_get_argument_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
782         void emitSlow_op_get_by_pname(Instruction*, Vector<SlowCaseEntry>::iterator&);
783         void emitSlow_op_check_has_instance(Instruction*, Vector<SlowCaseEntry>::iterator&);
784         void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
785         void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
786         void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
787         void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
788         void emitSlow_op_jgreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
789         void emitSlow_op_jgreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
790         void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
791         void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
792         void emitSlow_op_jngreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
793         void emitSlow_op_jngreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
794         void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
795         void emitSlow_op_loop_hint(Instruction*, Vector<SlowCaseEntry>::iterator&);
796         void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
797         void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
798         void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
799         void emitSlow_op_negate(Instruction*, Vector<SlowCaseEntry>::iterator&);
800         void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
801         void emitSlow_op_new_object(Instruction*, Vector<SlowCaseEntry>::iterator&);
802         void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
803         void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
804         void emitSlow_op_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
805         void emitSlow_op_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
806         void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
807         void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
808         void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
809         void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
810         void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
811         void emitSlow_op_to_number(Instruction*, Vector<SlowCaseEntry>::iterator&);
812         void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
813         void emitSlow_op_urshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
814
815         void emit_op_resolve_scope(Instruction*);
816         void emit_op_get_from_scope(Instruction*);
817         void emit_op_put_to_scope(Instruction*);
818         void emitSlow_op_resolve_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
819         void emitSlow_op_get_from_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
820         void emitSlow_op_put_to_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
821
822         void emitRightShift(Instruction*, bool isUnsigned);
823         void emitRightShiftSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&, bool isUnsigned);
824
825         void emitVarInjectionCheck(bool needsVarInjectionChecks);
826         void emitResolveClosure(int dst, bool needsVarInjectionChecks, unsigned depth);
827         void emitLoadWithStructureCheck(int scope, Structure** structureSlot);
828         void emitGetGlobalProperty(uintptr_t* operandSlot);
829         void emitGetGlobalVar(uintptr_t operand);
830         void emitGetClosureVar(int scope, uintptr_t operand);
831         void emitPutGlobalProperty(uintptr_t* operandSlot, int value);
832         void emitPutGlobalVar(uintptr_t operand, int value);
833         void emitPutClosureVar(int scope, uintptr_t operand, int value);
834
835         void emitInitRegister(int dst);
836
837         void emitPutIntToCallFrameHeader(RegisterID from, JSStack::CallFrameHeaderEntry);
838         void emitGetFromCallFrameHeaderPtr(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
839         void emitGetFromCallFrameHeader32(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
840 #if USE(JSVALUE64)
841         void emitGetFromCallFrameHeader64(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
842 #endif
843
844         JSValue getConstantOperand(int src);
845         bool isOperandConstantImmediateInt(int src);
846         bool isOperandConstantImmediateChar(int src);
847
848         bool atJumpTarget();
849
850         Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
851         {
852             return iter++->from;
853         }
854         void linkSlowCase(Vector<SlowCaseEntry>::iterator& iter)
855         {
856             iter->from.link(this);
857             ++iter;
858         }
859         void linkDummySlowCase(Vector<SlowCaseEntry>::iterator& iter)
860         {
861             ASSERT(!iter->from.isSet());
862             ++iter;
863         }
864         void linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&, int virtualRegisterIndex);
865
866         MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr&);
867         MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr&);
868         MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr&, int);
869         MacroAssembler::Call callOperation(J_JITOperation_E, int);
870         MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
871         MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
872         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID);
873         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID);
874         MacroAssembler::Call callOperation(S_JITOperation_EOJss, RegisterID, RegisterID);
875         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(J_JITOperation_E);
876         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb, CodeBlock*);
877         MacroAssembler::Call callOperationWithCallFrameRollbackOnException(Z_JITOperation_E);
878 #if USE(JSVALUE32_64)
879         MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID, RegisterID);
880         MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID, RegisterID, RegisterID);
881 #endif
882
883         Jump checkStructure(RegisterID reg, Structure* structure);
884
885         void restoreArgumentReferenceForTrampoline();
886         void updateTopCallFrame();
887
888         Call emitNakedCall(CodePtr function = CodePtr());
889
890         // Loads the character value of a single character string into dst.
891         void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
892         
893 #if ENABLE(DFG_JIT)
894         void emitEnterOptimizationCheck();
895 #else
896         void emitEnterOptimizationCheck() { }
897 #endif
898
899 #ifndef NDEBUG
900         void printBytecodeOperandTypes(int src1, int src2);
901 #endif
902
903 #if ENABLE(SAMPLING_FLAGS)
904         void setSamplingFlag(int32_t);
905         void clearSamplingFlag(int32_t);
906 #endif
907
908 #if ENABLE(SAMPLING_COUNTERS)
909         void emitCount(AbstractSamplingCounter&, int32_t = 1);
910 #endif
911
912 #if ENABLE(OPCODE_SAMPLING)
913         void sampleInstruction(Instruction*, bool = false);
914 #endif
915
916 #if ENABLE(CODEBLOCK_SAMPLING)
917         void sampleCodeBlock(CodeBlock*);
918 #else
919         void sampleCodeBlock(CodeBlock*) {}
920 #endif
921
922 #if ENABLE(DFG_JIT)
923         bool canBeOptimized() { return m_canBeOptimized; }
924         bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; }
925         bool shouldEmitProfiling() { return m_shouldEmitProfiling; }
926 #else
927         bool canBeOptimized() { return false; }
928         bool canBeOptimizedOrInlined() { return false; }
929         // Enables use of value profiler with tiered compilation turned off,
930         // in which case all code gets profiled.
931         bool shouldEmitProfiling() { return false; }
932 #endif
933
934         Interpreter* m_interpreter;
935
936         Vector<CallRecord> m_calls;
937         Vector<Label> m_labels;
938         Vector<PropertyStubCompilationInfo> m_propertyAccessCompilationInfo;
939         Vector<ByValCompilationInfo> m_byValCompilationInfo;
940         Vector<StructureStubCompilationInfo> m_callStructureStubCompilationInfo;
941         Vector<JumpTable> m_jmpTable;
942
943         unsigned m_bytecodeOffset;
944         Vector<SlowCaseEntry> m_slowCases;
945         Vector<SwitchRecord> m_switches;
946
947         JumpList m_exceptionChecks;
948         JumpList m_exceptionChecksWithCallFrameRollback;
949
950         unsigned m_propertyAccessInstructionIndex;
951         unsigned m_byValInstructionIndex;
952         unsigned m_callLinkInfoIndex;
953
954 #if USE(JSVALUE32_64)
955         unsigned m_jumpTargetIndex;
956         unsigned m_mappedBytecodeOffset;
957         int m_mappedVirtualRegisterIndex;
958         RegisterID m_mappedTag;
959         RegisterID m_mappedPayload;
960 #else
961         int m_lastResultBytecodeRegister;
962 #endif
963         unsigned m_jumpTargetsPosition;
964
965 #ifndef NDEBUG
966 #if defined(ASSEMBLER_HAS_CONSTANT_POOL) && ASSEMBLER_HAS_CONSTANT_POOL
967         Label m_uninterruptedInstructionSequenceBegin;
968         int m_uninterruptedConstantSequenceBegin;
969 #endif
970 #endif
971         OwnPtr<JITDisassembler> m_disassembler;
972         RefPtr<Profiler::Compilation> m_compilation;
973         WeakRandom m_randomGenerator;
974         static CodeRef stringGetByValStubGenerator(VM*);
975
976 #if ENABLE(VALUE_PROFILER)
977         bool m_canBeOptimized;
978         bool m_canBeOptimizedOrInlined;
979         bool m_shouldEmitProfiling;
980 #endif
981     } JIT_CLASS_ALIGNMENT;
982
983 } // namespace JSC
984
985 #endif // ENABLE(JIT)
986
987 #endif // JIT_h