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;
|
|
|
|
|
2010-07-26 11:54:12 -07:00
|
|
|
#if defined(JS_CPU_X86) || defined(JS_CPU_X64)
|
2010-05-22 17:09:52 -07:00
|
|
|
uintptr_t padding;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
union Arguments {
|
2010-06-12 19:00:27 -07:00
|
|
|
struct {
|
|
|
|
void *ptr;
|
|
|
|
void *ptr2;
|
|
|
|
} x;
|
2010-05-22 17:09:52 -07:00
|
|
|
} u;
|
|
|
|
|
2010-07-21 03:04:39 -07:00
|
|
|
VMFrame *previous;
|
2010-05-22 17:09:52 -07:00
|
|
|
JSFrameRegs *oldRegs;
|
|
|
|
JSFrameRegs regs;
|
|
|
|
JSStackFrame *fp;
|
|
|
|
JSContext *cx;
|
2010-07-24 23:22:30 -07:00
|
|
|
uint32 inlineCallCount;
|
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-07-24 23:22:30 -07:00
|
|
|
# ifdef _MSC_VER
|
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-07-24 23:22:30 -07:00
|
|
|
# ifdef _MSC_VER
|
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() {
|
|
|
|
return reinterpret_cast<void**>(&this->veneerReturn);
|
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; }
|
|
|
|
};
|
|
|
|
|
|
|
|
#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-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-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 {
|
|
|
|
|
|
|
|
JSBool
|
|
|
|
JaegerShot(JSContext *cx);
|
|
|
|
|
|
|
|
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-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-06-19 21:58:55 -07:00
|
|
|
void
|
|
|
|
PurgeShapeDependencies(JSContext *cx);
|
|
|
|
|
2010-07-21 03:04:39 -07:00
|
|
|
union CallSite
|
|
|
|
{
|
|
|
|
struct {
|
|
|
|
uint32 codeOffset;
|
|
|
|
uint32 pcOffset;
|
|
|
|
uint32 id;
|
|
|
|
} c;
|
|
|
|
uint32 nCallSites;
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
extern "C" void JaegerFromTracer();
|
|
|
|
|
|
|
|
#endif /* jsjaeger_h__ */
|
2010-06-19 21:58:55 -07:00
|
|
|
|