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 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during | 40 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during |
38 // development, but they should not be relied on in the final product. | 41 // development, but they should not be relied on in the final product. |
39 #ifdef DEBUG | 42 #ifdef DEBUG |
40 #define FATAL(msg) \ | 43 #define FATAL(msg) \ |
41 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | 44 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) |
42 #define UNIMPLEMENTED() \ | 45 #define UNIMPLEMENTED() \ |
43 V8_Fatal(__FILE__, __LINE__, "unimplemented code") | 46 V8_Fatal(__FILE__, __LINE__, "unimplemented code") |
44 #define UNREACHABLE() \ | 47 #define UNREACHABLE() \ |
45 V8_Fatal(__FILE__, __LINE__, "unreachable code") | 48 V8_Fatal(__FILE__, __LINE__, "unreachable code") |
46 #else | 49 #else |
47 #define FATAL(msg) \ | 50 #define FATAL(msg) \ |
48 V8_Fatal("", 0, "%s", (msg)) | 51 V8_Fatal("", 0, "%s", (msg)) |
49 #define UNIMPLEMENTED() \ | 52 #define UNIMPLEMENTED() \ |
50 V8_Fatal("", 0, "unimplemented code") | 53 V8_Fatal("", 0, "unimplemented code") |
51 #define UNREACHABLE() ((void) 0) | 54 #define UNREACHABLE() ((void) 0) |
52 #endif | 55 #endif |
53 | 56 |
| 57 #else |
| 58 |
| 59 #ifdef DEBUG |
| 60 #define FATAL(msg) \ |
| 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 |
| 121 |
54 | 122 |
55 // The CHECK macro checks that the given condition is true; if not, it | 123 // The CHECK macro checks that the given condition is true; if not, it |
56 // prints a message to stderr and aborts. | 124 // prints a message to stderr and aborts. |
57 #define CHECK(condition) do { \ | 125 #define CHECK(condition) do { \ |
58 if (!(condition)) { \ | 126 if (!(condition)) { \ |
59 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ | 127 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ |
60 } \ | 128 } \ |
61 } while (0) | 129 } while (0) |
62 | 130 |
63 | 131 |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 390 |
323 // "Extra checks" are lightweight checks that are enabled in some release | 391 // "Extra checks" are lightweight checks that are enabled in some release |
324 // builds. | 392 // builds. |
325 #ifdef ENABLE_EXTRA_CHECKS | 393 #ifdef ENABLE_EXTRA_CHECKS |
326 #define EXTRA_CHECK(condition) CHECK(condition) | 394 #define EXTRA_CHECK(condition) CHECK(condition) |
327 #else | 395 #else |
328 #define EXTRA_CHECK(condition) ((void) 0) | 396 #define EXTRA_CHECK(condition) ((void) 0) |
329 #endif | 397 #endif |
330 | 398 |
331 #endif // V8_CHECKS_H_ | 399 #endif // V8_CHECKS_H_ |
OLD | NEW |