2008-12-11 Gavin Barraclough <barraclough@apple.com>
[WebKit-https.git] / JavaScriptCore / jit / JIT.h
1 /*
2  * Copyright (C) 2008 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 #include <wtf/Platform.h>
30
31 #if ENABLE(JIT)
32
33 #define WTF_USE_CTI_REPATCH_PIC 1
34
35 #include "Interpreter.h"
36 #include "Opcode.h"
37 #include "RegisterFile.h"
38 #include "MacroAssembler.h"
39 #include "Profiler.h"
40 #include <wtf/AlwaysInline.h>
41 #include <wtf/Vector.h>
42
43 #define CTI_ARGS_code 0x0C
44 #define CTI_ARGS_registerFile 0x0D
45 #define CTI_ARGS_callFrame 0x0E
46 #define CTI_ARGS_exception 0x0F
47 #define CTI_ARGS_profilerReference 0x10
48 #define CTI_ARGS_globalData 0x11
49
50 #define ARG_callFrame static_cast<CallFrame*>(ARGS[CTI_ARGS_callFrame])
51 #define ARG_registerFile static_cast<RegisterFile*>(ARGS[CTI_ARGS_registerFile])
52 #define ARG_exception static_cast<JSValue**>(ARGS[CTI_ARGS_exception])
53 #define ARG_profilerReference static_cast<Profiler**>(ARGS[CTI_ARGS_profilerReference])
54 #define ARG_globalData static_cast<JSGlobalData*>(ARGS[CTI_ARGS_globalData])
55
56 #define ARG_setCallFrame(newCallFrame) (ARGS[CTI_ARGS_callFrame] = (newCallFrame))
57
58 #define ARG_src1 static_cast<JSValue*>(ARGS[1])
59 #define ARG_src2 static_cast<JSValue*>(ARGS[2])
60 #define ARG_src3 static_cast<JSValue*>(ARGS[3])
61 #define ARG_src4 static_cast<JSValue*>(ARGS[4])
62 #define ARG_src5 static_cast<JSValue*>(ARGS[5])
63 #define ARG_id1 static_cast<Identifier*>(ARGS[1])
64 #define ARG_id2 static_cast<Identifier*>(ARGS[2])
65 #define ARG_id3 static_cast<Identifier*>(ARGS[3])
66 #define ARG_id4 static_cast<Identifier*>(ARGS[4])
67 #define ARG_int1 reinterpret_cast<intptr_t>(ARGS[1])
68 #define ARG_int2 reinterpret_cast<intptr_t>(ARGS[2])
69 #define ARG_int3 reinterpret_cast<intptr_t>(ARGS[3])
70 #define ARG_int4 reinterpret_cast<intptr_t>(ARGS[4])
71 #define ARG_int5 reinterpret_cast<intptr_t>(ARGS[5])
72 #define ARG_int6 reinterpret_cast<intptr_t>(ARGS[6])
73 #define ARG_func1 static_cast<FuncDeclNode*>(ARGS[1])
74 #define ARG_funcexp1 static_cast<FuncExprNode*>(ARGS[1])
75 #define ARG_regexp1 static_cast<RegExp*>(ARGS[1])
76 #define ARG_pni1 static_cast<JSPropertyNameIterator*>(ARGS[1])
77 #define ARG_instr1 static_cast<Instruction*>(ARGS[1])
78 #define ARG_instr2 static_cast<Instruction*>(ARGS[2])
79 #define ARG_instr3 static_cast<Instruction*>(ARGS[3])
80 #define ARG_instr4 static_cast<Instruction*>(ARGS[4])
81 #define ARG_instr5 static_cast<Instruction*>(ARGS[5])
82 #define ARG_instr6 static_cast<Instruction*>(ARGS[6])
83 #define ARG_returnAddress2 static_cast<void*>(ARGS[2])
84 #define ARG_codeBlock4 static_cast<CodeBlock*>(ARGS[4])
85
86 #define CTI_RETURN_ADDRESS_SLOT (ARGS[-1])
87
88 namespace JSC {
89
90     class CodeBlock;
91     class JSPropertyNameIterator;
92     class Interpreter;
93     class Register;
94     class RegisterFile;
95     class ScopeChainNode;
96     class SimpleJumpTable;
97     class StringJumpTable;
98     class StructureChain;
99
100     struct CallLinkInfo;
101     struct Instruction;
102     struct OperandTypes;
103     struct PolymorphicAccessStructureList;
104     struct StructureStubInfo;
105
106     typedef JSValue* (SFX_CALL *CTIHelper_j)(CTI_ARGS);
107     typedef JSObject* (SFX_CALL *CTIHelper_o)(CTI_ARGS);
108     typedef JSPropertyNameIterator* (SFX_CALL *CTIHelper_p)(CTI_ARGS);
109     typedef void (SFX_CALL *CTIHelper_v)(CTI_ARGS);
110     typedef void* (SFX_CALL *CTIHelper_s)(CTI_ARGS);
111     typedef int (SFX_CALL *CTIHelper_b)(CTI_ARGS);
112     typedef VoidPtrPair (SFX_CALL *CTIHelper_2)(CTI_ARGS);
113
114     struct CallRecord {
115         typedef X86Assembler::JmpSrc JmpSrc;
116
117         JmpSrc from;
118         void* to;
119         unsigned bytecodeIndex;
120
121         CallRecord()
122         {
123         }
124
125         CallRecord(JmpSrc f, CTIHelper_j t, unsigned i)
126             : from(f)
127             , to(reinterpret_cast<void*>(t))
128             , bytecodeIndex(i)
129         {
130         }
131
132         CallRecord(JmpSrc f, CTIHelper_o t, unsigned i)
133             : from(f)
134             , to(reinterpret_cast<void*>(t))
135             , bytecodeIndex(i)
136         {
137         }
138
139         CallRecord(JmpSrc f, CTIHelper_p t, unsigned i)
140             : from(f)
141             , to(reinterpret_cast<void*>(t))
142             , bytecodeIndex(i)
143         {
144         }
145         
146         CallRecord(JmpSrc f, CTIHelper_v t, unsigned i)
147             : from(f)
148             , to(reinterpret_cast<void*>(t))
149             , bytecodeIndex(i)
150         {
151         }
152         
153         CallRecord(JmpSrc f, CTIHelper_s t, unsigned i)
154             : from(f)
155             , to(reinterpret_cast<void*>(t))
156             , bytecodeIndex(i)
157         {
158         }
159         
160         CallRecord(JmpSrc f, CTIHelper_b t, unsigned i)
161             : from(f)
162             , to(reinterpret_cast<void*>(t))
163             , bytecodeIndex(i)
164         {
165         }
166
167         CallRecord(JmpSrc f, CTIHelper_2 t, unsigned i)
168             : from(f)
169             , to(reinterpret_cast<void*>(t))
170             , bytecodeIndex(i)
171         {
172         }
173
174         CallRecord(JmpSrc f, unsigned i)
175             : from(f)
176             , to(0)
177             , bytecodeIndex(i)
178         {
179         }
180     };
181
182     struct JmpTable {
183         typedef X86Assembler::JmpSrc JmpSrc;
184
185         JmpSrc from;
186         unsigned to;
187         
188         JmpTable(JmpSrc f, unsigned t)
189             : from(f)
190             , to(t)
191         {
192         }
193     };
194
195     struct SlowCaseEntry {
196         typedef X86Assembler::JmpSrc JmpSrc;
197
198         JmpSrc from;
199         unsigned to;
200         unsigned hint;
201         
202         SlowCaseEntry(JmpSrc f, unsigned t, unsigned h = 0)
203             : from(f)
204             , to(t)
205             , hint(h)
206         {
207         }
208     };
209
210     struct SwitchRecord {
211         enum Type {
212             Immediate,
213             Character,
214             String
215         };
216
217         Type type;
218
219         union {
220             SimpleJumpTable* simpleJumpTable;
221             StringJumpTable* stringJumpTable;
222         } jumpTable;
223
224         unsigned bytecodeIndex;
225         unsigned defaultOffset;
226
227         SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeIndex, unsigned defaultOffset, Type type)
228             : type(type)
229             , bytecodeIndex(bytecodeIndex)
230             , defaultOffset(defaultOffset)
231         {
232             this->jumpTable.simpleJumpTable = jumpTable;
233         }
234
235         SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeIndex, unsigned defaultOffset)
236             : type(String)
237             , bytecodeIndex(bytecodeIndex)
238             , defaultOffset(defaultOffset)
239         {
240             this->jumpTable.stringJumpTable = jumpTable;
241         }
242     };
243
244     struct StructureStubCompilationInfo {
245         typedef X86Assembler::JmpSrc JmpSrc;
246         typedef X86Assembler::JmpDst JmpDst;
247
248         JmpSrc callReturnLocation;
249         JmpDst hotPathBegin;
250         JmpSrc hotPathOther;
251         JmpDst coldPathOther;
252     };
253
254     extern "C" {
255         JSValue* ctiTrampoline(void* code, RegisterFile*, CallFrame*, JSValue** exception, Profiler**, JSGlobalData*);
256         void ctiVMThrowTrampoline();
257     };
258
259     void ctiSetReturnAddress(void** where, void* what);
260     void ctiRepatchCallByReturnAddress(void* where, void* what);
261
262     class JIT : private MacroAssembler {
263         using MacroAssembler::Jump;
264         using MacroAssembler::JumpList;
265         using MacroAssembler::Label;
266
267         typedef X86Assembler::RegisterID RegisterID;
268         typedef X86Assembler::XMMRegisterID XMMRegisterID;
269         typedef X86Assembler::JmpSrc JmpSrc;
270         typedef X86Assembler::JmpDst JmpDst;
271
272         static const RegisterID callFrameRegister = X86::edi;
273
274         static const int repatchGetByIdDefaultStructure = -1;
275         // Magic number - initial offset cannot be representable as a signed 8bit value, or the X86Assembler
276         // will compress the displacement, and we may not be able to fit a repatched offset.
277         static const int repatchGetByIdDefaultOffset = 256;
278
279         // These architecture specific value are used to enable repatching - see comment on op_put_by_id.
280         static const int repatchOffsetPutByIdStructure = 7;
281         static const int repatchOffsetPutByIdPropertyMapOffset = 22;
282         // These architecture specific value are used to enable repatching - see comment on op_get_by_id.
283         static const int repatchOffsetGetByIdStructure = 7;
284         static const int repatchOffsetGetByIdBranchToSlowCase = 13;
285         static const int repatchOffsetGetByIdPropertyMapOffset = 22;
286 #if ENABLE(OPCODE_SAMPLING)
287         static const int repatchOffsetGetByIdSlowCaseCall = 27 + 4;
288 #else
289         static const int repatchOffsetGetByIdSlowCaseCall = 17 + 4;
290 #endif
291         static const int repatchOffsetOpCallCall = 6;
292
293     public:
294         static void compile(JSGlobalData* globalData, CodeBlock* codeBlock)
295         {
296             JIT jit(globalData, codeBlock);
297             jit.privateCompile();
298         }
299
300         static void compileGetByIdSelf(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, void* returnAddress)
301         {
302             JIT jit(globalData, codeBlock);
303             jit.privateCompileGetByIdSelf(stubInfo, structure, cachedOffset, returnAddress);
304         }
305
306         static void compileGetByIdProto(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, Structure* prototypeStructure, size_t cachedOffset, void* returnAddress)
307         {
308             JIT jit(globalData, codeBlock);
309             jit.privateCompileGetByIdProto(stubInfo, structure, prototypeStructure, cachedOffset, returnAddress, callFrame);
310         }
311
312 #if USE(CTI_REPATCH_PIC)
313         static void compileGetByIdSelfList(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* polymorphicStructures, int currentIndex, Structure* structure, size_t cachedOffset)
314         {
315             JIT jit(globalData, codeBlock);
316             jit.privateCompileGetByIdSelfList(stubInfo, polymorphicStructures, currentIndex, structure, cachedOffset);
317         }
318         static void compileGetByIdProtoList(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructureList, int currentIndex, Structure* structure, Structure* prototypeStructure, size_t cachedOffset)
319         {
320             JIT jit(globalData, codeBlock);
321             jit.privateCompileGetByIdProtoList(stubInfo, prototypeStructureList, currentIndex, structure, prototypeStructure, cachedOffset, callFrame);
322         }
323         static void compileGetByIdChainList(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructureList, int currentIndex, Structure* structure, StructureChain* chain, size_t count, size_t cachedOffset)
324         {
325             JIT jit(globalData, codeBlock);
326             jit.privateCompileGetByIdChainList(stubInfo, prototypeStructureList, currentIndex, structure, chain, count, cachedOffset, callFrame);
327         }
328 #endif
329
330         static void compileGetByIdChain(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, StructureChain* chain, size_t count, size_t cachedOffset, void* returnAddress)
331         {
332             JIT jit(globalData, codeBlock);
333             jit.privateCompileGetByIdChain(stubInfo, structure, chain, count, cachedOffset, returnAddress, callFrame);
334         }
335
336         static void compilePutByIdReplace(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, void* returnAddress)
337         {
338             JIT jit(globalData, codeBlock);
339             jit.privateCompilePutByIdReplace(stubInfo, structure, cachedOffset, returnAddress);
340         }
341         
342         static void compilePutByIdTransition(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, size_t cachedOffset, StructureChain* chain, void* returnAddress)
343         {
344             JIT jit(globalData, codeBlock);
345             jit.privateCompilePutByIdTransition(stubInfo, oldStructure, newStructure, cachedOffset, chain, returnAddress);
346         }
347
348         static void compileCTIMachineTrampolines(JSGlobalData* globalData)
349         {
350             JIT jit(globalData);
351             jit.privateCompileCTIMachineTrampolines();
352         }
353
354         static void patchGetByIdSelf(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
355         static void patchPutByIdReplace(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
356
357         static void compilePatchGetArrayLength(JSGlobalData* globalData, CodeBlock* codeBlock, void* returnAddress)
358         {
359             JIT jit(globalData, codeBlock);
360             return jit.privateCompilePatchGetArrayLength(returnAddress);
361         }
362
363         static void linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, void* ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount);
364         static void unlinkCall(CallLinkInfo*);
365
366         inline static JSValue* execute(void* code, RegisterFile* registerFile, CallFrame* callFrame, JSGlobalData* globalData, JSValue** exception)
367         {
368             return ctiTrampoline(code, registerFile, callFrame, exception, Profiler::enabledProfilerReference(), globalData);
369         }
370
371     private:
372         JIT(JSGlobalData*, CodeBlock* = 0);
373
374         void privateCompileMainPass();
375         void privateCompileLinkPass();
376         void privateCompileSlowCases();
377         void privateCompile();
378         void privateCompileGetByIdSelf(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
379         void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
380 #if USE(CTI_REPATCH_PIC)
381         void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, size_t cachedOffset);
382         void privateCompileGetByIdProtoList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, Structure* prototypeStructure, size_t cachedOffset, CallFrame* callFrame);
383         void privateCompileGetByIdChainList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, StructureChain* chain, size_t count, size_t cachedOffset, CallFrame* callFrame);
384 #endif
385         void privateCompileGetByIdChain(StructureStubInfo*, Structure*, StructureChain*, size_t count, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
386         void privateCompilePutByIdReplace(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
387         void privateCompilePutByIdTransition(StructureStubInfo*, Structure*, Structure*, size_t cachedOffset, StructureChain*, void* returnAddress);
388
389         void privateCompileCTIMachineTrampolines();
390         void privateCompilePatchGetArrayLength(void* returnAddress);
391
392         void compileGetByIdHotPath(int resultVReg, int baseVReg, Identifier* ident, unsigned i, unsigned propertyAccessInstructionIndex);
393         void compileGetByIdSlowCase(int resultVReg, int baseVReg, Identifier* ident, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned propertyAccessInstructionIndex);
394         void compilePutByIdHotPath(int baseVReg, Identifier* ident, int valueVReg, unsigned i, unsigned propertyAccessInstructionIndex);
395         void compilePutByIdSlowCase(int baseVReg, Identifier* ident, int valueVReg, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned propertyAccessInstructionIndex);
396         void compileOpCall(OpcodeID, Instruction* instruction, unsigned i, unsigned callLinkInfoIndex);
397         void compileOpCallInitializeCallFrame();
398         void compileOpCallSetupArgs(Instruction*);
399         void compileOpCallEvalSetupArgs(Instruction*);
400         void compileOpCallSlowCase(Instruction* instruction, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID);
401         void compileOpConstructSetupArgs(Instruction*);
402         enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
403         void compileOpStrictEq(Instruction* instruction, unsigned i, CompileOpStrictEqType type);
404         void putDoubleResultToJSNumberCellOrJSImmediate(XMMRegisterID xmmSource, RegisterID jsNumberCell, unsigned dst, JmpSrc* wroteJSNumberCell,  XMMRegisterID tempXmm, RegisterID tempReg1, RegisterID tempReg2);
405         void compileBinaryArithOp(OpcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi, unsigned i);
406         void compileBinaryArithOpSlowCase(OpcodeID, Vector<SlowCaseEntry>::iterator& iter, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi, unsigned i);
407
408         void emitGetVirtualRegister(int src, RegisterID dst, unsigned i);
409         void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2, unsigned i);
410         void emitPutVirtualRegister(unsigned dst, RegisterID from = X86::eax);
411
412         void emitPutCTIArg(RegisterID src, unsigned offset);
413         void emitPutCTIArgFromVirtualRegister(unsigned src, unsigned offset, RegisterID scratch);
414         void emitPutCTIArgConstant(unsigned value, unsigned offset);
415         void emitPutCTIArgConstant(void* value, unsigned offset);
416         void emitGetCTIArg(unsigned offset, RegisterID dst);
417
418         void emitInitRegister(unsigned dst);
419
420         void emitPutCTIParam(void* value, unsigned name);
421         void emitPutCTIParam(RegisterID from, unsigned name);
422         void emitGetCTIParam(unsigned name, RegisterID to);
423
424         void emitPutToCallFrameHeader(RegisterID from, RegisterFile::CallFrameHeaderEntry entry);
425         void emitPutImmediateToCallFrameHeader(void* value, RegisterFile::CallFrameHeaderEntry entry);
426         void emitGetFromCallFrameHeader(RegisterFile::CallFrameHeaderEntry entry, RegisterID to);
427
428         JSValue* getConstantImmediateNumericArg(unsigned src);
429         unsigned getDeTaggedConstantImmediate(JSValue* imm);
430
431         Jump emitJumpIfJSCell(RegisterID);
432         void emitJumpSlowCaseIfJSCell(RegisterID, unsigned bytecodeIndex);
433         Jump emitJumpIfNotJSCell(RegisterID);
434         void emitJumpSlowCaseIfNotJSCell(RegisterID, unsigned bytecodeIndex);
435         void emitJumpSlowCaseIfNotJSCell(RegisterID, unsigned bytecodeIndex, int VReg);
436         bool linkSlowCaseIfNotJSCell(const Vector<SlowCaseEntry>::iterator&, int vReg);
437
438         void emitJumpSlowCaseIfNotImmNum(RegisterID, unsigned bytecodeIndex);
439         void emitJumpSlowCaseIfNotImmNums(RegisterID, RegisterID, RegisterID, unsigned bytecodeIndex);
440
441         JmpSrc checkStructure(RegisterID reg, Structure* structure);
442
443         void emitFastArithDeTagImmediate(RegisterID);
444         JmpSrc emitFastArithDeTagImmediateJumpIfZero(RegisterID);
445         void emitFastArithReTagImmediate(RegisterID);
446         void emitFastArithPotentiallyReTagImmediate(RegisterID);
447         void emitFastArithImmToInt(RegisterID);
448         void emitFastArithIntToImmOrSlowCase(RegisterID, unsigned bytecodeIndex);
449         void emitFastArithIntToImmNoCheck(RegisterID);
450
451         void emitTagAsBoolImmediate(RegisterID reg);
452
453         JmpSrc emitNakedCall(unsigned bytecodeIndex, RegisterID);
454         JmpSrc emitNakedCall(unsigned bytecodeIndex, void* function);
455         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_j);
456         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_o);
457         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_p);
458         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_v);
459         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_s);
460         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_b);
461         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_2);
462
463         void emitGetVariableObjectRegister(RegisterID variableObject, int index, RegisterID dst);
464         void emitPutVariableObjectRegister(RegisterID src, RegisterID variableObject, int index);
465         
466         void emitSlowScriptCheck(unsigned bytecodeIndex);
467 #ifndef NDEBUG
468         void printBytecodeOperandTypes(unsigned src1, unsigned src2);
469 #endif
470
471         void killLastResultRegister();
472
473         Interpreter* m_interpreter;
474         JSGlobalData* m_globalData;
475         CodeBlock* m_codeBlock;
476
477         Vector<CallRecord> m_calls;
478         Vector<JmpDst> m_labels;
479         Vector<StructureStubCompilationInfo> m_propertyAccessCompilationInfo;
480         Vector<StructureStubCompilationInfo> m_callStructureStubCompilationInfo;
481         Vector<JmpTable> m_jmpTable;
482
483         struct JSRInfo {
484             JmpDst addrPosition;
485             JmpDst target;
486
487             JSRInfo(const JmpDst& storeLocation, const JmpDst& targetLocation)
488                 : addrPosition(storeLocation)
489                 , target(targetLocation)
490             {
491             }
492         };
493
494         Vector<JSRInfo> m_jsrSites;
495         Vector<SlowCaseEntry> m_slowCases;
496         Vector<SwitchRecord> m_switches;
497
498         int m_lastResultBytecodeRegister;
499         unsigned m_jumpTargetsPosition;
500     };
501 }
502
503 #endif // ENABLE(JIT)
504
505 #endif // JIT_h