Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 1 | // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 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) \ |
| 82 | F(SetNewFunctionAttributes, 1, 1) \ |
| 83 | \ |
| 84 | /* Array join support */ \ |
| 85 | F(PushIfAbsent, 2, 1) \ |
| 86 | F(ArrayConcat, 1, 1) \ |
| 87 | \ |
| 88 | /* Conversions */ \ |
| 89 | F(ToBool, 1, 1) \ |
| 90 | F(Typeof, 1, 1) \ |
| 91 | \ |
| 92 | F(StringToNumber, 1, 1) \ |
| 93 | F(StringFromCharCodeArray, 1, 1) \ |
| 94 | F(StringParseInt, 2, 1) \ |
| 95 | F(StringParseFloat, 1, 1) \ |
| 96 | F(StringToLowerCase, 1, 1) \ |
| 97 | F(StringToUpperCase, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 98 | F(StringSplit, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 99 | F(CharFromCode, 1, 1) \ |
| 100 | F(URIEscape, 1, 1) \ |
| 101 | F(URIUnescape, 1, 1) \ |
| 102 | \ |
| 103 | F(NumberToString, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 104 | F(NumberToStringSkipCache, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 105 | F(NumberToInteger, 1, 1) \ |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 106 | F(NumberToIntegerMapMinusZero, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 107 | F(NumberToJSUint32, 1, 1) \ |
| 108 | F(NumberToJSInt32, 1, 1) \ |
| 109 | F(NumberToSmi, 1, 1) \ |
| 110 | \ |
| 111 | /* Arithmetic operations */ \ |
| 112 | F(NumberAdd, 2, 1) \ |
| 113 | F(NumberSub, 2, 1) \ |
| 114 | F(NumberMul, 2, 1) \ |
| 115 | F(NumberDiv, 2, 1) \ |
| 116 | F(NumberMod, 2, 1) \ |
| 117 | F(NumberUnaryMinus, 1, 1) \ |
Ben Murdoch | 3bec4d2 | 2010-07-22 14:51:16 +0100 | [diff] [blame] | 118 | F(NumberAlloc, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 119 | \ |
| 120 | F(StringAdd, 2, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 121 | F(StringBuilderConcat, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 122 | \ |
| 123 | /* Bit operations */ \ |
| 124 | F(NumberOr, 2, 1) \ |
| 125 | F(NumberAnd, 2, 1) \ |
| 126 | F(NumberXor, 2, 1) \ |
| 127 | F(NumberNot, 1, 1) \ |
| 128 | \ |
| 129 | F(NumberShl, 2, 1) \ |
| 130 | F(NumberShr, 2, 1) \ |
| 131 | F(NumberSar, 2, 1) \ |
| 132 | \ |
| 133 | /* Comparisons */ \ |
| 134 | F(NumberEquals, 2, 1) \ |
| 135 | F(StringEquals, 2, 1) \ |
| 136 | \ |
| 137 | F(NumberCompare, 3, 1) \ |
| 138 | F(SmiLexicographicCompare, 2, 1) \ |
| 139 | F(StringCompare, 2, 1) \ |
| 140 | \ |
| 141 | /* Math */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 142 | F(Math_acos, 1, 1) \ |
| 143 | F(Math_asin, 1, 1) \ |
| 144 | F(Math_atan, 1, 1) \ |
| 145 | F(Math_atan2, 2, 1) \ |
| 146 | F(Math_ceil, 1, 1) \ |
| 147 | F(Math_cos, 1, 1) \ |
| 148 | F(Math_exp, 1, 1) \ |
| 149 | F(Math_floor, 1, 1) \ |
| 150 | F(Math_log, 1, 1) \ |
| 151 | F(Math_pow, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 152 | F(Math_pow_cfunction, 2, 1) \ |
| 153 | F(RoundNumber, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 154 | F(Math_sin, 1, 1) \ |
| 155 | F(Math_sqrt, 1, 1) \ |
| 156 | F(Math_tan, 1, 1) \ |
| 157 | \ |
| 158 | /* Regular expressions */ \ |
| 159 | F(RegExpCompile, 3, 1) \ |
| 160 | F(RegExpExec, 4, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 161 | F(RegExpExecMultiple, 4, 1) \ |
| 162 | F(RegExpInitializeObject, 5, 1) \ |
| 163 | F(RegExpConstructResult, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 164 | \ |
| 165 | /* Strings */ \ |
| 166 | F(StringCharCodeAt, 2, 1) \ |
| 167 | F(StringIndexOf, 3, 1) \ |
| 168 | F(StringLastIndexOf, 3, 1) \ |
| 169 | F(StringLocaleCompare, 2, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 170 | F(SubString, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 171 | F(StringReplaceRegExpWithString, 4, 1) \ |
| 172 | F(StringMatch, 3, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 173 | F(StringTrim, 3, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 174 | F(StringToArray, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 175 | \ |
| 176 | /* Numbers */ \ |
| 177 | F(NumberToRadixString, 2, 1) \ |
| 178 | F(NumberToFixed, 2, 1) \ |
| 179 | F(NumberToExponential, 2, 1) \ |
| 180 | F(NumberToPrecision, 2, 1) |
| 181 | |
| 182 | #define RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 183 | /* Reflection */ \ |
| 184 | F(FunctionSetInstanceClassName, 2, 1) \ |
| 185 | F(FunctionSetLength, 2, 1) \ |
| 186 | F(FunctionSetPrototype, 2, 1) \ |
| 187 | F(FunctionGetName, 1, 1) \ |
| 188 | F(FunctionSetName, 2, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 189 | F(FunctionRemovePrototype, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 190 | F(FunctionGetSourceCode, 1, 1) \ |
| 191 | F(FunctionGetScript, 1, 1) \ |
| 192 | F(FunctionGetScriptSourcePosition, 1, 1) \ |
| 193 | F(FunctionGetPositionForOffset, 2, 1) \ |
| 194 | F(FunctionIsAPIFunction, 1, 1) \ |
| 195 | F(FunctionIsBuiltin, 1, 1) \ |
| 196 | F(GetScript, 1, 1) \ |
| 197 | F(CollectStackTrace, 2, 1) \ |
Steve Block | 3ce2e20 | 2009-11-05 08:53:23 +0000 | [diff] [blame] | 198 | F(GetV8Version, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 199 | \ |
| 200 | F(ClassOf, 1, 1) \ |
| 201 | F(SetCode, 2, 1) \ |
| 202 | \ |
| 203 | F(CreateApiFunction, 1, 1) \ |
| 204 | F(IsTemplate, 1, 1) \ |
| 205 | F(GetTemplateField, 2, 1) \ |
| 206 | F(DisableAccessChecks, 1, 1) \ |
| 207 | F(EnableAccessChecks, 1, 1) \ |
| 208 | \ |
| 209 | /* Dates */ \ |
| 210 | F(DateCurrentTime, 0, 1) \ |
| 211 | F(DateParseString, 2, 1) \ |
| 212 | F(DateLocalTimezone, 1, 1) \ |
| 213 | F(DateLocalTimeOffset, 0, 1) \ |
| 214 | F(DateDaylightSavingsOffset, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 215 | F(DateMakeDay, 3, 1) \ |
| 216 | F(DateYMDFromTime, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 217 | \ |
| 218 | /* Numbers */ \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 219 | \ |
| 220 | /* Globals */ \ |
| 221 | F(CompileString, 2, 1) \ |
| 222 | F(GlobalPrint, 1, 1) \ |
| 223 | \ |
| 224 | /* Eval */ \ |
| 225 | F(GlobalReceiver, 1, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 226 | F(ResolvePossiblyDirectEval, 3, 2) \ |
Ben Murdoch | 7f4d5bd | 2010-06-15 11:15:29 +0100 | [diff] [blame] | 227 | F(ResolvePossiblyDirectEvalNoLookup, 3, 2) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 228 | \ |
| 229 | F(SetProperty, -1 /* 3 or 4 */, 1) \ |
Andrei Popescu | 3100271 | 2010-02-23 13:46:05 +0000 | [diff] [blame] | 230 | F(DefineOrRedefineDataProperty, 4, 1) \ |
| 231 | F(DefineOrRedefineAccessorProperty, 5, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 232 | F(IgnoreAttributesAndSetProperty, -1 /* 3 or 4 */, 1) \ |
| 233 | \ |
| 234 | /* Arrays */ \ |
| 235 | F(RemoveArrayHoles, 2, 1) \ |
| 236 | F(GetArrayKeys, 2, 1) \ |
| 237 | F(MoveArrayContents, 2, 1) \ |
| 238 | F(EstimateNumberOfElements, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 239 | F(SwapElements, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 240 | \ |
| 241 | /* Getters and Setters */ \ |
| 242 | F(DefineAccessor, -1 /* 4 or 5 */, 1) \ |
| 243 | F(LookupAccessor, 3, 1) \ |
| 244 | \ |
| 245 | /* Literals */ \ |
| 246 | F(MaterializeRegExpLiteral, 4, 1)\ |
| 247 | F(CreateArrayLiteralBoilerplate, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 248 | F(CloneLiteralBoilerplate, 1, 1) \ |
| 249 | F(CloneShallowLiteralBoilerplate, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 250 | F(CreateObjectLiteral, 4, 1) \ |
| 251 | F(CreateObjectLiteralShallow, 4, 1) \ |
Leon Clarke | e46be81 | 2010-01-19 14:06:41 +0000 | [diff] [blame] | 252 | F(CreateArrayLiteral, 3, 1) \ |
| 253 | F(CreateArrayLiteralShallow, 3, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 254 | \ |
| 255 | /* Catch context extension objects */ \ |
| 256 | F(CreateCatchExtensionObject, 2, 1) \ |
| 257 | \ |
| 258 | /* Statements */ \ |
| 259 | F(NewClosure, 2, 1) \ |
| 260 | F(NewObject, 1, 1) \ |
Kristian Monsen | 50ef84f | 2010-07-29 15:18:00 +0100 | [diff] [blame] | 261 | F(NewObjectFromBound, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 262 | F(Throw, 1, 1) \ |
| 263 | F(ReThrow, 1, 1) \ |
| 264 | F(ThrowReferenceError, 1, 1) \ |
| 265 | F(StackGuard, 1, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 266 | F(PromoteScheduledException, 0, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 267 | \ |
| 268 | /* Contexts */ \ |
| 269 | F(NewContext, 1, 1) \ |
| 270 | F(PushContext, 1, 1) \ |
| 271 | F(PushCatchContext, 1, 1) \ |
| 272 | F(LookupContext, 2, 1) \ |
| 273 | F(LoadContextSlot, 2, 2) \ |
| 274 | F(LoadContextSlotNoReferenceError, 2, 2) \ |
| 275 | F(StoreContextSlot, 3, 1) \ |
| 276 | \ |
| 277 | /* Declarations and initialization */ \ |
| 278 | F(DeclareGlobals, 3, 1) \ |
| 279 | F(DeclareContextSlot, 4, 1) \ |
| 280 | F(InitializeVarGlobal, -1 /* 1 or 2 */, 1) \ |
| 281 | F(InitializeConstGlobal, 2, 1) \ |
| 282 | F(InitializeConstContextSlot, 3, 1) \ |
| 283 | F(OptimizeObjectForAddingMultipleProperties, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 284 | \ |
| 285 | /* Debugging */ \ |
| 286 | F(DebugPrint, 1, 1) \ |
| 287 | F(DebugTrace, 0, 1) \ |
| 288 | F(TraceEnter, 0, 1) \ |
| 289 | F(TraceExit, 1, 1) \ |
| 290 | F(Abort, 2, 1) \ |
| 291 | /* Logging */ \ |
| 292 | F(Log, 2, 1) \ |
| 293 | /* ES5 */ \ |
| 294 | F(LocalKeys, 1, 1) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 295 | /* Handle scopes */ \ |
| 296 | F(DeleteHandleScopeExtensions, 0, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 297 | /* Cache suport */ \ |
| 298 | F(GetFromCache, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 299 | \ |
| 300 | /* Pseudo functions - handled as macros by parser */ \ |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 301 | F(IS_VAR, 1, 1) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 302 | |
| 303 | #ifdef ENABLE_DEBUGGER_SUPPORT |
| 304 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 305 | /* Debugger support*/ \ |
| 306 | F(DebugBreak, 0, 1) \ |
| 307 | F(SetDebugEventListener, 2, 1) \ |
| 308 | F(Break, 0, 1) \ |
| 309 | F(DebugGetPropertyDetails, 2, 1) \ |
| 310 | F(DebugGetProperty, 2, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 311 | F(DebugPropertyTypeFromDetails, 1, 1) \ |
| 312 | F(DebugPropertyAttributesFromDetails, 1, 1) \ |
| 313 | F(DebugPropertyIndexFromDetails, 1, 1) \ |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 314 | F(DebugNamedInterceptorPropertyValue, 2, 1) \ |
| 315 | F(DebugIndexedInterceptorElementValue, 2, 1) \ |
| 316 | F(CheckExecutionState, 1, 1) \ |
| 317 | F(GetFrameCount, 1, 1) \ |
| 318 | F(GetFrameDetails, 2, 1) \ |
| 319 | F(GetScopeCount, 2, 1) \ |
| 320 | F(GetScopeDetails, 3, 1) \ |
| 321 | F(DebugPrintScopes, 0, 1) \ |
| 322 | F(GetCFrames, 1, 1) \ |
| 323 | F(GetThreadCount, 1, 1) \ |
| 324 | F(GetThreadDetails, 2, 1) \ |
| 325 | F(GetBreakLocations, 1, 1) \ |
| 326 | F(SetFunctionBreakPoint, 3, 1) \ |
| 327 | F(SetScriptBreakPoint, 3, 1) \ |
| 328 | F(ClearBreakPoint, 1, 1) \ |
| 329 | F(ChangeBreakOnException, 2, 1) \ |
| 330 | F(PrepareStep, 3, 1) \ |
| 331 | F(ClearStepping, 0, 1) \ |
| 332 | F(DebugEvaluate, 4, 1) \ |
| 333 | F(DebugEvaluateGlobal, 3, 1) \ |
| 334 | F(DebugGetLoadedScripts, 0, 1) \ |
| 335 | F(DebugReferencedBy, 3, 1) \ |
| 336 | F(DebugConstructedBy, 2, 1) \ |
| 337 | F(DebugGetPrototype, 1, 1) \ |
| 338 | F(SystemBreak, 0, 1) \ |
| 339 | F(DebugDisassembleFunction, 1, 1) \ |
| 340 | F(DebugDisassembleConstructor, 1, 1) \ |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 341 | F(FunctionGetInferredName, 1, 1) \ |
| 342 | F(LiveEditFindSharedFunctionInfosForScript, 1, 1) \ |
| 343 | F(LiveEditGatherCompileInfo, 2, 1) \ |
| 344 | F(LiveEditReplaceScript, 3, 1) \ |
| 345 | F(LiveEditReplaceFunctionCode, 2, 1) \ |
| 346 | F(LiveEditFunctionSetScript, 2, 1) \ |
| 347 | F(LiveEditReplaceRefToNestedFunction, 3, 1) \ |
| 348 | F(LiveEditPatchFunctionPositions, 2, 1) \ |
| 349 | F(LiveEditCheckAndDropActivations, 2, 1) \ |
| 350 | F(LiveEditCompareStringsLinewise, 2, 1) \ |
| 351 | F(GetFunctionCodePositionFromSource, 2, 1) \ |
| 352 | F(ExecuteInDebugContext, 2, 1) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 353 | #else |
| 354 | #define RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) |
| 355 | #endif |
| 356 | |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 357 | #ifdef ENABLE_LOGGING_AND_PROFILING |
| 358 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) \ |
Andrei Popescu | 402d937 | 2010-02-26 13:31:12 +0000 | [diff] [blame] | 359 | F(ProfilerResume, 2, 1) \ |
| 360 | F(ProfilerPause, 2, 1) |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 361 | #else |
| 362 | #define RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
| 363 | #endif |
| 364 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 365 | #ifdef DEBUG |
| 366 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
| 367 | /* Testing */ \ |
| 368 | F(ListNatives, 0, 1) |
| 369 | #else |
| 370 | #define RUNTIME_FUNCTION_LIST_DEBUG(F) |
| 371 | #endif |
| 372 | |
| 373 | |
| 374 | // ---------------------------------------------------------------------------- |
| 375 | // RUNTIME_FUNCTION_LIST defines all runtime functions accessed |
| 376 | // either directly by id (via the code generator), or indirectly |
| 377 | // via a native call by name (from within JS code). |
| 378 | |
| 379 | #define RUNTIME_FUNCTION_LIST(F) \ |
| 380 | RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ |
| 381 | RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ |
| 382 | RUNTIME_FUNCTION_LIST_DEBUG(F) \ |
Steve Block | d0582a6 | 2009-12-15 09:54:21 +0000 | [diff] [blame] | 383 | RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ |
| 384 | RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 385 | |
| 386 | // ---------------------------------------------------------------------------- |
| 387 | // Runtime provides access to all C++ runtime functions. |
| 388 | |
| 389 | class Runtime : public AllStatic { |
| 390 | public: |
| 391 | enum FunctionId { |
| 392 | #define F(name, nargs, ressize) k##name, |
| 393 | RUNTIME_FUNCTION_LIST(F) |
| 394 | kNofFunctions |
| 395 | #undef F |
| 396 | }; |
| 397 | |
| 398 | // Runtime function descriptor. |
| 399 | struct Function { |
| 400 | // The JS name of the function. |
| 401 | const char* name; |
| 402 | |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 403 | // The C++ (native) entry point. |
| 404 | byte* entry; |
| 405 | |
| 406 | // The number of arguments expected; nargs < 0 if variable no. of |
| 407 | // arguments. |
| 408 | int nargs; |
| 409 | int stub_id; |
| 410 | // Size of result, if complex (larger than a single pointer), |
| 411 | // otherwise zero. |
| 412 | int result_size; |
| 413 | }; |
| 414 | |
| 415 | // Get the runtime function with the given function id. |
| 416 | static Function* FunctionForId(FunctionId fid); |
| 417 | |
| 418 | // Get the runtime function with the given name. |
| 419 | static Function* FunctionForName(const char* name); |
| 420 | |
| 421 | static int StringMatch(Handle<String> sub, Handle<String> pat, int index); |
| 422 | |
| 423 | static bool IsUpperCaseChar(uint16_t ch); |
| 424 | |
| 425 | // TODO(1240886): The following three methods are *not* handle safe, |
| 426 | // but accept handle arguments. This seems fragile. |
| 427 | |
| 428 | // Support getting the characters in a string using [] notation as |
| 429 | // in Firefox/SpiderMonkey, Safari and Opera. |
| 430 | static Object* GetElementOrCharAt(Handle<Object> object, uint32_t index); |
Steve Block | 6ded16b | 2010-05-10 14:33:55 +0100 | [diff] [blame] | 431 | static Object* GetElement(Handle<Object> object, uint32_t index); |
Steve Block | a7e24c1 | 2009-10-30 11:49:00 +0000 | [diff] [blame] | 432 | |
| 433 | static Object* SetObjectProperty(Handle<Object> object, |
| 434 | Handle<Object> key, |
| 435 | Handle<Object> value, |
| 436 | PropertyAttributes attr); |
| 437 | |
| 438 | static Object* ForceSetObjectProperty(Handle<JSObject> object, |
| 439 | Handle<Object> key, |
| 440 | Handle<Object> value, |
| 441 | PropertyAttributes attr); |
| 442 | |
| 443 | static Object* ForceDeleteObjectProperty(Handle<JSObject> object, |
| 444 | Handle<Object> key); |
| 445 | |
| 446 | static Object* GetObjectProperty(Handle<Object> object, Handle<Object> key); |
| 447 | |
| 448 | // This function is used in FunctionNameUsing* tests. |
| 449 | static Object* FindSharedFunctionInfoInScript(Handle<Script> script, |
| 450 | int position); |
| 451 | |
| 452 | // Helper functions used stubs. |
| 453 | static void PerformGC(Object* result); |
| 454 | }; |
| 455 | |
| 456 | |
| 457 | } } // namespace v8::internal |
| 458 | |
| 459 | #endif // V8_RUNTIME_H_ |