1 |
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
2 |
* vim: set ts=8 sw=4 et tw=0 ft=C: |
3 |
* |
4 |
* ***** BEGIN LICENSE BLOCK ***** |
5 |
* Version: MPL 1.1/GPL 2.0/LGPL 2.1 |
6 |
* |
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/ |
11 |
* |
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. |
16 |
* |
17 |
* The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released |
18 |
* June 22, 2008. |
19 |
* |
20 |
* The Initial Developer of the Original Code is |
21 |
* Andreas Gal <gal@uci.edu> |
22 |
* |
23 |
* Contributor(s): |
24 |
* |
25 |
* Alternatively, the contents of this file may be used under the terms of |
26 |
* either of the GNU General Public License Version 2 or later (the "GPL"), |
27 |
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), |
28 |
* in which case the provisions of the GPL or the LGPL are applicable instead |
29 |
* of those above. If you wish to allow use of your version of this file only |
30 |
* under the terms of either the GPL or the LGPL, and not to allow others to |
31 |
* use your version of this file under the terms of the MPL, indicate your |
32 |
* decision by deleting the provisions above and replace them with the notice |
33 |
* and other provisions required by the GPL or the LGPL. If you do not delete |
34 |
* the provisions above, a recipient may use your version of this file under |
35 |
* the terms of any one of the MPL, the GPL or the LGPL. |
36 |
* |
37 |
* ***** END LICENSE BLOCK ***** */ |
38 |
|
39 |
/** |
40 |
* This file declares the various builtins we recognize, and is |
41 |
* included in various places in interesting ways. Each line starts |
42 |
* with "BUILTIN" then an integer indicating the number of arguments |
43 |
* the builtin takes. Builtins with no arguments are not supported at |
44 |
* the moment. |
45 |
* |
46 |
* This is followed, in parentheses, by the following things, in order: |
47 |
* - A name for the builtin. Prefixed with "F_" this is the opcode name to |
48 |
* pass to insCall. Prefixed with "js_" this is the name of the actual |
49 |
* native method to call. |
50 |
* - The sizes of the arguments to the native, in order. These can be "LO" for |
51 |
* integers (any size), pointers, or jsvals and "F" for doubles. |
52 |
* - The size of the return value. This can be "LO" for 32-bit integers, "P" |
53 |
* for pointers or jsvals, "F" for doubles, "Q" for 64-bit integers. |
54 |
* - The actual C++ type of the return value |
55 |
* - The C++ types of the arguments, in order |
56 |
* - A boolean value (0 = false, 1 = true) indicating whether the builtin call |
57 |
* can be optimized away during common subexpression elimination. This |
58 |
* should only be true if the the builtin is idempotent and the return value |
59 |
* is uniquely determined by the values of the arguments. |
60 |
* - A boolean value (0 = false, 1 = true) indicating whether the builtin call |
61 |
* can be optimized away during constant folding. This should only be true |
62 |
* if the builtin is idempotent and if the return value can be determined at |
63 |
* compile time if the input values are known at compile time. |
64 |
*/ |
65 |
|
66 |
/* |
67 |
* NB: bool FASTCALL is not compatible with Nanojit's calling convention usage. |
68 |
* Do not use bool FASTCALL, use JSBool only! |
69 |
*/ |
70 |
|
71 |
BUILTIN2(BoxDouble, LO, F, P, jsval, JSContext*, jsdouble, 1, 1) |
72 |
BUILTIN2(BoxInt32, LO, LO, P, jsval, JSContext*, jsint, 1, 1) |
73 |
BUILTIN1(UnboxDouble, LO, F, jsdouble, jsval, 1, 1) |
74 |
BUILTIN1(UnboxInt32, LO, LO, int32, jsval, 1, 1) |
75 |
BUILTIN2(dmod, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
76 |
BUILTIN2(imod, LO, LO, LO, jsint, jsint, jsint, 1, 1) |
77 |
BUILTIN1(DoubleToInt32, F, LO, int32, jsdouble, 1, 1) |
78 |
BUILTIN1(DoubleToUint32, F, LO, int32, jsdouble, 1, 1) |
79 |
BUILTIN1(Math_sin, F, F, jsdouble, jsdouble, 1, 1) |
80 |
BUILTIN1(Math_cos, F, F, jsdouble, jsdouble, 1, 1) |
81 |
BUILTIN2(Math_pow, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
82 |
BUILTIN1(Math_sqrt, F, F, jsdouble, jsdouble, 1, 1) |
83 |
BUILTIN1(Math_floor, F, F, jsdouble, jsdouble, 1, 1) |
84 |
BUILTIN1(Math_ceil, F, F, jsdouble, jsdouble, 1, 1) |
85 |
BUILTIN1(Math_log, F, F, jsdouble, jsdouble, 1, 1) |
86 |
BUILTIN2(Math_max, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
87 |
BUILTIN4(Array_dense_setelem, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, jsint, jsval, 0, 0) |
88 |
BUILTIN3(Array_p_join, LO, LO, LO, P, JSString*, JSContext*, JSObject*, JSString*, 0, 0) |
89 |
BUILTIN4(String_p_substring, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, jsint, 1, 1) |
90 |
BUILTIN3(String_p_substring_1, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1) |
91 |
BUILTIN3(ConcatStrings, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, 1, 1) |
92 |
BUILTIN3(String_getelem, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1) |
93 |
BUILTIN2(String_fromCharCode, LO, LO, P, JSString*, JSContext*, jsint, 1, 1) |
94 |
BUILTIN2(String_p_charCodeAt, LO, LO, LO, jsint, JSString*, jsint, 1, 1) |
95 |
BUILTIN3(String_p_concat_1int, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1) |
96 |
BUILTIN4(String_p_concat_2str, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, 1, 1) |
97 |
BUILTIN5(String_p_concat_3str, LO, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, JSString*, 1, 1) |
98 |
BUILTIN4(String_p_match, LO, LO, LO, LO, P, JSObject*, JSContext*, JSString*, jsbytecode*, JSObject*, 1, 1) |
99 |
BUILTIN4(String_p_match_obj, LO, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, jsbytecode*, JSObject*, 1, 1) |
100 |
BUILTIN4(String_p_replace_str, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSObject*, JSString*, 1, 1) |
101 |
BUILTIN4(String_p_replace_str2, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, 1, 1) |
102 |
BUILTIN5(String_p_replace_str3, LO, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, JSString*, 1, 1) |
103 |
BUILTIN3(String_p_split, LO, LO, LO, P, JSObject*, JSContext*, JSString*, JSString*, 0, 0) |
104 |
BUILTIN2(toLowerCase, LO, LO, P, JSString*, JSContext*, JSString*, 1, 1) |
105 |
BUILTIN2(toUpperCase, LO, LO, P, JSString*, JSContext*, JSString*, 1, 1) |
106 |
BUILTIN1(Math_random, LO, F, jsdouble, JSRuntime*, 0, 0) |
107 |
BUILTIN2(EqualStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1) |
108 |
BUILTIN2(CompareStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1) |
109 |
BUILTIN2(StringToNumber, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1) |
110 |
BUILTIN2(StringToInt32, LO, LO, LO, jsint, JSContext*, JSString*, 1, 1) |
111 |
BUILTIN2(ParseInt, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1) |
112 |
BUILTIN1(ParseIntDouble, F, F, jsdouble, jsdouble, 1, 1) |
113 |
BUILTIN2(ParseFloat, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1) |
114 |
BUILTIN3(Any_getprop, LO, LO, LO, P, jsval, JSContext*, JSObject*, JSString*, 0, 0) |
115 |
BUILTIN4(Any_setprop, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSString*, jsval, 0, 0) |
116 |
BUILTIN3(Any_getelem, LO, LO, LO, P, jsval, JSContext*, JSObject*, jsuint, 0, 0) |
117 |
BUILTIN4(Any_setelem, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, jsuint, jsval, 0, 0) |
118 |
BUILTIN3(FastValueToIterator, LO, LO, LO, P, JSObject*, JSContext*, jsuint, jsval, 0, 0) |
119 |
BUILTIN2(FastCallIteratorNext, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0) |
120 |
BUILTIN2(CloseIterator, LO, LO, LO, bool, JSContext*, jsval, 0, 0) |
121 |
BUILTIN2(CallTree, LO, LO, P, nanojit::GuardRecord*, avmplus::InterpState*, nanojit::Fragment*, 0, 0) |
122 |
BUILTIN2(FastNewArray, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0) |
123 |
BUILTIN2(FastNewObject, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0) |
124 |
BUILTIN3(AddProperty, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSScopeProperty*, 0, 0) |
125 |
BUILTIN3(HasNamedProperty, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSString*, 0, 0) |
126 |
BUILTIN3(CallGetter, LO, LO, LO, P, jsval, JSContext*, JSObject*, JSScopeProperty*, 0, 0) |
127 |
BUILTIN2(TypeOfObject, LO, LO, P, JSString*, JSContext*, JSObject*, 1, 1) |
128 |
BUILTIN2(TypeOfBoolean, LO, LO, P, JSString*, JSContext*, jsint, 1, 1) |
129 |
BUILTIN2(NumberToString, LO, F, P, JSString*, JSContext*, jsdouble, 1, 1) |
130 |
BUILTIN3(Object_p_hasOwnProperty, |
131 |
LO, LO, LO, LO, jsint, JSContext*, JSObject*, JSString*, 0, 0) |
132 |
BUILTIN3(Object_p_propertyIsEnumerable, |
133 |
LO, LO, LO, LO, jsint, JSContext*, JSObject*, JSString*, 0, 0) |
134 |
BUILTIN2(BooleanToNumber, LO, LO, F, jsdouble, JSContext*, jsint, 1, 1) |
135 |
BUILTIN2(ObjectToString, LO, LO, P, JSString*, JSContext*, JSObject*, 0, 0) |
136 |
BUILTIN3(Array_1int, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, jsint, 0, 0) |
137 |
BUILTIN3(Array_1str, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, JSString*, 0, 0) |
138 |
BUILTIN4(Array_2obj, LO, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, JSObject*, JSObject**, 0, 0) |
139 |
BUILTIN5(Array_3num, LO, LO, F, F, F, P, JSObject*, JSContext*, JSObject*, jsdouble, jsdouble, jsdouble, 0, 0) |
140 |
BUILTIN1(Arguments, LO, P, JSObject*, JSContext*, 0, 0) |
141 |
|
142 |
// Don't really need an argument here, but we don't support arg-less builtins |
143 |
BUILTIN1(Date_now, LO, F, jsdouble, JSContext*, 0, 0) |
144 |
|
145 |
// soft float |
146 |
BUILTIN1(fneg, F, F, jsdouble, jsdouble, 1, 1) |
147 |
BUILTIN1(i2f, LO, F, jsdouble, jsint, 1, 1) |
148 |
BUILTIN1(u2f, LO, F, jsdouble, jsuint, 1, 1) |
149 |
BUILTIN2(fcmpeq, F, F, LO, jsint, jsdouble, jsdouble, 1, 1) |
150 |
BUILTIN2(fcmplt, F, F, LO, jsint, jsdouble, jsdouble, 1, 1) |
151 |
BUILTIN2(fcmple, F, F, LO, jsint, jsdouble, jsdouble, 1, 1) |
152 |
BUILTIN2(fcmpgt, F, F, LO, jsint, jsdouble, jsdouble, 1, 1) |
153 |
BUILTIN2(fcmpge, F, F, LO, jsint, jsdouble, jsdouble, 1, 1) |
154 |
BUILTIN2(fmul, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
155 |
BUILTIN2(fadd, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
156 |
BUILTIN2(fdiv, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |
157 |
BUILTIN2(fsub, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1) |