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 2554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2565 has_smi_value_(Smi::IsValid(integer_value)), | 2565 has_smi_value_(Smi::IsValid(integer_value)), |
2566 has_int32_value_(true), | 2566 has_int32_value_(true), |
2567 has_double_value_(true), | 2567 has_double_value_(true), |
2568 has_external_reference_value_(false), | 2568 has_external_reference_value_(false), |
2569 is_internalized_string_(false), | 2569 is_internalized_string_(false), |
2570 is_not_in_new_space_(is_not_in_new_space), | 2570 is_not_in_new_space_(is_not_in_new_space), |
2571 is_cell_(false), | 2571 is_cell_(false), |
2572 boolean_value_(integer_value != 0), | 2572 boolean_value_(integer_value != 0), |
2573 int32_value_(integer_value), | 2573 int32_value_(integer_value), |
2574 double_value_(FastI2D(integer_value)) { | 2574 double_value_(FastI2D(integer_value)) { |
2575 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); | 2575 // It's possible to create a constant with a value in Smi-range but stored |
| 2576 // in a (pre-existing) HeapNumber. See crbug.com/349878. |
| 2577 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); |
| 2578 bool is_smi = has_smi_value_ && !could_be_heapobject; |
| 2579 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); |
2576 Initialize(r); | 2580 Initialize(r); |
2577 } | 2581 } |
2578 | 2582 |
2579 | 2583 |
2580 HConstant::HConstant(double double_value, | 2584 HConstant::HConstant(double double_value, |
2581 Representation r, | 2585 Representation r, |
2582 bool is_not_in_new_space, | 2586 bool is_not_in_new_space, |
2583 Unique<Object> object) | 2587 Unique<Object> object) |
2584 : object_(object), | 2588 : object_(object), |
2585 has_int32_value_(IsInteger32(double_value)), | 2589 has_int32_value_(IsInteger32(double_value)), |
2586 has_double_value_(true), | 2590 has_double_value_(true), |
2587 has_external_reference_value_(false), | 2591 has_external_reference_value_(false), |
2588 is_internalized_string_(false), | 2592 is_internalized_string_(false), |
2589 is_not_in_new_space_(is_not_in_new_space), | 2593 is_not_in_new_space_(is_not_in_new_space), |
2590 is_cell_(false), | 2594 is_cell_(false), |
2591 boolean_value_(double_value != 0 && !std::isnan(double_value)), | 2595 boolean_value_(double_value != 0 && !std::isnan(double_value)), |
2592 int32_value_(DoubleToInt32(double_value)), | 2596 int32_value_(DoubleToInt32(double_value)), |
2593 double_value_(double_value) { | 2597 double_value_(double_value) { |
2594 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); | 2598 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); |
2595 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); | 2599 // It's possible to create a constant with a value in Smi-range but stored |
| 2600 // in a (pre-existing) HeapNumber. See crbug.com/349878. |
| 2601 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null(); |
| 2602 bool is_smi = has_smi_value_ && !could_be_heapobject; |
| 2603 set_type(is_smi ? HType::Smi() : HType::TaggedNumber()); |
2596 Initialize(r); | 2604 Initialize(r); |
2597 } | 2605 } |
2598 | 2606 |
2599 | 2607 |
2600 HConstant::HConstant(ExternalReference reference) | 2608 HConstant::HConstant(ExternalReference reference) |
2601 : HTemplateInstruction<0>(HType::None()), | 2609 : HTemplateInstruction<0>(HType::None()), |
2602 object_(Unique<Object>(Handle<Object>::null())), | 2610 object_(Unique<Object>(Handle<Object>::null())), |
2603 has_smi_value_(false), | 2611 has_smi_value_(false), |
2604 has_int32_value_(false), | 2612 has_int32_value_(false), |
2605 has_double_value_(false), | 2613 has_double_value_(false), |
(...skipping 1799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4405 break; | 4413 break; |
4406 case kExternalMemory: | 4414 case kExternalMemory: |
4407 stream->Add("[external-memory]"); | 4415 stream->Add("[external-memory]"); |
4408 break; | 4416 break; |
4409 } | 4417 } |
4410 | 4418 |
4411 stream->Add("@%d", offset()); | 4419 stream->Add("@%d", offset()); |
4412 } | 4420 } |
4413 | 4421 |
4414 } } // namespace v8::internal | 4422 } } // namespace v8::internal |
OLD | NEW |