| 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));
|
| }
|
|
|