2008-10-08 15:08:33 -07:00
|
|
|
/* -*- 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
|
|
|
|
|
Bug 97954: Allow SpiderMonkey to be built on its own, or as part of Mozilla.
Give SpiderMonkey its own configure script and top-level Makefile.
Adjust js/src/Makefile as appropriate for life as a stand-alone
makefile, instead of a 'make export; make libs'-style Mozilla tier
makefile. Have the configure script accept '--with-nspr-cflags' and
'--with-nspr-libs' options for using an in-tree NSPR. Also accept
'--with-system-nspr', '--with-nspr-prefix', and
'--with-nspr-exec-prefix' flags for using an installed NSPR. Default
to --disable-jemalloc, assuming we don't have that part of the tree
available; have the top-level configure script pass --enable-jemalloc
as needed.
Since we no longer have an export phase to copy header files into
dist/include/js before we build the library, we need to be able to
find nanojit.h in the nanojit directory; fix references in
jsbuiltins.h and jstracer.cpp.
Give SpiderMonkey it its own copies of many of the files from ./config
and ./build. These are all exact copies, except as follows:
. js/src/config/Makefile.in: js/src only has a subset of
js/src/config, and thus a subset of the makefile targets.
. js/src/config/autoconf.mk.in: js/src/configure.in has its own make
variables to set, not set by the top-level configure script, so it
needs a custom automake.mk template.
. js/src/config/make-system-wrappers.pl: a copy from nsprpub/config,
so that we can build without having an NSPR source tree handy.
Invoke js/src/configure from ./configure, passing the values computed
for NSPR_CFLAGS and NSPR_LIBS by the top-level configure script.
Treat js/src as a static directory of the js tier, and create a new
config/js (just a Makefile) to be the js tier's non-static directory.
Let js/src/configure generate SpiderMonkey's makefiles, not
./configure.
Generate a 'js-config' script, which clients can call to find the
CFLAGS and LIBS values necessary to compile and link against an
installed SpiderMonkey library. Don't include the js-config script in
Macintosh packages.
Teach client.mk how to rebuild js/src/configure.
Tell Mercurial to ignore files generated by autoconf in js/src.
Further work:
. Right now, callers must define JS_THREADSAFE when #including jsapi.h.
This is fixed in a subsequent patch.
. js/src/configure is a trimmed copy of ./configure. It could be
trimmed more.
--HG--
rename : build/autoconf/acoutput-fast.pl => js/src/build/autoconf/acoutput-fast.pl
rename : build/autoconf/altoptions.m4 => js/src/build/autoconf/altoptions.m4
rename : build/autoconf/config.guess => js/src/build/autoconf/config.guess
rename : build/autoconf/config.sub => js/src/build/autoconf/config.sub
rename : build/autoconf/glib.m4 => js/src/build/autoconf/glib.m4
rename : build/autoconf/install-sh => js/src/build/autoconf/install-sh
rename : build/autoconf/make-makefile => js/src/build/autoconf/make-makefile
rename : build/autoconf/match-dir.sh => js/src/build/autoconf/match-dir.sh
rename : build/autoconf/nspr.m4 => js/src/build/autoconf/nspr.m4
rename : build/autoconf/pkg.m4 => js/src/build/autoconf/pkg.m4
rename : build/autoconf/update-makefile.sh => js/src/build/autoconf/update-makefile.sh
rename : build/cygwin-wrapper => js/src/build/cygwin-wrapper
rename : build/hcc => js/src/build/hcc
rename : build/hcpp => js/src/build/hcpp
rename : build/unix/mddepend.pl => js/src/build/unix/mddepend.pl
rename : build/unix/uniq.pl => js/src/build/unix/uniq.pl
rename : config/Makefile.in => js/src/config/Makefile.in
rename : config/Moz/Milestone.pm => js/src/config/Moz/Milestone.pm
rename : config/autoconf.mk.in => js/src/config/autoconf.mk.in
rename : config/config.mk => js/src/config/config.mk
rename : config/elf-dynstr-gc.c => js/src/config/elf-dynstr-gc.c
rename : config/fastcwd.pl => js/src/config/fastcwd.pl
rename : config/gcc_hidden.h => js/src/config/gcc_hidden.h
rename : config/insure.mk => js/src/config/insure.mk
rename : nsprpub/config/make-system-wrappers.pl => js/src/config/make-system-wrappers.pl
rename : config/milestone.pl => js/src/config/milestone.pl
rename : config/milestone.txt => js/src/config/milestone.txt
rename : config/mkdepend/Makefile.in => js/src/config/mkdepend/Makefile.in
rename : config/mkdepend/cppsetup.c => js/src/config/mkdepend/cppsetup.c
rename : config/mkdepend/def.h => js/src/config/mkdepend/def.h
rename : config/mkdepend/ifparser.c => js/src/config/mkdepend/ifparser.c
rename : config/mkdepend/ifparser.h => js/src/config/mkdepend/ifparser.h
rename : config/mkdepend/imakemdep.h => js/src/config/mkdepend/imakemdep.h
rename : config/mkdepend/include.c => js/src/config/mkdepend/include.c
rename : config/mkdepend/main.c => js/src/config/mkdepend/main.c
rename : config/mkdepend/mkdepend.man => js/src/config/mkdepend/mkdepend.man
rename : config/mkdepend/parse.c => js/src/config/mkdepend/parse.c
rename : config/mkdepend/pr.c => js/src/config/mkdepend/pr.c
rename : config/nfspwd.pl => js/src/config/nfspwd.pl
rename : config/nsinstall.c => js/src/config/nsinstall.c
rename : config/nsinstall.py => js/src/config/nsinstall.py
rename : config/pathsub.c => js/src/config/pathsub.c
rename : config/pathsub.h => js/src/config/pathsub.h
rename : config/preprocessor.pl => js/src/config/preprocessor.pl
rename : config/revdepth-nt.pl => js/src/config/revdepth-nt.pl
rename : config/revdepth.pl => js/src/config/revdepth.pl
rename : config/rules.mk => js/src/config/rules.mk
rename : config/system-headers => js/src/config/system-headers
rename : config/version.mk => js/src/config/version.mk
rename : config/version_win.pl => js/src/config/version_win.pl
rename : configure.in => js/src/configure.in
2008-10-29 08:29:22 -07:00
|
|
|
#include "nanojit/nanojit.h"
|
2010-08-16 12:35:04 -07:00
|
|
|
#include "jsvalue.h"
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2008-12-03 05:41:12 -08:00
|
|
|
#ifdef THIS
|
|
|
|
#undef THIS
|
|
|
|
#endif
|
|
|
|
|
2010-10-18 12:55:56 -07:00
|
|
|
namespace js {
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See ValidateWriter::checkAccSet() for what each of these access regions
|
|
|
|
* mean.
|
|
|
|
*
|
|
|
|
* *** WARNING WARNING WARNING ***
|
|
|
|
*
|
|
|
|
* Any incorrect access region annotations on loads/stores/calls could lead to
|
|
|
|
* subtle bugs that manifest rarely, eg. when two loads are CSE'd that
|
|
|
|
* shouldn't be.
|
|
|
|
*
|
|
|
|
* If you add a new access region you will need to add some sanity checking to
|
|
|
|
* ValidateWriter::checkAccSet(). Do not skimp on this checking! Make it as
|
|
|
|
* strong as you can. Look at the existing cases for inspiration. This
|
|
|
|
* checking helps prevent these subtle bugs.
|
|
|
|
*
|
|
|
|
* Furthermore, do not add a "catch-all" region such as "ACCSET_OTHER". There
|
|
|
|
* are two reasons for this. First, no checking could be done on loads/stores
|
|
|
|
* bearing it. Second, it would be too easy for someone in the future who
|
|
|
|
* doesn't understand how AccSets work to use it inappropriately. Only
|
|
|
|
* ACCSET_ALL (the union of all access regions) should be used as a catch-all,
|
|
|
|
* it can always be used safely, but it reduces optimization possibilities.
|
|
|
|
*
|
|
|
|
* Most of the access regions are type-based, ie. all structs of a particular
|
|
|
|
* type combined together form a region. This is less precise than
|
|
|
|
* considering each struct separately, but also much simpler.
|
|
|
|
*
|
|
|
|
* - ACCSET_STATE: The TracerState struct.
|
|
|
|
* - ACCSET_STACK: The stack.
|
|
|
|
* - ACCSET_RSTACK: The return stack.
|
|
|
|
* - ACCSET_CX: All JSContext structs.
|
|
|
|
* - ACCSET_EOS: The globals area.
|
|
|
|
* - ACCSET_ALLOC: All memory blocks allocated with LIR_allocp (in
|
|
|
|
* other words, this region is the AR space).
|
|
|
|
* - ACCSET_FRAMEREGS: All JSFrameRegs structs.
|
|
|
|
* - ACCSET_STACKFRAME: All JSStackFrame objects.
|
|
|
|
* - ACCSET_RUNTIME: The JSRuntime object.
|
|
|
|
* - ACCSET_OBJ_CLASP: The 'clasp' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_SHAPE: The 'shape' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_PROTO: The 'proto' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_PARENT: The 'parent' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_PRIVATE: The 'private' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_CAPACITY: The 'capacity' field of all JSObjects.
|
|
|
|
* - ACCSET_OBJ_SLOTS: The 'slots' field of all JSObjects.
|
|
|
|
* - ACCSET_SLOTS: The slots (be they fixed or dynamic) of all JSObjects.
|
|
|
|
* - ACCSET_TARRAY: All TypedArray structs.
|
|
|
|
* - ACCSET_TARRAY_DATA: All TypedArray data arrays.
|
|
|
|
* - ACCSET_ITER: All NativeIterator structs.
|
|
|
|
* - ACCSET_ITER_PROPS: The props_arrays of all NativeIterator structs.
|
|
|
|
* - ACCSET_STRING: All JSString structs.
|
|
|
|
* - ACCSET_STRING_MCHARS: All JSString mchars arrays.
|
|
|
|
* - ACCSET_TYPEMAP: All typemaps form a single region.
|
|
|
|
* - ACCSET_FCSLOTS: All fcslots arrays form a single region.
|
|
|
|
* - ACCSET_ARGS_DATA: All Arguments data arrays form a single region.
|
|
|
|
*/
|
|
|
|
static const nanojit::AccSet ACCSET_STATE = (1 << 0);
|
|
|
|
static const nanojit::AccSet ACCSET_STACK = (1 << 1);
|
|
|
|
static const nanojit::AccSet ACCSET_RSTACK = (1 << 2);
|
|
|
|
static const nanojit::AccSet ACCSET_CX = (1 << 3);
|
|
|
|
static const nanojit::AccSet ACCSET_EOS = (1 << 4);
|
|
|
|
static const nanojit::AccSet ACCSET_ALLOC = (1 << 5);
|
|
|
|
static const nanojit::AccSet ACCSET_FRAMEREGS = (1 << 6);
|
|
|
|
static const nanojit::AccSet ACCSET_STACKFRAME = (1 << 7);
|
|
|
|
static const nanojit::AccSet ACCSET_RUNTIME = (1 << 8);
|
|
|
|
|
|
|
|
// Nb: JSObject::{lastProp,map,flags} don't have an AccSet because they are never accessed on trace
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_CLASP = (1 << 9);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_SHAPE = (1 << 10);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_PROTO = (1 << 11);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_PARENT = (1 << 12);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_PRIVATE = (1 << 13);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_CAPACITY = (1 << 14);
|
|
|
|
static const nanojit::AccSet ACCSET_OBJ_SLOTS = (1 << 15); // the pointer to the slots
|
|
|
|
|
|
|
|
static const nanojit::AccSet ACCSET_SLOTS = (1 << 16); // the slots themselves
|
|
|
|
static const nanojit::AccSet ACCSET_TARRAY = (1 << 17);
|
|
|
|
static const nanojit::AccSet ACCSET_TARRAY_DATA = (1 << 18);
|
|
|
|
static const nanojit::AccSet ACCSET_ITER = (1 << 19);
|
|
|
|
static const nanojit::AccSet ACCSET_ITER_PROPS = (1 << 20);
|
|
|
|
static const nanojit::AccSet ACCSET_STRING = (1 << 21);
|
|
|
|
static const nanojit::AccSet ACCSET_STRING_MCHARS = (1 << 22);
|
|
|
|
static const nanojit::AccSet ACCSET_TYPEMAP = (1 << 23);
|
|
|
|
static const nanojit::AccSet ACCSET_FCSLOTS = (1 << 24);
|
|
|
|
static const nanojit::AccSet ACCSET_ARGS_DATA = (1 << 25);
|
|
|
|
}
|
|
|
|
|
|
|
|
static const uint8_t TM_NUM_USED_ACCS = 26; // number of access regions used by TraceMonkey
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
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
|
|
|
|
};
|
2008-10-08 15:08:33 -07:00
|
|
|
|
|
|
|
#define JSTN_ERRTYPE(jstn) ((jstn)->flags & JSTN_ERRTYPE_MASK)
|
|
|
|
|
2008-10-10 09:43:30 -07:00
|
|
|
/*
|
2010-08-16 12:35:04 -07:00
|
|
|
* Type describing a type specialization of a js::Native.
|
2009-09-04 13:44:31 -07:00
|
|
|
*
|
2008-10-10 09:43:30 -07:00
|
|
|
* |prefix| and |argtypes| declare what arguments should be passed to the
|
2008-10-13 09:04:26 -07:00
|
|
|
* native function. |prefix| can contain the following characters:
|
2008-10-10 09:43:30 -07:00
|
|
|
*
|
|
|
|
* 'C': a JSContext* argument
|
2008-10-10 09:45:19 -07:00
|
|
|
* '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)
|
2008-10-10 09:43:30 -07:00
|
|
|
* 'R': a JSRuntime* argument
|
|
|
|
* 'P': the pc as a jsbytecode*
|
2008-10-10 09:45:19 -07:00
|
|
|
* 'D': |this| as a number (jsdouble)
|
2008-10-13 09:04:26 -07:00
|
|
|
* 'f': the function being called, as a JSObject*
|
|
|
|
* 'p': the .prototype of the function, as a JSObject*
|
2008-10-10 09:43:30 -07:00
|
|
|
*
|
|
|
|
* 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
|
2009-08-29 18:46:27 -07:00
|
|
|
* 'r': a JSObject* argument that is of class js_RegExpClass
|
|
|
|
* 'f': a JSObject* argument that is of class js_FunctionClass
|
2010-07-14 23:19:36 -07:00
|
|
|
* 'v': a value argument: on 32-bit, a Value*, on 64-bit, a jsval
|
2008-10-10 09:43:30 -07:00
|
|
|
*/
|
2009-09-04 13:44:31 -07:00
|
|
|
struct JSSpecializedNative {
|
2008-10-08 15:08:33 -07:00
|
|
|
const nanojit::CallInfo *builtin;
|
|
|
|
const char *prefix;
|
|
|
|
const char *argtypes;
|
2009-07-27 18:40:12 -07:00
|
|
|
uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
|
2009-03-03 22:53:27 -08:00
|
|
|
JSTN_CONSTRUCTOR */
|
2008-10-08 15:08:33 -07:00
|
|
|
};
|
|
|
|
|
2009-09-04 13:44:31 -07:00
|
|
|
/*
|
|
|
|
* 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 {
|
2010-08-16 12:35:04 -07:00
|
|
|
js::Native native;
|
2009-09-04 13:44:31 -07:00
|
|
|
JSSpecializedNative *specializations;
|
|
|
|
};
|
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
/* Macros used by JS_DEFINE_CALLINFOn. */
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define _JS_CI_NAME(op) ,#op
|
|
|
|
#else
|
|
|
|
#define _JS_CI_NAME(op)
|
|
|
|
#endif
|
|
|
|
|
2010-03-21 20:07:46 -07:00
|
|
|
#define _JS_I32_ARGTYPE nanojit::ARGTYPE_I
|
|
|
|
#define _JS_I32_RETTYPE nanojit::ARGTYPE_I
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_U64_ARGTYPE nanojit::ARGTYPE_Q
|
|
|
|
#define _JS_U64_RETTYPE nanojit::ARGTYPE_Q
|
2010-04-21 21:42:19 -07:00
|
|
|
#define _JS_F64_ARGTYPE nanojit::ARGTYPE_D
|
|
|
|
#define _JS_F64_RETTYPE nanojit::ARGTYPE_D
|
2010-03-21 20:07:46 -07:00
|
|
|
#define _JS_PTR_ARGTYPE nanojit::ARGTYPE_P
|
|
|
|
#define _JS_PTR_RETTYPE nanojit::ARGTYPE_P
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2009-09-23 11:16:30 -07:00
|
|
|
struct ClosureVarInfo;
|
2009-08-27 15:40:37 -07:00
|
|
|
|
2008-10-21 15:58:06 -07:00
|
|
|
/*
|
2009-07-27 18:40:12 -07:00
|
|
|
* Supported types for builtin functions.
|
2008-10-21 15:58:06 -07:00
|
|
|
*
|
|
|
|
* Types with -- for the two string fields are not permitted as argument types
|
|
|
|
* in JS_DEFINE_TRCINFO.
|
|
|
|
*
|
2009-02-03 16:25:12 -08:00
|
|
|
* 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
|
2009-04-09 16:07:00 -07:00
|
|
|
* cx->interpState->builtinStatus.
|
2009-02-03 16:25:12 -08:00
|
|
|
*
|
|
|
|
* - 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.
|
|
|
|
*
|
2009-04-07 14:15:34 -07:00
|
|
|
* _RETRY builtins indicate failure with a special return value that
|
|
|
|
* depends on the return type:
|
|
|
|
*
|
2010-07-14 23:19:36 -07:00
|
|
|
* BOOL_RETRY: JS_NEITHER
|
2009-04-07 14:15:34 -07:00
|
|
|
* INT32_RETRY: any negative value
|
|
|
|
* STRING_RETRY: NULL
|
|
|
|
* OBJECT_RETRY_NULL: NULL
|
2009-02-03 16:25:12 -08:00
|
|
|
*
|
|
|
|
* _RETRY function calls are faster than _FAIL calls. Each _RETRY call
|
2009-04-09 16:07:00 -07:00
|
|
|
* saves two writes to cx->bailExit and a read from state->builtinStatus.
|
2009-02-03 16:25:12 -08:00
|
|
|
*
|
|
|
|
* - All other traceable natives are infallible (e.g. Date.now, Math.log).
|
2008-10-21 15:58:06 -07:00
|
|
|
*
|
|
|
|
* 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.
|
2009-07-27 18:40:12 -07:00
|
|
|
*
|
2008-10-21 15:58:06 -07:00
|
|
|
* 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)
|
2009-02-03 16:25:12 -08:00
|
|
|
|
|
|
|
#define _JS_CTYPE_CONTEXT _JS_CTYPE(JSContext *, _JS_PTR,"C", "", INFALLIBLE)
|
2009-08-29 18:46:27 -07:00
|
|
|
#define _JS_CTYPE_RUNTIME _JS_CTYPE(JSRuntime *, _JS_PTR,"R", "", INFALLIBLE)
|
2010-10-06 12:13:20 -07:00
|
|
|
#define _JS_CTYPE_MATHCACHE _JS_CTYPE(js::MathCache *, _JS_PTR,"M", "", INFALLIBLE)
|
2009-02-03 16:25:12 -08:00
|
|
|
#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)
|
2009-08-29 13:05:16 -07:00
|
|
|
#define _JS_CTYPE_CALLEE _JS_CTYPE(JSObject *, _JS_PTR,"f","", INFALLIBLE)
|
2009-08-29 18:46:27 -07:00
|
|
|
#define _JS_CTYPE_CALLEE_PROTOTYPE _JS_CTYPE(JSObject *, _JS_PTR,"p","", INFALLIBLE)
|
2009-06-03 11:19:20 -07:00
|
|
|
#define _JS_CTYPE_FUNCTION _JS_CTYPE(JSFunction *, _JS_PTR, --, --, INFALLIBLE)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_PC _JS_CTYPE(jsbytecode *, _JS_PTR,"P", "", INFALLIBLE)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_VALUEPTR _JS_CTYPE(js::Value *, _JS_PTR, --, --, INFALLIBLE)
|
|
|
|
#define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const js::Value *, _JS_PTR, --, --, INFALLIBLE)
|
2009-07-27 18:13:53 -07:00
|
|
|
#define _JS_CTYPE_JSID _JS_CTYPE(jsid, _JS_PTR, --, --, INFALLIBLE)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_JSVAL _JS_CTYPE(js::Value, _JS_U64, --, --, INFALLIBLE)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_NEITHER)
|
2009-03-19 15:16:59 -07:00
|
|
|
#define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
|
2010-05-07 17:52:52 -07:00
|
|
|
#define _JS_CTYPE_BOOLPTR _JS_CTYPE(JSBool *, _JS_PTR, --, --, INFALLIBLE)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_INT32 _JS_CTYPE(int32, _JS_I32, "","i", INFALLIBLE)
|
2009-04-07 14:15:34 -07:00
|
|
|
#define _JS_CTYPE_INT32_RETRY _JS_CTYPE(int32, _JS_I32, --, --, FAIL_NEG)
|
2009-03-19 15:16:59 -07:00
|
|
|
#define _JS_CTYPE_INT32_FAIL _JS_CTYPE(int32, _JS_I32, --, --, FAIL_STATUS)
|
2009-09-30 15:28:00 -07:00
|
|
|
#define _JS_CTYPE_INT32PTR _JS_CTYPE(int32 *, _JS_PTR, --, --, INFALLIBLE)
|
2009-03-19 15:16:59 -07:00
|
|
|
#define _JS_CTYPE_UINT32 _JS_CTYPE(uint32, _JS_I32, "","i", INFALLIBLE)
|
2009-04-07 14:15:34 -07:00
|
|
|
#define _JS_CTYPE_UINT32_RETRY _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_NEG)
|
2009-03-19 15:16:59 -07:00
|
|
|
#define _JS_CTYPE_UINT32_FAIL _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_STATUS)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_DOUBLE _JS_CTYPE(jsdouble, _JS_F64, "","d", INFALLIBLE)
|
2009-03-19 15:16:59 -07:00
|
|
|
#define _JS_CTYPE_DOUBLE_FAIL _JS_CTYPE(jsdouble, _JS_F64, --, --, FAIL_STATUS)
|
2009-02-03 16:25:12 -08:00
|
|
|
#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)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_STRING_OR_NULL_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS | \
|
|
|
|
JSTN_RETURN_NULLABLE_STR)
|
2009-08-03 09:38:28 -07:00
|
|
|
#define _JS_CTYPE_STRINGPTR _JS_CTYPE(JSString **, _JS_PTR, --, --, INFALLIBLE)
|
2009-08-29 18:46:27 -07:00
|
|
|
#define _JS_CTYPE_OBJECT _JS_CTYPE(JSObject *, _JS_PTR, "","o", INFALLIBLE)
|
2009-04-07 14:15:34 -07:00
|
|
|
#define _JS_CTYPE_OBJECT_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_OBJECT_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_OBJECT_OR_NULL_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS | \
|
|
|
|
JSTN_RETURN_NULLABLE_OBJ)
|
2010-05-07 17:52:52 -07:00
|
|
|
#define _JS_CTYPE_OBJECTPTR _JS_CTYPE(JSObject **, _JS_PTR, --, --, INFALLIBLE)
|
2009-03-03 22:53:27 -08:00
|
|
|
#define _JS_CTYPE_CONSTRUCTOR_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL | \
|
|
|
|
JSTN_CONSTRUCTOR)
|
2009-08-29 18:46:27 -07:00
|
|
|
#define _JS_CTYPE_REGEXP _JS_CTYPE(JSObject *, _JS_PTR, "","r", INFALLIBLE)
|
2010-08-29 11:57:08 -07:00
|
|
|
#define _JS_CTYPE_SHAPE _JS_CTYPE(js::Shape *, _JS_PTR, --, --, INFALLIBLE)
|
2010-04-22 11:54:11 -07:00
|
|
|
#define _JS_CTYPE_TRACERSTATE _JS_CTYPE(TracerState *, _JS_PTR, --, --, INFALLIBLE)
|
2009-02-03 16:25:12 -08:00
|
|
|
#define _JS_CTYPE_FRAGMENT _JS_CTYPE(nanojit::Fragment *, _JS_PTR, --, --, INFALLIBLE)
|
2010-07-14 23:19:36 -07:00
|
|
|
#define _JS_CTYPE_CLASS _JS_CTYPE(js::Class *, _JS_PTR, --, --, INFALLIBLE)
|
2009-05-11 18:05:44 -07:00
|
|
|
#define _JS_CTYPE_DOUBLEPTR _JS_CTYPE(double *, _JS_PTR, --, --, INFALLIBLE)
|
2009-09-22 15:02:50 -07:00
|
|
|
#define _JS_CTYPE_CHARPTR _JS_CTYPE(char *, _JS_PTR, --, --, INFALLIBLE)
|
2009-08-27 15:40:37 -07:00
|
|
|
#define _JS_CTYPE_CVIPTR _JS_CTYPE(const ClosureVarInfo *, _JS_PTR, --, --, INFALLIBLE)
|
2009-09-30 15:28:00 -07:00
|
|
|
#define _JS_CTYPE_FRAMEINFO _JS_CTYPE(FrameInfo *, _JS_PTR, --, --, INFALLIBLE)
|
2010-09-15 21:33:17 -07:00
|
|
|
#define _JS_CTYPE_PICTABLE _JS_CTYPE(PICTable *, _JS_PTR, --, --, INFALLIBLE)
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
#define _JS_EXPAND(tokens) tokens
|
|
|
|
|
2008-10-21 15:58:06 -07:00
|
|
|
#define _JS_CTYPE_TYPE2(t,s,p,a,f) t
|
|
|
|
#define _JS_CTYPE_TYPE(tyname) _JS_EXPAND(_JS_CTYPE_TYPE2 _JS_CTYPE_##tyname)
|
2010-03-21 20:07:46 -07:00
|
|
|
#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)
|
2008-10-21 15:58:06 -07:00
|
|
|
#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)
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2008-10-16 12:24:10 -07:00
|
|
|
#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
|
2008-10-21 15:58:06 -07:00
|
|
|
#define _JS_TN_LINKAGE(linkage, t) _JS_##linkage##_TN(t)
|
|
|
|
#define _JS_CI_LINKAGE(linkage) _JS_##linkage##_CI
|
2008-10-16 12:24:10 -07:00
|
|
|
|
|
|
|
#define _JS_CALLINFO(name) name##_ci
|
|
|
|
|
2008-11-16 15:02:06 -08:00
|
|
|
#if defined(JS_NO_FASTCALL) && defined(NANOJIT_IA32)
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
|
2008-11-16 15:02:06 -08:00
|
|
|
_JS_TN_LINKAGE(linkage, crtype) name cargtypes; \
|
|
|
|
_JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
|
2010-03-01 18:47:17 -08:00
|
|
|
{ (intptr_t) &name, argtypes, nanojit::ABI_CDECL, isPure, storeAccSet _JS_CI_NAME(name) };\
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
|
2010-03-01 18:47:17 -08:00
|
|
|
|
2008-11-16 15:02:06 -08:00
|
|
|
#else
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_TN_LINKAGE(linkage, crtype) FASTCALL name cargtypes; \
|
|
|
|
_JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
|
2010-03-01 18:47:17 -08:00
|
|
|
{ (intptr_t) &name, argtypes, nanojit::ABI_FASTCALL, isPure, storeAccSet _JS_CI_NAME(name) }; \
|
2010-07-27 22:33:42 -07:00
|
|
|
JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
|
2008-11-16 15:02:06 -08:00
|
|
|
#endif
|
2008-10-08 15:08:33 -07:00
|
|
|
|
|
|
|
/*
|
2009-05-05 17:36:26 -07:00
|
|
|
* 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.
|
|
|
|
*
|
2010-03-01 18:47:17 -08:00
|
|
|
* - 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
|
2010-07-27 22:33:42 -07:00
|
|
|
* 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.
|
2008-10-08 15:08:33 -07:00
|
|
|
*/
|
2010-03-01 18:47:17 -08:00
|
|
|
#define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_JS_DEFINE_CALLINFO(linkage, op, \
|
|
|
|
_JS_CTYPE_TYPE(rt), \
|
|
|
|
(_JS_CTYPE_TYPE(at0)), \
|
|
|
|
nanojit::CallInfo::typeSig1(_JS_CTYPE_RETTYPE(rt), \
|
|
|
|
_JS_CTYPE_ARGTYPE(at0)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_JS_DEFINE_CALLINFO(linkage, op, \
|
|
|
|
_JS_CTYPE_TYPE(rt), \
|
|
|
|
(_JS_CTYPE_TYPE(at0), \
|
|
|
|
_JS_CTYPE_TYPE(at1), \
|
|
|
|
_JS_CTYPE_TYPE(at2), \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_CTYPE_TYPE(at3)), \
|
2010-07-04 20:00:33 -07:00
|
|
|
nanojit::CallInfo::typeSig4(_JS_CTYPE_RETTYPE(rt), \
|
|
|
|
_JS_CTYPE_ARGTYPE(at0), \
|
|
|
|
_JS_CTYPE_ARGTYPE(at1), \
|
|
|
|
_JS_CTYPE_ARGTYPE(at2), \
|
|
|
|
_JS_CTYPE_ARGTYPE(at3)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, \
|
|
|
|
storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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), \
|
2010-02-03 13:14:14 -08:00
|
|
|
_JS_CTYPE_TYPE(at6)), \
|
2010-07-04 20:00:33 -07:00
|
|
|
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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
|
|
|
#define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, \
|
|
|
|
storeAccSet) \
|
2010-07-04 20:00:33 -07:00
|
|
|
_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)), \
|
2010-03-01 18:47:17 -08:00
|
|
|
isPure, storeAccSet)
|
2009-03-19 15:16:59 -07:00
|
|
|
|
2008-10-16 12:24:10 -07:00
|
|
|
#define JS_DECLARE_CALLINFO(name) extern const nanojit::CallInfo _JS_CALLINFO(name);
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2008-10-21 15:58:06 -07:00
|
|
|
#define _JS_TN_INIT_HELPER_n(n, args) _JS_TN_INIT_HELPER_##n args
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_1(linkage, rt, op, at0, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
&_JS_CALLINFO(op), \
|
|
|
|
_JS_CTYPE_PCH(at0), \
|
|
|
|
_JS_CTYPE_ACH(at0), \
|
|
|
|
_JS_CTYPE_FLAGS(rt)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
&_JS_CALLINFO(op), \
|
|
|
|
_JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
|
2009-01-26 21:05:59 -08:00
|
|
|
_JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_CTYPE_FLAGS(rt)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
&_JS_CALLINFO(op), \
|
|
|
|
_JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
|
2009-01-26 21:05:59 -08:00
|
|
|
_JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_CTYPE_FLAGS(rt)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
&_JS_CALLINFO(op), \
|
|
|
|
_JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
|
2009-01-26 21:05:59 -08:00
|
|
|
_JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_CTYPE_FLAGS(rt)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
|
2008-10-21 15:58:06 -07:00
|
|
|
&_JS_CALLINFO(op), \
|
|
|
|
_JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) \
|
|
|
|
_JS_CTYPE_PCH(at0), \
|
2009-01-26 21:05:59 -08:00
|
|
|
_JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) \
|
|
|
|
_JS_CTYPE_ACH(at0), \
|
2008-10-21 15:58:06 -07:00
|
|
|
_JS_CTYPE_FLAGS(rt)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
|
2009-03-19 15:16:59 -07:00
|
|
|
&_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)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet) \
|
2010-02-03 13:14:14 -08:00
|
|
|
&_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)
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#define _JS_TN_INIT_HELPER_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet) \
|
2010-02-03 13:14:14 -08:00
|
|
|
&_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)
|
|
|
|
|
2008-10-21 15:58:06 -07:00
|
|
|
#define JS_DEFINE_TRCINFO_1(name, tn0) \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn0 \
|
2009-09-04 13:44:31 -07:00
|
|
|
JSSpecializedNative name##_sns[] = { \
|
|
|
|
{ _JS_TN_INIT_HELPER_n tn0 } \
|
|
|
|
}; \
|
2010-08-16 12:35:04 -07:00
|
|
|
JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
|
2008-10-21 15:58:06 -07:00
|
|
|
|
|
|
|
#define JS_DEFINE_TRCINFO_2(name, tn0, tn1) \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn0 \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn1 \
|
2009-09-04 13:44:31 -07:00
|
|
|
JSSpecializedNative name##_sns[] = { \
|
|
|
|
{ _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
|
|
|
|
{ _JS_TN_INIT_HELPER_n tn1 } \
|
|
|
|
}; \
|
2010-08-16 12:35:04 -07:00
|
|
|
JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
|
2008-10-21 15:58:06 -07:00
|
|
|
|
|
|
|
#define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2) \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn0 \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn1 \
|
|
|
|
_JS_DEFINE_CALLINFO_n tn2 \
|
2009-09-04 13:44:31 -07:00
|
|
|
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 } \
|
|
|
|
}; \
|
2010-08-16 12:35:04 -07:00
|
|
|
JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
|
2008-10-21 15:58:06 -07:00
|
|
|
|
|
|
|
#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 \
|
2009-09-04 13:44:31 -07:00
|
|
|
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 } \
|
|
|
|
}; \
|
2010-08-16 12:35:04 -07:00
|
|
|
JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
|
2008-10-21 15:58:06 -07:00
|
|
|
|
|
|
|
#define _JS_DEFINE_CALLINFO_n(n, args) JS_DEFINE_CALLINFO_##n args
|
|
|
|
|
2008-11-17 16:29:40 -08:00
|
|
|
jsdouble FASTCALL
|
|
|
|
js_StringToNumber(JSContext* cx, JSString* str);
|
|
|
|
|
2010-01-22 14:49:18 -08:00
|
|
|
/* Extern version of SetBuiltinError. */
|
2009-04-09 16:07:00 -07:00
|
|
|
extern JS_FRIEND_API(void)
|
|
|
|
js_SetTraceableNativeFailed(JSContext *cx);
|
|
|
|
|
2009-07-29 09:58:19 -07:00
|
|
|
extern jsdouble FASTCALL
|
|
|
|
js_dmod(jsdouble a, jsdouble b);
|
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
#else
|
|
|
|
|
2010-03-01 18:47:17 -08:00
|
|
|
#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)
|
2008-10-08 15:08:33 -07:00
|
|
|
#define JS_DECLARE_CALLINFO(name)
|
2008-10-21 15:58:06 -07:00
|
|
|
#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)
|
2008-10-08 15:08:33 -07:00
|
|
|
|
|
|
|
#endif /* !JS_TRACER */
|
|
|
|
|
2009-03-03 22:53:27 -08:00
|
|
|
/* Defined in jsarray.cpp. */
|
2010-09-08 18:31:47 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_Array_dense_setelem_hole)
|
2009-05-05 14:26:06 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_NewEmptyArray)
|
2010-07-27 16:42:58 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_NewPreallocatedArray)
|
2010-10-13 11:49:22 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_InitializerArray)
|
2010-07-14 23:19:36 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_ArrayCompPush_tn)
|
2010-09-08 18:31:47 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_EnsureDenseArrayCapacity)
|
2009-02-28 23:40:04 -08:00
|
|
|
|
2009-03-03 22:53:27 -08:00
|
|
|
/* Defined in jsbuiltins.cpp. */
|
2009-05-05 17:36:26 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_UnboxDouble)
|
|
|
|
JS_DECLARE_CALLINFO(js_UnboxInt32)
|
|
|
|
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)
|
2010-05-12 19:34:01 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_AddAtomProperty)
|
2009-05-05 17:36:26 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_HasNamedProperty)
|
|
|
|
JS_DECLARE_CALLINFO(js_HasNamedPropertyInt32)
|
|
|
|
JS_DECLARE_CALLINFO(js_TypeOfObject)
|
2010-03-18 12:12:06 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_BooleanIntToString)
|
2009-05-05 17:36:26 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_NewNullClosure)
|
2010-01-26 18:20:04 -08:00
|
|
|
|
|
|
|
/* Defined in jsfun.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_AllocFlatClosure)
|
2010-08-09 22:43:33 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_PutArgumentsOnTrace)
|
2010-01-26 18:20:04 -08:00
|
|
|
JS_DECLARE_CALLINFO(js_PutCallObjectOnTrace)
|
|
|
|
JS_DECLARE_CALLINFO(js_SetCallVar)
|
|
|
|
JS_DECLARE_CALLINFO(js_SetCallArg)
|
|
|
|
JS_DECLARE_CALLINFO(js_CloneFunctionObject)
|
2010-01-15 11:32:14 -08:00
|
|
|
JS_DECLARE_CALLINFO(js_CreateCallObjectOnTrace)
|
2010-08-09 22:43:33 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_NewArgumentsOnTrace)
|
2010-01-26 18:20:04 -08:00
|
|
|
|
|
|
|
/* Defined in jsnum.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_NumberToString)
|
|
|
|
|
|
|
|
/* Defined in jsobj.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_Object_tn)
|
2010-10-04 14:13:33 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_CreateThisFromTrace)
|
2010-10-13 11:49:22 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_InitializerObject)
|
2010-01-26 18:20:04 -08:00
|
|
|
|
2010-01-26 18:41:30 -08:00
|
|
|
/* Defined in jsregexp.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_CloneRegExpObject)
|
|
|
|
|
2010-01-26 18:20:04 -08:00
|
|
|
/* Defined in jsstr.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_String_tn)
|
|
|
|
JS_DECLARE_CALLINFO(js_CompareStrings)
|
|
|
|
JS_DECLARE_CALLINFO(js_ConcatStrings)
|
|
|
|
JS_DECLARE_CALLINFO(js_EqualStrings)
|
2010-08-05 22:54:34 -07:00
|
|
|
JS_DECLARE_CALLINFO(js_Flatten)
|
2008-10-08 15:08:33 -07:00
|
|
|
|
2010-02-04 16:33:40 -08:00
|
|
|
/* Defined in jstypedarray.cpp. */
|
|
|
|
JS_DECLARE_CALLINFO(js_TypedArray_uint8_clamp_double)
|
|
|
|
|
2008-10-08 15:08:33 -07:00
|
|
|
#endif /* jsbuiltins_h___ */
|