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

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

Issue 184353002: Fixed constant folding for Math.clz32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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-347906.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 3937 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 case kMathRound: 3948 case kMathRound:
3949 // -0.5 .. -0.0 round to -0.0. 3949 // -0.5 .. -0.0 round to -0.0.
3950 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0); 3950 if ((d >= -0.5 && Double(d).Sign() < 0)) return H_CONSTANT_DOUBLE(-0.0);
3951 // Doubles are represented as Significant * 2 ^ Exponent. If the 3951 // Doubles are represented as Significant * 2 ^ Exponent. If the
3952 // Exponent is not negative, the double value is already an integer. 3952 // Exponent is not negative, the double value is already an integer.
3953 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d); 3953 if (Double(d).Exponent() >= 0) return H_CONSTANT_DOUBLE(d);
3954 return H_CONSTANT_DOUBLE(std::floor(d + 0.5)); 3954 return H_CONSTANT_DOUBLE(std::floor(d + 0.5));
3955 case kMathFloor: 3955 case kMathFloor:
3956 return H_CONSTANT_DOUBLE(std::floor(d)); 3956 return H_CONSTANT_DOUBLE(std::floor(d));
3957 case kMathClz32: { 3957 case kMathClz32: {
3958 uint32_t i = static_cast<uint32_t>(constant->Integer32Value()); 3958 uint32_t i = DoubleToUint32(d);
3959 return H_CONSTANT_INT( 3959 return H_CONSTANT_INT(
3960 (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i)); 3960 (i == 0) ? 32 : CompilerIntrinsics::CountLeadingZeros(i));
3961 } 3961 }
3962 default: 3962 default:
3963 UNREACHABLE(); 3963 UNREACHABLE();
3964 break; 3964 break;
3965 } 3965 }
3966 } while (false); 3966 } while (false);
3967 return new(zone) HUnaryMathOperation(context, value, op); 3967 return new(zone) HUnaryMathOperation(context, value, op);
3968 } 3968 }
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after
4523 break; 4523 break;
4524 case kExternalMemory: 4524 case kExternalMemory:
4525 stream->Add("[external-memory]"); 4525 stream->Add("[external-memory]");
4526 break; 4526 break;
4527 } 4527 }
4528 4528
4529 stream->Add("@%d", offset()); 4529 stream->Add("@%d", offset());
4530 } 4530 }
4531 4531
4532 } } // namespace v8::internal 4532 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/regress/regress-347906.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698