2008-09-09 20:08:45 +00:00
|
|
|
// Copyright 2006-2008 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/checks.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "src/v8.h"
|
2013-09-23 14:11:59 +00:00
|
|
|
|
2014-03-17 13:33:19 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
intptr_t HeapObjectTagMask() { return kHeapObjectTagMask; }
|
2013-09-23 14:11:59 +00:00
|
|
|
|
2014-03-17 13:33:19 +00:00
|
|
|
} } // namespace v8::internal
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2014-07-30 13:54:45 +00:00
|
|
|
static bool CheckEqualsStrict(volatile double* exp, volatile double* val) {
|
|
|
|
v8::internal::DoubleRepresentation exp_rep(*exp);
|
|
|
|
v8::internal::DoubleRepresentation val_rep(*val);
|
|
|
|
if (std::isnan(exp_rep.value) && std::isnan(val_rep.value)) return true;
|
|
|
|
return exp_rep.bits == val_rep.bits;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckEqualsHelper(const char* file, int line, const char* expected_source,
|
|
|
|
double expected, const char* value_source,
|
|
|
|
double value) {
|
|
|
|
// Force values to 64 bit memory to truncate 80 bit precision on IA32.
|
|
|
|
volatile double* exp = new double[1];
|
|
|
|
*exp = expected;
|
|
|
|
volatile double* val = new double[1];
|
|
|
|
*val = value;
|
|
|
|
if (!CheckEqualsStrict(exp, val)) {
|
|
|
|
V8_Fatal(file, line,
|
|
|
|
"CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f",
|
|
|
|
expected_source, value_source, *exp, *val);
|
|
|
|
}
|
|
|
|
delete[] exp;
|
|
|
|
delete[] val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckNonEqualsHelper(const char* file, int line,
|
|
|
|
const char* expected_source, double expected,
|
|
|
|
const char* value_source, double value) {
|
|
|
|
// Force values to 64 bit memory to truncate 80 bit precision on IA32.
|
|
|
|
volatile double* exp = new double[1];
|
|
|
|
*exp = expected;
|
|
|
|
volatile double* val = new double[1];
|
|
|
|
*val = value;
|
|
|
|
if (CheckEqualsStrict(exp, val)) {
|
|
|
|
V8_Fatal(file, line,
|
|
|
|
"CHECK_EQ(%s, %s) failed\n# Expected: %f\n# Found: %f",
|
|
|
|
expected_source, value_source, *exp, *val);
|
|
|
|
}
|
|
|
|
delete[] exp;
|
|
|
|
delete[] val;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void CheckEqualsHelper(const char* file,
|
|
|
|
int line,
|
|
|
|
const char* expected_source,
|
|
|
|
v8::Handle<v8::Value> expected,
|
|
|
|
const char* value_source,
|
|
|
|
v8::Handle<v8::Value> value) {
|
|
|
|
if (!expected->Equals(value)) {
|
2008-09-10 11:41:48 +00:00
|
|
|
v8::String::Utf8Value value_str(value);
|
|
|
|
v8::String::Utf8Value expected_str(expected);
|
2008-07-03 15:10:15 +00:00
|
|
|
V8_Fatal(file, line,
|
|
|
|
"CHECK_EQ(%s, %s) failed\n# Expected: %s\n# Found: %s",
|
|
|
|
expected_source, value_source, *expected_str, *value_str);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CheckNonEqualsHelper(const char* file,
|
|
|
|
int line,
|
|
|
|
const char* unexpected_source,
|
|
|
|
v8::Handle<v8::Value> unexpected,
|
|
|
|
const char* value_source,
|
|
|
|
v8::Handle<v8::Value> value) {
|
|
|
|
if (unexpected->Equals(value)) {
|
2008-09-10 11:41:48 +00:00
|
|
|
v8::String::Utf8Value value_str(value);
|
2008-07-03 15:10:15 +00:00
|
|
|
V8_Fatal(file, line, "CHECK_NE(%s, %s) failed\n# Value: %s",
|
|
|
|
unexpected_source, value_source, *value_str);
|
|
|
|
}
|
|
|
|
}
|