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 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 } | 710 } |
711 | 711 |
712 ASSERT(instr->representation().IsSmiOrInteger32()); | 712 ASSERT(instr->representation().IsSmiOrInteger32()); |
713 ASSERT(instr->left()->representation().Equals(instr->representation())); | 713 ASSERT(instr->left()->representation().Equals(instr->representation())); |
714 ASSERT(instr->right()->representation().Equals(instr->representation())); | 714 ASSERT(instr->right()->representation().Equals(instr->representation())); |
715 LOperand* left = UseRegisterAtStart(instr->left()); | 715 LOperand* left = UseRegisterAtStart(instr->left()); |
716 | 716 |
717 HValue* right_value = instr->right(); | 717 HValue* right_value = instr->right(); |
718 LOperand* right = NULL; | 718 LOperand* right = NULL; |
719 int constant_value = 0; | 719 int constant_value = 0; |
| 720 bool does_deopt = false; |
720 if (right_value->IsConstant()) { | 721 if (right_value->IsConstant()) { |
721 HConstant* constant = HConstant::cast(right_value); | 722 HConstant* constant = HConstant::cast(right_value); |
722 right = chunk_->DefineConstantOperand(constant); | 723 right = chunk_->DefineConstantOperand(constant); |
723 constant_value = constant->Integer32Value() & 0x1f; | 724 constant_value = constant->Integer32Value() & 0x1f; |
| 725 if (SmiValuesAre31Bits() && instr->representation().IsSmi() && |
| 726 constant_value > 0) { |
| 727 // Left shifts can deoptimize if we shift by > 0 and the result cannot be |
| 728 // truncated to smi. |
| 729 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
| 730 if (!it.value()->CheckFlag(HValue::kTruncatingToSmi)) { |
| 731 does_deopt = true; |
| 732 break; |
| 733 } |
| 734 } |
| 735 } |
724 } else { | 736 } else { |
725 right = UseFixed(right_value, rcx); | 737 right = UseFixed(right_value, rcx); |
726 } | 738 } |
727 | 739 |
728 // Shift operations can only deoptimize if we do a logical shift by 0 and | 740 // Shift operations can only deoptimize if we do a logical shift by 0 and |
729 // the result cannot be truncated to int32. | 741 // the result cannot be truncated to int32. |
730 bool does_deopt = false; | |
731 if (op == Token::SHR && constant_value == 0) { | 742 if (op == Token::SHR && constant_value == 0) { |
732 if (FLAG_opt_safe_uint32_operations) { | 743 if (FLAG_opt_safe_uint32_operations) { |
733 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | 744 does_deopt = !instr->CheckFlag(HInstruction::kUint32); |
734 } else { | 745 } else { |
735 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { | 746 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
736 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { | 747 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
737 does_deopt = true; | 748 does_deopt = true; |
738 break; | 749 break; |
739 } | 750 } |
740 } | 751 } |
(...skipping 1107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1848 if (to.IsTagged()) { | 1859 if (to.IsTagged()) { |
1849 HValue* val = instr->value(); | 1860 HValue* val = instr->value(); |
1850 LOperand* value = UseRegister(val); | 1861 LOperand* value = UseRegister(val); |
1851 if (val->CheckFlag(HInstruction::kUint32)) { | 1862 if (val->CheckFlag(HInstruction::kUint32)) { |
1852 LOperand* temp = FixedTemp(xmm1); | 1863 LOperand* temp = FixedTemp(xmm1); |
1853 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); | 1864 LNumberTagU* result = new(zone()) LNumberTagU(value, temp); |
1854 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1865 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1855 } else if (val->HasRange() && val->range()->IsInSmiRange()) { | 1866 } else if (val->HasRange() && val->range()->IsInSmiRange()) { |
1856 return DefineSameAsFirst(new(zone()) LSmiTag(value)); | 1867 return DefineSameAsFirst(new(zone()) LSmiTag(value)); |
1857 } else { | 1868 } else { |
1858 LNumberTagI* result = new(zone()) LNumberTagI(value); | 1869 LOperand* temp = (SmiValuesAre31Bits()) ? FixedTemp(xmm1) : NULL; |
| 1870 LNumberTagI* result = new(zone()) LNumberTagI(value, temp); |
1859 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1871 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1860 } | 1872 } |
1861 } else if (to.IsSmi()) { | 1873 } else if (to.IsSmi()) { |
1862 HValue* val = instr->value(); | 1874 HValue* val = instr->value(); |
1863 LOperand* value = UseRegister(val); | 1875 LOperand* value = UseRegister(val); |
1864 LInstruction* result = | 1876 LInstruction* result = |
1865 DefineAsRegister(new(zone()) LInteger32ToSmi(value)); | 1877 DefineAsRegister(new(zone()) LInteger32ToSmi(value)); |
1866 if (val->HasRange() && val->range()->IsInSmiRange()) { | 1878 if (val->HasRange() && val->range()->IsInSmiRange()) { |
1867 return result; | 1879 return result; |
1868 } | 1880 } |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2081 | 2093 |
2082 | 2094 |
2083 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( | 2095 LInstruction* LChunkBuilder::DoLoadExternalArrayPointer( |
2084 HLoadExternalArrayPointer* instr) { | 2096 HLoadExternalArrayPointer* instr) { |
2085 LOperand* input = UseRegisterAtStart(instr->value()); | 2097 LOperand* input = UseRegisterAtStart(instr->value()); |
2086 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 2098 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
2087 } | 2099 } |
2088 | 2100 |
2089 | 2101 |
2090 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 2102 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
2091 ASSERT(instr->key()->representation().IsInteger32()); | 2103 ASSERT((SmiValuesAre32Bits() && |
| 2104 instr->key()->representation().IsInteger32()) || |
| 2105 (SmiValuesAre31Bits() && |
| 2106 instr->key()->representation().IsSmiOrInteger32())); |
2092 ElementsKind elements_kind = instr->elements_kind(); | 2107 ElementsKind elements_kind = instr->elements_kind(); |
2093 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2108 bool clobbers_key = instr->key()->representation().IsSmi(); |
| 2109 LOperand* key = clobbers_key |
| 2110 ? UseTempRegister(instr->key()) |
| 2111 : UseRegisterOrConstantAtStart(instr->key()); |
2094 LLoadKeyed* result = NULL; | 2112 LLoadKeyed* result = NULL; |
2095 | 2113 |
2096 if (!instr->is_external()) { | 2114 if (!instr->is_external()) { |
2097 LOperand* obj = UseRegisterAtStart(instr->elements()); | 2115 LOperand* obj = UseRegisterAtStart(instr->elements()); |
2098 result = new(zone()) LLoadKeyed(obj, key); | 2116 result = new(zone()) LLoadKeyed(obj, key); |
2099 } else { | 2117 } else { |
2100 ASSERT( | 2118 ASSERT( |
2101 (instr->representation().IsInteger32() && | 2119 (instr->representation().IsInteger32() && |
2102 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2120 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2103 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2121 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
(...skipping 17 matching lines...) Expand all Loading... |
2121 LOperand* object = UseFixed(instr->object(), rdx); | 2139 LOperand* object = UseFixed(instr->object(), rdx); |
2122 LOperand* key = UseFixed(instr->key(), rax); | 2140 LOperand* key = UseFixed(instr->key(), rax); |
2123 | 2141 |
2124 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); | 2142 LLoadKeyedGeneric* result = new(zone()) LLoadKeyedGeneric(object, key); |
2125 return MarkAsCall(DefineFixed(result, rax), instr); | 2143 return MarkAsCall(DefineFixed(result, rax), instr); |
2126 } | 2144 } |
2127 | 2145 |
2128 | 2146 |
2129 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 2147 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
2130 ElementsKind elements_kind = instr->elements_kind(); | 2148 ElementsKind elements_kind = instr->elements_kind(); |
| 2149 bool clobbers_key = instr->key()->representation().IsSmi(); |
2131 | 2150 |
2132 if (!instr->is_external()) { | 2151 if (!instr->is_external()) { |
2133 ASSERT(instr->elements()->representation().IsTagged()); | 2152 ASSERT(instr->elements()->representation().IsTagged()); |
2134 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2153 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2135 LOperand* object = NULL; | 2154 LOperand* object = NULL; |
2136 LOperand* key = NULL; | 2155 LOperand* key = NULL; |
2137 LOperand* val = NULL; | 2156 LOperand* val = NULL; |
2138 | 2157 |
2139 if (instr->value()->representation().IsDouble()) { | 2158 if (instr->value()->representation().IsDouble()) { |
2140 object = UseRegisterAtStart(instr->elements()); | 2159 object = UseRegisterAtStart(instr->elements()); |
2141 val = UseTempRegister(instr->value()); | 2160 val = UseTempRegister(instr->value()); |
2142 key = UseRegisterOrConstantAtStart(instr->key()); | 2161 key = clobbers_key ? UseTempRegister(instr->key()) |
| 2162 : UseRegisterOrConstantAtStart(instr->key()); |
2143 } else { | 2163 } else { |
2144 ASSERT(instr->value()->representation().IsSmiOrTagged()); | 2164 ASSERT(instr->value()->representation().IsSmiOrTagged()); |
2145 object = UseTempRegister(instr->elements()); | 2165 object = UseTempRegister(instr->elements()); |
2146 if (needs_write_barrier) { | 2166 if (needs_write_barrier) { |
2147 val = UseTempRegister(instr->value()); | 2167 val = UseTempRegister(instr->value()); |
2148 key = UseTempRegister(instr->key()); | 2168 key = UseTempRegister(instr->key()); |
2149 } else { | 2169 } else { |
2150 val = UseRegisterOrConstantAtStart(instr->value()); | 2170 val = UseRegisterOrConstantAtStart(instr->value()); |
2151 key = UseRegisterOrConstantAtStart(instr->key()); | 2171 key = clobbers_key ? UseTempRegister(instr->key()) |
| 2172 : UseRegisterOrConstantAtStart(instr->key()); |
2152 } | 2173 } |
2153 } | 2174 } |
2154 | 2175 |
2155 return new(zone()) LStoreKeyed(object, key, val); | 2176 return new(zone()) LStoreKeyed(object, key, val); |
2156 } | 2177 } |
2157 | 2178 |
2158 ASSERT( | 2179 ASSERT( |
2159 (instr->value()->representation().IsInteger32() && | 2180 (instr->value()->representation().IsInteger32() && |
2160 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 2181 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
2161 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2182 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
2162 (instr->value()->representation().IsDouble() && | 2183 (instr->value()->representation().IsDouble() && |
2163 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2184 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
2164 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2185 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
2165 ASSERT(instr->elements()->representation().IsExternal()); | 2186 ASSERT(instr->elements()->representation().IsExternal()); |
2166 bool val_is_temp_register = | 2187 bool val_is_temp_register = |
2167 elements_kind == EXTERNAL_PIXEL_ELEMENTS || | 2188 elements_kind == EXTERNAL_PIXEL_ELEMENTS || |
2168 elements_kind == EXTERNAL_FLOAT_ELEMENTS; | 2189 elements_kind == EXTERNAL_FLOAT_ELEMENTS; |
2169 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) | 2190 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value()) |
2170 : UseRegister(instr->value()); | 2191 : UseRegister(instr->value()); |
2171 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 2192 LOperand* key = clobbers_key ? UseTempRegister(instr->key()) |
| 2193 : UseRegisterOrConstantAtStart(instr->key()); |
2172 LOperand* external_pointer = UseRegister(instr->elements()); | 2194 LOperand* external_pointer = UseRegister(instr->elements()); |
2173 return new(zone()) LStoreKeyed(external_pointer, key, val); | 2195 return new(zone()) LStoreKeyed(external_pointer, key, val); |
2174 } | 2196 } |
2175 | 2197 |
2176 | 2198 |
2177 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2199 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
2178 LOperand* object = UseFixed(instr->object(), rdx); | 2200 LOperand* object = UseFixed(instr->object(), rdx); |
2179 LOperand* key = UseFixed(instr->key(), rcx); | 2201 LOperand* key = UseFixed(instr->key(), rcx); |
2180 LOperand* value = UseFixed(instr->value(), rax); | 2202 LOperand* value = UseFixed(instr->value(), rax); |
2181 | 2203 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2527 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2549 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2528 LOperand* object = UseRegister(instr->object()); | 2550 LOperand* object = UseRegister(instr->object()); |
2529 LOperand* index = UseTempRegister(instr->index()); | 2551 LOperand* index = UseTempRegister(instr->index()); |
2530 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2552 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2531 } | 2553 } |
2532 | 2554 |
2533 | 2555 |
2534 } } // namespace v8::internal | 2556 } } // namespace v8::internal |
2535 | 2557 |
2536 #endif // V8_TARGET_ARCH_X64 | 2558 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |