| 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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 #endif // V8_INTERPRETED_REGEXP | 61 #endif // V8_INTERPRETED_REGEXP |
| 62 | 62 |
| 63 namespace v8 { | 63 namespace v8 { |
| 64 namespace internal { | 64 namespace internal { |
| 65 | 65 |
| 66 | 66 |
| 67 const double DoubleConstant::min_int = kMinInt; | 67 const double DoubleConstant::min_int = kMinInt; |
| 68 const double DoubleConstant::one_half = 0.5; | 68 const double DoubleConstant::one_half = 0.5; |
| 69 const double DoubleConstant::minus_zero = -0.0; | 69 const double DoubleConstant::minus_zero = -0.0; |
| 70 const double DoubleConstant::negative_infinity = -V8_INFINITY; | 70 const double DoubleConstant::negative_infinity = -V8_INFINITY; |
| 71 | 71 const char* RelocInfo::kFillerCommentString = "DEOPTIMIZATION PADDING"; |
| 72 | 72 |
| 73 // ----------------------------------------------------------------------------- | 73 // ----------------------------------------------------------------------------- |
| 74 // Implementation of Label | 74 // Implementation of Label |
| 75 | 75 |
| 76 int Label::pos() const { | 76 int Label::pos() const { |
| 77 if (pos_ < 0) return -pos_ - 1; | 77 if (pos_ < 0) return -pos_ - 1; |
| 78 if (pos_ > 0) return pos_ - 1; | 78 if (pos_ > 0) return pos_ - 1; |
| 79 UNREACHABLE(); | 79 UNREACHABLE(); |
| 80 return 0; | 80 return 0; |
| 81 } | 81 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 ASSERT(RelocInfo::NUMBER_OF_MODES <= kMaxRelocModes); | 221 ASSERT(RelocInfo::NUMBER_OF_MODES <= kMaxRelocModes); |
| 222 // Use unsigned delta-encoding for pc. | 222 // Use unsigned delta-encoding for pc. |
| 223 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); | 223 uint32_t pc_delta = static_cast<uint32_t>(rinfo->pc() - last_pc_); |
| 224 RelocInfo::Mode rmode = rinfo->rmode(); | 224 RelocInfo::Mode rmode = rinfo->rmode(); |
| 225 | 225 |
| 226 // The two most common modes are given small tags, and usually fit in a byte. | 226 // The two most common modes are given small tags, and usually fit in a byte. |
| 227 if (rmode == RelocInfo::EMBEDDED_OBJECT) { | 227 if (rmode == RelocInfo::EMBEDDED_OBJECT) { |
| 228 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); | 228 WriteTaggedPC(pc_delta, kEmbeddedObjectTag); |
| 229 } else if (rmode == RelocInfo::CODE_TARGET) { | 229 } else if (rmode == RelocInfo::CODE_TARGET) { |
| 230 WriteTaggedPC(pc_delta, kCodeTargetTag); | 230 WriteTaggedPC(pc_delta, kCodeTargetTag); |
| 231 ASSERT(begin_pos - pos_ <= RelocInfo::kMaxCallSize); |
| 231 } else if (RelocInfo::IsPosition(rmode)) { | 232 } else if (RelocInfo::IsPosition(rmode)) { |
| 232 // Use signed delta-encoding for data. | 233 // Use signed delta-encoding for data. |
| 233 intptr_t data_delta = rinfo->data() - last_data_; | 234 intptr_t data_delta = rinfo->data() - last_data_; |
| 234 int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag | 235 int pos_type_tag = rmode == RelocInfo::POSITION ? kNonstatementPositionTag |
| 235 : kStatementPositionTag; | 236 : kStatementPositionTag; |
| 236 // Check if data is small enough to fit in a tagged byte. | 237 // Check if data is small enough to fit in a tagged byte. |
| 237 // We cannot use is_intn because data_delta is not an int32_t. | 238 // We cannot use is_intn because data_delta is not an int32_t. |
| 238 if (data_delta >= -(1 << (kSmallDataBits-1)) && | 239 if (data_delta >= -(1 << (kSmallDataBits-1)) && |
| 239 data_delta < 1 << (kSmallDataBits-1)) { | 240 data_delta < 1 << (kSmallDataBits-1)) { |
| 240 WriteTaggedPC(pc_delta, kPositionTag); | 241 WriteTaggedPC(pc_delta, kPositionTag); |
| 241 WriteTaggedData(data_delta, pos_type_tag); | 242 WriteTaggedData(data_delta, pos_type_tag); |
| 242 last_data_ = rinfo->data(); | 243 last_data_ = rinfo->data(); |
| 243 } else { | 244 } else { |
| 244 // Otherwise, use costly encoding. | 245 // Otherwise, use costly encoding. |
| 245 WriteExtraTaggedPC(pc_delta, kPCJumpTag); | 246 WriteExtraTaggedPC(pc_delta, kPCJumpTag); |
| 246 WriteExtraTaggedData(data_delta, pos_type_tag); | 247 WriteExtraTaggedData(data_delta, pos_type_tag); |
| 247 last_data_ = rinfo->data(); | 248 last_data_ = rinfo->data(); |
| 248 } | 249 } |
| 249 } else if (RelocInfo::IsComment(rmode)) { | 250 } else if (RelocInfo::IsComment(rmode)) { |
| 250 // Comments are normally not generated, so we use the costly encoding. | 251 // Comments are normally not generated, so we use the costly encoding. |
| 251 WriteExtraTaggedPC(pc_delta, kPCJumpTag); | 252 WriteExtraTaggedPC(pc_delta, kPCJumpTag); |
| 252 WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag); | 253 WriteExtraTaggedData(rinfo->data() - last_data_, kCommentTag); |
| 253 last_data_ = rinfo->data(); | 254 last_data_ = rinfo->data(); |
| 255 ASSERT(begin_pos - pos_ >= RelocInfo::kMinRelocCommentSize); |
| 254 } else { | 256 } else { |
| 255 // For all other modes we simply use the mode as the extra tag. | 257 // For all other modes we simply use the mode as the extra tag. |
| 256 // None of these modes need a data component. | 258 // None of these modes need a data component. |
| 257 ASSERT(rmode < kPCJumpTag && rmode < kDataJumpTag); | 259 ASSERT(rmode < kPCJumpTag && rmode < kDataJumpTag); |
| 258 WriteExtraTaggedPC(pc_delta, rmode); | 260 WriteExtraTaggedPC(pc_delta, rmode); |
| 259 } | 261 } |
| 260 last_pc_ = rinfo->pc(); | 262 last_pc_ = rinfo->pc(); |
| 261 #ifdef DEBUG | 263 #ifdef DEBUG |
| 262 ASSERT(begin_pos - pos_ <= kMaxSize); | 264 ASSERT(begin_pos - pos_ <= kMaxSize); |
| 263 #endif | 265 #endif |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 822 static double div_two_doubles(double x, double y) { | 824 static double div_two_doubles(double x, double y) { |
| 823 return x / y; | 825 return x / y; |
| 824 } | 826 } |
| 825 | 827 |
| 826 | 828 |
| 827 static double mod_two_doubles(double x, double y) { | 829 static double mod_two_doubles(double x, double y) { |
| 828 return modulo(x, y); | 830 return modulo(x, y); |
| 829 } | 831 } |
| 830 | 832 |
| 831 | 833 |
| 834 static double math_sin_double(double x) { |
| 835 return sin(x); |
| 836 } |
| 837 |
| 838 |
| 839 static double math_cos_double(double x) { |
| 840 return cos(x); |
| 841 } |
| 842 |
| 843 |
| 844 static double math_log_double(double x) { |
| 845 return log(x); |
| 846 } |
| 847 |
| 848 |
| 849 ExternalReference ExternalReference::math_sin_double_function() { |
| 850 return ExternalReference(Redirect(FUNCTION_ADDR(math_sin_double), |
| 851 FP_RETURN_CALL)); |
| 852 } |
| 853 |
| 854 |
| 855 ExternalReference ExternalReference::math_cos_double_function() { |
| 856 return ExternalReference(Redirect(FUNCTION_ADDR(math_cos_double), |
| 857 FP_RETURN_CALL)); |
| 858 } |
| 859 |
| 860 |
| 861 ExternalReference ExternalReference::math_log_double_function() { |
| 862 return ExternalReference(Redirect(FUNCTION_ADDR(math_log_double), |
| 863 FP_RETURN_CALL)); |
| 864 } |
| 865 |
| 866 |
| 832 // Helper function to compute x^y, where y is known to be an | 867 // Helper function to compute x^y, where y is known to be an |
| 833 // integer. Uses binary decomposition to limit the number of | 868 // integer. Uses binary decomposition to limit the number of |
| 834 // multiplications; see the discussion in "Hacker's Delight" by Henry | 869 // multiplications; see the discussion in "Hacker's Delight" by Henry |
| 835 // S. Warren, Jr., figure 11-6, page 213. | 870 // S. Warren, Jr., figure 11-6, page 213. |
| 836 double power_double_int(double x, int y) { | 871 double power_double_int(double x, int y) { |
| 837 double m = (y < 0) ? 1 / x : x; | 872 double m = (y < 0) ? 1 / x : x; |
| 838 unsigned n = (y < 0) ? -y : y; | 873 unsigned n = (y < 0) ? -y : y; |
| 839 double p = 1; | 874 double p = 1; |
| 840 while (n != 0) { | 875 while (n != 0) { |
| 841 if ((n & 1) != 0) p *= m; | 876 if ((n & 1) != 0) p *= m; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 858 if (y == -0.5) return 1.0 / sqrt(x + 0.0); | 893 if (y == -0.5) return 1.0 / sqrt(x + 0.0); |
| 859 } | 894 } |
| 860 if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { | 895 if (isnan(y) || ((x == 1 || x == -1) && isinf(y))) { |
| 861 return OS::nan_value(); | 896 return OS::nan_value(); |
| 862 } | 897 } |
| 863 return pow(x, y); | 898 return pow(x, y); |
| 864 } | 899 } |
| 865 | 900 |
| 866 | 901 |
| 867 ExternalReference ExternalReference::power_double_double_function() { | 902 ExternalReference ExternalReference::power_double_double_function() { |
| 868 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double))); | 903 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_double), |
| 904 FP_RETURN_CALL)); |
| 869 } | 905 } |
| 870 | 906 |
| 871 | 907 |
| 872 ExternalReference ExternalReference::power_double_int_function() { | 908 ExternalReference ExternalReference::power_double_int_function() { |
| 873 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int))); | 909 return ExternalReference(Redirect(FUNCTION_ADDR(power_double_int), |
| 910 FP_RETURN_CALL)); |
| 874 } | 911 } |
| 875 | 912 |
| 876 | 913 |
| 877 static int native_compare_doubles(double y, double x) { | 914 static int native_compare_doubles(double y, double x) { |
| 878 if (x == y) return EQUAL; | 915 if (x == y) return EQUAL; |
| 879 return x < y ? LESS : GREATER; | 916 return x < y ? LESS : GREATER; |
| 880 } | 917 } |
| 881 | 918 |
| 882 | 919 |
| 883 ExternalReference ExternalReference::double_fp_operation( | 920 ExternalReference ExternalReference::double_fp_operation( |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 971 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); | 1008 assembler_->RecordRelocInfo(RelocInfo::POSITION, state_.current_position); |
| 972 state_.written_position = state_.current_position; | 1009 state_.written_position = state_.current_position; |
| 973 written = true; | 1010 written = true; |
| 974 } | 1011 } |
| 975 | 1012 |
| 976 // Return whether something was written. | 1013 // Return whether something was written. |
| 977 return written; | 1014 return written; |
| 978 } | 1015 } |
| 979 | 1016 |
| 980 } } // namespace v8::internal | 1017 } } // namespace v8::internal |
| OLD | NEW |