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_UTILS_H_ | 5 #ifndef V8_UTILS_H_ |
6 #define V8_UTILS_H_ | 6 #define V8_UTILS_H_ |
7 | 7 |
8 #include <limits.h> | 8 #include <limits.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 static BailoutId FunctionContext() { return BailoutId(kFunctionContextId); } | 915 static BailoutId FunctionContext() { return BailoutId(kFunctionContextId); } |
916 static BailoutId FunctionEntry() { return BailoutId(kFunctionEntryId); } | 916 static BailoutId FunctionEntry() { return BailoutId(kFunctionEntryId); } |
917 static BailoutId Declarations() { return BailoutId(kDeclarationsId); } | 917 static BailoutId Declarations() { return BailoutId(kDeclarationsId); } |
918 static BailoutId FirstUsable() { return BailoutId(kFirstUsableId); } | 918 static BailoutId FirstUsable() { return BailoutId(kFirstUsableId); } |
919 static BailoutId StubEntry() { return BailoutId(kStubEntryId); } | 919 static BailoutId StubEntry() { return BailoutId(kStubEntryId); } |
920 | 920 |
921 bool IsNone() const { return id_ == kNoneId; } | 921 bool IsNone() const { return id_ == kNoneId; } |
922 bool operator==(const BailoutId& other) const { return id_ == other.id_; } | 922 bool operator==(const BailoutId& other) const { return id_ == other.id_; } |
923 bool operator!=(const BailoutId& other) const { return id_ != other.id_; } | 923 bool operator!=(const BailoutId& other) const { return id_ != other.id_; } |
924 friend size_t hash_value(BailoutId); | 924 friend size_t hash_value(BailoutId); |
925 friend std::ostream& operator<<(std::ostream&, BailoutId); | 925 V8_EXPORT_PRIVATE friend std::ostream& operator<<(std::ostream&, BailoutId); |
926 | 926 |
927 private: | 927 private: |
928 static const int kNoneId = -1; | 928 static const int kNoneId = -1; |
929 | 929 |
930 // Using 0 could disguise errors. | 930 // Using 0 could disguise errors. |
931 static const int kScriptContextId = 1; | 931 static const int kScriptContextId = 1; |
932 static const int kFunctionContextId = 2; | 932 static const int kFunctionContextId = 2; |
933 static const int kFunctionEntryId = 3; | 933 static const int kFunctionEntryId = 3; |
934 | 934 |
935 // This AST id identifies the point after the declarations have been visited. | 935 // This AST id identifies the point after the declarations have been visited. |
(...skipping 21 matching lines...) Expand all Loading... |
957 static const int kInvalidToken = -1; | 957 static const int kInvalidToken = -1; |
958 | 958 |
959 private: | 959 private: |
960 int next_token_ = kFirstBreakContinueToken; | 960 int next_token_ = kFirstBreakContinueToken; |
961 }; | 961 }; |
962 | 962 |
963 // ---------------------------------------------------------------------------- | 963 // ---------------------------------------------------------------------------- |
964 // I/O support. | 964 // I/O support. |
965 | 965 |
966 // Our version of printf(). | 966 // Our version of printf(). |
967 void PRINTF_FORMAT(1, 2) PrintF(const char* format, ...); | 967 V8_EXPORT_PRIVATE void PRINTF_FORMAT(1, 2) PrintF(const char* format, ...); |
968 void PRINTF_FORMAT(2, 3) PrintF(FILE* out, const char* format, ...); | 968 void PRINTF_FORMAT(2, 3) PrintF(FILE* out, const char* format, ...); |
969 | 969 |
970 // Prepends the current process ID to the output. | 970 // Prepends the current process ID to the output. |
971 void PRINTF_FORMAT(1, 2) PrintPID(const char* format, ...); | 971 void PRINTF_FORMAT(1, 2) PrintPID(const char* format, ...); |
972 | 972 |
973 // Prepends the current process ID and given isolate pointer to the output. | 973 // Prepends the current process ID and given isolate pointer to the output. |
974 void PRINTF_FORMAT(2, 3) PrintIsolate(void* isolate, const char* format, ...); | 974 void PRINTF_FORMAT(2, 3) PrintIsolate(void* isolate, const char* format, ...); |
975 | 975 |
976 // Safe formatting print. Ensures that str is always null-terminated. | 976 // Safe formatting print. Ensures that str is always null-terminated. |
977 // Returns the number of chars written, or -1 if output was truncated. | 977 // Returns the number of chars written, or -1 if output was truncated. |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 byte* dst = reinterpret_cast<byte*>(p); | 1594 byte* dst = reinterpret_cast<byte*>(p); |
1595 for (size_t i = 0; i < sizeof(V); i++) { | 1595 for (size_t i = 0; i < sizeof(V); i++) { |
1596 dst[i] = src[sizeof(V) - i - 1]; | 1596 dst[i] = src[sizeof(V) - i - 1]; |
1597 } | 1597 } |
1598 #endif // V8_TARGET_LITTLE_ENDIAN | 1598 #endif // V8_TARGET_LITTLE_ENDIAN |
1599 } | 1599 } |
1600 } // namespace internal | 1600 } // namespace internal |
1601 } // namespace v8 | 1601 } // namespace v8 |
1602 | 1602 |
1603 #endif // V8_UTILS_H_ | 1603 #endif // V8_UTILS_H_ |
OLD | NEW |