Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 1 | // Copyright 2010 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 | |
| 31 | namespace v8 { |
| 32 | namespace internal { |
| 33 | |
| 34 | // The interface to C++ runtime functions. |
| 35 | |
| 36 | // ---------------------------------------------------------------------------- |
| 37 | // RUNTIME_FUNCTION_LIST_ALWAYS defines runtime calls available in both |
| 38 | // release and debug mode. |
| 39 | // This macro should only be used by the macro RUNTIME_FUNCTION_LIST. |
| 40 | |
| 41 | // WARNING: RUNTIME_FUNCTION_LIST_ALWAYS_* is a very large macro that caused |
| 42 | // MSVC Intellisense to crash. It was broken into two macros to work around |
| 43 | // this problem. Please avoid large recursive macros whenever possible. |
| 44 | #define RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
| 45 | /* Property access */ \ |
| 46 | F(GetProperty, 2, 1) \ |
| 47 | F(KeyedGetProperty, 2, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 48 | F(DeleteProperty, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 49 | F(HasLocalProperty, 2, 1) \ |
| 50 | F(HasProperty, 2, 1) \ |
| 51 | F(HasElement, 2, 1) \ |
| 52 | F(IsPropertyEnumerable, 2, 1) \ |
| 53 | F(GetPropertyNames, 1, 1) \ |
| 54 | F(GetPropertyNamesFast, 1, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 55 | F(GetLocalPropertyNames, 1, 1) \ |
| 56 | F(GetLocalElementNames, 1, 1) \ |
| 57 | F(GetInterceptorInfo, 1, 1) \ |
| 58 | F(GetNamedInterceptorPropertyNames, 1, 1) \ |
| 59 | F(GetIndexedInterceptorElementNames, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 60 | F(GetArgumentsProperty, 1, 1) \ |
| 61 | F(ToFastProperties, 1, 1) \ |
| 62 | F(ToSlowProperties, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 63 | F(FinishArrayPrototypeSetup, 1, 1) \ |
| 64 | F(SpecialArrayFunctions, 1, 1) \ |
| 65 | F(GetGlobalReceiver, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 66 | \ |
| 67 | F(IsInPrototypeChain, 2, 1) \ |
| 68 | F(SetHiddenPrototype, 2, 1) \ |
| 69 | \ |
| 70 | F(IsConstructCall, 0, 1) \ |
| 71 | \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 72 | F(GetOwnProperty, 2, 1) \ |
| 73 | \ |
| 74 | F(IsExtensible, 1, 1) \ |
Steve Block | 8defd9f | 2010-07-08 12:39:36 +0100 | [diff] [blame] | 75 | F(PreventExtensions, 1, 1)\ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 76 | \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 77 | /* Utilities */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 78 | F(GetFunctionDelegate, 1, 1) \ |
| 79 | F(GetConstructorDelegate, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 80 | F(NewArgumentsFast, 3, 1) \ |
| 81 | F(LazyCompile, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 82 | F(LazyRecompile, 1, 1) \ |
| 83 | F(NotifyDeoptimized, 1, 1) \ |
| 84 | F(NotifyOSR, 0, 1) \ |
| 85 | F(DeoptimizeFunction, 1, 1) \ |
| 86 | F(CompileForOnStackReplacement, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 87 | F(SetNewFunctionAttributes, 1, 1) \ |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 88 | F(AllocateInNewSpace, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 89 | \ |
| 90 | /* Array join support */ \ |
| 91 | F(PushIfAbsent, 2, 1) \ |
| 92 | F(ArrayConcat, 1, 1) \ |
| 93 | \ |
| 94 | /* Conversions */ \ |
| 95 | F(ToBool, 1, 1) \ |
| 96 | F(Typeof, 1, 1) \ |
| 97 | \ |
| 98 | F(StringToNumber, 1, 1) \ |
| 99 | F(StringFromCharCodeArray, 1, 1) \ |
| 100 | F(StringParseInt, 2, 1) \ |
| 101 | F(StringParseFloat, 1, 1) \ |
| 102 | F(StringToLowerCase, 1, 1) \ |
| 103 | F(StringToUpperCase, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 104 | F(StringSplit, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 105 | F(CharFromCode, 1, 1) \ |
| 106 | F(URIEscape, 1, 1) \ |
| 107 | F(URIUnescape, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 108 | F(QuoteJSONString, 1, 1) \ |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 109 | F(QuoteJSONStringComma, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 110 | \ |
| 111 | F(NumberToString, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 112 | F(NumberToStringSkipCache, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 113 | F(NumberToInteger, 1, 1) \ |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 114 | F(NumberToIntegerMapMinusZero, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 115 | F(NumberToJSUint32, 1, 1) \ |
| 116 | F(NumberToJSInt32, 1, 1) \ |
| 117 | F(NumberToSmi, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 118 | F(AllocateHeapNumber, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 119 | \ |
| 120 | /* Arithmetic operations */ \ |
| 121 | F(NumberAdd, 2, 1) \ |
| 122 | F(NumberSub, 2, 1) \ |
| 123 | F(NumberMul, 2, 1) \ |
| 124 | F(NumberDiv, 2, 1) \ |
| 125 | F(NumberMod, 2, 1) \ |
| 126 | F(NumberUnaryMinus, 1, 1) \ |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 127 | F(NumberAlloc, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 128 | \ |
| 129 | F(StringAdd, 2, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 130 | F(StringBuilderConcat, 3, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 131 | F(StringBuilderJoin, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 132 | \ |
| 133 | /* Bit operations */ \ |
| 134 | F(NumberOr, 2, 1) \ |
| 135 | F(NumberAnd, 2, 1) \ |
| 136 | F(NumberXor, 2, 1) \ |
| 137 | F(NumberNot, 1, 1) \ |
| 138 | \ |
| 139 | F(NumberShl, 2, 1) \ |
| 140 | F(NumberShr, 2, 1) \ |
| 141 | F(NumberSar, 2, 1) \ |
| 142 | \ |
| 143 | /* Comparisons */ \ |
| 144 | F(NumberEquals, 2, 1) \ |
| 145 | F(StringEquals, 2, 1) \ |
| 146 | \ |
| 147 | F(NumberCompare, 3, 1) \ |
| 148 | F(SmiLexicographicCompare, 2, 1) \ |
| 149 | F(StringCompare, 2, 1) \ |
| 150 | \ |
| 151 | /* Math */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 152 | F(Math_acos, 1, 1) \ |
| 153 | F(Math_asin, 1, 1) \ |
| 154 | F(Math_atan, 1, 1) \ |
| 155 | F(Math_atan2, 2, 1) \ |
| 156 | F(Math_ceil, 1, 1) \ |
| 157 | F(Math_cos, 1, 1) \ |
| 158 | F(Math_exp, 1, 1) \ |
| 159 | F(Math_floor, 1, 1) \ |
| 160 | F(Math_log, 1, 1) \ |
| 161 | F(Math_pow, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 162 | F(Math_pow_cfunction, 2, 1) \ |
| 163 | F(RoundNumber, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 164 | F(Math_sin, 1, 1) \ |
| 165 | F(Math_sqrt, 1, 1) \ |
| 166 | F(Math_tan, 1, 1) \ |
| 167 | \ |
| 168 | /* Regular expressions */ \ |
| 169 | F(RegExpCompile, 3, 1) \ |
| 170 | F(RegExpExec, 4, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 171 | F(RegExpExecMultiple, 4, 1) \ |
| 172 | F(RegExpInitializeObject, 5, 1) \ |
| 173 | F(RegExpConstructResult, 3, 1) \ |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 174 | \ |
| 175 | /* JSON */ \ |
| 176 | F(ParseJson, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 177 | \ |
| 178 | /* Strings */ \ |
| 179 | F(StringCharCodeAt, 2, 1) \ |
| 180 | F(StringIndexOf, 3, 1) \ |
| 181 | F(StringLastIndexOf, 3, 1) \ |
| 182 | F(StringLocaleCompare, 2, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 183 | F(SubString, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 184 | F(StringReplaceRegExpWithString, 4, 1) \ |
| 185 | F(StringMatch, 3, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 186 | F(StringTrim, 3, 1) \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 187 | F(StringToArray, 2, 1) \ |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 188 | F(NewStringWrapper, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 189 | \ |
| 190 | /* Numbers */ \ |
| 191 | F(NumberToRadixString, 2, 1) \ |
| 192 | F(NumberToFixed, 2, 1) \ |
| 193 | F(NumberToExponential, 2, 1) \ |
| 194 | F(NumberToPrecision, 2, 1) |
| 195 | |
| 196 | #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 197 | /* Reflection */ \ |
| 198 | F(FunctionSetInstanceClassName, 2, 1) \ |
| 199 | F(FunctionSetLength, 2, 1) \ |
| 200 | F(FunctionSetPrototype, 2, 1) \ |
| 201 | F(FunctionGetName, 1, 1) \ |
| 202 | F(FunctionSetName, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 203 | F(FunctionRemovePrototype, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 204 | F(FunctionGetSourceCode, 1, 1) \ |
| 205 | F(FunctionGetScript, 1, 1) \ |
| 206 | F(FunctionGetScriptSourcePosition, 1, 1) \ |
| 207 | F(FunctionGetPositionForOffset, 2, 1) \ |
| 208 | F(FunctionIsAPIFunction, 1, 1) \ |
| 209 | F(FunctionIsBuiltin, 1, 1) \ |
| 210 | F(GetScript, 1, 1) \ |
| 211 | F(CollectStackTrace, 2, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 212 | F(GetV8Version, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 213 | \ |
| 214 | F(ClassOf, 1, 1) \ |
| 215 | F(SetCode, 2, 1) \ |
Kristian Monsen | 80d68ea | 2010-09-08 11:05:35 +0100 | [diff] [blame] | 216 | F(SetExpectedNumberOfProperties, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 217 | \ |
| 218 | F(CreateApiFunction, 1, 1) \ |
| 219 | F(IsTemplate, 1, 1) \ |
| 220 | F(GetTemplateField, 2, 1) \ |
| 221 | F(DisableAccessChecks, 1, 1) \ |
| 222 | F(EnableAccessChecks, 1, 1) \ |
| 223 | \ |
| 224 | /* Dates */ \ |
| 225 | F(DateCurrentTime, 0, 1) \ |
| 226 | F(DateParseString, 2, 1) \ |
| 227 | F(DateLocalTimezone, 1, 1) \ |
| 228 | F(DateLocalTimeOffset, 0, 1) \ |
| 229 | F(DateDaylightSavingsOffset, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 230 | F(DateMakeDay, 3, 1) \ |
| 231 | F(DateYMDFromTime, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 232 | \ |
| 233 | /* Numbers */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 234 | \ |
| 235 | /* Globals */ \ |
Teng-Hui Zhu | 3e5fa29 | 2010-11-09 16:16:48 -0800 | [diff] [blame] | 236 | F(CompileString, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 237 | F(GlobalPrint, 1, 1) \ |
| 238 | \ |
| 239 | /* Eval */ \ |
| 240 | F(GlobalReceiver, 1, 1) \ |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 241 | F(ResolvePossiblyDirectEval, 4, 2) \ |
| 242 | F(ResolvePossiblyDirectEvalNoLookup, 4, 2) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 243 | \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 244 | F(SetProperty, -1 /* 4 or 5 */, 1) \ |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 245 | F(DefineOrRedefineDataProperty, 4, 1) \ |
| 246 | F(DefineOrRedefineAccessorProperty, 5, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 247 | F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ |
| 248 | \ |
| 249 | /* Arrays */ \ |
| 250 | F(RemoveArrayHoles, 2, 1) \ |
| 251 | F(GetArrayKeys, 2, 1) \ |
| 252 | F(MoveArrayContents, 2, 1) \ |
| 253 | F(EstimateNumberOfElements, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 254 | F(SwapElements, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 255 | \ |
| 256 | /* Getters and Setters */ \ |
| 257 | F(DefineAccessor, -1 /* 4 or 5 */, 1) \ |
| 258 | F(LookupAccessor, 3, 1) \ |
| 259 | \ |
| 260 | /* Literals */ \ |
| 261 | F(MaterializeRegExpLiteral, 4, 1)\ |
| 262 | F(CreateArrayLiteralBoilerplate, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 263 | F(CloneLiteralBoilerplate, 1, 1) \ |
| 264 | F(CloneShallowLiteralBoilerplate, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 265 | F(CreateObjectLiteral, 4, 1) \ |
| 266 | F(CreateObjectLiteralShallow, 4, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 267 | F(CreateArrayLiteral, 3, 1) \ |
| 268 | F(CreateArrayLiteralShallow, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 269 | \ |
| 270 | /* Catch context extension objects */ \ |
| 271 | F(CreateCatchExtensionObject, 2, 1) \ |
| 272 | \ |
| 273 | /* Statements */ \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 274 | F(NewClosure, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 275 | F(NewObject, 1, 1) \ |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 276 | F(NewObjectFromBound, 2, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 277 | F(FinalizeInstanceSize, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 278 | F(Throw, 1, 1) \ |
| 279 | F(ReThrow, 1, 1) \ |
| 280 | F(ThrowReferenceError, 1, 1) \ |
Ben Murdoch | f87a203 | 2010-10-22 12:50:53 +0100 | [diff] [blame] | 281 | F(StackGuard, 0, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 282 | F(PromoteScheduledException, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 283 | \ |
| 284 | /* Contexts */ \ |
| 285 | F(NewContext, 1, 1) \ |
| 286 | F(PushContext, 1, 1) \ |
| 287 | F(PushCatchContext, 1, 1) \ |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 288 | F(DeleteContextSlot, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 289 | F(LoadContextSlot, 2, 2) \ |
| 290 | F(LoadContextSlotNoReferenceError, 2, 2) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 291 | F(StoreContextSlot, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 292 | \ |
| 293 | /* Declarations and initialization */ \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 294 | F(DeclareGlobals, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 295 | F(DeclareContextSlot, 4, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 296 | F(InitializeVarGlobal, -1 /* 2 or 3 */, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 297 | F(InitializeConstGlobal, 2, 1) \ |
| 298 | F(InitializeConstContextSlot, 3, 1) \ |
| 299 | F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 300 | \ |
| 301 | /* Debugging */ \ |
| 302 | F(DebugPrint, 1, 1) \ |
| 303 | F(DebugTrace, 0, 1) \ |
| 304 | F(TraceEnter, 0, 1) \ |
| 305 | F(TraceExit, 1, 1) \ |
| 306 | F(Abort, 2, 1) \ |
| 307 | /* Logging */ \ |
| 308 | F(Log, 2, 1) \ |
| 309 | /* ES5 */ \ |
| 310 | F(LocalKeys, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 311 | /* Cache suport */ \ |
| 312 | F(GetFromCache, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 313 | \ |
Steve Block | 1e0659c | 2011-05-24 12:43:12 +0100 | [diff] [blame] | 314 | /* Message objects */ \ |
| 315 | F(NewMessageObject, 2, 1) \ |
| 316 | F(MessageGetType, 1, 1) \ |
| 317 | F(MessageGetArguments, 1, 1) \ |
| 318 | F(MessageGetStartPosition, 1, 1) \ |
| 319 | F(MessageGetScript, 1, 1) \ |
| 320 | \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 321 | /* Pseudo functions - handled as macros by parser */ \ |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 322 | F(IS_VAR, 1, 1) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 323 | |
| 324 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 325 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 326 | /* Debugger support*/ \ |
| 327 | F(DebugBreak, 0, 1) \ |
| 328 | F(SetDebugEventListener, 2, 1) \ |
| 329 | F(Break, 0, 1) \ |
| 330 | F(DebugGetPropertyDetails, 2, 1) \ |
| 331 | F(DebugGetProperty, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 332 | F(DebugPropertyTypeFromDetails, 1, 1) \ |
| 333 | F(DebugPropertyAttributesFromDetails, 1, 1) \ |
| 334 | F(DebugPropertyIndexFromDetails, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 335 | F(DebugNamedInterceptorPropertyValue, 2, 1) \ |
| 336 | F(DebugIndexedInterceptorElementValue, 2, 1) \ |
| 337 | F(CheckExecutionState, 1, 1) \ |
| 338 | F(GetFrameCount, 1, 1) \ |
| 339 | F(GetFrameDetails, 2, 1) \ |
| 340 | F(GetScopeCount, 2, 1) \ |
| 341 | F(GetScopeDetails, 3, 1) \ |
| 342 | F(DebugPrintScopes, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 343 | F(GetThreadCount, 1, 1) \ |
| 344 | F(GetThreadDetails, 2, 1) \ |
Ben Murdoch | bb769b2 | 2010-08-11 14:56:33 +0100 | [diff] [blame] | 345 | F(SetDisableBreak, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 346 | F(GetBreakLocations, 1, 1) \ |
| 347 | F(SetFunctionBreakPoint, 3, 1) \ |
| 348 | F(SetScriptBreakPoint, 3, 1) \ |
| 349 | F(ClearBreakPoint, 1, 1) \ |
| 350 | F(ChangeBreakOnException, 2, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 351 | F(IsBreakOnException, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 352 | F(PrepareStep, 3, 1) \ |
| 353 | F(ClearStepping, 0, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 354 | F(DebugEvaluate, 5, 1) \ |
| 355 | F(DebugEvaluateGlobal, 4, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 356 | F(DebugGetLoadedScripts, 0, 1) \ |
| 357 | F(DebugReferencedBy, 3, 1) \ |
| 358 | F(DebugConstructedBy, 2, 1) \ |
| 359 | F(DebugGetPrototype, 1, 1) \ |
| 360 | F(SystemBreak, 0, 1) \ |
| 361 | F(DebugDisassembleFunction, 1, 1) \ |
| 362 | F(DebugDisassembleConstructor, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 363 | F(FunctionGetInferredName, 1, 1) \ |
| 364 | F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \ |
| 365 | F(LiveEditGatherCompileInfo, 2, 1) \ |
| 366 | F(LiveEditReplaceScript, 3, 1) \ |
| 367 | F(LiveEditReplaceFunctionCode, 2, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 368 | F(LiveEditFunctionSourceUpdated, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 369 | F(LiveEditFunctionSetScript, 2, 1) \ |
| 370 | F(LiveEditReplaceRefToNestedFunction, 3, 1) \ |
| 371 | F(LiveEditPatchFunctionPositions, 2, 1) \ |
| 372 | F(LiveEditCheckAndDropActivations, 2, 1) \ |
Ben Murdoch | b8e0da2 | 2011-05-16 14:20:40 +0100 | [diff] [blame] | 373 | F(LiveEditCompareStrings, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 374 | F(GetFunctionCodePositionFromSource, 2, 1) \ |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 375 | F(ExecuteInDebugContext, 2, 1) \ |
| 376 | \ |
| 377 | F(SetFlags, 1, 1) \ |
| 378 | F(CollectGarbage, 1, 1) \ |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 379 | F(GetHeapUsage, 0, 1) \ |
| 380 | \ |
| 381 | /* LiveObjectList support*/ \ |
| 382 | F(HasLOLEnabled, 0, 1) \ |
| 383 | F(CaptureLOL, 0, 1) \ |
| 384 | F(DeleteLOL, 1, 1) \ |
| 385 | F(DumpLOL, 5, 1) \ |
| 386 | F(GetLOLObj, 1, 1) \ |
| 387 | F(GetLOLObjId, 1, 1) \ |
| 388 | F(GetLOLObjRetainers, 6, 1) \ |
| 389 | F(GetLOLPath, 3, 1) \ |
| 390 | F(InfoLOL, 2, 1) \ |
| 391 | F(PrintLOLObj, 1, 1) \ |
| 392 | F(ResetLOL, 0, 1) \ |
| 393 | F(SummarizeLOL, 3, 1) |
Ben Murdoch | 086aeea | 2011-05-13 15:57:08 +0100 | [diff] [blame] | 394 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 395 | #else |
| 396 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) |
| 397 | #endif |
| 398 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 399 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 400 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) \ |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 401 | F(ProfilerResume, 2, 1) \ |
| 402 | F(ProfilerPause, 2, 1) |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 403 | #else |
| 404 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
| 405 | #endif |
| 406 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 407 | #ifdef DEBUG |
| 408 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
| 409 | /* Testing */ \ |
| 410 | F(ListNatives, 0, 1) |
| 411 | #else |
| 412 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) |
| 413 | #endif |
| 414 | |
| 415 | |
| 416 | // ---------------------------------------------------------------------------- |
| 417 | // RUNTIME_FUNCTION_LIST defines all runtime functions accessed |
| 418 | // either directly by id (via the code generator), or indirectly |
| 419 | // via a native call by name (from within JS code). |
| 420 | |
| 421 | #define RUNTIME_FUNCTION_LIST(F) \ |
| 422 | RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
| 423 | RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 424 | RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 425 | RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 426 | RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 427 | |
| 428 | // ---------------------------------------------------------------------------- |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 429 | // INLINE_FUNCTION_LIST defines all inlined functions accessed |
| 430 | // with a native call of the form %_name from within JS code. |
| 431 | // Entries have the form F(name, number of arguments, number of return values). |
| 432 | #define INLINE_FUNCTION_LIST(F) \ |
| 433 | F(IsSmi, 1, 1) \ |
| 434 | F(IsNonNegativeSmi, 1, 1) \ |
| 435 | F(IsArray, 1, 1) \ |
| 436 | F(IsRegExp, 1, 1) \ |
| 437 | F(CallFunction, -1 /* receiver + n args + function */, 1) \ |
| 438 | F(ArgumentsLength, 0, 1) \ |
| 439 | F(Arguments, 1, 1) \ |
| 440 | F(ValueOf, 1, 1) \ |
| 441 | F(SetValueOf, 2, 1) \ |
| 442 | F(StringCharFromCode, 1, 1) \ |
| 443 | F(StringCharAt, 2, 1) \ |
| 444 | F(ObjectEquals, 2, 1) \ |
| 445 | F(RandomHeapNumber, 0, 1) \ |
| 446 | F(IsObject, 1, 1) \ |
| 447 | F(IsFunction, 1, 1) \ |
| 448 | F(IsUndetectableObject, 1, 1) \ |
| 449 | F(IsSpecObject, 1, 1) \ |
| 450 | F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \ |
| 451 | F(MathPow, 2, 1) \ |
| 452 | F(MathSin, 1, 1) \ |
| 453 | F(MathCos, 1, 1) \ |
| 454 | F(MathSqrt, 1, 1) \ |
Ben Murdoch | b0fe162 | 2011-05-05 13:52:32 +0100 | [diff] [blame] | 455 | F(MathLog, 1, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 456 | F(IsRegExpEquivalent, 2, 1) \ |
| 457 | F(HasCachedArrayIndex, 1, 1) \ |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 458 | F(GetCachedArrayIndex, 1, 1) \ |
| 459 | F(FastAsciiArrayJoin, 2, 1) |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 460 | |
| 461 | |
| 462 | // ---------------------------------------------------------------------------- |
| 463 | // INLINE_AND_RUNTIME_FUNCTION_LIST defines all inlined functions accessed |
| 464 | // 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] | 465 | // a corresponding runtime function, that is called for slow cases. |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 466 | // Entries have the form F(name, number of arguments, number of return values). |
| 467 | #define INLINE_RUNTIME_FUNCTION_LIST(F) \ |
| 468 | F(IsConstructCall, 0, 1) \ |
| 469 | F(ClassOf, 1, 1) \ |
| 470 | F(StringCharCodeAt, 2, 1) \ |
| 471 | F(Log, 3, 1) \ |
| 472 | F(StringAdd, 2, 1) \ |
| 473 | F(SubString, 3, 1) \ |
| 474 | F(StringCompare, 2, 1) \ |
| 475 | F(RegExpExec, 4, 1) \ |
| 476 | F(RegExpConstructResult, 3, 1) \ |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 477 | F(GetFromCache, 2, 1) \ |
| 478 | F(NumberToString, 1, 1) \ |
| 479 | F(SwapElements, 3, 1) |
| 480 | |
| 481 | |
| 482 | //--------------------------------------------------------------------------- |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 483 | // Runtime provides access to all C++ runtime functions. |
| 484 | |
| 485 | class Runtime : public AllStatic { |
| 486 | public: |
| 487 | enum FunctionId { |
| 488 | #define F(name, nargs, ressize) k##name, |
| 489 | RUNTIME_FUNCTION_LIST(F) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 490 | #undef F |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 491 | #define F(name, nargs, ressize) kInline##name, |
| 492 | INLINE_FUNCTION_LIST(F) |
| 493 | INLINE_RUNTIME_FUNCTION_LIST(F) |
| 494 | #undef F |
| 495 | kNumFunctions, |
| 496 | kFirstInlineFunction = kInlineIsSmi |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 497 | }; |
| 498 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 499 | enum IntrinsicType { |
| 500 | RUNTIME, |
| 501 | INLINE |
| 502 | }; |
| 503 | |
| 504 | // Intrinsic function descriptor. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 505 | struct Function { |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 506 | FunctionId function_id; |
| 507 | IntrinsicType intrinsic_type; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 508 | // The JS name of the function. |
| 509 | const char* name; |
| 510 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 511 | // The C++ (native) entry point. NULL if the function is inlined. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 512 | byte* entry; |
| 513 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 514 | // The number of arguments expected. nargs is -1 if the function takes |
| 515 | // a variable number of arguments. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 516 | int nargs; |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 517 | // Size of result. Most functions return a single pointer, size 1. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 518 | int result_size; |
| 519 | }; |
| 520 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 521 | static const int kNotFound = -1; |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 522 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 523 | // Add symbols for all the intrinsic function names to a StringDictionary. |
| 524 | // Returns failure if an allocation fails. In this case, it must be |
| 525 | // retried with a new, empty StringDictionary, not with the same one. |
| 526 | // Alternatively, heap initialization can be completely restarted. |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 527 | MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames( |
| 528 | Object* dictionary); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 529 | |
Kristian Monsen | 0d5e116 | 2010-09-30 15:31:59 +0100 | [diff] [blame] | 530 | // Get the intrinsic function with the given name, which must be a symbol. |
| 531 | static Function* FunctionForSymbol(Handle<String> name); |
| 532 | |
| 533 | // Get the intrinsic function with the given FunctionId. |
| 534 | static Function* FunctionForId(FunctionId id); |
| 535 | |
| 536 | // General-purpose helper functions for runtime system. |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 537 | static int StringMatch(Handle<String> sub, Handle<String> pat, int index); |
| 538 | |
| 539 | static bool IsUpperCaseChar(uint16_t ch); |
| 540 | |
| 541 | // TODO(1240886): The following three methods are *not* handle safe, |
| 542 | // but accept handle arguments. This seems fragile. |
| 543 | |
| 544 | // Support getting the characters in a string using [] notation as |
| 545 | // in Firefox/SpiderMonkey, Safari and Opera. |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 546 | MUST_USE_RESULT static MaybeObject* GetElementOrCharAt(Handle<Object> object, |
| 547 | uint32_t index); |
| 548 | MUST_USE_RESULT static MaybeObject* GetElement(Handle<Object> object, |
| 549 | uint32_t index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 550 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 551 | MUST_USE_RESULT static MaybeObject* SetObjectProperty( |
| 552 | Handle<Object> object, |
| 553 | Handle<Object> key, |
| 554 | Handle<Object> value, |
Ben Murdoch | e0cee9b | 2011-05-25 10:26:03 +0100 | [diff] [blame^] | 555 | PropertyAttributes attr, |
| 556 | StrictModeFlag strict_mode); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 557 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 558 | MUST_USE_RESULT static MaybeObject* ForceSetObjectProperty( |
| 559 | Handle<JSObject> object, |
| 560 | Handle<Object> key, |
| 561 | Handle<Object> value, |
| 562 | PropertyAttributes attr); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 563 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 564 | MUST_USE_RESULT static MaybeObject* ForceDeleteObjectProperty( |
| 565 | Handle<JSObject> object, |
| 566 | Handle<Object> key); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 567 | |
John Reck | 5913587 | 2010-11-02 12:39:01 -0700 | [diff] [blame] | 568 | MUST_USE_RESULT static MaybeObject* GetObjectProperty(Handle<Object> object, |
| 569 | Handle<Object> key); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 570 | |
| 571 | // This function is used in FunctionNameUsing* tests. |
| 572 | static Object* FindSharedFunctionInfoInScript(Handle<Script> script, |
| 573 | int position); |
| 574 | |
| 575 | // Helper functions used stubs. |
| 576 | static void PerformGC(Object* result); |
| 577 | }; |
| 578 | |
| 579 | |
| 580 | } } // namespace v8::internal |
| 581 | |
| 582 | #endif // V8_RUNTIME_H_ |