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 2032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); | 2043 double roundtrip_value = static_cast<double>(static_cast<int32_t>(value)); |
2044 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); | 2044 return BitCast<int64_t>(roundtrip_value) == BitCast<int64_t>(value); |
2045 } | 2045 } |
2046 | 2046 |
2047 | 2047 |
2048 HConstant::HConstant(Handle<Object> handle, Representation r) | 2048 HConstant::HConstant(Handle<Object> handle, Representation r) |
2049 : handle_(handle), | 2049 : handle_(handle), |
2050 has_int32_value_(false), | 2050 has_int32_value_(false), |
2051 has_double_value_(false), | 2051 has_double_value_(false), |
2052 is_internalized_string_(false), | 2052 is_internalized_string_(false), |
2053 boolean_value_(handle->BooleanValue()) { | 2053 boolean_value_(handle->BooleanValue()), |
| 2054 raw_address_(NULL) { |
2054 if (handle_->IsNumber()) { | 2055 if (handle_->IsNumber()) { |
2055 double n = handle_->Number(); | 2056 double n = handle_->Number(); |
2056 has_int32_value_ = IsInteger32(n); | 2057 has_int32_value_ = IsInteger32(n); |
2057 int32_value_ = DoubleToInt32(n); | 2058 int32_value_ = DoubleToInt32(n); |
2058 double_value_ = n; | 2059 double_value_ = n; |
2059 has_double_value_ = true; | 2060 has_double_value_ = true; |
2060 } else { | 2061 } else { |
2061 type_from_value_ = HType::TypeFromValue(handle_); | 2062 type_from_value_ = HType::TypeFromValue(handle_); |
2062 is_internalized_string_ = handle_->IsInternalizedString(); | 2063 is_internalized_string_ = handle_->IsInternalizedString(); |
2063 } | 2064 } |
2064 if (r.IsNone()) { | 2065 if (r.IsNone()) { |
2065 if (has_int32_value_) { | 2066 if (has_int32_value_) { |
2066 r = Representation::Integer32(); | 2067 r = Representation::Integer32(); |
2067 } else if (has_double_value_) { | 2068 } else if (has_double_value_) { |
2068 r = Representation::Double(); | 2069 r = Representation::Double(); |
2069 } else { | 2070 } else { |
2070 r = Representation::Tagged(); | 2071 r = Representation::Tagged(); |
2071 } | 2072 } |
2072 } | 2073 } |
2073 Initialize(r); | 2074 Initialize(r); |
2074 } | 2075 } |
2075 | 2076 |
2076 | 2077 |
2077 HConstant::HConstant(Handle<Object> handle, | 2078 HConstant::HConstant(Handle<Object> handle, |
| 2079 Address raw_address, |
2078 Representation r, | 2080 Representation r, |
2079 HType type, | 2081 HType type, |
2080 bool is_internalize_string, | 2082 bool is_internalize_string, |
2081 bool boolean_value) | 2083 bool boolean_value) |
2082 : handle_(handle), | 2084 : handle_(handle), |
2083 has_int32_value_(false), | 2085 has_int32_value_(false), |
2084 has_double_value_(false), | 2086 has_double_value_(false), |
2085 is_internalized_string_(is_internalize_string), | 2087 is_internalized_string_(is_internalize_string), |
2086 boolean_value_(boolean_value), | 2088 boolean_value_(boolean_value), |
| 2089 raw_address_(raw_address), |
2087 type_from_value_(type) { | 2090 type_from_value_(type) { |
2088 ASSERT(!handle.is_null()); | 2091 ASSERT(!handle.is_null()); |
2089 ASSERT(!type.IsUninitialized()); | 2092 ASSERT(!type.IsUninitialized()); |
2090 ASSERT(!type.IsTaggedNumber()); | 2093 ASSERT(!type.IsTaggedNumber()); |
2091 Initialize(r); | 2094 Initialize(r); |
2092 } | 2095 } |
2093 | 2096 |
2094 | 2097 |
2095 HConstant::HConstant(int32_t integer_value, | 2098 HConstant::HConstant(int32_t integer_value, |
2096 Representation r, | 2099 Representation r, |
2097 Handle<Object> optional_handle) | 2100 Handle<Object> optional_handle) |
2098 : has_int32_value_(true), | 2101 : handle_(optional_handle), |
| 2102 has_int32_value_(true), |
2099 has_double_value_(true), | 2103 has_double_value_(true), |
2100 is_internalized_string_(false), | 2104 is_internalized_string_(false), |
2101 boolean_value_(integer_value != 0), | 2105 boolean_value_(integer_value != 0), |
2102 int32_value_(integer_value), | 2106 int32_value_(integer_value), |
2103 double_value_(FastI2D(integer_value)) { | 2107 double_value_(FastI2D(integer_value)) { |
2104 Initialize(r); | 2108 Initialize(r); |
2105 } | 2109 } |
2106 | 2110 |
2107 | 2111 |
2108 HConstant::HConstant(double double_value, | 2112 HConstant::HConstant(double double_value, |
2109 Representation r, | 2113 Representation r, |
2110 Handle<Object> optional_handle) | 2114 Handle<Object> optional_handle) |
2111 : has_int32_value_(IsInteger32(double_value)), | 2115 : handle_(optional_handle), |
| 2116 has_int32_value_(IsInteger32(double_value)), |
2112 has_double_value_(true), | 2117 has_double_value_(true), |
2113 is_internalized_string_(false), | 2118 is_internalized_string_(false), |
2114 boolean_value_(double_value != 0 && !isnan(double_value)), | 2119 boolean_value_(double_value != 0 && !isnan(double_value)), |
2115 int32_value_(DoubleToInt32(double_value)), | 2120 int32_value_(DoubleToInt32(double_value)), |
2116 double_value_(double_value) { | 2121 double_value_(double_value) { |
2117 Initialize(r); | 2122 Initialize(r); |
2118 } | 2123 } |
2119 | 2124 |
2120 | 2125 |
2121 void HConstant::Initialize(Representation r) { | 2126 void HConstant::Initialize(Representation r) { |
2122 set_representation(r); | 2127 set_representation(r); |
2123 SetFlag(kUseGVN); | 2128 SetFlag(kUseGVN); |
2124 if (representation().IsInteger32()) { | 2129 if (representation().IsInteger32()) { |
2125 ClearGVNFlag(kDependsOnOsrEntries); | 2130 ClearGVNFlag(kDependsOnOsrEntries); |
2126 } | 2131 } |
2127 } | 2132 } |
2128 | 2133 |
2129 | 2134 |
2130 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2135 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
2131 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2136 if (r.IsInteger32() && !has_int32_value_) return NULL; |
2132 if (r.IsDouble() && !has_double_value_) return NULL; | 2137 if (r.IsDouble() && !has_double_value_) return NULL; |
2133 if (has_int32_value_) return new(zone) HConstant(int32_value_, r, handle_); | 2138 if (has_int32_value_) return new(zone) HConstant(int32_value_, r, handle_); |
2134 if (has_double_value_) return new(zone) HConstant(double_value_, r, handle_); | 2139 if (has_double_value_) return new(zone) HConstant(double_value_, r, handle_); |
2135 ASSERT(!handle_.is_null()); | 2140 ASSERT(!handle_.is_null()); |
2136 return new(zone) HConstant( | 2141 ASSERT_NE(NULL, raw_address_); |
2137 handle_, r, type_from_value_, is_internalized_string_, boolean_value_); | 2142 return new(zone) HConstant(handle_, |
| 2143 raw_address_, |
| 2144 r, |
| 2145 type_from_value_, |
| 2146 is_internalized_string_, |
| 2147 boolean_value_); |
2138 } | 2148 } |
2139 | 2149 |
2140 | 2150 |
2141 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { | 2151 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
2142 if (has_int32_value_) { | 2152 if (has_int32_value_) { |
2143 return new(zone) HConstant( | 2153 return new(zone) HConstant( |
2144 int32_value_, Representation::Integer32(), handle_); | 2154 int32_value_, Representation::Integer32(), handle_); |
2145 } | 2155 } |
2146 if (has_double_value_) { | 2156 if (has_double_value_) { |
2147 return new(zone) HConstant( | 2157 return new(zone) HConstant( |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3533 | 3543 |
3534 | 3544 |
3535 void HCheckFunction::Verify() { | 3545 void HCheckFunction::Verify() { |
3536 HInstruction::Verify(); | 3546 HInstruction::Verify(); |
3537 ASSERT(HasNoUses()); | 3547 ASSERT(HasNoUses()); |
3538 } | 3548 } |
3539 | 3549 |
3540 #endif | 3550 #endif |
3541 | 3551 |
3542 } } // namespace v8::internal | 3552 } } // namespace v8::internal |
OLD | NEW |