Index: src/runtime.cc |
diff --git a/src/runtime.cc b/src/runtime.cc |
index be0281b846e7520ab28b581ac18fb078bc4d8de9..b5af3078aa93e2653b9b4abde4c01d08d40c3988 100644 |
--- a/src/runtime.cc |
+++ b/src/runtime.cc |
@@ -2960,10 +2960,24 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_SetCode) { |
RUNTIME_FUNCTION(MaybeObject*, Runtime_SetExpectedNumberOfProperties) { |
HandleScope scope(isolate); |
ASSERT(args.length() == 2); |
- CONVERT_ARG_HANDLE_CHECKED(JSFunction, function, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(JSFunction, func, 0); |
CONVERT_SMI_ARG_CHECKED(num, 1); |
RUNTIME_ASSERT(num >= 0); |
- SetExpectedNofProperties(function, num); |
+ // If objects constructed from this function exist then changing |
+ // 'estimated_nof_properties' is dangerous since the previous value might |
+ // have been compiled into the fast construct stub. More over, the inobject |
rossberg
2013/10/16 09:50:22
Nit: Moreover
|
+ // slack tracking logic might have adjusted the previous value, so even |
+ // passing the same value is risky. |
+ if (!func->shared()->live_objects_may_exist()) { |
+ func->shared()->set_expected_nof_properties(num); |
+ if (func->has_initial_map()) { |
+ Handle<Map> new_initial_map = |
+ func->GetIsolate()->factory()->CopyMap( |
+ Handle<Map>(func->initial_map())); |
+ new_initial_map->set_unused_property_fields(num); |
+ func->set_initial_map(*new_initial_map); |
+ } |
+ } |
return isolate->heap()->undefined_value(); |
} |