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 1866 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 if (to.IsTagged()) { | 1877 if (to.IsTagged()) { |
1878 HValue* val = instr->value(); | 1878 HValue* val = instr->value(); |
1879 LOperand* value = UseRegister(val); | 1879 LOperand* value = UseRegister(val); |
1880 if (val->CheckFlag(HInstruction::kUint32)) { | 1880 if (val->CheckFlag(HInstruction::kUint32)) { |
1881 LOperand* temp = FixedTemp(xmm1); | 1881 LOperand* temp = FixedTemp(xmm1); |
1882 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); | 1882 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); |
1883 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1883 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1884 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1884 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1885 return DefineSameAsFirst(new(zone()) LSmiTag(value)); | 1885 return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
1886 } else { | 1886 } else { |
1887 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1887 LOperand* temp = (kSmiValueSize == 31) ? FixedTemp(xmm1) : NULL; |
| 1888 LNumberTagI* result = new(zone()) LNumberTagI(value, temp); |
1888 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1889 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1889 } | 1890 } |
1890 } else if (to.IsSmi()) { | 1891 } else if (to.IsSmi()) { |
1891 HValue* val = instr->value(); | 1892 HValue* val = instr->value(); |
1892 LOperand* value = UseRegister(val); | 1893 LOperand* value = UseRegister(val); |
1893 LInstruction* result = | 1894 LInstruction* result = |
1894 DefineAsRegister(new(zone()) LInteger32ToSmi(value)); | 1895 DefineAsRegister(new(zone()) LInteger32ToSmi(value)); |
1895 if (val->HasRange() && val->range()->IsInSmiRange()) { | 1896 if (val->HasRange() && val->range()->IsInSmiRange()) { |
1896 return result; | 1897 return result; |
1897 } | 1898 } |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2111 | 2112 |
2112 | 2113 |
2113 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 2114 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
2114 HLoadExternalArrayPointer* instr) { | 2115 HLoadExternalArrayPointer* instr) { |
2115 LOperand* input = UseRegisterAtStart(instr->value()); | 2116 LOperand* input = UseRegisterAtStart(instr->value()); |
2116 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 2117 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
2117 } | 2118 } |
2118 | 2119 |
2119 | 2120 |
2120 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2121 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
2121 ASSERT(instr->key()->representation().IsInteger32()); | 2122 ASSERT((kSmiValueSize == 32 && |
| 2123 instr->key()->representation().IsInteger32()) || |
| 2124 (kSmiValueSize == 31 && |
| 2125 instr->key()->representation().IsSmiOrInteger32())); |
2122 ElementsKind elements_kind = instr->elements_kind(); | 2126 ElementsKind elements_kind = instr->elements_kind(); |
2123 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2127 bool clobbers_key = instr->key()->representation().IsSmi(); |
| 2128 LOperand* key = clobbers_key |
| 2129 ? UseTempRegister(instr->key()) |
| 2130 : UseRegisterOrConstantAtStart(instr->key()); |
2124 LLoadKeyed* result = NULL; | 2131 LLoadKeyed* result = NULL; |
2125 | 2132 |
2126 if (!instr->is_external()) { | 2133 if (!instr->is_external()) { |
2127 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2134 LOperand* obj = UseRegisterAtStart(instr->elements()); |
2128 result = new(zone()) LLoadKeyed(obj, key); | 2135 result = new(zone()) LLoadKeyed(obj, key); |
2129 } else { | 2136 } else { |
2130 ASSERT( | 2137 ASSERT( |
2131 (instr->representation().IsInteger32() && | 2138 (instr->representation().IsInteger32() && |
2132 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2139 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2133 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2140 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
(...skipping 17 matching lines...) Expand all Loading... |
2151 LOperand* object = UseFixed(instr->object(), rdx); | 2158 LOperand* object = UseFixed(instr->object(), rdx); |
2152 LOperand* key = UseFixed(instr->key(), rax); | 2159 LOperand* key = UseFixed(instr->key(), rax); |
2153 | 2160 |
2154 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); | 2161 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); |
2155 return MarkAsCall(DefineFixed(result, rax), instr); | 2162 return MarkAsCall(DefineFixed(result, rax), instr); |
2156 } | 2163 } |
2157 | 2164 |
2158 | 2165 |
2159 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2166 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2160 ElementsKind elements_kind = instr->elements_kind(); | 2167 ElementsKind elements_kind = instr->elements_kind(); |
| 2168 bool clobbers_key = instr->key()->representation().IsSmi(); |
2161 | 2169 |
2162 if (!instr->is_external()) { | 2170 if (!instr->is_external()) { |
2163 ASSERT(instr->elements()->representation().IsTagged()); | 2171 ASSERT(instr->elements()->representation().IsTagged()); |
2164 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2172 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2165 LOperand* object = NULL; | 2173 LOperand* object = NULL; |
2166 LOperand* key = NULL; | 2174 LOperand* key = NULL; |
2167 LOperand* val = NULL; | 2175 LOperand* val = NULL; |
2168 | 2176 |
2169 if (instr->value()->representation().IsDouble()) { | 2177 if (instr->value()->representation().IsDouble()) { |
2170 object = UseRegisterAtStart(instr->elements()); | 2178 object = UseRegisterAtStart(instr->elements()); |
2171 val = UseTempRegister(instr->value()); | 2179 val = UseTempRegister(instr->value()); |
2172 key = UseRegisterOrConstantAtStart(instr->key()); | 2180 key = clobbers_key ? UseTempRegister(instr->key()) |
| 2181 : UseRegisterOrConstantAtStart(instr->key()); |
2173 } else { | 2182 } else { |
2174 ASSERT(instr->value()->representation().IsSmiOrTagged()); | 2183 ASSERT(instr->value()->representation().IsSmiOrTagged()); |
2175 object = UseTempRegister(instr->elements()); | 2184 object = UseTempRegister(instr->elements()); |
2176 if (needs_write_barrier) { | 2185 if (needs_write_barrier) { |
2177 val = UseTempRegister(instr->value()); | 2186 val = UseTempRegister(instr->value()); |
2178 key = UseTempRegister(instr->key()); | 2187 key = UseTempRegister(instr->key()); |
2179 } else { | 2188 } else { |
2180 val = UseRegisterOrConstantAtStart(instr->value()); | 2189 val = UseRegisterOrConstantAtStart(instr->value()); |
2181 key = UseRegisterOrConstantAtStart(instr->key()); | 2190 key = clobbers_key ? UseTempRegister(instr->key()) |
| 2191 : UseRegisterOrConstantAtStart(instr->key()); |
2182 } | 2192 } |
2183 } | 2193 } |
2184 | 2194 |
2185 return new(zone()) LStoreKeyed(object, key, val); | 2195 return new(zone()) LStoreKeyed(object, key, val); |
2186 } | 2196 } |
2187 | 2197 |
2188 ASSERT( | 2198 ASSERT( |
2189 (instr->value()->representation().IsInteger32() && | 2199 (instr->value()->representation().IsInteger32() && |
2190 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2200 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2191 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2201 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2192 (instr->value()->representation().IsDouble() && | 2202 (instr->value()->representation().IsDouble() && |
2193 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2203 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
2194 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2204 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
2195 ASSERT(instr->elements()->representation().IsExternal()); | 2205 ASSERT(instr->elements()->representation().IsExternal()); |
2196 bool val_is_temp_register = | 2206 bool val_is_temp_register = |
2197 elements_kind == EXTERNAL_PIXEL_ELEMENTS || | 2207 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
2198 elements_kind == EXTERNAL_FLOAT_ELEMENTS; | 2208 elements_kind == EXTERNAL_FLOAT_ELEMENTS; |
2199 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) | 2209 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) |
2200 : UseRegister(instr->value()); | 2210 : UseRegister(instr->value()); |
2201 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2211 LOperand* key = clobbers_key ? UseTempRegister(instr->key()) |
| 2212 : UseRegisterOrConstantAtStart(instr->key()); |
2202 LOperand* external_pointer = UseRegister(instr->elements()); | 2213 LOperand* external_pointer = UseRegister(instr->elements()); |
2203 return new(zone()) LStoreKeyed(external_pointer, key, val); | 2214 return new(zone()) LStoreKeyed(external_pointer, key, val); |
2204 } | 2215 } |
2205 | 2216 |
2206 | 2217 |
2207 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2218 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2208 LOperand* object = UseFixed(instr->object(), rdx); | 2219 LOperand* object = UseFixed(instr->object(), rdx); |
2209 LOperand* key = UseFixed(instr->key(), rcx); | 2220 LOperand* key = UseFixed(instr->key(), rcx); |
2210 LOperand* value = UseFixed(instr->value(), rax); | 2221 LOperand* value = UseFixed(instr->value(), rax); |
2211 | 2222 |
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2563 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2574 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2564 LOperand* object = UseRegister(instr->object()); | 2575 LOperand* object = UseRegister(instr->object()); |
2565 LOperand* index = UseTempRegister(instr->index()); | 2576 LOperand* index = UseTempRegister(instr->index()); |
2566 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2577 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2567 } | 2578 } |
2568 | 2579 |
2569 | 2580 |
2570 } } // namespace v8::internal | 2581 } } // namespace v8::internal |
2571 | 2582 |
2572 #endif // V8_TARGET_ARCH_X64 | 2583 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |