1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=8 sw=4 et tw=99:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
20 * The Initial Developer of the Original Code is
21 * Mozilla Corporation.
24 * Jason Orendorff <jorendorff@mozilla.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef jsbuiltins_h___
41 #define jsbuiltins_h___
45 #include "nanojit/nanojit.h"
52 enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_NEITHER };
54 JSTN_ERRTYPE_MASK = 0x07,
55 JSTN_UNBOX_AFTER = 0x08,
57 JSTN_CONSTRUCTOR = 0x20,
58 JSTN_RETURN_NULLABLE_STR = 0x40,
59 JSTN_RETURN_NULLABLE_OBJ = 0x80
62 #define JSTN_ERRTYPE(jstn) ((jstn)->flags & JSTN_ERRTYPE_MASK)
65 * Type describing a type specialization of a js::Native.
67 * |prefix| and |argtypes| declare what arguments should be passed to the
68 * native function. |prefix| can contain the following characters:
70 * 'C': a JSContext* argument
71 * 'T': |this| as a JSObject* argument (bails if |this| is not an object)
72 * 'S': |this| as a JSString* argument (bails if |this| is not a string)
73 * 'R': a JSRuntime* argument
74 * 'P': the pc as a jsbytecode*
75 * 'D': |this| as a number (jsdouble)
76 * 'f': the function being called, as a JSObject*
77 * 'p': the .prototype of the function, as a JSObject*
79 * The corresponding things will get passed as arguments to the builtin in
80 * reverse order (so TC means JSContext* as the first arg, and the
81 * JSObject* for |this| as the second arg).
83 * |argtypes| can contain the following characters:
84 * 'd': a number (double) argument
85 * 'i': an integer argument
86 * 's': a JSString* argument
87 * 'o': a JSObject* argument
88 * 'r': a JSObject* argument that is of class js_RegExpClass
89 * 'f': a JSObject* argument that is of class js_FunctionClass
90 * 'v': a value argument: on 32-bit, a Value*, on 64-bit, a jsval
92 struct JSSpecializedNative {
93 const nanojit::CallInfo *builtin;
96 uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
101 * Type holding extra trace-specific information about a fast native.
103 * 'specializations' points to a static array of available specializations
104 * terminated by the lack of having the JSTN_MORE flag set.
106 struct JSNativeTraceInfo {
108 JSSpecializedNative *specializations;
111 /* Macros used by JS_DEFINE_CALLINFOn. */
113 #define _JS_CI_NAME(op) ,#op
115 #define _JS_CI_NAME(op)
118 #define _JS_I32_ARGTYPE nanojit::ARGTYPE_I
119 #define _JS_I32_RETTYPE nanojit::ARGTYPE_I
120 #define _JS_U64_ARGTYPE nanojit::ARGTYPE_Q
121 #define _JS_U64_RETTYPE nanojit::ARGTYPE_Q
122 #define _JS_F64_ARGTYPE nanojit::ARGTYPE_D
123 #define _JS_F64_RETTYPE nanojit::ARGTYPE_D
124 #define _JS_PTR_ARGTYPE nanojit::ARGTYPE_P
125 #define _JS_PTR_RETTYPE nanojit::ARGTYPE_P
127 struct ClosureVarInfo;
130 * Supported types for builtin functions.
132 * Types with -- for the two string fields are not permitted as argument types
133 * in JS_DEFINE_TRCINFO.
135 * There are three kinds of traceable-native error handling.
137 * - If a traceable native's return type ends with _FAIL, it always runs to
138 * completion. It can either succeed or fail with an error or exception;
139 * on success, it may or may not stay on trace. There may be side effects
140 * in any case. If the call succeeds but bails off trace, we resume in the
141 * interpreter at the next opcode.
143 * _FAIL builtins indicate failure or bailing off trace by setting bits in
144 * cx->interpState->builtinStatus.
146 * - If a traceable native's return type contains _RETRY, it can either
147 * succeed, fail with a JS exception, or tell the caller to bail off trace
148 * and retry the call from the interpreter. The last case happens if the
149 * builtin discovers that it can't do its job without examining the JS
150 * stack, reentering the interpreter, accessing properties of the global
153 * The builtin must detect the need to retry before committing any side
154 * effects. If a builtin can't do this, it must use a _FAIL return type
157 * _RETRY builtins indicate failure with a special return value that
158 * depends on the return type:
160 * BOOL_RETRY: JS_NEITHER
161 * INT32_RETRY: any negative value
163 * OBJECT_RETRY_NULL: NULL
165 * _RETRY function calls are faster than _FAIL calls. Each _RETRY call
166 * saves two writes to tm->bailExit and a read from state->builtinStatus.
168 * - All other traceable natives are infallible (e.g. Date.now, Math.log).
170 * Special builtins known to the tracer can have their own idiosyncratic
173 * When a traceable native returns a value indicating failure, we fall off
174 * trace. If an exception is pending, it is thrown; otherwise, we assume the
175 * builtin had no side effects and retry the current bytecode in the
178 * So a builtin must not return a value indicating failure after causing side
179 * effects (such as reporting an error), without setting an exception pending.
180 * The operation would be retried, despite the first attempt's observable
183 #define _JS_CTYPE(ctype, size, pch, ach, flags) (ctype, size, pch, ach, flags)
185 #define _JS_CTYPE_CONTEXT _JS_CTYPE(JSContext *, _JS_PTR,"C", "", INFALLIBLE)
186 #define _JS_CTYPE_RUNTIME _JS_CTYPE(JSRuntime *, _JS_PTR,"R", "", INFALLIBLE)
187 #define _JS_CTYPE_MATHCACHE _JS_CTYPE(js::MathCache *, _JS_PTR,"M", "", INFALLIBLE)
188 #define _JS_CTYPE_THIS _JS_CTYPE(JSObject *, _JS_PTR,"T", "", INFALLIBLE)
189 #define _JS_CTYPE_THIS_DOUBLE _JS_CTYPE(jsdouble, _JS_F64,"D", "", INFALLIBLE)
190 #define _JS_CTYPE_THIS_STRING _JS_CTYPE(JSString *, _JS_PTR,"S", "", INFALLIBLE)
191 #define _JS_CTYPE_CALLEE _JS_CTYPE(JSObject *, _JS_PTR,"f", "", INFALLIBLE)
192 #define _JS_CTYPE_CALLEE_PROTOTYPE _JS_CTYPE(JSObject *, _JS_PTR,"p", "", INFALLIBLE)
193 #define _JS_CTYPE_FUNCTION _JS_CTYPE(JSFunction *, _JS_PTR, --, --, INFALLIBLE)
194 #define _JS_CTYPE_PC _JS_CTYPE(jsbytecode *, _JS_PTR,"P", "", INFALLIBLE)
195 #define _JS_CTYPE_VALUEPTR _JS_CTYPE(js::Value *, _JS_PTR, --, --, INFALLIBLE)
196 #define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const js::Value *, _JS_PTR, --, --, INFALLIBLE)
197 #define _JS_CTYPE_JSID _JS_CTYPE(jsid, _JS_PTR, --, --, INFALLIBLE)
198 #define _JS_CTYPE_JSVAL _JS_CTYPE(js::Value, _JS_U64, --, --, INFALLIBLE)
199 #define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
200 #define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_NEITHER)
201 #define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
202 #define _JS_CTYPE_BOOLPTR _JS_CTYPE(JSBool *, _JS_PTR, --, --, INFALLIBLE)
203 #define _JS_CTYPE_INT32 _JS_CTYPE(int32, _JS_I32, "","i", INFALLIBLE)
204 #define _JS_CTYPE_INT32_RETRY _JS_CTYPE(int32, _JS_I32, --, --, FAIL_NEG)
205 #define _JS_CTYPE_INT32_FAIL _JS_CTYPE(int32, _JS_I32, --, --, FAIL_STATUS)
206 #define _JS_CTYPE_INT32PTR _JS_CTYPE(int32 *, _JS_PTR, --, --, INFALLIBLE)
207 #define _JS_CTYPE_UINT32 _JS_CTYPE(uint32, _JS_I32, "","i", INFALLIBLE)
208 #define _JS_CTYPE_UINT32_RETRY _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_NEG)
209 #define _JS_CTYPE_UINT32_FAIL _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_STATUS)
210 #define _JS_CTYPE_DOUBLE _JS_CTYPE(jsdouble, _JS_F64, "","d", INFALLIBLE)
211 #define _JS_CTYPE_DOUBLE_FAIL _JS_CTYPE(jsdouble, _JS_F64, --, --, FAIL_STATUS)
212 #define _JS_CTYPE_STRING _JS_CTYPE(JSString *, _JS_PTR, "","s", INFALLIBLE)
213 #define _JS_CTYPE_STRING_RETRY _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_NULL)
214 #define _JS_CTYPE_STRING_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS)
215 #define _JS_CTYPE_STRING_OR_NULL_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS | \
216 JSTN_RETURN_NULLABLE_STR)
217 #define _JS_CTYPE_STRINGPTR _JS_CTYPE(JSString **, _JS_PTR, --, --, INFALLIBLE)
218 #define _JS_CTYPE_OBJECT _JS_CTYPE(JSObject *, _JS_PTR, "","o", INFALLIBLE)
219 #define _JS_CTYPE_OBJECT_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL)
220 #define _JS_CTYPE_OBJECT_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS)
221 #define _JS_CTYPE_OBJECT_OR_NULL_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS | \
222 JSTN_RETURN_NULLABLE_OBJ)
223 #define _JS_CTYPE_OBJECTPTR _JS_CTYPE(JSObject **, _JS_PTR, --, --, INFALLIBLE)
224 #define _JS_CTYPE_CONSTRUCTOR_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL | \
226 #define _JS_CTYPE_REGEXP _JS_CTYPE(JSObject *, _JS_PTR, "","r", INFALLIBLE)
227 #define _JS_CTYPE_SHAPE _JS_CTYPE(js::Shape *, _JS_PTR, --, --, INFALLIBLE)
228 #define _JS_CTYPE_TRACERSTATE _JS_CTYPE(TracerState *, _JS_PTR, --, --, INFALLIBLE)
229 #define _JS_CTYPE_FRAGMENT _JS_CTYPE(nanojit::Fragment *, _JS_PTR, --, --, INFALLIBLE)
230 #define _JS_CTYPE_CLASS _JS_CTYPE(js::Class *, _JS_PTR, --, --, INFALLIBLE)
231 #define _JS_CTYPE_DOUBLEPTR _JS_CTYPE(double *, _JS_PTR, --, --, INFALLIBLE)
232 #define _JS_CTYPE_CHARPTR _JS_CTYPE(char *, _JS_PTR, --, --, INFALLIBLE)
233 #define _JS_CTYPE_CVIPTR _JS_CTYPE(const ClosureVarInfo *, _JS_PTR, --, --, INFALLIBLE)
234 #define _JS_CTYPE_FRAMEINFO _JS_CTYPE(FrameInfo *, _JS_PTR, --, --, INFALLIBLE)
235 #define _JS_CTYPE_PICTABLE _JS_CTYPE(PICTable *, _JS_PTR, --, --, INFALLIBLE)
236 #define _JS_CTYPE_UINTN _JS_CTYPE(uintN, _JS_PTR, --, --, INFALLIBLE)
239 * The "VALUE" type is used to indicate that a native takes a js::Value
240 * parameter by value. Unfortunately, for technical reasons, we can't simply
241 * have the parameter type be js::Value. Furthermore, the right thing to pass
242 * differs based on word size. Thus, a native that declares a parameter of type
243 * VALUE should have the corresponding argument type be:
244 * - on 32-bit: const Value*
245 * - on 64-bit: jsval (which is a uint64)
247 * To write code that just does the right thing, use the pattern:
248 * void foo(js::ValueArgType arg) {
249 * const js::Value &v = js::ValueArgToConstRef(arg);
251 #if JS_BITS_PER_WORD == 32
252 # define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_PTR, "","v", INFALLIBLE)
253 #elif JS_BITS_PER_WORD == 64
254 # define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_U64, "","v", INFALLIBLE)
257 #define _JS_EXPAND(tokens) tokens
259 #define _JS_CTYPE_TYPE2(t,s,p,a,f) t
260 #define _JS_CTYPE_TYPE(tyname) _JS_EXPAND(_JS_CTYPE_TYPE2 _JS_CTYPE_##tyname)
261 #define _JS_CTYPE_RETTYPE2(t,s,p,a,f) s##_RETTYPE
262 #define _JS_CTYPE_RETTYPE(tyname) _JS_EXPAND(_JS_CTYPE_RETTYPE2 _JS_CTYPE_##tyname)
263 #define _JS_CTYPE_ARGTYPE2(t,s,p,a,f) s##_ARGTYPE
264 #define _JS_CTYPE_ARGTYPE(tyname) _JS_EXPAND(_JS_CTYPE_ARGTYPE2 _JS_CTYPE_##tyname)
265 #define _JS_CTYPE_PCH2(t,s,p,a,f) p
266 #define _JS_CTYPE_PCH(tyname) _JS_EXPAND(_JS_CTYPE_PCH2 _JS_CTYPE_##tyname)
267 #define _JS_CTYPE_ACH2(t,s,p,a,f) a
268 #define _JS_CTYPE_ACH(tyname) _JS_EXPAND(_JS_CTYPE_ACH2 _JS_CTYPE_##tyname)
269 #define _JS_CTYPE_FLAGS2(t,s,p,a,f) f
270 #define _JS_CTYPE_FLAGS(tyname) _JS_EXPAND(_JS_CTYPE_FLAGS2 _JS_CTYPE_##tyname)
272 #define _JS_static_TN(t) static t
273 #define _JS_static_CI static
274 #define _JS_extern_TN(t) extern t
275 #define _JS_extern_CI
276 #define _JS_FRIEND_TN(t) extern JS_FRIEND_API(t)
277 #define _JS_FRIEND_CI
278 #define _JS_TN_LINKAGE(linkage, t) _JS_##linkage##_TN(t)
279 #define _JS_CI_LINKAGE(linkage) _JS_##linkage##_CI
281 #define _JS_CALLINFO(name) name##_ci
283 #if defined(JS_NO_FASTCALL) && defined(NANOJIT_IA32)
284 #define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
285 _JS_TN_LINKAGE(linkage, crtype) name cargtypes; \
286 _JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
287 { (intptr_t) &name, argtypes, nanojit::ABI_CDECL, isPure, storeAccSet _JS_CI_NAME(name) };\
288 JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
291 #define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
292 _JS_TN_LINKAGE(linkage, crtype) FASTCALL name cargtypes; \
293 _JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
294 { (intptr_t) &name, argtypes, nanojit::ABI_FASTCALL, isPure, storeAccSet _JS_CI_NAME(name) }; \
295 JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
299 * This macro is used for builtin functions that can be called from JITted
300 * code. It declares a C function named <op> and a CallInfo struct named
301 * <op>_ci so the tracer can call it. The <N> in JS_DEFINE_CALLINFO_<N> is
302 * the number of arguments the builtin takes. Builtins with no arguments
303 * are not supported. Using a macro is clunky but ensures that the types
304 * for each C function matches those for the corresponding CallInfo struct;
305 * mismatched types can cause subtle problems.
307 * The macro arguments are:
309 * - The linkage for the function and the associated CallInfo global. It
310 * can be extern, static, or FRIEND, which specifies JS_FRIEND_API linkage
313 * - The return type. This identifier must name one of the _JS_TYPEINFO_*
314 * macros defined in jsbuiltins.h.
316 * - The builtin name.
318 * - The parameter types.
320 * - The isPure flag. Set to 1 if:
321 * (a) the function's return value is determined solely by its arguments
322 * (ie. no hidden state, no implicit inputs used such as global
323 * variables or the result of an I/O operation); and
324 * (b) the function causes no observable side-effects (ie. no writes to
325 * global variables, no I/O output).
326 * Multiple calls to a pure function can be merged during CSE.
328 * - The storeAccSet. This indicates which memory access regions the function
329 * accesses. It must be ACCSET_NONE if the function is pure; use
330 * ACCSET_STORE_ANY if you're not sure. Used to determine if each call site
331 * of the function aliases any loads.
333 #define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet) \
334 _JS_DEFINE_CALLINFO(linkage, op, \
335 _JS_CTYPE_TYPE(rt), \
336 (_JS_CTYPE_TYPE(at0)), \
337 nanojit::CallInfo::typeSig1(_JS_CTYPE_RETTYPE(rt), \
338 _JS_CTYPE_ARGTYPE(at0)), \
340 #define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
341 _JS_DEFINE_CALLINFO(linkage, op, \
342 _JS_CTYPE_TYPE(rt), \
343 (_JS_CTYPE_TYPE(at0), \
344 _JS_CTYPE_TYPE(at1)), \
345 nanojit::CallInfo::typeSig2(_JS_CTYPE_RETTYPE(rt), \
346 _JS_CTYPE_ARGTYPE(at0), \
347 _JS_CTYPE_ARGTYPE(at1)), \
349 #define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
350 _JS_DEFINE_CALLINFO(linkage, op, \
351 _JS_CTYPE_TYPE(rt), \
352 (_JS_CTYPE_TYPE(at0), \
353 _JS_CTYPE_TYPE(at1), \
354 _JS_CTYPE_TYPE(at2)), \
355 nanojit::CallInfo::typeSig3(_JS_CTYPE_RETTYPE(rt), \
356 _JS_CTYPE_ARGTYPE(at0), \
357 _JS_CTYPE_ARGTYPE(at1), \
358 _JS_CTYPE_ARGTYPE(at2)), \
360 #define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
361 _JS_DEFINE_CALLINFO(linkage, op, \
362 _JS_CTYPE_TYPE(rt), \
363 (_JS_CTYPE_TYPE(at0), \
364 _JS_CTYPE_TYPE(at1), \
365 _JS_CTYPE_TYPE(at2), \
366 _JS_CTYPE_TYPE(at3)), \
367 nanojit::CallInfo::typeSig4(_JS_CTYPE_RETTYPE(rt), \
368 _JS_CTYPE_ARGTYPE(at0), \
369 _JS_CTYPE_ARGTYPE(at1), \
370 _JS_CTYPE_ARGTYPE(at2), \
371 _JS_CTYPE_ARGTYPE(at3)), \
373 #define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
374 _JS_DEFINE_CALLINFO(linkage, op, \
375 _JS_CTYPE_TYPE(rt), \
376 (_JS_CTYPE_TYPE(at0), \
377 _JS_CTYPE_TYPE(at1), \
378 _JS_CTYPE_TYPE(at2), \
379 _JS_CTYPE_TYPE(at3), \
380 _JS_CTYPE_TYPE(at4)), \
381 nanojit::CallInfo::typeSig5(_JS_CTYPE_RETTYPE(rt), \
382 _JS_CTYPE_ARGTYPE(at0), \
383 _JS_CTYPE_ARGTYPE(at1), \
384 _JS_CTYPE_ARGTYPE(at2), \
385 _JS_CTYPE_ARGTYPE(at3), \
386 _JS_CTYPE_ARGTYPE(at4)), \
388 #define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
389 _JS_DEFINE_CALLINFO(linkage, op, \
390 _JS_CTYPE_TYPE(rt), \
391 (_JS_CTYPE_TYPE(at0), \
392 _JS_CTYPE_TYPE(at1), \
393 _JS_CTYPE_TYPE(at2), \
394 _JS_CTYPE_TYPE(at3), \
395 _JS_CTYPE_TYPE(at4), \
396 _JS_CTYPE_TYPE(at5)), \
397 nanojit::CallInfo::typeSig6(_JS_CTYPE_RETTYPE(rt), \
398 _JS_CTYPE_ARGTYPE(at0), \
399 _JS_CTYPE_ARGTYPE(at1), \
400 _JS_CTYPE_ARGTYPE(at2), \
401 _JS_CTYPE_ARGTYPE(at3), \
402 _JS_CTYPE_ARGTYPE(at4), \
403 _JS_CTYPE_ARGTYPE(at5)), \
405 #define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, \
407 _JS_DEFINE_CALLINFO(linkage, op, \
408 _JS_CTYPE_TYPE(rt), \
409 (_JS_CTYPE_TYPE(at0), \
410 _JS_CTYPE_TYPE(at1), \
411 _JS_CTYPE_TYPE(at2), \
412 _JS_CTYPE_TYPE(at3), \
413 _JS_CTYPE_TYPE(at4), \
414 _JS_CTYPE_TYPE(at5), \
415 _JS_CTYPE_TYPE(at6)), \
416 nanojit::CallInfo::typeSig7(_JS_CTYPE_RETTYPE(rt), \
417 _JS_CTYPE_ARGTYPE(at0), \
418 _JS_CTYPE_ARGTYPE(at1), \
419 _JS_CTYPE_ARGTYPE(at2), \
420 _JS_CTYPE_ARGTYPE(at3), \
421 _JS_CTYPE_ARGTYPE(at4), \
422 _JS_CTYPE_ARGTYPE(at5), \
423 _JS_CTYPE_ARGTYPE(at6)), \
425 #define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, \
427 _JS_DEFINE_CALLINFO(linkage, op, \
428 _JS_CTYPE_TYPE(rt), \
429 (_JS_CTYPE_TYPE(at0), \
430 _JS_CTYPE_TYPE(at1), \
431 _JS_CTYPE_TYPE(at2), \
432 _JS_CTYPE_TYPE(at3), \
433 _JS_CTYPE_TYPE(at4), \
434 _JS_CTYPE_TYPE(at5), \
435 _JS_CTYPE_TYPE(at6), \
436 _JS_CTYPE_TYPE(at7)), \
437 nanojit::CallInfo::typeSig8(_JS_CTYPE_RETTYPE(rt), \
438 _JS_CTYPE_ARGTYPE(at0), \
439 _JS_CTYPE_ARGTYPE(at1), \
440 _JS_CTYPE_ARGTYPE(at2), \
441 _JS_CTYPE_ARGTYPE(at3), \
442 _JS_CTYPE_ARGTYPE(at4), \
443 _JS_CTYPE_ARGTYPE(at5), \
444 _JS_CTYPE_ARGTYPE(at6), \
445 _JS_CTYPE_ARGTYPE(at7)), \
448 #define JS_DECLARE_CALLINFO(name) extern const nanojit::CallInfo _JS_CALLINFO(name);
450 #define _JS_TN_INIT_HELPER_n(n, args) _JS_TN_INIT_HELPER_##n args
452 #define _JS_TN_INIT_HELPER_1(linkage, rt, op, at0, isPure, storeAccSet) \
454 _JS_CTYPE_PCH(at0), \
455 _JS_CTYPE_ACH(at0), \
458 #define _JS_TN_INIT_HELPER_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
460 _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
461 _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
464 #define _JS_TN_INIT_HELPER_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
466 _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
467 _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
470 #define _JS_TN_INIT_HELPER_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
472 _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
473 _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
476 #define _JS_TN_INIT_HELPER_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
478 _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) \
479 _JS_CTYPE_PCH(at0), \
480 _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) \
481 _JS_CTYPE_ACH(at0), \
484 #define _JS_TN_INIT_HELPER_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
486 _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) \
487 _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
488 _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) \
489 _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
492 #define _JS_TN_INIT_HELPER_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet) \
494 _JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) \
495 _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
496 _JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) \
497 _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
500 #define _JS_TN_INIT_HELPER_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet) \
502 _JS_CTYPE_PCH(at7) _JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) \
503 _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
504 _JS_CTYPE_ACH(at7) _JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) \
505 _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
508 #define JS_DEFINE_TRCINFO_1(name, tn0) \
509 _JS_DEFINE_CALLINFO_n tn0 \
510 JSSpecializedNative name##_sns[] = { \
511 { _JS_TN_INIT_HELPER_n tn0 } \
513 JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
515 #define JS_DEFINE_TRCINFO_2(name, tn0, tn1) \
516 _JS_DEFINE_CALLINFO_n tn0 \
517 _JS_DEFINE_CALLINFO_n tn1 \
518 JSSpecializedNative name##_sns[] = { \
519 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
520 { _JS_TN_INIT_HELPER_n tn1 } \
522 JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
524 #define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2) \
525 _JS_DEFINE_CALLINFO_n tn0 \
526 _JS_DEFINE_CALLINFO_n tn1 \
527 _JS_DEFINE_CALLINFO_n tn2 \
528 JSSpecializedNative name##_sns[] = { \
529 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
530 { _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
531 { _JS_TN_INIT_HELPER_n tn2 } \
533 JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
535 #define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3) \
536 _JS_DEFINE_CALLINFO_n tn0 \
537 _JS_DEFINE_CALLINFO_n tn1 \
538 _JS_DEFINE_CALLINFO_n tn2 \
539 _JS_DEFINE_CALLINFO_n tn3 \
540 JSSpecializedNative name##_sns[] = { \
541 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
542 { _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
543 { _JS_TN_INIT_HELPER_n tn2 | JSTN_MORE }, \
544 { _JS_TN_INIT_HELPER_n tn3 } \
546 JSNativeTraceInfo name##_trcinfo = { JS_VALUEIFY_NATIVE(name), name##_sns };
548 #define _JS_DEFINE_CALLINFO_n(n, args) JS_DEFINE_CALLINFO_##n args
551 js_StringToNumber(JSContext* cx, JSString* str, JSBool *ok);
553 /* Extern version of SetBuiltinError. */
554 extern JS_FRIEND_API(void)
555 js_SetTraceableNativeFailed(JSContext *cx);
557 extern jsdouble FASTCALL
558 js_dmod(jsdouble a, jsdouble b);
562 #define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet)
563 #define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet)
564 #define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet)
565 #define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet)
566 #define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet)
567 #define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet)
568 #define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet)
569 #define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet)
570 #define JS_DECLARE_CALLINFO(name)
571 #define JS_DEFINE_TRCINFO_1(name, tn0)
572 #define JS_DEFINE_TRCINFO_2(name, tn0, tn1)
573 #define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2)
574 #define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3)
576 #endif /* !JS_TRACER */
578 /* Defined in jsarray.cpp. */
580 JS_DECLARE_CALLINFO(NewDenseEmptyArray)
581 JS_DECLARE_CALLINFO(NewDenseAllocatedArray)
582 JS_DECLARE_CALLINFO(NewDenseUnallocatedArray)
584 JS_DECLARE_CALLINFO(js_ArrayCompPush_tn)
585 JS_DECLARE_CALLINFO(js_EnsureDenseArrayCapacity)
587 /* Defined in jsbuiltins.cpp. */
588 JS_DECLARE_CALLINFO(js_UnboxDouble)
589 JS_DECLARE_CALLINFO(js_UnboxInt32)
590 JS_DECLARE_CALLINFO(js_dmod)
591 JS_DECLARE_CALLINFO(js_imod)
592 JS_DECLARE_CALLINFO(js_DoubleToInt32)
593 JS_DECLARE_CALLINFO(js_DoubleToUint32)
594 JS_DECLARE_CALLINFO(js_StringToNumber)
595 JS_DECLARE_CALLINFO(js_StringToInt32)
596 JS_DECLARE_CALLINFO(js_AddProperty)
597 JS_DECLARE_CALLINFO(js_AddAtomProperty)
598 JS_DECLARE_CALLINFO(js_HasNamedProperty)
599 JS_DECLARE_CALLINFO(js_HasNamedPropertyInt32)
600 JS_DECLARE_CALLINFO(js_TypeOfObject)
601 JS_DECLARE_CALLINFO(js_BooleanIntToString)
602 JS_DECLARE_CALLINFO(js_NewNullClosure)
604 /* Defined in jsfun.cpp. */
605 JS_DECLARE_CALLINFO(js_AllocFlatClosure)
606 JS_DECLARE_CALLINFO(js_PutArgumentsOnTrace)
607 JS_DECLARE_CALLINFO(js_PutCallObjectOnTrace)
608 JS_DECLARE_CALLINFO(js_SetCallVar)
609 JS_DECLARE_CALLINFO(js_SetCallArg)
610 JS_DECLARE_CALLINFO(js_CloneFunctionObject)
611 JS_DECLARE_CALLINFO(js_CreateCallObjectOnTrace)
612 JS_DECLARE_CALLINFO(js_NewArgumentsOnTrace)
614 /* Defined in jsnum.cpp. */
615 JS_DECLARE_CALLINFO(js_NumberToString)
617 /* Defined in jsobj.cpp. */
618 JS_DECLARE_CALLINFO(js_Object_tn)
619 JS_DECLARE_CALLINFO(js_CreateThisFromTrace)
620 JS_DECLARE_CALLINFO(js_InitializerObject)
622 /* Defined in jsregexp.cpp. */
623 JS_DECLARE_CALLINFO(js_CloneRegExpObject)
625 /* Defined in jsstr.cpp. */
626 JS_DECLARE_CALLINFO(js_String_tn)
627 JS_DECLARE_CALLINFO(js_CompareStringsOnTrace)
628 JS_DECLARE_CALLINFO(js_ConcatStrings)
629 JS_DECLARE_CALLINFO(js_EqualStringsOnTrace)
630 JS_DECLARE_CALLINFO(js_Flatten)
632 /* Defined in jstypedarray.cpp. */
633 JS_DECLARE_CALLINFO(js_TypedArray_uint8_clamp_double)
635 #endif /* jsbuiltins_h___ */