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 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2112 | 2112 |
2113 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 2113 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
2114 LOperand* object = UseFixed(instr->object(), rdx); | 2114 LOperand* object = UseFixed(instr->object(), rdx); |
2115 LOperand* key = UseFixed(instr->key(), rax); | 2115 LOperand* key = UseFixed(instr->key(), rax); |
2116 | 2116 |
2117 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); | 2117 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); |
2118 return MarkAsCall(DefineFixed(result, rax), instr); | 2118 return MarkAsCall(DefineFixed(result, rax), instr); |
2119 } | 2119 } |
2120 | 2120 |
2121 | 2121 |
| 2122 // DoStoreKeyed and DoStoreNamedField have special considerations for allowing |
| 2123 // use of a constant instead of a register. |
| 2124 static bool StoreConstantValueAllowed(HValue* value) { |
| 2125 if (value->IsConstant()) { |
| 2126 HConstant* constant_value = HConstant::cast(value); |
| 2127 return constant_value->HasSmiValue() |
| 2128 || constant_value->HasDoubleValue() |
| 2129 || constant_value->ImmortalImmovable(); |
| 2130 } |
| 2131 return false; |
| 2132 } |
| 2133 |
| 2134 |
2122 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2135 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2123 ElementsKind elements_kind = instr->elements_kind(); | 2136 ElementsKind elements_kind = instr->elements_kind(); |
2124 bool clobbers_key = instr->key()->representation().IsTagged(); | 2137 bool clobbers_key = instr->key()->representation().IsTagged(); |
2125 | 2138 |
2126 if (!instr->is_external()) { | 2139 if (!instr->is_external()) { |
2127 ASSERT(instr->elements()->representation().IsTagged()); | 2140 ASSERT(instr->elements()->representation().IsTagged()); |
2128 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2141 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2129 LOperand* object = NULL; | 2142 LOperand* object = NULL; |
2130 LOperand* key = NULL; | 2143 LOperand* key = NULL; |
2131 LOperand* val = NULL; | 2144 LOperand* val = NULL; |
2132 | 2145 |
2133 if (instr->value()->representation().IsDouble()) { | 2146 if (instr->value()->representation().IsDouble()) { |
2134 object = UseRegisterAtStart(instr->elements()); | 2147 object = UseRegisterAtStart(instr->elements()); |
2135 val = UseTempRegister(instr->value()); | 2148 val = UseTempRegister(instr->value()); |
2136 key = clobbers_key ? UseTempRegister(instr->key()) | 2149 key = clobbers_key ? UseTempRegister(instr->key()) |
2137 : UseRegisterOrConstantAtStart(instr->key()); | 2150 : UseRegisterOrConstantAtStart(instr->key()); |
2138 } else { | 2151 } else { |
2139 ASSERT(instr->value()->representation().IsTagged()); | 2152 ASSERT(instr->value()->representation().IsTagged()); |
2140 object = UseTempRegister(instr->elements()); | 2153 object = UseTempRegister(instr->elements()); |
2141 val = needs_write_barrier ? UseTempRegister(instr->value()) | 2154 if (needs_write_barrier) { |
2142 : UseRegisterOrConstantAtStart(instr->value()); | 2155 val = UseTempRegister(instr->value()); |
2143 key = (clobbers_key || needs_write_barrier) | 2156 key = UseTempRegister(instr->key()); |
2144 ? UseTempRegister(instr->key()) | 2157 } else { |
2145 : UseRegisterOrConstantAtStart(instr->key()); | 2158 if (StoreConstantValueAllowed(instr->value())) { |
| 2159 val = UseRegisterOrConstantAtStart(instr->value()); |
| 2160 } else { |
| 2161 val = UseRegisterAtStart(instr->value()); |
| 2162 } |
| 2163 |
| 2164 if (clobbers_key) { |
| 2165 key = UseTempRegister(instr->key()); |
| 2166 } else if (StoreConstantValueAllowed(instr->key())) { |
| 2167 key = UseRegisterOrConstantAtStart(instr->key()); |
| 2168 } else { |
| 2169 key = UseRegisterAtStart(instr->key()); |
| 2170 } |
| 2171 } |
2146 } | 2172 } |
2147 | 2173 |
2148 return new(zone()) LStoreKeyed(object, key, val); | 2174 return new(zone()) LStoreKeyed(object, key, val); |
2149 } | 2175 } |
2150 | 2176 |
2151 ASSERT( | 2177 ASSERT( |
2152 (instr->value()->representation().IsInteger32() && | 2178 (instr->value()->representation().IsInteger32() && |
2153 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2179 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2154 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2180 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2155 (instr->value()->representation().IsDouble() && | 2181 (instr->value()->representation().IsDouble() && |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2229 if (needs_write_barrier) { | 2255 if (needs_write_barrier) { |
2230 obj = instr->is_in_object() | 2256 obj = instr->is_in_object() |
2231 ? UseRegister(instr->object()) | 2257 ? UseRegister(instr->object()) |
2232 : UseTempRegister(instr->object()); | 2258 : UseTempRegister(instr->object()); |
2233 } else { | 2259 } else { |
2234 obj = needs_write_barrier_for_map | 2260 obj = needs_write_barrier_for_map |
2235 ? UseRegister(instr->object()) | 2261 ? UseRegister(instr->object()) |
2236 : UseRegisterAtStart(instr->object()); | 2262 : UseRegisterAtStart(instr->object()); |
2237 } | 2263 } |
2238 | 2264 |
2239 bool register_or_constant = false; | |
2240 if (instr->value()->IsConstant()) { | |
2241 HConstant* constant_value = HConstant::cast(instr->value()); | |
2242 register_or_constant = constant_value->HasInteger32Value() | |
2243 || constant_value->HasDoubleValue() | |
2244 || constant_value->ImmortalImmovable(); | |
2245 } | |
2246 | |
2247 LOperand* val; | 2265 LOperand* val; |
2248 if (needs_write_barrier) { | 2266 if (needs_write_barrier) { |
2249 val = UseTempRegister(instr->value()); | 2267 val = UseTempRegister(instr->value()); |
2250 } else if (register_or_constant) { | 2268 } else if (StoreConstantValueAllowed(instr->value())) { |
2251 val = UseRegisterOrConstant(instr->value()); | 2269 val = UseRegisterOrConstant(instr->value()); |
2252 } else { | 2270 } else { |
2253 val = UseRegister(instr->value()); | 2271 val = UseRegister(instr->value()); |
2254 } | 2272 } |
2255 | 2273 |
2256 // We only need a scratch register if we have a write barrier or we | 2274 // We only need a scratch register if we have a write barrier or we |
2257 // have a store into the properties array (not in-object-property). | 2275 // have a store into the properties array (not in-object-property). |
2258 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || | 2276 LOperand* temp = (!instr->is_in_object() || needs_write_barrier || |
2259 needs_write_barrier_for_map) ? TempRegister() : NULL; | 2277 needs_write_barrier_for_map) ? TempRegister() : NULL; |
2260 | 2278 |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2547 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2565 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2548 LOperand* object = UseRegister(instr->object()); | 2566 LOperand* object = UseRegister(instr->object()); |
2549 LOperand* index = UseTempRegister(instr->index()); | 2567 LOperand* index = UseTempRegister(instr->index()); |
2550 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2568 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2551 } | 2569 } |
2552 | 2570 |
2553 | 2571 |
2554 } } // namespace v8::internal | 2572 } } // namespace v8::internal |
2555 | 2573 |
2556 #endif // V8_TARGET_ARCH_X64 | 2574 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |