OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/ic/ic.h" | 5 #include "src/ic/ic.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 1954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1965 } | 1965 } |
1966 | 1966 |
1967 return PropertyICCompiler::ComputeKeyedStorePolymorphic( | 1967 return PropertyICCompiler::ComputeKeyedStorePolymorphic( |
1968 &target_receiver_maps, store_mode, language_mode()); | 1968 &target_receiver_maps, store_mode, language_mode()); |
1969 } | 1969 } |
1970 | 1970 |
1971 | 1971 |
1972 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( | 1972 Handle<Map> KeyedStoreIC::ComputeTransitionedMap( |
1973 Handle<Map> map, KeyedAccessStoreMode store_mode) { | 1973 Handle<Map> map, KeyedAccessStoreMode store_mode) { |
1974 switch (store_mode) { | 1974 switch (store_mode) { |
1975 case STORE_TRANSITION_SMI_TO_OBJECT: | 1975 case STORE_TRANSITION_TO_OBJECT: |
1976 case STORE_TRANSITION_DOUBLE_TO_OBJECT: | 1976 case STORE_AND_GROW_TRANSITION_TO_OBJECT: { |
1977 case STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT: | 1977 ElementsKind kind = IsFastHoleyElementsKind(map->elements_kind()) |
1978 case STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT: | 1978 ? FAST_HOLEY_ELEMENTS |
1979 return Map::TransitionElementsTo(map, FAST_ELEMENTS); | 1979 : FAST_ELEMENTS; |
1980 case STORE_TRANSITION_SMI_TO_DOUBLE: | 1980 return Map::TransitionElementsTo(map, kind); |
1981 case STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE: | 1981 } |
1982 return Map::TransitionElementsTo(map, FAST_DOUBLE_ELEMENTS); | 1982 case STORE_TRANSITION_TO_DOUBLE: |
1983 case STORE_TRANSITION_HOLEY_SMI_TO_OBJECT: | 1983 case STORE_AND_GROW_TRANSITION_TO_DOUBLE: { |
1984 case STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT: | 1984 ElementsKind kind = IsFastHoleyElementsKind(map->elements_kind()) |
1985 case STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT: | 1985 ? FAST_HOLEY_DOUBLE_ELEMENTS |
1986 case STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT: | 1986 : FAST_DOUBLE_ELEMENTS; |
1987 return Map::TransitionElementsTo(map, FAST_HOLEY_ELEMENTS); | 1987 return Map::TransitionElementsTo(map, kind); |
1988 case STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE: | 1988 } |
1989 case STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE: | |
1990 return Map::TransitionElementsTo(map, FAST_HOLEY_DOUBLE_ELEMENTS); | |
1991 case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: | 1989 case STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS: |
1992 DCHECK(map->has_fixed_typed_array_elements()); | 1990 DCHECK(map->has_fixed_typed_array_elements()); |
1993 // Fall through | 1991 // Fall through |
1994 case STORE_NO_TRANSITION_HANDLE_COW: | 1992 case STORE_NO_TRANSITION_HANDLE_COW: |
1995 case STANDARD_STORE: | 1993 case STANDARD_STORE: |
1996 case STORE_AND_GROW_NO_TRANSITION: | 1994 case STORE_AND_GROW_NO_TRANSITION: |
1997 return map; | 1995 return map; |
1998 } | 1996 } |
1999 UNREACHABLE(); | 1997 UNREACHABLE(); |
2000 return MaybeHandle<Map>().ToHandleChecked(); | 1998 return MaybeHandle<Map>().ToHandleChecked(); |
(...skipping 15 matching lines...) Expand all Loading... |
2016 uint32_t index, Handle<Object> value) { | 2014 uint32_t index, Handle<Object> value) { |
2017 bool oob_access = IsOutOfBoundsAccess(receiver, index); | 2015 bool oob_access = IsOutOfBoundsAccess(receiver, index); |
2018 // Don't consider this a growing store if the store would send the receiver to | 2016 // Don't consider this a growing store if the store would send the receiver to |
2019 // dictionary mode. | 2017 // dictionary mode. |
2020 bool allow_growth = receiver->IsJSArray() && oob_access && | 2018 bool allow_growth = receiver->IsJSArray() && oob_access && |
2021 !receiver->WouldConvertToSlowElements(index); | 2019 !receiver->WouldConvertToSlowElements(index); |
2022 if (allow_growth) { | 2020 if (allow_growth) { |
2023 // Handle growing array in stub if necessary. | 2021 // Handle growing array in stub if necessary. |
2024 if (receiver->HasFastSmiElements()) { | 2022 if (receiver->HasFastSmiElements()) { |
2025 if (value->IsHeapNumber()) { | 2023 if (value->IsHeapNumber()) { |
2026 if (receiver->HasFastHoleyElements()) { | 2024 return STORE_AND_GROW_TRANSITION_TO_DOUBLE; |
2027 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_DOUBLE; | |
2028 } else { | |
2029 return STORE_AND_GROW_TRANSITION_SMI_TO_DOUBLE; | |
2030 } | |
2031 } | 2025 } |
2032 if (value->IsHeapObject()) { | 2026 if (value->IsHeapObject()) { |
2033 if (receiver->HasFastHoleyElements()) { | 2027 return STORE_AND_GROW_TRANSITION_TO_OBJECT; |
2034 return STORE_AND_GROW_TRANSITION_HOLEY_SMI_TO_OBJECT; | |
2035 } else { | |
2036 return STORE_AND_GROW_TRANSITION_SMI_TO_OBJECT; | |
2037 } | |
2038 } | 2028 } |
2039 } else if (receiver->HasFastDoubleElements()) { | 2029 } else if (receiver->HasFastDoubleElements()) { |
2040 if (!value->IsSmi() && !value->IsHeapNumber()) { | 2030 if (!value->IsSmi() && !value->IsHeapNumber()) { |
2041 if (receiver->HasFastHoleyElements()) { | 2031 return STORE_AND_GROW_TRANSITION_TO_OBJECT; |
2042 return STORE_AND_GROW_TRANSITION_HOLEY_DOUBLE_TO_OBJECT; | |
2043 } else { | |
2044 return STORE_AND_GROW_TRANSITION_DOUBLE_TO_OBJECT; | |
2045 } | |
2046 } | 2032 } |
2047 } | 2033 } |
2048 return STORE_AND_GROW_NO_TRANSITION; | 2034 return STORE_AND_GROW_NO_TRANSITION; |
2049 } else { | 2035 } else { |
2050 // Handle only in-bounds elements accesses. | 2036 // Handle only in-bounds elements accesses. |
2051 if (receiver->HasFastSmiElements()) { | 2037 if (receiver->HasFastSmiElements()) { |
2052 if (value->IsHeapNumber()) { | 2038 if (value->IsHeapNumber()) { |
2053 if (receiver->HasFastHoleyElements()) { | 2039 return STORE_TRANSITION_TO_DOUBLE; |
2054 return STORE_TRANSITION_HOLEY_SMI_TO_DOUBLE; | |
2055 } else { | |
2056 return STORE_TRANSITION_SMI_TO_DOUBLE; | |
2057 } | |
2058 } else if (value->IsHeapObject()) { | 2040 } else if (value->IsHeapObject()) { |
2059 if (receiver->HasFastHoleyElements()) { | 2041 return STORE_TRANSITION_TO_OBJECT; |
2060 return STORE_TRANSITION_HOLEY_SMI_TO_OBJECT; | |
2061 } else { | |
2062 return STORE_TRANSITION_SMI_TO_OBJECT; | |
2063 } | |
2064 } | 2042 } |
2065 } else if (receiver->HasFastDoubleElements()) { | 2043 } else if (receiver->HasFastDoubleElements()) { |
2066 if (!value->IsSmi() && !value->IsHeapNumber()) { | 2044 if (!value->IsSmi() && !value->IsHeapNumber()) { |
2067 if (receiver->HasFastHoleyElements()) { | 2045 return STORE_TRANSITION_TO_OBJECT; |
2068 return STORE_TRANSITION_HOLEY_DOUBLE_TO_OBJECT; | |
2069 } else { | |
2070 return STORE_TRANSITION_DOUBLE_TO_OBJECT; | |
2071 } | |
2072 } | 2046 } |
2073 } | 2047 } |
2074 if (!FLAG_trace_external_array_abuse && | 2048 if (!FLAG_trace_external_array_abuse && |
2075 receiver->map()->has_fixed_typed_array_elements() && oob_access) { | 2049 receiver->map()->has_fixed_typed_array_elements() && oob_access) { |
2076 return STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS; | 2050 return STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS; |
2077 } | 2051 } |
2078 Heap* heap = receiver->GetHeap(); | 2052 Heap* heap = receiver->GetHeap(); |
2079 if (receiver->elements()->map() == heap->fixed_cow_array_map()) { | 2053 if (receiver->elements()->map() == heap->fixed_cow_array_map()) { |
2080 return STORE_NO_TRANSITION_HANDLE_COW; | 2054 return STORE_NO_TRANSITION_HANDLE_COW; |
2081 } else { | 2055 } else { |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3083 KeyedLoadICNexus nexus(vector, vector_slot); | 3057 KeyedLoadICNexus nexus(vector, vector_slot); |
3084 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); | 3058 KeyedLoadIC ic(IC::EXTRA_CALL_FRAME, isolate, &nexus); |
3085 ic.UpdateState(receiver, key); | 3059 ic.UpdateState(receiver, key); |
3086 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); | 3060 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, result, ic.Load(receiver, key)); |
3087 } | 3061 } |
3088 | 3062 |
3089 return *result; | 3063 return *result; |
3090 } | 3064 } |
3091 } // namespace internal | 3065 } // namespace internal |
3092 } // namespace v8 | 3066 } // namespace v8 |
OLD | NEW |