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