OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 } | 125 } |
126 } | 126 } |
127 | 127 |
128 // Check that the source data hasn't been clobbered. | 128 // Check that the source data hasn't been clobbered. |
129 for (int i = 0; i < data_size; i++) { | 129 for (int i = 0; i < data_size; i++) { |
130 CHECK(src_buffer[i] == to_non_zero(i)); | 130 CHECK(src_buffer[i] == to_non_zero(i)); |
131 } | 131 } |
132 } | 132 } |
133 | 133 |
134 | 134 |
| 135 static void TestNaN(const char *code) { |
| 136 // NaN value is different on MIPS and x86 architectures, and TEST(NaNx) |
| 137 // tests checks the case where a x86 NaN value is serialized into the |
| 138 // snapshot on the simulator during cross compilation. |
| 139 v8::HandleScope scope(CcTest::isolate()); |
| 140 v8::Local<v8::Context> context = CcTest::NewContext(PRINT_EXTENSION); |
| 141 v8::Context::Scope context_scope(context); |
| 142 |
| 143 v8::Local<v8::Script> script = v8::Script::Compile(v8_str(code)); |
| 144 v8::Local<v8::Object> result = v8::Local<v8::Object>::Cast(script->Run()); |
| 145 // Have to populate the handle manually, as it's not Cast-able. |
| 146 i::Handle<i::JSObject> o = |
| 147 v8::Utils::OpenHandle<v8::Object, i::JSObject>(result); |
| 148 i::Handle<i::JSArray> array1(reinterpret_cast<i::JSArray*>(*o)); |
| 149 i::FixedDoubleArray* a = i::FixedDoubleArray::cast(array1->elements()); |
| 150 double value = a->get_scalar(0); |
| 151 CHECK(std::isnan(value) && |
| 152 i::BitCast<uint64_t>(value) == |
| 153 i::BitCast<uint64_t>( |
| 154 i::FixedDoubleArray::canonical_not_the_hole_nan_as_double())); |
| 155 } |
| 156 |
| 157 |
| 158 TEST(NaN0) { |
| 159 TestNaN( |
| 160 "var result;" |
| 161 "for (var i = 0; i < 2; i++) {" |
| 162 " result = new Array(Number.NaN, Number.POSITIVE_INFINITY);" |
| 163 "}" |
| 164 "result;"); |
| 165 } |
| 166 |
| 167 |
| 168 TEST(NaN1) { |
| 169 TestNaN( |
| 170 "var result;" |
| 171 "for (var i = 0; i < 2; i++) {" |
| 172 " result = [NaN];" |
| 173 "}" |
| 174 "result;"); |
| 175 } |
| 176 |
135 | 177 |
136 #undef __ | 178 #undef __ |
OLD | NEW |