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

Side by Side Diff: src/handles.cc

Issue 3329019: Dynamically determine optimal instance size.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 3 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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy( 136 Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
137 Handle<JSFunction> constructor, 137 Handle<JSFunction> constructor,
138 Handle<JSGlobalProxy> global) { 138 Handle<JSGlobalProxy> global) {
139 CALL_HEAP_FUNCTION(Heap::ReinitializeJSGlobalProxy(*constructor, *global), 139 CALL_HEAP_FUNCTION(Heap::ReinitializeJSGlobalProxy(*constructor, *global),
140 JSGlobalProxy); 140 JSGlobalProxy);
141 } 141 }
142 142
143 143
144 void SetExpectedNofProperties(Handle<JSFunction> func, int nof) { 144 void SetExpectedNofProperties(Handle<JSFunction> func, int nof) {
145 // If objects constructed from this function exist then changing
146 // 'estimated_nof_properties' is dangerous (even to the same value)
147 // since the inobject slack tracking logic might already have adjusted the
148 // previous value and compiled it into the fast construct stub.
149 if (func->shared()->live_objects_may_exist()) return;
150
145 func->shared()->set_expected_nof_properties(nof); 151 func->shared()->set_expected_nof_properties(nof);
146 if (func->has_initial_map()) { 152 if (func->has_initial_map()) {
147 Handle<Map> new_initial_map = 153 Handle<Map> new_initial_map =
148 Factory::CopyMapDropTransitions(Handle<Map>(func->initial_map())); 154 Factory::CopyMapDropTransitions(Handle<Map>(func->initial_map()));
149 new_initial_map->set_unused_property_fields(nof); 155 new_initial_map->set_unused_property_fields(nof);
150 func->set_initial_map(*new_initial_map); 156 func->set_initial_map(*new_initial_map);
151 } 157 }
152 } 158 }
153 159
154 160
155 void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value) { 161 void SetPrototypeProperty(Handle<JSFunction> func, Handle<JSObject> value) {
156 CALL_HEAP_FUNCTION_VOID(func->SetPrototype(*value)); 162 CALL_HEAP_FUNCTION_VOID(func->SetPrototype(*value));
157 } 163 }
158 164
159 165
160 static int ExpectedNofPropertiesFromEstimate(int estimate) { 166 static int ExpectedNofPropertiesFromEstimate(int estimate) {
161 // TODO(1231235): We need dynamic feedback to estimate the number 167 // If no properties are added in the constructor, they are more likely
162 // of expected properties in an object. The static hack below 168 // to be added later.
163 // is barely a solution. 169 if (estimate == 0) estimate = 2;
164 if (estimate == 0) return 4; 170
165 return estimate + 2; 171 // We do not shrink objects that go into a snapshot (yet), so we adjust
172 // the estimate conservatively.
173 if (Serializer::enabled()) return estimate + 2;
174
175 // Inobject slack tracking will reclaim redundant inobject space later,
176 // so we can afford to adjust the estimate generously.
177 return estimate + 6;
166 } 178 }
167 179
168 180
169 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared, 181 void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
170 int estimate) { 182 int estimate) {
183 // See the comment in SetExpectedNofProperties.
184 if (shared->live_objects_may_exist()) return;
185
171 shared->set_expected_nof_properties( 186 shared->set_expected_nof_properties(
172 ExpectedNofPropertiesFromEstimate(estimate)); 187 ExpectedNofPropertiesFromEstimate(estimate));
173 } 188 }
174 189
175 190
176 void NormalizeProperties(Handle<JSObject> object, 191 void NormalizeProperties(Handle<JSObject> object,
177 PropertyNormalizationMode mode, 192 PropertyNormalizationMode mode,
178 int expected_additional_properties) { 193 int expected_additional_properties) {
179 CALL_HEAP_FUNCTION_VOID(object->NormalizeProperties( 194 CALL_HEAP_FUNCTION_VOID(object->NormalizeProperties(
180 mode, 195 mode,
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 837
823 OptimizedObjectForAddingMultipleProperties:: 838 OptimizedObjectForAddingMultipleProperties::
824 ~OptimizedObjectForAddingMultipleProperties() { 839 ~OptimizedObjectForAddingMultipleProperties() {
825 // Reoptimize the object to allow fast property access. 840 // Reoptimize the object to allow fast property access.
826 if (has_been_transformed_) { 841 if (has_been_transformed_) {
827 TransformToFastProperties(object_, unused_property_fields_); 842 TransformToFastProperties(object_, unused_property_fields_);
828 } 843 }
829 } 844 }
830 845
831 } } // namespace v8::internal 846 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/builtins.h ('k') | src/heap.cc » ('j') | src/ia32/assembler-ia32.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698