OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 #include "src/checks.h" | 5 #include "src/checks.h" |
6 | 6 |
| 7 #include "src/v8.h" |
| 8 |
7 namespace v8 { | 9 namespace v8 { |
8 namespace internal {} // namespace internal | 10 namespace internal { |
9 } // namespace v8 | 11 |
| 12 intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; } |
| 13 |
| 14 } } // namespace v8::internal |
| 15 |
| 16 |
| 17 static bool CheckEqualsStrict(volatile double* exp, volatile double* val) { |
| 18 v8::internal::DoubleRepresentation exp_rep(*exp); |
| 19 v8::internal::DoubleRepresentation val_rep(*val); |
| 20 if (std::isnan(exp_rep.value) && std::isnan(val_rep.value)) return true; |
| 21 return exp_rep.bits == val_rep.bits; |
| 22 } |
| 23 |
| 24 |
| 25 void CheckEqualsHelper(const char* file, int line, const char* expected_source, |
| 26 double expected, const char* value_source, |
| 27 double value) { |
| 28 // Force values to 64 bit memory to truncate 80 bit precision on IA32. |
| 29 volatile double* exp = new double[1]; |
| 30 *exp = expected; |
| 31 volatile double* val = new double[1]; |
| 32 *val = value; |
| 33 if (!CheckEqualsStrict(exp, val)) { |
| 34 V8_Fatal(file, line, |
| 35 "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", |
| 36 expected_source, value_source, *exp, *val); |
| 37 } |
| 38 delete[] exp; |
| 39 delete[] val; |
| 40 } |
| 41 |
| 42 |
| 43 void CheckNonEqualsHelper(const char* file, int line, |
| 44 const char* expected_source, double expected, |
| 45 const char* value_source, double value) { |
| 46 // Force values to 64 bit memory to truncate 80 bit precision on IA32. |
| 47 volatile double* exp = new double[1]; |
| 48 *exp = expected; |
| 49 volatile double* val = new double[1]; |
| 50 *val = value; |
| 51 if (CheckEqualsStrict(exp, val)) { |
| 52 V8_Fatal(file, line, |
| 53 "CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f", |
| 54 expected_source, value_source, *exp, *val); |
| 55 } |
| 56 delete[] exp; |
| 57 delete[] val; |
| 58 } |
| 59 |
| 60 |
| 61 void CheckEqualsHelper(const char* file, |
| 62 int line, |
| 63 const char* expected_source, |
| 64 v8::Handle<v8::Value> expected, |
| 65 const char* value_source, |
| 66 v8::Handle<v8::Value> value) { |
| 67 if (!expected->Equals(value)) { |
| 68 v8::String::Utf8Value value_str(value); |
| 69 v8::String::Utf8Value expected_str(expected); |
| 70 V8_Fatal(file, line, |
| 71 "CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s", |
| 72 expected_source, value_source, *expected_str, *value_str); |
| 73 } |
| 74 } |
| 75 |
| 76 |
| 77 void CheckNonEqualsHelper(const char* file, |
| 78 int line, |
| 79 const char* unexpected_source, |
| 80 v8::Handle<v8::Value> unexpected, |
| 81 const char* value_source, |
| 82 v8::Handle<v8::Value> value) { |
| 83 if (unexpected->Equals(value)) { |
| 84 v8::String::Utf8Value value_str(value); |
| 85 V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s", |
| 86 unexpected_source, value_source, *value_str); |
| 87 } |
| 88 } |
OLD | NEW |