1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=99:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
20 * The Initial Developer of the Original Code is
21 * Brendan Eich <brendan@mozilla.org>
25 * Alternatively, the contents of this file may be used under the terms of
26 * either of the GNU General Public License Version 2 or later (the "GPL"),
27 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
28 * in which case the provisions of the GPL or the LGPL are applicable instead
29 * of those above. If you wish to allow use of your version of this file only
30 * under the terms of either the GPL or the LGPL, and not to allow others to
31 * use your version of this file under the terms of the MPL, indicate your
32 * decision by deleting the provisions above and replace them with the notice
33 * and other provisions required by the GPL or the LGPL. If you do not delete
34 * the provisions above, a recipient may use your version of this file under
35 * the terms of any one of the MPL, the GPL or the LGPL.
37 * ***** END LICENSE BLOCK ***** */
39 #if !defined jsjaeger_h__ && defined JS_METHODJIT
44 #include "assembler/assembler/MacroAssemblerCodeRef.h"
46 #if !defined JS_CPU_X64 && \
47 !defined JS_CPU_X86 && \
49 # error "Oh no, you should define a platform so this compiles."
52 #if !defined(JS_NUNBOX32) && !defined(JS_PUNBOX64)
53 # error "No boxing format selected."
73 JSStackFrame
*entryFp
;
75 #if defined(JS_CPU_X86)
82 # ifdef JS_NO_FASTCALL
83 inline void** returnAddressLocation() {
84 return reinterpret_cast<void**>(this) - 3;
87 inline void** returnAddressLocation() {
88 return reinterpret_cast<void**>(this) - 1;
91 #elif defined(JS_CPU_X64)
105 inline void** returnAddressLocation() {
106 return reinterpret_cast<void**>(this) - 5;
109 inline void** returnAddressLocation() {
110 return reinterpret_cast<void**>(this) - 1;
114 #elif defined(JS_CPU_ARM)
125 inline void** returnAddressLocation() {
126 return reinterpret_cast<void**>(this) - 1;
129 # error "The VMFrame layout isn't defined for your processor architecture!"
132 JSRuntime
*runtime() { return cx
->runtime
; }
134 JSStackFrame
*&fp() { return regs
.fp
; }
136 bool slowEnsureSpace(uint32 nslots
);
138 bool ensureSpace(uint32 nmissing
, uint32 nslots
) {
139 /* Fast check - if it's below the limit, it's safe to just get a frame. */
140 if (JS_LIKELY(regs
.sp
+ VALUES_PER_STACK_FRAME
+ nmissing
+ nslots
< stackLimit
))
143 /* Slower check that might have to commit memory or throw an error. */
144 return slowEnsureSpace(nmissing
+ nslots
);
149 // WARNING: Do not call this function directly from C(++) code because it is not ABI-compliant.
150 extern "C" void JaegerStubVeneer(void);
153 typedef void (JS_FASTCALL
*VoidStub
)(VMFrame
&);
154 typedef void (JS_FASTCALL
*VoidVpStub
)(VMFrame
&, Value
*);
155 typedef void (JS_FASTCALL
*VoidStubUInt32
)(VMFrame
&, uint32
);
156 typedef void (JS_FASTCALL
*VoidStubInt32
)(VMFrame
&, int32
);
157 typedef JSBool (JS_FASTCALL
*BoolStub
)(VMFrame
&);
158 typedef void * (JS_FASTCALL
*VoidPtrStub
)(VMFrame
&);
159 typedef void * (JS_FASTCALL
*VoidPtrStubPC
)(VMFrame
&, jsbytecode
*);
160 typedef void * (JS_FASTCALL
*VoidPtrStubUInt32
)(VMFrame
&, uint32
);
161 typedef JSObject
* (JS_FASTCALL
*JSObjStub
)(VMFrame
&);
162 typedef JSObject
* (JS_FASTCALL
*JSObjStubUInt32
)(VMFrame
&, uint32
);
163 typedef JSObject
* (JS_FASTCALL
*JSObjStubFun
)(VMFrame
&, JSFunction
*);
164 typedef JSObject
* (JS_FASTCALL
*JSObjStubJSObj
)(VMFrame
&, JSObject
*);
165 typedef void (JS_FASTCALL
*VoidStubAtom
)(VMFrame
&, JSAtom
*);
166 typedef JSString
* (JS_FASTCALL
*JSStrStub
)(VMFrame
&);
167 typedef JSString
* (JS_FASTCALL
*JSStrStubUInt32
)(VMFrame
&, uint32
);
168 typedef void (JS_FASTCALL
*VoidStubJSObj
)(VMFrame
&, JSObject
*);
169 typedef void (JS_FASTCALL
*VoidStubPC
)(VMFrame
&, jsbytecode
*);
170 typedef JSBool (JS_FASTCALL
*BoolStubUInt32
)(VMFrame
&f
, uint32
);
172 #define JS_UNJITTABLE_METHOD (reinterpret_cast<void*>(1))
177 JSC::ExecutablePool
*execPool
; /* pool that contains |ncode|; script owns the pool */
178 uint32 inlineLength
; /* length of inline JIT'd code */
179 uint32 outOfLineLength
; /* length of out of line JIT'd code */
180 js::mjit::CallSite
*callSites
;
183 uint32 nMICs
; /* number of MonoICs */
184 uint32 nCallICs
; /* number of call ICs */
187 uint32 nPICs
; /* number of PolyICs */
189 void *invoke
; /* invoke address */
190 void *arityCheck
; /* arity check address */
191 uint32
*escaping
; /* list of escaping slots */
192 uint32 nescaping
; /* number of escaping slots */
195 /* Execute a method that has been JIT compiled. */
196 JSBool
JaegerShot(JSContext
*cx
);
198 /* Drop into the middle of a method at an arbitrary point, and execute. */
199 JSBool
JaegerShotAtSafePoint(JSContext
*cx
, void *safePoint
);
209 ProfileStubCall(VMFrame
&f
);
212 TryCompile(JSContext
*cx
, JSScript
*script
, JSFunction
*fun
, JSObject
*scopeChain
);
215 ReleaseScriptCode(JSContext
*cx
, JSScript
*script
);
218 SweepCallICs(JSContext
*cx
);
220 static inline CompileStatus
221 CanMethodJIT(JSContext
*cx
, JSScript
*script
, JSFunction
*fun
, JSObject
*scopeChain
)
223 if (!(cx
->options
& JSOPTION_METHODJIT
) || script
->ncode
== JS_UNJITTABLE_METHOD
)
224 return Compile_Abort
;
225 if (script
->ncode
== NULL
)
226 return TryCompile(cx
, script
, fun
, scopeChain
);
237 } /* namespace mjit */
242 extern "C" void *JaegerThrowpoline(js::VMFrame
*vmFrame
);
244 extern "C" void JaegerThrowpoline();
246 extern "C" void InjectJaegerReturn();
248 #endif /* jsjaeger_h__ */