Commit a9e174f8 authored by ager@chromium.org's avatar ager@chromium.org

Make sure that the inline_new flag guards all the optimizations for

constructors that only contain simple this assignments.

Make sure that constructors with declarations are not treated as
constructors with only simple this property assignments.

Review URL: http://codereview.chromium.org/601081

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3875 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 8bc68937
......@@ -2383,11 +2383,14 @@ Object* Heap::AllocateInitialMap(JSFunction* fun) {
map->set_unused_property_fields(in_object_properties);
map->set_prototype(prototype);
// If the function has only simple this property assignments add field
// descriptors for these to the initial map as the object cannot be
// constructed without having these properties.
// If the function has only simple this property assignments add
// field descriptors for these to the initial map as the object
// cannot be constructed without having these properties. Guard by
// the inline_new flag so we only change the map if we generate a
// specialized construct stub.
ASSERT(in_object_properties <= Map::kMaxPreAllocatedPropertyFields);
if (fun->shared()->has_only_simple_this_property_assignments() &&
if (FLAG_inline_new &&
fun->shared()->has_only_simple_this_property_assignments() &&
fun->shared()->this_property_assignments_count() > 0) {
int count = fun->shared()->this_property_assignments_count();
if (count > in_object_properties) {
......
......@@ -1690,7 +1690,8 @@ void* Parser::ParseSourceElements(ZoneListWrapper<Statement>* processor,
// Propagate the collected information on this property assignments.
if (top_scope_->is_function_scope()) {
bool only_simple_this_property_assignments =
this_property_assignment_finder.only_simple_this_property_assignments();
this_property_assignment_finder.only_simple_this_property_assignments()
&& top_scope_->declarations()->length() == 0;
if (only_simple_this_property_assignments) {
temp_scope_->SetThisPropertyAssignmentInfo(
only_simple_this_property_assignments,
......
......@@ -4850,9 +4850,6 @@ static Object* Runtime_NewClosure(Arguments args) {
static Code* ComputeConstructStub(Handle<SharedFunctionInfo> shared) {
// TODO(385): Change this to create a construct stub specialized for
// the given map to make allocation of simple objects - and maybe
// arrays - much faster.
if (FLAG_inline_new
&& shared->has_only_simple_this_property_assignments()) {
ConstructStubCompiler compiler;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment