OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #ifndef V8_CHECKS_H_ | 28 #ifndef V8_CHECKS_H_ |
29 #define V8_CHECKS_H_ | 29 #define V8_CHECKS_H_ |
30 | 30 |
31 #include <string.h> | 31 #include <string.h> |
32 | 32 |
33 #include "../include/v8stdint.h" | 33 #include "../include/v8stdint.h" |
34 | 34 |
35 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); | 35 extern "C" void V8_Fatal(const char* file, int line, const char* format, ...); |
36 | 36 |
37 // Define custom A64 preprocessor helpers to facilitate development. | |
38 #ifndef V8_TARGET_ARCH_A64 | |
39 | 37 |
40 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during | 38 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during |
41 // development, but they should not be relied on in the final product. | 39 // development, but they should not be relied on in the final product. |
42 #ifdef DEBUG | 40 #ifdef DEBUG |
43 #define FATAL(msg) \ | 41 #define FATAL(msg) \ |
44 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | 42 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) |
45 #define UNIMPLEMENTED() \ | 43 #define UNIMPLEMENTED() \ |
46 V8_Fatal(__FILE__, __LINE__, "unimplemented code") | 44 V8_Fatal(__FILE__, __LINE__, "unimplemented code") |
47 #define UNREACHABLE() \ | 45 #define UNREACHABLE() \ |
48 V8_Fatal(__FILE__, __LINE__, "unreachable code") | 46 V8_Fatal(__FILE__, __LINE__, "unreachable code") |
49 #else | 47 #else |
50 #define FATAL(msg) \ | 48 #define FATAL(msg) \ |
51 V8_Fatal("", 0, "%s", (msg)) | 49 V8_Fatal("", 0, "%s", (msg)) |
52 #define UNIMPLEMENTED() \ | 50 #define UNIMPLEMENTED() \ |
53 V8_Fatal("", 0, "unimplemented code") | 51 V8_Fatal("", 0, "unimplemented code") |
54 #define UNREACHABLE() ((void) 0) | 52 #define UNREACHABLE() ((void) 0) |
55 #endif | 53 #endif |
56 | 54 |
| 55 // Simulator specific helpers. |
| 56 #if defined(USE_SIMULATOR) && defined(V8_TARGET_ARCH_A64) |
| 57 // TODO(all): If possible automatically prepend an indicator like |
| 58 // UNIMPLEMENTED or LOCATION. |
| 59 #define ASM_UNIMPLEMENTED(message) \ |
| 60 __ Debug(message, __LINE__, NO_PARAM) |
| 61 #define ASM_UNIMPLEMENTED_BREAK(message) \ |
| 62 __ Debug(message, __LINE__, \ |
| 63 FLAG_ignore_asm_unimplemented_break ? NO_PARAM : BREAK) |
| 64 #define ASM_LOCATION(message) \ |
| 65 __ Debug("LOCATION: " message, __LINE__, NO_PARAM) |
57 #else | 66 #else |
58 | 67 #define ASM_UNIMPLEMENTED(message) |
59 #ifdef DEBUG | 68 #define ASM_UNIMPLEMENTED_BREAK(message) |
60 #define FATAL(msg) \ | 69 #define ASM_LOCATION(message) |
61 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | |
62 #define UNREACHABLE() \ | |
63 V8_Fatal(__FILE__, __LINE__, "unreachable code") | |
64 #else | |
65 #define FATAL(msg) \ | |
66 V8_Fatal("", 0, "%s", (msg)) | |
67 #define UNREACHABLE() ((void) 0) | |
68 #endif | |
69 | |
70 #define ABORT() printf("in %s, line %i, %s", __FILE__, __LINE__, __func__); \ | |
71 abort() | |
72 | |
73 #define ALIGNMENT_EXCEPTION() printf("ALIGNMENT EXCEPTION\t"); ABORT() | |
74 | |
75 // Helpers for unimplemented sections. | |
76 #define UNIMPLEMENTED() \ | |
77 do { \ | |
78 printf("UNIMPLEMENTED: %s, line %d, %s\n", \ | |
79 __FILE__, __LINE__, __func__); \ | |
80 V8_Fatal(__FILE__, __LINE__, "unimplemented code"); \ | |
81 } while (0) | |
82 #define UNIMPLEMENTED_M(message) \ | |
83 do { \ | |
84 printf("UNIMPLEMENTED: %s, line %d, %s : %s\n", \ | |
85 __FILE__, __LINE__, __func__, message); \ | |
86 V8_Fatal(__FILE__, __LINE__, "unimplemented code"); \ | |
87 } while (0) | |
88 // Like UNIMPLEMENTED, but does not abort. | |
89 #define TODO_UNIMPLEMENTED(message) \ | |
90 do { \ | |
91 static const unsigned int kLimit = 1; \ | |
92 static unsigned int printed = 0; \ | |
93 if (printed < UINT_MAX) { \ | |
94 printed++; \ | |
95 } \ | |
96 if (printed <= kLimit) { \ | |
97 printf("UNIMPLEMENTED: %s, line %d, %s: %s\n", \ | |
98 __FILE__, __LINE__, __func__, message); \ | |
99 } \ | |
100 } while (0) | |
101 | |
102 // Simulator specific helpers. | |
103 #ifdef USE_SIMULATOR | |
104 // Helpers for unimplemented sections. | |
105 // TODO(all): If possible automatically prepend an indicator like | |
106 // UNIMPLEMENTED or LOCATION. | |
107 #define ASM_UNIMPLEMENTED(message) \ | |
108 __ Debug(message, __LINE__, NO_PARAM) | |
109 #define ASM_UNIMPLEMENTED_BREAK(message) \ | |
110 __ Debug(message, __LINE__, \ | |
111 FLAG_ignore_asm_unimplemented_break ? NO_PARAM : BREAK) | |
112 #define ASM_LOCATION(message) \ | |
113 __ Debug("LOCATION: " message, __LINE__, NO_PARAM) | |
114 #else | |
115 #define ASM_UNIMPLEMENTED(message) | |
116 #define ASM_UNIMPLEMENTED_BREAK(message) | |
117 #define ASM_LOCATION(message) | |
118 #endif | |
119 | |
120 #endif | 70 #endif |
121 | 71 |
122 | 72 |
123 // The CHECK macro checks that the given condition is true; if not, it | 73 // The CHECK macro checks that the given condition is true; if not, it |
124 // prints a message to stderr and aborts. | 74 // prints a message to stderr and aborts. |
125 #define CHECK(condition) do { \ | 75 #define CHECK(condition) do { \ |
126 if (!(condition)) { \ | 76 if (!(condition)) { \ |
127 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ | 77 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ |
128 } \ | 78 } \ |
129 } while (0) | 79 } while (0) |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 | 340 |
391 // "Extra checks" are lightweight checks that are enabled in some release | 341 // "Extra checks" are lightweight checks that are enabled in some release |
392 // builds. | 342 // builds. |
393 #ifdef ENABLE_EXTRA_CHECKS | 343 #ifdef ENABLE_EXTRA_CHECKS |
394 #define EXTRA_CHECK(condition) CHECK(condition) | 344 #define EXTRA_CHECK(condition) CHECK(condition) |
395 #else | 345 #else |
396 #define EXTRA_CHECK(condition) ((void) 0) | 346 #define EXTRA_CHECK(condition) ((void) 0) |
397 #endif | 347 #endif |
398 | 348 |
399 #endif // V8_CHECKS_H_ | 349 #endif // V8_CHECKS_H_ |
OLD | NEW |