| 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 4990 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5001 __ pop(rcx); | 5001 __ pop(rcx); |
| 5002 __ pop(rax); | 5002 __ pop(rax); |
| 5003 __ pop(rdx); | 5003 __ pop(rdx); |
| 5004 __ push(rcx); | 5004 __ push(rcx); |
| 5005 | 5005 |
| 5006 // Do a tail call to the rewritten stub. | 5006 // Do a tail call to the rewritten stub. |
| 5007 __ jmp(rdi); | 5007 __ jmp(rdi); |
| 5008 } | 5008 } |
| 5009 | 5009 |
| 5010 | 5010 |
| 5011 void GenerateFastPixelArrayLoad(MacroAssembler* masm, | |
| 5012 Register receiver, | |
| 5013 Register key, | |
| 5014 Register elements, | |
| 5015 Register untagged_key, | |
| 5016 Register result, | |
| 5017 Label* not_pixel_array, | |
| 5018 Label* key_not_smi, | |
| 5019 Label* out_of_range) { | |
| 5020 // Register use: | |
| 5021 // receiver - holds the receiver and is unchanged. | |
| 5022 // key - holds the key and is unchanged (must be a smi). | |
| 5023 // elements - is set to the the receiver's element if | |
| 5024 // the receiver doesn't have a pixel array or the | |
| 5025 // key is not a smi, otherwise it's the elements' | |
| 5026 // external pointer. | |
| 5027 // untagged_key - is set to the untagged key | |
| 5028 | |
| 5029 // Some callers already have verified that the key is a smi. key_not_smi is | |
| 5030 // set to NULL as a sentinel for that case. Otherwise, add an explicit check | |
| 5031 // to ensure the key is a smi must be added. | |
| 5032 if (key_not_smi != NULL) { | |
| 5033 __ JumpIfNotSmi(key, key_not_smi); | |
| 5034 } else { | |
| 5035 if (FLAG_debug_code) { | |
| 5036 __ AbortIfNotSmi(key); | |
| 5037 } | |
| 5038 } | |
| 5039 __ SmiToInteger32(untagged_key, key); | |
| 5040 | |
| 5041 __ movq(elements, FieldOperand(receiver, JSObject::kElementsOffset)); | |
| 5042 // By passing NULL as not_pixel_array, callers signal that they have already | |
| 5043 // verified that the receiver has pixel array elements. | |
| 5044 if (not_pixel_array != NULL) { | |
| 5045 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); | |
| 5046 } else { | |
| 5047 if (FLAG_debug_code) { | |
| 5048 // Map check should have already made sure that elements is a pixel array. | |
| 5049 __ Cmp(FieldOperand(elements, HeapObject::kMapOffset), | |
| 5050 Factory::pixel_array_map()); | |
| 5051 __ Assert(equal, "Elements isn't a pixel array"); | |
| 5052 } | |
| 5053 } | |
| 5054 | |
| 5055 // Check that the smi is in range. | |
| 5056 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); | |
| 5057 __ j(above_equal, out_of_range); // unsigned check handles negative keys. | |
| 5058 | |
| 5059 // Load and tag the element as a smi. | |
| 5060 __ movq(elements, FieldOperand(elements, PixelArray::kExternalPointerOffset)); | |
| 5061 __ movzxbq(result, Operand(elements, untagged_key, times_1, 0)); | |
| 5062 __ Integer32ToSmi(result, result); | |
| 5063 __ ret(0); | |
| 5064 } | |
| 5065 | |
| 5066 | |
| 5067 // Stores an indexed element into a pixel array, clamping the stored value. | |
| 5068 void GenerateFastPixelArrayStore(MacroAssembler* masm, | |
| 5069 Register receiver, | |
| 5070 Register key, | |
| 5071 Register value, | |
| 5072 Register elements, | |
| 5073 Register scratch1, | |
| 5074 bool load_elements_from_receiver, | |
| 5075 bool key_is_untagged, | |
| 5076 Label* key_not_smi, | |
| 5077 Label* value_not_smi, | |
| 5078 Label* not_pixel_array, | |
| 5079 Label* out_of_range) { | |
| 5080 // Register use: | |
| 5081 // receiver - holds the receiver and is unchanged. | |
| 5082 // key - holds the key (must be a smi) and is unchanged. | |
| 5083 // value - holds the value (must be a smi) and is unchanged. | |
| 5084 // elements - holds the element object of the receiver on entry if | |
| 5085 // load_elements_from_receiver is false, otherwise used | |
| 5086 // internally to store the pixel arrays elements and | |
| 5087 // external array pointer. | |
| 5088 // | |
| 5089 Register external_pointer = elements; | |
| 5090 Register untagged_key = scratch1; | |
| 5091 Register untagged_value = receiver; // Only set once success guaranteed. | |
| 5092 | |
| 5093 // Fetch the receiver's elements if the caller hasn't already done so. | |
| 5094 if (load_elements_from_receiver) { | |
| 5095 __ movq(elements, FieldOperand(receiver, JSObject::kElementsOffset)); | |
| 5096 } | |
| 5097 | |
| 5098 // By passing NULL as not_pixel_array, callers signal that they have already | |
| 5099 // verified that the receiver has pixel array elements. | |
| 5100 if (not_pixel_array != NULL) { | |
| 5101 __ CheckMap(elements, Factory::pixel_array_map(), not_pixel_array, true); | |
| 5102 } else { | |
| 5103 if (FLAG_debug_code) { | |
| 5104 // Map check should have already made sure that elements is a pixel array. | |
| 5105 __ Cmp(FieldOperand(elements, HeapObject::kMapOffset), | |
| 5106 Factory::pixel_array_map()); | |
| 5107 __ Assert(equal, "Elements isn't a pixel array"); | |
| 5108 } | |
| 5109 } | |
| 5110 | |
| 5111 // Key must be a smi and it must be in range. | |
| 5112 if (key_is_untagged) { | |
| 5113 untagged_key = key; | |
| 5114 } else { | |
| 5115 // Some callers already have verified that the key is a smi. key_not_smi is | |
| 5116 // set to NULL as a sentinel for that case. Otherwise, add an explicit | |
| 5117 // check to ensure the key is a smi. | |
| 5118 if (key_not_smi != NULL) { | |
| 5119 __ JumpIfNotSmi(key, key_not_smi); | |
| 5120 } else { | |
| 5121 if (FLAG_debug_code) { | |
| 5122 __ AbortIfNotSmi(key); | |
| 5123 } | |
| 5124 } | |
| 5125 __ SmiToInteger32(untagged_key, key); | |
| 5126 } | |
| 5127 __ cmpl(untagged_key, FieldOperand(elements, PixelArray::kLengthOffset)); | |
| 5128 __ j(above_equal, out_of_range); // unsigned check handles negative keys. | |
| 5129 | |
| 5130 // Value must be a smi. | |
| 5131 __ JumpIfNotSmi(value, value_not_smi); | |
| 5132 __ SmiToInteger32(untagged_value, value); | |
| 5133 | |
| 5134 { // Clamp the value to [0..255]. | |
| 5135 NearLabel done; | |
| 5136 __ testl(untagged_value, Immediate(0xFFFFFF00)); | |
| 5137 __ j(zero, &done); | |
| 5138 __ setcc(negative, untagged_value); // 1 if negative, 0 if positive. | |
| 5139 __ decb(untagged_value); // 0 if negative, 255 if positive. | |
| 5140 __ bind(&done); | |
| 5141 } | |
| 5142 | |
| 5143 __ movq(external_pointer, | |
| 5144 FieldOperand(elements, PixelArray::kExternalPointerOffset)); | |
| 5145 __ movb(Operand(external_pointer, untagged_key, times_1, 0), untagged_value); | |
| 5146 __ ret(0); // Return value in eax. | |
| 5147 } | |
| 5148 | |
| 5149 #undef __ | 5011 #undef __ |
| 5150 | 5012 |
| 5151 } } // namespace v8::internal | 5013 } } // namespace v8::internal |
| 5152 | 5014 |
| 5153 #endif // V8_TARGET_ARCH_X64 | 5015 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |