| 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 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 LOperand* right = NULL; | 844 LOperand* right = NULL; |
| 845 int constant_value = 0; | 845 int constant_value = 0; |
| 846 if (right_value->IsConstant()) { | 846 if (right_value->IsConstant()) { |
| 847 HConstant* constant = HConstant::cast(right_value); | 847 HConstant* constant = HConstant::cast(right_value); |
| 848 right = chunk_->DefineConstantOperand(constant); | 848 right = chunk_->DefineConstantOperand(constant); |
| 849 constant_value = constant->Integer32Value() & 0x1f; | 849 constant_value = constant->Integer32Value() & 0x1f; |
| 850 } else { | 850 } else { |
| 851 right = UseFixed(right_value, rcx); | 851 right = UseFixed(right_value, rcx); |
| 852 } | 852 } |
| 853 | 853 |
| 854 // Shift operations can only deoptimize if we do a logical shift | 854 // Shift operations can only deoptimize if we do a logical shift by 0 and |
| 855 // by 0 and the result cannot be truncated to int32. | 855 // the result cannot be truncated to int32. |
| 856 bool can_deopt = (op == Token::SHR && constant_value == 0); | 856 bool may_deopt = (op == Token::SHR && constant_value == 0); |
| 857 if (can_deopt) { | 857 bool does_deopt = false; |
| 858 bool can_truncate = true; | 858 if (may_deopt) { |
| 859 for (int i = 0; i < instr->uses()->length(); i++) { | 859 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
| 860 if (!instr->uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) { | 860 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
| 861 can_truncate = false; | 861 does_deopt = true; |
| 862 break; | 862 break; |
| 863 } | 863 } |
| 864 } | 864 } |
| 865 can_deopt = !can_truncate; | |
| 866 } | 865 } |
| 867 | 866 |
| 868 LShiftI* result = new LShiftI(op, left, right, can_deopt); | 867 LInstruction* result = |
| 869 return can_deopt | 868 DefineSameAsFirst(new LShiftI(op, left, right, does_deopt)); |
| 870 ? AssignEnvironment(DefineSameAsFirst(result)) | 869 return does_deopt ? AssignEnvironment(result) : result; |
| 871 : DefineSameAsFirst(result); | |
| 872 } | 870 } |
| 873 | 871 |
| 874 | 872 |
| 875 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 873 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 876 HArithmeticBinaryOperation* instr) { | 874 HArithmeticBinaryOperation* instr) { |
| 877 ASSERT(instr->representation().IsDouble()); | 875 ASSERT(instr->representation().IsDouble()); |
| 878 ASSERT(instr->left()->representation().IsDouble()); | 876 ASSERT(instr->left()->representation().IsDouble()); |
| 879 ASSERT(instr->right()->representation().IsDouble()); | 877 ASSERT(instr->right()->representation().IsDouble()); |
| 880 ASSERT(op != Token::MOD); | 878 ASSERT(op != Token::MOD); |
| 881 LOperand* left = UseRegisterAtStart(instr->left()); | 879 LOperand* left = UseRegisterAtStart(instr->left()); |
| (...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1839 LOperand* key = UseRegisterAtStart(instr->key()); | 1837 LOperand* key = UseRegisterAtStart(instr->key()); |
| 1840 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); | 1838 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); |
| 1841 return AssignEnvironment(DefineSameAsFirst(result)); | 1839 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1842 } | 1840 } |
| 1843 | 1841 |
| 1844 | 1842 |
| 1845 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( | 1843 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( |
| 1846 HLoadKeyedSpecializedArrayElement* instr) { | 1844 HLoadKeyedSpecializedArrayElement* instr) { |
| 1847 ExternalArrayType array_type = instr->array_type(); | 1845 ExternalArrayType array_type = instr->array_type(); |
| 1848 Representation representation(instr->representation()); | 1846 Representation representation(instr->representation()); |
| 1849 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1847 ASSERT( |
| 1850 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1848 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1849 array_type != kExternalDoubleArray)) || |
| 1850 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1851 array_type == kExternalDoubleArray))); |
| 1851 ASSERT(instr->key()->representation().IsInteger32()); | 1852 ASSERT(instr->key()->representation().IsInteger32()); |
| 1852 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1853 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1853 LOperand* key = UseRegister(instr->key()); | 1854 LOperand* key = UseRegister(instr->key()); |
| 1854 LLoadKeyedSpecializedArrayElement* result = | 1855 LLoadKeyedSpecializedArrayElement* result = |
| 1855 new LLoadKeyedSpecializedArrayElement(external_pointer, key); | 1856 new LLoadKeyedSpecializedArrayElement(external_pointer, key); |
| 1856 LInstruction* load_instr = DefineAsRegister(result); | 1857 LInstruction* load_instr = DefineAsRegister(result); |
| 1857 // An unsigned int array load might overflow and cause a deopt, make sure it | 1858 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1858 // has an environment. | 1859 // has an environment. |
| 1859 return (array_type == kExternalUnsignedIntArray) ? | 1860 return (array_type == kExternalUnsignedIntArray) ? |
| 1860 AssignEnvironment(load_instr) : load_instr; | 1861 AssignEnvironment(load_instr) : load_instr; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1886 : UseRegisterOrConstantAtStart(instr->key()); | 1887 : UseRegisterOrConstantAtStart(instr->key()); |
| 1887 | 1888 |
| 1888 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); | 1889 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); |
| 1889 } | 1890 } |
| 1890 | 1891 |
| 1891 | 1892 |
| 1892 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( | 1893 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( |
| 1893 HStoreKeyedSpecializedArrayElement* instr) { | 1894 HStoreKeyedSpecializedArrayElement* instr) { |
| 1894 Representation representation(instr->value()->representation()); | 1895 Representation representation(instr->value()->representation()); |
| 1895 ExternalArrayType array_type = instr->array_type(); | 1896 ExternalArrayType array_type = instr->array_type(); |
| 1896 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1897 ASSERT( |
| 1897 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1898 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1899 array_type != kExternalDoubleArray)) || |
| 1900 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1901 array_type == kExternalDoubleArray))); |
| 1898 ASSERT(instr->external_pointer()->representation().IsExternal()); | 1902 ASSERT(instr->external_pointer()->representation().IsExternal()); |
| 1899 ASSERT(instr->key()->representation().IsInteger32()); | 1903 ASSERT(instr->key()->representation().IsInteger32()); |
| 1900 | 1904 |
| 1901 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1905 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1902 bool val_is_temp_register = array_type == kExternalPixelArray || | 1906 bool val_is_temp_register = array_type == kExternalPixelArray || |
| 1903 array_type == kExternalFloatArray; | 1907 array_type == kExternalFloatArray; |
| 1904 LOperand* val = val_is_temp_register | 1908 LOperand* val = val_is_temp_register |
| 1905 ? UseTempRegister(instr->value()) | 1909 ? UseTempRegister(instr->value()) |
| 1906 : UseRegister(instr->value()); | 1910 : UseRegister(instr->value()); |
| 1907 LOperand* key = UseRegister(instr->key()); | 1911 LOperand* key = UseRegister(instr->key()); |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2125 return NULL; | 2129 return NULL; |
| 2126 } | 2130 } |
| 2127 | 2131 |
| 2128 | 2132 |
| 2129 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2133 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 2130 HEnvironment* outer = current_block_->last_environment()->outer(); | 2134 HEnvironment* outer = current_block_->last_environment()->outer(); |
| 2131 current_block_->UpdateEnvironment(outer); | 2135 current_block_->UpdateEnvironment(outer); |
| 2132 return NULL; | 2136 return NULL; |
| 2133 } | 2137 } |
| 2134 | 2138 |
| 2139 |
| 2140 LInstruction* LChunkBuilder::DoIn(HIn* instr) { |
| 2141 LOperand* key = UseOrConstantAtStart(instr->key()); |
| 2142 LOperand* object = UseOrConstantAtStart(instr->object()); |
| 2143 LIn* result = new LIn(key, object); |
| 2144 return MarkAsCall(DefineFixed(result, rax), instr); |
| 2145 } |
| 2146 |
| 2147 |
| 2135 } } // namespace v8::internal | 2148 } } // namespace v8::internal |
| 2136 | 2149 |
| 2137 #endif // V8_TARGET_ARCH_X64 | 2150 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |