Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: src/objects.cc

Issue 6966041: Add complete ElementKind information directly to Map for objects with elements. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: implement all platforms Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 1922 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 cache->Update(descriptors, name, number); 1933 cache->Update(descriptors, name, number);
1934 } 1934 }
1935 if (number != DescriptorArray::kNotFound) { 1935 if (number != DescriptorArray::kNotFound) {
1936 result->DescriptorResult(holder, descriptors->GetDetails(number), number); 1936 result->DescriptorResult(holder, descriptors->GetDetails(number), number);
1937 } else { 1937 } else {
1938 result->NotFound(); 1938 result->NotFound();
1939 } 1939 }
1940 } 1940 }
1941 1941
1942 1942
1943 static JSObject::ElementsKind GetElementsKindFromExternalArrayType(
1944 ExternalArrayType array_type) {
1945 switch (array_type) {
1946 case kExternalByteArray:
1947 return JSObject::EXTERNAL_BYTE_ELEMENTS;
1948 break;
1949 case kExternalUnsignedByteArray:
1950 return JSObject::EXTERNAL_UNSIGNED_BYTE_ELEMENTS;
1951 break;
1952 case kExternalShortArray:
1953 return JSObject::EXTERNAL_SHORT_ELEMENTS;
1954 break;
1955 case kExternalUnsignedShortArray:
1956 return JSObject::EXTERNAL_UNSIGNED_SHORT_ELEMENTS;
1957 break;
1958 case kExternalIntArray:
1959 return JSObject::EXTERNAL_INT_ELEMENTS;
1960 break;
1961 case kExternalUnsignedIntArray:
1962 return JSObject::EXTERNAL_UNSIGNED_INT_ELEMENTS;
1963 break;
1964 case kExternalFloatArray:
1965 return JSObject::EXTERNAL_FLOAT_ELEMENTS;
1966 break;
1967 case kExternalDoubleArray:
1968 return JSObject::EXTERNAL_DOUBLE_ELEMENTS;
1969 break;
1970 case kExternalPixelArray:
1971 return JSObject::EXTERNAL_PIXEL_ELEMENTS;
1972 break;
1973 }
1974 UNREACHABLE();
1975 return JSObject::DICTIONARY_ELEMENTS;
1976 }
1977
1978
1943 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type, 1979 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type,
1944 bool safe_to_add_transition) { 1980 bool safe_to_add_transition) {
1945 Heap* current_heap = heap(); 1981 Heap* current_heap = heap();
1946 DescriptorArray* descriptors = instance_descriptors(); 1982 DescriptorArray* descriptors = instance_descriptors();
1947 String* external_array_sentinel_name = current_heap->empty_symbol(); 1983 String* external_array_sentinel_name = current_heap->empty_symbol();
1948 1984
1949 if (safe_to_add_transition) { 1985 if (safe_to_add_transition) {
1950 // It's only safe to manipulate the descriptor array if it would be 1986 // It's only safe to manipulate the descriptor array if it would be
1951 // safe to add a transition. 1987 // safe to add a transition.
1952 1988
(...skipping 22 matching lines...) Expand all
1975 } 2011 }
1976 } 2012 }
1977 2013
1978 // No transition to an existing external array map. Make a new one. 2014 // No transition to an existing external array map. Make a new one.
1979 Object* obj; 2015 Object* obj;
1980 { MaybeObject* maybe_map = CopyDropTransitions(); 2016 { MaybeObject* maybe_map = CopyDropTransitions();
1981 if (!maybe_map->ToObject(&obj)) return maybe_map; 2017 if (!maybe_map->ToObject(&obj)) return maybe_map;
1982 } 2018 }
1983 Map* new_map = Map::cast(obj); 2019 Map* new_map = Map::cast(obj);
1984 2020
1985 new_map->set_has_fast_elements(false); 2021 new_map->set_elements_kind(GetElementsKindFromExternalArrayType(array_type));
1986 new_map->set_has_external_array_elements(true);
1987 GetIsolate()->counters()->map_to_external_array_elements()->Increment(); 2022 GetIsolate()->counters()->map_to_external_array_elements()->Increment();
1988 2023
1989 // Only remember the map transition if the object's map is NOT equal to the 2024 // Only remember the map transition if the object's map is NOT equal to the
1990 // global object_function's map and there is not an already existing 2025 // global object_function's map and there is not an already existing
1991 // non-matching external array transition. 2026 // non-matching external array transition.
1992 bool allow_map_transition = 2027 bool allow_map_transition =
1993 safe_to_add_transition && 2028 safe_to_add_transition &&
1994 (GetIsolate()->context()->global_context()->object_function()->map() != 2029 (GetIsolate()->context()->global_context()->object_function()->map() !=
1995 map()); 2030 map());
1996 if (allow_map_transition) { 2031 if (allow_map_transition) {
(...skipping 8615 matching lines...) Expand 10 before | Expand all | Expand 10 after
10612 if (break_point_objects()->IsUndefined()) return 0; 10647 if (break_point_objects()->IsUndefined()) return 0;
10613 // Single beak point. 10648 // Single beak point.
10614 if (!break_point_objects()->IsFixedArray()) return 1; 10649 if (!break_point_objects()->IsFixedArray()) return 1;
10615 // Multiple break points. 10650 // Multiple break points.
10616 return FixedArray::cast(break_point_objects())->length(); 10651 return FixedArray::cast(break_point_objects())->length();
10617 } 10652 }
10618 #endif 10653 #endif
10619 10654
10620 10655
10621 } } // namespace v8::internal 10656 } } // namespace v8::internal
OLDNEW
« src/objects.h ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698