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