mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
157 lines
10 KiB
C
157 lines
10 KiB
C
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
|
* vim: set ts=8 sw=4 et tw=0 ft=C:
|
|
*
|
|
* ***** 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
|
|
* June 22, 2008.
|
|
*
|
|
* The Initial Developer of the Original Code is
|
|
* Andreas Gal <gal@uci.edu>
|
|
*
|
|
* Contributor(s):
|
|
*
|
|
* 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 ***** */
|
|
|
|
/**
|
|
* This file declares the various builtins we recognize, and is
|
|
* included in various places in interesting ways. Each line starts
|
|
* with "BUILTIN" then an integer indicating the number of arguments
|
|
* the builtin takes. Builtins with no arguments are not supported at
|
|
* the moment.
|
|
*
|
|
* This is followed, in parentheses, by the following things, in order:
|
|
* - A name for the builtin. Prefixed with "F_" this is the opcode name to
|
|
* pass to insCall. Prefixed with "js_" this is the name of the actual
|
|
* native method to call.
|
|
* - The sizes of the arguments to the native, in order. These can be "LO" for
|
|
* integers (any size), pointers, or jsvals and "F" for doubles.
|
|
* - The size of the return value. This can be "LO" for 32-bit integers, "P"
|
|
* for pointers or jsvals, "F" for doubles, "Q" for 64-bit integers.
|
|
* - The actual C++ type of the return value
|
|
* - The C++ types of the arguments, in order
|
|
* - A boolean value (0 = false, 1 = true) indicating whether the builtin call
|
|
* can be optimized away during common subexpression elimination. This
|
|
* should only be true if the the builtin is idempotent and the return value
|
|
* is uniquely determined by the values of the arguments.
|
|
* - A boolean value (0 = false, 1 = true) indicating whether the builtin call
|
|
* can be optimized away during constant folding. This should only be true
|
|
* if the builtin is idempotent and if the return value can be determined at
|
|
* compile time if the input values are known at compile time.
|
|
*/
|
|
|
|
/*
|
|
* NB: bool FASTCALL is not compatible with Nanojit's calling convention usage.
|
|
* Do not use bool FASTCALL, use JSBool only!
|
|
*/
|
|
|
|
BUILTIN2(BoxDouble, LO, F, P, jsval, JSContext*, jsdouble, 1, 1)
|
|
BUILTIN2(BoxInt32, LO, LO, P, jsval, JSContext*, jsint, 1, 1)
|
|
BUILTIN1(UnboxDouble, LO, F, jsdouble, jsval, 1, 1)
|
|
BUILTIN1(UnboxInt32, LO, LO, int32, jsval, 1, 1)
|
|
BUILTIN2(dmod, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(DoubleToInt32, F, LO, int32, jsdouble, 1, 1)
|
|
BUILTIN1(DoubleToUint32, F, LO, int32, jsdouble, 1, 1)
|
|
BUILTIN1(Math_sin, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(Math_cos, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(Math_pow, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(Math_sqrt, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(Math_floor, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(Math_ceil, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(Math_log, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(Math_max, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN4(Array_dense_setelem, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, jsint, jsval, 0, 0)
|
|
BUILTIN3(Array_p_join, LO, LO, LO, P, JSString*, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN4(String_p_substring, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, jsint, 1, 1)
|
|
BUILTIN3(String_p_substring_1, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1)
|
|
BUILTIN3(ConcatStrings, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, 1, 1)
|
|
BUILTIN3(String_getelem, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1)
|
|
BUILTIN2(String_fromCharCode, LO, LO, P, JSString*, JSContext*, jsint, 1, 1)
|
|
BUILTIN2(String_p_charCodeAt, LO, LO, LO, jsint, JSString*, jsint, 1, 1)
|
|
BUILTIN3(String_p_concat_1int, LO, LO, LO, P, JSString*, JSContext*, JSString*, jsint, 1, 1)
|
|
BUILTIN4(String_p_concat_2str, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, 1, 1)
|
|
BUILTIN5(String_p_concat_3str, LO, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, JSString*, 1, 1)
|
|
BUILTIN4(String_p_match, LO, LO, LO, LO, P, JSObject*, JSContext*, JSString*, jsbytecode*, JSObject*, 1, 1)
|
|
BUILTIN4(String_p_match_obj, LO, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, jsbytecode*, JSObject*, 1, 1)
|
|
BUILTIN4(String_p_replace_str, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSObject*, JSString*, 1, 1)
|
|
BUILTIN4(String_p_replace_str2, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, 1, 1)
|
|
BUILTIN5(String_p_replace_str3, LO, LO, LO, LO, LO, P, JSString*, JSContext*, JSString*, JSString*, JSString*, JSString*, 1, 1)
|
|
BUILTIN3(String_p_split, LO, LO, LO, P, JSObject*, JSContext*, JSString*, JSString*, 0, 0)
|
|
BUILTIN2(toLowerCase, LO, LO, P, JSString*, JSContext*, JSString*, 1, 1)
|
|
BUILTIN2(toUpperCase, LO, LO, P, JSString*, JSContext*, JSString*, 1, 1)
|
|
BUILTIN1(Math_random, LO, F, jsdouble, JSRuntime*, 0, 0)
|
|
BUILTIN2(EqualStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1)
|
|
BUILTIN2(CompareStrings, LO, LO, LO, bool, JSString*, JSString*, 1, 1)
|
|
BUILTIN2(StringToNumber, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1)
|
|
BUILTIN2(StringToInt32, LO, LO, LO, jsint, JSContext*, JSString*, 1, 1)
|
|
BUILTIN2(ParseInt, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1)
|
|
BUILTIN1(ParseIntDouble, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(ParseFloat, LO, LO, F, jsdouble, JSContext*, JSString*, 1, 1)
|
|
BUILTIN3(Any_getprop, LO, LO, LO, P, jsval, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN4(Any_setprop, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSString*, jsval, 0, 0)
|
|
BUILTIN3(Any_getelem, LO, LO, F, P, jsval, JSContext*, JSObject*, jsdouble, 0, 0)
|
|
BUILTIN4(Any_setelem, LO, LO, F, LO, LO, bool, JSContext*, JSObject*, jsdouble, jsval, 0, 0)
|
|
BUILTIN3(Any_getelem_int, LO, LO, LO, P, jsval, JSContext*, JSObject*, jsuint, 0, 0)
|
|
BUILTIN4(Any_setelem_int, LO, LO, LO, LO, LO, bool, JSContext*, JSObject*, jsuint, jsval, 0, 0)
|
|
BUILTIN3(FastValueToIterator, LO, LO, LO, P, JSObject*, JSContext*, jsuint, jsval, 0, 0)
|
|
BUILTIN2(FastCallIteratorNext, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0)
|
|
BUILTIN2(CloseIterator, LO, LO, LO, bool, JSContext*, jsval, 0, 0)
|
|
BUILTIN2(CallTree, LO, LO, P, nanojit::GuardRecord*, avmplus::InterpState*, nanojit::Fragment*, 0, 0)
|
|
BUILTIN2(FastNewArray, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0)
|
|
BUILTIN2(FastNewObject, LO, LO, P, JSObject*, JSContext*, JSObject*, 0, 0)
|
|
BUILTIN3(AddProperty, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSScopeProperty*, 0, 0)
|
|
BUILTIN3(HasNamedProperty, LO, LO, LO, LO, bool, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN3(CallGetter, LO, LO, LO, P, jsval, JSContext*, JSObject*, JSScopeProperty*, 0, 0)
|
|
BUILTIN2(TypeOfObject, LO, LO, P, JSString*, JSContext*, JSObject*, 1, 1)
|
|
BUILTIN2(TypeOfBoolean, LO, LO, P, JSString*, JSContext*, jsint, 1, 1)
|
|
BUILTIN2(NumberToString, LO, F, P, JSString*, JSContext*, jsdouble, 1, 1)
|
|
BUILTIN3(Object_p_hasOwnProperty,
|
|
LO, LO, LO, LO, jsint, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN3(Object_p_propertyIsEnumerable,
|
|
LO, LO, LO, LO, jsint, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN2(BooleanToNumber, LO, LO, F, jsdouble, JSContext*, jsint, 1, 1)
|
|
BUILTIN2(ObjectToString, LO, LO, P, JSString*, JSContext*, JSObject*, 0, 0)
|
|
BUILTIN3(Array_1int, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, jsint, 0, 0)
|
|
BUILTIN3(Array_1str, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, JSString*, 0, 0)
|
|
BUILTIN4(Array_2obj, LO, LO, LO, LO, P, JSObject*, JSContext*, JSObject*, JSObject*, JSObject**, 0, 0)
|
|
BUILTIN5(Array_3num, LO, LO, F, F, F, P, JSObject*, JSContext*, JSObject*, jsdouble, jsdouble, jsdouble, 0, 0)
|
|
BUILTIN1(Arguments, LO, P, JSObject*, JSContext*, 0, 0)
|
|
BUILTIN2(imod, LO, LO, LO, jsint, jsint, jsint, 1, 1)
|
|
|
|
// soft float
|
|
BUILTIN1(fneg, F, F, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN1(i2f, LO, F, jsdouble, jsint, 1, 1)
|
|
BUILTIN1(u2f, LO, F, jsdouble, jsuint, 1, 1)
|
|
BUILTIN2(fcmpeq, F, F, LO, jsint, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fcmplt, F, F, LO, jsint, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fcmple, F, F, LO, jsint, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fcmpgt, F, F, LO, jsint, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fcmpge, F, F, LO, jsint, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fmul, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fadd, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fdiv, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|
|
BUILTIN2(fsub, F, F, F, jsdouble, jsdouble, jsdouble, 1, 1)
|