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