Bug 588735 - Mirror glass caption buttons for rtl windows. r=roc, a=blocking-betaN.
[mozilla-central.git] / js / src / jsbuiltins.h
blob3813287211935688b04b5616c8a6212d9939af3e
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
15 * License.
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
18 * May 28, 2008.
20 * The Initial Developer of the Original Code is
21 * Mozilla Corporation.
23 * Contributor(s):
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___
43 #ifdef JS_TRACER
45 #include "nanojit/nanojit.h"
47 #ifdef THIS
48 #undef THIS
49 #endif
51 enum JSTNErrType { INFALLIBLE, FAIL_STATUS, FAIL_NULL, FAIL_NEG, FAIL_NEITHER };
52 enum {
53 JSTN_ERRTYPE_MASK = 0x07,
54 JSTN_UNBOX_AFTER = 0x08,
55 JSTN_MORE = 0x10,
56 JSTN_CONSTRUCTOR = 0x20,
57 JSTN_RETURN_NULLABLE_STR = 0x40,
58 JSTN_RETURN_NULLABLE_OBJ = 0x80
61 #define JSTN_ERRTYPE(jstn) ((jstn)->flags & JSTN_ERRTYPE_MASK)
64 * Type describing a type specialization of a JSFastNative.
66 * |prefix| and |argtypes| declare what arguments should be passed to the
67 * native function. |prefix| can contain the following characters:
69 * 'C': a JSContext* argument
70 * 'T': |this| as a JSObject* argument (bails if |this| is not an object)
71 * 'S': |this| as a JSString* argument (bails if |this| is not a string)
72 * 'R': a JSRuntime* argument
73 * 'P': the pc as a jsbytecode*
74 * 'D': |this| as a number (jsdouble)
75 * 'f': the function being called, as a JSObject*
76 * 'p': the .prototype of the function, as a JSObject*
78 * The corresponding things will get passed as arguments to the builtin in
79 * reverse order (so TC means JSContext* as the first arg, and the
80 * JSObject* for |this| as the second arg).
82 * |argtypes| can contain the following characters:
83 * 'd': a number (double) argument
84 * 'i': an integer argument
85 * 's': a JSString* argument
86 * 'o': a JSObject* argument
87 * 'r': a JSObject* argument that is of class js_RegExpClass
88 * 'f': a JSObject* argument that is of class js_FunctionClass
89 * 'v': a value argument: on 32-bit, a Value*, on 64-bit, a jsval
91 struct JSSpecializedNative {
92 const nanojit::CallInfo *builtin;
93 const char *prefix;
94 const char *argtypes;
95 uintN flags; /* JSTNErrType | JSTN_UNBOX_AFTER | JSTN_MORE |
96 JSTN_CONSTRUCTOR */
100 * Type holding extra trace-specific information about a fast native.
102 * 'specializations' points to a static array of available specializations
103 * terminated by the lack of having the JSTN_MORE flag set.
105 struct JSNativeTraceInfo {
106 JSFastNative native;
107 JSSpecializedNative *specializations;
110 /* Macros used by JS_DEFINE_CALLINFOn. */
111 #ifdef DEBUG
112 #define _JS_CI_NAME(op) ,#op
113 #else
114 #define _JS_CI_NAME(op)
115 #endif
117 #define _JS_I32_ARGTYPE nanojit::ARGTYPE_I
118 #define _JS_I32_RETTYPE nanojit::ARGTYPE_I
119 #define _JS_U64_ARGTYPE nanojit::ARGTYPE_Q
120 #define _JS_U64_RETTYPE nanojit::ARGTYPE_Q
121 #define _JS_F64_ARGTYPE nanojit::ARGTYPE_D
122 #define _JS_F64_RETTYPE nanojit::ARGTYPE_D
123 #define _JS_PTR_ARGTYPE nanojit::ARGTYPE_P
124 #define _JS_PTR_RETTYPE nanojit::ARGTYPE_P
126 struct ClosureVarInfo;
129 * Supported types for builtin functions.
131 * Types with -- for the two string fields are not permitted as argument types
132 * in JS_DEFINE_TRCINFO.
134 * There are three kinds of traceable-native error handling.
136 * - If a traceable native's return type ends with _FAIL, it always runs to
137 * completion. It can either succeed or fail with an error or exception;
138 * on success, it may or may not stay on trace. There may be side effects
139 * in any case. If the call succeeds but bails off trace, we resume in the
140 * interpreter at the next opcode.
142 * _FAIL builtins indicate failure or bailing off trace by setting bits in
143 * cx->interpState->builtinStatus.
145 * - If a traceable native's return type contains _RETRY, it can either
146 * succeed, fail with a JS exception, or tell the caller to bail off trace
147 * and retry the call from the interpreter. The last case happens if the
148 * builtin discovers that it can't do its job without examining the JS
149 * stack, reentering the interpreter, accessing properties of the global
150 * object, etc.
152 * The builtin must detect the need to retry before committing any side
153 * effects. If a builtin can't do this, it must use a _FAIL return type
154 * instead of _RETRY.
156 * _RETRY builtins indicate failure with a special return value that
157 * depends on the return type:
159 * BOOL_RETRY: JS_NEITHER
160 * INT32_RETRY: any negative value
161 * STRING_RETRY: NULL
162 * OBJECT_RETRY_NULL: NULL
164 * _RETRY function calls are faster than _FAIL calls. Each _RETRY call
165 * saves two writes to cx->bailExit and a read from state->builtinStatus.
167 * - All other traceable natives are infallible (e.g. Date.now, Math.log).
169 * Special builtins known to the tracer can have their own idiosyncratic
170 * error codes.
172 * When a traceable native returns a value indicating failure, we fall off
173 * trace. If an exception is pending, it is thrown; otherwise, we assume the
174 * builtin had no side effects and retry the current bytecode in the
175 * interpreter.
177 * So a builtin must not return a value indicating failure after causing side
178 * effects (such as reporting an error), without setting an exception pending.
179 * The operation would be retried, despite the first attempt's observable
180 * effects.
182 #define _JS_CTYPE(ctype, size, pch, ach, flags) (ctype, size, pch, ach, flags)
184 #define _JS_CTYPE_CONTEXT _JS_CTYPE(JSContext *, _JS_PTR,"C", "", INFALLIBLE)
185 #define _JS_CTYPE_RUNTIME _JS_CTYPE(JSRuntime *, _JS_PTR,"R", "", INFALLIBLE)
186 #define _JS_CTYPE_THIS _JS_CTYPE(JSObject *, _JS_PTR,"T", "", INFALLIBLE)
187 #define _JS_CTYPE_THIS_DOUBLE _JS_CTYPE(jsdouble, _JS_F64,"D", "", INFALLIBLE)
188 #define _JS_CTYPE_THIS_STRING _JS_CTYPE(JSString *, _JS_PTR,"S", "", INFALLIBLE)
189 #define _JS_CTYPE_CALLEE _JS_CTYPE(JSObject *, _JS_PTR,"f","", INFALLIBLE)
190 #define _JS_CTYPE_CALLEE_PROTOTYPE _JS_CTYPE(JSObject *, _JS_PTR,"p","", INFALLIBLE)
191 #define _JS_CTYPE_FUNCTION _JS_CTYPE(JSFunction *, _JS_PTR, --, --, INFALLIBLE)
192 #define _JS_CTYPE_PC _JS_CTYPE(jsbytecode *, _JS_PTR,"P", "", INFALLIBLE)
193 #define _JS_CTYPE_VALUEPTR _JS_CTYPE(js::Value *, _JS_PTR, --, --, INFALLIBLE)
194 #define _JS_CTYPE_CVALUEPTR _JS_CTYPE(const js::Value *, _JS_PTR, --, --, INFALLIBLE)
195 #define _JS_CTYPE_JSID _JS_CTYPE(jsid, _JS_PTR, --, --, INFALLIBLE)
196 #define _JS_CTYPE_JSVAL _JS_CTYPE(js::Value, _JS_U64, --, --, INFALLIBLE)
197 #define _JS_CTYPE_BOOL _JS_CTYPE(JSBool, _JS_I32, "","i", INFALLIBLE)
198 #define _JS_CTYPE_BOOL_RETRY _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_NEITHER)
199 #define _JS_CTYPE_BOOL_FAIL _JS_CTYPE(JSBool, _JS_I32, --, --, FAIL_STATUS)
200 #define _JS_CTYPE_BOOLPTR _JS_CTYPE(JSBool *, _JS_PTR, --, --, INFALLIBLE)
201 #define _JS_CTYPE_INT32 _JS_CTYPE(int32, _JS_I32, "","i", INFALLIBLE)
202 #define _JS_CTYPE_INT32_RETRY _JS_CTYPE(int32, _JS_I32, --, --, FAIL_NEG)
203 #define _JS_CTYPE_INT32_FAIL _JS_CTYPE(int32, _JS_I32, --, --, FAIL_STATUS)
204 #define _JS_CTYPE_INT32PTR _JS_CTYPE(int32 *, _JS_PTR, --, --, INFALLIBLE)
205 #define _JS_CTYPE_UINT32 _JS_CTYPE(uint32, _JS_I32, "","i", INFALLIBLE)
206 #define _JS_CTYPE_UINT32_RETRY _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_NEG)
207 #define _JS_CTYPE_UINT32_FAIL _JS_CTYPE(uint32, _JS_I32, --, --, FAIL_STATUS)
208 #define _JS_CTYPE_DOUBLE _JS_CTYPE(jsdouble, _JS_F64, "","d", INFALLIBLE)
209 #define _JS_CTYPE_DOUBLE_FAIL _JS_CTYPE(jsdouble, _JS_F64, --, --, FAIL_STATUS)
210 #define _JS_CTYPE_STRING _JS_CTYPE(JSString *, _JS_PTR, "","s", INFALLIBLE)
211 #define _JS_CTYPE_STRING_RETRY _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_NULL)
212 #define _JS_CTYPE_STRING_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS)
213 #define _JS_CTYPE_STRING_OR_NULL_FAIL _JS_CTYPE(JSString *, _JS_PTR, --, --, FAIL_STATUS | \
214 JSTN_RETURN_NULLABLE_STR)
215 #define _JS_CTYPE_STRINGPTR _JS_CTYPE(JSString **, _JS_PTR, --, --, INFALLIBLE)
216 #define _JS_CTYPE_OBJECT _JS_CTYPE(JSObject *, _JS_PTR, "","o", INFALLIBLE)
217 #define _JS_CTYPE_OBJECT_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL)
218 #define _JS_CTYPE_OBJECT_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS)
219 #define _JS_CTYPE_OBJECT_OR_NULL_FAIL _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_STATUS | \
220 JSTN_RETURN_NULLABLE_OBJ)
221 #define _JS_CTYPE_OBJECTPTR _JS_CTYPE(JSObject **, _JS_PTR, --, --, INFALLIBLE)
222 #define _JS_CTYPE_CONSTRUCTOR_RETRY _JS_CTYPE(JSObject *, _JS_PTR, --, --, FAIL_NULL | \
223 JSTN_CONSTRUCTOR)
224 #define _JS_CTYPE_REGEXP _JS_CTYPE(JSObject *, _JS_PTR, "","r", INFALLIBLE)
225 #define _JS_CTYPE_SCOPEPROP _JS_CTYPE(JSScopeProperty *, _JS_PTR, --, --, INFALLIBLE)
226 #define _JS_CTYPE_TRACERSTATE _JS_CTYPE(TracerState *, _JS_PTR, --, --, INFALLIBLE)
227 #define _JS_CTYPE_FRAGMENT _JS_CTYPE(nanojit::Fragment *, _JS_PTR, --, --, INFALLIBLE)
228 #define _JS_CTYPE_CLASS _JS_CTYPE(js::Class *, _JS_PTR, --, --, INFALLIBLE)
229 #define _JS_CTYPE_DOUBLEPTR _JS_CTYPE(double *, _JS_PTR, --, --, INFALLIBLE)
230 #define _JS_CTYPE_CHARPTR _JS_CTYPE(char *, _JS_PTR, --, --, INFALLIBLE)
231 #define _JS_CTYPE_CVIPTR _JS_CTYPE(const ClosureVarInfo *, _JS_PTR, --, --, INFALLIBLE)
232 #define _JS_CTYPE_FRAMEINFO _JS_CTYPE(FrameInfo *, _JS_PTR, --, --, INFALLIBLE)
235 * The "VALUE" type is used to indicate that a native takes a js::Value
236 * parameter by value. Unfortunately, for technical reasons, we can't simply
237 * have the parameter type be js::Value. Furthermore, the right thing to pass
238 * differs based on word size. Thus, a native that declares a parameter of type
239 * VALUE should have the corresponding argument type be:
240 * - on 32-bit: const Value*
241 * - on 64-bit: jsval (which is a uint64)
243 * To write code that just does the right thing, use the pattern:
244 * void foo(js::ValueArgType arg) {
245 * const js::Value &v = js::ValueArgToConstRef(arg);
247 #if JS_BITS_PER_WORD == 32
248 # define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_PTR, "","v", INFALLIBLE)
249 #elif JS_BITS_PER_WORD == 64
250 # define _JS_CTYPE_VALUE _JS_CTYPE(js::ValueArgType, _JS_U64, "","v", INFALLIBLE)
251 #endif
253 #define _JS_EXPAND(tokens) tokens
255 #define _JS_CTYPE_TYPE2(t,s,p,a,f) t
256 #define _JS_CTYPE_TYPE(tyname) _JS_EXPAND(_JS_CTYPE_TYPE2 _JS_CTYPE_##tyname)
257 #define _JS_CTYPE_RETTYPE2(t,s,p,a,f) s##_RETTYPE
258 #define _JS_CTYPE_RETTYPE(tyname) _JS_EXPAND(_JS_CTYPE_RETTYPE2 _JS_CTYPE_##tyname)
259 #define _JS_CTYPE_ARGTYPE2(t,s,p,a,f) s##_ARGTYPE
260 #define _JS_CTYPE_ARGTYPE(tyname) _JS_EXPAND(_JS_CTYPE_ARGTYPE2 _JS_CTYPE_##tyname)
261 #define _JS_CTYPE_PCH2(t,s,p,a,f) p
262 #define _JS_CTYPE_PCH(tyname) _JS_EXPAND(_JS_CTYPE_PCH2 _JS_CTYPE_##tyname)
263 #define _JS_CTYPE_ACH2(t,s,p,a,f) a
264 #define _JS_CTYPE_ACH(tyname) _JS_EXPAND(_JS_CTYPE_ACH2 _JS_CTYPE_##tyname)
265 #define _JS_CTYPE_FLAGS2(t,s,p,a,f) f
266 #define _JS_CTYPE_FLAGS(tyname) _JS_EXPAND(_JS_CTYPE_FLAGS2 _JS_CTYPE_##tyname)
268 #define _JS_static_TN(t) static t
269 #define _JS_static_CI static
270 #define _JS_extern_TN(t) extern t
271 #define _JS_extern_CI
272 #define _JS_FRIEND_TN(t) extern JS_FRIEND_API(t)
273 #define _JS_FRIEND_CI
274 #define _JS_TN_LINKAGE(linkage, t) _JS_##linkage##_TN(t)
275 #define _JS_CI_LINKAGE(linkage) _JS_##linkage##_CI
277 #define _JS_CALLINFO(name) name##_ci
279 #if defined(JS_NO_FASTCALL) && defined(NANOJIT_IA32)
280 #define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
281 _JS_TN_LINKAGE(linkage, crtype) name cargtypes; \
282 _JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
283 { (intptr_t) &name, argtypes, nanojit::ABI_CDECL, isPure, storeAccSet _JS_CI_NAME(name) };\
284 JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
286 #else
287 #define _JS_DEFINE_CALLINFO(linkage, name, crtype, cargtypes, argtypes, isPure, storeAccSet) \
288 _JS_TN_LINKAGE(linkage, crtype) FASTCALL name cargtypes; \
289 _JS_CI_LINKAGE(linkage) const nanojit::CallInfo _JS_CALLINFO(name) = \
290 { (intptr_t) &name, argtypes, nanojit::ABI_FASTCALL, isPure, storeAccSet _JS_CI_NAME(name) }; \
291 JS_STATIC_ASSERT_IF(isPure, (storeAccSet) == nanojit::ACCSET_NONE);
292 #endif
295 * This macro is used for builtin functions that can be called from JITted
296 * code. It declares a C function named <op> and a CallInfo struct named
297 * <op>_ci so the tracer can call it. The <N> in JS_DEFINE_CALLINFO_<N> is
298 * the number of arguments the builtin takes. Builtins with no arguments
299 * are not supported. Using a macro is clunky but ensures that the types
300 * for each C function matches those for the corresponding CallInfo struct;
301 * mismatched types can cause subtle problems.
303 * The macro arguments are:
305 * - The linkage for the function and the associated CallInfo global. It
306 * can be extern, static, or FRIEND, which specifies JS_FRIEND_API linkage
307 * for the function.
309 * - The return type. This identifier must name one of the _JS_TYPEINFO_*
310 * macros defined in jsbuiltins.h.
312 * - The builtin name.
314 * - The parameter types.
316 * - The isPure flag. Set to 1 if:
317 * (a) the function's return value is determined solely by its arguments
318 * (ie. no hidden state, no implicit inputs used such as global
319 * variables or the result of an I/O operation); and
320 * (b) the function causes no observable side-effects (ie. no writes to
321 * global variables, no I/O output).
322 * Multiple calls to a pure function can be merged during CSE.
324 * - The storeAccSet. This indicates which memory access regions the function
325 * accesses. It must be ACCSET_NONE if the function is pure; use
326 * ACCSET_STORE_ANY if you're not sure. Used to determine if each call site
327 * of the function aliases any loads.
329 #define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet) \
330 _JS_DEFINE_CALLINFO(linkage, op, \
331 _JS_CTYPE_TYPE(rt), \
332 (_JS_CTYPE_TYPE(at0)), \
333 nanojit::CallInfo::typeSig1(_JS_CTYPE_RETTYPE(rt), \
334 _JS_CTYPE_ARGTYPE(at0)), \
335 isPure, storeAccSet)
336 #define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
337 _JS_DEFINE_CALLINFO(linkage, op, \
338 _JS_CTYPE_TYPE(rt), \
339 (_JS_CTYPE_TYPE(at0), \
340 _JS_CTYPE_TYPE(at1)), \
341 nanojit::CallInfo::typeSig2(_JS_CTYPE_RETTYPE(rt), \
342 _JS_CTYPE_ARGTYPE(at0), \
343 _JS_CTYPE_ARGTYPE(at1)), \
344 isPure, storeAccSet)
345 #define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
346 _JS_DEFINE_CALLINFO(linkage, op, \
347 _JS_CTYPE_TYPE(rt), \
348 (_JS_CTYPE_TYPE(at0), \
349 _JS_CTYPE_TYPE(at1), \
350 _JS_CTYPE_TYPE(at2)), \
351 nanojit::CallInfo::typeSig3(_JS_CTYPE_RETTYPE(rt), \
352 _JS_CTYPE_ARGTYPE(at0), \
353 _JS_CTYPE_ARGTYPE(at1), \
354 _JS_CTYPE_ARGTYPE(at2)), \
355 isPure, storeAccSet)
356 #define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
357 _JS_DEFINE_CALLINFO(linkage, op, \
358 _JS_CTYPE_TYPE(rt), \
359 (_JS_CTYPE_TYPE(at0), \
360 _JS_CTYPE_TYPE(at1), \
361 _JS_CTYPE_TYPE(at2), \
362 _JS_CTYPE_TYPE(at3)), \
363 nanojit::CallInfo::typeSig4(_JS_CTYPE_RETTYPE(rt), \
364 _JS_CTYPE_ARGTYPE(at0), \
365 _JS_CTYPE_ARGTYPE(at1), \
366 _JS_CTYPE_ARGTYPE(at2), \
367 _JS_CTYPE_ARGTYPE(at3)), \
368 isPure, storeAccSet)
369 #define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
370 _JS_DEFINE_CALLINFO(linkage, op, \
371 _JS_CTYPE_TYPE(rt), \
372 (_JS_CTYPE_TYPE(at0), \
373 _JS_CTYPE_TYPE(at1), \
374 _JS_CTYPE_TYPE(at2), \
375 _JS_CTYPE_TYPE(at3), \
376 _JS_CTYPE_TYPE(at4)), \
377 nanojit::CallInfo::typeSig5(_JS_CTYPE_RETTYPE(rt), \
378 _JS_CTYPE_ARGTYPE(at0), \
379 _JS_CTYPE_ARGTYPE(at1), \
380 _JS_CTYPE_ARGTYPE(at2), \
381 _JS_CTYPE_ARGTYPE(at3), \
382 _JS_CTYPE_ARGTYPE(at4)), \
383 isPure, storeAccSet)
384 #define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
385 _JS_DEFINE_CALLINFO(linkage, op, \
386 _JS_CTYPE_TYPE(rt), \
387 (_JS_CTYPE_TYPE(at0), \
388 _JS_CTYPE_TYPE(at1), \
389 _JS_CTYPE_TYPE(at2), \
390 _JS_CTYPE_TYPE(at3), \
391 _JS_CTYPE_TYPE(at4), \
392 _JS_CTYPE_TYPE(at5)), \
393 nanojit::CallInfo::typeSig6(_JS_CTYPE_RETTYPE(rt), \
394 _JS_CTYPE_ARGTYPE(at0), \
395 _JS_CTYPE_ARGTYPE(at1), \
396 _JS_CTYPE_ARGTYPE(at2), \
397 _JS_CTYPE_ARGTYPE(at3), \
398 _JS_CTYPE_ARGTYPE(at4), \
399 _JS_CTYPE_ARGTYPE(at5)), \
400 isPure, storeAccSet)
401 #define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, \
402 storeAccSet) \
403 _JS_DEFINE_CALLINFO(linkage, op, \
404 _JS_CTYPE_TYPE(rt), \
405 (_JS_CTYPE_TYPE(at0), \
406 _JS_CTYPE_TYPE(at1), \
407 _JS_CTYPE_TYPE(at2), \
408 _JS_CTYPE_TYPE(at3), \
409 _JS_CTYPE_TYPE(at4), \
410 _JS_CTYPE_TYPE(at5), \
411 _JS_CTYPE_TYPE(at6)), \
412 nanojit::CallInfo::typeSig7(_JS_CTYPE_RETTYPE(rt), \
413 _JS_CTYPE_ARGTYPE(at0), \
414 _JS_CTYPE_ARGTYPE(at1), \
415 _JS_CTYPE_ARGTYPE(at2), \
416 _JS_CTYPE_ARGTYPE(at3), \
417 _JS_CTYPE_ARGTYPE(at4), \
418 _JS_CTYPE_ARGTYPE(at5), \
419 _JS_CTYPE_ARGTYPE(at6)), \
420 isPure, storeAccSet)
421 #define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, \
422 storeAccSet) \
423 _JS_DEFINE_CALLINFO(linkage, op, \
424 _JS_CTYPE_TYPE(rt), \
425 (_JS_CTYPE_TYPE(at0), \
426 _JS_CTYPE_TYPE(at1), \
427 _JS_CTYPE_TYPE(at2), \
428 _JS_CTYPE_TYPE(at3), \
429 _JS_CTYPE_TYPE(at4), \
430 _JS_CTYPE_TYPE(at5), \
431 _JS_CTYPE_TYPE(at6), \
432 _JS_CTYPE_TYPE(at7)), \
433 nanojit::CallInfo::typeSig8(_JS_CTYPE_RETTYPE(rt), \
434 _JS_CTYPE_ARGTYPE(at0), \
435 _JS_CTYPE_ARGTYPE(at1), \
436 _JS_CTYPE_ARGTYPE(at2), \
437 _JS_CTYPE_ARGTYPE(at3), \
438 _JS_CTYPE_ARGTYPE(at4), \
439 _JS_CTYPE_ARGTYPE(at5), \
440 _JS_CTYPE_ARGTYPE(at6), \
441 _JS_CTYPE_ARGTYPE(at7)), \
442 isPure, storeAccSet)
444 #define JS_DECLARE_CALLINFO(name) extern const nanojit::CallInfo _JS_CALLINFO(name);
446 #define _JS_TN_INIT_HELPER_n(n, args) _JS_TN_INIT_HELPER_##n args
448 #define _JS_TN_INIT_HELPER_1(linkage, rt, op, at0, isPure, storeAccSet) \
449 &_JS_CALLINFO(op), \
450 _JS_CTYPE_PCH(at0), \
451 _JS_CTYPE_ACH(at0), \
452 _JS_CTYPE_FLAGS(rt)
454 #define _JS_TN_INIT_HELPER_2(linkage, rt, op, at0, at1, isPure, storeAccSet) \
455 &_JS_CALLINFO(op), \
456 _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
457 _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
458 _JS_CTYPE_FLAGS(rt)
460 #define _JS_TN_INIT_HELPER_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet) \
461 &_JS_CALLINFO(op), \
462 _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
463 _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
464 _JS_CTYPE_FLAGS(rt)
466 #define _JS_TN_INIT_HELPER_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet) \
467 &_JS_CALLINFO(op), \
468 _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
469 _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
470 _JS_CTYPE_FLAGS(rt)
472 #define _JS_TN_INIT_HELPER_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet) \
473 &_JS_CALLINFO(op), \
474 _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) \
475 _JS_CTYPE_PCH(at0), \
476 _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) \
477 _JS_CTYPE_ACH(at0), \
478 _JS_CTYPE_FLAGS(rt)
480 #define _JS_TN_INIT_HELPER_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet) \
481 &_JS_CALLINFO(op), \
482 _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) \
483 _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
484 _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) \
485 _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
486 _JS_CTYPE_FLAGS(rt)
488 #define _JS_TN_INIT_HELPER_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet) \
489 &_JS_CALLINFO(op), \
490 _JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) _JS_CTYPE_PCH(at3) \
491 _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
492 _JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) _JS_CTYPE_ACH(at3) \
493 _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
494 _JS_CTYPE_FLAGS(rt)
496 #define _JS_TN_INIT_HELPER_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet) \
497 &_JS_CALLINFO(op), \
498 _JS_CTYPE_PCH(at7) _JS_CTYPE_PCH(at6) _JS_CTYPE_PCH(at5) _JS_CTYPE_PCH(at4) \
499 _JS_CTYPE_PCH(at3) _JS_CTYPE_PCH(at2) _JS_CTYPE_PCH(at1) _JS_CTYPE_PCH(at0), \
500 _JS_CTYPE_ACH(at7) _JS_CTYPE_ACH(at6) _JS_CTYPE_ACH(at5) _JS_CTYPE_ACH(at4) \
501 _JS_CTYPE_ACH(at3) _JS_CTYPE_ACH(at2) _JS_CTYPE_ACH(at1) _JS_CTYPE_ACH(at0), \
502 _JS_CTYPE_FLAGS(rt)
504 #define JS_DEFINE_TRCINFO_1(name, tn0) \
505 _JS_DEFINE_CALLINFO_n tn0 \
506 JSSpecializedNative name##_sns[] = { \
507 { _JS_TN_INIT_HELPER_n tn0 } \
508 }; \
509 JSNativeTraceInfo name##_trcinfo = { (JSFastNative)name, name##_sns };
511 #define JS_DEFINE_TRCINFO_2(name, tn0, tn1) \
512 _JS_DEFINE_CALLINFO_n tn0 \
513 _JS_DEFINE_CALLINFO_n tn1 \
514 JSSpecializedNative name##_sns[] = { \
515 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
516 { _JS_TN_INIT_HELPER_n tn1 } \
517 }; \
518 JSNativeTraceInfo name##_trcinfo = { (JSFastNative)name, name##_sns };
520 #define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2) \
521 _JS_DEFINE_CALLINFO_n tn0 \
522 _JS_DEFINE_CALLINFO_n tn1 \
523 _JS_DEFINE_CALLINFO_n tn2 \
524 JSSpecializedNative name##_sns[] = { \
525 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
526 { _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
527 { _JS_TN_INIT_HELPER_n tn2 } \
528 }; \
529 JSNativeTraceInfo name##_trcinfo = { (JSFastNative)name, name##_sns };
531 #define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3) \
532 _JS_DEFINE_CALLINFO_n tn0 \
533 _JS_DEFINE_CALLINFO_n tn1 \
534 _JS_DEFINE_CALLINFO_n tn2 \
535 _JS_DEFINE_CALLINFO_n tn3 \
536 JSSpecializedNative name##_sns[] = { \
537 { _JS_TN_INIT_HELPER_n tn0 | JSTN_MORE }, \
538 { _JS_TN_INIT_HELPER_n tn1 | JSTN_MORE }, \
539 { _JS_TN_INIT_HELPER_n tn2 | JSTN_MORE }, \
540 { _JS_TN_INIT_HELPER_n tn3 } \
541 }; \
542 JSNativeTraceInfo name##_trcinfo = { (JSFastNative)name, name##_sns };
544 #define _JS_DEFINE_CALLINFO_n(n, args) JS_DEFINE_CALLINFO_##n args
546 jsdouble FASTCALL
547 js_StringToNumber(JSContext* cx, JSString* str);
549 /* Extern version of SetBuiltinError. */
550 extern JS_FRIEND_API(void)
551 js_SetTraceableNativeFailed(JSContext *cx);
553 extern jsdouble FASTCALL
554 js_dmod(jsdouble a, jsdouble b);
556 #else
558 #define JS_DEFINE_CALLINFO_1(linkage, rt, op, at0, isPure, storeAccSet)
559 #define JS_DEFINE_CALLINFO_2(linkage, rt, op, at0, at1, isPure, storeAccSet)
560 #define JS_DEFINE_CALLINFO_3(linkage, rt, op, at0, at1, at2, isPure, storeAccSet)
561 #define JS_DEFINE_CALLINFO_4(linkage, rt, op, at0, at1, at2, at3, isPure, storeAccSet)
562 #define JS_DEFINE_CALLINFO_5(linkage, rt, op, at0, at1, at2, at3, at4, isPure, storeAccSet)
563 #define JS_DEFINE_CALLINFO_6(linkage, rt, op, at0, at1, at2, at3, at4, at5, isPure, storeAccSet)
564 #define JS_DEFINE_CALLINFO_7(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, isPure, storeAccSet)
565 #define JS_DEFINE_CALLINFO_8(linkage, rt, op, at0, at1, at2, at3, at4, at5, at6, at7, isPure, storeAccSet)
566 #define JS_DECLARE_CALLINFO(name)
567 #define JS_DEFINE_TRCINFO_1(name, tn0)
568 #define JS_DEFINE_TRCINFO_2(name, tn0, tn1)
569 #define JS_DEFINE_TRCINFO_3(name, tn0, tn1, tn2)
570 #define JS_DEFINE_TRCINFO_4(name, tn0, tn1, tn2, tn3)
572 #endif /* !JS_TRACER */
574 /* Defined in jsarray.cpp. */
575 JS_DECLARE_CALLINFO(js_Array_dense_setelem)
576 JS_DECLARE_CALLINFO(js_Array_dense_setelem_int)
577 JS_DECLARE_CALLINFO(js_Array_dense_setelem_double)
578 JS_DECLARE_CALLINFO(js_NewEmptyArray)
579 JS_DECLARE_CALLINFO(js_NewPreallocatedArray)
580 JS_DECLARE_CALLINFO(js_ArrayCompPush_tn)
582 /* Defined in jsbuiltins.cpp. */
583 JS_DECLARE_CALLINFO(js_UnboxDouble)
584 JS_DECLARE_CALLINFO(js_UnboxInt32)
585 JS_DECLARE_CALLINFO(js_dmod)
586 JS_DECLARE_CALLINFO(js_imod)
587 JS_DECLARE_CALLINFO(js_DoubleToInt32)
588 JS_DECLARE_CALLINFO(js_DoubleToUint32)
589 JS_DECLARE_CALLINFO(js_StringToNumber)
590 JS_DECLARE_CALLINFO(js_StringToInt32)
591 JS_DECLARE_CALLINFO(js_AddProperty)
592 JS_DECLARE_CALLINFO(js_AddAtomProperty)
593 JS_DECLARE_CALLINFO(js_HasNamedProperty)
594 JS_DECLARE_CALLINFO(js_HasNamedPropertyInt32)
595 JS_DECLARE_CALLINFO(js_TypeOfObject)
596 JS_DECLARE_CALLINFO(js_BooleanIntToString)
597 JS_DECLARE_CALLINFO(js_NewNullClosure)
598 JS_DECLARE_CALLINFO(js_PopInterpFrame)
600 /* Defined in jsfun.cpp. */
601 JS_DECLARE_CALLINFO(js_AllocFlatClosure)
602 JS_DECLARE_CALLINFO(js_PutArguments)
603 JS_DECLARE_CALLINFO(js_PutCallObjectOnTrace)
604 JS_DECLARE_CALLINFO(js_SetCallVar)
605 JS_DECLARE_CALLINFO(js_SetCallArg)
606 JS_DECLARE_CALLINFO(js_CloneFunctionObject)
607 JS_DECLARE_CALLINFO(js_CreateCallObjectOnTrace)
608 JS_DECLARE_CALLINFO(js_Arguments)
610 /* Defined in jsnum.cpp. */
611 JS_DECLARE_CALLINFO(js_NumberToString)
613 /* Defined in jsobj.cpp. */
614 JS_DECLARE_CALLINFO(js_Object_tn)
615 JS_DECLARE_CALLINFO(js_NewInstance)
616 JS_DECLARE_CALLINFO(js_NonEmptyObject)
618 /* Defined in jsregexp.cpp. */
619 JS_DECLARE_CALLINFO(js_CloneRegExpObject)
621 /* Defined in jsstr.cpp. */
622 JS_DECLARE_CALLINFO(js_String_tn)
623 JS_DECLARE_CALLINFO(js_CompareStrings)
624 JS_DECLARE_CALLINFO(js_ConcatStrings)
625 JS_DECLARE_CALLINFO(js_EqualStrings)
626 JS_DECLARE_CALLINFO(js_Flatten)
628 /* Defined in jstypedarray.cpp. */
629 JS_DECLARE_CALLINFO(js_TypedArray_uint8_clamp_double)
631 #endif /* jsbuiltins_h___ */