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 1923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1934 cache->Update(descriptors, name, number); | 1934 cache->Update(descriptors, name, number); |
1935 } | 1935 } |
1936 if (number != DescriptorArray::kNotFound) { | 1936 if (number != DescriptorArray::kNotFound) { |
1937 result->DescriptorResult(holder, descriptors->GetDetails(number), number); | 1937 result->DescriptorResult(holder, descriptors->GetDetails(number), number); |
1938 } else { | 1938 } else { |
1939 result->NotFound(); | 1939 result->NotFound(); |
1940 } | 1940 } |
1941 } | 1941 } |
1942 | 1942 |
1943 | 1943 |
| 1944 static JSObject::ElementsKind GetElementsKindFromExternalArrayType( |
| 1945 ExternalArrayType array_type) { |
| 1946 switch (array_type) { |
| 1947 case kExternalByteArray: |
| 1948 return JSObject::EXTERNAL_BYTE_ELEMENTS; |
| 1949 break; |
| 1950 case kExternalUnsignedByteArray: |
| 1951 return JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS; |
| 1952 break; |
| 1953 case kExternalShortArray: |
| 1954 return JSObject::EXTERNAL_SHORT_ELEMENTS; |
| 1955 break; |
| 1956 case kExternalUnsignedShortArray: |
| 1957 return JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS; |
| 1958 break; |
| 1959 case kExternalIntArray: |
| 1960 return JSObject::EXTERNAL_INT_ELEMENTS; |
| 1961 break; |
| 1962 case kExternalUnsignedIntArray: |
| 1963 return JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS; |
| 1964 break; |
| 1965 case kExternalFloatArray: |
| 1966 return JSObject::EXTERNAL_FLOAT_ELEMENTS; |
| 1967 break; |
| 1968 case kExternalDoubleArray: |
| 1969 return JSObject::EXTERNAL_DOUBLE_ELEMENTS; |
| 1970 break; |
| 1971 case kExternalPixelArray: |
| 1972 return JSObject::EXTERNAL_PIXEL_ELEMENTS; |
| 1973 break; |
| 1974 } |
| 1975 UNREACHABLE(); |
| 1976 return JSObject::DICTIONARY_ELEMENTS; |
| 1977 } |
| 1978 |
| 1979 |
1944 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, | 1980 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, |
1945 bool safe_to_add_transition) { | 1981 bool safe_to_add_transition) { |
1946 Heap* current_heap = heap(); | 1982 Heap* current_heap = heap(); |
1947 DescriptorArray* descriptors = instance_descriptors(); | 1983 DescriptorArray* descriptors = instance_descriptors(); |
1948 String* external_array_sentinel_name = current_heap->empty_symbol(); | 1984 String* external_array_sentinel_name = current_heap->empty_symbol(); |
1949 | 1985 |
1950 if (safe_to_add_transition) { | 1986 if (safe_to_add_transition) { |
1951 // It's only safe to manipulate the descriptor array if it would be | 1987 // It's only safe to manipulate the descriptor array if it would be |
1952 // safe to add a transition. | 1988 // safe to add a transition. |
1953 | 1989 |
(...skipping 22 matching lines...) Expand all Loading... |
1976 } | 2012 } |
1977 } | 2013 } |
1978 | 2014 |
1979 // No transition to an existing external array map. Make a new one. | 2015 // No transition to an existing external array map. Make a new one. |
1980 Object* obj; | 2016 Object* obj; |
1981 { MaybeObject* maybe_map = CopyDropTransitions(); | 2017 { MaybeObject* maybe_map = CopyDropTransitions(); |
1982 if (!maybe_map->ToObject(&obj)) return maybe_map; | 2018 if (!maybe_map->ToObject(&obj)) return maybe_map; |
1983 } | 2019 } |
1984 Map* new_map = Map::cast(obj); | 2020 Map* new_map = Map::cast(obj); |
1985 | 2021 |
1986 new_map->set_has_fast_elements(false); | 2022 new_map->set_elements_kind(GetElementsKindFromExternalArrayType(array_type)); |
1987 new_map->set_has_external_array_elements(true); | |
1988 GetIsolate()->counters()->map_to_external_array_elements()->Increment(); | 2023 GetIsolate()->counters()->map_to_external_array_elements()->Increment(); |
1989 | 2024 |
1990 // Only remember the map transition if the object's map is NOT equal to the | 2025 // Only remember the map transition if the object's map is NOT equal to the |
1991 // global object_function's map and there is not an already existing | 2026 // global object_function's map and there is not an already existing |
1992 // non-matching external array transition. | 2027 // non-matching external array transition. |
1993 bool allow_map_transition = | 2028 bool allow_map_transition = |
1994 safe_to_add_transition && | 2029 safe_to_add_transition && |
1995 (GetIsolate()->context()->global_context()->object_function()->map() != | 2030 (GetIsolate()->context()->global_context()->object_function()->map() != |
1996 map()); | 2031 map()); |
1997 if (allow_map_transition) { | 2032 if (allow_map_transition) { |
(...skipping 8711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10709 if (break_point_objects()->IsUndefined()) return 0; | 10744 if (break_point_objects()->IsUndefined()) return 0; |
10710 // Single beak point. | 10745 // Single beak point. |
10711 if (!break_point_objects()->IsFixedArray()) return 1; | 10746 if (!break_point_objects()->IsFixedArray()) return 1; |
10712 // Multiple break points. | 10747 // Multiple break points. |
10713 return FixedArray::cast(break_point_objects())->length(); | 10748 return FixedArray::cast(break_point_objects())->length(); |
10714 } | 10749 } |
10715 #endif | 10750 #endif |
10716 | 10751 |
10717 | 10752 |
10718 } } // namespace v8::internal | 10753 } } // namespace v8::internal |
OLD | NEW |