From a4d1e01b793f51cdc0ee3fc3c56c4d64056ee25d Mon Sep 17 00:00:00 2001 From: "jkummerow@chromium.org" Date: Fri, 13 Jun 2014 09:46:29 +0000 Subject: [PATCH] Use generic representation when normalizing boilerplate properties R=verwaest@chromium.org Review URL: https://codereview.chromium.org/323403008 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21833 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/runtime.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/runtime.cc b/src/runtime.cc index d5903a0645..83fbcb78a0 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -245,13 +245,14 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( int length = constant_properties->length(); bool should_transform = !is_result_from_cache && boilerplate->HasFastProperties(); - if (should_transform || has_function_literal) { - // Normalize the properties of object to avoid n^2 behavior - // when extending the object multiple properties. Indicate the number of - // properties to be added. + bool should_normalize = should_transform || has_function_literal; + if (should_normalize) { + // TODO(verwaest): We might not want to ever normalize here. JSObject::NormalizeProperties( boilerplate, KEEP_INOBJECT_PROPERTIES, length / 2); } + Object::ValueType value_type = should_normalize + ? Object::FORCE_TAGGED : Object::OPTIMAL_REPRESENTATION; // TODO(verwaest): Support tracking representations in the boilerplate. for (int index = 0; index < length; index +=2) { @@ -279,7 +280,7 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( ASSERT(!name->AsArrayIndex(&element_index)); maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( boilerplate, name, value, NONE, - Object::OPTIMAL_REPRESENTATION, mode); + value_type, mode); } } else if (key->ToArrayIndex(&element_index)) { // Array index (uint32). @@ -295,7 +296,7 @@ MUST_USE_RESULT static MaybeHandle CreateObjectLiteralBoilerplate( Handle name = isolate->factory()->NewStringFromAsciiChecked(str); maybe_result = JSObject::SetOwnPropertyIgnoreAttributes( boilerplate, name, value, NONE, - Object::OPTIMAL_REPRESENTATION, mode); + value_type, mode); } // If setting the property on the boilerplate throws an // exception, the exception is converted to an empty handle in