blob: f8f309f68704975e036ce23280b0d770a896a23a [file] [log] [blame]
mrowe@apple.comf88a4632008-09-07 05:44:58 +00001/*
fpizlo@apple.com947ec622013-01-02 08:48:18 +00002 * Copyright (C) 2008, 2012, 2013 Apple Inc. All rights reserved.
mrowe@apple.comf88a4632008-09-07 05:44:58 +00003 *
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
ggaren@apple.comcc0f1f12008-11-17 23:16:00 +000026#ifndef JIT_h
27#define JIT_h
mrowe@apple.comf88a4632008-09-07 05:44:58 +000028
ggaren@apple.comf272d2d2008-11-17 04:25:37 +000029#if ENABLE(JIT)
mrowe@apple.comf88a4632008-09-07 05:44:58 +000030
barraclough@apple.com433cd152009-05-13 00:27:24 +000031// 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
xan@webkit.org773abaf2011-02-21 21:14:57 +000039#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));
barraclough@apple.com71c5a9a2009-10-28 07:13:37 +000040
ggaren@apple.comd8fccca2009-05-08 20:51:53 +000041#include "CodeBlock.h"
fpizlo@apple.com7f6c6802011-09-13 01:33:43 +000042#include "CompactJITCodeMap.h"
ggaren@apple.com901a8a22008-11-17 20:57:18 +000043#include "Interpreter.h"
fpizlo@apple.com1949f322012-11-22 00:46:57 +000044#include "JITDisassembler.h"
fpizlo@apple.com5ba07882013-10-19 23:13:23 +000045#include "JITInlineCacheGenerator.h"
oliver@apple.comec0e4002010-04-27 03:45:47 +000046#include "JSInterfaceJIT.h"
fpizlo@apple.com77ea29a2012-12-04 22:30:28 +000047#include "LegacyProfiler.h"
mrowe@apple.comf88a4632008-09-07 05:44:58 +000048#include "Opcode.h"
ossy@webkit.org7269f912013-02-18 07:18:56 +000049#include "ResultType.h"
ap@apple.com94163232013-10-20 00:01:17 +000050#include "SamplingTool.h"
msaboff@apple.comec1cd572012-12-20 23:20:30 +000051#include "UnusedPointer.h"
mrowe@apple.comf88a4632008-09-07 05:44:58 +000052
cwzwarich@webkit.org3f782f62008-09-08 01:28:33 +000053namespace JSC {
mrowe@apple.comf88a4632008-09-07 05:44:58 +000054
mark.lam@apple.com5d7e7082013-10-11 19:03:39 +000055 class ArrayAllocationProfile;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000056 class CodeBlock;
oliver@apple.come843bc02011-08-05 20:03:19 +000057 class FunctionExecutable;
ggaren@apple.comd8fccca2009-05-08 20:51:53 +000058 class JIT;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000059 class JSPropertyNameIterator;
mark.lam@apple.com03944a02013-10-14 16:42:22 +000060 class Identifier;
ggaren@apple.com031563e2008-11-17 02:21:16 +000061 class Interpreter;
ggaren@apple.comb11e7872012-08-30 22:50:00 +000062 class JSScope;
mark.lam@apple.com4fbb9c32012-10-09 07:12:56 +000063 class JSStack;
ggaren@apple.comc862eac2013-01-29 05:48:01 +000064 class MarkedAllocator;
mark.lam@apple.com4fbb9c32012-10-09 07:12:56 +000065 class Register;
darin@apple.coma9778f92008-11-16 04:40:06 +000066 class StructureChain;
darin@apple.com5a494422008-10-18 23:08:12 +000067
barraclough@apple.come9642652008-10-23 22:29:54 +000068 struct CallLinkInfo;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000069 struct Instruction;
barraclough@apple.comb8b15e22008-09-27 01:44:15 +000070 struct OperandTypes;
barraclough@apple.combc0fea62008-11-22 03:34:43 +000071 struct PolymorphicAccessStructureList;
levin@chromium.org93604aa2009-07-29 08:04:19 +000072 struct SimpleJumpTable;
73 struct StringJumpTable;
barraclough@apple.comf5f74822008-11-21 05:04:19 +000074 struct StructureStubInfo;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000075
mrowe@apple.comf88a4632008-09-07 05:44:58 +000076 struct CallRecord {
barraclough@apple.com8c4ea6b2009-02-11 04:57:08 +000077 MacroAssembler::Call from;
ggaren@apple.com1ba49812010-05-19 18:28:54 +000078 unsigned bytecodeOffset;
barraclough@apple.com249befb2008-12-13 03:18:10 +000079 void* to;
mrowe@apple.comf88a4632008-09-07 05:44:58 +000080
81 CallRecord()
82 {
83 }
84
ggaren@apple.com1ba49812010-05-19 18:28:54 +000085 CallRecord(MacroAssembler::Call from, unsigned bytecodeOffset, void* to = 0)
barraclough@apple.com249befb2008-12-13 03:18:10 +000086 : from(from)
ggaren@apple.com1ba49812010-05-19 18:28:54 +000087 , bytecodeOffset(bytecodeOffset)
barraclough@apple.com249befb2008-12-13 03:18:10 +000088 , to(to)
ggaren@apple.com107bd0e2008-09-24 00:27:18 +000089 {
90 }
mrowe@apple.comf88a4632008-09-07 05:44:58 +000091 };
92
barraclough@apple.coma2a2e132008-12-13 23:58:58 +000093 struct JumpTable {
94 MacroAssembler::Jump from;
ggaren@apple.com1ba49812010-05-19 18:28:54 +000095 unsigned toBytecodeOffset;
barraclough@apple.coma2a2e132008-12-13 23:58:58 +000096
97 JumpTable(MacroAssembler::Jump f, unsigned t)
mrowe@apple.comf88a4632008-09-07 05:44:58 +000098 : from(f)
ggaren@apple.com1ba49812010-05-19 18:28:54 +000099 , toBytecodeOffset(t)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000100 {
101 }
102 };
103
104 struct SlowCaseEntry {
barraclough@apple.com4f46a502008-12-13 01:39:38 +0000105 MacroAssembler::Jump from;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000106 unsigned to;
107 unsigned hint;
108
barraclough@apple.com4f46a502008-12-13 01:39:38 +0000109 SlowCaseEntry(MacroAssembler::Jump f, unsigned t, unsigned h = 0)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000110 : from(f)
111 , to(t)
112 , hint(h)
113 {
114 }
115 };
116
117 struct SwitchRecord {
118 enum Type {
119 Immediate,
120 Character,
121 String
122 };
123
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000124 Type type;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000125
126 union {
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000127 SimpleJumpTable* simpleJumpTable;
128 StringJumpTable* stringJumpTable;
129 } jumpTable;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000130
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000131 unsigned bytecodeOffset;
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000132 unsigned defaultOffset;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000133
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000134 SwitchRecord(SimpleJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset, Type type)
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000135 : type(type)
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000136 , bytecodeOffset(bytecodeOffset)
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000137 , defaultOffset(defaultOffset)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000138 {
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000139 this->jumpTable.simpleJumpTable = jumpTable;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000140 }
141
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000142 SwitchRecord(StringJumpTable* jumpTable, unsigned bytecodeOffset, unsigned defaultOffset)
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000143 : type(String)
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000144 , bytecodeOffset(bytecodeOffset)
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000145 , defaultOffset(defaultOffset)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000146 {
cwzwarich@webkit.orge8827732008-11-11 18:31:51 +0000147 this->jumpTable.stringJumpTable = jumpTable;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000148 }
149 };
150
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000151 struct ByValCompilationInfo {
152 ByValCompilationInfo() { }
153
154 ByValCompilationInfo(unsigned bytecodeIndex, MacroAssembler::PatchableJump badTypeJump, JITArrayMode arrayMode, MacroAssembler::Label doneTarget)
155 : bytecodeIndex(bytecodeIndex)
156 , badTypeJump(badTypeJump)
157 , arrayMode(arrayMode)
158 , doneTarget(doneTarget)
159 {
160 }
161
162 unsigned bytecodeIndex;
163 MacroAssembler::PatchableJump badTypeJump;
164 JITArrayMode arrayMode;
165 MacroAssembler::Label doneTarget;
166 MacroAssembler::Label slowPathTarget;
167 MacroAssembler::Call returnAddress;
168 };
169
barraclough@apple.com71500d52008-09-15 02:18:13 +0000170 struct StructureStubCompilationInfo {
barraclough@apple.com289318a2008-12-22 01:00:07 +0000171 MacroAssembler::DataLabelPtr hotPathBegin;
barraclough@apple.com8c4ea6b2009-02-11 04:57:08 +0000172 MacroAssembler::Call hotPathOther;
173 MacroAssembler::Call callReturnLocation;
ggaren@apple.com539d1bb2011-11-14 19:21:40 +0000174 CallLinkInfo::CallType callType;
oliver@apple.com1386ec92011-10-07 18:39:45 +0000175 unsigned bytecodeIndex;
barraclough@apple.com71500d52008-09-15 02:18:13 +0000176 };
177
barraclough@apple.com97bacef2009-06-05 07:55:38 +0000178 // Near calls can only be patched to other JIT code, regular calls can be patched to JIT code or relinked to stub functions.
barraclough@apple.com1444b282009-07-22 22:17:10 +0000179 void ctiPatchNearCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, MacroAssemblerCodePtr newCalleeFunction);
180 void ctiPatchCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, MacroAssemblerCodePtr newCalleeFunction);
181 void ctiPatchCallByReturnAddress(CodeBlock* codeblock, ReturnAddressPtr returnAddress, FunctionPtr newCalleeFunction);
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000182
oliver@apple.comec0e4002010-04-27 03:45:47 +0000183 class JIT : private JSInterfaceJIT {
oliver@apple.com7ca71432013-07-25 04:02:44 +0000184 friend class JITSlowPathCall;
ggaren@apple.comd8fccca2009-05-08 20:51:53 +0000185 friend class JITStubCall;
ggaren@apple.comd8fccca2009-05-08 20:51:53 +0000186
barraclough@apple.comd13288c2008-12-05 23:57:43 +0000187 using MacroAssembler::Jump;
188 using MacroAssembler::JumpList;
189 using MacroAssembler::Label;
190
msaboff@apple.comec1cd572012-12-20 23:20:30 +0000191 static const uintptr_t patchGetByIdDefaultStructure = unusedPointer;
oliver@apple.com2c012fa2011-05-17 20:02:41 +0000192 static const int patchGetByIdDefaultOffset = 0;
barraclough@apple.com71500d52008-09-15 02:18:13 +0000193 // Magic number - initial offset cannot be representable as a signed 8bit value, or the X86Assembler
weinig@apple.com76b0f8a2008-12-22 21:21:18 +0000194 // will compress the displacement, and we may not be able to fit a patched offset.
oliver@apple.com2c012fa2011-05-17 20:02:41 +0000195 static const int patchPutByIdDefaultOffset = 256;
barraclough@apple.com71500d52008-09-15 02:18:13 +0000196
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000197 public:
fpizlo@apple.com1342e7a2013-08-29 19:28:55 +0000198 static CompilationResult compile(VM* vm, CodeBlock* codeBlock, JITCompilationEffort effort)
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000199 {
fpizlo@apple.com1342e7a2013-08-29 19:28:55 +0000200 return JIT(vm, codeBlock).privateCompile(effort);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000201 }
fpizlo@apple.com947ec622013-01-02 08:48:18 +0000202
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000203 static void compileClosureCall(VM* vm, CallLinkInfo* callLinkInfo, CodeBlock* callerCodeBlock, CodeBlock* calleeCodeBlock, Structure* expectedStructure, ExecutableBase* expectedExecutable, MacroAssemblerCodePtr codePtr)
fpizlo@apple.com947ec622013-01-02 08:48:18 +0000204 {
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000205 JIT jit(vm, callerCodeBlock);
fpizlo@apple.com947ec622013-01-02 08:48:18 +0000206 jit.m_bytecodeOffset = callLinkInfo->codeOrigin.bytecodeIndex;
207 jit.privateCompileClosureCall(callLinkInfo, calleeCodeBlock, expectedStructure, expectedExecutable, codePtr);
208 }
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000209
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000210 static void compileGetByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000211 {
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000212 JIT jit(vm, codeBlock);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000213 jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
214 jit.privateCompileGetByVal(byValInfo, returnAddress, arrayMode);
215 }
216
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000217 static void compilePutByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000218 {
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000219 JIT jit(vm, codeBlock);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000220 jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
221 jit.privateCompilePutByVal(byValInfo, returnAddress, arrayMode);
222 }
oliver@apple.come050d642013-10-19 00:09:28 +0000223
224 static void compileDirectPutByVal(VM* vm, CodeBlock* codeBlock, ByValInfo* byValInfo, ReturnAddressPtr returnAddress, JITArrayMode arrayMode)
225 {
226 JIT jit(vm, codeBlock);
227 jit.m_bytecodeOffset = byValInfo->bytecodeIndex;
228 jit.privateCompilePutByVal(byValInfo, returnAddress, arrayMode);
229 }
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000230
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000231 static CodeRef compileCTINativeCall(VM* vm, NativeFunction func)
barraclough@apple.com8cc46692010-05-19 06:04:18 +0000232 {
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000233 if (!vm->canUseJIT()) {
fpizlo@apple.come6e29a6f2012-03-06 06:54:23 +0000234#if ENABLE(LLINT)
235 return CodeRef::createLLIntCodeRef(llint_native_call_trampoline);
236#else
fpizlo@apple.come6a7f5f2011-09-11 05:49:36 +0000237 return CodeRef();
fpizlo@apple.come6e29a6f2012-03-06 06:54:23 +0000238#endif
239 }
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000240 JIT jit(vm, 0);
241 return jit.privateCompileCTINativeCall(vm, func);
barraclough@apple.com8cc46692010-05-19 06:04:18 +0000242 }
243
oliver@apple.comd2cdd312013-07-25 04:01:00 +0000244 static void linkFor(ExecState*, JSFunction* callee, CodeBlock* callerCodeBlock, CodeBlock* calleeCodeBlock, CodePtr, CallLinkInfo*, VM*, CodeSpecializationKind);
fpizlo@apple.com947ec622013-01-02 08:48:18 +0000245 static void linkSlowCall(CodeBlock* callerCodeBlock, CallLinkInfo*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000246
247 private:
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000248 JIT(VM*, CodeBlock* = 0);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000249
250 void privateCompileMainPass();
251 void privateCompileLinkPass();
252 void privateCompileSlowCases();
fpizlo@apple.com1342e7a2013-08-29 19:28:55 +0000253 CompilationResult privateCompile(JITCompilationEffort);
fpizlo@apple.com33fbf1f2012-11-05 03:13:26 +0000254
fpizlo@apple.com947ec622013-01-02 08:48:18 +0000255 void privateCompileClosureCall(CallLinkInfo*, CodeBlock* calleeCodeBlock, Structure*, ExecutableBase*, MacroAssemblerCodePtr);
256
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000257 void privateCompileGetByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
258 void privateCompilePutByVal(ByValInfo*, ReturnAddressPtr, JITArrayMode);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000259
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000260 Label privateCompileCTINativeCall(VM*, bool isConstruct = false);
261 CodeRef privateCompileCTINativeCall(VM*, NativeFunction);
barraclough@apple.comce1490e2010-08-26 23:21:24 +0000262 void privateCompilePatchGetArrayLength(ReturnAddressPtr returnAddress);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000263
msaboff@apple.coma482c542013-10-04 18:20:40 +0000264 // Add a call out from JIT code, without an exception check.
265 Call appendCall(const FunctionPtr& function)
266 {
267 Call functionCall = call();
268 m_calls.append(CallRecord(functionCall, m_bytecodeOffset, function.value()));
fpizlo@apple.com203b78b2013-10-17 03:01:49 +0000269#if USE(JSVALUE32_64)
270 unmap();
271#else
272 killLastResultRegister();
273#endif
msaboff@apple.coma482c542013-10-04 18:20:40 +0000274 return functionCall;
275 }
276
msaboff@apple.com8f4bb0c2013-10-02 23:33:46 +0000277 void exceptionCheck(Jump jumpToHandler)
278 {
279 m_exceptionChecks.append(jumpToHandler);
280 }
281
282 void exceptionCheck()
283 {
284 m_exceptionChecks.append(emitExceptionCheck());
285 }
286
msaboff@apple.com5ca16c42013-10-07 18:20:27 +0000287 void exceptionCheckWithCallFrameRollback()
288 {
289 m_exceptionChecksWithCallFrameRollback.append(emitExceptionCheck());
290 }
291
msaboff@apple.com8f4bb0c2013-10-02 23:33:46 +0000292 void privateCompileExceptionHandlers();
293
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000294 void addSlowCase(Jump);
295 void addSlowCase(JumpList);
fpizlo@apple.com9b0b31e2011-09-19 22:27:38 +0000296 void addSlowCase();
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000297 void addJump(Jump, int);
298 void emitJumpSlowToHot(Jump, int);
299
ggaren@apple.com539d1bb2011-11-14 19:21:40 +0000300 void compileOpCall(OpcodeID, Instruction*, unsigned callLinkInfoIndex);
301 void compileOpCallSlowCase(OpcodeID, Instruction*, Vector<SlowCaseEntry>::iterator&, unsigned callLinkInfoIndex);
302 void compileLoadVarargs(Instruction*);
oliver@apple.comcf0e6c42013-07-25 04:01:45 +0000303 void compileCallEval(Instruction*);
304 void compileCallEvalSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&);
305 void emitPutCallResult(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000306
307 enum CompileOpStrictEqType { OpStrictEq, OpNStrictEq };
308 void compileOpStrictEq(Instruction* instruction, CompileOpStrictEqType type);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000309 bool isOperandConstantImmediateDouble(int src);
oliver@apple.com8d181632009-09-25 02:40:59 +0000310
ggaren@apple.come1e45912011-11-14 19:44:32 +0000311 void emitLoadDouble(int index, FPRegisterID value);
312 void emitLoadInt32ToDouble(int index, FPRegisterID value);
barraclough@apple.comb8bcc942011-09-07 17:55:50 +0000313 Jump emitJumpIfNotObject(RegisterID structureReg);
oliver@apple.com8d181632009-09-25 02:40:59 +0000314
fpizlo@apple.com33fbf1f2012-11-05 03:13:26 +0000315 Jump addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, RegisterID scratch);
316 void addStructureTransitionCheck(JSCell*, Structure*, StructureStubInfo*, JumpList& failureCases, RegisterID scratch);
317 void testPrototype(JSValue, JumpList& failureCases, StructureStubInfo*);
ggaren@apple.com9dc3ab7a2009-10-19 22:59:41 +0000318
oliver@apple.com0cae6932011-09-23 22:05:24 +0000319 enum WriteBarrierMode { UnconditionalWriteBarrier, ShouldFilterImmediates };
320 // value register in write barrier is used before any scratch registers
321 // so may safely be the same as either of the scratch registers.
322 void emitWriteBarrier(RegisterID owner, RegisterID valueTag, RegisterID scratch, RegisterID scratch2, WriteBarrierMode, WriteBarrierUseKind);
323 void emitWriteBarrier(JSCell* owner, RegisterID value, RegisterID scratch, WriteBarrierMode, WriteBarrierUseKind);
oliver@apple.come843bc02011-08-05 20:03:19 +0000324
ggaren@apple.comc862eac2013-01-29 05:48:01 +0000325 template<typename StructureType> // StructureType can be RegisterID or ImmPtr.
326 void emitAllocateJSObject(RegisterID allocator, StructureType, RegisterID result, RegisterID scratch);
fpizlo@apple.com95a9f0d2011-08-20 02:17:49 +0000327
fpizlo@apple.com95a9f0d2011-08-20 02:17:49 +0000328#if ENABLE(VALUE_PROFILER)
329 // This assumes that the value to profile is in regT0 and that regT3 is available for
330 // scratch.
oliver@apple.coma17ff5b2013-07-25 04:03:07 +0000331 void emitValueProfilingSite(ValueProfile*, RegisterID);
332 void emitValueProfilingSite(unsigned bytecodeOffset, RegisterID);
333 void emitValueProfilingSite(RegisterID);
fpizlo@apple.com95a9f0d2011-08-20 02:17:49 +0000334#else
oliver@apple.coma17ff5b2013-07-25 04:03:07 +0000335 void emitValueProfilingSite(unsigned, RegisterID) { }
336 void emitValueProfilingSite(RegisterID) { }
fpizlo@apple.com95a9f0d2011-08-20 02:17:49 +0000337#endif
fpizlo@apple.comc7be5be02012-09-17 19:07:32 +0000338 void emitArrayProfilingSite(RegisterID structureAndIndexingType, RegisterID scratch, ArrayProfile*);
339 void emitArrayProfilingSiteForBytecodeIndex(RegisterID structureAndIndexingType, RegisterID scratch, unsigned bytecodeIndex);
fpizlo@apple.com69e27842012-09-19 21:43:10 +0000340 void emitArrayProfileStoreToHoleSpecialCase(ArrayProfile*);
fpizlo@apple.com304fbca2012-12-17 21:38:51 +0000341 void emitArrayProfileOutOfBoundsSpecialCase(ArrayProfile*);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000342
343 JITArrayMode chooseArrayMode(ArrayProfile*);
344
345 // Property is in regT1, base is in regT0. regT2 contains indexing type.
346 // Property is int-checked and zero extended. Base is cell checked.
347 // Structure is already profiled. Returns the slow cases. Fall-through
348 // case contains result in regT0, and it is not yet profiled.
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000349 JumpList emitInt32GetByVal(Instruction* instruction, PatchableJump& badType) { return emitContiguousGetByVal(instruction, badType, Int32Shape); }
350 JumpList emitDoubleGetByVal(Instruction*, PatchableJump& badType);
351 JumpList emitContiguousGetByVal(Instruction*, PatchableJump& badType, IndexingType expectedShape = ContiguousShape);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000352 JumpList emitArrayStorageGetByVal(Instruction*, PatchableJump& badType);
fpizlo@apple.com0e0d9312013-08-15 20:43:06 +0000353 JumpList emitIntTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
354 JumpList emitFloatTypedArrayGetByVal(Instruction*, PatchableJump& badType, TypedArrayType);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000355
356 // Property is in regT0, base is in regT0. regT2 contains indecing type.
357 // The value to store is not yet loaded. Property is int-checked and
358 // zero-extended. Base is cell checked. Structure is already profiled.
359 // returns the slow cases.
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000360 JumpList emitInt32PutByVal(Instruction* currentInstruction, PatchableJump& badType)
361 {
ossy@webkit.org2460fa12012-11-14 16:18:10 +0000362 return emitGenericContiguousPutByVal(currentInstruction, badType, Int32Shape);
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000363 }
364 JumpList emitDoublePutByVal(Instruction* currentInstruction, PatchableJump& badType)
365 {
ossy@webkit.org2460fa12012-11-14 16:18:10 +0000366 return emitGenericContiguousPutByVal(currentInstruction, badType, DoubleShape);
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000367 }
368 JumpList emitContiguousPutByVal(Instruction* currentInstruction, PatchableJump& badType)
369 {
ossy@webkit.org2460fa12012-11-14 16:18:10 +0000370 return emitGenericContiguousPutByVal(currentInstruction, badType);
fpizlo@apple.com75c91a72012-11-08 22:28:25 +0000371 }
ossy@webkit.org2460fa12012-11-14 16:18:10 +0000372 JumpList emitGenericContiguousPutByVal(Instruction*, PatchableJump& badType, IndexingType indexingShape = ContiguousShape);
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000373 JumpList emitArrayStoragePutByVal(Instruction*, PatchableJump& badType);
fpizlo@apple.com0e0d9312013-08-15 20:43:06 +0000374 JumpList emitIntTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
375 JumpList emitFloatTypedArrayPutByVal(Instruction*, PatchableJump& badType, TypedArrayType);
fpizlo@apple.comc14c8d32012-10-10 02:14:42 +0000376
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000377 enum FinalObjectMode { MayBeFinal, KnownNotFinal };
378
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000379#if USE(JSVALUE32_64)
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000380 bool getOperandConstantImmediateInt(int op1, int op2, int& op, int32_t& constant);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000381
ggaren@apple.come1e45912011-11-14 19:44:32 +0000382 void emitLoadTag(int index, RegisterID tag);
383 void emitLoadPayload(int index, RegisterID payload);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000384
385 void emitLoad(const JSValue& v, RegisterID tag, RegisterID payload);
ggaren@apple.come1e45912011-11-14 19:44:32 +0000386 void emitLoad(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
387 void emitLoad2(int index1, RegisterID tag1, RegisterID payload1, int index2, RegisterID tag2, RegisterID payload2);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000388
ggaren@apple.come1e45912011-11-14 19:44:32 +0000389 void emitStore(int index, RegisterID tag, RegisterID payload, RegisterID base = callFrameRegister);
390 void emitStore(int index, const JSValue constant, RegisterID base = callFrameRegister);
391 void emitStoreInt32(int index, RegisterID payload, bool indexIsInt32 = false);
392 void emitStoreInt32(int index, TrustedImm32 payload, bool indexIsInt32 = false);
393 void emitStoreAndMapInt32(int index, RegisterID tag, RegisterID payload, bool indexIsInt32, size_t opcodeLength);
394 void emitStoreCell(int index, RegisterID payload, bool indexIsCell = false);
395 void emitStoreBool(int index, RegisterID payload, bool indexIsBool = false);
396 void emitStoreDouble(int index, FPRegisterID value);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000397
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000398 bool isLabeled(unsigned bytecodeOffset);
ggaren@apple.come1e45912011-11-14 19:44:32 +0000399 void map(unsigned bytecodeOffset, int virtualRegisterIndex, RegisterID tag, RegisterID payload);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000400 void unmap(RegisterID);
401 void unmap();
ggaren@apple.come1e45912011-11-14 19:44:32 +0000402 bool isMapped(int virtualRegisterIndex);
403 bool getMappedPayload(int virtualRegisterIndex, RegisterID& payload);
404 bool getMappedTag(int virtualRegisterIndex, RegisterID& tag);
fpizlo@apple.comb75911b2012-06-13 20:53:52 +0000405
ggaren@apple.come1e45912011-11-14 19:44:32 +0000406 void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex);
407 void emitJumpSlowCaseIfNotJSCell(int virtualRegisterIndex, RegisterID tag);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000408
oliver@apple.com9b652762013-08-12 22:39:13 +0000409 void compileGetByIdHotPath(const Identifier*);
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000410 void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
411 void compileGetDirectOffset(JSObject* base, RegisterID resultTag, RegisterID resultPayload, PropertyOffset cachedOffset);
412 void compileGetDirectOffset(RegisterID base, RegisterID resultTag, RegisterID resultPayload, RegisterID offset, FinalObjectMode = MayBeFinal);
413 void compilePutDirectOffset(RegisterID base, RegisterID valueTag, RegisterID valuePayload, PropertyOffset cachedOffset);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000414
415 // Arithmetic opcode helpers
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000416 void emitAdd32Constant(int dst, int op, int32_t constant, ResultType opType);
417 void emitSub32Constant(int dst, int op, int32_t constant, ResultType opType);
418 void emitBinaryDoubleOp(OpcodeID, int dst, int op1, int op2, OperandTypes, JumpList& notInt32Op1, JumpList& notInt32Op2, bool op1IsInRegisters = true, bool op2IsInRegisters = true);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000419
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000420#else // USE(JSVALUE32_64)
421 void emitGetVirtualRegister(int src, RegisterID dst);
msaboff@apple.com62aa8b72013-09-26 22:53:54 +0000422 void emitGetVirtualRegister(VirtualRegister src, RegisterID dst);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000423 void emitGetVirtualRegisters(int src1, RegisterID dst1, int src2, RegisterID dst2);
msaboff@apple.com62aa8b72013-09-26 22:53:54 +0000424 void emitGetVirtualRegisters(VirtualRegister src1, RegisterID dst1, VirtualRegister src2, RegisterID dst2);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000425 void emitPutVirtualRegister(int dst, RegisterID from = regT0);
msaboff@apple.com62aa8b72013-09-26 22:53:54 +0000426 void emitPutVirtualRegister(VirtualRegister dst, RegisterID from = regT0);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000427 void emitStoreCell(int dst, RegisterID payload, bool /* only used in JSValue32_64 */ = false)
oliver@apple.come843bc02011-08-05 20:03:19 +0000428 {
429 emitPutVirtualRegister(dst, payload);
430 }
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000431 void emitStoreCell(VirtualRegister dst, RegisterID payload)
432 {
433 emitPutVirtualRegister(dst, payload);
434 }
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000435
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000436 int32_t getConstantOperandImmediateInt(int src);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000437
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000438 void killLastResultRegister();
439
440 Jump emitJumpIfJSCell(RegisterID);
441 Jump emitJumpIfBothJSCells(RegisterID, RegisterID, RegisterID);
442 void emitJumpSlowCaseIfJSCell(RegisterID);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000443 void emitJumpSlowCaseIfNotJSCell(RegisterID);
444 void emitJumpSlowCaseIfNotJSCell(RegisterID, int VReg);
barraclough@apple.comb8bcc942011-09-07 17:55:50 +0000445 Jump emitJumpIfImmediateInteger(RegisterID);
446 Jump emitJumpIfNotImmediateInteger(RegisterID);
447 Jump emitJumpIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000448 void emitJumpSlowCaseIfNotImmediateInteger(RegisterID);
oliver@apple.com8d181632009-09-25 02:40:59 +0000449 void emitJumpSlowCaseIfNotImmediateNumber(RegisterID);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000450 void emitJumpSlowCaseIfNotImmediateIntegers(RegisterID, RegisterID, RegisterID);
451
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000452 void emitFastArithReTagImmediate(RegisterID src, RegisterID dest);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000453
454 void emitTagAsBoolImmediate(RegisterID reg);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000455 void compileBinaryArithOp(OpcodeID, int dst, int src1, int src2, OperandTypes opi);
456 void compileBinaryArithOpSlowCase(Instruction*, OpcodeID, Vector<SlowCaseEntry>::iterator&, int dst, int src1, int src2, OperandTypes, bool op1HasImmediateIntFastCase, bool op2HasImmediateIntFastCase);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000457
oliver@apple.com9b652762013-08-12 22:39:13 +0000458 void compileGetByIdHotPath(int baseVReg, const Identifier*);
fpizlo@apple.comd68b1f82012-07-05 22:55:51 +0000459 void compileGetDirectOffset(RegisterID base, RegisterID result, PropertyOffset cachedOffset);
460 void compileGetDirectOffset(JSObject* base, RegisterID result, PropertyOffset cachedOffset);
461 void compileGetDirectOffset(RegisterID base, RegisterID result, RegisterID offset, RegisterID scratch, FinalObjectMode = MayBeFinal);
462 void compilePutDirectOffset(RegisterID base, RegisterID value, PropertyOffset cachedOffset);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000463
zoltan@webkit.org723ba022009-11-14 01:07:01 +0000464#endif // USE(JSVALUE32_64)
barraclough@apple.com970af2c2009-08-13 05:58:36 +0000465
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000466 void emit_compareAndJump(OpcodeID, int op1, int op2, unsigned target, RelationalCondition);
msaboff@apple.comc8dd3f72013-10-10 23:10:40 +0000467 void emit_compareAndJumpSlow(int op1, int op2, unsigned target, DoubleCondition, size_t (JIT_OPERATION *operation)(ExecState*, EncodedJSValue, EncodedJSValue), bool invert, Vector<SlowCaseEntry>::iterator&);
barraclough@apple.com3a8c64b2011-07-04 05:59:03 +0000468
weinig@apple.com0d74a262009-05-12 01:06:58 +0000469 void emit_op_add(Instruction*);
weinig@apple.com0d74a262009-05-12 01:06:58 +0000470 void emit_op_bitand(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000471 void emit_op_bitor(Instruction*);
472 void emit_op_bitxor(Instruction*);
473 void emit_op_call(Instruction*);
474 void emit_op_call_eval(Instruction*);
475 void emit_op_call_varargs(Instruction*);
476 void emit_op_catch(Instruction*);
477 void emit_op_construct(Instruction*);
fpizlo@apple.coma1fe26b2012-11-13 06:04:51 +0000478 void emit_op_get_callee(Instruction*);
barraclough@apple.comfd8c28a2010-05-25 03:04:43 +0000479 void emit_op_create_this(Instruction*);
oliver@apple.come2fe4ce2013-07-25 03:59:41 +0000480 void emit_op_to_this(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000481 void emit_op_create_arguments(Instruction*);
482 void emit_op_debug(Instruction*);
483 void emit_op_del_by_id(Instruction*);
484 void emit_op_div(Instruction*);
485 void emit_op_end(Instruction*);
486 void emit_op_enter(Instruction*);
oliver@apple.comf312e222010-10-04 22:43:18 +0000487 void emit_op_create_activation(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000488 void emit_op_eq(Instruction*);
489 void emit_op_eq_null(Instruction*);
490 void emit_op_get_by_id(Instruction*);
oliver@apple.com74e00b02010-09-25 21:42:00 +0000491 void emit_op_get_arguments_length(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000492 void emit_op_get_by_val(Instruction*);
oliver@apple.com74e00b02010-09-25 21:42:00 +0000493 void emit_op_get_argument_by_val(Instruction*);
oliver@apple.com0a4803c2009-10-29 01:25:02 +0000494 void emit_op_get_by_pname(Instruction*);
oliver@apple.comf61c9a12010-09-24 19:06:29 +0000495 void emit_op_init_lazy_reg(Instruction*);
barraclough@apple.com8da6d972010-11-16 21:11:26 +0000496 void emit_op_check_has_instance(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000497 void emit_op_instanceof(Instruction*);
fpizlo@apple.com1d216892012-04-12 00:55:44 +0000498 void emit_op_is_undefined(Instruction*);
499 void emit_op_is_boolean(Instruction*);
500 void emit_op_is_number(Instruction*);
501 void emit_op_is_string(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000502 void emit_op_jeq_null(Instruction*);
503 void emit_op_jfalse(Instruction*);
504 void emit_op_jmp(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000505 void emit_op_jneq_null(Instruction*);
506 void emit_op_jneq_ptr(Instruction*);
mjs@apple.coma46c49c2009-12-06 09:42:03 +0000507 void emit_op_jless(Instruction*);
barraclough@apple.com3a8c64b2011-07-04 05:59:03 +0000508 void emit_op_jlesseq(Instruction*);
barraclough@apple.com57b4bdb82011-07-04 19:26:05 +0000509 void emit_op_jgreater(Instruction*);
510 void emit_op_jgreatereq(Instruction*);
511 void emit_op_jnless(Instruction*);
weinig@apple.com0d74a262009-05-12 01:06:58 +0000512 void emit_op_jnlesseq(Instruction*);
barraclough@apple.com57b4bdb82011-07-04 19:26:05 +0000513 void emit_op_jngreater(Instruction*);
514 void emit_op_jngreatereq(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000515 void emit_op_jtrue(Instruction*);
fpizlo@apple.coma71ab052011-09-13 05:35:53 +0000516 void emit_op_loop_hint(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000517 void emit_op_lshift(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000518 void emit_op_mod(Instruction*);
519 void emit_op_mov(Instruction*);
520 void emit_op_mul(Instruction*);
521 void emit_op_negate(Instruction*);
522 void emit_op_neq(Instruction*);
523 void emit_op_neq_null(Instruction*);
524 void emit_op_new_array(Instruction*);
fpizlo@apple.com4500e352012-10-17 21:39:11 +0000525 void emit_op_new_array_with_size(Instruction*);
oliver@apple.coma991d692011-06-14 23:39:25 +0000526 void emit_op_new_array_buffer(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000527 void emit_op_new_func(Instruction*);
528 void emit_op_new_func_exp(Instruction*);
529 void emit_op_new_object(Instruction*);
oliver@apple.com22d55c32010-05-10 01:41:07 +0000530 void emit_op_new_regexp(Instruction*);
ggaren@apple.com5236be22009-10-17 05:52:20 +0000531 void emit_op_get_pnames(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000532 void emit_op_next_pname(Instruction*);
533 void emit_op_not(Instruction*);
534 void emit_op_nstricteq(Instruction*);
535 void emit_op_pop_scope(Instruction*);
ggaren@apple.comf3036112013-04-27 23:14:04 +0000536 void emit_op_dec(Instruction*);
537 void emit_op_inc(Instruction*);
commit-queue@webkit.org90ba1872010-11-17 08:05:39 +0000538 void emit_op_profile_did_call(Instruction*);
539 void emit_op_profile_will_call(Instruction*);
ggaren@apple.com170d6f22012-09-02 21:27:23 +0000540 void emit_op_push_name_scope(Instruction*);
541 void emit_op_push_with_scope(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000542 void emit_op_put_by_id(Instruction*);
543 void emit_op_put_by_index(Instruction*);
544 void emit_op_put_by_val(Instruction*);
barraclough@apple.com09a55682012-01-30 18:28:39 +0000545 void emit_op_put_getter_setter(Instruction*);
oliver@apple.comc909f5f2012-10-18 23:37:40 +0000546 void emit_op_init_global_const(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000547 void emit_op_ret(Instruction*);
barraclough@apple.comfd6a1502010-05-20 05:36:17 +0000548 void emit_op_ret_object_or_this(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000549 void emit_op_rshift(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000550 void emit_op_strcat(Instruction*);
551 void emit_op_stricteq(Instruction*);
552 void emit_op_sub(Instruction*);
553 void emit_op_switch_char(Instruction*);
554 void emit_op_switch_imm(Instruction*);
555 void emit_op_switch_string(Instruction*);
weinig@apple.com0d74a262009-05-12 01:06:58 +0000556 void emit_op_tear_off_activation(Instruction*);
557 void emit_op_tear_off_arguments(Instruction*);
weinig@apple.com0d74a262009-05-12 01:06:58 +0000558 void emit_op_throw(Instruction*);
oliver@apple.comf0c01b82012-11-07 00:13:54 +0000559 void emit_op_throw_static_error(Instruction*);
ggaren@apple.comf3036112013-04-27 23:14:04 +0000560 void emit_op_to_number(Instruction*);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000561 void emit_op_to_primitive(Instruction*);
562 void emit_op_unexpected_load(Instruction*);
oliver@apple.com429ede02010-04-30 07:56:38 +0000563 void emit_op_urshift(Instruction*);
weinig@apple.com0d74a262009-05-12 01:06:58 +0000564
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000565 void emitSlow_op_add(Instruction*, Vector<SlowCaseEntry>::iterator&);
566 void emitSlow_op_bitand(Instruction*, Vector<SlowCaseEntry>::iterator&);
weinig@apple.com60a74092009-05-12 01:40:00 +0000567 void emitSlow_op_bitor(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000568 void emitSlow_op_bitxor(Instruction*, Vector<SlowCaseEntry>::iterator&);
weinig@apple.com60a74092009-05-12 01:40:00 +0000569 void emitSlow_op_call(Instruction*, Vector<SlowCaseEntry>::iterator&);
570 void emitSlow_op_call_eval(Instruction*, Vector<SlowCaseEntry>::iterator&);
571 void emitSlow_op_call_varargs(Instruction*, Vector<SlowCaseEntry>::iterator&);
572 void emitSlow_op_construct(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.come2fe4ce2013-07-25 03:59:41 +0000573 void emitSlow_op_to_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
commit-queue@webkit.orgc9b19ab2011-07-18 18:55:48 +0000574 void emitSlow_op_create_this(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000575 void emitSlow_op_div(Instruction*, Vector<SlowCaseEntry>::iterator&);
576 void emitSlow_op_eq(Instruction*, Vector<SlowCaseEntry>::iterator&);
mhahnenberg@apple.com5f2e70b2013-09-25 00:37:57 +0000577 void emitSlow_op_get_callee(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000578 void emitSlow_op_get_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.com74e00b02010-09-25 21:42:00 +0000579 void emitSlow_op_get_arguments_length(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000580 void emitSlow_op_get_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.com74e00b02010-09-25 21:42:00 +0000581 void emitSlow_op_get_argument_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.com0a4803c2009-10-29 01:25:02 +0000582 void emitSlow_op_get_by_pname(Instruction*, Vector<SlowCaseEntry>::iterator&);
barraclough@apple.com8da6d972010-11-16 21:11:26 +0000583 void emitSlow_op_check_has_instance(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000584 void emitSlow_op_instanceof(Instruction*, Vector<SlowCaseEntry>::iterator&);
585 void emitSlow_op_jfalse(Instruction*, Vector<SlowCaseEntry>::iterator&);
mjs@apple.coma46c49c2009-12-06 09:42:03 +0000586 void emitSlow_op_jless(Instruction*, Vector<SlowCaseEntry>::iterator&);
barraclough@apple.com3a8c64b2011-07-04 05:59:03 +0000587 void emitSlow_op_jlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
barraclough@apple.com57b4bdb82011-07-04 19:26:05 +0000588 void emitSlow_op_jgreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
589 void emitSlow_op_jgreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
590 void emitSlow_op_jnless(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000591 void emitSlow_op_jnlesseq(Instruction*, Vector<SlowCaseEntry>::iterator&);
barraclough@apple.com57b4bdb82011-07-04 19:26:05 +0000592 void emitSlow_op_jngreater(Instruction*, Vector<SlowCaseEntry>::iterator&);
593 void emitSlow_op_jngreatereq(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000594 void emitSlow_op_jtrue(Instruction*, Vector<SlowCaseEntry>::iterator&);
mark.lam@apple.coma61ec352013-04-22 17:37:29 +0000595 void emitSlow_op_loop_hint(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000596 void emitSlow_op_lshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000597 void emitSlow_op_mod(Instruction*, Vector<SlowCaseEntry>::iterator&);
598 void emitSlow_op_mul(Instruction*, Vector<SlowCaseEntry>::iterator&);
599 void emitSlow_op_negate(Instruction*, Vector<SlowCaseEntry>::iterator&);
600 void emitSlow_op_neq(Instruction*, Vector<SlowCaseEntry>::iterator&);
commit-queue@webkit.orgc9b19ab2011-07-18 18:55:48 +0000601 void emitSlow_op_new_object(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000602 void emitSlow_op_not(Instruction*, Vector<SlowCaseEntry>::iterator&);
603 void emitSlow_op_nstricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.comf3036112013-04-27 23:14:04 +0000604 void emitSlow_op_dec(Instruction*, Vector<SlowCaseEntry>::iterator&);
605 void emitSlow_op_inc(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000606 void emitSlow_op_put_by_id(Instruction*, Vector<SlowCaseEntry>::iterator&);
607 void emitSlow_op_put_by_val(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000608 void emitSlow_op_rshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
609 void emitSlow_op_stricteq(Instruction*, Vector<SlowCaseEntry>::iterator&);
610 void emitSlow_op_sub(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.comf3036112013-04-27 23:14:04 +0000611 void emitSlow_op_to_number(Instruction*, Vector<SlowCaseEntry>::iterator&);
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000612 void emitSlow_op_to_primitive(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.com429ede02010-04-30 07:56:38 +0000613 void emitSlow_op_urshift(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.comc909f5f2012-10-18 23:37:40 +0000614
oliver@apple.com58c86752013-07-25 04:02:40 +0000615 void emit_op_resolve_scope(Instruction*);
616 void emit_op_get_from_scope(Instruction*);
617 void emit_op_put_to_scope(Instruction*);
618 void emitSlow_op_resolve_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
619 void emitSlow_op_get_from_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
620 void emitSlow_op_put_to_scope(Instruction*, Vector<SlowCaseEntry>::iterator&);
oliver@apple.comc909f5f2012-10-18 23:37:40 +0000621
oliver@apple.com429ede02010-04-30 07:56:38 +0000622 void emitRightShift(Instruction*, bool isUnsigned);
623 void emitRightShiftSlowCase(Instruction*, Vector<SlowCaseEntry>::iterator&, bool isUnsigned);
weinig@apple.com60a74092009-05-12 01:40:00 +0000624
oliver@apple.com58c86752013-07-25 04:02:40 +0000625 void emitVarInjectionCheck(bool needsVarInjectionChecks);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000626 void emitResolveClosure(int dst, bool needsVarInjectionChecks, unsigned depth);
627 void emitLoadWithStructureCheck(int scope, Structure** structureSlot);
oliver@apple.com58c86752013-07-25 04:02:40 +0000628 void emitGetGlobalProperty(uintptr_t* operandSlot);
629 void emitGetGlobalVar(uintptr_t operand);
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000630 void emitGetClosureVar(int scope, uintptr_t operand);
631 void emitPutGlobalProperty(uintptr_t* operandSlot, int value);
632 void emitPutGlobalVar(uintptr_t operand, int value);
633 void emitPutClosureVar(int scope, uintptr_t operand, int value);
oliver@apple.com58c86752013-07-25 04:02:40 +0000634
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000635 void emitInitRegister(int dst);
oliver@apple.comecfd2242008-09-20 03:00:43 +0000636
mark.lam@apple.com4fbb9c32012-10-09 07:12:56 +0000637 void emitPutIntToCallFrameHeader(RegisterID from, JSStack::CallFrameHeaderEntry);
mark.lam@apple.com4fbb9c32012-10-09 07:12:56 +0000638 void emitGetFromCallFrameHeaderPtr(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
639 void emitGetFromCallFrameHeader32(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
yuqiang.xian@intel.com5b1cb732012-10-19 05:46:10 +0000640#if USE(JSVALUE64)
641 void emitGetFromCallFrameHeader64(JSStack::CallFrameHeaderEntry, RegisterID to, RegisterID from = callFrameRegister);
642#endif
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000643
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000644 JSValue getConstantOperand(int src);
645 bool isOperandConstantImmediateInt(int src);
646 bool isOperandConstantImmediateChar(int src);
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000647
barraclough@apple.com4836c7a2011-05-01 22:20:59 +0000648 bool atJumpTarget();
649
barraclough@apple.com4f46a502008-12-13 01:39:38 +0000650 Jump getSlowCase(Vector<SlowCaseEntry>::iterator& iter)
651 {
652 return iter++->from;
653 }
654 void linkSlowCase(Vector<SlowCaseEntry>::iterator& iter)
655 {
656 iter->from.link(this);
657 ++iter;
658 }
fpizlo@apple.com9b0b31e2011-09-19 22:27:38 +0000659 void linkDummySlowCase(Vector<SlowCaseEntry>::iterator& iter)
660 {
661 ASSERT(!iter->from.isSet());
662 ++iter;
663 }
ggaren@apple.come1e45912011-11-14 19:44:32 +0000664 void linkSlowCaseIfNotJSCell(Vector<SlowCaseEntry>::iterator&, int virtualRegisterIndex);
weinig@apple.com262302f2008-09-16 03:46:58 +0000665
msaboff@apple.coma482c542013-10-04 18:20:40 +0000666 MacroAssembler::Call appendCallWithExceptionCheck(const FunctionPtr&);
msaboff@apple.com5ca16c42013-10-07 18:20:27 +0000667 MacroAssembler::Call appendCallWithCallFrameRollbackOnException(const FunctionPtr&);
msaboff@apple.coma482c542013-10-04 18:20:40 +0000668 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResult(const FunctionPtr&, int);
fpizlo@apple.com1cfa0a92013-10-16 02:19:20 +0000669 MacroAssembler::Call appendCallWithExceptionCheckSetJSValueResultWithProfile(const FunctionPtr&, int);
670
671 enum WithProfileTag { WithProfile };
672
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000673 MacroAssembler::Call callOperation(C_JITOperation_E);
674 MacroAssembler::Call callOperation(C_JITOperation_EO, GPRReg);
mark.lam@apple.com5d7e7082013-10-11 19:03:39 +0000675 MacroAssembler::Call callOperation(C_JITOperation_ESt, Structure*);
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000676 MacroAssembler::Call callOperation(C_JITOperation_EZ, int32_t);
677 MacroAssembler::Call callOperation(F_JITOperation_EJJZ, GPRReg, GPRReg, int32_t);
msaboff@apple.coma482c542013-10-04 18:20:40 +0000678 MacroAssembler::Call callOperation(J_JITOperation_E, int);
mark.lam@apple.com5d7e7082013-10-11 19:03:39 +0000679 MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg);
mark.lam@apple.com5d7e7082013-10-11 19:03:39 +0000680 MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, GPRReg, int32_t);
681 MacroAssembler::Call callOperation(J_JITOperation_EAapJcpZ, int, ArrayAllocationProfile*, const JSValue*, int32_t);
682 MacroAssembler::Call callOperation(J_JITOperation_EC, int, JSCell*);
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000683 MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg);
fpizlo@apple.com1cfa0a92013-10-16 02:19:20 +0000684#if USE(JSVALUE64)
fpizlo@apple.comd49bfe82013-10-19 02:20:14 +0000685 MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, StringImpl*);
fpizlo@apple.com1cfa0a92013-10-16 02:19:20 +0000686#else
fpizlo@apple.comd49bfe82013-10-19 02:20:14 +0000687 MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_ESsiJI, int, StructureStubInfo*, GPRReg, GPRReg, StringImpl*);
fpizlo@apple.com1cfa0a92013-10-16 02:19:20 +0000688#endif
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000689 MacroAssembler::Call callOperation(J_JITOperation_EJIdc, int, GPRReg, const Identifier*);
690 MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg);
mark.lam@apple.com65293072013-10-17 07:20:20 +0000691#if USE(JSVALUE64)
692 MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg);
693#else
694 MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
695#endif
msaboff@apple.coma482c542013-10-04 18:20:40 +0000696 MacroAssembler::Call callOperation(J_JITOperation_EP, int, void*);
fpizlo@apple.com1cfa0a92013-10-16 02:19:20 +0000697 MacroAssembler::Call callOperation(WithProfileTag, J_JITOperation_EPc, int, Instruction*);
mark.lam@apple.com2a90d902013-10-15 03:03:45 +0000698 MacroAssembler::Call callOperation(J_JITOperation_EZ, int, int32_t);
699 MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, size_t);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000700 MacroAssembler::Call callOperation(P_JITOperation_EZ, int32_t);
msaboff@apple.comc8dd3f72013-10-10 23:10:40 +0000701 MacroAssembler::Call callOperation(S_JITOperation_ECC, RegisterID, RegisterID);
702 MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID);
703 MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID);
704 MacroAssembler::Call callOperation(S_JITOperation_EOJss, RegisterID, RegisterID);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000705 MacroAssembler::Call callOperation(V_JITOperation_E);
706 MacroAssembler::Call callOperation(V_JITOperation_EC, RegisterID);
707 MacroAssembler::Call callOperation(V_JITOperation_ECC, RegisterID, RegisterID);
708 MacroAssembler::Call callOperation(V_JITOperation_ECICC, RegisterID, const Identifier*, RegisterID, RegisterID);
709 MacroAssembler::Call callOperation(V_JITOperation_EIdJZ, const Identifier*, RegisterID, int32_t);
710 MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID);
msaboff@apple.combdfcf6a2013-10-18 16:25:02 +0000711#if USE(JSVALUE64)
712 MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID);
713#else
714 MacroAssembler::Call callOperationNoExceptionCheck(V_JITOperation_EJ, RegisterID, RegisterID);
715#endif
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000716 MacroAssembler::Call callOperation(V_JITOperation_EJIdJJ, RegisterID, const Identifier*, RegisterID, RegisterID);
fpizlo@apple.comd97d7572013-10-14 18:39:45 +0000717#if USE(JSVALUE64)
fpizlo@apple.comd49bfe82013-10-19 02:20:14 +0000718 MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, StringImpl*);
fpizlo@apple.comd97d7572013-10-14 18:39:45 +0000719#else
fpizlo@apple.comd49bfe82013-10-19 02:20:14 +0000720 MacroAssembler::Call callOperation(V_JITOperation_ESsiJJI, StructureStubInfo*, RegisterID, RegisterID, RegisterID, RegisterID, StringImpl*);
fpizlo@apple.comd97d7572013-10-14 18:39:45 +0000721#endif
msaboff@apple.com853b04f2013-10-17 01:23:56 +0000722 MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000723 MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, int32_t, RegisterID);
724 MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, int32_t);
mark.lam@apple.com2a90d902013-10-15 03:03:45 +0000725 MacroAssembler::Call callOperation(V_JITOperation_EPc, Instruction*);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000726 MacroAssembler::Call callOperation(V_JITOperation_EZ, int32_t);
msaboff@apple.com2b95ada2013-10-09 13:29:00 +0000727 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(J_JITOperation_E);
msaboff@apple.com5ca16c42013-10-07 18:20:27 +0000728 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(V_JITOperation_ECb, CodeBlock*);
729 MacroAssembler::Call callOperationWithCallFrameRollbackOnException(Z_JITOperation_E);
msaboff@apple.comc8dd3f72013-10-10 23:10:40 +0000730#if USE(JSVALUE32_64)
mark.lam@apple.com03944a02013-10-14 16:42:22 +0000731 MacroAssembler::Call callOperation(F_JITOperation_EJJZ, GPRReg, GPRReg, GPRReg, GPRReg, int32_t);
732 MacroAssembler::Call callOperation(J_JITOperation_EAapJ, int, ArrayAllocationProfile*, GPRReg, GPRReg);
733 MacroAssembler::Call callOperation(J_JITOperation_EJ, int, GPRReg, GPRReg);
734 MacroAssembler::Call callOperation(J_JITOperation_EJIdc, int, GPRReg, GPRReg, const Identifier*);
735 MacroAssembler::Call callOperation(J_JITOperation_EJJ, int, GPRReg, GPRReg, GPRReg, GPRReg);
mark.lam@apple.com2a90d902013-10-15 03:03:45 +0000736 MacroAssembler::Call callOperation(P_JITOperation_EJS, GPRReg, GPRReg, size_t);
msaboff@apple.comc8dd3f72013-10-10 23:10:40 +0000737 MacroAssembler::Call callOperation(S_JITOperation_EJ, RegisterID, RegisterID);
738 MacroAssembler::Call callOperation(S_JITOperation_EJJ, RegisterID, RegisterID, RegisterID, RegisterID);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000739 MacroAssembler::Call callOperation(V_JITOperation_EIdJZ, const Identifier*, RegisterID, RegisterID, int32_t);
740 MacroAssembler::Call callOperation(V_JITOperation_EJ, RegisterID, RegisterID);
msaboff@apple.com853b04f2013-10-17 01:23:56 +0000741 MacroAssembler::Call callOperation(V_JITOperation_EJJJ, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID, RegisterID);
msaboff@apple.com4b6250f2013-10-15 18:33:04 +0000742 MacroAssembler::Call callOperation(V_JITOperation_EJZ, RegisterID, RegisterID, int32_t);
743 MacroAssembler::Call callOperation(V_JITOperation_EJZJ, RegisterID, RegisterID, int32_t, RegisterID, RegisterID);
msaboff@apple.comc8dd3f72013-10-10 23:10:40 +0000744#endif
msaboff@apple.coma482c542013-10-04 18:20:40 +0000745
barraclough@apple.coma2a2e132008-12-13 23:58:58 +0000746 Jump checkStructure(RegisterID reg, Structure* structure);
barraclough@apple.comf5f74822008-11-21 05:04:19 +0000747
commit-queue@webkit.org84814622011-08-25 01:25:38 +0000748 void updateTopCallFrame();
barraclough@apple.com23f0c052008-12-16 04:48:16 +0000749
barraclough@apple.com97bacef2009-06-05 07:55:38 +0000750 Call emitNakedCall(CodePtr function = CodePtr());
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000751
oliver@apple.com5230bd32010-05-06 19:39:54 +0000752 // Loads the character value of a single character string into dst.
753 void emitLoadCharacterString(RegisterID src, RegisterID dst, JumpList& failures);
754
fpizlo@apple.com903c3782011-09-15 23:24:27 +0000755#if ENABLE(DFG_JIT)
mark.lam@apple.coma61ec352013-04-22 17:37:29 +0000756 void emitEnterOptimizationCheck();
fpizlo@apple.com594887a2011-09-06 09:23:55 +0000757#else
mark.lam@apple.coma61ec352013-04-22 17:37:29 +0000758 void emitEnterOptimizationCheck() { }
fpizlo@apple.com594887a2011-09-06 09:23:55 +0000759#endif
mark.lam@apple.comdff6b222013-04-17 22:37:45 +0000760
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000761#ifndef NDEBUG
msaboff@apple.com7535bbd2013-09-10 06:01:03 +0000762 void printBytecodeOperandTypes(int src1, int src2);
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000763#endif
764
barraclough@apple.com536c0db2009-05-12 06:21:56 +0000765#if ENABLE(SAMPLING_FLAGS)
barraclough@apple.comc32f32e2009-05-13 09:10:02 +0000766 void setSamplingFlag(int32_t);
767 void clearSamplingFlag(int32_t);
768#endif
769
770#if ENABLE(SAMPLING_COUNTERS)
barraclough@apple.com6d410b02011-11-10 20:24:06 +0000771 void emitCount(AbstractSamplingCounter&, int32_t = 1);
barraclough@apple.com24a7abb2009-01-16 23:34:46 +0000772#endif
773
774#if ENABLE(OPCODE_SAMPLING)
barraclough@apple.com536c0db2009-05-12 06:21:56 +0000775 void sampleInstruction(Instruction*, bool = false);
barraclough@apple.com24a7abb2009-01-16 23:34:46 +0000776#endif
barraclough@apple.com536c0db2009-05-12 06:21:56 +0000777
778#if ENABLE(CODEBLOCK_SAMPLING)
779 void sampleCodeBlock(CodeBlock*);
barraclough@apple.com24a7abb2009-01-16 23:34:46 +0000780#else
barraclough@apple.com536c0db2009-05-12 06:21:56 +0000781 void sampleCodeBlock(CodeBlock*) {}
barraclough@apple.com24a7abb2009-01-16 23:34:46 +0000782#endif
783
fpizlo@apple.com903c3782011-09-15 23:24:27 +0000784#if ENABLE(DFG_JIT)
fpizlo@apple.com98aa2532011-09-25 23:40:51 +0000785 bool canBeOptimized() { return m_canBeOptimized; }
fpizlo@apple.com4d95ce62013-02-27 03:52:58 +0000786 bool canBeOptimizedOrInlined() { return m_canBeOptimizedOrInlined; }
fpizlo@apple.com5e3852d2012-05-24 00:05:21 +0000787 bool shouldEmitProfiling() { return m_shouldEmitProfiling; }
fpizlo@apple.com452cb412011-09-08 21:38:04 +0000788#else
fpizlo@apple.com98aa2532011-09-25 23:40:51 +0000789 bool canBeOptimized() { return false; }
commit-queue@webkit.org456305d2013-02-27 18:34:33 +0000790 bool canBeOptimizedOrInlined() { return false; }
fpizlo@apple.com452cb412011-09-08 21:38:04 +0000791 // Enables use of value profiler with tiered compilation turned off,
792 // in which case all code gets profiled.
fpizlo@apple.com85846322013-02-28 23:23:14 +0000793 bool shouldEmitProfiling() { return false; }
fpizlo@apple.com452cb412011-09-08 21:38:04 +0000794#endif
795
ggaren@apple.com031563e2008-11-17 02:21:16 +0000796 Interpreter* m_interpreter;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000797
798 Vector<CallRecord> m_calls;
barraclough@apple.coma2a2e132008-12-13 23:58:58 +0000799 Vector<Label> m_labels;
fpizlo@apple.com5ba07882013-10-19 23:13:23 +0000800 Vector<JITGetByIdGenerator> m_getByIds;
801 Vector<JITPutByIdGenerator> m_putByIds;
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000802 Vector<ByValCompilationInfo> m_byValCompilationInfo;
barraclough@apple.come9642652008-10-23 22:29:54 +0000803 Vector<StructureStubCompilationInfo> m_callStructureStubCompilationInfo;
barraclough@apple.coma2a2e132008-12-13 23:58:58 +0000804 Vector<JumpTable> m_jmpTable;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000805
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000806 unsigned m_bytecodeOffset;
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000807 Vector<SlowCaseEntry> m_slowCases;
808 Vector<SwitchRecord> m_switches;
809
msaboff@apple.com8f4bb0c2013-10-02 23:33:46 +0000810 JumpList m_exceptionChecks;
msaboff@apple.com5ca16c42013-10-07 18:20:27 +0000811 JumpList m_exceptionChecksWithCallFrameRollback;
msaboff@apple.com8f4bb0c2013-10-02 23:33:46 +0000812
fpizlo@apple.com5ba07882013-10-19 23:13:23 +0000813 unsigned m_getByIdIndex;
814 unsigned m_putByIdIndex;
fpizlo@apple.com0e9910a2012-10-09 23:39:53 +0000815 unsigned m_byValInstructionIndex;
weinig@apple.com0d74a262009-05-12 01:06:58 +0000816 unsigned m_callLinkInfoIndex;
ggaren@apple.comd8fccca2009-05-08 20:51:53 +0000817
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000818#if USE(JSVALUE32_64)
819 unsigned m_jumpTargetIndex;
ggaren@apple.com1ba49812010-05-19 18:28:54 +0000820 unsigned m_mappedBytecodeOffset;
ggaren@apple.come1e45912011-11-14 19:44:32 +0000821 int m_mappedVirtualRegisterIndex;
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000822 RegisterID m_mappedTag;
823 RegisterID m_mappedPayload;
824#else
825 int m_lastResultBytecodeRegister;
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000826#endif
barraclough@apple.com4836c7a2011-05-01 22:20:59 +0000827 unsigned m_jumpTargetsPosition;
barraclough@apple.com970af2c2009-08-13 05:58:36 +0000828
fpizlo@apple.com1949f322012-11-22 00:46:57 +0000829 OwnPtr<JITDisassembler> m_disassembler;
fpizlo@apple.comd2deec82012-12-10 18:17:46 +0000830 RefPtr<Profiler::Compilation> m_compilation;
oliver@apple.com31df1c82011-05-20 01:33:46 +0000831 WeakRandom m_randomGenerator;
ggaren@apple.com9a9a4b52013-04-18 19:32:17 +0000832 static CodeRef stringGetByValStubGenerator(VM*);
barraclough@apple.come32d4ec2011-09-21 22:43:11 +0000833
834#if ENABLE(VALUE_PROFILER)
fpizlo@apple.com452cb412011-09-08 21:38:04 +0000835 bool m_canBeOptimized;
fpizlo@apple.com4d95ce62013-02-27 03:52:58 +0000836 bool m_canBeOptimizedOrInlined;
fpizlo@apple.com5e3852d2012-05-24 00:05:21 +0000837 bool m_shouldEmitProfiling;
barraclough@apple.come32d4ec2011-09-21 22:43:11 +0000838#endif
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000839 } JIT_CLASS_ALIGNMENT;
mjs@apple.combe317ee2009-12-12 17:52:21 +0000840
ggaren@apple.com540d71a62009-07-30 20:57:44 +0000841} // namespace JSC
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000842
ggaren@apple.comf272d2d2008-11-17 04:25:37 +0000843#endif // ENABLE(JIT)
mrowe@apple.comf88a4632008-09-07 05:44:58 +0000844
ggaren@apple.comcc0f1f12008-11-17 23:16:00 +0000845#endif // JIT_h