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

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

Issue 6801050: Add ToBoolean-conversion of constants in Crankshaft and use it when generating a branch based on ... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 years, 8 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 | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 1043
1044 1044
1045 HConstant* HConstant::CopyToTruncatedInt32() const { 1045 HConstant* HConstant::CopyToTruncatedInt32() const {
1046 if (!has_double_value_) return NULL; 1046 if (!has_double_value_) return NULL;
1047 int32_t truncated = NumberToInt32(*handle_); 1047 int32_t truncated = NumberToInt32(*handle_);
1048 return new HConstant(FACTORY->NewNumberFromInt(truncated), 1048 return new HConstant(FACTORY->NewNumberFromInt(truncated),
1049 Representation::Integer32()); 1049 Representation::Integer32());
1050 } 1050 }
1051 1051
1052 1052
1053 bool HConstant::ToBoolean() const {
1054 // Converts the constant's boolean value according to
1055 // ECMAScript section 9.2 ToBoolean conversion.
1056 if (HasInteger32Value()) return Integer32Value() != 0;
1057 if (HasDoubleValue()) {
1058 double v = DoubleValue();
1059 return v != 0 && !isnan(v);
1060 }
1061 if (handle()->IsTrue()) return true;
1062 if (handle()->IsFalse()) return false;
1063 if (handle()->IsUndefined()) return false;
1064 if (handle()->IsNull()) return false;
1065 if (handle()->IsString() &&
1066 String::cast(*handle())->length() == 0) return false;
1067 return true;
1068 }
1069
1053 void HConstant::PrintDataTo(StringStream* stream) { 1070 void HConstant::PrintDataTo(StringStream* stream) {
1054 handle()->ShortPrint(stream); 1071 handle()->ShortPrint(stream);
1055 } 1072 }
1056 1073
1057 1074
1058 bool HArrayLiteral::IsCopyOnWrite() const { 1075 bool HArrayLiteral::IsCopyOnWrite() const {
1059 return constant_elements()->map() == HEAP->fixed_cow_array_map(); 1076 return constant_elements()->map() == HEAP->fixed_cow_array_map();
1060 } 1077 }
1061 1078
1062 1079
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
1630 1647
1631 1648
1632 void HCheckPrototypeMaps::Verify() { 1649 void HCheckPrototypeMaps::Verify() {
1633 HInstruction::Verify(); 1650 HInstruction::Verify();
1634 ASSERT(HasNoUses()); 1651 ASSERT(HasNoUses());
1635 } 1652 }
1636 1653
1637 #endif 1654 #endif
1638 1655
1639 } } // namespace v8::internal 1656 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/hydrogen-instructions.h ('k') | src/ia32/lithium-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698