OLD | NEW |
1 // Copyright 2007-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2009 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 8480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8491 v8::HeapStatistics heap_statistics; | 8491 v8::HeapStatistics heap_statistics; |
8492 CHECK_EQ(heap_statistics.total_heap_size(), 0); | 8492 CHECK_EQ(heap_statistics.total_heap_size(), 0); |
8493 CHECK_EQ(heap_statistics.used_heap_size(), 0); | 8493 CHECK_EQ(heap_statistics.used_heap_size(), 0); |
8494 v8::V8::GetHeapStatistics(&heap_statistics); | 8494 v8::V8::GetHeapStatistics(&heap_statistics); |
8495 CHECK_NE(heap_statistics.total_heap_size(), 0); | 8495 CHECK_NE(heap_statistics.total_heap_size(), 0); |
8496 CHECK_NE(heap_statistics.used_heap_size(), 0); | 8496 CHECK_NE(heap_statistics.used_heap_size(), 0); |
8497 } | 8497 } |
8498 | 8498 |
8499 | 8499 |
8500 static double DoubleFromBits(uint64_t value) { | 8500 static double DoubleFromBits(uint64_t value) { |
| 8501 const int kIntSize = 4; |
8501 double target; | 8502 double target; |
| 8503 #ifdef BIG_ENDIAN_FLOATING_POINT |
| 8504 // Somebody swapped the lower and higher half of doubles. |
| 8505 memcpy(&target, reinterpret_cast<char*>(&value) + kIntSize, kIntSize); |
| 8506 memcpy(reinterpret_cast<char*>(&target) + kIntSize, &value, kIntSize); |
| 8507 #else |
8502 memcpy(&target, &value, sizeof(target)); | 8508 memcpy(&target, &value, sizeof(target)); |
| 8509 #endif |
8503 return target; | 8510 return target; |
8504 } | 8511 } |
8505 | 8512 |
8506 | 8513 |
8507 static uint64_t DoubleToBits(double value) { | 8514 static uint64_t DoubleToBits(double value) { |
| 8515 const int kIntSize = 4; |
8508 uint64_t target; | 8516 uint64_t target; |
| 8517 #ifdef BIG_ENDIAN_FLOATING_POINT |
| 8518 // Somebody swapped the lower and higher half of doubles. |
| 8519 memcpy(&target, reinterpret_cast<char*>(&value) + kIntSize, kIntSize); |
| 8520 memcpy(reinterpret_cast<char*>(&target) + kIntSize, &value, kIntSize); |
| 8521 #else |
8509 memcpy(&target, &value, sizeof(target)); | 8522 memcpy(&target, &value, sizeof(target)); |
| 8523 #endif |
8510 return target; | 8524 return target; |
8511 } | 8525 } |
8512 | 8526 |
8513 | 8527 |
8514 static double DoubleToDateTime(double input) { | 8528 static double DoubleToDateTime(double input) { |
8515 double date_limit = 864e13; | 8529 double date_limit = 864e13; |
8516 if (IsNaN(input) || input < -date_limit || input > date_limit) { | 8530 if (IsNaN(input) || input < -date_limit || input > date_limit) { |
8517 return i::OS::nan_value(); | 8531 return i::OS::nan_value(); |
8518 } | 8532 } |
8519 return (input < 0) ? -(floor(-input)) : floor(input); | 8533 return (input < 0) ? -(floor(-input)) : floor(input); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8589 double stored_date = date->NumberValue(); | 8603 double stored_date = date->NumberValue(); |
8590 if (!IsNaN(expected_stored_date)) { | 8604 if (!IsNaN(expected_stored_date)) { |
8591 CHECK_EQ(expected_stored_date, stored_date); | 8605 CHECK_EQ(expected_stored_date, stored_date); |
8592 } else { | 8606 } else { |
8593 uint64_t stored_bits = DoubleToBits(stored_date); | 8607 uint64_t stored_bits = DoubleToBits(stored_date); |
8594 // Check if quiet nan (bits 51..62 all set). | 8608 // Check if quiet nan (bits 51..62 all set). |
8595 CHECK_EQ(0xfff, (stored_bits >> 51) & 0xfff); | 8609 CHECK_EQ(0xfff, (stored_bits >> 51) & 0xfff); |
8596 } | 8610 } |
8597 } | 8611 } |
8598 } | 8612 } |
OLD | NEW |