Remove traceable natives (bug 698201 part 3, r=luke).

This commit is contained in:
David Anderson 2011-11-22 17:41:42 -05:00
parent 6d89716705
commit 94f9f3e31a
19 changed files with 30 additions and 1631 deletions

View File

@ -56,7 +56,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jsclone.h"
#include "jscntxt.h"
#include "jsversion.h"
@ -4527,14 +4526,7 @@ js_generic_native_method_dispatcher(JSContext *cx, uintN argc, Value *vp)
/* Clear the last parameter in case too few arguments were passed. */
vp[2 + --argc].setUndefined();
Native native =
#ifdef JS_TRACER
(fs->flags & JSFUN_TRCINFO)
? JS_FUNC_TO_DATA_PTR(JSNativeTraceInfo *, fs->call)->native
:
#endif
fs->call;
return native(cx, argc, vp);
return fs->call(cx, argc, vp);
}
JS_PUBLIC_API(JSBool)
@ -4570,7 +4562,7 @@ JS_DefineFunctions(JSContext *cx, JSObject *obj, JSFunctionSpec *fs)
fun = js_DefineFunction(cx, ctor, ATOM_TO_JSID(atom),
js_generic_native_method_dispatcher,
fs->nargs + 1,
flags & ~JSFUN_TRCINFO);
flags);
if (!fun)
return JS_FALSE;

View File

@ -110,7 +110,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsfun.h"
@ -506,25 +505,6 @@ SetArrayElement(JSContext *cx, JSObject *obj, jsdouble index, const Value &v)
return obj->setGeneric(cx, idr.id(), &tmp, true);
}
#ifdef JS_TRACER
JSBool JS_FASTCALL
js_EnsureDenseArrayCapacity(JSContext *cx, JSObject *obj, jsint i)
{
#ifdef DEBUG
Class *origObjClasp = obj->getClass();
#endif
jsuint u = jsuint(i);
JSBool ret = (obj->ensureDenseArrayElements(cx, u, 1) == JSObject::ED_OK);
/* Partially check the CallInfo's storeAccSet is correct. */
JS_ASSERT(obj->getClass() == origObjClasp);
return ret;
}
/* This function and its callees do not touch any object's .clasp field. */
JS_DEFINE_CALLINFO_3(extern, BOOL, js_EnsureDenseArrayCapacity, CONTEXT, OBJECT, INT32,
0, nanojit::ACCSET_STORE_ANY & ~tjit::ACCSET_OBJ_CLASP)
#endif
/*
* Delete the element |index| from |obj|. If |strict|, do a strict
* deletion: throw if the property is not configurable.
@ -2338,23 +2318,6 @@ js_NewbornArrayPush(JSContext *cx, JSObject *obj, const Value &vp)
return NewbornArrayPushImpl(cx, obj, vp);
}
#ifdef JS_TRACER
JSBool JS_FASTCALL
js_NewbornArrayPush_tn(JSContext *cx, JSObject *obj, ValueArgType v)
{
TraceMonitor *tm = JS_TRACE_MONITOR_ON_TRACE(cx);
if (!NewbornArrayPushImpl(cx, obj, ValueArgToConstRef(v))) {
SetBuiltinError(tm);
return JS_FALSE;
}
return WasBuiltinSuccessful(tm);
}
JS_DEFINE_CALLINFO_3(extern, BOOL_FAIL, js_NewbornArrayPush_tn, CONTEXT, OBJECT,
VALUE, 0, nanojit::ACCSET_STORE_ANY)
#endif
JSBool
js::array_push(JSContext *cx, uintN argc, Value *vp)
{
@ -3757,19 +3720,6 @@ NewDenseCopiedArray(JSContext *cx, uint32 length, const Value *vp, JSObject *pro
return obj;
}
#ifdef JS_TRACER
JS_DEFINE_CALLINFO_2(extern, OBJECT, NewDenseEmptyArray, CONTEXT, OBJECT, 0,
nanojit::ACCSET_STORE_ANY)
JS_DEFINE_CALLINFO_3(extern, OBJECT, NewDenseAllocatedArray, CONTEXT, UINT32, OBJECT, 0,
nanojit::ACCSET_STORE_ANY)
JS_DEFINE_CALLINFO_3(extern, OBJECT, NewDenseAllocatedEmptyArray, CONTEXT, UINT32, OBJECT, 0,
nanojit::ACCSET_STORE_ANY)
JS_DEFINE_CALLINFO_3(extern, OBJECT, NewDenseUnallocatedArray, CONTEXT, UINT32, OBJECT, 0,
nanojit::ACCSET_STORE_ANY)
#endif
JSObject *
NewSlowEmptyArray(JSContext *cx)
{

View File

@ -1,329 +0,0 @@
/* -*- Mode: C++; tab-width: 8; 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
* Andreas Gal <gal@mozilla.com>
*
* Contributor(s):
* Brendan Eich <brendan@mozilla.org>
* Mike Shaver <shaver@mozilla.org>
* David Anderson <danderson@mozilla.com>
*
* 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 ***** */
#include <math.h>
#include "jsapi.h"
#include "jsstdint.h"
#include "jsarray.h"
#include "jsbool.h"
#include "jscntxt.h"
#include "jsgc.h"
#include "jsiter.h"
#include "jsnum.h"
#include "jslibmath.h"
#include "jsmath.h"
#include "jsnum.h"
#include "prmjtime.h"
#include "jsdate.h"
#include "jsscope.h"
#include "jsstr.h"
#include "jsbuiltins.h"
#include "jsatominlines.h"
#include "jscntxtinlines.h"
#include "jsnuminlines.h"
#include "jsobjinlines.h"
#include "jsscopeinlines.h"
using namespace avmplus;
using namespace nanojit;
using namespace js;
JS_FRIEND_API(void)
js_SetTraceableNativeFailed(JSContext *cx)
{
/*
* We might not be on trace (we might have deep bailed) so we hope
* cx->compartment is correct.
*/
SetBuiltinError(JS_TRACE_MONITOR_FROM_CONTEXT(cx));
}
/*
* NB: bool FASTCALL is not compatible with Nanojit's calling convention usage.
* Do not use bool FASTCALL, use JSBool only!
*/
jsdouble FASTCALL
js_dmod(jsdouble a, jsdouble b)
{
if (b == 0.0) {
jsdpun u;
u.s.hi = JSDOUBLE_HI32_NAN;
u.s.lo = JSDOUBLE_LO32_NAN;
return u.d;
}
return js_fmod(a, b);
}
JS_DEFINE_CALLINFO_2(extern, DOUBLE, js_dmod, DOUBLE, DOUBLE, 1, ACCSET_NONE)
int32 FASTCALL
js_imod(int32 a, int32 b)
{
if (a < 0 || b <= 0)
return -1;
int r = a % b;
return r;
}
JS_DEFINE_CALLINFO_2(extern, INT32, js_imod, INT32, INT32, 1, ACCSET_NONE)
#if JS_BITS_PER_WORD == 32
jsdouble FASTCALL
js_UnboxNumberAsDouble(uint32 tag, uint32 payload)
{
if (tag == JSVAL_TAG_INT32)
return (double)(int32)payload;
JS_ASSERT(tag <= JSVAL_TAG_CLEAR);
jsval_layout l;
l.s.tag = (JSValueTag)tag;
l.s.payload.u32 = payload;
return l.asDouble;
}
JS_DEFINE_CALLINFO_2(extern, DOUBLE, js_UnboxNumberAsDouble, UINT32, UINT32, 1, ACCSET_NONE)
int32 FASTCALL
js_UnboxNumberAsInt32(uint32 tag, uint32 payload)
{
if (tag == JSVAL_TAG_INT32)
return (int32)payload;
JS_ASSERT(tag <= JSVAL_TAG_CLEAR);
jsval_layout l;
l.s.tag = (JSValueTag)tag;
l.s.payload.u32 = payload;
return js_DoubleToECMAInt32(l.asDouble);
}
JS_DEFINE_CALLINFO_2(extern, INT32, js_UnboxNumberAsInt32, UINT32, UINT32, 1, ACCSET_NONE)
#elif JS_BITS_PER_WORD == 64
jsdouble FASTCALL
js_UnboxNumberAsDouble(Value v)
{
if (v.isInt32())
return (jsdouble)v.toInt32();
JS_ASSERT(v.isDouble());
return v.toDouble();
}
JS_DEFINE_CALLINFO_1(extern, DOUBLE, js_UnboxNumberAsDouble, JSVAL, 1, ACCSET_NONE)
int32 FASTCALL
js_UnboxNumberAsInt32(Value v)
{
if (v.isInt32())
return v.toInt32();
JS_ASSERT(v.isDouble());
return js_DoubleToECMAInt32(v.toDouble());
}
JS_DEFINE_CALLINFO_1(extern, INT32, js_UnboxNumberAsInt32, VALUE, 1, ACCSET_NONE)
#endif
int32 FASTCALL
js_DoubleToInt32(jsdouble d)
{
return js_DoubleToECMAInt32(d);
}
JS_DEFINE_CALLINFO_1(extern, INT32, js_DoubleToInt32, DOUBLE, 1, ACCSET_NONE)
uint32 FASTCALL
js_DoubleToUint32(jsdouble d)
{
return js_DoubleToECMAUint32(d);
}
JS_DEFINE_CALLINFO_1(extern, UINT32, js_DoubleToUint32, DOUBLE, 1, ACCSET_NONE)
/*
* js_StringToNumber and js_StringToInt32 store into their second argument, so
* they need to be annotated accordingly. To be future-proof, we use
* ACCSET_STORE_ANY so that new callers don't have to remember to update the
* annotation.
*/
jsdouble FASTCALL
js_StringToNumber(JSContext* cx, JSString* str, JSBool *ok)
{
double out = 0; /* silence warnings. */
*ok = StringToNumberType<jsdouble>(cx, str, &out);
return out;
}
JS_DEFINE_CALLINFO_3(extern, DOUBLE, js_StringToNumber, CONTEXT, STRING, BOOLPTR,
0, ACCSET_STORE_ANY)
int32 FASTCALL
js_StringToInt32(JSContext* cx, JSString* str, JSBool *ok)
{
int32 out = 0; /* silence warnings. */
*ok = StringToNumberType<int32>(cx, str, &out);
return out;
}
JS_DEFINE_CALLINFO_3(extern, INT32, js_StringToInt32, CONTEXT, STRING, BOOLPTR,
0, ACCSET_STORE_ANY)
/* Nb: it's always safe to set isDefinitelyAtom to false if you're unsure or don't know. */
static inline JSBool
AddPropertyHelper(JSContext* cx, JSObject* obj, Shape* shape, bool isDefinitelyAtom)
{
JS_ASSERT(shape->previous() == obj->lastProperty());
if (obj->nativeEmpty()) {
if (!obj->ensureClassReservedSlotsForEmptyObject(cx))
return false;
}
uint32 slot;
slot = shape->slot;
JS_ASSERT(slot == obj->slotSpan());
if (slot < obj->numSlots()) {
JS_ASSERT(obj->getSlot(slot).isUndefined());
} else {
if (!obj->allocSlot(cx, &slot))
return false;
JS_ASSERT(slot == shape->slot);
}
obj->extend(cx, shape, isDefinitelyAtom);
return !js_IsPropertyCacheDisabled(cx);
}
JSBool FASTCALL
js_AddProperty(JSContext* cx, JSObject* obj, Shape* shape)
{
return AddPropertyHelper(cx, obj, shape, /* isDefinitelyAtom = */false);
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_AddProperty, CONTEXT, OBJECT, SHAPE, 0, ACCSET_STORE_ANY)
JSBool FASTCALL
js_AddAtomProperty(JSContext* cx, JSObject* obj, Shape* shape)
{
return AddPropertyHelper(cx, obj, shape, /* isDefinitelyAtom = */true);
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_AddAtomProperty, CONTEXT, OBJECT, SHAPE, 0, ACCSET_STORE_ANY)
static JSBool
HasProperty(JSContext* cx, JSObject* obj, jsid id)
{
// Check that we know how the lookup op will behave.
for (JSObject* pobj = obj; pobj; pobj = pobj->getProto()) {
if (pobj->getOps()->lookupProperty)
return JS_NEITHER;
Class* clasp = pobj->getClass();
if (clasp->resolve != JS_ResolveStub && clasp != &StringClass)
return JS_NEITHER;
}
JSObject* obj2;
JSProperty* prop;
if (!LookupPropertyWithFlags(cx, obj, id, JSRESOLVE_QUALIFIED, &obj2, &prop))
return JS_NEITHER;
return prop != NULL;
}
JSBool FASTCALL
js_HasNamedProperty(JSContext* cx, JSObject* obj, JSString* idstr)
{
JSAtom *atom = js_AtomizeString(cx, idstr);
if (!atom)
return JS_NEITHER;
return HasProperty(cx, obj, ATOM_TO_JSID(atom));
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedProperty, CONTEXT, OBJECT, STRING,
0, ACCSET_STORE_ANY)
JSBool FASTCALL
js_HasNamedPropertyInt32(JSContext* cx, JSObject* obj, int32 index)
{
jsid id;
if (!js_Int32ToId(cx, index, &id))
return JS_NEITHER;
return HasProperty(cx, obj, id);
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_HasNamedPropertyInt32, CONTEXT, OBJECT, INT32,
0, ACCSET_STORE_ANY)
JSString* FASTCALL
js_TypeOfObject(JSContext* cx, JSObject* obj)
{
JS_ASSERT(obj);
return cx->runtime->atomState.typeAtoms[obj->typeOf(cx)];
}
JS_DEFINE_CALLINFO_2(extern, STRING, js_TypeOfObject, CONTEXT, OBJECT, 1, ACCSET_NONE)
JSString* FASTCALL
js_BooleanIntToString(JSContext *cx, int32 unboxed)
{
JS_ASSERT(uint32(unboxed) <= 1);
return cx->runtime->atomState.booleanAtoms[unboxed];
}
JS_DEFINE_CALLINFO_2(extern, STRING, js_BooleanIntToString, CONTEXT, INT32, 1, ACCSET_NONE)
JSObject* FASTCALL
js_NewNullClosure(JSContext* cx, JSObject* funobj, JSObject* proto, JSObject* parent)
{
JS_ASSERT(funobj->isFunction());
JS_ASSERT(proto->isFunction());
JS_ASSERT(JS_ON_TRACE(cx));
JSFunction *fun = (JSFunction*) funobj;
JS_ASSERT(funobj->getFunctionPrivate() == fun);
types::TypeObject *type = proto->getNewType(cx);
if (!type)
return NULL;
JSObject* closure = js_NewGCObject(cx, gc::FINALIZE_OBJECT2);
if (!closure)
return NULL;
if (!closure->initSharingEmptyShape(cx, &FunctionClass, type, parent,
fun, gc::FINALIZE_OBJECT2)) {
return NULL;
}
return closure;
}
JS_DEFINE_CALLINFO_4(extern, OBJECT, js_NewNullClosure, CONTEXT, OBJECT, OBJECT, OBJECT,
0, ACCSET_STORE_ANY)

View File

@ -1,653 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 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
* Mozilla Corporation.
*
* Contributor(s):
* Jason Orendorff <jorendorff@mozilla.com>
*
* 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 ***** */
#ifndef jsbuiltins_h___
#define jsbuiltins_h___
#ifdef JS_TRACER
// nanojit.h includes windows.h, so undo the obnoxious #defines, if needed
#include "nanojit/nanojit.h"
#include "jswin.h"
#include "jsprvtd.h"
enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_NEITHER };
enum {
JSTN_ERRTYPE_MASK = 0x07,
JSTN_UNBOX_AFTER = 0x08,
JSTN_MORE = 0x10,
JSTN_CONSTRUCTOR = 0x20,
JSTN_RETURN_NULLABLE_STR = 0x40,
JSTN_RETURN_NULLABLE_OBJ = 0x80
};
#define JSTN_ERRTYPE(jstn) ((jstn)->flags & JSTN_ERRTYPE_MASK)
/*
* Type describing a type specialization of a js::Native.
*
* |prefix| and |argtypes| declare what arguments should be passed to the
* native function. |prefix| can contain the following characters:
*
* 'C': a JSContext* argument
* 'T': |this| as a JSObject* argument (bails if |this| is not an object)
* 'S': |this| as a JSString* argument (bails if |this| is not a string)
* 'R': a JSRuntime* argument
* 'P': the pc as a jsbytecode*
* 'D': |this| as a number (jsdouble)
* 'f': the function being called, as a JSObject*
* 'p': the .prototype of the function, as a JSObject*
*
* The corresponding things will get passed as arguments to the builtin in
* reverse order (so TC means JSContext* as the first arg, and the
* JSObject* for |this| as the second arg).
*
* |argtypes| can contain the following characters:
* 'd': a number (double) argument
* 'i': an integer argument
* 's': a JSString* argument
* 'o': a JSObject* argument
* 'r': a JSObject* argument that is of class RegExpClass
* 'f': a JSObject* argument that is of class FunctionClass
* 'v': a value argument: on 32-bit, a Value*, on 64-bit, a jsval
*/
struct JSSpecializedNative {
const nanojit::CallInfo *builtin;
const char *prefix;
const char *argtypes;
uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
JSTN_CONSTRUCTOR */
};
/*
* Type holding extra trace-specific information about a fast native.
*
* 'specializations' points to a static array of available specializations
* terminated by the lack of having the JSTN_MORE flag set.
*/
struct JSNativeTraceInfo {
js::Native native;
JSSpecializedNative *specializations;
};
/* Macros used by JS_DEFINE_CALLINFOn. */
#ifdef DEBUG
#define _JS_CI_NAME(op) ,#op
#else
#define _JS_CI_NAME(op)
#endif
#define _JS_I32_ARGTYPE nanojit::ARGTYPE_I
#define _JS_I32_RETTYPE nanojit::ARGTYPE_I
#define _JS_U64_ARGTYPE nanojit::ARGTYPE_Q
#define _JS_U64_RETTYPE nanojit::ARGTYPE_Q
#define _JS_F64_ARGTYPE nanojit::ARGTYPE_D
#define _JS_F64_RETTYPE nanojit::ARGTYPE_D
#define _JS_PTR_ARGTYPE nanojit::ARGTYPE_P
#define _JS_PTR_RETTYPE nanojit::ARGTYPE_P
struct ClosureVarInfo;
/*
* Supported types for builtin functions.
*
* Types with -- for the two string fields are not permitted as argument types
* in JS_DEFINE_TRCINFO.
*
* There are three kinds of traceable-native error handling.
*
* - If a traceable native's return type ends with _FAIL, it always runs to
* completion. It can either succeed or fail with an error or exception;
* on success, it may or may not stay on trace. There may be side effects
* in any case. If the call succeeds but bails off trace, we resume in the
* interpreter at the next opcode.
*
* _FAIL builtins indicate failure or bailing off trace by setting bits in
* cx->interpState->builtinStatus.
*
* - If a traceable native's return type contains _RETRY, it can either
* succeed, fail with a JS exception, or tell the caller to bail off trace
* and retry the call from the interpreter. The last case happens if the
* builtin discovers that it can't do its job without examining the JS
* stack, reentering the interpreter, accessing properties of the global
* object, etc.
*
* The builtin must detect the need to retry before committing any side
* effects. If a builtin can't do this, it must use a _FAIL return type
* instead of _RETRY.
*
* _RETRY builtins indicate failure with a special return value that
* depends on the return type:
*
* BOOL_RETRY: JS_NEITHER
* INT32_RETRY: any negative value
* STRING_RETRY: NULL
* OBJECT_RETRY_NULL: NULL
*
* _RETRY function calls are faster than _FAIL calls. Each _RETRY call
* saves two writes to tm->bailExit and a read from state->builtinStatus.
*
* - All other traceable natives are infallible (e.g. Date.now, Math.log).
*
* Special builtins known to the tracer can have their own idiosyncratic
* error codes.
*
* When a traceable native returns a value indicating failure, we fall off
* trace. If an exception is pending, it is thrown; otherwise, we assume the
* builtin had no side effects and retry the current bytecode in the
* interpreter.
*
* So a builtin must not return a value indicating failure after causing side
* effects (such as reporting an error), without setting an exception pending.
* The operation would be retried, despite the first attempt's observable
* effects.
*/
#define _JS_CTYPE(ctype, size, pch, ach, flags) (ctype, size, pch, ach, flags)
#define _JS_CTYPE_CONTEXT _JS_CTYPE(JSContext *, _JS_PTR,"C", "", INFALLIBLE)
#define _JS_CTYPE_RUNTIME _JS_CTYPE(JSRuntime *, _JS_PTR,"R", "", INFALLIBLE)
#define _JS_CTYPE_MATHCACHE _JS_CTYPE(js::MathCache *, _JS_PTR,"M", "", INFALLIBLE)
#define _JS_CTYPE_THIS _JS_CTYPE(JSObject *, _JS_PTR,"T", "", INFALLIBLE)
#define _JS_CTYPE_THIS_DOUBLE _JS_CTYPE(jsdouble, _JS_F64,"D", "", INFALLIBLE)
#define _JS_CTYPE_THIS_STRING _JS_CTYPE(JSString *, _JS_PTR,"S", "", INFALLIBLE)
#define _JS_CTYPE_CALLEE _JS_CTYPE(JSObject *, _JS_PTR,"f", "", INFALLIBLE)
#define _JS_CTYPE_CALLEE_PROTOTYPE _JS_CTYPE(JSObject *, _JS_PTR,"p", "", INFALLIBLE)
#define _JS_CTYPE_FUNCTION _JS_CTYPE(JSFunction *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_PC _JS_CTYPE(jsbytecode *, _JS_PTR,"P", "", INFALLIBLE)
#define _JS_CTYPE_VALUEPTR _JS_CTYPE(js::Value *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const js::Value *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_JSID _JS_CTYPE(jsid, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_JSVAL _JS_CTYPE(js::Value, _JS_U64, --, --, INFALLIBLE)
#define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
#define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_NEITHER)
#define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
#define _JS_CTYPE_BOOLPTR _JS_CTYPE(JSBool *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_INT32 _JS_CTYPE(int32, _JS_I32, "","i", INFALLIBLE)
#define _JS_CTYPE_INT32_RETRY _JS_CTYPE(int32, _JS_I32, --, --, FAIL_NEG)
#define _JS_CTYPE_INT32_FAIL _JS_CTYPE(int32, _JS_I32, --, --, FAIL_STATUS)
#define _JS_CTYPE_INT32PTR _JS_CTYPE(int32 *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_UINT32 _JS_CTYPE(uint32, _JS_I32, "","i", INFALLIBLE)
#define _JS_CTYPE_UINT32_RETRY _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_NEG)
#define _JS_CTYPE_UINT32_FAIL _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_STATUS)
#define _JS_CTYPE_DOUBLE _JS_CTYPE(jsdouble, _JS_F64, "","d", INFALLIBLE)
#define _JS_CTYPE_DOUBLE_FAIL _JS_CTYPE(jsdouble, _JS_F64, --, --, FAIL_STATUS)
#define _JS_CTYPE_STRING _JS_CTYPE(JSString *, _JS_PTR, "","s", INFALLIBLE)
#define _JS_CTYPE_STRING_RETRY _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_NULL)
#define _JS_CTYPE_STRING_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS)
#define _JS_CTYPE_STRING_OR_NULL_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS | \
JSTN_RETURN_NULLABLE_STR)
#define _JS_CTYPE_STRINGPTR _JS_CTYPE(JSString **, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_OBJECT _JS_CTYPE(JSObject *, _JS_PTR, "","o", INFALLIBLE)
#define _JS_CTYPE_OBJECT_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL)
#define _JS_CTYPE_OBJECT_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS)
#define _JS_CTYPE_OBJECT_OR_NULL_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS | \
JSTN_RETURN_NULLABLE_OBJ)
#define _JS_CTYPE_OBJECTPTR _JS_CTYPE(JSObject **, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_CONSTRUCTOR_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL | \
JSTN_CONSTRUCTOR)
#define _JS_CTYPE_REGEXP _JS_CTYPE(JSObject *, _JS_PTR, "","r", INFALLIBLE)
#define _JS_CTYPE_SHAPE _JS_CTYPE(js::Shape *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_TRACERSTATE _JS_CTYPE(TracerState *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_FRAGMENT _JS_CTYPE(nanojit::Fragment *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_CLASS _JS_CTYPE(js::Class *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_DOUBLEPTR _JS_CTYPE(double *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_CHARPTR _JS_CTYPE(char *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_CVIPTR _JS_CTYPE(const ClosureVarInfo *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_FRAMEINFO _JS_CTYPE(FrameInfo *, _JS_PTR, --, --, INFALLIBLE)
#define _JS_CTYPE_UINTN _JS_CTYPE(uintN, _JS_PTR, --, --, INFALLIBLE)
/*
* The "VALUE" type is used to indicate that a native takes a js::Value
* parameter by value. Unfortunately, for technical reasons, we can't simply
* have the parameter type be js::Value. Furthermore, the right thing to pass
* differs based on word size. Thus, a native that declares a parameter of type
* VALUE should have the corresponding argument type be:
* - on 32-bit: const Value*
* - on 64-bit: jsval (which is a uint64)
*
* To write code that just does the right thing, use the pattern:
* void foo(js::ValueArgType arg) {
* const js::Value &v = js::ValueArgToConstRef(arg);
*/
#if JS_BITS_PER_WORD == 32
# define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_PTR, "","v", INFALLIBLE)
#elif JS_BITS_PER_WORD == 64
# define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_U64, "","v", INFALLIBLE)
#endif
namespace js {
#if JS_BITS_PER_WORD == 32
typedef const js::Value *ValueArgType;
static JS_ALWAYS_INLINE const js::Value &
ValueArgToConstRef(const js::Value *arg)
{
return *arg;
}
#elif JS_BITS_PER_WORD == 64
typedef js::Value ValueArgType;
static JS_ALWAYS_INLINE const Value &
ValueArgToConstRef(const Value &v)
{
return v;
}
#endif
} /* namespace js */
#define _JS_EXPAND(tokens) tokens
#define _JS_CTYPE_TYPE2(t,s,p,a,f) t
#define _JS_CTYPE_TYPE(tyname) _JS_EXPAND(_JS_CTYPE_TYPE2 _JS_CTYPE_##tyname)
#define _JS_CTYPE_RETTYPE2(t,s,p,a,f) s##_RETTYPE
#define _JS_CTYPE_RETTYPE(tyname) _JS_EXPAND(_JS_CTYPE_RETTYPE2 _JS_CTYPE_##tyname)
#define _JS_CTYPE_ARGTYPE2(t,s,p,a,f) s##_ARGTYPE
#define _JS_CTYPE_ARGTYPE(tyname) _JS_EXPAND(_JS_CTYPE_ARGTYPE2 _JS_CTYPE_##tyname)
#define _JS_CTYPE_PCH2(t,s,p,a,f) p
#define _JS_CTYPE_PCH(tyname) _JS_EXPAND(_JS_CTYPE_PCH2 _JS_CTYPE_##tyname)
#define _JS_CTYPE_ACH2(t,s,p,a,f) a
#define _JS_CTYPE_ACH(tyname) _JS_EXPAND(_JS_CTYPE_ACH2 _JS_CTYPE_##tyname)
#define _JS_CTYPE_FLAGS2(t,s,p,a,f) f
#define _JS_CTYPE_FLAGS(tyname) _JS_EXPAND(_JS_CTYPE_FLAGS2 _JS_CTYPE_##tyname)
#define _JS_static_TN(t) static t
#define _JS_static_CI static
#define _JS_extern_TN(t) extern t
#define _JS_extern_CI
#define _JS_FRIEND_TN(t) extern JS_FRIEND_API(t)
#define _JS_FRIEND_CI
#define _JS_TN_LINKAGE(linkage, t) _JS_##linkage##_TN(t)
#define _JS_CI_LINKAGE(linkage) _JS_##linkage##_CI
#define _JS_CALLINFO(name) name##_ci
#if defined(JS_NO_FASTCALL) && defined(NANOJIT_IA32)
#define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
_JS_TN_LINKAGE(linkage, crtype) name cargtypes; \
_JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
{ (intptr_t) &name, argtypes, nanojit::ABI_CDECL, isPure, storeAccSet _JS_CI_NAME(name) };\
JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
#else
#define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
_JS_TN_LINKAGE(linkage, crtype) FASTCALL name cargtypes; \
_JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
{ (uintptr_t) &name, argtypes, nanojit::ABI_FASTCALL, isPure, storeAccSet _JS_CI_NAME(name) }; \
JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
#endif
/*
* This macro is used for builtin functions that can be called from JITted
* code. It declares a C function named <op> and a CallInfo struct named
* <op>_ci so the tracer can call it. The <N> in JS_DEFINE_CALLINFO_<N> is
* the number of arguments the builtin takes. Builtins with no arguments
* are not supported. Using a macro is clunky but ensures that the types
* for each C function matches those for the corresponding CallInfo struct;
* mismatched types can cause subtle problems.
*
* The macro arguments are:
*
* - The linkage for the function and the associated CallInfo global. It
* can be extern, static, or FRIEND, which specifies JS_FRIEND_API linkage
* for the function.
*
* - The return type. This identifier must name one of the _JS_TYPEINFO_*
* macros defined in jsbuiltins.h.
*
* - The builtin name.
*
* - The parameter types.
*
* - The isPure flag. Set to 1 if:
* (a) the function's return value is determined solely by its arguments
* (ie. no hidden state, no implicit inputs used such as global
* variables or the result of an I/O operation); and
* (b) the function causes no observable side-effects (ie. no writes to
* global variables, no I/O output).
* Multiple calls to a pure function can be merged during CSE.
*
* - The storeAccSet. This indicates which memory access regions the function
* accesses. It must be ACCSET_NONE if the function is pure; use
* ACCSET_STORE_ANY if you're not sure. Used to determine if each call site
* of the function aliases any loads.
*/
#define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0)), \
nanojit::CallInfo::typeSig1(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1)), \
nanojit::CallInfo::typeSig2(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2)), \
nanojit::CallInfo::typeSig3(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2), \
_JS_CTYPE_TYPE(at3)), \
nanojit::CallInfo::typeSig4(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2), \
_JS_CTYPE_ARGTYPE(at3)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2), \
_JS_CTYPE_TYPE(at3), \
_JS_CTYPE_TYPE(at4)), \
nanojit::CallInfo::typeSig5(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2), \
_JS_CTYPE_ARGTYPE(at3), \
_JS_CTYPE_ARGTYPE(at4)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2), \
_JS_CTYPE_TYPE(at3), \
_JS_CTYPE_TYPE(at4), \
_JS_CTYPE_TYPE(at5)), \
nanojit::CallInfo::typeSig6(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2), \
_JS_CTYPE_ARGTYPE(at3), \
_JS_CTYPE_ARGTYPE(at4), \
_JS_CTYPE_ARGTYPE(at5)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, \
storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2), \
_JS_CTYPE_TYPE(at3), \
_JS_CTYPE_TYPE(at4), \
_JS_CTYPE_TYPE(at5), \
_JS_CTYPE_TYPE(at6)), \
nanojit::CallInfo::typeSig7(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2), \
_JS_CTYPE_ARGTYPE(at3), \
_JS_CTYPE_ARGTYPE(at4), \
_JS_CTYPE_ARGTYPE(at5), \
_JS_CTYPE_ARGTYPE(at6)), \
isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, \
storeAccSet) \
_JS_DEFINE_CALLINFO(linkage, op, \
_JS_CTYPE_TYPE(rt), \
(_JS_CTYPE_TYPE(at0), \
_JS_CTYPE_TYPE(at1), \
_JS_CTYPE_TYPE(at2), \
_JS_CTYPE_TYPE(at3), \
_JS_CTYPE_TYPE(at4), \
_JS_CTYPE_TYPE(at5), \
_JS_CTYPE_TYPE(at6), \
_JS_CTYPE_TYPE(at7)), \
nanojit::CallInfo::typeSig8(_JS_CTYPE_RETTYPE(rt), \
_JS_CTYPE_ARGTYPE(at0), \
_JS_CTYPE_ARGTYPE(at1), \
_JS_CTYPE_ARGTYPE(at2), \
_JS_CTYPE_ARGTYPE(at3), \
_JS_CTYPE_ARGTYPE(at4), \
_JS_CTYPE_ARGTYPE(at5), \
_JS_CTYPE_ARGTYPE(at6), \
_JS_CTYPE_ARGTYPE(at7)), \
isPure, storeAccSet)
#define JS_DECLARE_CALLINFO(name) extern const nanojit::CallInfo _JS_CALLINFO(name);
#define _JS_TN_INIT_HELPER_n(n, args) _JS_TN_INIT_HELPER_##n args
#define _JS_TN_INIT_HELPER_1(linkage, rt, op, at0, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) \
_JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) \
_JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) \
_JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) \
_JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) \
_JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) \
_JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define _JS_TN_INIT_HELPER_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet) \
&_JS_CALLINFO(op), \
_JS_CTYPE_PCH(at7) _JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) \
_JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
_JS_CTYPE_ACH(at7) _JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) \
_JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
_JS_CTYPE_FLAGS(rt)
#define JS_DEFINE_TRCINFO_1(name, tn0) \
_JS_DEFINE_CALLINFO_n tn0 \
JSSpecializedNative name##_sns[] = { \
{ _JS_TN_INIT_HELPER_n tn0 } \
}; \
JSNativeTraceInfo name##_trcinfo = { name, name##_sns };
#define JS_DEFINE_TRCINFO_2(name, tn0, tn1) \
_JS_DEFINE_CALLINFO_n tn0 \
_JS_DEFINE_CALLINFO_n tn1 \
JSSpecializedNative name##_sns[] = { \
{ _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn1 } \
}; \
JSNativeTraceInfo name##_trcinfo = { name, name##_sns };
#define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2) \
_JS_DEFINE_CALLINFO_n tn0 \
_JS_DEFINE_CALLINFO_n tn1 \
_JS_DEFINE_CALLINFO_n tn2 \
JSSpecializedNative name##_sns[] = { \
{ _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn2 } \
}; \
JSNativeTraceInfo name##_trcinfo = { name, name##_sns };
#define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3) \
_JS_DEFINE_CALLINFO_n tn0 \
_JS_DEFINE_CALLINFO_n tn1 \
_JS_DEFINE_CALLINFO_n tn2 \
_JS_DEFINE_CALLINFO_n tn3 \
JSSpecializedNative name##_sns[] = { \
{ _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn2 | JSTN_MORE }, \
{ _JS_TN_INIT_HELPER_n tn3 } \
}; \
JSNativeTraceInfo name##_trcinfo = { name, name##_sns };
#define _JS_DEFINE_CALLINFO_n(n, args) JS_DEFINE_CALLINFO_##n args
jsdouble FASTCALL
js_StringToNumber(JSContext* cx, JSString* str, JSBool *ok);
/* Extern version of SetBuiltinError. */
extern JS_FRIEND_API(void)
js_SetTraceableNativeFailed(JSContext *cx);
extern jsdouble FASTCALL
js_dmod(jsdouble a, jsdouble b);
#else
#define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet)
#define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet)
#define JS_DECLARE_CALLINFO(name)
#define JS_DEFINE_TRCINFO_1(name, tn0)
#define JS_DEFINE_TRCINFO_2(name, tn0, tn1)
#define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2)
#define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3)
#endif /* !JS_TRACER */
/* Defined in jsarray.cpp. */
namespace js {
JS_DECLARE_CALLINFO(NewDenseEmptyArray)
JS_DECLARE_CALLINFO(NewDenseAllocatedArray)
JS_DECLARE_CALLINFO(NewDenseUnallocatedArray)
JS_DECLARE_CALLINFO(NewDenseAllocatedEmptyArray)
}
JS_DECLARE_CALLINFO(js_NewbornArrayPush_tn)
JS_DECLARE_CALLINFO(js_EnsureDenseArrayCapacity)
/* Defined in jsbuiltins.cpp. */
JS_DECLARE_CALLINFO(js_UnboxNumberAsDouble)
JS_DECLARE_CALLINFO(js_UnboxNumberAsInt32)
JS_DECLARE_CALLINFO(js_dmod)
JS_DECLARE_CALLINFO(js_imod)
JS_DECLARE_CALLINFO(js_DoubleToInt32)
JS_DECLARE_CALLINFO(js_DoubleToUint32)
JS_DECLARE_CALLINFO(js_StringToNumber)
JS_DECLARE_CALLINFO(js_StringToInt32)
JS_DECLARE_CALLINFO(js_AddProperty)
JS_DECLARE_CALLINFO(js_AddAtomProperty)
JS_DECLARE_CALLINFO(js_HasNamedProperty)
JS_DECLARE_CALLINFO(js_HasNamedPropertyInt32)
JS_DECLARE_CALLINFO(js_TypeOfObject)
JS_DECLARE_CALLINFO(js_BooleanIntToString)
JS_DECLARE_CALLINFO(js_NewNullClosure)
/* Defined in jsfun.cpp. */
JS_DECLARE_CALLINFO(js_AllocFlatClosure)
JS_DECLARE_CALLINFO(js_PutArgumentsOnTrace)
JS_DECLARE_CALLINFO(js_PutCallObjectOnTrace)
JS_DECLARE_CALLINFO(js_SetCallVar)
JS_DECLARE_CALLINFO(js_SetCallArg)
JS_DECLARE_CALLINFO(js_CloneFunctionObject)
JS_DECLARE_CALLINFO(js_CreateCallObjectOnTrace)
JS_DECLARE_CALLINFO(js_NewArgumentsOnTrace)
/* Defined in jsnum.cpp. */
JS_DECLARE_CALLINFO(js_NumberToString)
/* Defined in jsobj.cpp. */
JS_DECLARE_CALLINFO(js_Object_tn)
JS_DECLARE_CALLINFO(js_CreateThisFromTrace)
JS_DECLARE_CALLINFO(js_InitializerObject)
/* Defined in vm/RegExpObject.cpp. */
JS_DECLARE_CALLINFO(js_CloneRegExpObject)
/* Defined in jsstr.cpp. */
JS_DECLARE_CALLINFO(js_String_tn)
JS_DECLARE_CALLINFO(js_CompareStringsOnTrace)
JS_DECLARE_CALLINFO(js_ConcatStrings)
JS_DECLARE_CALLINFO(js_EqualStringsOnTrace)
JS_DECLARE_CALLINFO(js_FlattenOnTrace)
/* Defined in jstypedarray.cpp. */
JS_DECLARE_CALLINFO(js_TypedArray_uint8_clamp_double)
#endif /* jsbuiltins_h___ */

View File

@ -66,7 +66,6 @@
#include "jsutil.h"
#include "jsapi.h"
#include "jsversion.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsdate.h"
#include "jsinterp.h"
@ -1221,14 +1220,6 @@ date_now(JSContext *cx, uintN argc, Value *vp)
return JS_TRUE;
}
#ifdef JS_TRACER
static jsdouble FASTCALL
date_now_tn(JSContext*)
{
return NowAsMillis();
}
#endif
/*
* Set UTC time to a given time and invalidate cached local time.
*/
@ -2550,14 +2541,10 @@ date_valueOf(JSContext *cx, uintN argc, Value *vp)
return date_format(cx, obj->getDateUTCTime().toNumber(), FORMATSPEC_FULL, args);
}
// Don't really need an argument here, but we don't support arg-less builtins
JS_DEFINE_TRCINFO_1(date_now,
(1, (static, DOUBLE, date_now_tn, CONTEXT, 0, nanojit::ACCSET_STORE_ANY)))
static JSFunctionSpec date_static_methods[] = {
JS_FN("UTC", date_UTC, MAXARGS,0),
JS_FN("parse", date_parse, 1,0),
JS_TN("now", date_now, 0,0, &date_now_trcinfo),
JS_FN("now", date_now, 0,0),
JS_FS_END
};

View File

@ -366,9 +366,6 @@ StringIsArrayIndex(JSLinearString *str, jsuint *indexp);
#define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */
#define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */
/* When defining functions, JSFunctionSpec::call points to a JSNativeTraceInfo. */
#define JSFUN_TRCINFO 0x2000
} /* namespace js */
#endif

View File

@ -52,7 +52,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsfun.h"
@ -244,62 +243,6 @@ js_PutArgsObject(StackFrame *fp)
}
}
#ifdef JS_TRACER
/*
* Traced versions of js_GetArgsObject and js_PutArgsObject.
*/
JSObject * JS_FASTCALL
js_NewArgumentsOnTrace(JSContext *cx, uint32 argc, JSObject *callee)
{
ArgumentsObject *argsobj = ArgumentsObject::create(cx, argc, *callee);
if (!argsobj)
return NULL;
if (argsobj->isStrictArguments()) {
/*
* Strict mode callers must copy arguments into the created arguments
* object. The trace-JITting code is in TraceRecorder::newArguments.
*/
JS_ASSERT(!argsobj->maybeStackFrame());
} else {
argsobj->setOnTrace();
}
return argsobj;
}
JS_DEFINE_CALLINFO_3(extern, OBJECT, js_NewArgumentsOnTrace, CONTEXT, UINT32, OBJECT,
0, nanojit::ACCSET_STORE_ANY)
/* FIXME change the return type to void. */
JSBool JS_FASTCALL
js_PutArgumentsOnTrace(JSContext *cx, JSObject *obj, Value *argv)
{
NormalArgumentsObject *argsobj = obj->asNormalArguments();
JS_ASSERT(argsobj->onTrace());
/*
* TraceRecorder::putActivationObjects builds a single, contiguous array of
* the arguments, regardless of whether #actuals > #formals so there is no
* need to worry about actual vs. formal arguments.
*/
Value *srcend = argv + argsobj->initialLength();
HeapValue *dst = argsobj->data()->slots;
JSCompartment *comp = cx->compartment;
for (Value *src = argv; src < srcend; ++src, ++dst) {
if (!dst->isMagic(JS_ARGS_HOLE))
dst->set(comp, *src);
}
argsobj->clearOnTrace();
return true;
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_PutArgumentsOnTrace, CONTEXT, OBJECT, VALUEPTR, 0,
nanojit::ACCSET_STORE_ANY)
#endif /* JS_TRACER */
static JSBool
args_delProperty(JSContext *cx, JSObject *obj, jsid id, Value *vp)
{
@ -773,9 +716,6 @@ js_CreateCallObjectOnTrace(JSContext *cx, JSFunction *fun, JSObject *callee, JSO
return CallObject::create(cx, fun->script(), *scopeChain, callee);
}
JS_DEFINE_CALLINFO_4(extern, OBJECT, js_CreateCallObjectOnTrace, CONTEXT, FUNCTION, OBJECT, OBJECT,
0, nanojit::ACCSET_STORE_ANY)
void
js_PutCallObject(StackFrame *fp)
{
@ -874,23 +814,6 @@ js_PutCallObject(StackFrame *fp)
callobj.setStackFrame(NULL);
}
JSBool JS_FASTCALL
js_PutCallObjectOnTrace(JSObject *obj, uint32 nargs, Value *argv,
uint32 nvars, Value *slots)
{
CallObject &callobj = obj->asCall();
JS_ASSERT(!callobj.maybeStackFrame());
uintN n = nargs + nvars;
if (n != 0)
callobj.copyValues(nargs, argv, nvars, slots);
return true;
}
JS_DEFINE_CALLINFO_5(extern, BOOL, js_PutCallObjectOnTrace, OBJECT, UINT32, VALUEPTR,
UINT32, VALUEPTR, 0, nanojit::ACCSET_STORE_ANY)
namespace js {
static JSBool
@ -1033,26 +956,6 @@ SetCallVar(JSContext *cx, JSObject *obj, jsid id, JSBool strict, Value *vp)
} // namespace js
#if JS_TRACER
JSBool JS_FASTCALL
js_SetCallArg(JSContext *cx, JSObject *obj, jsid slotid, ValueArgType arg)
{
Value argcopy = ValueArgToConstRef(arg);
return SetCallArg(cx, obj, slotid, false /* STRICT DUMMY */, &argcopy);
}
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallArg, CONTEXT, OBJECT, JSID, VALUE, 0,
nanojit::ACCSET_STORE_ANY)
JSBool JS_FASTCALL
js_SetCallVar(JSContext *cx, JSObject *obj, jsid slotid, ValueArgType arg)
{
Value argcopy = ValueArgToConstRef(arg);
return SetCallVar(cx, obj, slotid, false /* STRICT DUMMY */, &argcopy);
}
JS_DEFINE_CALLINFO_4(extern, BOOL, js_SetCallVar, CONTEXT, OBJECT, JSID, VALUE, 0,
nanojit::ACCSET_STORE_ANY)
#endif
static JSBool
call_resolve(JSContext *cx, JSObject *obj, jsid id, uintN flags, JSObject **objp)
{
@ -2290,7 +2193,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs,
/* Initialize all function members. */
fun->nargs = uint16(nargs);
fun->flags = flags & (JSFUN_FLAGS_MASK | JSFUN_KINDMASK | JSFUN_TRCINFO);
fun->flags = flags & (JSFUN_FLAGS_MASK | JSFUN_KINDMASK);
if ((flags & JSFUN_KINDMASK) >= JSFUN_INTERPRETED) {
JS_ASSERT(!native);
JS_ASSERT(nargs == 0);
@ -2298,19 +2201,7 @@ js_NewFunction(JSContext *cx, JSObject *funobj, Native native, uintN nargs,
fun->script().init(NULL);
} else {
fun->u.n.clasp = NULL;
if (flags & JSFUN_TRCINFO) {
#ifdef JS_TRACER
JSNativeTraceInfo *trcinfo =
JS_FUNC_TO_DATA_PTR(JSNativeTraceInfo *, native);
fun->u.n.native = (Native) trcinfo->native;
fun->u.n.trcinfo = trcinfo;
#else
fun->u.n.trcinfo = NULL;
#endif
} else {
fun->u.n.native = native;
fun->u.n.trcinfo = NULL;
}
fun->u.n.native = native;
JS_ASSERT(fun->u.n.native);
}
fun->atom = atom;
@ -2385,11 +2276,6 @@ js_CloneFunctionObject(JSContext *cx, JSFunction *fun, JSObject *parent,
return clone;
}
#ifdef JS_TRACER
JS_DEFINE_CALLINFO_4(extern, OBJECT, js_CloneFunctionObject, CONTEXT, FUNCTION, OBJECT, OBJECT, 0,
nanojit::ACCSET_STORE_ANY)
#endif
/*
* Create a new flat closure, but don't initialize the imported upvar
* values. The tracer calls this function and then initializes the upvar
@ -2420,9 +2306,6 @@ js_AllocFlatClosure(JSContext *cx, JSFunction *fun, JSObject *scopeChain)
return closure;
}
JS_DEFINE_CALLINFO_3(extern, OBJECT, js_AllocFlatClosure,
CONTEXT, FUNCTION, OBJECT, 0, nanojit::ACCSET_STORE_ANY)
JSObject *
js_NewFlatClosure(JSContext *cx, JSFunction *fun, JSOp op, size_t oplen)
{
@ -2518,7 +2401,7 @@ js_DefineFunction(JSContext *cx, JSObject *obj, jsid id, Native native,
bool wasDelegate = obj->isDelegate();
fun = js_NewFunction(cx, NULL, native, nargs,
attrs & (JSFUN_FLAGS_MASK | JSFUN_TRCINFO),
attrs & (JSFUN_FLAGS_MASK),
obj,
JSID_IS_ATOM(id) ? JSID_TO_ATOM(id) : NULL);
if (!fun)

View File

@ -94,8 +94,6 @@
global object */
#define JSFUN_EXPR_CLOSURE 0x1000 /* expression closure: function(x) x*x */
/* 0x2000 is JSFUN_TRCINFO:
u.n.trcinfo is non-null */
#define JSFUN_INTERPRETED 0x4000 /* use u.i if kind >= this value else u.n */
#define JSFUN_FLAT_CLOSURE 0x8000 /* flat (aka "display") closure */
#define JSFUN_NULL_CLOSURE 0xc000 /* null closure entrains no scope chain */
@ -114,7 +112,6 @@ struct JSFunction : public JSObject_Slots2
js::Native native; /* native method pointer or null */
js::Class *clasp; /* class of objects constructed
by this function */
JSNativeTraceInfo *trcinfo;
} n;
struct Scripted {
JSScript *script_; /* interpreted bytecode descriptor or null;
@ -237,29 +234,8 @@ struct JSFunction : public JSObject_Slots2
JS_ASSERT(isNative());
u.n.clasp = clasp;
}
JSNativeTraceInfo *getTraceInfo() const {
JS_ASSERT(isNative());
JS_ASSERT(flags & JSFUN_TRCINFO);
return u.n.trcinfo;
}
};
/*
* Trace-annotated native. This expands to a JSFunctionSpec initializer (like
* JS_FN in jsapi.h). fastcall is a FastNative; trcinfo is a
* JSNativeTraceInfo*.
*/
#ifdef JS_TRACER
/* MSVC demands the intermediate (void *) cast here. */
# define JS_TN(name,fastcall,nargs,flags,trcinfo) \
JS_FN(name, JS_DATA_TO_FUNC_PTR(Native, trcinfo), nargs, \
(flags) | JSFUN_STUB_GSOPS | JSFUN_TRCINFO)
#else
# define JS_TN(name,fastcall,nargs,flags,trcinfo) \
JS_FN(name, fastcall, nargs, flags)
#endif
inline JSFunction *
JSObject::getFunctionPrivate() const
{

View File

@ -43,7 +43,6 @@
#include "jsgcstats.h"
#include "jsgc.h"
#include "jsxml.h"
#include "jsbuiltins.h"
#include "jscompartment.h"
#include "jsgcinlines.h"

View File

@ -52,7 +52,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsexn.h"

View File

@ -46,7 +46,6 @@
#include "prmjtime.h"
#include "jsapi.h"
#include "jsatom.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jslock.h"
@ -666,189 +665,28 @@ math_toSource(JSContext *cx, uintN argc, Value *vp)
}
#endif
#ifdef JS_TRACER
#define MATH_BUILTIN_1(name, cfun) \
static jsdouble FASTCALL name##_tn(MathCache *cache, jsdouble d) { \
return cache->lookup(cfun, d); \
} \
JS_DEFINE_TRCINFO_1(name, \
(2, (static, DOUBLE, name##_tn, MATHCACHE, DOUBLE, 1, nanojit::ACCSET_NONE)))
MATH_BUILTIN_1(js_math_abs, fabs)
MATH_BUILTIN_1(math_atan, atan)
MATH_BUILTIN_1(math_sin, sin)
MATH_BUILTIN_1(math_cos, cos)
MATH_BUILTIN_1(js_math_sqrt, sqrt)
MATH_BUILTIN_1(math_tan, tan)
static jsdouble FASTCALL
math_acos_tn(MathCache *cache, jsdouble d)
{
#if defined(SOLARIS) && defined(__GNUC__)
if (d < -1 || 1 < d) {
return js_NaN;
}
#endif
return cache->lookup(acos, d);
}
static jsdouble FASTCALL
math_asin_tn(MathCache *cache, jsdouble d)
{
#if defined(SOLARIS) && defined(__GNUC__)
if (d < -1 || 1 < d) {
return js_NaN;
}
#endif
return cache->lookup(asin, d);
}
static jsdouble FASTCALL
math_exp_tn(MathCache *cache, jsdouble d)
{
return cache->lookup(math_exp_body, d);
}
JS_DEFINE_TRCINFO_1(math_exp,
(2, (static, DOUBLE, math_exp_tn, MATHCACHE, DOUBLE, 1, nanojit::ACCSET_NONE)))
static jsdouble FASTCALL
math_log_tn(MathCache *cache, jsdouble d)
{
#if defined(SOLARIS) && defined(__GNUC__)
if (d < 0)
return js_NaN;
#endif
return cache->lookup(log, d);
}
static jsdouble FASTCALL
math_max_tn(jsdouble d, jsdouble p)
{
if (JSDOUBLE_IS_NaN(d) || JSDOUBLE_IS_NaN(p))
return js_NaN;
if (p == 0 && p == d) {
// Max prefers 0.0 to -0.0.
if (js_copysign(1.0, d) == -1)
return p;
return d;
}
return (p > d) ? p : d;
}
static jsdouble FASTCALL
math_min_tn(jsdouble d, jsdouble p)
{
if (JSDOUBLE_IS_NaN(d) || JSDOUBLE_IS_NaN(p))
return js_NaN;
if (p == 0 && p == d) {
// Min prefers -0.0 to 0.0.
if (js_copysign (1.0, p) == -1)
return p;
return d;
}
return (p < d) ? p : d;
}
static jsdouble FASTCALL
math_pow_tn(jsdouble d, jsdouble p)
{
/*
* Special case for square roots. Note that pow(x, 0.5) != sqrt(x)
* when x = -0.0, so we have to guard for this.
*/
if (JSDOUBLE_IS_FINITE(d) && d != 0.0) {
if (p == 0.5)
return sqrt(d);
if (p == -0.5)
return 1.0/sqrt(d);
}
if (!JSDOUBLE_IS_FINITE(p) && (d == 1.0 || d == -1.0))
return js_NaN;
if (p == 0)
return 1.0;
int32_t i;
if (JSDOUBLE_IS_INT32(p, &i))
return powi(d, i);
return pow(d, p);
}
static jsdouble FASTCALL
math_random_tn(JSContext *cx)
{
return random_nextDouble(cx);
}
static jsdouble FASTCALL
math_round_tn(jsdouble x)
{
return js_math_round_impl(x);
}
static jsdouble FASTCALL
math_ceil_tn(jsdouble x)
{
return js_math_ceil_impl(x);
}
static jsdouble FASTCALL
math_floor_tn(jsdouble x)
{
return js_math_floor_impl(x);
}
JS_DEFINE_TRCINFO_1(math_acos,
(2, (static, DOUBLE, math_acos_tn, MATHCACHE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(math_asin,
(2, (static, DOUBLE, math_asin_tn, MATHCACHE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(math_atan2,
(2, (static, DOUBLE, math_atan2_kernel, DOUBLE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(js_math_floor,
(1, (static, DOUBLE, math_floor_tn, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(math_log,
(2, (static, DOUBLE, math_log_tn, MATHCACHE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(js_math_max,
(2, (static, DOUBLE, math_max_tn, DOUBLE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(js_math_min,
(2, (static, DOUBLE, math_min_tn, DOUBLE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(js_math_pow,
(2, (static, DOUBLE, math_pow_tn, DOUBLE, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(math_random,
(1, (static, DOUBLE, math_random_tn, CONTEXT, 0, nanojit::ACCSET_STORE_ANY)))
JS_DEFINE_TRCINFO_1(js_math_round,
(1, (static, DOUBLE, math_round_tn, DOUBLE, 1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(js_math_ceil,
(1, (static, DOUBLE, math_ceil_tn, DOUBLE, 1, nanojit::ACCSET_NONE)))
#endif /* JS_TRACER */
static JSFunctionSpec math_static_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, math_toSource, 0, 0),
#endif
JS_TN("abs", js_math_abs, 1, 0, &js_math_abs_trcinfo),
JS_TN("acos", math_acos, 1, 0, &math_acos_trcinfo),
JS_TN("asin", math_asin, 1, 0, &math_asin_trcinfo),
JS_TN("atan", math_atan, 1, 0, &math_atan_trcinfo),
JS_TN("atan2", math_atan2, 2, 0, &math_atan2_trcinfo),
JS_TN("ceil", js_math_ceil, 1, 0, &js_math_ceil_trcinfo),
JS_TN("cos", math_cos, 1, 0, &math_cos_trcinfo),
JS_TN("exp", math_exp, 1, 0, &math_exp_trcinfo),
JS_TN("floor", js_math_floor, 1, 0, &js_math_floor_trcinfo),
JS_TN("log", math_log, 1, 0, &math_log_trcinfo),
JS_TN("max", js_math_max, 2, 0, &js_math_max_trcinfo),
JS_TN("min", js_math_min, 2, 0, &js_math_min_trcinfo),
JS_TN("pow", js_math_pow, 2, 0, &js_math_pow_trcinfo),
JS_TN("random", math_random, 0, 0, &math_random_trcinfo),
JS_TN("round", js_math_round, 1, 0, &js_math_round_trcinfo),
JS_TN("sin", math_sin, 1, 0, &math_sin_trcinfo),
JS_TN("sqrt", js_math_sqrt, 1, 0, &js_math_sqrt_trcinfo),
JS_TN("tan", math_tan, 1, 0, &math_tan_trcinfo),
JS_FN("abs", js_math_abs, 1, 0),
JS_FN("acos", math_acos, 1, 0),
JS_FN("asin", math_asin, 1, 0),
JS_FN("atan", math_atan, 1, 0),
JS_FN("atan2", math_atan2, 2, 0),
JS_FN("ceil", js_math_ceil, 1, 0),
JS_FN("cos", math_cos, 1, 0),
JS_FN("exp", math_exp, 1, 0),
JS_FN("floor", js_math_floor, 1, 0),
JS_FN("log", math_log, 1, 0),
JS_FN("max", js_math_max, 2, 0),
JS_FN("min", js_math_min, 2, 0),
JS_FN("pow", js_math_pow, 2, 0),
JS_FN("random", math_random, 0, 0),
JS_FN("round", js_math_round, 1, 0),
JS_FN("sin", math_sin, 1, 0),
JS_FN("sqrt", js_math_sqrt, 1, 0),
JS_FN("tan", math_tan, 1, 0),
JS_FS_END
};

View File

@ -59,7 +59,6 @@
#include "jsutil.h"
#include "jsapi.h"
#include "jsatom.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsdtoa.h"
@ -339,27 +338,6 @@ num_parseFloat(JSContext *cx, uintN argc, Value *vp)
return JS_TRUE;
}
#ifdef JS_TRACER
static jsdouble FASTCALL
ParseFloat(JSContext* cx, JSString* str)
{
TraceMonitor *tm = JS_TRACE_MONITOR_ON_TRACE(cx);
const jschar *bp = str->getChars(cx);
if (!bp) {
SetBuiltinError(tm);
return js_NaN;
}
const jschar *end = bp + str->length();
const jschar *ep;
double d;
if (!js_strtod(cx, bp, end, &ep, &d) || ep == bp)
return js_NaN;
return d;
}
#endif
static bool
ParseIntStringHelper(JSContext *cx, const jschar *ws, const jschar *end, int maybeRadix,
bool stripPrefix, jsdouble *dp)
@ -492,46 +470,6 @@ num_parseInt(JSContext *cx, uintN argc, Value *vp)
return true;
}
#ifdef JS_TRACER
static jsdouble FASTCALL
ParseInt(JSContext* cx, JSString* str)
{
TraceMonitor *tm = JS_TRACE_MONITOR_ON_TRACE(cx);
const jschar *start = str->getChars(cx);
if (!start) {
SetBuiltinError(tm);
return js_NaN;
}
const jschar *end = start + str->length();
jsdouble d;
if (!ParseIntStringHelper(cx, start, end, 0, true, &d)) {
SetBuiltinError(tm);
return js_NaN;
}
return d;
}
static jsdouble FASTCALL
ParseIntDouble(JSContext* cx, jsdouble d)
{
/* Fast path - see comment in numParseInt. */
if (-1.0e21 < d && d < 1.0e21)
return ParseIntDoubleHelper(d);
/* Slow path - convert to a string and parse normally. */
JSString *inputString = js_NumberToString(cx, d);
if (!inputString) {
TraceMonitor *tm = JS_TRACE_MONITOR_ON_TRACE(cx);
SetBuiltinError(tm);
return js_NaN;
}
return ParseInt(cx, inputString);
}
#endif
const char js_Infinity_str[] = "Infinity";
const char js_NaN_str[] = "NaN";
const char js_isNaN_str[] = "isNaN";
@ -539,22 +477,11 @@ const char js_isFinite_str[] = "isFinite";
const char js_parseFloat_str[] = "parseFloat";
const char js_parseInt_str[] = "parseInt";
#ifdef JS_TRACER
JS_DEFINE_TRCINFO_2(num_parseInt,
(2, (static, DOUBLE_FAIL, ParseInt, CONTEXT, STRING,1, nanojit::ACCSET_NONE)),
(2, (static, DOUBLE_FAIL, ParseIntDouble, CONTEXT, DOUBLE,1, nanojit::ACCSET_NONE)))
JS_DEFINE_TRCINFO_1(num_parseFloat,
(2, (static, DOUBLE_FAIL, ParseFloat, CONTEXT, STRING, 1, nanojit::ACCSET_NONE)))
#endif /* JS_TRACER */
static JSFunctionSpec number_functions[] = {
JS_FN(js_isNaN_str, num_isNaN, 1,0),
JS_FN(js_isFinite_str, num_isFinite, 1,0),
JS_TN(js_parseFloat_str, num_parseFloat, 1,0, &num_parseFloat_trcinfo),
JS_TN(js_parseInt_str, num_parseInt, 2,0, &num_parseInt_trcinfo),
JS_FN(js_parseFloat_str, num_parseFloat, 1,0),
JS_FN(js_parseInt_str, num_parseInt, 2,0),
JS_FS_END
};
@ -954,21 +881,11 @@ num_toPrecision(JSContext *cx, uintN argc, Value *vp)
CallArgsFromVp(argc, vp));
}
#ifdef JS_TRACER
JS_DEFINE_TRCINFO_2(num_toString,
(2, (extern, STRING_RETRY, js_NumberToString, CONTEXT, THIS_DOUBLE,
1, nanojit::ACCSET_NONE)),
(3, (static, STRING_RETRY, js_NumberToStringWithBase, CONTEXT, THIS_DOUBLE, INT32,
1, nanojit::ACCSET_NONE)))
#endif /* JS_TRACER */
static JSFunctionSpec number_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN(js_toSource_str, num_toSource, 0, 0),
#endif
JS_TN(js_toString_str, num_toString, 1, 0, &num_toString_trcinfo),
JS_FN(js_toString_str, num_toString, 1, 0),
JS_FN(js_toLocaleString_str, num_toLocaleString, 0, 0),
JS_FN(js_valueOf_str, js_num_valueOf, 0, 0),
JS_FN("toFixed", num_toFixed, 1, 0),

View File

@ -56,7 +56,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsfun.h"
@ -3056,88 +3055,6 @@ js_CreateThisForFunction(JSContext *cx, JSObject *callee, bool newType)
return obj;
}
#ifdef JS_TRACER
JSObject* FASTCALL
js_Object_tn(JSContext* cx, JSObject* proto)
{
JS_ASSERT(!(ObjectClass.flags & JSCLASS_HAS_PRIVATE));
return NewObjectWithClassProto(cx, &ObjectClass, proto, FINALIZE_OBJECT8);
}
JS_DEFINE_TRCINFO_1(js_Object,
(2, (extern, CONSTRUCTOR_RETRY, js_Object_tn, CONTEXT, CALLEE_PROTOTYPE, 0,
nanojit::ACCSET_STORE_ANY)))
JSObject* FASTCALL
js_InitializerObject(JSContext* cx, JSObject *proto, JSObject *baseobj)
{
if (!baseobj) {
gc::AllocKind kind = GuessObjectGCKind(0, false);
return NewObjectWithClassProto(cx, &ObjectClass, proto, kind);
}
/* :FIXME: bug 637856 new Objects do not have the right type when created on trace. */
TypeObject *type = proto->getNewType(cx);
if (!type)
return NULL;
return CopyInitializerObject(cx, baseobj, type);
}
JS_DEFINE_CALLINFO_3(extern, OBJECT, js_InitializerObject, CONTEXT, OBJECT, OBJECT,
0, nanojit::ACCSET_STORE_ANY)
JSObject* FASTCALL
js_String_tn(JSContext* cx, JSObject* proto, JSString* str)
{
JS_ASSERT(JS_ON_TRACE(cx));
JS_ASSERT(proto);
return StringObject::createWithProto(cx, str, *proto);
}
JS_DEFINE_CALLINFO_3(extern, OBJECT, js_String_tn, CONTEXT, CALLEE_PROTOTYPE, STRING, 0,
nanojit::ACCSET_STORE_ANY)
JSObject * FASTCALL
js_CreateThisFromTrace(JSContext *cx, JSObject *ctor, uintN protoSlot)
{
#ifdef DEBUG
JS_ASSERT(ctor->isFunction());
JS_ASSERT(ctor->getFunctionPrivate()->isInterpreted());
jsid id = ATOM_TO_JSID(cx->runtime->atomState.classPrototypeAtom);
const Shape *shape = ctor->nativeLookup(cx, id);
JS_ASSERT(shape->slot == protoSlot);
JS_ASSERT(!shape->configurable());
JS_ASSERT(!shape->isMethod());
#endif
JSObject *parent = ctor->getParent();
JSObject *proto;
const Value &protov = ctor->getSlot(protoSlot);
if (protov.isObject()) {
proto = &protov.toObject();
} else {
/*
* GetInterpretedFunctionPrototype found that ctor.prototype is
* primitive. Use Object.prototype for proto, per ES5 13.2.2 step 7.
*/
proto = parent->getGlobal()->getOrCreateObjectPrototype(cx);
if (!proto)
return NULL;
}
gc::AllocKind kind = NewObjectGCKind(cx, &ObjectClass);
return NewNativeClassInstance(cx, &ObjectClass, proto, parent, kind);
}
JS_DEFINE_CALLINFO_3(extern, CONSTRUCTOR_RETRY, js_CreateThisFromTrace, CONTEXT, OBJECT, UINTN, 0,
nanojit::ACCSET_STORE_ANY)
#else /* !JS_TRACER */
# define js_Object_trcinfo NULL
#endif /* !JS_TRACER */
/*
* Given pc pointing after a property accessing bytecode, return true if the
* access is "object-detecting" in the sense used by web scripts, e.g., when

View File

@ -410,9 +410,6 @@ class RegExpObject;
* overflow, and never points to the object's fixed slots. Unlike dense arrays,
* the fixed slots can always be accessed. Two objects with the same shape are
* guaranteed to have the same number of fixed slots.
*
* If you change this struct, you'll probably need to change the AccSet values
* in jsbuiltins.h.
*/
struct JSObject : js::gc::Cell {
/*

View File

@ -234,7 +234,7 @@ FunctionClassname(const JSFunction *fun)
{
if (!fun || fun->isInterpreted())
return Probes::nullName;
if (!(fun->flags & JSFUN_TRCINFO) && fun->getConstructorClass())
if (fun->getConstructorClass())
return fun->getConstructorClass()->name;
return Probes::nullName;
}

View File

@ -90,7 +90,6 @@ typedef struct JSCodeSpec JSCodeSpec;
typedef struct JSPrinter JSPrinter;
typedef struct JSStackHeader JSStackHeader;
typedef struct JSSubString JSSubString;
typedef struct JSNativeTraceInfo JSNativeTraceInfo;
typedef struct JSSpecializedNative JSSpecializedNative;
typedef struct JSXML JSXML;

View File

@ -59,7 +59,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsgc.h"
#include "jsinterp.h"
@ -90,17 +89,6 @@ using namespace js::gc;
using namespace js::types;
using namespace js::unicode;
#ifdef JS_TRACER
JSBool JS_FASTCALL
js_FlattenOnTrace(JSContext *cx, JSString* str)
{
return !!str->ensureLinear(cx);
}
JS_DEFINE_CALLINFO_2(extern, BOOL, js_FlattenOnTrace, CONTEXT, STRING, 0, nanojit::ACCSET_STORE_ANY)
#endif /* !JS_TRACER */
static JSLinearString *
ArgToRootedString(JSContext *cx, uintN argc, Value *vp, uintN arg)
{
@ -2845,20 +2833,6 @@ str_sub(JSContext *cx, uintN argc, Value *vp)
}
#endif /* JS_HAS_STR_HTML_HELPERS */
#ifdef JS_TRACER
JSString* FASTCALL
js_String_getelem(JSContext* cx, JSString* str, int32 i)
{
if ((size_t)i >= str->length())
return NULL;
return cx->runtime->staticStrings.getUnitStringForElement(cx, str, size_t(i));
}
#endif
JS_DEFINE_TRCINFO_1(str_concat,
(3, (extern, STRING_RETRY, js_ConcatStrings, CONTEXT, THIS_STRING, STRING,
1, nanojit::ACCSET_NONE)))
static JSFunctionSpec string_methods[] = {
#if JS_HAS_TOSOURCE
JS_FN("quote", str_quote, 0,JSFUN_GENERIC_NATIVE),
@ -2892,7 +2866,7 @@ static JSFunctionSpec string_methods[] = {
#endif
/* Python-esque sequence methods. */
JS_TN("concat", str_concat, 1,JSFUN_GENERIC_NATIVE, &str_concat_trcinfo),
JS_FN("concat", str_concat, 1,JSFUN_GENERIC_NATIVE),
JS_FN("slice", str_slice, 2,JSFUN_GENERIC_NATIVE),
/* HTML string methods. */
@ -2976,24 +2950,8 @@ js::str_fromCharCode(JSContext *cx, uintN argc, Value *vp)
return JS_TRUE;
}
#ifdef JS_TRACER
static JSString* FASTCALL
String_fromCharCode(JSContext* cx, int32 i)
{
JS_ASSERT(JS_ON_TRACE(cx));
jschar c = (jschar)i;
if (StaticStrings::hasUnit(c))
return cx->runtime->staticStrings.getUnit(c);
return js_NewStringCopyN(cx, &c, 1);
}
#endif
JS_DEFINE_TRCINFO_1(str_fromCharCode,
(2, (static, STRING_RETRY, String_fromCharCode, CONTEXT, INT32, 1, nanojit::ACCSET_NONE)))
static JSFunctionSpec string_static_methods[] = {
JS_TN("fromCharCode", js::str_fromCharCode, 1, 0, &str_fromCharCode_trcinfo),
JS_FN("fromCharCode", js::str_fromCharCode, 1, 0),
JS_FS_END
};
@ -3395,15 +3353,6 @@ EqualStrings(JSLinearString *str1, JSLinearString *str2)
} /* namespace js */
JSBool JS_FASTCALL
js_EqualStringsOnTrace(JSContext *cx, JSString *str1, JSString *str2)
{
JSBool result;
return EqualStrings(cx, str1, str2, &result) ? result : JS_NEITHER;
}
JS_DEFINE_CALLINFO_3(extern, BOOL, js_EqualStringsOnTrace,
CONTEXT, STRING, STRING, 1, nanojit::ACCSET_NONE)
namespace js {
static bool
@ -3446,18 +3395,6 @@ CompareStrings(JSContext *cx, JSString *str1, JSString *str2, int32 *result)
} /* namespace js */
int32 JS_FASTCALL
js_CompareStringsOnTrace(JSContext *cx, JSString *str1, JSString *str2)
{
int32 result;
if (!CompareStringsImpl(cx, str1, str2, &result))
return INT32_MIN;
JS_ASSERT(result != INT32_MIN);
return result;
}
JS_DEFINE_CALLINFO_3(extern, INT32, js_CompareStringsOnTrace,
CONTEXT, STRING, STRING, 1, nanojit::ACCSET_NONE)
namespace js {
bool

View File

@ -50,7 +50,6 @@
#include "jsarray.h"
#include "jsatom.h"
#include "jsbool.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsversion.h"
#include "jsgc.h"
@ -870,10 +869,6 @@ js_TypedArray_uint8_clamp_double(const double x)
return y;
}
JS_DEFINE_CALLINFO_1(extern, INT32, js_TypedArray_uint8_clamp_double, DOUBLE,
1, nanojit::ACCSET_NONE)
struct uint8_clamped {
uint8 val;

View File

@ -59,7 +59,6 @@
#include "jsapi.h"
#include "jsarray.h"
#include "jsatom.h"
#include "jsbuiltins.h"
#include "jscntxt.h"
#include "jsdate.h"
#include "jsdbgapi.h"
@ -2012,7 +2011,6 @@ DisassembleScript(JSContext *cx, JSScript *script, JSFunction *fun, bool lines,
SHOW_FLAG(LAMBDA);
SHOW_FLAG(HEAVYWEIGHT);
SHOW_FLAG(EXPR_CLOSURE);
SHOW_FLAG(TRCINFO);
#undef SHOW_FLAG