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

Side by Side Diff: src/objects-inl.h

Issue 667113002: Handle NaN value storing in Uint8Clamped typed arrays. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comment. Created 6 years, 2 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // Review notes: 5 // Review notes:
6 // 6 //
7 // - The use of macros in these inline functions may seem superfluous 7 // - The use of macros in these inline functions may seem superfluous
8 // but it is absolutely needed to make sure gcc generates optimal 8 // but it is absolutely needed to make sure gcc generates optimal
9 // code. gcc is not happy when attempting to inline too deep. 9 // code. gcc is not happy when attempting to inline too deep.
10 // 10 //
(...skipping 4153 matching lines...) Expand 10 before | Expand all | Expand 10 after
4164 4164
4165 template <class Traits> 4165 template <class Traits>
4166 typename Traits::ElementType FixedTypedArray<Traits>::from_double( 4166 typename Traits::ElementType FixedTypedArray<Traits>::from_double(
4167 double value) { 4167 double value) {
4168 return static_cast<ElementType>(DoubleToInt32(value)); 4168 return static_cast<ElementType>(DoubleToInt32(value));
4169 } 4169 }
4170 4170
4171 4171
4172 template<> inline 4172 template<> inline
4173 uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_double(double value) { 4173 uint8_t FixedTypedArray<Uint8ClampedArrayTraits>::from_double(double value) {
4174 if (value < 0) return 0; 4174 // Handle NaNs and less than zero values which clamp to zero.
4175 if (!(value > 0)) return 0;
4175 if (value > 0xFF) return 0xFF; 4176 if (value > 0xFF) return 0xFF;
4176 return static_cast<uint8_t>(lrint(value)); 4177 return static_cast<uint8_t>(lrint(value));
4177 } 4178 }
4178 4179
4179 4180
4180 template<> inline 4181 template<> inline
4181 float FixedTypedArray<Float32ArrayTraits>::from_double(double value) { 4182 float FixedTypedArray<Float32ArrayTraits>::from_double(double value) {
4182 return static_cast<float>(value); 4183 return static_cast<float>(value);
4183 } 4184 }
4184 4185
(...skipping 3100 matching lines...) Expand 10 before | Expand all | Expand 10 after
7285 #undef READ_SHORT_FIELD 7286 #undef READ_SHORT_FIELD
7286 #undef WRITE_SHORT_FIELD 7287 #undef WRITE_SHORT_FIELD
7287 #undef READ_BYTE_FIELD 7288 #undef READ_BYTE_FIELD
7288 #undef WRITE_BYTE_FIELD 7289 #undef WRITE_BYTE_FIELD
7289 #undef NOBARRIER_READ_BYTE_FIELD 7290 #undef NOBARRIER_READ_BYTE_FIELD
7290 #undef NOBARRIER_WRITE_BYTE_FIELD 7291 #undef NOBARRIER_WRITE_BYTE_FIELD
7291 7292
7292 } } // namespace v8::internal 7293 } } // namespace v8::internal
7293 7294
7294 #endif // V8_OBJECTS_INL_H_ 7295 #endif // V8_OBJECTS_INL_H_
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