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 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2168 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
2169 ASSERT(instr->key()->representation().IsSmiOrInteger32()); | 2169 ASSERT(instr->key()->representation().IsSmiOrInteger32()); |
2170 ElementsKind elements_kind = instr->elements_kind(); | 2170 ElementsKind elements_kind = instr->elements_kind(); |
2171 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2171 bool clobbers_key = ExternalArrayOpRequiresTemp( |
2172 instr->key()->representation(), elements_kind); | 2172 instr->key()->representation(), elements_kind); |
2173 LOperand* key = clobbers_key | 2173 LOperand* key = clobbers_key |
2174 ? UseTempRegister(instr->key()) | 2174 ? UseTempRegister(instr->key()) |
2175 : UseRegisterOrConstantAtStart(instr->key()); | 2175 : UseRegisterOrConstantAtStart(instr->key()); |
2176 LLoadKeyed* result = NULL; | 2176 LLoadKeyed* result = NULL; |
2177 | 2177 |
2178 if (!instr->is_external()) { | 2178 if (!instr->is_external() && !instr->is_fixed_typed_array()) { |
2179 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2179 LOperand* obj = UseRegisterAtStart(instr->elements()); |
2180 result = new(zone()) LLoadKeyed(obj, key); | 2180 result = new(zone()) LLoadKeyed(obj, key); |
2181 } else { | 2181 } else { |
2182 ASSERT( | 2182 ASSERT( |
2183 (instr->representation().IsInteger32() && | 2183 (instr->representation().IsInteger32() && |
2184 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2184 !(IsDoubleOrFloatElementsKind(instr->elements_kind()))) || |
2185 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
2186 (instr->representation().IsDouble() && | 2185 (instr->representation().IsDouble() && |
2187 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2186 (IsDoubleOrFloatElementsKind(instr->elements_kind())))); |
2188 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2187 LOperand* backing_store = UseRegister(instr->elements()); |
2189 LOperand* external_pointer = UseRegister(instr->elements()); | 2188 result = new(zone()) LLoadKeyed(backing_store, key); |
2190 result = new(zone()) LLoadKeyed(external_pointer, key); | |
2191 } | 2189 } |
2192 | 2190 |
2193 DefineAsRegister(result); | 2191 DefineAsRegister(result); |
2194 bool can_deoptimize = instr->RequiresHoleCheck() || | 2192 bool can_deoptimize = instr->RequiresHoleCheck() || |
2195 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 2193 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
2196 // An unsigned int array load might overflow and cause a deopt, make sure it | 2194 // An unsigned int array load might overflow and cause a deopt, make sure it |
2197 // has an environment. | 2195 // has an environment. |
2198 return can_deoptimize ? AssignEnvironment(result) : result; | 2196 return can_deoptimize ? AssignEnvironment(result) : result; |
2199 } | 2197 } |
2200 | 2198 |
2201 | 2199 |
2202 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 2200 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
2203 LOperand* context = UseFixed(instr->context(), esi); | 2201 LOperand* context = UseFixed(instr->context(), esi); |
2204 LOperand* object = UseFixed(instr->object(), edx); | 2202 LOperand* object = UseFixed(instr->object(), edx); |
2205 LOperand* key = UseFixed(instr->key(), ecx); | 2203 LOperand* key = UseFixed(instr->key(), ecx); |
2206 | 2204 |
2207 LLoadKeyedGeneric* result = | 2205 LLoadKeyedGeneric* result = |
2208 new(zone()) LLoadKeyedGeneric(context, object, key); | 2206 new(zone()) LLoadKeyedGeneric(context, object, key); |
2209 return MarkAsCall(DefineFixed(result, eax), instr); | 2207 return MarkAsCall(DefineFixed(result, eax), instr); |
2210 } | 2208 } |
2211 | 2209 |
2212 | 2210 |
2213 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { | 2211 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { |
2214 ElementsKind elements_kind = instr->elements_kind(); | 2212 ElementsKind elements_kind = instr->elements_kind(); |
2215 | 2213 |
2216 // Determine if we need a byte register in this case for the value. | 2214 // Determine if we need a byte register in this case for the value. |
2217 bool val_is_fixed_register = | 2215 bool val_is_fixed_register = |
2218 elements_kind == EXTERNAL_BYTE_ELEMENTS || | 2216 elements_kind == EXTERNAL_BYTE_ELEMENTS || |
2219 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || | 2217 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
2220 elements_kind == EXTERNAL_PIXEL_ELEMENTS; | 2218 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
| 2219 elements_kind == UINT8_ELEMENTS || |
| 2220 elements_kind == INT8_ELEMENTS || |
| 2221 elements_kind == UINT8_CLAMPED_ELEMENTS; |
2221 if (val_is_fixed_register) { | 2222 if (val_is_fixed_register) { |
2222 return UseFixed(instr->value(), eax); | 2223 return UseFixed(instr->value(), eax); |
2223 } | 2224 } |
2224 | 2225 |
2225 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && | 2226 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && |
2226 IsDoubleOrFloatElementsKind(elements_kind)) { | 2227 IsDoubleOrFloatElementsKind(elements_kind)) { |
2227 return UseRegisterAtStart(instr->value()); | 2228 return UseRegisterAtStart(instr->value()); |
2228 } | 2229 } |
2229 | 2230 |
2230 return UseRegister(instr->value()); | 2231 return UseRegister(instr->value()); |
2231 } | 2232 } |
2232 | 2233 |
2233 | 2234 |
2234 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2235 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2235 if (!instr->is_external()) { | 2236 if (!instr->is_external() && !instr->is_fixed_typed_array()) { |
2236 ASSERT(instr->elements()->representation().IsTagged()); | 2237 ASSERT(instr->elements()->representation().IsTagged()); |
2237 ASSERT(instr->key()->representation().IsInteger32() || | 2238 ASSERT(instr->key()->representation().IsInteger32() || |
2238 instr->key()->representation().IsSmi()); | 2239 instr->key()->representation().IsSmi()); |
2239 | 2240 |
2240 if (instr->value()->representation().IsDouble()) { | 2241 if (instr->value()->representation().IsDouble()) { |
2241 LOperand* object = UseRegisterAtStart(instr->elements()); | 2242 LOperand* object = UseRegisterAtStart(instr->elements()); |
2242 LOperand* val = NULL; | 2243 LOperand* val = NULL; |
2243 val = UseRegisterAtStart(instr->value()); | 2244 val = UseRegisterAtStart(instr->value()); |
2244 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2245 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2245 return new(zone()) LStoreKeyed(object, key, val); | 2246 return new(zone()) LStoreKeyed(object, key, val); |
(...skipping 11 matching lines...) Expand all Loading... |
2257 val = UseRegisterOrConstantAtStart(instr->value()); | 2258 val = UseRegisterOrConstantAtStart(instr->value()); |
2258 key = UseRegisterOrConstantAtStart(instr->key()); | 2259 key = UseRegisterOrConstantAtStart(instr->key()); |
2259 } | 2260 } |
2260 return new(zone()) LStoreKeyed(obj, key, val); | 2261 return new(zone()) LStoreKeyed(obj, key, val); |
2261 } | 2262 } |
2262 } | 2263 } |
2263 | 2264 |
2264 ElementsKind elements_kind = instr->elements_kind(); | 2265 ElementsKind elements_kind = instr->elements_kind(); |
2265 ASSERT( | 2266 ASSERT( |
2266 (instr->value()->representation().IsInteger32() && | 2267 (instr->value()->representation().IsInteger32() && |
2267 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2268 !IsDoubleOrFloatElementsKind(elements_kind)) || |
2268 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | |
2269 (instr->value()->representation().IsDouble() && | 2269 (instr->value()->representation().IsDouble() && |
2270 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2270 IsDoubleOrFloatElementsKind(elements_kind))); |
2271 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2271 ASSERT((instr->is_fixed_typed_array() && |
2272 ASSERT(instr->elements()->representation().IsExternal()); | 2272 instr->elements()->representation().IsTagged()) || |
| 2273 (instr->is_external() && |
| 2274 instr->elements()->representation().IsExternal())); |
2273 | 2275 |
2274 LOperand* external_pointer = UseRegister(instr->elements()); | 2276 LOperand* backing_store = UseRegister(instr->elements()); |
2275 LOperand* val = GetStoreKeyedValueOperand(instr); | 2277 LOperand* val = GetStoreKeyedValueOperand(instr); |
2276 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2278 bool clobbers_key = ExternalArrayOpRequiresTemp( |
2277 instr->key()->representation(), elements_kind); | 2279 instr->key()->representation(), elements_kind); |
2278 LOperand* key = clobbers_key | 2280 LOperand* key = clobbers_key |
2279 ? UseTempRegister(instr->key()) | 2281 ? UseTempRegister(instr->key()) |
2280 : UseRegisterOrConstantAtStart(instr->key()); | 2282 : UseRegisterOrConstantAtStart(instr->key()); |
2281 return new(zone()) LStoreKeyed(external_pointer, | 2283 return new(zone()) LStoreKeyed(backing_store, key, val); |
2282 key, | |
2283 val); | |
2284 } | 2284 } |
2285 | 2285 |
2286 | 2286 |
2287 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2287 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2288 LOperand* context = UseFixed(instr->context(), esi); | 2288 LOperand* context = UseFixed(instr->context(), esi); |
2289 LOperand* object = UseFixed(instr->object(), edx); | 2289 LOperand* object = UseFixed(instr->object(), edx); |
2290 LOperand* key = UseFixed(instr->key(), ecx); | 2290 LOperand* key = UseFixed(instr->key(), ecx); |
2291 LOperand* value = UseFixed(instr->value(), eax); | 2291 LOperand* value = UseFixed(instr->value(), eax); |
2292 | 2292 |
2293 ASSERT(instr->object()->representation().IsTagged()); | 2293 ASSERT(instr->object()->representation().IsTagged()); |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2680 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2680 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2681 LOperand* object = UseRegister(instr->object()); | 2681 LOperand* object = UseRegister(instr->object()); |
2682 LOperand* index = UseTempRegister(instr->index()); | 2682 LOperand* index = UseTempRegister(instr->index()); |
2683 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2683 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2684 } | 2684 } |
2685 | 2685 |
2686 | 2686 |
2687 } } // namespace v8::internal | 2687 } } // namespace v8::internal |
2688 | 2688 |
2689 #endif // V8_TARGET_ARCH_IA32 | 2689 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |