Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(285)

Side by Side Diff: src/hydrogen-instructions.cc

Issue 186123003: Fix HConstants with Smi-ranged HeapNumber values (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix nit Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-349878.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 2544 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 has_smi_value_(Smi::IsValid(integer_value)), 2555 has_smi_value_(Smi::IsValid(integer_value)),
2556 has_int32_value_(true), 2556 has_int32_value_(true),
2557 has_double_value_(true), 2557 has_double_value_(true),
2558 has_external_reference_value_(false), 2558 has_external_reference_value_(false),
2559 is_internalized_string_(false), 2559 is_internalized_string_(false),
2560 is_not_in_new_space_(is_not_in_new_space), 2560 is_not_in_new_space_(is_not_in_new_space),
2561 is_cell_(false), 2561 is_cell_(false),
2562 boolean_value_(integer_value != 0), 2562 boolean_value_(integer_value != 0),
2563 int32_value_(integer_value), 2563 int32_value_(integer_value),
2564 double_value_(FastI2D(integer_value)) { 2564 double_value_(FastI2D(integer_value)) {
2565 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); 2565 // It's possible to create a constant with a value in Smi-range but stored
2566 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2567 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2568 bool is_smi = has_smi_value_ && !could_be_heapobject;
2569 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2566 Initialize(r); 2570 Initialize(r);
2567 } 2571 }
2568 2572
2569 2573
2570 HConstant::HConstant(double double_value, 2574 HConstant::HConstant(double double_value,
2571 Representation r, 2575 Representation r,
2572 bool is_not_in_new_space, 2576 bool is_not_in_new_space,
2573 Unique<Object> object) 2577 Unique<Object> object)
2574 : object_(object), 2578 : object_(object),
2575 has_int32_value_(IsInteger32(double_value)), 2579 has_int32_value_(IsInteger32(double_value)),
2576 has_double_value_(true), 2580 has_double_value_(true),
2577 has_external_reference_value_(false), 2581 has_external_reference_value_(false),
2578 is_internalized_string_(false), 2582 is_internalized_string_(false),
2579 is_not_in_new_space_(is_not_in_new_space), 2583 is_not_in_new_space_(is_not_in_new_space),
2580 is_cell_(false), 2584 is_cell_(false),
2581 boolean_value_(double_value != 0 && !std::isnan(double_value)), 2585 boolean_value_(double_value != 0 && !std::isnan(double_value)),
2582 int32_value_(DoubleToInt32(double_value)), 2586 int32_value_(DoubleToInt32(double_value)),
2583 double_value_(double_value) { 2587 double_value_(double_value) {
2584 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_); 2588 has_smi_value_ = has_int32_value_ && Smi::IsValid(int32_value_);
2585 set_type(has_smi_value_ ? HType::Smi() : HType::TaggedNumber()); 2589 // It's possible to create a constant with a value in Smi-range but stored
2590 // in a (pre-existing) HeapNumber. See crbug.com/349878.
2591 bool could_be_heapobject = r.IsTagged() && !object.handle().is_null();
2592 bool is_smi = has_smi_value_ && !could_be_heapobject;
2593 set_type(is_smi ? HType::Smi() : HType::TaggedNumber());
2586 Initialize(r); 2594 Initialize(r);
2587 } 2595 }
2588 2596
2589 2597
2590 HConstant::HConstant(ExternalReference reference) 2598 HConstant::HConstant(ExternalReference reference)
2591 : HTemplateInstruction<0>(HType::None()), 2599 : HTemplateInstruction<0>(HType::None()),
2592 object_(Unique<Object>(Handle<Object>::null())), 2600 object_(Unique<Object>(Handle<Object>::null())),
2593 has_smi_value_(false), 2601 has_smi_value_(false),
2594 has_int32_value_(false), 2602 has_int32_value_(false),
2595 has_double_value_(false), 2603 has_double_value_(false),
(...skipping 1926 matching lines...) Expand 10 before | Expand all | Expand 10 after
4522 break; 4530 break;
4523 case kExternalMemory: 4531 case kExternalMemory:
4524 stream->Add("[external-memory]"); 4532 stream->Add("[external-memory]");
4525 break; 4533 break;
4526 } 4534 }
4527 4535
4528 stream->Add("@%d", offset()); 4536 stream->Add("@%d", offset());
4529 } 4537 }
4530 4538
4531 } } // namespace v8::internal 4539 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-crbug-349878.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698