Chromium Code Reviews| 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 2292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2303 unique_id_, | 2303 unique_id_, |
| 2304 r, | 2304 r, |
| 2305 type_from_value_, | 2305 type_from_value_, |
| 2306 is_internalized_string_, | 2306 is_internalized_string_, |
| 2307 is_not_in_new_space_, | 2307 is_not_in_new_space_, |
| 2308 is_cell_, | 2308 is_cell_, |
| 2309 boolean_value_); | 2309 boolean_value_); |
| 2310 } | 2310 } |
| 2311 | 2311 |
| 2312 | 2312 |
| 2313 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) const { | 2313 HConstant* HConstant::CopyToTruncatedInt32(Zone* zone) { |
| 2314 if (has_int32_value_) { | 2314 if (has_int32_value_) { |
| 2315 return new(zone) HConstant(int32_value_, | 2315 return new(zone) HConstant(int32_value_, |
| 2316 Representation::Integer32(), | 2316 Representation::Integer32(), |
| 2317 is_not_in_new_space_, | 2317 is_not_in_new_space_, |
| 2318 handle_); | 2318 handle_); |
| 2319 } | 2319 } |
| 2320 if (has_double_value_) { | 2320 if (has_double_value_) { |
| 2321 return new(zone) HConstant(DoubleToInt32(double_value_), | 2321 return new(zone) HConstant(DoubleToInt32(double_value_), |
| 2322 Representation::Integer32(), | 2322 Representation::Integer32(), |
| 2323 is_not_in_new_space_, | 2323 is_not_in_new_space_, |
| 2324 handle_); | 2324 handle_); |
| 2325 } | 2325 } |
| 2326 HConstant* number = CopyToTruncatedNumber(zone); | |
| 2327 return (number != NULL) ? number->CopyToTruncatedInt32(zone) : NULL; | |
| 2328 } | |
| 2329 | |
| 2330 | |
| 2331 HConstant* HConstant::CopyToTruncatedNumber(Zone* zone) { | |
|
Toon Verwaest
2013/07/22 08:31:44
Shouldn't we also return "this" for values that ar
oliv
2013/07/22 13:56:43
there is no point to copying the constant if we ar
| |
| 2332 if (handle()->IsBoolean()) { | |
| 2333 return handle()->BooleanValue() ? | |
| 2334 new(zone) HConstant(1) : new(zone) HConstant(0); | |
| 2335 } else if (handle()->IsUndefined()) { | |
| 2336 return new(zone) HConstant(OS::nan_value()); | |
| 2337 } else if (handle()->IsNull()) { | |
| 2338 return new(zone) HConstant(0); | |
| 2339 } | |
| 2326 return NULL; | 2340 return NULL; |
| 2327 } | 2341 } |
| 2328 | 2342 |
| 2329 | 2343 |
| 2330 void HConstant::PrintDataTo(StringStream* stream) { | 2344 void HConstant::PrintDataTo(StringStream* stream) { |
| 2331 if (has_int32_value_) { | 2345 if (has_int32_value_) { |
| 2332 stream->Add("%d ", int32_value_); | 2346 stream->Add("%d ", int32_value_); |
| 2333 } else if (has_double_value_) { | 2347 } else if (has_double_value_) { |
| 2334 stream->Add("%f ", FmtElm(double_value_)); | 2348 stream->Add("%f ", FmtElm(double_value_)); |
| 2335 } else { | 2349 } else { |
| (...skipping 1658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3994 case kBackingStore: | 4008 case kBackingStore: |
| 3995 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); | 4009 if (!name_.is_null()) stream->Add(*String::cast(*name_)->ToCString()); |
| 3996 stream->Add("[backing-store]"); | 4010 stream->Add("[backing-store]"); |
| 3997 break; | 4011 break; |
| 3998 } | 4012 } |
| 3999 | 4013 |
| 4000 stream->Add("@%d", offset()); | 4014 stream->Add("@%d", offset()); |
| 4001 } | 4015 } |
| 4002 | 4016 |
| 4003 } } // namespace v8::internal | 4017 } } // namespace v8::internal |
| OLD | NEW |