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