Commit 679201f6 authored by franzih's avatar franzih Committed by Commit bot

[parser] Delete has_seen_proto in ObjectLiteral.

For an object literal, has_seen_proto is needed to create the
BoilerplateDescription. When iterating over the object
properties in the AST, has_seen_proto can easily be computed. The
flag in the ObjectLiteral is unnecessary.

R=verwaest@chromium.org

BUG=v8:5625

Review-Url: https://codereview.chromium.org/2646333002
Cr-Commit-Position: refs/heads/master@{#42601}
parent e347408d
......@@ -520,7 +520,6 @@ void ObjectLiteral::InitDepthAndFlags() {
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
if (!IsBoilerplateProperty(property)) {
DCHECK(has_seen_proto());
is_simple = false;
continue;
}
......@@ -584,9 +583,14 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
if (!constant_properties_.is_null()) return;
int index_keys = 0;
bool has_seen_proto = false;
for (int i = 0; i < properties()->length(); i++) {
ObjectLiteral::Property* property = properties()->at(i);
if (!IsBoilerplateProperty(property) || property->is_computed_name()) {
if (!IsBoilerplateProperty(property)) {
has_seen_proto = true;
continue;
}
if (property->is_computed_name()) {
continue;
}
......@@ -602,7 +606,7 @@ void ObjectLiteral::BuildConstantProperties(Isolate* isolate) {
Handle<BoilerplateDescription> constant_properties =
isolate->factory()->NewBoilerplateDescription(
boilerplate_properties_, properties()->length() - index_keys,
has_seen_proto());
has_seen_proto);
int position = 0;
for (int i = 0; i < properties()->length(); i++) {
......
......@@ -1402,9 +1402,6 @@ class ObjectLiteral final : public MaterializedLiteral {
bool has_rest_property() const {
return HasRestPropertyField::decode(bit_field_);
}
bool has_seen_proto() const {
return HasSeenProtoPropertyField::decode(bit_field_);
}
// Decide if a property should be in the object boilerplate.
static bool IsBoilerplateProperty(Property* property);
......@@ -1476,7 +1473,7 @@ class ObjectLiteral final : public MaterializedLiteral {
friend class AstNodeFactory;
ObjectLiteral(ZoneList<Property*>* properties, int literal_index,
uint32_t boilerplate_properties, bool has_seen_proto, int pos,
uint32_t boilerplate_properties, int pos,
bool has_rest_property)
: MaterializedLiteral(literal_index, pos, kObjectLiteral),
boilerplate_properties_(boilerplate_properties),
......@@ -1484,8 +1481,7 @@ class ObjectLiteral final : public MaterializedLiteral {
bit_field_ |= FastElementsField::encode(false) |
HasElementsField::encode(false) |
MayStoreDoublesField::encode(false) |
HasRestPropertyField::encode(has_rest_property) |
HasSeenProtoPropertyField::encode(has_seen_proto);
HasRestPropertyField::encode(has_rest_property);
}
static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
......@@ -1503,8 +1499,6 @@ class ObjectLiteral final : public MaterializedLiteral {
: public BitField<bool, HasElementsField::kNext, 1> {};
class HasRestPropertyField
: public BitField<bool, MayStoreDoublesField::kNext, 1> {};
class HasSeenProtoPropertyField
: public BitField<bool, HasRestPropertyField::kNext, 1> {};
};
......@@ -3351,11 +3345,10 @@ class AstNodeFactory final BASE_EMBEDDED {
ObjectLiteral* NewObjectLiteral(
ZoneList<ObjectLiteral::Property*>* properties, int literal_index,
uint32_t boilerplate_properties, bool has_seen_proto, int pos,
bool has_rest_property) {
uint32_t boilerplate_properties, int pos, bool has_rest_property) {
return new (zone_)
ObjectLiteral(properties, literal_index, boilerplate_properties,
has_seen_proto, pos, has_rest_property);
ObjectLiteral(properties, literal_index, boilerplate_properties, pos,
has_rest_property);
}
ObjectLiteral::Property* NewObjectLiteralProperty(
......
......@@ -2552,7 +2552,6 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
typename Types::ObjectPropertyList properties =
impl()->NewObjectPropertyList(4);
int number_of_boilerplate_properties = 0;
bool has_seen_proto = false;
bool has_computed_names = false;
bool has_rest_property = false;
......@@ -2576,9 +2575,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
has_rest_property = true;
}
if (!impl()->IsBoilerplateProperty(property)) {
has_seen_proto = true;
} else if (!has_computed_names) {
if (impl()->IsBoilerplateProperty(property) && !has_computed_names) {
// Count CONSTANT or COMPUTED properties to maintain the enumeration
// order.
number_of_boilerplate_properties++;
......@@ -2599,8 +2596,8 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseObjectLiteral(
int literal_index = function_state_->NextMaterializedLiteralIndex();
return factory()->NewObjectLiteral(properties, literal_index,
number_of_boilerplate_properties,
has_seen_proto, pos, has_rest_property);
number_of_boilerplate_properties, pos,
has_rest_property);
}
template <typename Impl>
......
......@@ -595,8 +595,7 @@ class PreParserFactory {
}
PreParserExpression NewObjectLiteral(PreParserExpressionList properties,
int literal_index,
int boilerplate_properties,
bool has_seen_proto, int pos,
int boilerplate_properties, int pos,
bool has_rest_property) {
return PreParserExpression::ObjectLiteral(properties.variables_);
}
......
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