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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/builtins.h ('k') | src/heap.cc » ('j') | src/ia32/assembler-ia32.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/handles.cc
===================================================================
--- src/handles.cc (revision 5500)
+++ src/handles.cc (working copy)
@@ -142,6 +142,12 @@
void SetExpectedNofProperties(Handle<JSFunction> func, int nof) {
+ // If objects constructed from this function exist then changing
+ // 'estimated_nof_properties' is dangerous (even to the same value)
+ // since the inobject slack tracking logic might already have adjusted the
+ // previous value and compiled it into the fast construct stub.
+ if (func->shared()->live_objects_may_exist()) return;
+
func->shared()->set_expected_nof_properties(nof);
if (func->has_initial_map()) {
Handle<Map> new_initial_map =
@@ -158,16 +164,25 @@
static int ExpectedNofPropertiesFromEstimate(int estimate) {
- // TODO(1231235): We need dynamic feedback to estimate the number
- // of expected properties in an object. The static hack below
- // is barely a solution.
- if (estimate == 0) return 4;
- return estimate + 2;
+ // If no properties are added in the constructor, they are more likely
+ // to be added later.
+ if (estimate == 0) estimate = 2;
+
+ // We do not shrink objects that go into a snapshot (yet), so we adjust
+ // the estimate conservatively.
+ if (Serializer::enabled()) return estimate + 2;
+
+ // Inobject slack tracking will reclaim redundant inobject space later,
+ // so we can afford to adjust the estimate generously.
+ return estimate + 6;
}
void SetExpectedNofPropertiesFromEstimate(Handle<SharedFunctionInfo> shared,
int estimate) {
+ // See the comment in SetExpectedNofProperties.
+ if (shared->live_objects_may_exist()) return;
+
shared->set_expected_nof_properties(
ExpectedNofPropertiesFromEstimate(estimate));
}
« 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