OLD | NEW |
1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
2 // All Rights Reserved. | 2 // All Rights Reserved. |
3 // | 3 // |
4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
6 // met: | 6 // met: |
7 // | 7 // |
8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
10 // | 10 // |
(...skipping 873 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 double_constants.min_int = kMinInt; | 884 double_constants.min_int = kMinInt; |
885 double_constants.one_half = 0.5; | 885 double_constants.one_half = 0.5; |
886 double_constants.minus_one_half = -0.5; | 886 double_constants.minus_one_half = -0.5; |
887 double_constants.minus_zero = -0.0; | 887 double_constants.minus_zero = -0.0; |
888 double_constants.uint8_max_value = 255; | 888 double_constants.uint8_max_value = 255; |
889 double_constants.zero = 0.0; | 889 double_constants.zero = 0.0; |
890 double_constants.canonical_non_hole_nan = OS::nan_value(); | 890 double_constants.canonical_non_hole_nan = OS::nan_value(); |
891 double_constants.the_hole_nan = BitCast<double>(kHoleNanInt64); | 891 double_constants.the_hole_nan = BitCast<double>(kHoleNanInt64); |
892 double_constants.negative_infinity = -V8_INFINITY; | 892 double_constants.negative_infinity = -V8_INFINITY; |
893 | 893 |
894 math_exp_data_mutex = OS::CreateMutex(); | 894 math_exp_data_mutex = new Mutex; |
895 } | 895 } |
896 | 896 |
897 | 897 |
898 void ExternalReference::InitializeMathExpData() { | 898 void ExternalReference::InitializeMathExpData() { |
899 // Early return? | 899 // Early return? |
900 if (math_exp_data_initialized) return; | 900 if (math_exp_data_initialized) return; |
901 | 901 |
902 math_exp_data_mutex->Lock(); | 902 ScopedLock with(math_exp_data_mutex); |
903 if (!math_exp_data_initialized) { | 903 if (!math_exp_data_initialized) { |
904 // If this is changed, generated code must be adapted too. | 904 // If this is changed, generated code must be adapted too. |
905 const int kTableSizeBits = 11; | 905 const int kTableSizeBits = 11; |
906 const int kTableSize = 1 << kTableSizeBits; | 906 const int kTableSize = 1 << kTableSizeBits; |
907 const double kTableSizeDouble = static_cast<double>(kTableSize); | 907 const double kTableSizeDouble = static_cast<double>(kTableSize); |
908 | 908 |
909 math_exp_constants_array = new double[9]; | 909 math_exp_constants_array = new double[9]; |
910 // Input values smaller than this always return 0. | 910 // Input values smaller than this always return 0. |
911 math_exp_constants_array[0] = -708.39641853226408; | 911 math_exp_constants_array[0] = -708.39641853226408; |
912 // Input values larger than this always return +Infinity. | 912 // Input values larger than this always return +Infinity. |
(...skipping 15 matching lines...) Expand all Loading... |
928 for (int i = 0; i < kTableSize; i++) { | 928 for (int i = 0; i < kTableSize; i++) { |
929 double value = pow(2, i / kTableSizeDouble); | 929 double value = pow(2, i / kTableSizeDouble); |
930 uint64_t bits = BitCast<uint64_t, double>(value); | 930 uint64_t bits = BitCast<uint64_t, double>(value); |
931 bits &= (static_cast<uint64_t>(1) << 52) - 1; | 931 bits &= (static_cast<uint64_t>(1) << 52) - 1; |
932 double mantissa = BitCast<double, uint64_t>(bits); | 932 double mantissa = BitCast<double, uint64_t>(bits); |
933 math_exp_log_table_array[i] = mantissa; | 933 math_exp_log_table_array[i] = mantissa; |
934 } | 934 } |
935 | 935 |
936 math_exp_data_initialized = true; | 936 math_exp_data_initialized = true; |
937 } | 937 } |
938 math_exp_data_mutex->Unlock(); | |
939 } | 938 } |
940 | 939 |
941 | 940 |
942 void ExternalReference::TearDownMathExpData() { | 941 void ExternalReference::TearDownMathExpData() { |
943 delete[] math_exp_constants_array; | 942 delete[] math_exp_constants_array; |
944 delete[] math_exp_log_table_array; | 943 delete[] math_exp_log_table_array; |
945 delete math_exp_data_mutex; | 944 delete math_exp_data_mutex; |
946 } | 945 } |
947 | 946 |
948 | 947 |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1676 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
1678 state_.written_position = state_.current_position; | 1677 state_.written_position = state_.current_position; |
1679 written = true; | 1678 written = true; |
1680 } | 1679 } |
1681 | 1680 |
1682 // Return whether something was written. | 1681 // Return whether something was written. |
1683 return written; | 1682 return written; |
1684 } | 1683 } |
1685 | 1684 |
1686 } } // namespace v8::internal | 1685 } } // namespace v8::internal |
OLD | NEW |