2010-05-22 17:09:52 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
|
|
* vim: set ts=4 sw=4 et tw=99:
|
|
|
|
*
|
|
|
|
* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
|
|
|
|
* May 28, 2008.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Brendan Eich <brendan@mozilla.org>
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#if !defined jsjaeger_h__ && defined JS_METHODJIT
|
|
|
|
#define jsjaeger_h__
|
|
|
|
|
|
|
|
#include "jscntxt.h"
|
|
|
|
|
|
|
|
#include "assembler/assembler/MacroAssemblerCodeRef.h"
|
|
|
|
|
|
|
|
#if !defined JS_CPU_X64 && \
|
|
|
|
!defined JS_CPU_X86 && \
|
|
|
|
!defined JS_CPU_ARM
|
|
|
|
# error "Oh no, you should define a platform so this compiles."
|
|
|
|
#endif
|
|
|
|
|
2010-07-27 18:26:57 -07:00
|
|
|
#if !defined(JS_NUNBOX32) && !defined(JS_PUNBOX64)
|
|
|
|
# error "No boxing format selected."
|
2010-05-25 14:14:13 -07:00
|
|
|
#endif
|
|
|
|
|
2010-05-22 17:09:52 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
struct VMFrame
|
|
|
|
{
|
|
|
|
union Arguments {
|
2010-06-12 19:00:27 -07:00
|
|
|
struct {
|
|
|
|
void *ptr;
|
|
|
|
void *ptr2;
|
2010-08-20 13:20:38 -07:00
|
|
|
void *ptr3;
|
2010-06-12 19:00:27 -07:00
|
|
|
} x;
|
2010-05-22 17:09:52 -07:00
|
|
|
} u;
|
|
|
|
|
2010-07-21 03:04:39 -07:00
|
|
|
VMFrame *previous;
|
2010-09-07 22:52:15 -07:00
|
|
|
void *unused;
|
2010-05-22 17:09:52 -07:00
|
|
|
JSFrameRegs regs;
|
|
|
|
JSContext *cx;
|
2010-08-13 14:22:18 -07:00
|
|
|
Value *stackLimit;
|
|
|
|
JSStackFrame *entryFp;
|
2010-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
#if defined(JS_CPU_X86)
|
|
|
|
void *savedEBX;
|
|
|
|
void *savedEDI;
|
|
|
|
void *savedESI;
|
|
|
|
void *savedEBP;
|
|
|
|
void *savedEIP;
|
|
|
|
|
2010-07-24 23:22:30 -07:00
|
|
|
# ifdef JS_NO_FASTCALL
|
2010-07-21 03:04:39 -07:00
|
|
|
inline void** returnAddressLocation() {
|
|
|
|
return reinterpret_cast<void**>(this) - 3;
|
2010-06-29 21:02:49 -07:00
|
|
|
}
|
2010-07-24 23:22:30 -07:00
|
|
|
# else
|
2010-07-21 03:04:39 -07:00
|
|
|
inline void** returnAddressLocation() {
|
|
|
|
return reinterpret_cast<void**>(this) - 1;
|
2010-05-22 17:09:52 -07:00
|
|
|
}
|
2010-07-24 23:22:30 -07:00
|
|
|
# endif
|
2010-05-22 17:09:52 -07:00
|
|
|
#elif defined(JS_CPU_X64)
|
|
|
|
void *savedRBX;
|
2010-08-22 23:43:43 -07:00
|
|
|
# ifdef _WIN64
|
2010-05-22 17:09:52 -07:00
|
|
|
void *savedRSI;
|
|
|
|
void *savedRDI;
|
2010-07-24 23:22:30 -07:00
|
|
|
# endif
|
2010-05-22 17:09:52 -07:00
|
|
|
void *savedR15;
|
|
|
|
void *savedR14;
|
|
|
|
void *savedR13;
|
|
|
|
void *savedR12;
|
|
|
|
void *savedRBP;
|
|
|
|
void *savedRIP;
|
|
|
|
|
2010-08-22 23:43:43 -07:00
|
|
|
# ifdef _WIN64
|
2010-07-21 03:04:39 -07:00
|
|
|
inline void** returnAddressLocation() {
|
|
|
|
return reinterpret_cast<void**>(this) - 5;
|
2010-05-22 17:09:52 -07:00
|
|
|
}
|
2010-07-24 23:22:30 -07:00
|
|
|
# else
|
2010-07-21 03:04:39 -07:00
|
|
|
inline void** returnAddressLocation() {
|
|
|
|
return reinterpret_cast<void**>(this) - 1;
|
2010-05-22 17:09:52 -07:00
|
|
|
}
|
2010-07-24 23:22:30 -07:00
|
|
|
# endif
|
2010-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
#elif defined(JS_CPU_ARM)
|
|
|
|
void *savedR4;
|
|
|
|
void *savedR5;
|
|
|
|
void *savedR6;
|
|
|
|
void *savedR7;
|
|
|
|
void *savedR8;
|
|
|
|
void *savedR9;
|
|
|
|
void *savedR10;
|
|
|
|
void *savedR11;
|
|
|
|
void *savedLR;
|
|
|
|
|
2010-07-21 03:04:39 -07:00
|
|
|
inline void** returnAddressLocation() {
|
2010-08-10 02:28:23 -07:00
|
|
|
return reinterpret_cast<void**>(this) - 1;
|
2010-05-22 17:09:52 -07:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
# error "The VMFrame layout isn't defined for your processor architecture!"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JSRuntime *runtime() { return cx->runtime; }
|
2010-08-13 14:22:18 -07:00
|
|
|
|
2010-08-23 14:13:53 -07:00
|
|
|
JSStackFrame *&fp() { return regs.fp; }
|
2010-05-22 17:09:52 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef JS_CPU_ARM
|
2010-08-10 02:28:23 -07:00
|
|
|
// WARNING: Do not call this function directly from C(++) code because it is not ABI-compliant.
|
2010-05-22 17:09:52 -07:00
|
|
|
extern "C" void JaegerStubVeneer(void);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef void (JS_FASTCALL *VoidStub)(VMFrame &);
|
2010-05-30 19:44:29 -07:00
|
|
|
typedef void (JS_FASTCALL *VoidVpStub)(VMFrame &, Value *);
|
2010-05-22 17:09:52 -07:00
|
|
|
typedef void (JS_FASTCALL *VoidStubUInt32)(VMFrame &, uint32);
|
|
|
|
typedef void (JS_FASTCALL *VoidStubInt32)(VMFrame &, int32);
|
|
|
|
typedef JSBool (JS_FASTCALL *BoolStub)(VMFrame &);
|
|
|
|
typedef void * (JS_FASTCALL *VoidPtrStub)(VMFrame &);
|
|
|
|
typedef void * (JS_FASTCALL *VoidPtrStubPC)(VMFrame &, jsbytecode *);
|
|
|
|
typedef void * (JS_FASTCALL *VoidPtrStubUInt32)(VMFrame &, uint32);
|
|
|
|
typedef JSObject * (JS_FASTCALL *JSObjStub)(VMFrame &);
|
|
|
|
typedef JSObject * (JS_FASTCALL *JSObjStubUInt32)(VMFrame &, uint32);
|
2010-06-05 17:56:28 -07:00
|
|
|
typedef JSObject * (JS_FASTCALL *JSObjStubFun)(VMFrame &, JSFunction *);
|
2010-09-07 13:59:01 -07:00
|
|
|
typedef void (JS_FASTCALL *VoidStubFun)(VMFrame &, JSFunction *);
|
2010-06-06 00:34:14 -07:00
|
|
|
typedef JSObject * (JS_FASTCALL *JSObjStubJSObj)(VMFrame &, JSObject *);
|
|
|
|
typedef void (JS_FASTCALL *VoidStubAtom)(VMFrame &, JSAtom *);
|
|
|
|
typedef JSString * (JS_FASTCALL *JSStrStub)(VMFrame &);
|
2010-06-06 00:49:46 -07:00
|
|
|
typedef JSString * (JS_FASTCALL *JSStrStubUInt32)(VMFrame &, uint32);
|
2010-06-09 01:03:58 -07:00
|
|
|
typedef void (JS_FASTCALL *VoidStubJSObj)(VMFrame &, JSObject *);
|
2010-07-21 03:04:39 -07:00
|
|
|
typedef void (JS_FASTCALL *VoidStubPC)(VMFrame &, jsbytecode *);
|
2010-09-02 20:04:33 -07:00
|
|
|
typedef JSBool (JS_FASTCALL *BoolStubUInt32)(VMFrame &f, uint32);
|
2010-05-22 17:09:52 -07:00
|
|
|
|
2010-06-17 18:36:28 -07:00
|
|
|
#define JS_UNJITTABLE_METHOD (reinterpret_cast<void*>(1))
|
2010-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
namespace mjit {
|
|
|
|
|
2010-08-24 19:57:35 -07:00
|
|
|
struct JITScript {
|
|
|
|
JSC::ExecutablePool *execPool; /* pool that contains |ncode|; script owns the pool */
|
|
|
|
uint32 inlineLength; /* length of inline JIT'd code */
|
|
|
|
uint32 outOfLineLength; /* length of out of line JIT'd code */
|
|
|
|
js::mjit::CallSite *callSites;
|
|
|
|
uint32 nCallSites;
|
|
|
|
#ifdef JS_MONOIC
|
|
|
|
uint32 nMICs; /* number of MonoICs */
|
2010-09-02 20:04:33 -07:00
|
|
|
uint32 nCallICs; /* number of call ICs */
|
2010-08-24 19:57:35 -07:00
|
|
|
#endif
|
|
|
|
#ifdef JS_POLYIC
|
|
|
|
uint32 nPICs; /* number of PolyICs */
|
|
|
|
#endif
|
|
|
|
void *invoke; /* invoke address */
|
2010-09-02 20:04:33 -07:00
|
|
|
void *arityCheck; /* arity check address */
|
2010-08-27 15:54:30 -07:00
|
|
|
uint32 *escaping; /* list of escaping slots */
|
|
|
|
uint32 nescaping; /* number of escaping slots */
|
2010-08-24 19:57:35 -07:00
|
|
|
};
|
|
|
|
|
2010-08-20 13:20:38 -07:00
|
|
|
/* Execute a method that has been JIT compiled. */
|
|
|
|
JSBool JaegerShot(JSContext *cx);
|
|
|
|
|
|
|
|
/* Drop into the middle of a method at an arbitrary point, and execute. */
|
|
|
|
JSBool JaegerShotAtSafePoint(JSContext *cx, void *safePoint);
|
2010-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
enum CompileStatus
|
|
|
|
{
|
|
|
|
Compile_Okay,
|
|
|
|
Compile_Abort,
|
|
|
|
Compile_Error
|
|
|
|
};
|
|
|
|
|
2010-06-16 17:53:35 -07:00
|
|
|
void JS_FASTCALL
|
|
|
|
ProfileStubCall(VMFrame &f);
|
|
|
|
|
2010-05-22 17:09:52 -07:00
|
|
|
CompileStatus
|
2010-05-25 14:14:13 -07:00
|
|
|
TryCompile(JSContext *cx, JSScript *script, JSFunction *fun, JSObject *scopeChain);
|
2010-05-22 17:09:52 -07:00
|
|
|
|
2010-05-22 17:45:52 -07:00
|
|
|
void
|
|
|
|
ReleaseScriptCode(JSContext *cx, JSScript *script);
|
|
|
|
|
2010-09-02 20:04:33 -07:00
|
|
|
void
|
|
|
|
SweepCallICs(JSContext *cx);
|
|
|
|
|
2010-05-22 17:09:52 -07:00
|
|
|
static inline CompileStatus
|
2010-05-25 14:14:13 -07:00
|
|
|
CanMethodJIT(JSContext *cx, JSScript *script, JSFunction *fun, JSObject *scopeChain)
|
2010-05-22 17:09:52 -07:00
|
|
|
{
|
|
|
|
if (!(cx->options & JSOPTION_METHODJIT) || script->ncode == JS_UNJITTABLE_METHOD)
|
|
|
|
return Compile_Abort;
|
|
|
|
if (script->ncode == NULL)
|
2010-05-25 14:14:13 -07:00
|
|
|
return TryCompile(cx, script, fun, scopeChain);
|
2010-05-22 17:09:52 -07:00
|
|
|
return Compile_Okay;
|
|
|
|
}
|
|
|
|
|
2010-08-24 19:57:35 -07:00
|
|
|
struct CallSite
|
2010-07-21 03:04:39 -07:00
|
|
|
{
|
2010-08-24 19:57:35 -07:00
|
|
|
uint32 codeOffset;
|
|
|
|
uint32 pcOffset;
|
|
|
|
uint32 id;
|
2010-07-21 03:04:39 -07:00
|
|
|
};
|
|
|
|
|
2010-05-22 17:09:52 -07:00
|
|
|
} /* namespace mjit */
|
|
|
|
|
|
|
|
} /* namespace js */
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
extern "C" void *JaegerThrowpoline(js::VMFrame *vmFrame);
|
|
|
|
#else
|
|
|
|
extern "C" void JaegerThrowpoline();
|
|
|
|
#endif
|
2010-08-20 13:20:38 -07:00
|
|
|
extern "C" void InjectJaegerReturn();
|
2010-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
#endif /* jsjaeger_h__ */
|
2010-06-19 21:58:55 -07:00
|
|
|
|