Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Side by Side Diff: src/ast/ast.h

Issue 2445333002: Ensure slow properties for simple {__proto__:null} literals. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | test/mjsunit/object-literal.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_AST_AST_H_ 5 #ifndef V8_AST_AST_H_
6 #define V8_AST_AST_H_ 6 #define V8_AST_AST_H_
7 7
8 #include "src/ast/ast-types.h" 8 #include "src/ast/ast-types.h"
9 #include "src/ast/ast-value-factory.h" 9 #include "src/ast/ast-value-factory.h"
10 #include "src/ast/modules.h" 10 #include "src/ast/modules.h"
(...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 ZoneList<Property*>* properties() const { return properties_; } 1414 ZoneList<Property*>* properties() const { return properties_; }
1415 bool fast_elements() const { return FastElementsField::decode(bit_field_); } 1415 bool fast_elements() const { return FastElementsField::decode(bit_field_); }
1416 bool may_store_doubles() const { 1416 bool may_store_doubles() const {
1417 return MayStoreDoublesField::decode(bit_field_); 1417 return MayStoreDoublesField::decode(bit_field_);
1418 } 1418 }
1419 bool has_elements() const { return HasElementsField::decode(bit_field_); } 1419 bool has_elements() const { return HasElementsField::decode(bit_field_); }
1420 bool has_shallow_properties() const { 1420 bool has_shallow_properties() const {
1421 return depth() == 1 && !has_elements() && !may_store_doubles(); 1421 return depth() == 1 && !has_elements() && !may_store_doubles();
1422 } 1422 }
1423 1423
1424 bool HasOnlyNullPrototype() const {
1425 if (is_simple() || properties_count() != 0) return false;
adamk 2016/10/25 11:14:24 I don't think properties_count() gives you the rig
Camillo Bruni 2017/03/13 17:21:44 That's probably easier, right.
1426 const ObjectLiteral::Property* property = properties()->at(0);
1427 if (property->kind() != ObjectLiteral::Property::PROTOTYPE) return false;
1428 return property->value()->IsNullLiteral();
1429 }
1430
1424 // Decide if a property should be in the object boilerplate. 1431 // Decide if a property should be in the object boilerplate.
1425 static bool IsBoilerplateProperty(Property* property); 1432 static bool IsBoilerplateProperty(Property* property);
1426 1433
1427 // Populate the constant properties fixed array. 1434 // Populate the constant properties fixed array.
1428 void BuildConstantProperties(Isolate* isolate); 1435 void BuildConstantProperties(Isolate* isolate);
1429 1436
1430 // Mark all computed expressions that are bound to a key that 1437 // Mark all computed expressions that are bound to a key that
1431 // is shadowed by a later occurrence of the same key. For the 1438 // is shadowed by a later occurrence of the same key. For the
1432 // marked expressions, no store code is emitted. 1439 // marked expressions, no store code is emitted.
1433 void CalculateEmitStore(Zone* zone); 1440 void CalculateEmitStore(Zone* zone);
1434 1441
1435 // Assemble bitfield of flags for the CreateObjectLiteral helper. 1442 // Assemble bitfield of flags for the CreateObjectLiteral helper.
1436 int ComputeFlags(bool disable_mementos = false) const { 1443 int ComputeFlags(bool disable_mementos = false) const {
1437 int flags = fast_elements() ? kFastElements : kNoFlags; 1444 int flags = kNoFlags;
1445 // Use slow properties if we only set the null prototype.
1446 if (fast_elements() && !HasOnlyNullPrototype()) {
1447 flags = kFastElements;
1448 }
1438 if (has_shallow_properties()) { 1449 if (has_shallow_properties()) {
1439 flags |= kShallowProperties; 1450 flags |= kShallowProperties;
1440 } 1451 }
1441 if (disable_mementos) { 1452 if (disable_mementos) {
1442 flags |= kDisableMementos; 1453 flags |= kDisableMementos;
1443 } 1454 }
1444 return flags; 1455 return flags;
1445 } 1456 }
1446 1457
1447 enum Flags { 1458 enum Flags {
(...skipping 2146 matching lines...) Expand 10 before | Expand all | Expand 10 after
3594 : NULL; \ 3605 : NULL; \
3595 } 3606 }
3596 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) 3607 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS)
3597 #undef DECLARE_NODE_FUNCTIONS 3608 #undef DECLARE_NODE_FUNCTIONS
3598 3609
3599 3610
3600 } // namespace internal 3611 } // namespace internal
3601 } // namespace v8 3612 } // namespace v8
3602 3613
3603 #endif // V8_AST_AST_H_ 3614 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | test/mjsunit/object-literal.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698