Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_RUNTIME_RUNTIME_H_ | 5 #ifndef V8_RUNTIME_RUNTIME_H_ |
| 6 #define V8_RUNTIME_RUNTIME_H_ | 6 #define V8_RUNTIME_RUNTIME_H_ |
| 7 | 7 |
| 8 #include "src/allocation.h" | 8 #include "src/allocation.h" |
| 9 #include "src/contexts.h" | |
| 9 #include "src/objects.h" | 10 #include "src/objects.h" |
| 10 #include "src/unicode.h" | 11 #include "src/unicode.h" |
| 11 #include "src/zone.h" | 12 #include "src/zone.h" |
| 12 | 13 |
| 13 namespace v8 { | 14 namespace v8 { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 // * Each intrinsic is consistently exposed in JavaScript via 2 names: | 17 // * Each intrinsic is consistently exposed in JavaScript via 2 names: |
| 17 // * %#name, which is always a runtime call. | 18 // * %#name, which is always a runtime call. |
| 18 // * %_#name, which can be inlined or just a runtime call, the compiler in | 19 // * %_#name, which can be inlined or just a runtime call, the compiler in |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 F(BreakIteratorCurrent, 1, 1) \ | 297 F(BreakIteratorCurrent, 1, 1) \ |
| 297 F(BreakIteratorBreakType, 1, 1) | 298 F(BreakIteratorBreakType, 1, 1) |
| 298 #else | 299 #else |
| 299 #define FOR_EACH_INTRINSIC_I18N(F) | 300 #define FOR_EACH_INTRINSIC_I18N(F) |
| 300 #endif | 301 #endif |
| 301 | 302 |
| 302 | 303 |
| 303 #define FOR_EACH_INTRINSIC_INTERNAL(F) \ | 304 #define FOR_EACH_INTRINSIC_INTERNAL(F) \ |
| 304 F(CheckIsBootstrapping, 0, 1) \ | 305 F(CheckIsBootstrapping, 0, 1) \ |
| 305 F(ExportPrivateSymbols, 1, 1) \ | 306 F(ExportPrivateSymbols, 1, 1) \ |
| 306 F(ImportToRuntime, 1, 1) \ | 307 F(ExportToRuntime, 1, 1) \ |
| 307 F(ImportExperimentalToRuntime, 1, 1) \ | |
| 308 F(InstallJSBuiltins, 1, 1) \ | 308 F(InstallJSBuiltins, 1, 1) \ |
| 309 F(Throw, 1, 1) \ | 309 F(Throw, 1, 1) \ |
| 310 F(ReThrow, 1, 1) \ | 310 F(ReThrow, 1, 1) \ |
| 311 F(UnwindAndFindExceptionHandler, 0, 1) \ | 311 F(UnwindAndFindExceptionHandler, 0, 1) \ |
| 312 F(PromoteScheduledException, 0, 1) \ | 312 F(PromoteScheduledException, 0, 1) \ |
| 313 F(ThrowReferenceError, 1, 1) \ | 313 F(ThrowReferenceError, 1, 1) \ |
| 314 F(NewTypeError, 2, 1) \ | 314 F(NewTypeError, 2, 1) \ |
| 315 F(NewSyntaxError, 2, 1) \ | 315 F(NewSyntaxError, 2, 1) \ |
| 316 F(NewReferenceError, 2, 1) \ | 316 F(NewReferenceError, 2, 1) \ |
| 317 F(ThrowIteratorResultNotAnObject, 1, 1) \ | 317 F(ThrowIteratorResultNotAnObject, 1, 1) \ |
| (...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 975 | 975 |
| 976 | 976 |
| 977 class JavaScriptFrameIterator; // Forward declaration. | 977 class JavaScriptFrameIterator; // Forward declaration. |
| 978 | 978 |
| 979 | 979 |
| 980 class Runtime : public AllStatic { | 980 class Runtime : public AllStatic { |
| 981 public: | 981 public: |
| 982 enum FunctionId { | 982 enum FunctionId { |
| 983 #define F(name, nargs, ressize) k##name, | 983 #define F(name, nargs, ressize) k##name, |
| 984 #define I(name, nargs, ressize) kInline##name, | 984 #define I(name, nargs, ressize) kInline##name, |
| 985 FOR_EACH_INTRINSIC(F) FOR_EACH_INTRINSIC(I) | 985 #define C(index, type, name) kContext_##name, |
| 986 FOR_EACH_INTRINSIC(F) | |
| 987 FOR_EACH_INTRINSIC(I) | |
| 988 NATIVE_CONTEXT_IMPORTED_FIELDS(C) | |
| 989 #undef C | |
| 986 #undef I | 990 #undef I |
| 987 #undef F | 991 #undef F |
| 988 kNumFunctions, | 992 kNumFunctions, |
| 989 }; | 993 }; |
| 990 | 994 |
| 991 enum IntrinsicType { RUNTIME, INLINE }; | 995 enum IntrinsicType { RUNTIME, INLINE, CONTEXT }; |
|
Michael Starzinger
2015/08/25 18:12:09
High-level feedback: I am not sure whether overloa
| |
| 992 | 996 |
| 993 // Intrinsic function descriptor. | 997 // Intrinsic function descriptor. |
| 994 struct Function { | 998 struct Function { |
| 995 FunctionId function_id; | 999 FunctionId function_id; |
| 996 IntrinsicType intrinsic_type; | 1000 IntrinsicType intrinsic_type; |
| 997 // The JS name of the function. | 1001 // The JS name of the function. |
| 998 const char* name; | 1002 const char* name; |
| 999 | 1003 |
| 1000 // The C++ (native) entry point. NULL if the function is inlined. | 1004 // For RUNTIME functions, this is the C++ entry point. |
| 1001 byte* entry; | 1005 // For INLINE functions this is the C++ entry point of the fall back. |
| 1006 // For CONTEXT functions this is the native context index. | |
| 1007 union { | |
| 1008 Address entry; | |
| 1009 Context::Index index; | |
| 1010 }; | |
| 1002 | 1011 |
| 1003 // The number of arguments expected. nargs is -1 if the function takes | 1012 // The number of arguments expected. nargs is -1 if the function takes |
| 1004 // a variable number of arguments. | 1013 // a variable number of arguments. |
| 1005 int nargs; | 1014 int8_t nargs; |
| 1006 // Size of result. Most functions return a single pointer, size 1. | 1015 // Size of result. Most functions return a single pointer, size 1. |
| 1007 int result_size; | 1016 int8_t result_size; |
| 1008 }; | 1017 }; |
| 1009 | 1018 |
| 1010 static const int kNotFound = -1; | 1019 static const int kNotFound = -1; |
| 1011 | 1020 |
| 1012 // Add internalized strings for all the intrinsic function names to a | 1021 // Add internalized strings for all the intrinsic function names to a |
| 1013 // StringDictionary. | 1022 // StringDictionary. |
| 1014 static void InitializeIntrinsicFunctionNames(Isolate* isolate, | 1023 static void InitializeIntrinsicFunctionNames(Isolate* isolate, |
| 1015 Handle<NameDictionary> dict); | 1024 Handle<NameDictionary> dict); |
| 1016 | 1025 |
| 1017 // Get the intrinsic function with the given name, which must be internalized. | 1026 // Get the intrinsic function with the given name, which must be internalized. |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1138 inline bool Runtime::AtomicIsLockFree(uint32_t size) { | 1147 inline bool Runtime::AtomicIsLockFree(uint32_t size) { |
| 1139 return size == 1 || size == 2 || size == 4; | 1148 return size == 1 || size == 2 || size == 4; |
| 1140 } | 1149 } |
| 1141 | 1150 |
| 1142 #endif | 1151 #endif |
| 1143 | 1152 |
| 1144 } // namespace internal | 1153 } // namespace internal |
| 1145 } // namespace v8 | 1154 } // namespace v8 |
| 1146 | 1155 |
| 1147 #endif // V8_RUNTIME_RUNTIME_H_ | 1156 #endif // V8_RUNTIME_RUNTIME_H_ |
| OLD | NEW |