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

Side by Side Diff: src/heap.cc

Issue 10833033: Set LastAdded to kNoneAdded in RawCopy. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 5 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 | « no previous file | src/objects.cc » ('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 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 4107 matching lines...) Expand 10 before | Expand all | Expand 10 after
4118 // global objects. They will be unused once we normalize the object. 4118 // global objects. They will be unused once we normalize the object.
4119 ASSERT(map->unused_property_fields() == 0); 4119 ASSERT(map->unused_property_fields() == 0);
4120 ASSERT(map->inobject_properties() == 0); 4120 ASSERT(map->inobject_properties() == 0);
4121 4121
4122 // Initial size of the backing store to avoid resize of the storage during 4122 // Initial size of the backing store to avoid resize of the storage during
4123 // bootstrapping. The size differs between the JS global object ad the 4123 // bootstrapping. The size differs between the JS global object ad the
4124 // builtins object. 4124 // builtins object.
4125 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512; 4125 int initial_size = map->instance_type() == JS_GLOBAL_OBJECT_TYPE ? 64 : 512;
4126 4126
4127 // Allocate a dictionary object for backing storage. 4127 // Allocate a dictionary object for backing storage.
4128 Object* obj; 4128 StringDictionary* dictionary;
4129 { MaybeObject* maybe_obj = 4129 MaybeObject* maybe_dictionary =
4130 StringDictionary::Allocate( 4130 StringDictionary::Allocate(
4131 map->NumberOfDescribedProperties() * 2 + initial_size); 4131 map->NumberOfDescribedProperties() * 2 + initial_size);
4132 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 4132 if (!maybe_dictionary->To(&dictionary)) return maybe_dictionary;
4133 }
4134 StringDictionary* dictionary = StringDictionary::cast(obj);
4135 4133
4136 // The global object might be created from an object template with accessors. 4134 // The global object might be created from an object template with accessors.
4137 // Fill these accessors into the dictionary. 4135 // Fill these accessors into the dictionary.
4138 DescriptorArray* descs = map->instance_descriptors(); 4136 DescriptorArray* descs = map->instance_descriptors();
4139 for (int i = 0; i < descs->number_of_descriptors(); i++) { 4137 for (int i = 0; i < descs->number_of_descriptors(); i++) {
4140 PropertyDetails details = descs->GetDetails(i); 4138 PropertyDetails details = descs->GetDetails(i);
4141 ASSERT(details.type() == CALLBACKS); // Only accessors are expected. 4139 ASSERT(details.type() == CALLBACKS); // Only accessors are expected.
4142 PropertyDetails d = 4140 PropertyDetails d =
4143 PropertyDetails(details.attributes(), CALLBACKS, details.index()); 4141 PropertyDetails(details.attributes(), CALLBACKS, details.index());
4144 Object* value = descs->GetCallbacksObject(i); 4142 Object* value = descs->GetCallbacksObject(i);
4145 { MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value); 4143 MaybeObject* maybe_value = AllocateJSGlobalPropertyCell(value);
4146 if (!maybe_value->ToObject(&value)) return maybe_value; 4144 if (!maybe_value->ToObject(&value)) return maybe_value;
4147 }
4148 4145
4149 Object* result; 4146 MaybeObject* maybe_added = dictionary->Add(descs->GetKey(i), value, d);
4150 { MaybeObject* maybe_result = dictionary->Add(descs->GetKey(i), value, d); 4147 if (!maybe_added->To(&dictionary)) return maybe_added;
4151 if (!maybe_result->ToObject(&result)) return maybe_result;
4152 }
4153 dictionary = StringDictionary::cast(result);
4154 } 4148 }
4155 4149
4156 // Allocate the global object and initialize it with the backing store. 4150 // Allocate the global object and initialize it with the backing store.
4157 { MaybeObject* maybe_obj = Allocate(map, OLD_POINTER_SPACE); 4151 JSObject* global;
4158 if (!maybe_obj->ToObject(&obj)) return maybe_obj; 4152 MaybeObject* maybe_global = Allocate(map, OLD_POINTER_SPACE);
4159 } 4153 if (!maybe_global->To(&global)) return maybe_global;
4160 JSObject* global = JSObject::cast(obj); 4154
4161 InitializeJSObjectFromMap(global, dictionary, map); 4155 InitializeJSObjectFromMap(global, dictionary, map);
4162 4156
4163 // Create a new map for the global object. 4157 // Create a new map for the global object.
4164 Map* new_map; 4158 Map* new_map;
4165 { MaybeObject* maybe_map = map->CopyDropDescriptors(); 4159 MaybeObject* maybe_map = map->CopyDropDescriptors();
4166 if (!maybe_map->To(&new_map)) return maybe_map; 4160 if (!maybe_map->To(&new_map)) return maybe_map;
4167 } 4161
4162 ASSERT(new_map->LastAdded() == Map::kNoneAdded);
4168 4163
4169 // Set up the global object as a normalized object. 4164 // Set up the global object as a normalized object.
4170 global->set_map(new_map); 4165 global->set_map(new_map);
4171 global->set_properties(dictionary); 4166 global->set_properties(dictionary);
4172 4167
4173 // Make sure result is a global object with properties in dictionary. 4168 // Make sure result is a global object with properties in dictionary.
4174 ASSERT(global->IsGlobalObject()); 4169 ASSERT(global->IsGlobalObject());
4175 ASSERT(!global->HasFastProperties()); 4170 ASSERT(!global->HasFastProperties());
4176 return global; 4171 return global;
4177 } 4172 }
(...skipping 3058 matching lines...) Expand 10 before | Expand all | Expand 10 after
7236 static_cast<int>(object_sizes_last_time_[index])); 7231 static_cast<int>(object_sizes_last_time_[index]));
7237 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7232 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7238 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7233 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7239 7234
7240 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7235 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7241 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7236 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7242 ClearObjectStats(); 7237 ClearObjectStats();
7243 } 7238 }
7244 7239
7245 } } // namespace v8::internal 7240 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698