| 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 1915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1926 HLoadExternalArrayPointer* instr) { | 1926 HLoadExternalArrayPointer* instr) { |
| 1927 LOperand* input = UseRegisterAtStart(instr->value()); | 1927 LOperand* input = UseRegisterAtStart(instr->value()); |
| 1928 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); | 1928 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input)); |
| 1929 } | 1929 } |
| 1930 | 1930 |
| 1931 | 1931 |
| 1932 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | 1932 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { |
| 1933 ASSERT(instr->key()->representation().IsInteger32() || | 1933 ASSERT(instr->key()->representation().IsInteger32() || |
| 1934 instr->key()->representation().IsTagged()); | 1934 instr->key()->representation().IsTagged()); |
| 1935 ElementsKind elements_kind = instr->elements_kind(); | 1935 ElementsKind elements_kind = instr->elements_kind(); |
| 1936 bool clobbers_key = ExternalArrayOpRequiresTemp( | 1936 LOperand* elements = UseRegisterAtStart(instr->elements()); |
| 1937 instr->key()->representation(), elements_kind); | 1937 LOperand* key = instr->is_external() && |
| 1938 LOperand* key = clobbers_key | 1938 ExternalArrayOpRequiresTemp<HLoadKeyed>(instr) |
| 1939 ? UseTempRegister(instr->key()) | 1939 ? UseTempRegister(instr->key()) |
| 1940 : UseRegisterOrConstantAtStart(instr->key()); | 1940 : UseRegisterOrConstantAtStart(instr->key()); |
| 1941 LLoadKeyed* result = NULL; | |
| 1942 | 1941 |
| 1943 if (!instr->is_external()) { | 1942 #ifdef DEBUG |
| 1944 LOperand* obj = UseRegisterAtStart(instr->elements()); | 1943 if (instr->is_external()) { |
| 1945 result = new(zone()) LLoadKeyed(obj, key); | |
| 1946 } else { | |
| 1947 ASSERT( | 1944 ASSERT( |
| 1948 (instr->representation().IsInteger32() && | 1945 (instr->representation().IsInteger32() && |
| 1949 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1946 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 1950 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 1947 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 1951 (instr->representation().IsDouble() && | 1948 (instr->representation().IsDouble() && |
| 1952 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 1949 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 1953 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 1950 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 1954 LOperand* external_pointer = UseRegister(instr->elements()); | |
| 1955 result = new(zone()) LLoadKeyed(external_pointer, key); | |
| 1956 } | 1951 } |
| 1952 #endif |
| 1957 | 1953 |
| 1954 LLoadKeyed* result = new(zone()) LLoadKeyed(elements, key); |
| 1958 DefineAsRegister(result); | 1955 DefineAsRegister(result); |
| 1959 bool can_deoptimize = instr->RequiresHoleCheck() || | 1956 bool can_deoptimize = instr->RequiresHoleCheck() || |
| 1960 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); | 1957 (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS); |
| 1961 // An unsigned int array load might overflow and cause a deopt, make sure it | 1958 // An unsigned int array load might overflow and cause a deopt, make sure it |
| 1962 // has an environment. | 1959 // has an environment. |
| 1963 return can_deoptimize ? AssignEnvironment(result) : result; | 1960 return can_deoptimize ? AssignEnvironment(result) : result; |
| 1964 } | 1961 } |
| 1965 | 1962 |
| 1966 | 1963 |
| 1967 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | 1964 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { |
| 1968 LOperand* context = UseFixed(instr->context(), esi); | 1965 LOperand* context = UseFixed(instr->context(), esi); |
| 1969 LOperand* object = UseFixed(instr->object(), edx); | 1966 LOperand* object = UseFixed(instr->object(), edx); |
| 1970 LOperand* key = UseFixed(instr->key(), ecx); | 1967 LOperand* key = UseFixed(instr->key(), ecx); |
| 1971 | 1968 |
| 1972 LLoadKeyedGeneric* result = | 1969 LLoadKeyedGeneric* result = |
| 1973 new(zone()) LLoadKeyedGeneric(context, object, key); | 1970 new(zone()) LLoadKeyedGeneric(context, object, key); |
| 1974 return MarkAsCall(DefineFixed(result, eax), instr); | 1971 return MarkAsCall(DefineFixed(result, eax), instr); |
| 1975 } | 1972 } |
| 1976 | 1973 |
| 1977 | 1974 |
| 1978 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | 1975 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { |
| 1979 LStoreKeyed* result = NULL; | 1976 ElementsKind elements_kind = instr->elements_kind(); |
| 1977 LOperand* elements; |
| 1978 LOperand* val; |
| 1979 LOperand* key; |
| 1980 | 1980 |
| 1981 if (!instr->is_external()) { | 1981 if (!instr->is_external()) { |
| 1982 ASSERT(instr->elements()->representation().IsTagged()); | 1982 ASSERT(instr->elements()->representation().IsTagged()); |
| 1983 ASSERT(instr->key()->representation().IsInteger32() || | 1983 ASSERT(instr->key()->representation().IsInteger32() || |
| 1984 instr->key()->representation().IsTagged()); | 1984 instr->key()->representation().IsTagged()); |
| 1985 | 1985 |
| 1986 if (instr->value()->representation().IsDouble()) { | 1986 if (instr->NeedsWriteBarrier() && |
| 1987 LOperand* object = UseRegisterAtStart(instr->elements()); | 1987 !IsFastDoubleElementsKind(elements_kind)) { |
| 1988 LOperand* val = UseTempRegister(instr->value()); | 1988 val = UseTempRegister(instr->value()); |
| 1989 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | 1989 key = UseTempRegister(instr->key()); |
| 1990 | 1990 elements = UseRegister(instr->elements()); |
| 1991 result = new(zone()) LStoreKeyed(object, key, val); | |
| 1992 } else { | 1991 } else { |
| 1993 ASSERT(instr->value()->representation().IsTagged()); | 1992 val = UseRegisterAtStart(instr->value()); |
| 1994 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 1993 key = UseRegisterOrConstantAtStart(instr->key()); |
| 1995 | 1994 elements = UseRegisterAtStart(instr->elements()); |
| 1996 LOperand* obj = UseRegister(instr->elements()); | |
| 1997 LOperand* val = needs_write_barrier | |
| 1998 ? UseTempRegister(instr->value()) | |
| 1999 : UseRegisterAtStart(instr->value()); | |
| 2000 LOperand* key = needs_write_barrier | |
| 2001 ? UseTempRegister(instr->key()) | |
| 2002 : UseRegisterOrConstantAtStart(instr->key()); | |
| 2003 result = new(zone()) LStoreKeyed(obj, key, val); | |
| 2004 } | 1995 } |
| 2005 } else { | 1996 } else { |
| 2006 ElementsKind elements_kind = instr->elements_kind(); | |
| 2007 ASSERT( | 1997 ASSERT( |
| 2008 (instr->value()->representation().IsInteger32() && | 1998 (instr->value()->representation().IsInteger32() && |
| 2009 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && | 1999 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) && |
| 2010 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || | 2000 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) || |
| 2011 (instr->value()->representation().IsDouble() && | 2001 (instr->value()->representation().IsDouble() && |
| 2012 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || | 2002 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) || |
| 2013 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); | 2003 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS)))); |
| 2014 ASSERT(instr->elements()->representation().IsExternal()); | 2004 ASSERT(instr->elements()->representation().IsExternal()); |
| 2015 | 2005 |
| 2016 LOperand* external_pointer = UseRegister(instr->elements()); | 2006 if (ExternalArrayOpRequiresTemp<HStoreKeyed>(instr)) { |
| 2007 key = UseTempRegister(instr->key()); |
| 2008 elements = UseRegister(instr->elements()); |
| 2009 } else { |
| 2010 key = UseRegisterOrConstantAtStart(instr->key()); |
| 2011 elements = UseRegisterAtStart(instr->elements()); |
| 2012 } |
| 2013 |
| 2017 // Determine if we need a byte register in this case for the value. | 2014 // Determine if we need a byte register in this case for the value. |
| 2018 bool val_is_fixed_register = | 2015 bool val_is_fixed_register = |
| 2019 elements_kind == EXTERNAL_BYTE_ELEMENTS || | 2016 elements_kind == EXTERNAL_BYTE_ELEMENTS || |
| 2020 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || | 2017 elements_kind == EXTERNAL_UNSIGNED_BYTE_ELEMENTS || |
| 2021 elements_kind == EXTERNAL_PIXEL_ELEMENTS; | 2018 elements_kind == EXTERNAL_PIXEL_ELEMENTS; |
| 2022 | 2019 val = val_is_fixed_register |
| 2023 LOperand* val = val_is_fixed_register | |
| 2024 ? UseFixed(instr->value(), eax) | 2020 ? UseFixed(instr->value(), eax) |
| 2025 : UseRegister(instr->value()); | 2021 : UseRegister(instr->value()); |
| 2026 bool clobbers_key = ExternalArrayOpRequiresTemp( | |
| 2027 instr->key()->representation(), elements_kind); | |
| 2028 LOperand* key = clobbers_key | |
| 2029 ? UseTempRegister(instr->key()) | |
| 2030 : UseRegisterOrConstantAtStart(instr->key()); | |
| 2031 result = new(zone()) LStoreKeyed(external_pointer, | |
| 2032 key, | |
| 2033 val); | |
| 2034 } | 2022 } |
| 2035 | 2023 |
| 2024 LStoreKeyed* result = new(zone()) LStoreKeyed(elements, key, val); |
| 2036 ASSERT(result != NULL); | 2025 ASSERT(result != NULL); |
| 2037 return result; | 2026 return result; |
| 2038 } | 2027 } |
| 2039 | 2028 |
| 2040 | 2029 |
| 2041 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | 2030 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { |
| 2042 LOperand* context = UseFixed(instr->context(), esi); | 2031 LOperand* context = UseFixed(instr->context(), esi); |
| 2043 LOperand* object = UseFixed(instr->object(), edx); | 2032 LOperand* object = UseFixed(instr->object(), edx); |
| 2044 LOperand* key = UseFixed(instr->key(), ecx); | 2033 LOperand* key = UseFixed(instr->key(), ecx); |
| 2045 LOperand* value = UseFixed(instr->value(), eax); | 2034 LOperand* value = UseFixed(instr->value(), eax); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2401 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2390 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2402 LOperand* object = UseRegister(instr->object()); | 2391 LOperand* object = UseRegister(instr->object()); |
| 2403 LOperand* index = UseTempRegister(instr->index()); | 2392 LOperand* index = UseTempRegister(instr->index()); |
| 2404 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2393 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
| 2405 } | 2394 } |
| 2406 | 2395 |
| 2407 | 2396 |
| 2408 } } // namespace v8::internal | 2397 } } // namespace v8::internal |
| 2409 | 2398 |
| 2410 #endif // V8_TARGET_ARCH_IA32 | 2399 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |