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

Side by Side Diff: src/objects.cc

Issue 6685073: Remember and reuse derived map for external arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix formatting Created 9 years, 9 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
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 1762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1773 DescriptorLookupCache::Update(descriptors, name, number); 1773 DescriptorLookupCache::Update(descriptors, name, number);
1774 } 1774 }
1775 if (number != DescriptorArray::kNotFound) { 1775 if (number != DescriptorArray::kNotFound) {
1776 result->DescriptorResult(holder, descriptors->GetDetails(number), number); 1776 result->DescriptorResult(holder, descriptors->GetDetails(number), number);
1777 } else { 1777 } else {
1778 result->NotFound(); 1778 result->NotFound();
1779 } 1779 }
1780 } 1780 }
1781 1781
1782 1782
1783 MaybeObject* Map::GetExternalArrayElementsMap(ExternalArrayType array_type) {
1784 DescriptorArray* descriptors = instance_descriptors();
1785 String* external_array_sentinel_name = Heap::empty_string();
Mads Ager (chromium) 2011/03/21 08:32:40 The empty string is a valid property name (every s
1786
1787 // Check if the external array transition already exists.
1788 int index = DescriptorLookupCache::Lookup(descriptors,
1789 external_array_sentinel_name);
1790 if (index == DescriptorLookupCache::kAbsent) {
1791 index = descriptors->Search(external_array_sentinel_name);
1792 DescriptorLookupCache::Update(descriptors,
1793 external_array_sentinel_name,
1794 index);
1795 }
1796
1797 // If the transition already exists, check the type. If thee is a match,
Mads Ager (chromium) 2011/03/21 08:32:40 thee -> there
1798 // return it.
1799 if (index != DescriptorArray::kNotFound) {
1800 PropertyDetails details(PropertyDetails(descriptors->GetDetails(index)));
1801 if (details.type() == EXTERNAL_ARRAY_TRANSITION &&
1802 details.array_type() == array_type) {
1803 return descriptors->GetValue(index);
1804 }
1805 }
1806
1807 // No transition to an existing external array map. Make a new one.
1808 Object* obj;
1809 { MaybeObject* maybe_map = CopyDropTransitions();
1810 if (!maybe_map->ToObject(&obj)) return maybe_map;
1811 }
1812 Map* new_map = Map::cast(obj);
1813
1814 new_map->set_has_fast_elements(false);
1815 new_map->set_has_external_array_elements(true);
1816 Counters::map_to_external_array_elements.Increment();
1817
1818 // Only remember the map transition if the object's map is NOT equal to the
1819 // global object_function's map and there is not an already existing
1820 // non-matching external array transition.
1821 bool allow_map_transition =
1822 index == DescriptorArray::kNotFound &&
1823 (Top::context()->global_context()->object_function()->map() != map());
1824 if (allow_map_transition) {
1825 // Allocate new instance descriptors for the old map with map transition.
1826 ExternalArrayTransitionDescriptor desc(external_array_sentinel_name,
1827 Map::cast(new_map),
1828 array_type);
1829 Object* new_descriptors;
1830 MaybeObject* maybe_new_descriptors = descriptors->CopyInsert(
1831 &desc,
1832 KEEP_TRANSITIONS);
1833 if (!maybe_new_descriptors->ToObject(&new_descriptors)) {
1834 return maybe_new_descriptors;
1835 }
1836 descriptors = DescriptorArray::cast(new_descriptors);
1837 set_instance_descriptors(descriptors);
1838 }
1839
1840 return new_map;
1841 }
1842
1843
1783 void JSObject::LocalLookupRealNamedProperty(String* name, 1844 void JSObject::LocalLookupRealNamedProperty(String* name,
1784 LookupResult* result) { 1845 LookupResult* result) {
1785 if (IsJSGlobalProxy()) { 1846 if (IsJSGlobalProxy()) {
1786 Object* proto = GetPrototype(); 1847 Object* proto = GetPrototype();
1787 if (proto->IsNull()) return result->NotFound(); 1848 if (proto->IsNull()) return result->NotFound();
1788 ASSERT(proto->IsJSGlobalObject()); 1849 ASSERT(proto->IsJSGlobalObject());
1789 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result); 1850 return JSObject::cast(proto)->LocalLookupRealNamedProperty(name, result);
1790 } 1851 }
1791 1852
1792 if (HasFastProperties()) { 1853 if (HasFastProperties()) {
(...skipping 4478 matching lines...) Expand 10 before | Expand all | Expand 10 after
6271 6332
6272 6333
6273 const char* Code::PropertyType2String(PropertyType type) { 6334 const char* Code::PropertyType2String(PropertyType type) {
6274 switch (type) { 6335 switch (type) {
6275 case NORMAL: return "NORMAL"; 6336 case NORMAL: return "NORMAL";
6276 case FIELD: return "FIELD"; 6337 case FIELD: return "FIELD";
6277 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION"; 6338 case CONSTANT_FUNCTION: return "CONSTANT_FUNCTION";
6278 case CALLBACKS: return "CALLBACKS"; 6339 case CALLBACKS: return "CALLBACKS";
6279 case INTERCEPTOR: return "INTERCEPTOR"; 6340 case INTERCEPTOR: return "INTERCEPTOR";
6280 case MAP_TRANSITION: return "MAP_TRANSITION"; 6341 case MAP_TRANSITION: return "MAP_TRANSITION";
6342 case EXTERNAL_ARRAY_TRANSITION: return "EXTERNAL_ARRAY_TRANSITION";
6281 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION"; 6343 case CONSTANT_TRANSITION: return "CONSTANT_TRANSITION";
6282 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR"; 6344 case NULL_DESCRIPTOR: return "NULL_DESCRIPTOR";
6283 } 6345 }
6284 UNREACHABLE(); 6346 UNREACHABLE();
6285 return NULL; 6347 return NULL;
6286 } 6348 }
6287 6349
6288 6350
6289 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) { 6351 void Code::PrintExtraICState(FILE* out, Kind kind, ExtraICState extra) {
6290 const char* name = NULL; 6352 const char* name = NULL;
(...skipping 3751 matching lines...) Expand 10 before | Expand all | Expand 10 after
10042 if (break_point_objects()->IsUndefined()) return 0; 10104 if (break_point_objects()->IsUndefined()) return 0;
10043 // Single beak point. 10105 // Single beak point.
10044 if (!break_point_objects()->IsFixedArray()) return 1; 10106 if (!break_point_objects()->IsFixedArray()) return 1;
10045 // Multiple break points. 10107 // Multiple break points.
10046 return FixedArray::cast(break_point_objects())->length(); 10108 return FixedArray::cast(break_point_objects())->length();
10047 } 10109 }
10048 #endif 10110 #endif
10049 10111
10050 10112
10051 } } // namespace v8::internal 10113 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698