Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(596)

Side by Side Diff: src/checks.h

Issue 8680013: Remove the static qualifier from functions in header files. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Restored static const references on ARM and MIPS. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2011 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
11 // with the distribution. 11 // with the distribution.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 #else 45 #else
46 #define FATAL(msg) \ 46 #define FATAL(msg) \
47 V8_Fatal("", 0, "%s", (msg)) 47 V8_Fatal("", 0, "%s", (msg))
48 #define UNIMPLEMENTED() \ 48 #define UNIMPLEMENTED() \
49 V8_Fatal("", 0, "unimplemented code") 49 V8_Fatal("", 0, "unimplemented code")
50 #define UNREACHABLE() ((void) 0) 50 #define UNREACHABLE() ((void) 0)
51 #endif 51 #endif
52 52
53 53
54 // Used by the CHECK macro -- should not be called directly. 54 // Used by the CHECK macro -- should not be called directly.
55 static inline void CheckHelper(const char* file, 55 inline void CheckHelper(const char* file,
56 int line, 56 int line,
57 const char* source, 57 const char* source,
58 bool condition) { 58 bool condition) {
59 if (!condition) 59 if (!condition)
60 V8_Fatal(file, line, "CHECK(%s) failed", source); 60 V8_Fatal(file, line, "CHECK(%s) failed", source);
61 } 61 }
62 62
63 63
64 // The CHECK macro checks that the given condition is true; if not, it 64 // The CHECK macro checks that the given condition is true; if not, it
65 // prints a message to stderr and aborts. 65 // prints a message to stderr and aborts.
66 #define CHECK(condition) do { \ 66 #define CHECK(condition) do { \
67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \ 67 if (!(condition)) CheckHelper(__FILE__, __LINE__, #condition, false); \
68 } while (0) 68 } while (0)
69 69
70 70
71 // Helper function used by the CHECK_EQ function when given int 71 // Helper function used by the CHECK_EQ function when given int
72 // arguments. Should not be called directly. 72 // arguments. Should not be called directly.
73 static inline void CheckEqualsHelper(const char* file, int line, 73 inline void CheckEqualsHelper(const char* file, int line,
74 const char* expected_source, int expected, 74 const char* expected_source, int expected,
75 const char* value_source, int value) { 75 const char* value_source, int value) {
76 if (expected != value) { 76 if (expected != value) {
77 V8_Fatal(file, line, 77 V8_Fatal(file, line,
78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i", 78 "CHECK_EQ(%s, %s) failed\n# Expected: %i\n# Found: %i",
79 expected_source, value_source, expected, value); 79 expected_source, value_source, expected, value);
80 } 80 }
81 } 81 }
82 82
83 83
84 // Helper function used by the CHECK_EQ function when given int64_t 84 // Helper function used by the CHECK_EQ function when given int64_t
85 // arguments. Should not be called directly. 85 // arguments. Should not be called directly.
86 static inline void CheckEqualsHelper(const char* file, int line, 86 inline void CheckEqualsHelper(const char* file, int line,
87 const char* expected_source, 87 const char* expected_source,
88 int64_t expected, 88 int64_t expected,
89 const char* value_source, 89 const char* value_source,
90 int64_t value) { 90 int64_t value) {
91 if (expected != value) { 91 if (expected != value) {
92 // Print int64_t values in hex, as two int32s, 92 // Print int64_t values in hex, as two int32s,
93 // to avoid platform-dependencies. 93 // to avoid platform-dependencies.
94 V8_Fatal(file, line, 94 V8_Fatal(file, line,
95 "CHECK_EQ(%s, %s) failed\n#" 95 "CHECK_EQ(%s, %s) failed\n#"
96 " Expected: 0x%08x%08x\n# Found: 0x%08x%08x", 96 " Expected: 0x%08x%08x\n# Found: 0x%08x%08x",
97 expected_source, value_source, 97 expected_source, value_source,
98 static_cast<uint32_t>(expected >> 32), 98 static_cast<uint32_t>(expected >> 32),
99 static_cast<uint32_t>(expected), 99 static_cast<uint32_t>(expected),
100 static_cast<uint32_t>(value >> 32), 100 static_cast<uint32_t>(value >> 32),
101 static_cast<uint32_t>(value)); 101 static_cast<uint32_t>(value));
102 } 102 }
103 } 103 }
104 104
105 105
106 // Helper function used by the CHECK_NE function when given int 106 // Helper function used by the CHECK_NE function when given int
107 // arguments. Should not be called directly. 107 // arguments. Should not be called directly.
108 static inline void CheckNonEqualsHelper(const char* file, 108 inline void CheckNonEqualsHelper(const char* file,
109 int line, 109 int line,
110 const char* unexpected_source, 110 const char* unexpected_source,
111 int unexpected, 111 int unexpected,
112 const char* value_source, 112 const char* value_source,
113 int value) { 113 int value) {
114 if (unexpected == value) { 114 if (unexpected == value) {
115 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i", 115 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %i",
116 unexpected_source, value_source, value); 116 unexpected_source, value_source, value);
117 } 117 }
118 } 118 }
119 119
120 120
121 // Helper function used by the CHECK function when given string 121 // Helper function used by the CHECK function when given string
122 // arguments. Should not be called directly. 122 // arguments. Should not be called directly.
123 static inline void CheckEqualsHelper(const char* file, 123 inline void CheckEqualsHelper(const char* file,
124 int line, 124 int line,
125 const char* expected_source, 125 const char* expected_source,
126 const char* expected, 126 const char* expected,
127 const char* value_source, 127 const char* value_source,
128 const char* value) { 128 const char* value) {
129 if ((expected == NULL && value != NULL) || 129 if ((expected == NULL && value != NULL) ||
130 (expected != NULL && value == NULL) || 130 (expected != NULL && value == NULL) ||
131 (expected != NULL && value != NULL && strcmp(expected, value) != 0)) { 131 (expected != NULL && value != NULL && strcmp(expected, value) != 0)) {
132 V8_Fatal(file, line, 132 V8_Fatal(file, line,
133 "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s", 133 "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s",
134 expected_source, value_source, expected, value); 134 expected_source, value_source, expected, value);
135 } 135 }
136 } 136 }
137 137
138 138
139 static inline void CheckNonEqualsHelper(const char* file, 139 inline void CheckNonEqualsHelper(const char* file,
140 int line, 140 int line,
141 const char* expected_source, 141 const char* expected_source,
142 const char* expected, 142 const char* expected,
143 const char* value_source, 143 const char* value_source,
144 const char* value) { 144 const char* value) {
145 if (expected == value || 145 if (expected == value ||
146 (expected != NULL && value != NULL && strcmp(expected, value) == 0)) { 146 (expected != NULL && value != NULL && strcmp(expected, value) == 0)) {
147 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", 147 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
148 expected_source, value_source, value); 148 expected_source, value_source, value);
149 } 149 }
150 } 150 }
151 151
152 152
153 // Helper function used by the CHECK function when given pointer 153 // Helper function used by the CHECK function when given pointer
154 // arguments. Should not be called directly. 154 // arguments. Should not be called directly.
155 static inline void CheckEqualsHelper(const char* file, 155 inline void CheckEqualsHelper(const char* file,
156 int line, 156 int line,
157 const char* expected_source, 157 const char* expected_source,
158 const void* expected, 158 const void* expected,
159 const char* value_source, 159 const char* value_source,
160 const void* value) { 160 const void* value) {
161 if (expected != value) { 161 if (expected != value) {
162 V8_Fatal(file, line, 162 V8_Fatal(file, line,
163 "CHECK_EQ(%s, %s) failed\n# Expected: %p\n# Found: %p", 163 "CHECK_EQ(%s, %s) failed\n# Expected: %p\n# Found: %p",
164 expected_source, value_source, 164 expected_source, value_source,
165 expected, value); 165 expected, value);
166 } 166 }
167 } 167 }
168 168
169 169
170 static inline void CheckNonEqualsHelper(const char* file, 170 inline void CheckNonEqualsHelper(const char* file,
171 int line, 171 int line,
172 const char* expected_source, 172 const char* expected_source,
173 const void* expected, 173 const void* expected,
174 const char* value_source, 174 const char* value_source,
175 const void* value) { 175 const void* value) {
176 if (expected == value) { 176 if (expected == value) {
177 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p", 177 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %p",
178 expected_source, value_source, value); 178 expected_source, value_source, value);
179 } 179 }
180 } 180 }
181 181
182 182
183 // Helper function used by the CHECK function when given floating 183 // Helper function used by the CHECK function when given floating
184 // point arguments. Should not be called directly. 184 // point arguments. Should not be called directly.
185 static inline void CheckEqualsHelper(const char* file, 185 inline void CheckEqualsHelper(const char* file,
186 int line, 186 int line,
187 const char* expected_source, 187 const char* expected_source,
188 double expected, 188 double expected,
189 const char* value_source, 189 const char* value_source,
190 double value) { 190 double value) {
191 // Force values to 64 bit memory to truncate 80 bit precision on IA32. 191 // Force values to 64 bit memory to truncate 80 bit precision on IA32.
192 volatile double* exp = new double[1]; 192 volatile double* exp = new double[1];
193 *exp = expected; 193 *exp = expected;
194 volatile double* val = new double[1]; 194 volatile double* val = new double[1];
195 *val = value; 195 *val = value;
196 if (*exp != *val) { 196 if (*exp != *val) {
197 V8_Fatal(file, line, 197 V8_Fatal(file, line,
198 "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", 198 "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f",
199 expected_source, value_source, *exp, *val); 199 expected_source, value_source, *exp, *val);
200 } 200 }
201 delete[] exp; 201 delete[] exp;
202 delete[] val; 202 delete[] val;
203 } 203 }
204 204
205 205
206 static inline void CheckNonEqualsHelper(const char* file, 206 inline void CheckNonEqualsHelper(const char* file,
207 int line, 207 int line,
208 const char* expected_source, 208 const char* expected_source,
209 double expected, 209 double expected,
210 const char* value_source, 210 const char* value_source,
211 double value) { 211 double value) {
212 // Force values to 64 bit memory to truncate 80 bit precision on IA32. 212 // Force values to 64 bit memory to truncate 80 bit precision on IA32.
213 volatile double* exp = new double[1]; 213 volatile double* exp = new double[1];
214 *exp = expected; 214 *exp = expected;
215 volatile double* val = new double[1]; 215 volatile double* val = new double[1];
216 *val = value; 216 *val = value;
217 if (*exp == *val) { 217 if (*exp == *val) {
218 V8_Fatal(file, line, 218 V8_Fatal(file, line,
219 "CHECK_NE(%s, %s) failed\n# Value: %f", 219 "CHECK_NE(%s, %s) failed\n# Value: %f",
220 expected_source, value_source, *val); 220 expected_source, value_source, *val);
221 } 221 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Static asserts has no impact on runtime performance, so they can be 286 // Static asserts has no impact on runtime performance, so they can be
287 // safely enabled in release mode. Moreover, the ((void) 0) expression 287 // safely enabled in release mode. Moreover, the ((void) 0) expression
288 // obeys different syntax rules than typedef's, e.g. it can't appear 288 // obeys different syntax rules than typedef's, e.g. it can't appear
289 // inside class declaration, this leads to inconsistency between debug 289 // inside class declaration, this leads to inconsistency between debug
290 // and release compilation modes behavior. 290 // and release compilation modes behavior.
291 #define STATIC_ASSERT(test) STATIC_CHECK(test) 291 #define STATIC_ASSERT(test) STATIC_CHECK(test)
292 292
293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p) 293 #define ASSERT_NOT_NULL(p) ASSERT_NE(NULL, p)
294 294
295 #endif // V8_CHECKS_H_ 295 #endif // V8_CHECKS_H_
OLDNEW
« no previous file with comments | « src/char-predicates-inl.h ('k') | src/conversions.h » ('j') | src/conversions-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698