Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(581)

Side by Side Diff: src/runtime.h

Issue 3421009: Revision 2.4.4.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/profile-generator.cc ('k') | src/runtime.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2010 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution. 11 // with the distribution.
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 // via a native call by name (from within JS code). 382 // via a native call by name (from within JS code).
383 383
384 #define RUNTIME_FUNCTION_LIST(F) \ 384 #define RUNTIME_FUNCTION_LIST(F) \
385 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \ 385 RUNTIME_FUNCTION_LIST_ALWAYS_1(F) \
386 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \ 386 RUNTIME_FUNCTION_LIST_ALWAYS_2(F) \
387 RUNTIME_FUNCTION_LIST_DEBUG(F) \ 387 RUNTIME_FUNCTION_LIST_DEBUG(F) \
388 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \ 388 RUNTIME_FUNCTION_LIST_DEBUGGER_SUPPORT(F) \
389 RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F) 389 RUNTIME_FUNCTION_LIST_PROFILER_SUPPORT(F)
390 390
391 // ---------------------------------------------------------------------------- 391 // ----------------------------------------------------------------------------
392 // INLINE_FUNCTION_LIST defines all inlined functions accessed
393 // with a native call of the form %_name from within JS code.
394 // Entries have the form F(name, number of arguments, number of return values).
395 #define INLINE_FUNCTION_LIST(F) \
396 F(IsSmi, 1, 1) \
397 F(IsNonNegativeSmi, 1, 1) \
398 F(IsArray, 1, 1) \
399 F(IsRegExp, 1, 1) \
400 F(CallFunction, -1 /* receiver + n args + function */, 1) \
401 F(ArgumentsLength, 0, 1) \
402 F(Arguments, 1, 1) \
403 F(ValueOf, 1, 1) \
404 F(SetValueOf, 2, 1) \
405 F(StringCharFromCode, 1, 1) \
406 F(StringCharAt, 2, 1) \
407 F(ObjectEquals, 2, 1) \
408 F(RandomHeapNumber, 0, 1) \
409 F(IsObject, 1, 1) \
410 F(IsFunction, 1, 1) \
411 F(IsUndetectableObject, 1, 1) \
412 F(IsSpecObject, 1, 1) \
413 F(IsStringWrapperSafeForDefaultValueOf, 1, 1) \
414 F(MathPow, 2, 1) \
415 F(MathSin, 1, 1) \
416 F(MathCos, 1, 1) \
417 F(MathSqrt, 1, 1) \
418 F(IsRegExpEquivalent, 2, 1) \
419 F(HasCachedArrayIndex, 1, 1) \
420 F(GetCachedArrayIndex, 1, 1)
421
422
423 // ----------------------------------------------------------------------------
424 // INLINE_AND_RUNTIME_FUNCTION_LIST defines all inlined functions accessed
425 // with a native call of the form %_name from within JS code that also have
426 // a corresponding runtime function, that is called for slow cases.
427 // Entries have the form F(name, number of arguments, number of return values).
428 #define INLINE_RUNTIME_FUNCTION_LIST(F) \
429 F(IsConstructCall, 0, 1) \
430 F(ClassOf, 1, 1) \
431 F(StringCharCodeAt, 2, 1) \
432 F(Log, 3, 1) \
433 F(StringAdd, 2, 1) \
434 F(SubString, 3, 1) \
435 F(StringCompare, 2, 1) \
436 F(RegExpExec, 4, 1) \
437 F(RegExpConstructResult, 3, 1) \
438 F(RegExpCloneResult, 1, 1) \
439 F(GetFromCache, 2, 1) \
440 F(NumberToString, 1, 1) \
441 F(SwapElements, 3, 1)
442
443
444 //---------------------------------------------------------------------------
392 // Runtime provides access to all C++ runtime functions. 445 // Runtime provides access to all C++ runtime functions.
393 446
394 class Runtime : public AllStatic { 447 class Runtime : public AllStatic {
395 public: 448 public:
396 enum FunctionId { 449 enum FunctionId {
397 #define F(name, nargs, ressize) k##name, 450 #define F(name, nargs, ressize) k##name,
398 RUNTIME_FUNCTION_LIST(F) 451 RUNTIME_FUNCTION_LIST(F)
399 kNofFunctions
400 #undef F 452 #undef F
453 #define F(name, nargs, ressize) kInline##name,
454 INLINE_FUNCTION_LIST(F)
455 INLINE_RUNTIME_FUNCTION_LIST(F)
456 #undef F
457 kNumFunctions,
458 kFirstInlineFunction = kInlineIsSmi
401 }; 459 };
402 460
403 // Runtime function descriptor. 461 enum IntrinsicType {
462 RUNTIME,
463 INLINE
464 };
465
466 // Intrinsic function descriptor.
404 struct Function { 467 struct Function {
468 FunctionId function_id;
469 IntrinsicType intrinsic_type;
405 // The JS name of the function. 470 // The JS name of the function.
406 const char* name; 471 const char* name;
407 472
408 // The C++ (native) entry point. 473 // The C++ (native) entry point. NULL if the function is inlined.
409 byte* entry; 474 byte* entry;
410 475
411 // The number of arguments expected; nargs < 0 if variable no. of 476 // The number of arguments expected. nargs is -1 if the function takes
412 // arguments. 477 // a variable number of arguments.
413 int nargs; 478 int nargs;
414 int stub_id; 479 // Size of result. Most functions return a single pointer, size 1.
415 // Size of result, if complex (larger than a single pointer),
416 // otherwise zero.
417 int result_size; 480 int result_size;
418 }; 481 };
419 482
420 // Get the runtime function with the given function id. 483 static const int kNotFound = -1;
421 static Function* FunctionForId(FunctionId fid);
422 484
423 // Get the runtime function with the given name. 485 // Add symbols for all the intrinsic function names to a StringDictionary.
424 static Function* FunctionForName(Vector<const char> name); 486 // Returns failure if an allocation fails. In this case, it must be
487 // retried with a new, empty StringDictionary, not with the same one.
488 // Alternatively, heap initialization can be completely restarted.
489 static Object* InitializeIntrinsicFunctionNames(Object* dictionary);
425 490
491 // Get the intrinsic function with the given name, which must be a symbol.
492 static Function* FunctionForSymbol(Handle<String> name);
493
494 // Get the intrinsic function with the given FunctionId.
495 static Function* FunctionForId(FunctionId id);
496
497 // General-purpose helper functions for runtime system.
426 static int StringMatch(Handle<String> sub, Handle<String> pat, int index); 498 static int StringMatch(Handle<String> sub, Handle<String> pat, int index);
427 499
428 static bool IsUpperCaseChar(uint16_t ch); 500 static bool IsUpperCaseChar(uint16_t ch);
429 501
430 // TODO(1240886): The following three methods are *not* handle safe, 502 // TODO(1240886): The following three methods are *not* handle safe,
431 // but accept handle arguments. This seems fragile. 503 // but accept handle arguments. This seems fragile.
432 504
433 // Support getting the characters in a string using [] notation as 505 // Support getting the characters in a string using [] notation as
434 // in Firefox/SpiderMonkey, Safari and Opera. 506 // in Firefox/SpiderMonkey, Safari and Opera.
435 static Object* GetElementOrCharAt(Handle<Object> object, uint32_t index); 507 static Object* GetElementOrCharAt(Handle<Object> object, uint32_t index);
(...skipping 19 matching lines...) Expand all
455 int position); 527 int position);
456 528
457 // Helper functions used stubs. 529 // Helper functions used stubs.
458 static void PerformGC(Object* result); 530 static void PerformGC(Object* result);
459 }; 531 };
460 532
461 533
462 } } // namespace v8::internal 534 } } // namespace v8::internal
463 535
464 #endif // V8_RUNTIME_H_ 536 #endif // V8_RUNTIME_H_
OLDNEW
« no previous file with comments | « src/profile-generator.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698