| 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 | |
| 38 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during | 37 // The FATAL, UNREACHABLE and UNIMPLEMENTED macros are useful during |
| 39 // development, but they should not be relied on in the final product. | 38 // development, but they should not be relied on in the final product. |
| 40 #ifdef DEBUG | 39 #ifdef DEBUG |
| 41 #define FATAL(msg) \ | 40 #define FATAL(msg) \ |
| 42 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) | 41 V8_Fatal(__FILE__, __LINE__, "%s", (msg)) |
| 43 #define UNIMPLEMENTED() \ | 42 #define UNIMPLEMENTED() \ |
| 44 V8_Fatal(__FILE__, __LINE__, "unimplemented code") | 43 V8_Fatal(__FILE__, __LINE__, "unimplemented code") |
| 45 #define UNREACHABLE() \ | 44 #define UNREACHABLE() \ |
| 46 V8_Fatal(__FILE__, __LINE__, "unreachable code") | 45 V8_Fatal(__FILE__, __LINE__, "unreachable code") |
| 47 #else | 46 #else |
| 48 #define FATAL(msg) \ | 47 #define FATAL(msg) \ |
| 49 V8_Fatal("", 0, "%s", (msg)) | 48 V8_Fatal("", 0, "%s", (msg)) |
| 50 #define UNIMPLEMENTED() \ | 49 #define UNIMPLEMENTED() \ |
| 51 V8_Fatal("", 0, "unimplemented code") | 50 V8_Fatal("", 0, "unimplemented code") |
| 52 #define UNREACHABLE() ((void) 0) | 51 #define UNREACHABLE() ((void) 0) |
| 53 #endif | 52 #endif |
| 54 | 53 |
| 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) | |
| 66 #else | |
| 67 #define ASM_UNIMPLEMENTED(message) | |
| 68 #define ASM_UNIMPLEMENTED_BREAK(message) | |
| 69 #define ASM_LOCATION(message) | |
| 70 #endif | |
| 71 | |
| 72 | 54 |
| 73 // The CHECK macro checks that the given condition is true; if not, it | 55 // The CHECK macro checks that the given condition is true; if not, it |
| 74 // prints a message to stderr and aborts. | 56 // prints a message to stderr and aborts. |
| 75 #define CHECK(condition) do { \ | 57 #define CHECK(condition) do { \ |
| 76 if (!(condition)) { \ | 58 if (!(condition)) { \ |
| 77 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ | 59 V8_Fatal(__FILE__, __LINE__, "CHECK(%s) failed", #condition); \ |
| 78 } \ | 60 } \ |
| 79 } while (0) | 61 } while (0) |
| 80 | 62 |
| 81 | 63 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 | 322 |
| 341 // "Extra checks" are lightweight checks that are enabled in some release | 323 // "Extra checks" are lightweight checks that are enabled in some release |
| 342 // builds. | 324 // builds. |
| 343 #ifdef ENABLE_EXTRA_CHECKS | 325 #ifdef ENABLE_EXTRA_CHECKS |
| 344 #define EXTRA_CHECK(condition) CHECK(condition) | 326 #define EXTRA_CHECK(condition) CHECK(condition) |
| 345 #else | 327 #else |
| 346 #define EXTRA_CHECK(condition) ((void) 0) | 328 #define EXTRA_CHECK(condition) ((void) 0) |
| 347 #endif | 329 #endif |
| 348 | 330 |
| 349 #endif // V8_CHECKS_H_ | 331 #endif // V8_CHECKS_H_ |
| OLD | NEW |