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-05-26 00:21:47 -07:00
|
|
|
#if !defined(JS_32BIT) && !defined(JS_64BIT)
|
2010-05-25 14:14:13 -07:00
|
|
|
# error "This processor is UNKNOWN."
|
|
|
|
#endif
|
|
|
|
|
2010-05-22 17:09:52 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
struct VMFrame
|
|
|
|
{
|
|
|
|
#if defined(JS_CPU_ARM)
|
|
|
|
JSC::ReturnAddressPtr veneerReturn;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* This must be the first entry on CPUs which push return addresses. */
|
|
|
|
void *scriptedReturn;
|
|
|
|
|
|
|
|
#if defined(JS_CPU_X86)
|
|
|
|
uintptr_t padding[2];
|
|
|
|
#elif defined(JS_CPU_ARM)
|
|
|
|
uintptr_t padding;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
union Arguments {
|
|
|
|
struct DEFVAR {
|
|
|
|
jsatomid index;
|
|
|
|
uint32 op;
|
|
|
|
} defvar;
|
|
|
|
struct LAMBDA {
|
|
|
|
uint32 index;
|
|
|
|
JSOp op;
|
|
|
|
} lambda;
|
|
|
|
struct INITPROP {
|
|
|
|
uint32 index;
|
|
|
|
unsigned defineHow;
|
|
|
|
} initprop;
|
|
|
|
struct DEFLOCALFUN {
|
|
|
|
uint32 slot;
|
|
|
|
uint32 index;
|
|
|
|
} deflocalfun;
|
|
|
|
struct TRACER {
|
|
|
|
uint32 traceId;
|
|
|
|
uint32 offs;
|
|
|
|
} tracer;
|
|
|
|
struct SETTER {
|
|
|
|
jsatomid index;
|
|
|
|
JSOp op;
|
|
|
|
} setter;
|
|
|
|
} u;
|
|
|
|
|
|
|
|
JSFrameRegs *oldRegs;
|
|
|
|
JSFrameRegs regs;
|
|
|
|
JSStackFrame *fp;
|
|
|
|
JSContext *cx;
|
|
|
|
uintptr_t inlineCallCount;
|
|
|
|
|
|
|
|
#if defined(JS_CPU_X86)
|
|
|
|
void *savedEBX;
|
|
|
|
void *savedEDI;
|
|
|
|
void *savedESI;
|
|
|
|
void *savedEBP;
|
|
|
|
void *savedEIP;
|
|
|
|
|
|
|
|
inline void setReturnAddress(JSC::ReturnAddressPtr addr) {
|
|
|
|
*(reinterpret_cast<JSC::ReturnAddressPtr*>(this)-1) = addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline JSC::ReturnAddressPtr getReturnAddress() const {
|
|
|
|
return *(reinterpret_cast<const JSC::ReturnAddressPtr*>(this)-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(JS_CPU_X64)
|
|
|
|
void *savedRBX;
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
void *savedRSI;
|
|
|
|
void *savedRDI;
|
|
|
|
#endif
|
|
|
|
void *savedR15;
|
|
|
|
void *savedR14;
|
|
|
|
void *savedR13;
|
|
|
|
void *savedR12;
|
|
|
|
void *savedRBP;
|
|
|
|
void *savedRIP;
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
inline void setReturnAddress(JSC::ReturnAddressPtr addr) {
|
|
|
|
*(reinterpret_cast<JSC::ReturnAddressPtr*>(this)-5) = addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline JSC::ReturnAddressPtr getReturnAddress() const {
|
|
|
|
return *(reinterpret_cast<const JSC::ReturnAddressPtr*>(this)-5);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
inline void setReturnAddress(JSC::ReturnAddressPtr addr) {
|
|
|
|
*(reinterpret_cast<JSC::ReturnAddressPtr*>(this)-1) = addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline JSC::ReturnAddressPtr getReturnAddress() const {
|
|
|
|
return *(reinterpret_cast<const JSC::ReturnAddressPtr*>(this)-1);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#elif defined(JS_CPU_ARM)
|
|
|
|
void *savedR4;
|
|
|
|
void *savedR5;
|
|
|
|
void *savedR6;
|
|
|
|
void *savedR7;
|
|
|
|
void *savedR8;
|
|
|
|
void *savedR9;
|
|
|
|
void *savedR10;
|
|
|
|
void *savedR11;
|
|
|
|
void *savedLR;
|
|
|
|
|
|
|
|
inline void setReturnAddress(JSC::ReturnAddressPtr addr) {
|
|
|
|
this->veneerReturn = addr;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline JSC::ReturnAddressPtr getReturnAddress() {
|
|
|
|
return this->veneerReturn;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
# error "The VMFrame layout isn't defined for your processor architecture!"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
JSRuntime *runtime() { return cx->runtime; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef JS_CPU_ARM
|
|
|
|
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-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-05-22 17:09:52 -07:00
|
|
|
|
|
|
|
#define JS_UNJITTABLE_METHOD (reinterpret_cast<void*>(-1))
|
|
|
|
|
|
|
|
namespace mjit {
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
JaegerShot(JSContext *cx);
|
|
|
|
|
|
|
|
enum CompileStatus
|
|
|
|
{
|
|
|
|
Compile_Okay,
|
|
|
|
Compile_Abort,
|
|
|
|
Compile_Error
|
|
|
|
};
|
|
|
|
|
|
|
|
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-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;
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace mjit */
|
|
|
|
|
|
|
|
} /* namespace js */
|
|
|
|
|
|
|
|
#ifdef _MSC_VER
|
|
|
|
extern "C" void *JaegerThrowpoline(js::VMFrame *vmFrame);
|
|
|
|
#else
|
|
|
|
extern "C" void JaegerThrowpoline();
|
|
|
|
#endif
|
|
|
|
extern "C" void JaegerFromTracer();
|
|
|
|
|
|
|
|
#endif /* jsjaeger_h__ */
|