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 2135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2146 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2146 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
2147 ASSERT(instr->key()->representation().IsSmiOrInteger32()); | 2147 ASSERT(instr->key()->representation().IsSmiOrInteger32()); |
2148 ElementsKind elements_kind = instr->elements_kind(); | 2148 ElementsKind elements_kind = instr->elements_kind(); |
2149 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2149 bool clobbers_key = ExternalArrayOpRequiresTemp( |
2150 instr->key()->representation(), elements_kind); | 2150 instr->key()->representation(), elements_kind); |
2151 LOperand* key = clobbers_key | 2151 LOperand* key = clobbers_key |
2152 ? UseTempRegister(instr->key()) | 2152 ? UseTempRegister(instr->key()) |
2153 : UseRegisterOrConstantAtStart(instr->key()); | 2153 : UseRegisterOrConstantAtStart(instr->key()); |
2154 LLoadKeyed* result = NULL; | 2154 LLoadKeyed* result = NULL; |
2155 | 2155 |
2156 if (!instr->is_external()) { | 2156 if (!instr->is_typed_elements()) { |
2157 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2157 LOperand* obj = UseRegisterAtStart(instr->elements()); |
2158 result = new(zone()) LLoadKeyed(obj, key); | 2158 result = new(zone()) LLoadKeyed(obj, key); |
2159 } else { | 2159 } else { |
2160 ASSERT( | 2160 ASSERT( |
2161 (instr->representation().IsInteger32() && | 2161 (instr->representation().IsInteger32() && |
2162 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2162 !(IsDoubleOrFloatElementsKind(instr->elements_kind()))) || |
2163 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
2164 (instr->representation().IsDouble() && | 2163 (instr->representation().IsDouble() && |
2165 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2164 (IsDoubleOrFloatElementsKind(instr->elements_kind())))); |
2166 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2165 LOperand* backing_store = UseRegister(instr->elements()); |
2167 LOperand* external_pointer = UseRegister(instr->elements()); | 2166 result = new(zone()) LLoadKeyed(backing_store, key); |
2168 result = new(zone()) LLoadKeyed(external_pointer, key); | |
2169 } | 2167 } |
2170 | 2168 |
2171 DefineAsRegister(result); | 2169 DefineAsRegister(result); |
2172 bool can_deoptimize = instr->RequiresHoleCheck() || | 2170 bool can_deoptimize = instr->RequiresHoleCheck() || |
2173 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 2171 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
2174 // An unsigned int array load might overflow and cause a deopt, make sure it | 2172 // An unsigned int array load might overflow and cause a deopt, make sure it |
2175 // has an environment. | 2173 // has an environment. |
2176 return can_deoptimize ? AssignEnvironment(result) : result; | 2174 return can_deoptimize ? AssignEnvironment(result) : result; |
2177 } | 2175 } |
2178 | 2176 |
2179 | 2177 |
2180 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 2178 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
2181 LOperand* context = UseFixed(instr->context(), esi); | 2179 LOperand* context = UseFixed(instr->context(), esi); |
2182 LOperand* object = UseFixed(instr->object(), edx); | 2180 LOperand* object = UseFixed(instr->object(), edx); |
2183 LOperand* key = UseFixed(instr->key(), ecx); | 2181 LOperand* key = UseFixed(instr->key(), ecx); |
2184 | 2182 |
2185 LLoadKeyedGeneric* result = | 2183 LLoadKeyedGeneric* result = |
2186 new(zone()) LLoadKeyedGeneric(context, object, key); | 2184 new(zone()) LLoadKeyedGeneric(context, object, key); |
2187 return MarkAsCall(DefineFixed(result, eax), instr); | 2185 return MarkAsCall(DefineFixed(result, eax), instr); |
2188 } | 2186 } |
2189 | 2187 |
2190 | 2188 |
2191 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { | 2189 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { |
2192 ElementsKind elements_kind = instr->elements_kind(); | 2190 ElementsKind elements_kind = instr->elements_kind(); |
2193 | 2191 |
2194 // Determine if we need a byte register in this case for the value. | 2192 // Determine if we need a byte register in this case for the value. |
2195 bool val_is_fixed_register = | 2193 bool val_is_fixed_register = |
2196 elements_kind == EXTERNAL_BYTE_ELEMENTS || | 2194 elements_kind == EXTERNAL_BYTE_ELEMENTS || |
2197 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || | 2195 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
2198 elements_kind == EXTERNAL_PIXEL_ELEMENTS; | 2196 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
| 2197 elements_kind == UINT8_ELEMENTS || |
| 2198 elements_kind == INT8_ELEMENTS || |
| 2199 elements_kind == UINT8_CLAMPED_ELEMENTS; |
2199 if (val_is_fixed_register) { | 2200 if (val_is_fixed_register) { |
2200 return UseFixed(instr->value(), eax); | 2201 return UseFixed(instr->value(), eax); |
2201 } | 2202 } |
2202 | 2203 |
2203 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && | 2204 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && |
2204 IsDoubleOrFloatElementsKind(elements_kind)) { | 2205 IsDoubleOrFloatElementsKind(elements_kind)) { |
2205 return UseRegisterAtStart(instr->value()); | 2206 return UseRegisterAtStart(instr->value()); |
2206 } | 2207 } |
2207 | 2208 |
2208 return UseRegister(instr->value()); | 2209 return UseRegister(instr->value()); |
2209 } | 2210 } |
2210 | 2211 |
2211 | 2212 |
2212 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2213 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2213 if (!instr->is_external()) { | 2214 if (!instr->is_typed_elements()) { |
2214 ASSERT(instr->elements()->representation().IsTagged()); | 2215 ASSERT(instr->elements()->representation().IsTagged()); |
2215 ASSERT(instr->key()->representation().IsInteger32() || | 2216 ASSERT(instr->key()->representation().IsInteger32() || |
2216 instr->key()->representation().IsSmi()); | 2217 instr->key()->representation().IsSmi()); |
2217 | 2218 |
2218 if (instr->value()->representation().IsDouble()) { | 2219 if (instr->value()->representation().IsDouble()) { |
2219 LOperand* object = UseRegisterAtStart(instr->elements()); | 2220 LOperand* object = UseRegisterAtStart(instr->elements()); |
2220 LOperand* val = NULL; | 2221 LOperand* val = NULL; |
2221 val = UseRegisterAtStart(instr->value()); | 2222 val = UseRegisterAtStart(instr->value()); |
2222 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2223 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2223 return new(zone()) LStoreKeyed(object, key, val); | 2224 return new(zone()) LStoreKeyed(object, key, val); |
(...skipping 11 matching lines...) Expand all Loading... |
2235 val = UseRegisterOrConstantAtStart(instr->value()); | 2236 val = UseRegisterOrConstantAtStart(instr->value()); |
2236 key = UseRegisterOrConstantAtStart(instr->key()); | 2237 key = UseRegisterOrConstantAtStart(instr->key()); |
2237 } | 2238 } |
2238 return new(zone()) LStoreKeyed(obj, key, val); | 2239 return new(zone()) LStoreKeyed(obj, key, val); |
2239 } | 2240 } |
2240 } | 2241 } |
2241 | 2242 |
2242 ElementsKind elements_kind = instr->elements_kind(); | 2243 ElementsKind elements_kind = instr->elements_kind(); |
2243 ASSERT( | 2244 ASSERT( |
2244 (instr->value()->representation().IsInteger32() && | 2245 (instr->value()->representation().IsInteger32() && |
2245 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2246 !IsDoubleOrFloatElementsKind(elements_kind)) || |
2246 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
2247 (instr->value()->representation().IsDouble() && | 2247 (instr->value()->representation().IsDouble() && |
2248 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2248 IsDoubleOrFloatElementsKind(elements_kind))); |
2249 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2249 ASSERT((instr->is_fixed_typed_array() && |
2250 ASSERT(instr->elements()->representation().IsExternal()); | 2250 instr->elements()->representation().IsTagged()) || |
| 2251 (instr->is_external() && |
| 2252 instr->elements()->representation().IsExternal())); |
2251 | 2253 |
2252 LOperand* external_pointer = UseRegister(instr->elements()); | 2254 LOperand* backing_store = UseRegister(instr->elements()); |
2253 LOperand* val = GetStoreKeyedValueOperand(instr); | 2255 LOperand* val = GetStoreKeyedValueOperand(instr); |
2254 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2256 bool clobbers_key = ExternalArrayOpRequiresTemp( |
2255 instr->key()->representation(), elements_kind); | 2257 instr->key()->representation(), elements_kind); |
2256 LOperand* key = clobbers_key | 2258 LOperand* key = clobbers_key |
2257 ? UseTempRegister(instr->key()) | 2259 ? UseTempRegister(instr->key()) |
2258 : UseRegisterOrConstantAtStart(instr->key()); | 2260 : UseRegisterOrConstantAtStart(instr->key()); |
2259 return new(zone()) LStoreKeyed(external_pointer, | 2261 return new(zone()) LStoreKeyed(backing_store, key, val); |
2260 key, | |
2261 val); | |
2262 } | 2262 } |
2263 | 2263 |
2264 | 2264 |
2265 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2265 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2266 LOperand* context = UseFixed(instr->context(), esi); | 2266 LOperand* context = UseFixed(instr->context(), esi); |
2267 LOperand* object = UseFixed(instr->object(), edx); | 2267 LOperand* object = UseFixed(instr->object(), edx); |
2268 LOperand* key = UseFixed(instr->key(), ecx); | 2268 LOperand* key = UseFixed(instr->key(), ecx); |
2269 LOperand* value = UseFixed(instr->value(), eax); | 2269 LOperand* value = UseFixed(instr->value(), eax); |
2270 | 2270 |
2271 ASSERT(instr->object()->representation().IsTagged()); | 2271 ASSERT(instr->object()->representation().IsTagged()); |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2657 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2657 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2658 LOperand* object = UseRegister(instr->object()); | 2658 LOperand* object = UseRegister(instr->object()); |
2659 LOperand* index = UseTempRegister(instr->index()); | 2659 LOperand* index = UseTempRegister(instr->index()); |
2660 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2660 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2661 } | 2661 } |
2662 | 2662 |
2663 | 2663 |
2664 } } // namespace v8::internal | 2664 } } // namespace v8::internal |
2665 | 2665 |
2666 #endif // V8_TARGET_ARCH_IA32 | 2666 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |