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

Unified Diff: src/ast/ast.h

Issue 2445333002: Ensure slow properties for simple {__proto__:null} literals. (Closed)
Patch Set: updated bytecode expectations Created 3 years, 9 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index c3790b34b377fe448289a171d066207cdb8e998e..44b865aad180291d4d94669b0f5030dcc7d86fa1 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -1353,6 +1353,12 @@ class ObjectLiteralProperty final : public LiteralProperty {
void set_receiver_type(Handle<Map> map) { receiver_type_ = map; }
+ bool IsNullPrototype() const {
+ if (!IsPrototype()) return false;
+ return value()->IsNullLiteral();
adamk 2017/03/13 18:10:44 Nit: return IsPrototype() && value()->IsNullLiter
Camillo Bruni 2017/03/17 16:40:55 uhm, right, used to be more complex ;)
+ }
+ bool IsPrototype() const { return kind() == PROTOTYPE; }
+
private:
friend class AstNodeFactory;
@@ -1390,7 +1396,13 @@ class ObjectLiteral final : public MaterializedLiteral {
bool has_rest_property() const {
return HasRestPropertyField::decode(bit_field_);
}
-
+ bool HasNullPrototype() const {
+ for (int i = 0; i < properties()->length(); i++) {
+ const ObjectLiteral::Property* property = properties()->at(i);
+ if (property->IsNullPrototype()) return true;
+ }
+ return false;
+ }
// Decide if a property should be in the object boilerplate.
static bool IsBoilerplateProperty(Property* property);
@@ -1420,12 +1432,9 @@ class ObjectLiteral final : public MaterializedLiteral {
// Assemble bitfield of flags for the CreateObjectLiteral helper.
int ComputeFlags(bool disable_mementos = false) const {
int flags = fast_elements() ? kFastElements : kNoFlags;
- if (has_shallow_properties()) {
- flags |= kShallowProperties;
- }
- if (disable_mementos) {
- flags |= kDisableMementos;
- }
+ if (HasNullPrototype()) flags |= kHasNullPrototype;
+ if (has_shallow_properties()) flags |= kShallowProperties;
+ if (disable_mementos) flags |= kDisableMementos;
return flags;
}
@@ -1435,6 +1444,7 @@ class ObjectLiteral final : public MaterializedLiteral {
kShallowProperties = 1 << 1,
kDisableMementos = 1 << 2,
kHasRestProperty = 1 << 3,
+ kHasNullPrototype = 1 << 4,
};
struct Accessors: public ZoneObject {
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | src/ast/ast.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698