a7d1aacd7f987edc79c61f414cabf396648c61c9
[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 #if USE(FAST_CALL_CTI_ARGUMENT)
280         static const int ctiArgumentInitSize = 2;
281 #elif USE(CTI_ARGUMENT)
282         static const int ctiArgumentInitSize = 4;
283 #else
284         static const int ctiArgumentInitSize = 0;
285 #endif
286         // These architecture specific value are used to enable repatching - see comment on op_put_by_id.
287         static const int repatchOffsetPutByIdStructure = 7;
288         static const int repatchOffsetPutByIdPropertyMapOffset = 22;
289         // These architecture specific value are used to enable repatching - see comment on op_get_by_id.
290         static const int repatchOffsetGetByIdStructure = 7;
291         static const int repatchOffsetGetByIdBranchToSlowCase = 13;
292         static const int repatchOffsetGetByIdPropertyMapOffset = 22;
293 #if ENABLE(OPCODE_SAMPLING)
294         static const int repatchOffsetGetByIdSlowCaseCall = 27 + 4 + ctiArgumentInitSize;
295 #else
296         static const int repatchOffsetGetByIdSlowCaseCall = 17 + 4 + ctiArgumentInitSize;
297 #endif
298         static const int repatchOffsetOpCallCall = 6;
299
300     public:
301         static void compile(JSGlobalData* globalData, CodeBlock* codeBlock)
302         {
303             JIT jit(globalData, codeBlock);
304             jit.privateCompile();
305         }
306
307         static void compileGetByIdSelf(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, void* returnAddress)
308         {
309             JIT jit(globalData, codeBlock);
310             jit.privateCompileGetByIdSelf(stubInfo, structure, cachedOffset, returnAddress);
311         }
312
313         static void compileGetByIdProto(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, Structure* prototypeStructure, size_t cachedOffset, void* returnAddress)
314         {
315             JIT jit(globalData, codeBlock);
316             jit.privateCompileGetByIdProto(stubInfo, structure, prototypeStructure, cachedOffset, returnAddress, callFrame);
317         }
318
319 #if USE(CTI_REPATCH_PIC)
320         static void compileGetByIdSelfList(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* polymorphicStructures, int currentIndex, Structure* structure, size_t cachedOffset)
321         {
322             JIT jit(globalData, codeBlock);
323             jit.privateCompileGetByIdSelfList(stubInfo, polymorphicStructures, currentIndex, structure, cachedOffset);
324         }
325         static void compileGetByIdProtoList(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, PolymorphicAccessStructureList* prototypeStructureList, int currentIndex, Structure* structure, Structure* prototypeStructure, size_t cachedOffset)
326         {
327             JIT jit(globalData, codeBlock);
328             jit.privateCompileGetByIdProtoList(stubInfo, prototypeStructureList, currentIndex, structure, prototypeStructure, cachedOffset, callFrame);
329         }
330         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)
331         {
332             JIT jit(globalData, codeBlock);
333             jit.privateCompileGetByIdChainList(stubInfo, prototypeStructureList, currentIndex, structure, chain, count, cachedOffset, callFrame);
334         }
335 #endif
336
337         static void compileGetByIdChain(JSGlobalData* globalData, CallFrame* callFrame, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, StructureChain* chain, size_t count, size_t cachedOffset, void* returnAddress)
338         {
339             JIT jit(globalData, codeBlock);
340             jit.privateCompileGetByIdChain(stubInfo, structure, chain, count, cachedOffset, returnAddress, callFrame);
341         }
342
343         static void compilePutByIdReplace(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* structure, size_t cachedOffset, void* returnAddress)
344         {
345             JIT jit(globalData, codeBlock);
346             jit.privateCompilePutByIdReplace(stubInfo, structure, cachedOffset, returnAddress);
347         }
348         
349         static void compilePutByIdTransition(JSGlobalData* globalData, CodeBlock* codeBlock, StructureStubInfo* stubInfo, Structure* oldStructure, Structure* newStructure, size_t cachedOffset, StructureChain* chain, void* returnAddress)
350         {
351             JIT jit(globalData, codeBlock);
352             jit.privateCompilePutByIdTransition(stubInfo, oldStructure, newStructure, cachedOffset, chain, returnAddress);
353         }
354
355         static void compileCTIMachineTrampolines(JSGlobalData* globalData)
356         {
357             JIT jit(globalData);
358             jit.privateCompileCTIMachineTrampolines();
359         }
360
361         static void patchGetByIdSelf(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
362         static void patchPutByIdReplace(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
363
364         static void compilePatchGetArrayLength(JSGlobalData* globalData, CodeBlock* codeBlock, void* returnAddress)
365         {
366             JIT jit(globalData, codeBlock);
367             return jit.privateCompilePatchGetArrayLength(returnAddress);
368         }
369
370         static void linkCall(JSFunction* callee, CodeBlock* calleeCodeBlock, void* ctiCode, CallLinkInfo* callLinkInfo, int callerArgCount);
371         static void unlinkCall(CallLinkInfo*);
372
373         inline static JSValue* execute(void* code, RegisterFile* registerFile, CallFrame* callFrame, JSGlobalData* globalData, JSValue** exception)
374         {
375             return ctiTrampoline(code, registerFile, callFrame, exception, Profiler::enabledProfilerReference(), globalData);
376         }
377
378     private:
379         JIT(JSGlobalData*, CodeBlock* = 0);
380
381         void privateCompileMainPass();
382         void privateCompileLinkPass();
383         void privateCompileSlowCases();
384         void privateCompile();
385         void privateCompileGetByIdSelf(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
386         void privateCompileGetByIdProto(StructureStubInfo*, Structure*, Structure* prototypeStructure, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
387 #if USE(CTI_REPATCH_PIC)
388         void privateCompileGetByIdSelfList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, size_t cachedOffset);
389         void privateCompileGetByIdProtoList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, Structure* prototypeStructure, size_t cachedOffset, CallFrame* callFrame);
390         void privateCompileGetByIdChainList(StructureStubInfo*, PolymorphicAccessStructureList*, int, Structure*, StructureChain* chain, size_t count, size_t cachedOffset, CallFrame* callFrame);
391 #endif
392         void privateCompileGetByIdChain(StructureStubInfo*, Structure*, StructureChain*, size_t count, size_t cachedOffset, void* returnAddress, CallFrame* callFrame);
393         void privateCompilePutByIdReplace(StructureStubInfo*, Structure*, size_t cachedOffset, void* returnAddress);
394         void privateCompilePutByIdTransition(StructureStubInfo*, Structure*, Structure*, size_t cachedOffset, StructureChain*, void* returnAddress);
395
396         void privateCompileCTIMachineTrampolines();
397         void privateCompilePatchGetArrayLength(void* returnAddress);
398
399         void compileGetByIdHotPath(int resultVReg, int baseVReg, Identifier* ident, unsigned i, unsigned propertyAccessInstructionIndex);
400         void compileGetByIdSlowCase(int resultVReg, int baseVReg, Identifier* ident, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned propertyAccessInstructionIndex);
401         void compilePutByIdHotPath(int baseVReg, Identifier* ident, int valueVReg, unsigned i, unsigned propertyAccessInstructionIndex);
402         void compilePutByIdSlowCase(int baseVReg, Identifier* ident, int valueVReg, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned propertyAccessInstructionIndex);
403         void compileOpCall(OpcodeID, Instruction* instruction, unsigned i, unsigned callLinkInfoIndex);
404         void compileOpCallInitializeCallFrame();
405         void compileOpCallSetupArgs(Instruction*);
406         void compileOpCallEvalSetupArgs(Instruction*);
407         void compileOpCallSlowCase(Instruction* instruction, unsigned i, Vector<SlowCaseEntry>::iterator& iter, unsigned callLinkInfoIndex, OpcodeID opcodeID);
408         void compileOpConstructSetupArgs(Instruction*);
409         enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
410         void compileOpStrictEq(Instruction* instruction, unsigned i, CompileOpStrictEqType type);
411         void putDoubleResultToJSNumberCellOrJSImmediate(XMMRegisterID xmmSource, RegisterID jsNumberCell, unsigned dst, JmpSrc* wroteJSNumberCell,  XMMRegisterID tempXmm, RegisterID tempReg1, RegisterID tempReg2);
412         void compileBinaryArithOp(OpcodeID, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi, unsigned i);
413         void compileBinaryArithOpSlowCase(OpcodeID, Vector<SlowCaseEntry>::iterator& iter, unsigned dst, unsigned src1, unsigned src2, OperandTypes opi, unsigned i);
414
415         void emitGetVirtualRegister(int src, RegisterID dst, unsigned i);
416         void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2, unsigned i);
417         void emitPutVirtualRegister(unsigned dst, RegisterID from = X86::eax);
418
419         void emitPutCTIArg(RegisterID src, unsigned offset);
420         void emitPutCTIArgFromVirtualRegister(unsigned src, unsigned offset, RegisterID scratch);
421         void emitPutCTIArgConstant(unsigned value, unsigned offset);
422         void emitPutCTIArgConstant(void* value, unsigned offset);
423         void emitGetCTIArg(unsigned offset, RegisterID dst);
424
425         void emitInitRegister(unsigned dst);
426
427         void emitPutCTIParam(void* value, unsigned name);
428         void emitPutCTIParam(RegisterID from, unsigned name);
429         void emitGetCTIParam(unsigned name, RegisterID to);
430
431         void emitPutToCallFrameHeader(RegisterID from, RegisterFile::CallFrameHeaderEntry entry);
432         void emitPutImmediateToCallFrameHeader(void* value, RegisterFile::CallFrameHeaderEntry entry);
433         void emitGetFromCallFrameHeader(RegisterFile::CallFrameHeaderEntry entry, RegisterID to);
434
435         JSValue* getConstantImmediateNumericArg(unsigned src);
436         unsigned getDeTaggedConstantImmediate(JSValue* imm);
437
438         Jump emitJumpIfJSCell(RegisterID);
439         void emitJumpSlowCaseIfJSCell(RegisterID, unsigned bytecodeIndex);
440         Jump emitJumpIfNotJSCell(RegisterID);
441         void emitJumpSlowCaseIfNotJSCell(RegisterID, unsigned bytecodeIndex);
442         void emitJumpSlowCaseIfNotJSCell(RegisterID, unsigned bytecodeIndex, int VReg);
443         bool linkSlowCaseIfNotJSCell(const Vector<SlowCaseEntry>::iterator&, int vReg);
444
445         void emitJumpSlowCaseIfNotImmNum(RegisterID, unsigned bytecodeIndex);
446         void emitJumpSlowCaseIfNotImmNums(RegisterID, RegisterID, RegisterID, unsigned bytecodeIndex);
447
448         JmpSrc checkStructure(RegisterID reg, Structure* structure);
449
450         void emitFastArithDeTagImmediate(RegisterID);
451         JmpSrc emitFastArithDeTagImmediateJumpIfZero(RegisterID);
452         void emitFastArithReTagImmediate(RegisterID);
453         void emitFastArithPotentiallyReTagImmediate(RegisterID);
454         void emitFastArithImmToInt(RegisterID);
455         void emitFastArithIntToImmOrSlowCase(RegisterID, unsigned bytecodeIndex);
456         void emitFastArithIntToImmNoCheck(RegisterID);
457
458         void emitTagAsBoolImmediate(RegisterID reg);
459
460         void restoreArgumentReference();
461         void restoreArgumentReferenceForTrampoline();
462
463         JmpSrc emitNakedCall(unsigned bytecodeIndex, RegisterID);
464         JmpSrc emitNakedCall(unsigned bytecodeIndex, void* function);
465         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_j);
466         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_o);
467         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_p);
468         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_v);
469         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_s);
470         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_b);
471         JmpSrc emitCTICall(unsigned bytecodeIndex, CTIHelper_2);
472
473         void emitGetVariableObjectRegister(RegisterID variableObject, int index, RegisterID dst);
474         void emitPutVariableObjectRegister(RegisterID src, RegisterID variableObject, int index);
475         
476         void emitSlowScriptCheck(unsigned bytecodeIndex);
477 #ifndef NDEBUG
478         void printBytecodeOperandTypes(unsigned src1, unsigned src2);
479 #endif
480
481         void killLastResultRegister();
482
483         Interpreter* m_interpreter;
484         JSGlobalData* m_globalData;
485         CodeBlock* m_codeBlock;
486
487         Vector<CallRecord> m_calls;
488         Vector<JmpDst> m_labels;
489         Vector<StructureStubCompilationInfo> m_propertyAccessCompilationInfo;
490         Vector<StructureStubCompilationInfo> m_callStructureStubCompilationInfo;
491         Vector<JmpTable> m_jmpTable;
492
493         struct JSRInfo {
494             JmpDst addrPosition;
495             JmpDst target;
496
497             JSRInfo(const JmpDst& storeLocation, const JmpDst& targetLocation)
498                 : addrPosition(storeLocation)
499                 , target(targetLocation)
500             {
501             }
502         };
503
504         Vector<JSRInfo> m_jsrSites;
505         Vector<SlowCaseEntry> m_slowCases;
506         Vector<SwitchRecord> m_switches;
507
508         int m_lastResultBytecodeRegister;
509         unsigned m_jumpTargetsPosition;
510     };
511 }
512
513 #endif // ENABLE(JIT)
514
515 #endif // JIT_h