| OLD | NEW |
| 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 11610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11621 } else if (value->IsHeapNumber()) { | 11621 } else if (value->IsHeapNumber()) { |
| 11622 double double_value = HeapNumber::cast(value)->value(); | 11622 double double_value = HeapNumber::cast(value)->value(); |
| 11623 if (!(double_value > 0)) { | 11623 if (!(double_value > 0)) { |
| 11624 // NaN and less than zero clamp to zero. | 11624 // NaN and less than zero clamp to zero. |
| 11625 clamped_value = 0; | 11625 clamped_value = 0; |
| 11626 } else if (double_value > 255) { | 11626 } else if (double_value > 255) { |
| 11627 // Greater than 255 clamp to 255. | 11627 // Greater than 255 clamp to 255. |
| 11628 clamped_value = 255; | 11628 clamped_value = 255; |
| 11629 } else { | 11629 } else { |
| 11630 // Other doubles are rounded to the nearest integer. | 11630 // Other doubles are rounded to the nearest integer. |
| 11631 clamped_value = static_cast<uint8_t>(double_value + 0.5); | 11631 clamped_value = static_cast<uint8_t>(lrint(double_value)); |
| 11632 } | 11632 } |
| 11633 } else { | 11633 } else { |
| 11634 // Clamp undefined to zero (default). All other types have been | 11634 // Clamp undefined to zero (default). All other types have been |
| 11635 // converted to a number type further up in the call chain. | 11635 // converted to a number type further up in the call chain. |
| 11636 ASSERT(value->IsUndefined()); | 11636 ASSERT(value->IsUndefined()); |
| 11637 } | 11637 } |
| 11638 set(index, clamped_value); | 11638 set(index, clamped_value); |
| 11639 } | 11639 } |
| 11640 return Smi::FromInt(clamped_value); | 11640 return Smi::FromInt(clamped_value); |
| 11641 } | 11641 } |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13167 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 13167 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
| 13168 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 13168 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
| 13169 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 13169 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
| 13170 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 13170 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
| 13171 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 13171 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
| 13172 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 13172 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
| 13173 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 13173 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
| 13174 } | 13174 } |
| 13175 | 13175 |
| 13176 } } // namespace v8::internal | 13176 } } // namespace v8::internal |
| OLD | NEW |