OLD | NEW |
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 4819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4830 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); | 4830 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); |
4831 } else { | 4831 } else { |
4832 if (FLAG_debug_code) { | 4832 if (FLAG_debug_code) { |
4833 // Map check should have already made sure that elements is a pixel array. | 4833 // Map check should have already made sure that elements is a pixel array. |
4834 __ Cmp(FieldOperand(elements, HeapObject::kMapOffset), | 4834 __ Cmp(FieldOperand(elements, HeapObject::kMapOffset), |
4835 Factory::pixel_array_map()); | 4835 Factory::pixel_array_map()); |
4836 __ Assert(equal, "Elements isn't a pixel array"); | 4836 __ Assert(equal, "Elements isn't a pixel array"); |
4837 } | 4837 } |
4838 } | 4838 } |
4839 | 4839 |
4840 // Some callers already have verified that the key is a smi. key_not_smi is | |
4841 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
4842 // to ensure the key is a smi must be added. | |
4843 if (key_not_smi != NULL) { | |
4844 __ JumpIfNotSmi(key, key_not_smi); | |
4845 } else { | |
4846 if (FLAG_debug_code) { | |
4847 __ AbortIfNotSmi(key); | |
4848 } | |
4849 } | |
4850 | |
4851 // Key must be a smi and it must be in range. | 4840 // Key must be a smi and it must be in range. |
4852 if (key_is_untagged) { | 4841 if (key_is_untagged) { |
4853 untagged_key = key; | 4842 untagged_key = key; |
4854 } else { | 4843 } else { |
| 4844 // Some callers already have verified that the key is a smi. key_not_smi is |
| 4845 // set to NULL as a sentinel for that case. Otherwise, add an explicit |
| 4846 // check to ensure the key is a smi. |
| 4847 if (key_not_smi != NULL) { |
| 4848 __ JumpIfNotSmi(key, key_not_smi); |
| 4849 } else { |
| 4850 if (FLAG_debug_code) { |
| 4851 __ AbortIfNotSmi(key); |
| 4852 } |
| 4853 } |
4855 __ SmiToInteger32(untagged_key, key); | 4854 __ SmiToInteger32(untagged_key, key); |
4856 } | 4855 } |
4857 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); | 4856 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); |
4858 __ j(above_equal, out_of_range); // unsigned check handles negative keys. | 4857 __ j(above_equal, out_of_range); // unsigned check handles negative keys. |
4859 | 4858 |
4860 // Value must be a smi. | 4859 // Value must be a smi. |
4861 __ JumpIfNotSmi(value, value_not_smi); | 4860 __ JumpIfNotSmi(value, value_not_smi); |
4862 __ SmiToInteger32(untagged_value, value); | 4861 __ SmiToInteger32(untagged_value, value); |
4863 | 4862 |
4864 { // Clamp the value to [0..255]. | 4863 { // Clamp the value to [0..255]. |
4865 NearLabel done; | 4864 NearLabel done; |
4866 __ testl(untagged_value, Immediate(0xFFFFFF00)); | 4865 __ testl(untagged_value, Immediate(0xFFFFFF00)); |
4867 __ j(zero, &done); | 4866 __ j(zero, &done); |
4868 __ setcc(negative, untagged_value); // 1 if negative, 0 if positive. | 4867 __ setcc(negative, untagged_value); // 1 if negative, 0 if positive. |
4869 __ decb(untagged_value); // 0 if negative, 255 if positive. | 4868 __ decb(untagged_value); // 0 if negative, 255 if positive. |
4870 __ bind(&done); | 4869 __ bind(&done); |
4871 } | 4870 } |
4872 | 4871 |
4873 __ movq(external_pointer, | 4872 __ movq(external_pointer, |
4874 FieldOperand(elements, PixelArray::kExternalPointerOffset)); | 4873 FieldOperand(elements, PixelArray::kExternalPointerOffset)); |
4875 __ movb(Operand(external_pointer, untagged_key, times_1, 0), untagged_value); | 4874 __ movb(Operand(external_pointer, untagged_key, times_1, 0), untagged_value); |
4876 __ ret(0); // Return value in eax. | 4875 __ ret(0); // Return value in eax. |
4877 } | 4876 } |
4878 | 4877 |
4879 #undef __ | 4878 #undef __ |
4880 | 4879 |
4881 } } // namespace v8::internal | 4880 } } // namespace v8::internal |
4882 | 4881 |
4883 #endif // V8_TARGET_ARCH_X64 | 4882 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |