| 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 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2066 if (handle_->IsNumber()) { | 2066 if (handle_->IsNumber()) { |
| 2067 double n = handle_->Number(); | 2067 double n = handle_->Number(); |
| 2068 has_int32_value_ = IsInteger32(n); | 2068 has_int32_value_ = IsInteger32(n); |
| 2069 int32_value_ = DoubleToInt32(n); | 2069 int32_value_ = DoubleToInt32(n); |
| 2070 double_value_ = n; | 2070 double_value_ = n; |
| 2071 has_double_value_ = true; | 2071 has_double_value_ = true; |
| 2072 } else { | 2072 } else { |
| 2073 type_from_value_ = HType::TypeFromValue(handle_); | 2073 type_from_value_ = HType::TypeFromValue(handle_); |
| 2074 is_internalized_string_ = handle_->IsInternalizedString(); | 2074 is_internalized_string_ = handle_->IsInternalizedString(); |
| 2075 } | 2075 } |
| 2076 |
| 2076 if (r.IsNone()) { | 2077 if (r.IsNone()) { |
| 2077 if (has_int32_value_) { | 2078 if (has_int32_value_) { |
| 2078 r = Representation::Integer32(); | 2079 r = Representation::Integer32(); |
| 2079 } else if (has_double_value_) { | 2080 } else if (has_double_value_) { |
| 2080 r = Representation::Double(); | 2081 r = Representation::Double(); |
| 2081 } else { | 2082 } else { |
| 2082 r = Representation::Tagged(); | 2083 r = Representation::Tagged(); |
| 2083 } | 2084 } |
| 2084 } | 2085 } |
| 2085 Initialize(r); | 2086 Initialize(r); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 Initialize(r); | 2136 Initialize(r); |
| 2136 } | 2137 } |
| 2137 | 2138 |
| 2138 | 2139 |
| 2139 void HConstant::Initialize(Representation r) { | 2140 void HConstant::Initialize(Representation r) { |
| 2140 set_representation(r); | 2141 set_representation(r); |
| 2141 SetFlag(kUseGVN); | 2142 SetFlag(kUseGVN); |
| 2142 if (representation().IsInteger32()) { | 2143 if (representation().IsInteger32()) { |
| 2143 ClearGVNFlag(kDependsOnOsrEntries); | 2144 ClearGVNFlag(kDependsOnOsrEntries); |
| 2144 } | 2145 } |
| 2146 |
| 2147 // TODO(mvstanton): pass isolate as a parameter |
| 2148 Isolate* isolate = Isolate::Current(); |
| 2149 if (handle_.is_null()) { |
| 2150 guaranteed_in_old_space_ = true; |
| 2151 } else if (!isolate->optimizing_compiler_thread()->IsOptimizerThread()) { |
| 2152 ALLOW_HANDLE_DEREF(isolate, "using raw address"); |
| 2153 guaranteed_in_old_space_ = !(isolate->heap()->InNewSpace(*handle_)); |
| 2154 } else { |
| 2155 guaranteed_in_old_space_ = false; |
| 2156 } |
| 2145 } | 2157 } |
| 2146 | 2158 |
| 2147 | 2159 |
| 2148 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { | 2160 HConstant* HConstant::CopyToRepresentation(Representation r, Zone* zone) const { |
| 2149 if (r.IsInteger32() && !has_int32_value_) return NULL; | 2161 if (r.IsInteger32() && !has_int32_value_) return NULL; |
| 2150 if (r.IsDouble() && !has_double_value_) return NULL; | 2162 if (r.IsDouble() && !has_double_value_) return NULL; |
| 2151 if (has_int32_value_) return new(zone) HConstant(int32_value_, r, handle_); | 2163 HConstant* result; |
| 2152 if (has_double_value_) return new(zone) HConstant(double_value_, r, handle_); | 2164 if (has_int32_value_) { |
| 2153 ASSERT(!handle_.is_null()); | 2165 result = new(zone) HConstant(int32_value_, r, handle_); |
| 2154 return new(zone) HConstant(handle_, | 2166 } else if (has_double_value_) { |
| 2155 unique_id_, | 2167 result = new(zone) HConstant(double_value_, r, handle_); |
| 2156 r, | 2168 } else { |
| 2157 type_from_value_, | 2169 ASSERT(!handle_.is_null()); |
| 2158 is_internalized_string_, | 2170 result = new(zone) HConstant(handle_, |
| 2159 boolean_value_); | 2171 unique_id_, |
| 2172 r, |
| 2173 type_from_value_, |
| 2174 is_internalized_string_, |
| 2175 boolean_value_); |
| 2176 } |
| 2177 result->set_guaranteed_in_old_space(guaranteed_in_old_space_); |
| 2178 return result; |
| 2160 } | 2179 } |
| 2161 | 2180 |
| 2162 | 2181 |
| 2163 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { | 2182 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { |
| 2183 HConstant* result; |
| 2164 if (has_int32_value_) { | 2184 if (has_int32_value_) { |
| 2165 return new(zone) HConstant( | 2185 result = new(zone) HConstant( |
| 2166 int32_value_, Representation::Integer32(), handle_); | 2186 int32_value_, Representation::Integer32(), handle_); |
| 2187 } else if (has_double_value_) { |
| 2188 result = new(zone) HConstant( |
| 2189 DoubleToInt32(double_value_), Representation::Integer32(), handle_); |
| 2190 } else { |
| 2191 return NULL; |
| 2167 } | 2192 } |
| 2168 if (has_double_value_) { | 2193 |
| 2169 return new(zone) HConstant( | 2194 result->set_guaranteed_in_old_space(guaranteed_in_old_space_); |
| 2170 DoubleToInt32(double_value_), Representation::Integer32(), handle_); | 2195 return result; |
| 2171 } | |
| 2172 return NULL; | |
| 2173 } | 2196 } |
| 2174 | 2197 |
| 2175 | 2198 |
| 2176 void HConstant::PrintDataTo(StringStream* stream) { | 2199 void HConstant::PrintDataTo(StringStream* stream) { |
| 2177 if (has_int32_value_) { | 2200 if (has_int32_value_) { |
| 2178 stream->Add("%d ", int32_value_); | 2201 stream->Add("%d ", int32_value_); |
| 2179 } else if (has_double_value_) { | 2202 } else if (has_double_value_) { |
| 2180 stream->Add("%f ", FmtElm(double_value_)); | 2203 stream->Add("%f ", FmtElm(double_value_)); |
| 2181 } else { | 2204 } else { |
| 2182 handle()->ShortPrint(stream); | 2205 handle()->ShortPrint(stream); |
| (...skipping 1444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3627 | 3650 |
| 3628 | 3651 |
| 3629 void HCheckFunction::Verify() { | 3652 void HCheckFunction::Verify() { |
| 3630 HInstruction::Verify(); | 3653 HInstruction::Verify(); |
| 3631 ASSERT(HasNoUses()); | 3654 ASSERT(HasNoUses()); |
| 3632 } | 3655 } |
| 3633 | 3656 |
| 3634 #endif | 3657 #endif |
| 3635 | 3658 |
| 3636 } } // namespace v8::internal | 3659 } } // namespace v8::internal |
| OLD | NEW |