00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef V8_RUNTIME_H_
00029 #define V8_RUNTIME_H_
00030
00031 namespace v8 { namespace internal {
00032
00033
00034
00035
00036
00037
00038
00039
00040 #define RUNTIME_FUNCTION_LIST_ALWAYS(F) \
00041 \
00042 F(GetProperty, 2) \
00043 F(KeyedGetProperty, 2) \
00044 F(DeleteProperty, 2) \
00045 F(HasLocalProperty, 2) \
00046 F(HasProperty, 2) \
00047 F(HasElement, 2) \
00048 F(IsPropertyEnumerable, 2) \
00049 F(GetPropertyNames, 1) \
00050 F(GetPropertyNamesFast, 1) \
00051 F(GetArgumentsProperty, 1) \
00052 \
00053 F(IsInPrototypeChain, 2) \
00054 \
00055 F(IsConstructCall, 0) \
00056 \
00057 \
00058 F(GetCalledFunction, 0) \
00059 F(GetFunctionDelegate, 1) \
00060 F(NewArguments, 1) \
00061 F(NewArgumentsFast, 3) \
00062 F(LazyCompile, 1) \
00063 F(SetNewFunctionAttributes, 1) \
00064 \
00065 \
00066 F(PushIfAbsent, 2) \
00067 F(ArrayConcat, 1) \
00068 \
00069 \
00070 F(ConsStringFst, 1) \
00071 F(ConsStringSnd, 1) \
00072 \
00073 \
00074 F(ToBool, 1) \
00075 F(Typeof, 1) \
00076 \
00077 F(StringToNumber, 1) \
00078 F(StringFromCharCodeArray, 1) \
00079 F(StringParseInt, 2) \
00080 F(StringParseFloat, 1) \
00081 F(StringToLowerCase, 1) \
00082 F(StringToUpperCase, 1) \
00083 F(CharFromCode, 1) \
00084 F(URIEscape, 1) \
00085 F(URIUnescape, 1) \
00086 \
00087 F(NumberToString, 1) \
00088 F(NumberToInteger, 1) \
00089 F(NumberToJSUint32, 1) \
00090 F(NumberToJSInt32, 1) \
00091 \
00092 \
00093 F(NumberAdd, 2) \
00094 F(NumberSub, 2) \
00095 F(NumberMul, 2) \
00096 F(NumberDiv, 2) \
00097 F(NumberMod, 2) \
00098 F(NumberUnaryMinus, 1) \
00099 \
00100 F(StringAdd, 2) \
00101 F(StringBuilderConcat, 2) \
00102 \
00103 \
00104 F(NumberOr, 2) \
00105 F(NumberAnd, 2) \
00106 F(NumberXor, 2) \
00107 F(NumberNot, 1) \
00108 \
00109 F(NumberShl, 2) \
00110 F(NumberShr, 2) \
00111 F(NumberSar, 2) \
00112 \
00113 \
00114 F(NumberEquals, 2) \
00115 F(StringEquals, 2) \
00116 \
00117 F(NumberCompare, 3) \
00118 F(SmiLexicographicCompare, 2) \
00119 F(StringCompare, 2) \
00120 \
00121 \
00122 F(Math_abs, 1) \
00123 F(Math_acos, 1) \
00124 F(Math_asin, 1) \
00125 F(Math_atan, 1) \
00126 F(Math_atan2, 2) \
00127 F(Math_ceil, 1) \
00128 F(Math_cos, 1) \
00129 F(Math_exp, 1) \
00130 F(Math_floor, 1) \
00131 F(Math_log, 1) \
00132 F(Math_pow, 2) \
00133 F(Math_random, 0) \
00134 F(Math_round, 1) \
00135 F(Math_sin, 1) \
00136 F(Math_sqrt, 1) \
00137 F(Math_tan, 1) \
00138 \
00139 \
00140 F(RegExpCompile, 3) \
00141 F(RegExpExec, 3) \
00142 F(RegExpExecGlobal, 2) \
00143 \
00144 \
00145 F(StringCharCodeAt, 2) \
00146 F(StringIndexOf, 3) \
00147 F(StringLastIndexOf, 3) \
00148 F(StringLocaleCompare, 2) \
00149 F(StringSlice, 3) \
00150 \
00151 \
00152 F(NumberToRadixString, 2) \
00153 F(NumberToFixed, 2) \
00154 F(NumberToExponential, 2) \
00155 F(NumberToPrecision, 2) \
00156 \
00157 \
00158 F(FunctionSetInstanceClassName, 2) \
00159 F(FunctionSetLength, 2) \
00160 F(FunctionSetPrototype, 2) \
00161 F(FunctionGetName, 1) \
00162 F(FunctionSetName, 2) \
00163 F(FunctionGetSourceCode, 1) \
00164 F(FunctionGetScript, 1) \
00165 F(FunctionGetScriptSourcePosition, 1) \
00166 F(GetScript, 1) \
00167 \
00168 F(ClassOf, 1) \
00169 F(HasDateClass, 1) \
00170 F(HasStringClass, 1) \
00171 F(HasArrayClass, 1) \
00172 F(HasFunctionClass, 1) \
00173 F(HasNumberClass, 1) \
00174 F(HasBooleanClass, 1) \
00175 F(HasArgumentsClass, 1) \
00176 F(HasRegExpClass, 1) \
00177 F(SetCode, 2) \
00178 \
00179 F(CreateApiFunction, 1) \
00180 F(IsTemplate, 1) \
00181 F(GetTemplateField, 2) \
00182 \
00183 \
00184 F(DateCurrentTime, 0) \
00185 F(DateParseString, 1) \
00186 F(DateLocalTimezone, 1) \
00187 F(DateLocalTimeOffset, 0) \
00188 F(DateDaylightSavingsOffset, 1) \
00189 \
00190 \
00191 F(NumberIsFinite, 1) \
00192 \
00193 \
00194 F(CompileString, 3) \
00195 F(CompileScript, 4) \
00196 F(GlobalPrint, 1) \
00197 \
00198 \
00199 F(EvalReceiver, 1) \
00200 F(GlobalReceiver, 1) \
00201 \
00202 F(SetProperty, -1 ) \
00203 F(IgnoreAttributesAndSetProperty, -1 ) \
00204 \
00205 \
00206 F(RemoveArrayHoles, 1) \
00207 F(GetArrayKeys, 2) \
00208 F(MoveArrayContents, 2) \
00209 F(EstimateNumberOfElements, 1) \
00210 \
00211 \
00212 F(DefineAccessor, -1 ) \
00213 F(LookupAccessor, 3) \
00214 \
00215 \
00216 F(AddDebugEventListener, 2) \
00217 F(RemoveDebugEventListener, 1) \
00218 F(Break, 0) \
00219 F(DebugGetPropertyDetails, 2) \
00220 F(DebugGetProperty, 2) \
00221 F(DebugLocalPropertyNames, 1) \
00222 F(DebugLocalElementNames, 1) \
00223 F(DebugPropertyTypeFromDetails, 1) \
00224 F(DebugPropertyAttributesFromDetails, 1) \
00225 F(DebugPropertyIndexFromDetails, 1) \
00226 F(DebugInterceptorInfo, 1) \
00227 F(DebugNamedInterceptorPropertyNames, 1) \
00228 F(DebugIndexedInterceptorElementNames, 1) \
00229 F(DebugNamedInterceptorPropertyValue, 2) \
00230 F(DebugIndexedInterceptorElementValue, 2) \
00231 F(CheckExecutionState, 1) \
00232 F(GetFrameCount, 1) \
00233 F(GetFrameDetails, 2) \
00234 F(GetCFrames, 1) \
00235 F(GetBreakLocations, 1) \
00236 F(SetFunctionBreakPoint, 3) \
00237 F(SetScriptBreakPoint, 3) \
00238 F(ClearBreakPoint, 1) \
00239 F(ChangeBreakOnException, 2) \
00240 F(PrepareStep, 3) \
00241 F(ClearStepping, 0) \
00242 F(DebugEvaluate, 4) \
00243 F(DebugEvaluateGlobal, 3) \
00244 F(DebugGetLoadedScripts, 0) \
00245 F(DebugReferencedBy, 3) \
00246 F(DebugConstructedBy, 2) \
00247 F(GetPrototype, 1) \
00248 F(SystemBreak, 0) \
00249 \
00250 \
00251 F(MaterializeRegExpLiteral, 4)\
00252 F(CreateArrayLiteral, 2) \
00253 F(CreateObjectLiteralBoilerplate, 3) \
00254 F(CloneObjectLiteralBoilerplate, 1) \
00255 \
00256 \
00257 F(NewClosure, 2) \
00258 F(NewObject, 1) \
00259 F(Throw, 1) \
00260 F(ReThrow, 1) \
00261 F(ThrowReferenceError, 1) \
00262 F(StackGuard, 1) \
00263 \
00264 \
00265 F(NewContext, 1) \
00266 F(PushContext, 1) \
00267 F(LookupContext, 2) \
00268 F(LoadContextSlot, 2) \
00269 F(LoadContextSlotNoReferenceError, 2) \
00270 F(StoreContextSlot, 3) \
00271 \
00272 \
00273 F(DeclareGlobals, 3) \
00274 F(DeclareContextSlot, 4) \
00275 F(InitializeVarGlobal, -1 ) \
00276 F(InitializeConstGlobal, 2) \
00277 F(InitializeConstContextSlot, 3) \
00278 \
00279 \
00280 F(DebugPrint, 1) \
00281 F(DebugTrace, 0) \
00282 F(TraceEnter, 0) \
00283 F(TraceExit, 1) \
00284 F(DebugBreak, 0) \
00285 F(FunctionGetAssemblerCode, 1) \
00286 F(Abort, 2) \
00287 \
00288 \
00289 F(IS_VAR, 1)
00290
00291
00292 #ifdef DEBUG
00293 #define RUNTIME_FUNCTION_LIST_DEBUG(F) \
00294 \
00295 F(ListNatives, 0)
00296 #else
00297 #define RUNTIME_FUNCTION_LIST_DEBUG(F)
00298 #endif
00299
00300
00301
00302
00303
00304
00305
00306 #define RUNTIME_FUNCTION_LIST(F) \
00307 RUNTIME_FUNCTION_LIST_ALWAYS(F) \
00308 RUNTIME_FUNCTION_LIST_DEBUG(F)
00309
00310
00311
00312
00313 class Runtime : public AllStatic {
00314 public:
00315 enum FunctionId {
00316 #define F(name, nargs) k##name,
00317 RUNTIME_FUNCTION_LIST(F)
00318 kNofFunctions
00319 #undef F
00320 };
00321 static Object* CreateArrayLiteral(Arguments args);
00322
00323
00324 struct Function {
00325
00326 const char* name;
00327
00328
00329 const char* stub_name;
00330
00331
00332 byte* entry;
00333
00334
00335
00336 int nargs;
00337 int stub_id;
00338 };
00339
00340
00341 static Function* FunctionForId(FunctionId fid);
00342
00343
00344 static Function* FunctionForName(const char* name);
00345
00346 static int StringMatch(Handle<String> sub, Handle<String> pat, int index);
00347
00348
00349
00350
00351
00352
00353 static Object* GetElementOrCharAt(Handle<Object> object, uint32_t index);
00354
00355 static Object* SetObjectProperty(Handle<Object> object,
00356 Handle<Object> key,
00357 Handle<Object> value,
00358 PropertyAttributes attr);
00359
00360 static Object* GetObjectProperty(Handle<Object> object, Handle<Object> key);
00361
00362
00363 static void PerformGC(Object* result);
00364 };
00365
00366
00367 } }
00368
00369 #endif // V8_RUNTIME_H_