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

Side by Side Diff: src/objects.cc

Issue 363073002: One of the fast cases in JSObject::MigrateFastToFast() should not be taken... (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments Created 6 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 | « src/objects.h ('k') | test/mjsunit/regress/regress-crbug-390918.js » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/allocation-site-scopes.h" 8 #include "src/allocation-site-scopes.h"
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/arguments.h" 10 #include "src/arguments.h"
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after
2055 2055
2056 // The array may not be moved during GC, 2056 // The array may not be moved during GC,
2057 // and size has to be adjusted nevertheless. 2057 // and size has to be adjusted nevertheless.
2058 HeapProfiler* profiler = heap->isolate()->heap_profiler(); 2058 HeapProfiler* profiler = heap->isolate()->heap_profiler();
2059 if (profiler->is_tracking_allocations()) { 2059 if (profiler->is_tracking_allocations()) {
2060 profiler->UpdateObjectSizeEvent(elms->address(), elms->Size()); 2060 profiler->UpdateObjectSizeEvent(elms->address(), elms->Size());
2061 } 2061 }
2062 } 2062 }
2063 2063
2064 2064
2065 bool Map::InstancesNeedRewriting(Map* target, 2065 bool Map::InstancesNeedRewriting(Map* target, int target_number_of_fields,
2066 int target_number_of_fields, 2066 int target_inobject, int target_unused,
2067 int target_inobject, 2067 int* old_number_of_fields) {
2068 int target_unused) {
2069 // If fields were added (or removed), rewrite the instance. 2068 // If fields were added (or removed), rewrite the instance.
2070 int number_of_fields = NumberOfFields(); 2069 *old_number_of_fields = NumberOfFields();
2071 ASSERT(target_number_of_fields >= number_of_fields); 2070 ASSERT(target_number_of_fields >= *old_number_of_fields);
2072 if (target_number_of_fields != number_of_fields) return true; 2071 if (target_number_of_fields != *old_number_of_fields) return true;
2073 2072
2074 // If smi descriptors were replaced by double descriptors, rewrite. 2073 // If smi descriptors were replaced by double descriptors, rewrite.
2075 DescriptorArray* old_desc = instance_descriptors(); 2074 DescriptorArray* old_desc = instance_descriptors();
2076 DescriptorArray* new_desc = target->instance_descriptors(); 2075 DescriptorArray* new_desc = target->instance_descriptors();
2077 int limit = NumberOfOwnDescriptors(); 2076 int limit = NumberOfOwnDescriptors();
2078 for (int i = 0; i < limit; i++) { 2077 for (int i = 0; i < limit; i++) {
2079 if (new_desc->GetDetails(i).representation().IsDouble() != 2078 if (new_desc->GetDetails(i).representation().IsDouble() !=
2080 old_desc->GetDetails(i).representation().IsDouble()) { 2079 old_desc->GetDetails(i).representation().IsDouble()) {
2081 return true; 2080 return true;
2082 } 2081 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 // * Copy inobject properties from the backing store back into the object. 2139 // * Copy inobject properties from the backing store back into the object.
2141 // * Trim the difference in instance size of the object. This also cleanly 2140 // * Trim the difference in instance size of the object. This also cleanly
2142 // frees inobject properties that moved to the backing store. 2141 // frees inobject properties that moved to the backing store.
2143 // * If there are properties left in the backing store, trim of the space used 2142 // * If there are properties left in the backing store, trim of the space used
2144 // to temporarily store the inobject properties. 2143 // to temporarily store the inobject properties.
2145 // * If there are properties left in the backing store, install the backing 2144 // * If there are properties left in the backing store, install the backing
2146 // store. 2145 // store.
2147 void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) { 2146 void JSObject::MigrateFastToFast(Handle<JSObject> object, Handle<Map> new_map) {
2148 Isolate* isolate = object->GetIsolate(); 2147 Isolate* isolate = object->GetIsolate();
2149 Handle<Map> old_map(object->map()); 2148 Handle<Map> old_map(object->map());
2149 int old_number_of_fields;
2150 int number_of_fields = new_map->NumberOfFields(); 2150 int number_of_fields = new_map->NumberOfFields();
2151 int inobject = new_map->inobject_properties(); 2151 int inobject = new_map->inobject_properties();
2152 int unused = new_map->unused_property_fields(); 2152 int unused = new_map->unused_property_fields();
2153 2153
2154 // Nothing to do if no functions were converted to fields and no smis were 2154 // Nothing to do if no functions were converted to fields and no smis were
2155 // converted to doubles. 2155 // converted to doubles.
2156 if (!old_map->InstancesNeedRewriting( 2156 if (!old_map->InstancesNeedRewriting(*new_map, number_of_fields, inobject,
2157 *new_map, number_of_fields, inobject, unused)) { 2157 unused, &old_number_of_fields)) {
2158 object->synchronized_set_map(*new_map); 2158 object->synchronized_set_map(*new_map);
2159 return; 2159 return;
2160 } 2160 }
2161 2161
2162 int total_size = number_of_fields + unused; 2162 int total_size = number_of_fields + unused;
2163 int external = total_size - inobject; 2163 int external = total_size - inobject;
2164 2164
2165 if ((old_map->unused_property_fields() == 0) && 2165 if ((old_map->unused_property_fields() == 0) &&
2166 (number_of_fields != old_number_of_fields) &&
2166 (new_map->GetBackPointer() == *old_map)) { 2167 (new_map->GetBackPointer() == *old_map)) {
2168 ASSERT(number_of_fields == old_number_of_fields + 1);
2167 // This migration is a transition from a map that has run out out property 2169 // This migration is a transition from a map that has run out out property
2168 // space. Therefore it could be done by extending the backing store. 2170 // space. Therefore it could be done by extending the backing store.
2169 Handle<FixedArray> old_storage = handle(object->properties(), isolate); 2171 Handle<FixedArray> old_storage = handle(object->properties(), isolate);
2170 Handle<FixedArray> new_storage = 2172 Handle<FixedArray> new_storage =
2171 FixedArray::CopySize(old_storage, external); 2173 FixedArray::CopySize(old_storage, external);
2172 2174
2173 // Properly initialize newly added property. 2175 // Properly initialize newly added property.
2174 PropertyDetails details = new_map->GetLastDescriptorDetails(); 2176 PropertyDetails details = new_map->GetLastDescriptorDetails();
2175 Handle<Object> value; 2177 Handle<Object> value;
2176 if (details.representation().IsDouble()) { 2178 if (details.representation().IsDouble()) {
(...skipping 14799 matching lines...) Expand 10 before | Expand all | Expand 10 after
16976 #define ERROR_MESSAGES_TEXTS(C, T) T, 16978 #define ERROR_MESSAGES_TEXTS(C, T) T,
16977 static const char* error_messages_[] = { 16979 static const char* error_messages_[] = {
16978 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16980 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16979 }; 16981 };
16980 #undef ERROR_MESSAGES_TEXTS 16982 #undef ERROR_MESSAGES_TEXTS
16981 return error_messages_[reason]; 16983 return error_messages_[reason];
16982 } 16984 }
16983 16985
16984 16986
16985 } } // namespace v8::internal 16987 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | test/mjsunit/regress/regress-crbug-390918.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698