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

Unified Diff: src/ast/ast.h

Issue 2176653003: Wrap ClassLiterals in DoExpressions instead of giving them BlockScopes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: address comments Created 4 years, 5 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') | no next file with comments »
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 f0138723f540120eeaf1ff9cf772795130c7f590..19e530c915912f5df9a28ca6581df7b6d8cc40d0 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -474,10 +474,18 @@ class DoExpression final : public Expression {
void set_block(Block* b) { block_ = b; }
VariableProxy* result() { return result_; }
void set_result(VariableProxy* v) { result_ = v; }
+ FunctionLiteral* represented_function() { return represented_function_; }
+ void set_represented_function(FunctionLiteral* f) {
+ represented_function_ = f;
+ }
+ bool IsAnonymousFunctionDefinition() const;
protected:
DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos)
- : Expression(zone, pos, kDoExpression), block_(block), result_(result) {
+ : Expression(zone, pos, kDoExpression),
+ block_(block),
+ result_(result),
+ represented_function_(nullptr) {
DCHECK_NOT_NULL(block_);
DCHECK_NOT_NULL(result_);
}
@@ -488,6 +496,7 @@ class DoExpression final : public Expression {
Block* block_;
VariableProxy* result_;
+ FunctionLiteral* represented_function_;
};
@@ -2715,7 +2724,6 @@ class ClassLiteral final : public Expression {
DECLARE_NODE_TYPE(ClassLiteral)
- Scope* scope() const { return scope_; }
VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
Expression* extends() const { return extends_; }
void set_extends(Expression* e) { extends_ = e; }
@@ -2725,18 +2733,15 @@ class ClassLiteral final : public Expression {
int start_position() const { return position(); }
int end_position() const { return end_position_; }
- BailoutId EntryId() const { return BailoutId(local_id(0)); }
- BailoutId DeclsId() const { return BailoutId(local_id(1)); }
- BailoutId ExitId() { return BailoutId(local_id(2)); }
- BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); }
- BailoutId PrototypeId() { return BailoutId(local_id(4)); }
+ BailoutId CreateLiteralId() const { return BailoutId(local_id(0)); }
+ BailoutId PrototypeId() { return BailoutId(local_id(1)); }
// Return an AST id for a property that is used in simulate instructions.
- BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 5)); }
+ BailoutId GetIdForProperty(int i) { return BailoutId(local_id(i + 2)); }
// Unlike other AST nodes, this number of bailout IDs allocated for an
// ClassLiteral can vary, so num_ids() is not a static method.
- int num_ids() const { return parent_num_ids() + 5 + properties()->length(); }
+ int num_ids() const { return parent_num_ids() + 2 + properties()->length(); }
// Object literals need one feedback slot for each non-trivial value, as well
// as some slots for home objects.
@@ -2751,18 +2756,14 @@ class ClassLiteral final : public Expression {
FeedbackVectorSlot PrototypeSlot() const { return prototype_slot_; }
FeedbackVectorSlot ProxySlot() const { return proxy_slot_; }
- bool IsAnonymousFunctionDefinition() const {
- return constructor()->raw_name()->length() == 0;
- }
protected:
- ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy,
+ ClassLiteral(Zone* zone, VariableProxy* class_variable_proxy,
Expression* extends, FunctionLiteral* constructor,
ZoneList<Property*>* properties, int start_position,
int end_position)
: Expression(zone, start_position, kClassLiteral),
end_position_(end_position),
- scope_(scope),
class_variable_proxy_(class_variable_proxy),
extends_(extends),
constructor_(constructor),
@@ -2776,7 +2777,6 @@ class ClassLiteral final : public Expression {
int end_position_;
FeedbackVectorSlot prototype_slot_;
FeedbackVectorSlot proxy_slot_;
- Scope* scope_;
VariableProxy* class_variable_proxy_;
Expression* extends_;
FunctionLiteral* constructor_;
@@ -3425,14 +3425,13 @@ class AstNodeFactory final BASE_EMBEDDED {
false);
}
- ClassLiteral* NewClassLiteral(Scope* scope, VariableProxy* proxy,
- Expression* extends,
+ ClassLiteral* NewClassLiteral(VariableProxy* proxy, Expression* extends,
FunctionLiteral* constructor,
ZoneList<ObjectLiteral::Property*>* properties,
int start_position, int end_position) {
return new (local_zone_)
- ClassLiteral(local_zone_, scope, proxy, extends, constructor,
- properties, start_position, end_position);
+ ClassLiteral(local_zone_, proxy, extends, constructor, properties,
+ start_position, end_position);
}
NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name,
« no previous file with comments | « no previous file | src/ast/ast.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698