Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +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 | |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 32 | #include "zone.h" |
| 33 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 34 | namespace v8 { |
| 35 | namespace internal { |
| 36 | |
| 37 | // The interface to C++ runtime functions. |
| 38 | |
| 39 | // ---------------------------------------------------------------------------- |
| 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. |
| 43 | |
| 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) \ |
| 48 | /* Property access */ \ |
| 49 | F(GetProperty, 2, 1) \ |
| 50 | F(KeyedGetProperty, 2, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 51 | F(DeleteProperty, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +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) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +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) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 63 | F(GetArgumentsProperty, 1, 1) \ |
| 64 | F(ToFastProperties, 1, 1) \ |
| 65 | F(ToSlowProperties, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 66 | F(FinishArrayPrototypeSetup, 1, 1) \ |
| 67 | F(SpecialArrayFunctions, 1, 1) \ |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 68 | F(GetDefaultReceiver, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 69 | \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 70 | F(GetPrototype, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 71 | F(IsInPrototypeChain, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 72 | \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 73 | F(GetOwnProperty, 2, 1) \ |
| 74 | \ |
| 75 | F(IsExtensible, 1, 1) \ |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 76 | F(PreventExtensions, 1, 1)\ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 77 | \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 78 | /* Utilities */ \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 79 | F(CheckIsBootstrapping, 0, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 80 | F(Call, -1 /* >= 2 */, 1) \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 81 | F(Apply, 5, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 82 | F(GetFunctionDelegate, 1, 1) \ |
| 83 | F(GetConstructorDelegate, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 84 | F(NewArgumentsFast, 3, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 85 | F(NewStrictArgumentsFast, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 86 | F(LazyCompile, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 87 | F(LazyRecompile, 1, 1) \ |
| 88 | F(NotifyDeoptimized, 1, 1) \ |
| 89 | F(NotifyOSR, 0, 1) \ |
Ben Murdoch | 8b112d2 | 2011-06-08 16:22:53 +0100 | [diff] [blame] | 90 | F(DeoptimizeFunction, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 91 | F(RunningInSimulator, 0, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 92 | F(OptimizeFunctionOnNextCall, -1, 1) \ |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 93 | F(GetOptimizationStatus, 1, 1) \ |
| 94 | F(GetOptimizationCount, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 95 | F(CompileForOnStackReplacement, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 96 | F(SetNewFunctionAttributes, 1, 1) \ |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 97 | F(AllocateInNewSpace, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 98 | F(SetNativeFlag, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 99 | F(StoreArrayLiteralElement, 5, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 100 | \ |
| 101 | /* Array join support */ \ |
| 102 | F(PushIfAbsent, 2, 1) \ |
| 103 | F(ArrayConcat, 1, 1) \ |
| 104 | \ |
| 105 | /* Conversions */ \ |
| 106 | F(ToBool, 1, 1) \ |
| 107 | F(Typeof, 1, 1) \ |
| 108 | \ |
| 109 | F(StringToNumber, 1, 1) \ |
| 110 | F(StringFromCharCodeArray, 1, 1) \ |
| 111 | F(StringParseInt, 2, 1) \ |
| 112 | F(StringParseFloat, 1, 1) \ |
| 113 | F(StringToLowerCase, 1, 1) \ |
| 114 | F(StringToUpperCase, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 115 | F(StringSplit, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 116 | F(CharFromCode, 1, 1) \ |
| 117 | F(URIEscape, 1, 1) \ |
| 118 | F(URIUnescape, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 119 | F(QuoteJSONString, 1, 1) \ |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 120 | F(QuoteJSONStringComma, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 121 | F(QuoteJSONStringArray, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 122 | \ |
| 123 | F(NumberToString, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 124 | F(NumberToStringSkipCache, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 125 | F(NumberToInteger, 1, 1) \ |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 126 | F(NumberToIntegerMapMinusZero, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 127 | F(NumberToJSUint32, 1, 1) \ |
| 128 | F(NumberToJSInt32, 1, 1) \ |
| 129 | F(NumberToSmi, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 130 | F(AllocateHeapNumber, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 131 | \ |
| 132 | /* Arithmetic operations */ \ |
| 133 | F(NumberAdd, 2, 1) \ |
| 134 | F(NumberSub, 2, 1) \ |
| 135 | F(NumberMul, 2, 1) \ |
| 136 | F(NumberDiv, 2, 1) \ |
| 137 | F(NumberMod, 2, 1) \ |
| 138 | F(NumberUnaryMinus, 1, 1) \ |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 139 | F(NumberAlloc, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 140 | \ |
| 141 | F(StringAdd, 2, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 142 | F(StringBuilderConcat, 3, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 143 | F(StringBuilderJoin, 3, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 144 | F(SparseJoinWithSeparator, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 145 | \ |
| 146 | /* Bit operations */ \ |
| 147 | F(NumberOr, 2, 1) \ |
| 148 | F(NumberAnd, 2, 1) \ |
| 149 | F(NumberXor, 2, 1) \ |
| 150 | F(NumberNot, 1, 1) \ |
| 151 | \ |
| 152 | F(NumberShl, 2, 1) \ |
| 153 | F(NumberShr, 2, 1) \ |
| 154 | F(NumberSar, 2, 1) \ |
| 155 | \ |
| 156 | /* Comparisons */ \ |
| 157 | F(NumberEquals, 2, 1) \ |
| 158 | F(StringEquals, 2, 1) \ |
| 159 | \ |
| 160 | F(NumberCompare, 3, 1) \ |
| 161 | F(SmiLexicographicCompare, 2, 1) \ |
| 162 | F(StringCompare, 2, 1) \ |
| 163 | \ |
| 164 | /* Math */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 165 | F(Math_acos, 1, 1) \ |
| 166 | F(Math_asin, 1, 1) \ |
| 167 | F(Math_atan, 1, 1) \ |
| 168 | F(Math_atan2, 2, 1) \ |
| 169 | F(Math_ceil, 1, 1) \ |
| 170 | F(Math_cos, 1, 1) \ |
| 171 | F(Math_exp, 1, 1) \ |
| 172 | F(Math_floor, 1, 1) \ |
| 173 | F(Math_log, 1, 1) \ |
| 174 | F(Math_pow, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 175 | F(Math_pow_cfunction, 2, 1) \ |
| 176 | F(RoundNumber, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 177 | F(Math_sin, 1, 1) \ |
| 178 | F(Math_sqrt, 1, 1) \ |
| 179 | F(Math_tan, 1, 1) \ |
| 180 | \ |
| 181 | /* Regular expressions */ \ |
| 182 | F(RegExpCompile, 3, 1) \ |
| 183 | F(RegExpExec, 4, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 184 | F(RegExpExecMultiple, 4, 1) \ |
| 185 | F(RegExpInitializeObject, 5, 1) \ |
| 186 | F(RegExpConstructResult, 3, 1) \ |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 187 | \ |
| 188 | /* JSON */ \ |
| 189 | F(ParseJson, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 190 | \ |
| 191 | /* Strings */ \ |
| 192 | F(StringCharCodeAt, 2, 1) \ |
| 193 | F(StringIndexOf, 3, 1) \ |
| 194 | F(StringLastIndexOf, 3, 1) \ |
| 195 | F(StringLocaleCompare, 2, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 196 | F(SubString, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 197 | F(StringReplaceRegExpWithString, 4, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 198 | F(StringReplaceOneCharWithString, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 199 | F(StringMatch, 3, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 200 | F(StringTrim, 3, 1) \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 201 | F(StringToArray, 2, 1) \ |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 202 | F(NewStringWrapper, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 203 | \ |
| 204 | /* Numbers */ \ |
| 205 | F(NumberToRadixString, 2, 1) \ |
| 206 | F(NumberToFixed, 2, 1) \ |
| 207 | F(NumberToExponential, 2, 1) \ |
| 208 | F(NumberToPrecision, 2, 1) |
| 209 | |
| 210 | #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 211 | /* Reflection */ \ |
| 212 | F(FunctionSetInstanceClassName, 2, 1) \ |
| 213 | F(FunctionSetLength, 2, 1) \ |
| 214 | F(FunctionSetPrototype, 2, 1) \ |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 215 | F(FunctionSetReadOnlyPrototype, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 216 | F(FunctionGetName, 1, 1) \ |
| 217 | F(FunctionSetName, 2, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 218 | F(FunctionNameShouldPrintAsAnonymous, 1, 1) \ |
| 219 | F(FunctionMarkNameShouldPrintAsAnonymous, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 220 | F(FunctionBindArguments, 4, 1) \ |
| 221 | F(BoundFunctionGetBindings, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 222 | F(FunctionRemovePrototype, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 223 | F(FunctionGetSourceCode, 1, 1) \ |
| 224 | F(FunctionGetScript, 1, 1) \ |
| 225 | F(FunctionGetScriptSourcePosition, 1, 1) \ |
| 226 | F(FunctionGetPositionForOffset, 2, 1) \ |
| 227 | F(FunctionIsAPIFunction, 1, 1) \ |
| 228 | F(FunctionIsBuiltin, 1, 1) \ |
| 229 | F(GetScript, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 230 | F(CollectStackTrace, 3, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 231 | F(GetV8Version, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 232 | \ |
| 233 | F(ClassOf, 1, 1) \ |
| 234 | F(SetCode, 2, 1) \ |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 235 | F(SetExpectedNumberOfProperties, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 236 | \ |
| 237 | F(CreateApiFunction, 1, 1) \ |
| 238 | F(IsTemplate, 1, 1) \ |
| 239 | F(GetTemplateField, 2, 1) \ |
| 240 | F(DisableAccessChecks, 1, 1) \ |
| 241 | F(EnableAccessChecks, 1, 1) \ |
| 242 | \ |
| 243 | /* Dates */ \ |
| 244 | F(DateCurrentTime, 0, 1) \ |
| 245 | F(DateParseString, 2, 1) \ |
| 246 | F(DateLocalTimezone, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 247 | F(DateToUTC, 1, 1) \ |
| 248 | F(DateMakeDay, 2, 1) \ |
| 249 | F(DateSetValue, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 250 | \ |
| 251 | /* Numbers */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 252 | \ |
| 253 | /* Globals */ \ |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 254 | F(CompileString, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 255 | F(GlobalPrint, 1, 1) \ |
| 256 | \ |
| 257 | /* Eval */ \ |
| 258 | F(GlobalReceiver, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 259 | F(ResolvePossiblyDirectEval, 5, 2) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 260 | \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 261 | F(SetProperty, -1 /* 4 or 5 */, 1) \ |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 262 | F(DefineOrRedefineDataProperty, 4, 1) \ |
| 263 | F(DefineOrRedefineAccessorProperty, 5, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 264 | F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ |
| 265 | \ |
| 266 | /* Arrays */ \ |
| 267 | F(RemoveArrayHoles, 2, 1) \ |
| 268 | F(GetArrayKeys, 2, 1) \ |
| 269 | F(MoveArrayContents, 2, 1) \ |
| 270 | F(EstimateNumberOfElements, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 271 | F(SwapElements, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 272 | \ |
| 273 | /* Getters and Setters */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 274 | F(LookupAccessor, 3, 1) \ |
| 275 | \ |
| 276 | /* Literals */ \ |
| 277 | F(MaterializeRegExpLiteral, 4, 1)\ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 278 | F(CreateObjectLiteral, 4, 1) \ |
| 279 | F(CreateObjectLiteralShallow, 4, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 280 | F(CreateArrayLiteral, 3, 1) \ |
| 281 | F(CreateArrayLiteralShallow, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 282 | \ |
Ben Murdoch | 257744e | 2011-11-30 15:57:28 +0000 | [diff] [blame] | 283 | /* Harmony proxies */ \ |
| 284 | F(CreateJSProxy, 2, 1) \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 285 | F(CreateJSFunctionProxy, 4, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 286 | F(IsJSProxy, 1, 1) \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 287 | F(IsJSFunctionProxy, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 288 | F(GetHandler, 1, 1) \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 289 | F(GetCallTrap, 1, 1) \ |
| 290 | F(GetConstructTrap, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 291 | F(Fix, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 292 | \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 293 | /* Harmony sets */ \ |
| 294 | F(SetInitialize, 1, 1) \ |
| 295 | F(SetAdd, 2, 1) \ |
| 296 | F(SetHas, 2, 1) \ |
| 297 | F(SetDelete, 2, 1) \ |
| 298 | \ |
| 299 | /* Harmony maps */ \ |
| 300 | F(MapInitialize, 1, 1) \ |
| 301 | F(MapGet, 2, 1) \ |
| 302 | F(MapSet, 3, 1) \ |
| 303 | \ |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 304 | /* Harmony weakmaps */ \ |
| 305 | F(WeakMapInitialize, 1, 1) \ |
| 306 | F(WeakMapGet, 2, 1) \ |
| 307 | F(WeakMapSet, 3, 1) \ |
| 308 | \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 309 | /* Statements */ \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 310 | F(NewClosure, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 311 | F(NewObject, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 312 | F(NewObjectFromBound, 1, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 313 | F(FinalizeInstanceSize, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 314 | F(Throw, 1, 1) \ |
| 315 | F(ReThrow, 1, 1) \ |
| 316 | F(ThrowReferenceError, 1, 1) \ |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 317 | F(StackGuard, 0, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 318 | F(Interrupt, 0, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 319 | F(PromoteScheduledException, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 320 | \ |
| 321 | /* Contexts */ \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 322 | F(NewFunctionContext, 1, 1) \ |
| 323 | F(PushWithContext, 2, 1) \ |
| 324 | F(PushCatchContext, 3, 1) \ |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 325 | F(PushBlockContext, 2, 1) \ |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 326 | F(DeleteContextSlot, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 327 | F(LoadContextSlot, 2, 2) \ |
| 328 | F(LoadContextSlotNoReferenceError, 2, 2) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 329 | F(StoreContextSlot, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 330 | \ |
| 331 | /* Declarations and initialization */ \ |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 332 | F(DeclareGlobals, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 333 | F(DeclareContextSlot, 4, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 334 | F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 335 | F(InitializeConstGlobal, 2, 1) \ |
| 336 | F(InitializeConstContextSlot, 3, 1) \ |
| 337 | F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 338 | \ |
| 339 | /* Debugging */ \ |
| 340 | F(DebugPrint, 1, 1) \ |
| 341 | F(DebugTrace, 0, 1) \ |
| 342 | F(TraceEnter, 0, 1) \ |
| 343 | F(TraceExit, 1, 1) \ |
| 344 | F(Abort, 2, 1) \ |
| 345 | /* Logging */ \ |
| 346 | F(Log, 2, 1) \ |
| 347 | /* ES5 */ \ |
| 348 | F(LocalKeys, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 349 | /* Cache suport */ \ |
| 350 | F(GetFromCache, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 351 | \ |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 352 | /* Message objects */ \ |
| 353 | F(NewMessageObject, 2, 1) \ |
| 354 | F(MessageGetType, 1, 1) \ |
| 355 | F(MessageGetArguments, 1, 1) \ |
| 356 | F(MessageGetStartPosition, 1, 1) \ |
| 357 | F(MessageGetScript, 1, 1) \ |
| 358 | \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 359 | /* Pseudo functions - handled as macros by parser */ \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 360 | F(IS_VAR, 1, 1) \ |
| 361 | \ |
| 362 | /* expose boolean functions from objects-inl.h */ \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 363 | F(HasFastSmiOnlyElements, 1, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 364 | F(HasFastElements, 1, 1) \ |
| 365 | F(HasFastDoubleElements, 1, 1) \ |
| 366 | F(HasDictionaryElements, 1, 1) \ |
| 367 | F(HasExternalPixelElements, 1, 1) \ |
| 368 | F(HasExternalArrayElements, 1, 1) \ |
| 369 | F(HasExternalByteElements, 1, 1) \ |
| 370 | F(HasExternalUnsignedByteElements, 1, 1) \ |
| 371 | F(HasExternalShortElements, 1, 1) \ |
| 372 | F(HasExternalUnsignedShortElements, 1, 1) \ |
| 373 | F(HasExternalIntElements, 1, 1) \ |
| 374 | F(HasExternalUnsignedIntElements, 1, 1) \ |
| 375 | F(HasExternalFloatElements, 1, 1) \ |
| 376 | F(HasExternalDoubleElements, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 377 | F(TransitionElementsSmiToDouble, 1, 1) \ |
| 378 | F(TransitionElementsDoubleToObject, 1, 1) \ |
| 379 | F(HaveSameMap, 2, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 380 | /* profiler */ \ |
| 381 | F(ProfilerResume, 0, 1) \ |
| 382 | F(ProfilerPause, 0, 1) |
| 383 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 384 | |
| 385 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 386 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 387 | /* Debugger support*/ \ |
| 388 | F(DebugBreak, 0, 1) \ |
| 389 | F(SetDebugEventListener, 2, 1) \ |
| 390 | F(Break, 0, 1) \ |
| 391 | F(DebugGetPropertyDetails, 2, 1) \ |
| 392 | F(DebugGetProperty, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 393 | F(DebugPropertyTypeFromDetails, 1, 1) \ |
| 394 | F(DebugPropertyAttributesFromDetails, 1, 1) \ |
| 395 | F(DebugPropertyIndexFromDetails, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 396 | F(DebugNamedInterceptorPropertyValue, 2, 1) \ |
| 397 | F(DebugIndexedInterceptorElementValue, 2, 1) \ |
| 398 | F(CheckExecutionState, 1, 1) \ |
| 399 | F(GetFrameCount, 1, 1) \ |
| 400 | F(GetFrameDetails, 2, 1) \ |
| 401 | F(GetScopeCount, 2, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 402 | F(GetScopeDetails, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 403 | F(DebugPrintScopes, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 404 | F(GetThreadCount, 1, 1) \ |
| 405 | F(GetThreadDetails, 2, 1) \ |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 406 | F(SetDisableBreak, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 407 | F(GetBreakLocations, 1, 1) \ |
| 408 | F(SetFunctionBreakPoint, 3, 1) \ |
| 409 | F(SetScriptBreakPoint, 3, 1) \ |
| 410 | F(ClearBreakPoint, 1, 1) \ |
| 411 | F(ChangeBreakOnException, 2, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 412 | F(IsBreakOnException, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 413 | F(PrepareStep, 3, 1) \ |
| 414 | F(ClearStepping, 0, 1) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 415 | F(DebugEvaluate, 6, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 416 | F(DebugEvaluateGlobal, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 417 | F(DebugGetLoadedScripts, 0, 1) \ |
| 418 | F(DebugReferencedBy, 3, 1) \ |
| 419 | F(DebugConstructedBy, 2, 1) \ |
| 420 | F(DebugGetPrototype, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 421 | F(DebugSetScriptSource, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 422 | F(SystemBreak, 0, 1) \ |
| 423 | F(DebugDisassembleFunction, 1, 1) \ |
| 424 | F(DebugDisassembleConstructor, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 425 | F(FunctionGetInferredName, 1, 1) \ |
| 426 | F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \ |
| 427 | F(LiveEditGatherCompileInfo, 2, 1) \ |
| 428 | F(LiveEditReplaceScript, 3, 1) \ |
| 429 | F(LiveEditReplaceFunctionCode, 2, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 430 | F(LiveEditFunctionSourceUpdated, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 431 | F(LiveEditFunctionSetScript, 2, 1) \ |
| 432 | F(LiveEditReplaceRefToNestedFunction, 3, 1) \ |
| 433 | F(LiveEditPatchFunctionPositions, 2, 1) \ |
| 434 | F(LiveEditCheckAndDropActivations, 2, 1) \ |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 435 | F(LiveEditCompareStrings, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 436 | F(GetFunctionCodePositionFromSource, 2, 1) \ |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 437 | F(ExecuteInDebugContext, 2, 1) \ |
| 438 | \ |
| 439 | F(SetFlags, 1, 1) \ |
| 440 | F(CollectGarbage, 1, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 441 | F(GetHeapUsage, 0, 1) \ |
| 442 | \ |
| 443 | /* LiveObjectList support*/ \ |
| 444 | F(HasLOLEnabled, 0, 1) \ |
| 445 | F(CaptureLOL, 0, 1) \ |
| 446 | F(DeleteLOL, 1, 1) \ |
| 447 | F(DumpLOL, 5, 1) \ |
| 448 | F(GetLOLObj, 1, 1) \ |
| 449 | F(GetLOLObjId, 1, 1) \ |
| 450 | F(GetLOLObjRetainers, 6, 1) \ |
| 451 | F(GetLOLPath, 3, 1) \ |
| 452 | F(InfoLOL, 2, 1) \ |
| 453 | F(PrintLOLObj, 1, 1) \ |
| 454 | F(ResetLOL, 0, 1) \ |
| 455 | F(SummarizeLOL, 3, 1) |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 456 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 457 | #else |
| 458 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) |
| 459 | #endif |
| 460 | |
| 461 | #ifdef DEBUG |
| 462 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
| 463 | /* Testing */ \ |
| 464 | F(ListNatives, 0, 1) |
| 465 | #else |
| 466 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) |
| 467 | #endif |
| 468 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 469 | // ---------------------------------------------------------------------------- |
| 470 | // RUNTIME_FUNCTION_LIST defines all runtime functions accessed |
| 471 | // either directly by id (via the code generator), or indirectly |
| 472 | // via a native call by name (from within JS code). |
| 473 | |
| 474 | #define RUNTIME_FUNCTION_LIST(F) \ |
| 475 | RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
| 476 | RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 477 | RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 478 | RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 479 | |
| 480 | // ---------------------------------------------------------------------------- |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 481 | // INLINE_FUNCTION_LIST defines all inlined functions accessed |
| 482 | // with a native call of the form %_name from within JS code. |
| 483 | // Entries have the form F(name, number of arguments, number of return values). |
| 484 | #define INLINE_FUNCTION_LIST(F) \ |
| 485 | F(IsSmi, 1, 1) \ |
| 486 | F(IsNonNegativeSmi, 1, 1) \ |
| 487 | F(IsArray, 1, 1) \ |
| 488 | F(IsRegExp, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 489 | F(IsConstructCall, 0, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 490 | F(CallFunction, -1 /* receiver + n args + function */, 1) \ |
| 491 | F(ArgumentsLength, 0, 1) \ |
| 492 | F(Arguments, 1, 1) \ |
| 493 | F(ValueOf, 1, 1) \ |
| 494 | F(SetValueOf, 2, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 495 | F(DateField, 2 /* date object, field index */, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 496 | F(StringCharFromCode, 1, 1) \ |
| 497 | F(StringCharAt, 2, 1) \ |
| 498 | F(ObjectEquals, 2, 1) \ |
| 499 | F(RandomHeapNumber, 0, 1) \ |
| 500 | F(IsObject, 1, 1) \ |
| 501 | F(IsFunction, 1, 1) \ |
| 502 | F(IsUndetectableObject, 1, 1) \ |
| 503 | F(IsSpecObject, 1, 1) \ |
| 504 | F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \ |
| 505 | F(MathPow, 2, 1) \ |
| 506 | F(MathSin, 1, 1) \ |
| 507 | F(MathCos, 1, 1) \ |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 508 | F(MathTan, 1, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 509 | F(MathSqrt, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 510 | F(MathLog, 1, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 511 | F(IsRegExpEquivalent, 2, 1) \ |
| 512 | F(HasCachedArrayIndex, 1, 1) \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 513 | F(GetCachedArrayIndex, 1, 1) \ |
Ben Murdoch | 69a99ed | 2011-11-30 16:03:39 +0000 | [diff] [blame] | 514 | F(FastAsciiArrayJoin, 2, 1) |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 515 | |
| 516 | |
| 517 | // ---------------------------------------------------------------------------- |
| 518 | // INLINE_AND_RUNTIME_FUNCTION_LIST defines all inlined functions accessed |
| 519 | // with a native call of the form %_name from within JS code that also have |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 520 | // a corresponding runtime function, that is called for slow cases. |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 521 | // Entries have the form F(name, number of arguments, number of return values). |
| 522 | #define INLINE_RUNTIME_FUNCTION_LIST(F) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 523 | F(ClassOf, 1, 1) \ |
| 524 | F(StringCharCodeAt, 2, 1) \ |
| 525 | F(Log, 3, 1) \ |
| 526 | F(StringAdd, 2, 1) \ |
| 527 | F(SubString, 3, 1) \ |
| 528 | F(StringCompare, 2, 1) \ |
| 529 | F(RegExpExec, 4, 1) \ |
| 530 | F(RegExpConstructResult, 3, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 531 | F(GetFromCache, 2, 1) \ |
| 532 | F(NumberToString, 1, 1) \ |
| 533 | F(SwapElements, 3, 1) |
| 534 | |
| 535 | |
| 536 | //--------------------------------------------------------------------------- |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 537 | // Runtime provides access to all C++ runtime functions. |
| 538 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 539 | class RuntimeState { |
| 540 | public: |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 541 | StaticResource<StringInputBuffer>* string_input_buffer() { |
| 542 | return &string_input_buffer_; |
| 543 | } |
| 544 | unibrow::Mapping<unibrow::ToUppercase, 128>* to_upper_mapping() { |
| 545 | return &to_upper_mapping_; |
| 546 | } |
| 547 | unibrow::Mapping<unibrow::ToLowercase, 128>* to_lower_mapping() { |
| 548 | return &to_lower_mapping_; |
| 549 | } |
| 550 | StringInputBuffer* string_input_buffer_compare_bufx() { |
| 551 | return &string_input_buffer_compare_bufx_; |
| 552 | } |
| 553 | StringInputBuffer* string_input_buffer_compare_bufy() { |
| 554 | return &string_input_buffer_compare_bufy_; |
| 555 | } |
| 556 | StringInputBuffer* string_locale_compare_buf1() { |
| 557 | return &string_locale_compare_buf1_; |
| 558 | } |
| 559 | StringInputBuffer* string_locale_compare_buf2() { |
| 560 | return &string_locale_compare_buf2_; |
| 561 | } |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 562 | |
| 563 | private: |
| 564 | RuntimeState() {} |
| 565 | // Non-reentrant string buffer for efficient general use in the runtime. |
| 566 | StaticResource<StringInputBuffer> string_input_buffer_; |
| 567 | unibrow::Mapping<unibrow::ToUppercase, 128> to_upper_mapping_; |
| 568 | unibrow::Mapping<unibrow::ToLowercase, 128> to_lower_mapping_; |
| 569 | StringInputBuffer string_input_buffer_compare_bufx_; |
| 570 | StringInputBuffer string_input_buffer_compare_bufy_; |
| 571 | StringInputBuffer string_locale_compare_buf1_; |
| 572 | StringInputBuffer string_locale_compare_buf2_; |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 573 | |
| 574 | friend class Isolate; |
| 575 | friend class Runtime; |
| 576 | |
| 577 | DISALLOW_COPY_AND_ASSIGN(RuntimeState); |
| 578 | }; |
| 579 | |
| 580 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 581 | class Runtime : public AllStatic { |
| 582 | public: |
| 583 | enum FunctionId { |
| 584 | #define F(name, nargs, ressize) k##name, |
| 585 | RUNTIME_FUNCTION_LIST(F) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 586 | #undef F |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 587 | #define F(name, nargs, ressize) kInline##name, |
| 588 | INLINE_FUNCTION_LIST(F) |
| 589 | INLINE_RUNTIME_FUNCTION_LIST(F) |
| 590 | #undef F |
| 591 | kNumFunctions, |
| 592 | kFirstInlineFunction = kInlineIsSmi |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 593 | }; |
| 594 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 595 | enum IntrinsicType { |
| 596 | RUNTIME, |
| 597 | INLINE |
| 598 | }; |
| 599 | |
| 600 | // Intrinsic function descriptor. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 601 | struct Function { |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 602 | FunctionId function_id; |
| 603 | IntrinsicType intrinsic_type; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 604 | // The JS name of the function. |
| 605 | const char* name; |
| 606 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 607 | // The C++ (native) entry point. NULL if the function is inlined. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 608 | byte* entry; |
| 609 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 610 | // The number of arguments expected. nargs is -1 if the function takes |
| 611 | // a variable number of arguments. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 612 | int nargs; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 613 | // Size of result. Most functions return a single pointer, size 1. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 614 | int result_size; |
| 615 | }; |
| 616 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 617 | static const int kNotFound = -1; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 618 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 619 | // Add symbols for all the intrinsic function names to a StringDictionary. |
| 620 | // Returns failure if an allocation fails. In this case, it must be |
| 621 | // retried with a new, empty StringDictionary, not with the same one. |
| 622 | // Alternatively, heap initialization can be completely restarted. |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 623 | MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames( |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 624 | Heap* heap, Object* dictionary); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 625 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 626 | // Get the intrinsic function with the given name, which must be a symbol. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 627 | static const Function* FunctionForSymbol(Handle<String> name); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 628 | |
| 629 | // Get the intrinsic function with the given FunctionId. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 630 | static const Function* FunctionForId(FunctionId id); |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 631 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 632 | static Handle<String> StringReplaceOneCharWithString(Isolate* isolate, |
| 633 | Handle<String> subject, |
| 634 | Handle<String> search, |
| 635 | Handle<String> replace, |
| 636 | bool* found, |
| 637 | int recursion_limit); |
| 638 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 639 | // General-purpose helper functions for runtime system. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 640 | static int StringMatch(Isolate* isolate, |
| 641 | Handle<String> sub, |
| 642 | Handle<String> pat, |
| 643 | int index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 644 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 645 | static bool IsUpperCaseChar(RuntimeState* runtime_state, uint16_t ch); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 646 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 647 | // TODO(1240886): Some of the following methods are *not* handle safe, but |
| 648 | // accept handle arguments. This seems fragile. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 649 | |
| 650 | // Support getting the characters in a string using [] notation as |
| 651 | // in Firefox/SpiderMonkey, Safari and Opera. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 652 | MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Isolate* isolate, |
| 653 | Handle<Object> object, |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 654 | uint32_t index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 655 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 656 | MUST_USE_RESULT static MaybeObject* SetObjectProperty( |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 657 | Isolate* isolate, |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 658 | Handle<Object> object, |
| 659 | Handle<Object> key, |
| 660 | Handle<Object> value, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame] | 661 | PropertyAttributes attr, |
| 662 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 663 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 664 | MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty( |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 665 | Isolate* isolate, |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 666 | Handle<JSObject> object, |
| 667 | Handle<Object> key, |
| 668 | Handle<Object> value, |
| 669 | PropertyAttributes attr); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 670 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 671 | MUST_USE_RESULT static MaybeObject* ForceDeleteObjectProperty( |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 672 | Isolate* isolate, |
Ben Murdoch | 3fb3ca8 | 2011-12-02 17:19:32 +0000 | [diff] [blame] | 673 | Handle<JSReceiver> object, |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 674 | Handle<Object> key); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 675 | |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 676 | MUST_USE_RESULT static MaybeObject* GetObjectProperty( |
| 677 | Isolate* isolate, |
| 678 | Handle<Object> object, |
| 679 | Handle<Object> key); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 680 | |
| 681 | // This function is used in FunctionNameUsing* tests. |
Steve Block | 44f0eee | 2011-05-26 01:26:41 +0100 | [diff] [blame] | 682 | static Object* FindSharedFunctionInfoInScript(Isolate* isolate, |
| 683 | Handle<Script> script, |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 684 | int position); |
| 685 | |
| 686 | // Helper functions used stubs. |
| 687 | static void PerformGC(Object* result); |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 688 | |
| 689 | // Used in runtime.cc and hydrogen's VisitArrayLiteral. |
| 690 | static Handle<Object> CreateArrayLiteralBoilerplate( |
| 691 | Isolate* isolate, |
| 692 | Handle<FixedArray> literals, |
| 693 | Handle<FixedArray> elements); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 694 | }; |
| 695 | |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 696 | |
| 697 | //--------------------------------------------------------------------------- |
| 698 | // Constants used by interface to runtime functions. |
| 699 | |
Ben Murdoch | 3ef787d | 2012-04-12 10:51:47 +0100 | [diff] [blame^] | 700 | class DeclareGlobalsEvalFlag: public BitField<bool, 0, 1> {}; |
| 701 | class DeclareGlobalsNativeFlag: public BitField<bool, 1, 1> {}; |
| 702 | class DeclareGlobalsLanguageMode: public BitField<LanguageMode, 2, 2> {}; |
Ben Murdoch | 589d697 | 2011-11-30 16:04:58 +0000 | [diff] [blame] | 703 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 704 | } } // namespace v8::internal |
| 705 | |
| 706 | #endif // V8_RUNTIME_H_ |