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

Side by Side Diff: src/hydrogen.cc

Issue 21531003: Remove buggy ToNumber truncation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 4 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 7661 matching lines...) Expand 10 before | Expand all | Expand 10 after
7672 7672
7673 7673
7674 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) { 7674 HValue* HGraphBuilder::TruncateToNumber(HValue* value, Handle<Type>* expected) {
7675 if (value->IsConstant()) { 7675 if (value->IsConstant()) {
7676 HConstant* constant = HConstant::cast(value); 7676 HConstant* constant = HConstant::cast(value);
7677 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone()); 7677 Maybe<HConstant*> number = constant->CopyToTruncatedNumber(zone());
7678 if (number.has_value) { 7678 if (number.has_value) {
7679 *expected = handle(Type::Number(), isolate()); 7679 *expected = handle(Type::Number(), isolate());
7680 return AddInstruction(number.value); 7680 return AddInstruction(number.value);
7681 } 7681 }
7682 return value;
7683 }
7684
7685 Handle<Type> expected_type = *expected;
7686 Representation rep = Representation::FromType(expected_type);
7687 if (!rep.IsTagged()) return value;
7688
7689 // If our type feedback suggests that we can non-observably truncate to number
7690 // we introduce the appropriate check here. This avoids 'value' having a
7691 // tagged representation later on.
7692 if (expected_type->Is(Type::Oddball())) {
7693 // TODO(olivf) The BinaryOpStub only records undefined. It might pay off to
7694 // also record booleans and convert them to 0/1 here.
7695 IfBuilder if_nan(this);
7696 if_nan.If<HCompareObjectEqAndBranch>(value,
7697 graph()->GetConstantUndefined());
7698 if_nan.Then();
7699 if_nan.ElseDeopt();
7700 if_nan.End();
7701 return Add<HConstant>(OS::nan_value());
7702 } 7682 }
7703 7683
7704 return value; 7684 return value;
7705 } 7685 }
7706 7686
7707 7687
7708 HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation( 7688 HInstruction* HOptimizedGraphBuilder::BuildBinaryOperation(
7709 BinaryOperation* expr, 7689 BinaryOperation* expr,
7710 HValue* left, 7690 HValue* left,
7711 HValue* right) { 7691 HValue* right) {
(...skipping 2087 matching lines...) Expand 10 before | Expand all | Expand 10 after
9799 if (ShouldProduceTraceOutput()) { 9779 if (ShouldProduceTraceOutput()) {
9800 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); 9780 isolate()->GetHTracer()->TraceHydrogen(name(), graph_);
9801 } 9781 }
9802 9782
9803 #ifdef DEBUG 9783 #ifdef DEBUG
9804 graph_->Verify(false); // No full verify. 9784 graph_->Verify(false); // No full verify.
9805 #endif 9785 #endif
9806 } 9786 }
9807 9787
9808 } } // namespace v8::internal 9788 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698