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

Unified Diff: src/ast.h

Issue 1143813002: Reland "[strong] Object literals create strong objects" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix handlification bug Created 5 years, 7 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 | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 26950b4c9ae95ca003e177422e45e41130e63691..60f0068d37aebe855c31c352469af4d9ca058bf5 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -1295,11 +1295,14 @@ class MaterializedLiteral : public Expression {
return depth_;
}
+ bool is_strong() const { return is_strong_; }
+
protected:
- MaterializedLiteral(Zone* zone, int literal_index, int pos)
+ MaterializedLiteral(Zone* zone, int literal_index, bool is_strong, int pos)
: Expression(zone, pos),
literal_index_(literal_index),
is_simple_(false),
+ is_strong_(is_strong),
depth_(0) {}
// A materialized literal is simple if the values consist of only
@@ -1328,6 +1331,7 @@ class MaterializedLiteral : public Expression {
private:
int literal_index_;
bool is_simple_;
+ bool is_strong_;
int depth_;
};
@@ -1422,6 +1426,9 @@ class ObjectLiteral final : public MaterializedLiteral {
if (disable_mementos) {
flags |= kDisableMementos;
}
+ if (is_strong()) {
+ flags |= kIsStrong;
+ }
return flags;
}
@@ -1430,7 +1437,8 @@ class ObjectLiteral final : public MaterializedLiteral {
kFastElements = 1,
kHasFunction = 1 << 1,
kShallowProperties = 1 << 2,
- kDisableMementos = 1 << 3
+ kDisableMementos = 1 << 3,
+ kIsStrong = 1 << 4
};
struct Accessors: public ZoneObject {
@@ -1450,8 +1458,9 @@ class ObjectLiteral final : public MaterializedLiteral {
protected:
ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index,
- int boilerplate_properties, bool has_function, int pos)
- : MaterializedLiteral(zone, literal_index, pos),
+ int boilerplate_properties, bool has_function,
+ bool is_strong, int pos)
+ : MaterializedLiteral(zone, literal_index, is_strong, pos),
properties_(properties),
boilerplate_properties_(boilerplate_properties),
fast_elements_(false),
@@ -1482,8 +1491,9 @@ class RegExpLiteral final : public MaterializedLiteral {
protected:
RegExpLiteral(Zone* zone, const AstRawString* pattern,
- const AstRawString* flags, int literal_index, int pos)
- : MaterializedLiteral(zone, literal_index, pos),
+ const AstRawString* flags, int literal_index, bool is_strong,
+ int pos)
+ : MaterializedLiteral(zone, literal_index, is_strong, pos),
pattern_(pattern),
flags_(flags) {
set_depth(1);
@@ -1528,19 +1538,24 @@ class ArrayLiteral final : public MaterializedLiteral {
if (disable_mementos) {
flags |= kDisableMementos;
}
+ if (is_strong()) {
+ flags |= kIsStrong;
+ }
return flags;
}
enum Flags {
kNoFlags = 0,
kShallowElements = 1,
- kDisableMementos = 1 << 1
+ kDisableMementos = 1 << 1,
+ kIsStrong = 1 << 2
};
protected:
ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index,
- int pos)
- : MaterializedLiteral(zone, literal_index, pos), values_(values) {}
+ bool is_strong, int pos)
+ : MaterializedLiteral(zone, literal_index, is_strong, pos),
+ values_(values) {}
static int parent_num_ids() { return MaterializedLiteral::num_ids(); }
private:
@@ -3305,9 +3320,11 @@ class AstNodeFactory final BASE_EMBEDDED {
int literal_index,
int boilerplate_properties,
bool has_function,
+ bool is_strong,
int pos) {
return new (zone_) ObjectLiteral(zone_, properties, literal_index,
- boilerplate_properties, has_function, pos);
+ boilerplate_properties, has_function,
+ is_strong, pos);
}
ObjectLiteral::Property* NewObjectLiteralProperty(
@@ -3328,14 +3345,18 @@ class AstNodeFactory final BASE_EMBEDDED {
RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern,
const AstRawString* flags,
int literal_index,
+ bool is_strong,
int pos) {
- return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos);
+ return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index,
+ is_strong, pos);
}
ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values,
int literal_index,
+ bool is_strong,
int pos) {
- return new (zone_) ArrayLiteral(zone_, values, literal_index, pos);
+ return new (zone_) ArrayLiteral(zone_, values, literal_index, is_strong,
+ pos);
}
VariableProxy* NewVariableProxy(Variable* var,
« no previous file with comments | « include/v8.h ('k') | src/bootstrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698