OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 30 matching lines...) Expand all Loading... |
41 #include "objects.h" | 41 #include "objects.h" |
42 #include "snapshot.h" | 42 #include "snapshot.h" |
43 #include "platform.h" | 43 #include "platform.h" |
44 #include "utils.h" | 44 #include "utils.h" |
45 #include "cctest.h" | 45 #include "cctest.h" |
46 #include "parser.h" | 46 #include "parser.h" |
47 #include "unicode-inl.h" | 47 #include "unicode-inl.h" |
48 | 48 |
49 static const bool kLogThreading = false; | 49 static const bool kLogThreading = false; |
50 | 50 |
51 static bool IsNaN(double x) { | |
52 #ifdef WIN32 | |
53 return _isnan(x); | |
54 #else | |
55 return isnan(x); | |
56 #endif | |
57 } | |
58 | |
59 using ::v8::AccessorInfo; | 51 using ::v8::AccessorInfo; |
60 using ::v8::Arguments; | 52 using ::v8::Arguments; |
61 using ::v8::Context; | 53 using ::v8::Context; |
62 using ::v8::Extension; | 54 using ::v8::Extension; |
63 using ::v8::Function; | 55 using ::v8::Function; |
64 using ::v8::FunctionTemplate; | 56 using ::v8::FunctionTemplate; |
65 using ::v8::Handle; | 57 using ::v8::Handle; |
66 using ::v8::HandleScope; | 58 using ::v8::HandleScope; |
67 using ::v8::Local; | 59 using ::v8::Local; |
68 using ::v8::Message; | 60 using ::v8::Message; |
(...skipping 3572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3641 | 3633 |
3642 int32_t int32_value = obj->Int32Value(); | 3634 int32_t int32_value = obj->Int32Value(); |
3643 CHECK_EQ(0, int32_value); | 3635 CHECK_EQ(0, int32_value); |
3644 CheckUncle(&try_catch); | 3636 CheckUncle(&try_catch); |
3645 | 3637 |
3646 uint32_t uint32_value = obj->Uint32Value(); | 3638 uint32_t uint32_value = obj->Uint32Value(); |
3647 CHECK_EQ(0, uint32_value); | 3639 CHECK_EQ(0, uint32_value); |
3648 CheckUncle(&try_catch); | 3640 CheckUncle(&try_catch); |
3649 | 3641 |
3650 double number_value = obj->NumberValue(); | 3642 double number_value = obj->NumberValue(); |
3651 CHECK_NE(0, IsNaN(number_value)); | 3643 CHECK_NE(0, isnan(number_value)); |
3652 CheckUncle(&try_catch); | 3644 CheckUncle(&try_catch); |
3653 | 3645 |
3654 int64_t integer_value = obj->IntegerValue(); | 3646 int64_t integer_value = obj->IntegerValue(); |
3655 CHECK_EQ(0.0, static_cast<double>(integer_value)); | 3647 CHECK_EQ(0.0, static_cast<double>(integer_value)); |
3656 CheckUncle(&try_catch); | 3648 CheckUncle(&try_catch); |
3657 } | 3649 } |
3658 | 3650 |
3659 | 3651 |
3660 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { | 3652 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { |
3661 ApiTestFuzzer::Fuzz(); | 3653 ApiTestFuzzer::Fuzz(); |
(...skipping 12080 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15742 | 15734 |
15743 static uint64_t DoubleToBits(double value) { | 15735 static uint64_t DoubleToBits(double value) { |
15744 uint64_t target; | 15736 uint64_t target; |
15745 memcpy(&target, &value, sizeof(target)); | 15737 memcpy(&target, &value, sizeof(target)); |
15746 return target; | 15738 return target; |
15747 } | 15739 } |
15748 | 15740 |
15749 | 15741 |
15750 static double DoubleToDateTime(double input) { | 15742 static double DoubleToDateTime(double input) { |
15751 double date_limit = 864e13; | 15743 double date_limit = 864e13; |
15752 if (IsNaN(input) || input < -date_limit || input > date_limit) { | 15744 if (isnan(input) || input < -date_limit || input > date_limit) { |
15753 return i::OS::nan_value(); | 15745 return i::OS::nan_value(); |
15754 } | 15746 } |
15755 return (input < 0) ? -(floor(-input)) : floor(input); | 15747 return (input < 0) ? -(floor(-input)) : floor(input); |
15756 } | 15748 } |
15757 | 15749 |
15758 // We don't have a consistent way to write 64-bit constants syntactically, so we | 15750 // We don't have a consistent way to write 64-bit constants syntactically, so we |
15759 // split them into two 32-bit constants and combine them programmatically. | 15751 // split them into two 32-bit constants and combine them programmatically. |
15760 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { | 15752 static double DoubleFromBits(uint32_t high_bits, uint32_t low_bits) { |
15761 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); | 15753 return DoubleFromBits((static_cast<uint64_t>(high_bits) << 32) | low_bits); |
15762 } | 15754 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15803 -snan | 15795 -snan |
15804 }; | 15796 }; |
15805 int num_test_values = 20; | 15797 int num_test_values = 20; |
15806 | 15798 |
15807 for (int i = 0; i < num_test_values; i++) { | 15799 for (int i = 0; i < num_test_values; i++) { |
15808 double test_value = test_values[i]; | 15800 double test_value = test_values[i]; |
15809 | 15801 |
15810 // Check that Number::New preserves non-NaNs and quiets SNaNs. | 15802 // Check that Number::New preserves non-NaNs and quiets SNaNs. |
15811 v8::Handle<v8::Value> number = v8::Number::New(test_value); | 15803 v8::Handle<v8::Value> number = v8::Number::New(test_value); |
15812 double stored_number = number->NumberValue(); | 15804 double stored_number = number->NumberValue(); |
15813 if (!IsNaN(test_value)) { | 15805 if (!isnan(test_value)) { |
15814 CHECK_EQ(test_value, stored_number); | 15806 CHECK_EQ(test_value, stored_number); |
15815 } else { | 15807 } else { |
15816 uint64_t stored_bits = DoubleToBits(stored_number); | 15808 uint64_t stored_bits = DoubleToBits(stored_number); |
15817 // Check if quiet nan (bits 51..62 all set). | 15809 // Check if quiet nan (bits 51..62 all set). |
15818 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 15810 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
15819 // Most significant fraction bit for quiet nan is set to 0 | 15811 // Most significant fraction bit for quiet nan is set to 0 |
15820 // on MIPS architecture. Allowed by IEEE-754. | 15812 // on MIPS architecture. Allowed by IEEE-754. |
15821 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 15813 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
15822 #else | 15814 #else |
15823 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 15815 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
15824 #endif | 15816 #endif |
15825 } | 15817 } |
15826 | 15818 |
15827 // Check that Date::New preserves non-NaNs in the date range and | 15819 // Check that Date::New preserves non-NaNs in the date range and |
15828 // quiets SNaNs. | 15820 // quiets SNaNs. |
15829 v8::Handle<v8::Value> date = v8::Date::New(test_value); | 15821 v8::Handle<v8::Value> date = v8::Date::New(test_value); |
15830 double expected_stored_date = DoubleToDateTime(test_value); | 15822 double expected_stored_date = DoubleToDateTime(test_value); |
15831 double stored_date = date->NumberValue(); | 15823 double stored_date = date->NumberValue(); |
15832 if (!IsNaN(expected_stored_date)) { | 15824 if (!isnan(expected_stored_date)) { |
15833 CHECK_EQ(expected_stored_date, stored_date); | 15825 CHECK_EQ(expected_stored_date, stored_date); |
15834 } else { | 15826 } else { |
15835 uint64_t stored_bits = DoubleToBits(stored_date); | 15827 uint64_t stored_bits = DoubleToBits(stored_date); |
15836 // Check if quiet nan (bits 51..62 all set). | 15828 // Check if quiet nan (bits 51..62 all set). |
15837 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) | 15829 #if defined(V8_TARGET_ARCH_MIPS) && !defined(USE_SIMULATOR) |
15838 // Most significant fraction bit for quiet nan is set to 0 | 15830 // Most significant fraction bit for quiet nan is set to 0 |
15839 // on MIPS architecture. Allowed by IEEE-754. | 15831 // on MIPS architecture. Allowed by IEEE-754. |
15840 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); | 15832 CHECK_EQ(0xffe, static_cast<int>((stored_bits >> 51) & 0xfff)); |
15841 #else | 15833 #else |
15842 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); | 15834 CHECK_EQ(0xfff, static_cast<int>((stored_bits >> 51) & 0xfff)); |
(...skipping 2855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
18698 i::Semaphore* sem_; | 18690 i::Semaphore* sem_; |
18699 volatile int sem_value_; | 18691 volatile int sem_value_; |
18700 }; | 18692 }; |
18701 | 18693 |
18702 | 18694 |
18703 THREADED_TEST(SemaphoreInterruption) { | 18695 THREADED_TEST(SemaphoreInterruption) { |
18704 ThreadInterruptTest().RunTest(); | 18696 ThreadInterruptTest().RunTest(); |
18705 } | 18697 } |
18706 | 18698 |
18707 #endif // WIN32 | 18699 #endif // WIN32 |
OLD | NEW |