ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_RUNTIME_H_ |
| 29 | #define V8_RUNTIME_H_ |
| 30 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 32 | #include "zone.h" |
| 33 | |
kasperl@chromium.org | 71affb5 | 2009-05-26 05:44:31 +0000 | [diff] [blame] | 34 | namespace v8 { |
| 35 | namespace internal { |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 36 | |
| 37 | // The interface to C++ runtime functions. |
| 38 | |
| 39 | // ---------------------------------------------------------------------------- |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 40 | // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both |
| 41 | // release and debug mode. |
| 42 | // This macro should only be used by the macro RUNTIME_FUNCTION_LIST. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 43 | |
ager@chromium.org | ce58e17 | 2009-05-13 07:11:48 +0000 | [diff] [blame] | 44 | // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused |
| 45 | // MSVC Intellisense to crash. It was broken into two macros to work around |
| 46 | // this problem. Please avoid large recursive macros whenever possible. |
| 47 | #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 48 | /* Property access */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 49 | F(GetProperty, 2, 1) \ |
| 50 | F(KeyedGetProperty, 2, 1) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 51 | F(DeleteProperty, 3, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 52 | F(HasLocalProperty, 2, 1) \ |
| 53 | F(HasProperty, 2, 1) \ |
| 54 | F(HasElement, 2, 1) \ |
| 55 | F(IsPropertyEnumerable, 2, 1) \ |
| 56 | F(GetPropertyNames, 1, 1) \ |
| 57 | F(GetPropertyNamesFast, 1, 1) \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 58 | F(GetLocalPropertyNames, 1, 1) \ |
| 59 | F(GetLocalElementNames, 1, 1) \ |
| 60 | F(GetInterceptorInfo, 1, 1) \ |
| 61 | F(GetNamedInterceptorPropertyNames, 1, 1) \ |
| 62 | F(GetIndexedInterceptorElementNames, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 63 | F(GetArgumentsProperty, 1, 1) \ |
| 64 | F(ToFastProperties, 1, 1) \ |
| 65 | F(ToSlowProperties, 1, 1) \ |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 66 | F(FinishArrayPrototypeSetup, 1, 1) \ |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 67 | F(SpecialArrayFunctions, 1, 1) \ |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 68 | F(GetGlobalReceiver, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 69 | \ |
erik.corry@gmail.com | d6076d9 | 2011-06-06 09:39:18 +0000 | [diff] [blame] | 70 | F(GetPrototype, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 71 | F(IsInPrototypeChain, 2, 1) \ |
| 72 | F(SetHiddenPrototype, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 73 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 74 | F(IsConstructCall, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 75 | \ |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 76 | F(GetOwnProperty, 2, 1) \ |
| 77 | \ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 78 | F(IsExtensible, 1, 1) \ |
kmillikin@chromium.org | 69ea396 | 2010-07-05 11:01:40 +0000 | [diff] [blame] | 79 | F(PreventExtensions, 1, 1)\ |
sgjesse@chromium.org | b302e56 | 2010-02-03 11:26:59 +0000 | [diff] [blame] | 80 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 81 | /* Utilities */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 82 | F(GetFunctionDelegate, 1, 1) \ |
| 83 | F(GetConstructorDelegate, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 84 | F(NewArgumentsFast, 3, 1) \ |
| 85 | F(LazyCompile, 1, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 86 | F(LazyRecompile, 1, 1) \ |
| 87 | F(NotifyDeoptimized, 1, 1) \ |
| 88 | F(NotifyOSR, 0, 1) \ |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 89 | F(DeoptimizeFunction, 1, 1) \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame^] | 90 | F(RunningInSimulator, 0, 1) \ |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 91 | F(OptimizeFunctionOnNextCall, 1, 1) \ |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 92 | F(GetOptimizationStatus, 1, 1) \ |
| 93 | F(GetOptimizationCount, 1, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 94 | F(CompileForOnStackReplacement, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 95 | F(SetNewFunctionAttributes, 1, 1) \ |
lrn@chromium.org | c4e51ac | 2010-08-09 09:47:21 +0000 | [diff] [blame] | 96 | F(AllocateInNewSpace, 1, 1) \ |
ricow@chromium.org | d2be901 | 2011-06-01 06:00:58 +0000 | [diff] [blame] | 97 | F(SetNativeFlag, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 98 | \ |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 99 | /* Array join support */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 100 | F(PushIfAbsent, 2, 1) \ |
| 101 | F(ArrayConcat, 1, 1) \ |
ager@chromium.org | 9258b6b | 2008-09-11 09:11:10 +0000 | [diff] [blame] | 102 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 103 | /* Conversions */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 104 | F(ToBool, 1, 1) \ |
| 105 | F(Typeof, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 106 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 107 | F(StringToNumber, 1, 1) \ |
| 108 | F(StringFromCharCodeArray, 1, 1) \ |
| 109 | F(StringParseInt, 2, 1) \ |
| 110 | F(StringParseFloat, 1, 1) \ |
| 111 | F(StringToLowerCase, 1, 1) \ |
| 112 | F(StringToUpperCase, 1, 1) \ |
fschneider@chromium.org | 086aac6 | 2010-03-17 13:18:24 +0000 | [diff] [blame] | 113 | F(StringSplit, 3, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 114 | F(CharFromCode, 1, 1) \ |
| 115 | F(URIEscape, 1, 1) \ |
| 116 | F(URIUnescape, 1, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 117 | F(QuoteJSONString, 1, 1) \ |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 118 | F(QuoteJSONStringComma, 1, 1) \ |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame] | 119 | F(QuoteJSONStringArray, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 120 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 121 | F(NumberToString, 1, 1) \ |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 122 | F(NumberToStringSkipCache, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 123 | F(NumberToInteger, 1, 1) \ |
ricow@chromium.org | 30ce411 | 2010-05-31 10:38:25 +0000 | [diff] [blame] | 124 | F(NumberToIntegerMapMinusZero, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 125 | F(NumberToJSUint32, 1, 1) \ |
| 126 | F(NumberToJSInt32, 1, 1) \ |
| 127 | F(NumberToSmi, 1, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 128 | F(AllocateHeapNumber, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 129 | \ |
| 130 | /* Arithmetic operations */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 131 | F(NumberAdd, 2, 1) \ |
| 132 | F(NumberSub, 2, 1) \ |
| 133 | F(NumberMul, 2, 1) \ |
| 134 | F(NumberDiv, 2, 1) \ |
| 135 | F(NumberMod, 2, 1) \ |
| 136 | F(NumberUnaryMinus, 1, 1) \ |
ager@chromium.org | 6a2b0aa | 2010-07-13 20:58:03 +0000 | [diff] [blame] | 137 | F(NumberAlloc, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 138 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 139 | F(StringAdd, 2, 1) \ |
fschneider@chromium.org | 0c20e67 | 2010-01-14 15:28:53 +0000 | [diff] [blame] | 140 | F(StringBuilderConcat, 3, 1) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 141 | F(StringBuilderJoin, 3, 1) \ |
sgjesse@chromium.org | 8e8294a | 2011-05-02 14:30:53 +0000 | [diff] [blame] | 142 | F(SparseJoinWithSeparator, 3, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 143 | \ |
| 144 | /* Bit operations */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 145 | F(NumberOr, 2, 1) \ |
| 146 | F(NumberAnd, 2, 1) \ |
| 147 | F(NumberXor, 2, 1) \ |
| 148 | F(NumberNot, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 149 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 150 | F(NumberShl, 2, 1) \ |
| 151 | F(NumberShr, 2, 1) \ |
| 152 | F(NumberSar, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 153 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 154 | /* Comparisons */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 155 | F(NumberEquals, 2, 1) \ |
| 156 | F(StringEquals, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 157 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 158 | F(NumberCompare, 3, 1) \ |
| 159 | F(SmiLexicographicCompare, 2, 1) \ |
| 160 | F(StringCompare, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 161 | \ |
| 162 | /* Math */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 163 | F(Math_acos, 1, 1) \ |
| 164 | F(Math_asin, 1, 1) \ |
| 165 | F(Math_atan, 1, 1) \ |
| 166 | F(Math_atan2, 2, 1) \ |
| 167 | F(Math_ceil, 1, 1) \ |
| 168 | F(Math_cos, 1, 1) \ |
| 169 | F(Math_exp, 1, 1) \ |
| 170 | F(Math_floor, 1, 1) \ |
| 171 | F(Math_log, 1, 1) \ |
| 172 | F(Math_pow, 2, 1) \ |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 173 | F(Math_pow_cfunction, 2, 1) \ |
whesse@chromium.org | cec079d | 2010-03-22 14:44:04 +0000 | [diff] [blame] | 174 | F(RoundNumber, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 175 | F(Math_sin, 1, 1) \ |
| 176 | F(Math_sqrt, 1, 1) \ |
| 177 | F(Math_tan, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 178 | \ |
| 179 | /* Regular expressions */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 180 | F(RegExpCompile, 3, 1) \ |
| 181 | F(RegExpExec, 4, 1) \ |
lrn@chromium.org | 25156de | 2010-04-06 13:10:27 +0000 | [diff] [blame] | 182 | F(RegExpExecMultiple, 4, 1) \ |
| 183 | F(RegExpInitializeObject, 5, 1) \ |
whesse@chromium.org | b6e43bb | 2010-04-14 09:36:28 +0000 | [diff] [blame] | 184 | F(RegExpConstructResult, 3, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 185 | \ |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 186 | /* JSON */ \ |
| 187 | F(ParseJson, 1, 1) \ |
| 188 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 189 | /* Strings */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 190 | F(StringCharCodeAt, 2, 1) \ |
| 191 | F(StringIndexOf, 3, 1) \ |
| 192 | F(StringLastIndexOf, 3, 1) \ |
| 193 | F(StringLocaleCompare, 2, 1) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 194 | F(SubString, 3, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 195 | F(StringReplaceRegExpWithString, 4, 1) \ |
| 196 | F(StringMatch, 3, 1) \ |
christian.plesner.hansen@gmail.com | 9d58c2b | 2009-10-16 11:48:38 +0000 | [diff] [blame] | 197 | F(StringTrim, 3, 1) \ |
ager@chromium.org | beb2571 | 2010-11-29 08:02:25 +0000 | [diff] [blame] | 198 | F(StringToArray, 2, 1) \ |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 199 | F(NewStringWrapper, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 200 | \ |
| 201 | /* Numbers */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 202 | F(NumberToRadixString, 2, 1) \ |
| 203 | F(NumberToFixed, 2, 1) \ |
| 204 | F(NumberToExponential, 2, 1) \ |
| 205 | F(NumberToPrecision, 2, 1) |
ager@chromium.org | ce58e17 | 2009-05-13 07:11:48 +0000 | [diff] [blame] | 206 | |
| 207 | #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 208 | /* Reflection */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 209 | F(FunctionSetInstanceClassName, 2, 1) \ |
| 210 | F(FunctionSetLength, 2, 1) \ |
| 211 | F(FunctionSetPrototype, 2, 1) \ |
| 212 | F(FunctionGetName, 1, 1) \ |
| 213 | F(FunctionSetName, 2, 1) \ |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 214 | F(FunctionRemovePrototype, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 215 | F(FunctionGetSourceCode, 1, 1) \ |
| 216 | F(FunctionGetScript, 1, 1) \ |
| 217 | F(FunctionGetScriptSourcePosition, 1, 1) \ |
| 218 | F(FunctionGetPositionForOffset, 2, 1) \ |
| 219 | F(FunctionIsAPIFunction, 1, 1) \ |
christian.plesner.hansen@gmail.com | 2bc58ef | 2009-09-22 10:00:30 +0000 | [diff] [blame] | 220 | F(FunctionIsBuiltin, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 221 | F(GetScript, 1, 1) \ |
| 222 | F(CollectStackTrace, 2, 1) \ |
ager@chromium.org | 3811b43 | 2009-10-28 14:53:37 +0000 | [diff] [blame] | 223 | F(GetV8Version, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 224 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 225 | F(ClassOf, 1, 1) \ |
| 226 | F(SetCode, 2, 1) \ |
ricow@chromium.org | d236f4d | 2010-09-01 06:52:08 +0000 | [diff] [blame] | 227 | F(SetExpectedNumberOfProperties, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 228 | \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 229 | F(CreateApiFunction, 1, 1) \ |
| 230 | F(IsTemplate, 1, 1) \ |
| 231 | F(GetTemplateField, 2, 1) \ |
| 232 | F(DisableAccessChecks, 1, 1) \ |
| 233 | F(EnableAccessChecks, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 234 | \ |
| 235 | /* Dates */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 236 | F(DateCurrentTime, 0, 1) \ |
| 237 | F(DateParseString, 2, 1) \ |
| 238 | F(DateLocalTimezone, 1, 1) \ |
| 239 | F(DateLocalTimeOffset, 0, 1) \ |
| 240 | F(DateDaylightSavingsOffset, 1, 1) \ |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 241 | F(DateMakeDay, 3, 1) \ |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 242 | F(DateYMDFromTime, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 243 | \ |
| 244 | /* Numbers */ \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 245 | \ |
| 246 | /* Globals */ \ |
fschneider@chromium.org | e03fb64 | 2010-11-01 12:34:09 +0000 | [diff] [blame] | 247 | F(CompileString, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 248 | F(GlobalPrint, 1, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 249 | \ |
| 250 | /* Eval */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 251 | F(GlobalReceiver, 1, 1) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 252 | F(ResolvePossiblyDirectEval, 4, 2) \ |
| 253 | F(ResolvePossiblyDirectEvalNoLookup, 4, 2) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 254 | \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 255 | F(SetProperty, -1 /* 4 or 5 */, 1) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 256 | F(DefineOrRedefineDataProperty, 4, 1) \ |
| 257 | F(DefineOrRedefineAccessorProperty, 5, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 258 | F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 259 | \ |
| 260 | /* Arrays */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 261 | F(RemoveArrayHoles, 2, 1) \ |
| 262 | F(GetArrayKeys, 2, 1) \ |
| 263 | F(MoveArrayContents, 2, 1) \ |
| 264 | F(EstimateNumberOfElements, 1, 1) \ |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 265 | F(SwapElements, 3, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 266 | \ |
| 267 | /* Getters and Setters */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 268 | F(DefineAccessor, -1 /* 4 or 5 */, 1) \ |
| 269 | F(LookupAccessor, 3, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 270 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 271 | /* Literals */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 272 | F(MaterializeRegExpLiteral, 4, 1)\ |
| 273 | F(CreateArrayLiteralBoilerplate, 3, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 274 | F(CloneLiteralBoilerplate, 1, 1) \ |
| 275 | F(CloneShallowLiteralBoilerplate, 1, 1) \ |
vegorov@chromium.org | f837290 | 2010-03-15 10:26:20 +0000 | [diff] [blame] | 276 | F(CreateObjectLiteral, 4, 1) \ |
| 277 | F(CreateObjectLiteralShallow, 4, 1) \ |
kmillikin@chromium.org | 13bd294 | 2009-12-16 15:36:05 +0000 | [diff] [blame] | 278 | F(CreateArrayLiteral, 3, 1) \ |
| 279 | F(CreateArrayLiteralShallow, 3, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 280 | \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 281 | /* Harmony proxies */ \ |
| 282 | F(CreateJSProxy, 2, 1) \ |
erik.corry@gmail.com | d6076d9 | 2011-06-06 09:39:18 +0000 | [diff] [blame] | 283 | F(IsJSProxy, 1, 1) \ |
| 284 | F(GetHandler, 1, 1) \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 285 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 286 | /* Statements */ \ |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 287 | F(NewClosure, 3, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 288 | F(NewObject, 1, 1) \ |
whesse@chromium.org | ba5a61b | 2010-07-26 11:44:40 +0000 | [diff] [blame] | 289 | F(NewObjectFromBound, 2, 1) \ |
whesse@chromium.org | 4a1fe7d | 2010-09-27 12:32:04 +0000 | [diff] [blame] | 290 | F(FinalizeInstanceSize, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 291 | F(Throw, 1, 1) \ |
| 292 | F(ReThrow, 1, 1) \ |
| 293 | F(ThrowReferenceError, 1, 1) \ |
whesse@chromium.org | 4a5224e | 2010-10-20 12:37:07 +0000 | [diff] [blame] | 294 | F(StackGuard, 0, 1) \ |
ager@chromium.org | c4c9272 | 2009-11-18 14:12:51 +0000 | [diff] [blame] | 295 | F(PromoteScheduledException, 0, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 296 | \ |
| 297 | /* Contexts */ \ |
svenpanne@chromium.org | 6d786c9 | 2011-06-15 10:58:27 +0000 | [diff] [blame^] | 298 | F(NewFunctionContext, 1, 1) \ |
| 299 | F(PushWithContext, 1, 1) \ |
| 300 | F(PushCatchContext, 2, 1) \ |
ager@chromium.org | 0ee099b | 2011-01-25 14:06:47 +0000 | [diff] [blame] | 301 | F(DeleteContextSlot, 2, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 302 | F(LoadContextSlot, 2, 2) \ |
| 303 | F(LoadContextSlotNoReferenceError, 2, 2) \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 304 | F(StoreContextSlot, 4, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 305 | \ |
| 306 | /* Declarations and initialization */ \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 307 | F(DeclareGlobals, 4, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 308 | F(DeclareContextSlot, 4, 1) \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 309 | F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 310 | F(InitializeConstGlobal, 2, 1) \ |
| 311 | F(InitializeConstContextSlot, 3, 1) \ |
| 312 | F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 313 | \ |
| 314 | /* Debugging */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 315 | F(DebugPrint, 1, 1) \ |
| 316 | F(DebugTrace, 0, 1) \ |
| 317 | F(TraceEnter, 0, 1) \ |
| 318 | F(TraceExit, 1, 1) \ |
| 319 | F(Abort, 2, 1) \ |
christian.plesner.hansen@gmail.com | 37abdec | 2009-01-06 14:43:28 +0000 | [diff] [blame] | 320 | /* Logging */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 321 | F(Log, 2, 1) \ |
christian.plesner.hansen@gmail.com | 2bc58ef | 2009-09-22 10:00:30 +0000 | [diff] [blame] | 322 | /* ES5 */ \ |
| 323 | F(LocalKeys, 1, 1) \ |
ricow@chromium.org | c9c8082 | 2010-04-21 08:22:37 +0000 | [diff] [blame] | 324 | /* Cache suport */ \ |
| 325 | F(GetFromCache, 2, 1) \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 326 | \ |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 327 | /* Message objects */ \ |
| 328 | F(NewMessageObject, 2, 1) \ |
| 329 | F(MessageGetType, 1, 1) \ |
| 330 | F(MessageGetArguments, 1, 1) \ |
| 331 | F(MessageGetStartPosition, 1, 1) \ |
| 332 | F(MessageGetScript, 1, 1) \ |
| 333 | \ |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 334 | /* Pseudo functions - handled as macros by parser */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 335 | F(IS_VAR, 1, 1) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 336 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 337 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 338 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 339 | /* Debugger support*/ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 340 | F(DebugBreak, 0, 1) \ |
| 341 | F(SetDebugEventListener, 2, 1) \ |
| 342 | F(Break, 0, 1) \ |
| 343 | F(DebugGetPropertyDetails, 2, 1) \ |
| 344 | F(DebugGetProperty, 2, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 345 | F(DebugPropertyTypeFromDetails, 1, 1) \ |
| 346 | F(DebugPropertyAttributesFromDetails, 1, 1) \ |
| 347 | F(DebugPropertyIndexFromDetails, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 348 | F(DebugNamedInterceptorPropertyValue, 2, 1) \ |
| 349 | F(DebugIndexedInterceptorElementValue, 2, 1) \ |
| 350 | F(CheckExecutionState, 1, 1) \ |
| 351 | F(GetFrameCount, 1, 1) \ |
| 352 | F(GetFrameDetails, 2, 1) \ |
| 353 | F(GetScopeCount, 2, 1) \ |
| 354 | F(GetScopeDetails, 3, 1) \ |
| 355 | F(DebugPrintScopes, 0, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 356 | F(GetThreadCount, 1, 1) \ |
| 357 | F(GetThreadDetails, 2, 1) \ |
whesse@chromium.org | e90029b | 2010-08-02 11:52:17 +0000 | [diff] [blame] | 358 | F(SetDisableBreak, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 359 | F(GetBreakLocations, 1, 1) \ |
| 360 | F(SetFunctionBreakPoint, 3, 1) \ |
| 361 | F(SetScriptBreakPoint, 3, 1) \ |
| 362 | F(ClearBreakPoint, 1, 1) \ |
| 363 | F(ChangeBreakOnException, 2, 1) \ |
fschneider@chromium.org | c20610a | 2010-09-22 09:44:58 +0000 | [diff] [blame] | 364 | F(IsBreakOnException, 1, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 365 | F(PrepareStep, 3, 1) \ |
| 366 | F(ClearStepping, 0, 1) \ |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 367 | F(DebugEvaluate, 5, 1) \ |
| 368 | F(DebugEvaluateGlobal, 4, 1) \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 369 | F(DebugGetLoadedScripts, 0, 1) \ |
| 370 | F(DebugReferencedBy, 3, 1) \ |
| 371 | F(DebugConstructedBy, 2, 1) \ |
| 372 | F(DebugGetPrototype, 1, 1) \ |
| 373 | F(SystemBreak, 0, 1) \ |
| 374 | F(DebugDisassembleFunction, 1, 1) \ |
| 375 | F(DebugDisassembleConstructor, 1, 1) \ |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 376 | F(FunctionGetInferredName, 1, 1) \ |
| 377 | F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \ |
| 378 | F(LiveEditGatherCompileInfo, 2, 1) \ |
| 379 | F(LiveEditReplaceScript, 3, 1) \ |
| 380 | F(LiveEditReplaceFunctionCode, 2, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 381 | F(LiveEditFunctionSourceUpdated, 1, 1) \ |
kmillikin@chromium.org | 4111b80 | 2010-05-03 10:34:42 +0000 | [diff] [blame] | 382 | F(LiveEditFunctionSetScript, 2, 1) \ |
| 383 | F(LiveEditReplaceRefToNestedFunction, 3, 1) \ |
ager@chromium.org | ce5e87b | 2010-03-10 10:24:18 +0000 | [diff] [blame] | 384 | F(LiveEditPatchFunctionPositions, 2, 1) \ |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 385 | F(LiveEditCheckAndDropActivations, 2, 1) \ |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 386 | F(LiveEditCompareStrings, 2, 1) \ |
ager@chromium.org | 357bf65 | 2010-04-12 11:30:10 +0000 | [diff] [blame] | 387 | F(GetFunctionCodePositionFromSource, 2, 1) \ |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 388 | F(ExecuteInDebugContext, 2, 1) \ |
| 389 | \ |
| 390 | F(SetFlags, 1, 1) \ |
| 391 | F(CollectGarbage, 1, 1) \ |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 392 | F(GetHeapUsage, 0, 1) \ |
| 393 | \ |
| 394 | /* LiveObjectList support*/ \ |
| 395 | F(HasLOLEnabled, 0, 1) \ |
| 396 | F(CaptureLOL, 0, 1) \ |
| 397 | F(DeleteLOL, 1, 1) \ |
| 398 | F(DumpLOL, 5, 1) \ |
| 399 | F(GetLOLObj, 1, 1) \ |
| 400 | F(GetLOLObjId, 1, 1) \ |
| 401 | F(GetLOLObjRetainers, 6, 1) \ |
| 402 | F(GetLOLPath, 3, 1) \ |
| 403 | F(InfoLOL, 2, 1) \ |
| 404 | F(PrintLOLObj, 1, 1) \ |
| 405 | F(ResetLOL, 0, 1) \ |
| 406 | F(SummarizeLOL, 3, 1) |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 407 | |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 408 | #else |
| 409 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) |
| 410 | #endif |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 411 | |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 412 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 413 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) \ |
ager@chromium.org | 5c83825 | 2010-02-19 08:53:10 +0000 | [diff] [blame] | 414 | F(ProfilerResume, 2, 1) \ |
| 415 | F(ProfilerPause, 2, 1) |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 416 | #else |
| 417 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
| 418 | #endif |
| 419 | |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 420 | #ifdef DEBUG |
| 421 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
| 422 | /* Testing */ \ |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 423 | F(ListNatives, 0, 1) |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 424 | #else |
| 425 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) |
| 426 | #endif |
| 427 | |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 428 | // ---------------------------------------------------------------------------- |
| 429 | // RUNTIME_FUNCTION_LIST defines all runtime functions accessed |
| 430 | // either directly by id (via the code generator), or indirectly |
| 431 | // via a native call by name (from within JS code). |
| 432 | |
| 433 | #define RUNTIME_FUNCTION_LIST(F) \ |
ager@chromium.org | ce58e17 | 2009-05-13 07:11:48 +0000 | [diff] [blame] | 434 | RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
| 435 | RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 436 | RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
sgjesse@chromium.org | ac6aa17 | 2009-12-04 12:29:05 +0000 | [diff] [blame] | 437 | RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 438 | RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
kasper.lund | 4451067 | 2008-07-25 07:37:58 +0000 | [diff] [blame] | 439 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 440 | // ---------------------------------------------------------------------------- |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 441 | // INLINE_FUNCTION_LIST defines all inlined functions accessed |
| 442 | // with a native call of the form %_name from within JS code. |
| 443 | // Entries have the form F(name, number of arguments, number of return values). |
| 444 | #define INLINE_FUNCTION_LIST(F) \ |
| 445 | F(IsSmi, 1, 1) \ |
| 446 | F(IsNonNegativeSmi, 1, 1) \ |
| 447 | F(IsArray, 1, 1) \ |
| 448 | F(IsRegExp, 1, 1) \ |
| 449 | F(CallFunction, -1 /* receiver + n args + function */, 1) \ |
| 450 | F(ArgumentsLength, 0, 1) \ |
| 451 | F(Arguments, 1, 1) \ |
| 452 | F(ValueOf, 1, 1) \ |
| 453 | F(SetValueOf, 2, 1) \ |
| 454 | F(StringCharFromCode, 1, 1) \ |
| 455 | F(StringCharAt, 2, 1) \ |
| 456 | F(ObjectEquals, 2, 1) \ |
| 457 | F(RandomHeapNumber, 0, 1) \ |
| 458 | F(IsObject, 1, 1) \ |
| 459 | F(IsFunction, 1, 1) \ |
| 460 | F(IsUndetectableObject, 1, 1) \ |
| 461 | F(IsSpecObject, 1, 1) \ |
| 462 | F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \ |
| 463 | F(MathPow, 2, 1) \ |
| 464 | F(MathSin, 1, 1) \ |
| 465 | F(MathCos, 1, 1) \ |
| 466 | F(MathSqrt, 1, 1) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 467 | F(MathLog, 1, 1) \ |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 468 | F(IsRegExpEquivalent, 2, 1) \ |
| 469 | F(HasCachedArrayIndex, 1, 1) \ |
vegorov@chromium.org | 21b5e95 | 2010-11-23 10:24:40 +0000 | [diff] [blame] | 470 | F(GetCachedArrayIndex, 1, 1) \ |
| 471 | F(FastAsciiArrayJoin, 2, 1) |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 472 | |
| 473 | |
| 474 | // ---------------------------------------------------------------------------- |
| 475 | // INLINE_AND_RUNTIME_FUNCTION_LIST defines all inlined functions accessed |
| 476 | // with a native call of the form %_name from within JS code that also have |
lrn@chromium.org | fa943b7 | 2010-11-03 08:14:36 +0000 | [diff] [blame] | 477 | // a corresponding runtime function, that is called for slow cases. |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 478 | // Entries have the form F(name, number of arguments, number of return values). |
| 479 | #define INLINE_RUNTIME_FUNCTION_LIST(F) \ |
| 480 | F(IsConstructCall, 0, 1) \ |
| 481 | F(ClassOf, 1, 1) \ |
| 482 | F(StringCharCodeAt, 2, 1) \ |
| 483 | F(Log, 3, 1) \ |
| 484 | F(StringAdd, 2, 1) \ |
| 485 | F(SubString, 3, 1) \ |
| 486 | F(StringCompare, 2, 1) \ |
| 487 | F(RegExpExec, 4, 1) \ |
| 488 | F(RegExpConstructResult, 3, 1) \ |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 489 | F(GetFromCache, 2, 1) \ |
| 490 | F(NumberToString, 1, 1) \ |
| 491 | F(SwapElements, 3, 1) |
| 492 | |
| 493 | |
| 494 | //--------------------------------------------------------------------------- |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 495 | // Runtime provides access to all C++ runtime functions. |
| 496 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 497 | class RuntimeState { |
| 498 | public: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 499 | StaticResource<StringInputBuffer>* string_input_buffer() { |
| 500 | return &string_input_buffer_; |
| 501 | } |
| 502 | unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() { |
| 503 | return &to_upper_mapping_; |
| 504 | } |
| 505 | unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() { |
| 506 | return &to_lower_mapping_; |
| 507 | } |
| 508 | StringInputBuffer* string_input_buffer_compare_bufx() { |
| 509 | return &string_input_buffer_compare_bufx_; |
| 510 | } |
| 511 | StringInputBuffer* string_input_buffer_compare_bufy() { |
| 512 | return &string_input_buffer_compare_bufy_; |
| 513 | } |
| 514 | StringInputBuffer* string_locale_compare_buf1() { |
| 515 | return &string_locale_compare_buf1_; |
| 516 | } |
| 517 | StringInputBuffer* string_locale_compare_buf2() { |
| 518 | return &string_locale_compare_buf2_; |
| 519 | } |
| 520 | int* smi_lexicographic_compare_x_elms() { |
| 521 | return smi_lexicographic_compare_x_elms_; |
| 522 | } |
| 523 | int* smi_lexicographic_compare_y_elms() { |
| 524 | return smi_lexicographic_compare_y_elms_; |
| 525 | } |
| 526 | |
| 527 | private: |
| 528 | RuntimeState() {} |
| 529 | // Non-reentrant string buffer for efficient general use in the runtime. |
| 530 | StaticResource<StringInputBuffer> string_input_buffer_; |
| 531 | unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_; |
| 532 | unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_; |
| 533 | StringInputBuffer string_input_buffer_compare_bufx_; |
| 534 | StringInputBuffer string_input_buffer_compare_bufy_; |
| 535 | StringInputBuffer string_locale_compare_buf1_; |
| 536 | StringInputBuffer string_locale_compare_buf2_; |
| 537 | int smi_lexicographic_compare_x_elms_[10]; |
| 538 | int smi_lexicographic_compare_y_elms_[10]; |
| 539 | |
| 540 | friend class Isolate; |
| 541 | friend class Runtime; |
| 542 | |
| 543 | DISALLOW_COPY_AND_ASSIGN(RuntimeState); |
| 544 | }; |
| 545 | |
| 546 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 547 | class Runtime : public AllStatic { |
| 548 | public: |
| 549 | enum FunctionId { |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 550 | #define F(name, nargs, ressize) k##name, |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 551 | RUNTIME_FUNCTION_LIST(F) |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 552 | #undef F |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 553 | #define F(name, nargs, ressize) kInline##name, |
| 554 | INLINE_FUNCTION_LIST(F) |
| 555 | INLINE_RUNTIME_FUNCTION_LIST(F) |
| 556 | #undef F |
| 557 | kNumFunctions, |
| 558 | kFirstInlineFunction = kInlineIsSmi |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 559 | }; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 560 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 561 | enum IntrinsicType { |
| 562 | RUNTIME, |
| 563 | INLINE |
| 564 | }; |
| 565 | |
| 566 | // Intrinsic function descriptor. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 567 | struct Function { |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 568 | FunctionId function_id; |
| 569 | IntrinsicType intrinsic_type; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 570 | // The JS name of the function. |
| 571 | const char* name; |
| 572 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 573 | // The C++ (native) entry point. NULL if the function is inlined. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 574 | byte* entry; |
| 575 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 576 | // The number of arguments expected. nargs is -1 if the function takes |
| 577 | // a variable number of arguments. |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 578 | int nargs; |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 579 | // Size of result. Most functions return a single pointer, size 1. |
ager@chromium.org | a1645e2 | 2009-09-09 19:27:10 +0000 | [diff] [blame] | 580 | int result_size; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 581 | }; |
| 582 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 583 | static const int kNotFound = -1; |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 584 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 585 | // Add symbols for all the intrinsic function names to a StringDictionary. |
| 586 | // Returns failure if an allocation fails. In this case, it must be |
| 587 | // retried with a new, empty StringDictionary, not with the same one. |
| 588 | // Alternatively, heap initialization can be completely restarted. |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 589 | MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 590 | Heap* heap, Object* dictionary); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 591 | |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 592 | // Get the intrinsic function with the given name, which must be a symbol. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 593 | static const Function* FunctionForSymbol(Handle<String> name); |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 594 | |
| 595 | // Get the intrinsic function with the given FunctionId. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 596 | static const Function* FunctionForId(FunctionId id); |
erik.corry@gmail.com | d88afa2 | 2010-09-15 12:33:05 +0000 | [diff] [blame] | 597 | |
| 598 | // General-purpose helper functions for runtime system. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 599 | static int StringMatch(Isolate* isolate, |
| 600 | Handle<String> sub, |
| 601 | Handle<String> pat, |
| 602 | int index); |
kasperl@chromium.org | 41044eb | 2008-10-06 08:24:46 +0000 | [diff] [blame] | 603 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 604 | static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch); |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 605 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 606 | // TODO(1240886): The following three methods are *not* handle safe, |
| 607 | // but accept handle arguments. This seems fragile. |
| 608 | |
| 609 | // Support getting the characters in a string using [] notation as |
| 610 | // in Firefox/SpiderMonkey, Safari and Opera. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 611 | MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Isolate* isolate, |
| 612 | Handle<Object> object, |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 613 | uint32_t index); |
| 614 | MUST_USE_RESULT static MaybeObject* GetElement(Handle<Object> object, |
| 615 | uint32_t index); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 616 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 617 | MUST_USE_RESULT static MaybeObject* SetObjectProperty( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 618 | Isolate* isolate, |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 619 | Handle<Object> object, |
| 620 | Handle<Object> key, |
| 621 | Handle<Object> value, |
ager@chromium.org | 9ee27ae | 2011-03-02 13:43:26 +0000 | [diff] [blame] | 622 | PropertyAttributes attr, |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 623 | StrictModeFlag strict_mode); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 624 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 625 | MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 626 | Isolate* isolate, |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 627 | Handle<JSObject> object, |
| 628 | Handle<Object> key, |
| 629 | Handle<Object> value, |
| 630 | PropertyAttributes attr); |
ager@chromium.org | 65dad4b | 2009-04-23 08:48:43 +0000 | [diff] [blame] | 631 | |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 632 | MUST_USE_RESULT static MaybeObject* ForceDeleteObjectProperty( |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 633 | Isolate* isolate, |
lrn@chromium.org | 303ada7 | 2010-10-27 09:33:13 +0000 | [diff] [blame] | 634 | Handle<JSObject> object, |
| 635 | Handle<Object> key); |
ager@chromium.org | e2902be | 2009-06-08 12:21:35 +0000 | [diff] [blame] | 636 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 637 | MUST_USE_RESULT static MaybeObject* GetObjectProperty( |
| 638 | Isolate* isolate, |
| 639 | Handle<Object> object, |
| 640 | Handle<Object> key); |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 641 | |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 642 | // This function is used in FunctionNameUsing* tests. |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 643 | static Object* FindSharedFunctionInfoInScript(Isolate* isolate, |
| 644 | Handle<Script> script, |
kasperl@chromium.org | d1e3e72 | 2009-04-14 13:38:25 +0000 | [diff] [blame] | 645 | int position); |
| 646 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 647 | // Helper functions used stubs. |
| 648 | static void PerformGC(Object* result); |
| 649 | }; |
| 650 | |
christian.plesner.hansen | 43d26ec | 2008-07-03 15:10:15 +0000 | [diff] [blame] | 651 | } } // namespace v8::internal |
| 652 | |
| 653 | #endif // V8_RUNTIME_H_ |