| 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 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 if (right_value->IsConstant()) { | 851 if (right_value->IsConstant()) { |
| 852 HConstant* constant = HConstant::cast(right_value); | 852 HConstant* constant = HConstant::cast(right_value); |
| 853 right = chunk_->DefineConstantOperand(constant); | 853 right = chunk_->DefineConstantOperand(constant); |
| 854 constant_value = constant->Integer32Value() & 0x1f; | 854 constant_value = constant->Integer32Value() & 0x1f; |
| 855 } else { | 855 } else { |
| 856 right = UseRegister(right_value); | 856 right = UseRegister(right_value); |
| 857 } | 857 } |
| 858 | 858 |
| 859 // Shift operations can only deoptimize if we do a logical shift | 859 // Shift operations can only deoptimize if we do a logical shift |
| 860 // by 0 and the result cannot be truncated to int32. | 860 // by 0 and the result cannot be truncated to int32. |
| 861 bool can_deopt = (op == Token::SHR && constant_value == 0); | 861 bool may_deopt = (op == Token::SHR && constant_value == 0); |
| 862 if (can_deopt) { | 862 bool does_deopt = false; |
| 863 bool can_truncate = true; | 863 if (may_deopt) { |
| 864 for (int i = 0; i < instr->uses()->length(); i++) { | 864 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) { |
| 865 if (!instr->uses()->at(i)->CheckFlag(HValue::kTruncatingToInt32)) { | 865 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) { |
| 866 can_truncate = false; | 866 does_deopt = true; |
| 867 break; | 867 break; |
| 868 } | 868 } |
| 869 } | 869 } |
| 870 can_deopt = !can_truncate; | |
| 871 } | 870 } |
| 872 | 871 |
| 873 LInstruction* result = | 872 LInstruction* result = |
| 874 DefineSameAsFirst(new LShiftI(op, left, right, can_deopt)); | 873 DefineSameAsFirst(new LShiftI(op, left, right, does_deopt)); |
| 875 if (can_deopt) AssignEnvironment(result); | 874 return does_deopt ? AssignEnvironment(result) : result; |
| 876 return result; | |
| 877 } | 875 } |
| 878 | 876 |
| 879 | 877 |
| 880 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | 878 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, |
| 881 HArithmeticBinaryOperation* instr) { | 879 HArithmeticBinaryOperation* instr) { |
| 882 ASSERT(instr->representation().IsDouble()); | 880 ASSERT(instr->representation().IsDouble()); |
| 883 ASSERT(instr->left()->representation().IsDouble()); | 881 ASSERT(instr->left()->representation().IsDouble()); |
| 884 ASSERT(instr->right()->representation().IsDouble()); | 882 ASSERT(instr->right()->representation().IsDouble()); |
| 885 ASSERT(op != Token::MOD); | 883 ASSERT(op != Token::MOD); |
| 886 LOperand* left = UseRegisterAtStart(instr->left()); | 884 LOperand* left = UseRegisterAtStart(instr->left()); |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1849 LOperand* key = UseRegisterAtStart(instr->key()); | 1847 LOperand* key = UseRegisterAtStart(instr->key()); |
| 1850 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); | 1848 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key); |
| 1851 return AssignEnvironment(DefineSameAsFirst(result)); | 1849 return AssignEnvironment(DefineSameAsFirst(result)); |
| 1852 } | 1850 } |
| 1853 | 1851 |
| 1854 | 1852 |
| 1855 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( | 1853 LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement( |
| 1856 HLoadKeyedSpecializedArrayElement* instr) { | 1854 HLoadKeyedSpecializedArrayElement* instr) { |
| 1857 ExternalArrayType array_type = instr->array_type(); | 1855 ExternalArrayType array_type = instr->array_type(); |
| 1858 Representation representation(instr->representation()); | 1856 Representation representation(instr->representation()); |
| 1859 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1857 ASSERT( |
| 1860 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1858 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1859 array_type != kExternalDoubleArray)) || |
| 1860 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1861 array_type == kExternalDoubleArray))); |
| 1861 ASSERT(instr->key()->representation().IsInteger32()); | 1862 ASSERT(instr->key()->representation().IsInteger32()); |
| 1862 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1863 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1863 LOperand* key = UseRegister(instr->key()); | 1864 LOperand* key = UseRegister(instr->key()); |
| 1864 LLoadKeyedSpecializedArrayElement* result = | 1865 LLoadKeyedSpecializedArrayElement* result = |
| 1865 new LLoadKeyedSpecializedArrayElement(external_pointer, key); | 1866 new LLoadKeyedSpecializedArrayElement(external_pointer, key); |
| 1866 LInstruction* load_instr = DefineAsRegister(result); | 1867 LInstruction* load_instr = DefineAsRegister(result); |
| 1867 // An unsigned int array load might overflow and cause a deopt, make sure it | 1868 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1868 // has an environment. | 1869 // has an environment. |
| 1869 return (array_type == kExternalUnsignedIntArray) ? | 1870 return (array_type == kExternalUnsignedIntArray) ? |
| 1870 AssignEnvironment(load_instr) : load_instr; | 1871 AssignEnvironment(load_instr) : load_instr; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1897 : UseRegisterOrConstantAtStart(instr->key()); | 1898 : UseRegisterOrConstantAtStart(instr->key()); |
| 1898 | 1899 |
| 1899 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); | 1900 return AssignEnvironment(new LStoreKeyedFastElement(obj, key, val)); |
| 1900 } | 1901 } |
| 1901 | 1902 |
| 1902 | 1903 |
| 1903 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( | 1904 LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement( |
| 1904 HStoreKeyedSpecializedArrayElement* instr) { | 1905 HStoreKeyedSpecializedArrayElement* instr) { |
| 1905 Representation representation(instr->value()->representation()); | 1906 Representation representation(instr->value()->representation()); |
| 1906 ExternalArrayType array_type = instr->array_type(); | 1907 ExternalArrayType array_type = instr->array_type(); |
| 1907 ASSERT((representation.IsInteger32() && array_type != kExternalFloatArray) || | 1908 ASSERT( |
| 1908 (representation.IsDouble() && array_type == kExternalFloatArray)); | 1909 (representation.IsInteger32() && (array_type != kExternalFloatArray && |
| 1910 array_type != kExternalDoubleArray)) || |
| 1911 (representation.IsDouble() && (array_type == kExternalFloatArray || |
| 1912 array_type == kExternalDoubleArray))); |
| 1909 ASSERT(instr->external_pointer()->representation().IsExternal()); | 1913 ASSERT(instr->external_pointer()->representation().IsExternal()); |
| 1910 ASSERT(instr->key()->representation().IsInteger32()); | 1914 ASSERT(instr->key()->representation().IsInteger32()); |
| 1911 | 1915 |
| 1912 LOperand* external_pointer = UseRegister(instr->external_pointer()); | 1916 LOperand* external_pointer = UseRegister(instr->external_pointer()); |
| 1913 bool val_is_temp_register = array_type == kExternalPixelArray || | 1917 bool val_is_temp_register = array_type == kExternalPixelArray || |
| 1914 array_type == kExternalFloatArray; | 1918 array_type == kExternalFloatArray; |
| 1915 LOperand* val = val_is_temp_register | 1919 LOperand* val = val_is_temp_register |
| 1916 ? UseTempRegister(instr->value()) | 1920 ? UseTempRegister(instr->value()) |
| 1917 : UseRegister(instr->value()); | 1921 : UseRegister(instr->value()); |
| 1918 LOperand* key = UseRegister(instr->key()); | 1922 LOperand* key = UseRegister(instr->key()); |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2131 } | 2135 } |
| 2132 | 2136 |
| 2133 | 2137 |
| 2134 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | 2138 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { |
| 2135 HEnvironment* outer = current_block_->last_environment()->outer(); | 2139 HEnvironment* outer = current_block_->last_environment()->outer(); |
| 2136 current_block_->UpdateEnvironment(outer); | 2140 current_block_->UpdateEnvironment(outer); |
| 2137 return NULL; | 2141 return NULL; |
| 2138 } | 2142 } |
| 2139 | 2143 |
| 2140 | 2144 |
| 2145 LInstruction* LChunkBuilder::DoIn(HIn* instr) { |
| 2146 LOperand* key = UseRegisterAtStart(instr->key()); |
| 2147 LOperand* object = UseRegisterAtStart(instr->object()); |
| 2148 LIn* result = new LIn(key, object); |
| 2149 return MarkAsCall(DefineFixed(result, r0), instr); |
| 2150 } |
| 2151 |
| 2152 |
| 2141 } } // namespace v8::internal | 2153 } } // namespace v8::internal |
| OLD | NEW |