OLD | NEW |
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 13434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13445 case EXTERNAL_DOUBLE_ARRAY_TYPE: | 13445 case EXTERNAL_DOUBLE_ARRAY_TYPE: |
13446 return kExternalDoubleArray; | 13446 return kExternalDoubleArray; |
13447 case EXTERNAL_PIXEL_ARRAY_TYPE: | 13447 case EXTERNAL_PIXEL_ARRAY_TYPE: |
13448 return kExternalPixelArray; | 13448 return kExternalPixelArray; |
13449 default: | 13449 default: |
13450 return static_cast<ExternalArrayType>(-1); | 13450 return static_cast<ExternalArrayType>(-1); |
13451 } | 13451 } |
13452 } | 13452 } |
13453 | 13453 |
13454 | 13454 |
| 13455 size_t JSTypedArray::element_size() { |
| 13456 switch (elements()->map()->instance_type()) { |
| 13457 case EXTERNAL_BYTE_ARRAY_TYPE: |
| 13458 return 1; |
| 13459 case EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE: |
| 13460 return 1; |
| 13461 case EXTERNAL_SHORT_ARRAY_TYPE: |
| 13462 return 2; |
| 13463 case EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE: |
| 13464 return 2; |
| 13465 case EXTERNAL_INT_ARRAY_TYPE: |
| 13466 return 4; |
| 13467 case EXTERNAL_UNSIGNED_INT_ARRAY_TYPE: |
| 13468 return 4; |
| 13469 case EXTERNAL_FLOAT_ARRAY_TYPE: |
| 13470 return 4; |
| 13471 case EXTERNAL_DOUBLE_ARRAY_TYPE: |
| 13472 return 8; |
| 13473 case EXTERNAL_PIXEL_ARRAY_TYPE: |
| 13474 return 1; |
| 13475 default: |
| 13476 UNREACHABLE(); |
| 13477 return 0; |
| 13478 } |
| 13479 } |
| 13480 |
| 13481 |
13455 Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { | 13482 Object* ExternalPixelArray::SetValue(uint32_t index, Object* value) { |
13456 uint8_t clamped_value = 0; | 13483 uint8_t clamped_value = 0; |
13457 if (index < static_cast<uint32_t>(length())) { | 13484 if (index < static_cast<uint32_t>(length())) { |
13458 if (value->IsSmi()) { | 13485 if (value->IsSmi()) { |
13459 int int_value = Smi::cast(value)->value(); | 13486 int int_value = Smi::cast(value)->value(); |
13460 if (int_value < 0) { | 13487 if (int_value < 0) { |
13461 clamped_value = 0; | 13488 clamped_value = 0; |
13462 } else if (int_value > 255) { | 13489 } else if (int_value > 255) { |
13463 clamped_value = 255; | 13490 clamped_value = 255; |
13464 } else { | 13491 } else { |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
15139 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); | 15166 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); |
15140 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); | 15167 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); |
15141 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); | 15168 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); |
15142 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); | 15169 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); |
15143 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); | 15170 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); |
15144 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); | 15171 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); |
15145 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); | 15172 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); |
15146 } | 15173 } |
15147 | 15174 |
15148 } } // namespace v8::internal | 15175 } } // namespace v8::internal |
OLD | NEW |