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_typed_elements()) { | 2156 if (!instr->is_external()) { |
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 !(IsDoubleOrFloatElementsKind(instr->elements_kind()))) || | 2162 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2163 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2163 (instr->representation().IsDouble() && | 2164 (instr->representation().IsDouble() && |
2164 (IsDoubleOrFloatElementsKind(instr->elements_kind())))); | 2165 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
2165 LOperand* backing_store = UseRegister(instr->elements()); | 2166 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
2166 result = new(zone()) LLoadKeyed(backing_store, key); | 2167 LOperand* external_pointer = UseRegister(instr->elements()); |
| 2168 result = new(zone()) LLoadKeyed(external_pointer, key); |
2167 } | 2169 } |
2168 | 2170 |
2169 DefineAsRegister(result); | 2171 DefineAsRegister(result); |
2170 bool can_deoptimize = instr->RequiresHoleCheck() || | 2172 bool can_deoptimize = instr->RequiresHoleCheck() || |
2171 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 2173 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
2172 // An unsigned int array load might overflow and cause a deopt, make sure it | 2174 // An unsigned int array load might overflow and cause a deopt, make sure it |
2173 // has an environment. | 2175 // has an environment. |
2174 return can_deoptimize ? AssignEnvironment(result) : result; | 2176 return can_deoptimize ? AssignEnvironment(result) : result; |
2175 } | 2177 } |
2176 | 2178 |
2177 | 2179 |
2178 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 2180 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
2179 LOperand* context = UseFixed(instr->context(), esi); | 2181 LOperand* context = UseFixed(instr->context(), esi); |
2180 LOperand* object = UseFixed(instr->object(), edx); | 2182 LOperand* object = UseFixed(instr->object(), edx); |
2181 LOperand* key = UseFixed(instr->key(), ecx); | 2183 LOperand* key = UseFixed(instr->key(), ecx); |
2182 | 2184 |
2183 LLoadKeyedGeneric* result = | 2185 LLoadKeyedGeneric* result = |
2184 new(zone()) LLoadKeyedGeneric(context, object, key); | 2186 new(zone()) LLoadKeyedGeneric(context, object, key); |
2185 return MarkAsCall(DefineFixed(result, eax), instr); | 2187 return MarkAsCall(DefineFixed(result, eax), instr); |
2186 } | 2188 } |
2187 | 2189 |
2188 | 2190 |
2189 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { | 2191 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) { |
2190 ElementsKind elements_kind = instr->elements_kind(); | 2192 ElementsKind elements_kind = instr->elements_kind(); |
2191 | 2193 |
2192 // Determine if we need a byte register in this case for the value. | 2194 // Determine if we need a byte register in this case for the value. |
2193 bool val_is_fixed_register = | 2195 bool val_is_fixed_register = |
2194 elements_kind == EXTERNAL_BYTE_ELEMENTS || | 2196 elements_kind == EXTERNAL_BYTE_ELEMENTS || |
2195 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || | 2197 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
2196 elements_kind == EXTERNAL_PIXEL_ELEMENTS || | 2198 elements_kind == EXTERNAL_PIXEL_ELEMENTS; |
2197 elements_kind == UINT8_ELEMENTS || | |
2198 elements_kind == INT8_ELEMENTS || | |
2199 elements_kind == UINT8_CLAMPED_ELEMENTS; | |
2200 if (val_is_fixed_register) { | 2199 if (val_is_fixed_register) { |
2201 return UseFixed(instr->value(), eax); | 2200 return UseFixed(instr->value(), eax); |
2202 } | 2201 } |
2203 | 2202 |
2204 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && | 2203 if (!CpuFeatures::IsSafeForSnapshot(SSE2) && |
2205 IsDoubleOrFloatElementsKind(elements_kind)) { | 2204 IsDoubleOrFloatElementsKind(elements_kind)) { |
2206 return UseRegisterAtStart(instr->value()); | 2205 return UseRegisterAtStart(instr->value()); |
2207 } | 2206 } |
2208 | 2207 |
2209 return UseRegister(instr->value()); | 2208 return UseRegister(instr->value()); |
2210 } | 2209 } |
2211 | 2210 |
2212 | 2211 |
2213 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2212 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2214 if (!instr->is_typed_elements()) { | 2213 if (!instr->is_external()) { |
2215 ASSERT(instr->elements()->representation().IsTagged()); | 2214 ASSERT(instr->elements()->representation().IsTagged()); |
2216 ASSERT(instr->key()->representation().IsInteger32() || | 2215 ASSERT(instr->key()->representation().IsInteger32() || |
2217 instr->key()->representation().IsSmi()); | 2216 instr->key()->representation().IsSmi()); |
2218 | 2217 |
2219 if (instr->value()->representation().IsDouble()) { | 2218 if (instr->value()->representation().IsDouble()) { |
2220 LOperand* object = UseRegisterAtStart(instr->elements()); | 2219 LOperand* object = UseRegisterAtStart(instr->elements()); |
2221 LOperand* val = NULL; | 2220 LOperand* val = NULL; |
2222 val = UseRegisterAtStart(instr->value()); | 2221 val = UseRegisterAtStart(instr->value()); |
2223 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2222 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); |
2224 return new(zone()) LStoreKeyed(object, key, val); | 2223 return new(zone()) LStoreKeyed(object, key, val); |
(...skipping 11 matching lines...) Expand all Loading... |
2236 val = UseRegisterOrConstantAtStart(instr->value()); | 2235 val = UseRegisterOrConstantAtStart(instr->value()); |
2237 key = UseRegisterOrConstantAtStart(instr->key()); | 2236 key = UseRegisterOrConstantAtStart(instr->key()); |
2238 } | 2237 } |
2239 return new(zone()) LStoreKeyed(obj, key, val); | 2238 return new(zone()) LStoreKeyed(obj, key, val); |
2240 } | 2239 } |
2241 } | 2240 } |
2242 | 2241 |
2243 ElementsKind elements_kind = instr->elements_kind(); | 2242 ElementsKind elements_kind = instr->elements_kind(); |
2244 ASSERT( | 2243 ASSERT( |
2245 (instr->value()->representation().IsInteger32() && | 2244 (instr->value()->representation().IsInteger32() && |
2246 !IsDoubleOrFloatElementsKind(elements_kind)) || | 2245 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2246 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2247 (instr->value()->representation().IsDouble() && | 2247 (instr->value()->representation().IsDouble() && |
2248 IsDoubleOrFloatElementsKind(elements_kind))); | 2248 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
2249 ASSERT((instr->is_fixed_typed_array() && | 2249 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
2250 instr->elements()->representation().IsTagged()) || | 2250 ASSERT(instr->elements()->representation().IsExternal()); |
2251 (instr->is_external() && | |
2252 instr->elements()->representation().IsExternal())); | |
2253 | 2251 |
2254 LOperand* backing_store = UseRegister(instr->elements()); | 2252 LOperand* external_pointer = UseRegister(instr->elements()); |
2255 LOperand* val = GetStoreKeyedValueOperand(instr); | 2253 LOperand* val = GetStoreKeyedValueOperand(instr); |
2256 bool clobbers_key = ExternalArrayOpRequiresTemp( | 2254 bool clobbers_key = ExternalArrayOpRequiresTemp( |
2257 instr->key()->representation(), elements_kind); | 2255 instr->key()->representation(), elements_kind); |
2258 LOperand* key = clobbers_key | 2256 LOperand* key = clobbers_key |
2259 ? UseTempRegister(instr->key()) | 2257 ? UseTempRegister(instr->key()) |
2260 : UseRegisterOrConstantAtStart(instr->key()); | 2258 : UseRegisterOrConstantAtStart(instr->key()); |
2261 return new(zone()) LStoreKeyed(backing_store, key, val); | 2259 return new(zone()) LStoreKeyed(external_pointer, |
| 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 |