| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 845 LOperand* right = NULL; | 845 LOperand* right = NULL; |
| 846 int constant_value = 0; | 846 int constant_value = 0; |
| 847 if (right_value->IsConstant()) { | 847 if (right_value->IsConstant()) { |
| 848 HConstant* constant = HConstant::cast(right_value); | 848 HConstant* constant = HConstant::cast(right_value); |
| 849 right = chunk_->DefineConstantOperand(constant); | 849 right = chunk_->DefineConstantOperand(constant); |
| 850 constant_value = constant->Integer32Value() & 0x1f; | 850 constant_value = constant->Integer32Value() & 0x1f; |
| 851 } else { | 851 } else { |
| 852 right = UseFixed(right_value, ecx); | 852 right = UseFixed(right_value, ecx); |
| 853 } | 853 } |
| 854 | 854 |
| 855 // Shift operations can only deoptimize if we do a logical shift | 855 // Shift operations can only deoptimize if we do a logical shift by 0 and |
| 856 // by 0 and the result cannot be truncated to int32. | 856 // the result cannot be truncated to int32. |
| 857 bool can_deopt = (op == Token::SHR && constant_value == 0); | 857 bool may_deopt = (op == Token::SHR && constant_value == 0); |
| 858 if (can_deopt) { | 858 bool does_deopt = false; |
| 859 bool can_truncate = true; | 859 if (may_deopt) { |
| 860 for (int i = 0; i < instr->uses()->length(); i++) { | 860 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
| 861 if (!instr->uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) { | 861 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
| 862 can_truncate = false; | 862 does_deopt = true; |
| 863 break; | 863 break; |
| 864 } | 864 } |
| 865 } | 865 } |
| 866 can_deopt = !can_truncate; | |
| 867 } | 866 } |
| 868 | 867 |
| 869 LShiftI* result = new LShiftI(op, left, right, can_deopt); | 868 LInstruction* result = |
| 870 return can_deopt | 869 DefineSameAsFirst(new LShiftI(op, left, right, does_deopt)); |
| 871 ? AssignEnvironment(DefineSameAsFirst(result)) | 870 return does_deopt ? AssignEnvironment(result) : result; |
| 872 : DefineSameAsFirst(result); | |
| 873 } | 871 } |
| 874 | 872 |
| 875 | 873 |
| 876 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 874 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 877 HArithmeticBinaryOperation* instr) { | 875 HArithmeticBinaryOperation* instr) { |
| 878 ASSERT(instr->representation().IsDouble()); | 876 ASSERT(instr->representation().IsDouble()); |
| 879 ASSERT(instr->left()->representation().IsDouble()); | 877 ASSERT(instr->left()->representation().IsDouble()); |
| 880 ASSERT(instr->right()->representation().IsDouble()); | 878 ASSERT(instr->right()->representation().IsDouble()); |
| 881 ASSERT(op != Token::MOD); | 879 ASSERT(op != Token::MOD); |
| 882 LOperand* left = UseRegisterAtStart(instr->left()); | 880 LOperand* left = UseRegisterAtStart(instr->left()); |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1883 LOperand* key = UseRegisterAtStart(instr->key()); | 1881 LOperand* key = UseRegisterAtStart(instr->key()); |
| 1884 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); | 1882 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); |
| 1885 return AssignEnvironment(DefineSameAsFirst(result)); | 1883 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1886 } | 1884 } |
| 1887 | 1885 |
| 1888 | 1886 |
| 1889 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( | 1887 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( |
| 1890 HLoadKeyedSpecializedArrayElement* instr) { | 1888 HLoadKeyedSpecializedArrayElement* instr) { |
| 1891 ExternalArrayType array_type = instr->array_type(); | 1889 ExternalArrayType array_type = instr->array_type(); |
| 1892 Representation representation(instr->representation()); | 1890 Representation representation(instr->representation()); |
| 1893 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1891 ASSERT( |
| 1894 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1892 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1893 array_type != kExternalDoubleArray)) || |
| 1894 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1895 array_type == kExternalDoubleArray))); |
| 1895 ASSERT(instr->key()->representation().IsInteger32()); | 1896 ASSERT(instr->key()->representation().IsInteger32()); |
| 1896 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1897 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1897 LOperand* key = UseRegister(instr->key()); | 1898 LOperand* key = UseRegister(instr->key()); |
| 1898 LLoadKeyedSpecializedArrayElement* result = | 1899 LLoadKeyedSpecializedArrayElement* result = |
| 1899 new LLoadKeyedSpecializedArrayElement(external_pointer, | 1900 new LLoadKeyedSpecializedArrayElement(external_pointer, |
| 1900 key); | 1901 key); |
| 1901 LInstruction* load_instr = DefineAsRegister(result); | 1902 LInstruction* load_instr = DefineAsRegister(result); |
| 1902 // An unsigned int array load might overflow and cause a deopt, make sure it | 1903 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1903 // has an environment. | 1904 // has an environment. |
| 1904 return (array_type == kExternalUnsignedIntArray) | 1905 return (array_type == kExternalUnsignedIntArray) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1933 : UseRegisterOrConstantAtStart(instr->key()); | 1934 : UseRegisterOrConstantAtStart(instr->key()); |
| 1934 | 1935 |
| 1935 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); | 1936 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); |
| 1936 } | 1937 } |
| 1937 | 1938 |
| 1938 | 1939 |
| 1939 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( | 1940 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( |
| 1940 HStoreKeyedSpecializedArrayElement* instr) { | 1941 HStoreKeyedSpecializedArrayElement* instr) { |
| 1941 Representation representation(instr->value()->representation()); | 1942 Representation representation(instr->value()->representation()); |
| 1942 ExternalArrayType array_type = instr->array_type(); | 1943 ExternalArrayType array_type = instr->array_type(); |
| 1943 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1944 ASSERT( |
| 1944 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1945 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1946 array_type != kExternalDoubleArray)) || |
| 1947 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1948 array_type == kExternalDoubleArray))); |
| 1945 ASSERT(instr->external_pointer()->representation().IsExternal()); | 1949 ASSERT(instr->external_pointer()->representation().IsExternal()); |
| 1946 ASSERT(instr->key()->representation().IsInteger32()); | 1950 ASSERT(instr->key()->representation().IsInteger32()); |
| 1947 | 1951 |
| 1948 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1952 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1949 LOperand* key = UseRegister(instr->key()); | 1953 LOperand* key = UseRegister(instr->key()); |
| 1950 LOperand* temp = NULL; | 1954 LOperand* temp = NULL; |
| 1951 | 1955 |
| 1952 if (array_type == kExternalPixelArray) { | 1956 if (array_type == kExternalPixelArray) { |
| 1953 // The generated code for pixel array stores requires that the clamped value | 1957 // The generated code for pixel array stores requires that the clamped value |
| 1954 // is in a byte register. eax is an arbitrary choice to satisfy this | 1958 // is in a byte register. eax is an arbitrary choice to satisfy this |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 } | 2198 } |
| 2195 | 2199 |
| 2196 | 2200 |
| 2197 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2201 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 2198 HEnvironment* outer = current_block_->last_environment()->outer(); | 2202 HEnvironment* outer = current_block_->last_environment()->outer(); |
| 2199 current_block_->UpdateEnvironment(outer); | 2203 current_block_->UpdateEnvironment(outer); |
| 2200 return NULL; | 2204 return NULL; |
| 2201 } | 2205 } |
| 2202 | 2206 |
| 2203 | 2207 |
| 2208 LInstruction* LChunkBuilder::DoIn(HIn* instr) { |
| 2209 LOperand* key = UseOrConstantAtStart(instr->key()); |
| 2210 LOperand* object = UseOrConstantAtStart(instr->object()); |
| 2211 LIn* result = new LIn(key, object); |
| 2212 return MarkAsCall(DefineFixed(result, eax), instr); |
| 2213 } |
| 2214 |
| 2215 |
| 2204 } } // namespace v8::internal | 2216 } } // namespace v8::internal |
| 2205 | 2217 |
| 2206 #endif // V8_TARGET_ARCH_IA32 | 2218 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |