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