ES6 Classes: Remove tracking of super construct calls.
With the new ES6 semantics super construct calls are only valid in a constructor in a derived class. This is something that is statically known and we report early SyntaxError in case it occurs. We therefore do not need to track this any more. BUG=v8:3330 LOG=N R=dslomov@chromium.org, adamk Review URL: https://codereview.chromium.org/924123002 Cr-Commit-Position: refs/heads/master@{#26644}
This commit is contained in:
parent
907f0b6ce5
commit
d0c2c2b32c
@ -152,13 +152,6 @@ bool FunctionLiteral::uses_super_property() const {
|
||||
}
|
||||
|
||||
|
||||
bool FunctionLiteral::uses_super_constructor_call() const {
|
||||
DCHECK_NOT_NULL(scope());
|
||||
return scope()->uses_super_constructor_call() ||
|
||||
scope()->inner_uses_super_constructor_call();
|
||||
}
|
||||
|
||||
|
||||
// Helper to find an existing shared function info in the baseline code for the
|
||||
// given function literal. Used to canonicalize SharedFunctionInfo objects.
|
||||
void FunctionLiteral::InitializeSharedInfo(
|
||||
|
@ -2470,7 +2470,6 @@ class FunctionLiteral FINAL : public Expression {
|
||||
bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
|
||||
LanguageMode language_mode() const;
|
||||
bool uses_super_property() const;
|
||||
bool uses_super_constructor_call() const;
|
||||
|
||||
static bool NeedsHomeObject(Expression* literal) {
|
||||
return literal != NULL && literal->IsFunctionLiteral() &&
|
||||
|
@ -5853,8 +5853,6 @@ void SharedFunctionInfo::set_kind(FunctionKind kind) {
|
||||
|
||||
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super_property,
|
||||
kUsesSuperProperty)
|
||||
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super_constructor_call,
|
||||
kUsesSuperConstructorCall)
|
||||
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
|
||||
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
|
||||
kInlineBuiltin)
|
||||
|
@ -10415,8 +10415,6 @@ void SharedFunctionInfo::InitFromFunctionLiteral(
|
||||
lit->flags()->Contains(AstPropertiesFlag::kDontCache));
|
||||
shared_info->set_kind(lit->kind());
|
||||
shared_info->set_uses_super_property(lit->uses_super_property());
|
||||
shared_info->set_uses_super_constructor_call(
|
||||
lit->uses_super_constructor_call());
|
||||
shared_info->set_asm_function(lit->scope()->asm_function());
|
||||
}
|
||||
|
||||
|
@ -6912,9 +6912,6 @@ class SharedFunctionInfo: public HeapObject {
|
||||
// This is needed to set up the [[HomeObject]] on the function instance.
|
||||
DECL_BOOLEAN_ACCESSORS(uses_super_property)
|
||||
|
||||
// Indicates that this function uses the super constructor.
|
||||
DECL_BOOLEAN_ACCESSORS(uses_super_constructor_call)
|
||||
|
||||
// True if the function has any duplicated parameter names.
|
||||
DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)
|
||||
|
||||
@ -7199,7 +7196,6 @@ class SharedFunctionInfo: public HeapObject {
|
||||
kStrongModeFunction,
|
||||
kUsesArguments,
|
||||
kUsesSuperProperty,
|
||||
kUsesSuperConstructorCall,
|
||||
kHasDuplicateParameters,
|
||||
kNative,
|
||||
kInlineBuiltin,
|
||||
|
@ -297,7 +297,6 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
|
||||
Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper),
|
||||
args, pos);
|
||||
body->Add(factory()->NewReturnStatement(call, pos), zone());
|
||||
function_scope->RecordSuperConstructorCallUsage();
|
||||
}
|
||||
|
||||
materialized_literal_count = function_state.materialized_literal_count();
|
||||
@ -1089,7 +1088,7 @@ FunctionLiteral* Parser::ParseLazy(CompilationInfo* info,
|
||||
DCHECK(expression->IsFunctionLiteral());
|
||||
result = expression->AsFunctionLiteral();
|
||||
} else if (shared_info->is_default_constructor()) {
|
||||
result = DefaultConstructor(shared_info->uses_super_constructor_call(),
|
||||
result = DefaultConstructor(IsSubclassConstructor(shared_info->kind()),
|
||||
scope, shared_info->start_position(),
|
||||
shared_info->end_position());
|
||||
} else {
|
||||
|
@ -2754,7 +2754,6 @@ ParserBase<Traits>::ParseSuperExpression(bool is_new, bool* ok) {
|
||||
// new super() is never allowed.
|
||||
// super() is only allowed in derived constructor
|
||||
if (!is_new && peek() == Token::LPAREN && IsSubclassConstructor(kind)) {
|
||||
scope_->RecordSuperConstructorCallUsage();
|
||||
return this->SuperReference(scope_, factory());
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +157,6 @@ void Scope::SetDefaults(ScopeType scope_type,
|
||||
scope_calls_eval_ = false;
|
||||
scope_uses_arguments_ = false;
|
||||
scope_uses_super_property_ = false;
|
||||
scope_uses_super_constructor_call_ = false;
|
||||
scope_uses_this_ = false;
|
||||
asm_module_ = false;
|
||||
asm_function_ = outer_scope != NULL && outer_scope->asm_module_;
|
||||
@ -168,7 +167,6 @@ void Scope::SetDefaults(ScopeType scope_type,
|
||||
inner_scope_uses_arguments_ = false;
|
||||
inner_scope_uses_this_ = false;
|
||||
inner_scope_uses_super_property_ = false;
|
||||
inner_scope_uses_super_constructor_call_ = false;
|
||||
force_eager_compilation_ = false;
|
||||
force_context_allocation_ = (outer_scope != NULL && !is_function_scope())
|
||||
? outer_scope->has_forced_context_allocation() : false;
|
||||
@ -371,9 +369,6 @@ Scope* Scope::FinalizeBlockScope() {
|
||||
// Propagate usage flags to outer scope.
|
||||
if (uses_arguments()) outer_scope_->RecordArgumentsUsage();
|
||||
if (uses_super_property()) outer_scope_->RecordSuperPropertyUsage();
|
||||
if (uses_super_constructor_call()) {
|
||||
outer_scope_->RecordSuperConstructorCallUsage();
|
||||
}
|
||||
if (uses_this()) outer_scope_->RecordThisUsage();
|
||||
|
||||
return NULL;
|
||||
@ -903,17 +898,12 @@ void Scope::Print(int n) {
|
||||
if (scope_uses_arguments_) Indent(n1, "// scope uses 'arguments'\n");
|
||||
if (scope_uses_super_property_)
|
||||
Indent(n1, "// scope uses 'super' property\n");
|
||||
if (scope_uses_super_constructor_call_)
|
||||
Indent(n1, "// scope uses 'super' constructor\n");
|
||||
if (scope_uses_this_) Indent(n1, "// scope uses 'this'\n");
|
||||
if (inner_scope_uses_arguments_) {
|
||||
Indent(n1, "// inner scope uses 'arguments'\n");
|
||||
}
|
||||
if (inner_scope_uses_super_property_)
|
||||
Indent(n1, "// inner scope uses 'super' property\n");
|
||||
if (inner_scope_uses_super_constructor_call_) {
|
||||
Indent(n1, "// inner scope uses 'super' constructor\n");
|
||||
}
|
||||
if (inner_scope_uses_this_) Indent(n1, "// inner scope uses 'this'\n");
|
||||
if (outer_scope_calls_sloppy_eval_) {
|
||||
Indent(n1, "// outer scope calls 'eval' in sloppy context\n");
|
||||
@ -1190,10 +1180,6 @@ void Scope::PropagateScopeInfo(bool outer_scope_calls_sloppy_eval ) {
|
||||
inner->inner_scope_uses_super_property_) {
|
||||
inner_scope_uses_super_property_ = true;
|
||||
}
|
||||
if (inner->uses_super_constructor_call() ||
|
||||
inner->inner_scope_uses_super_constructor_call_) {
|
||||
inner_scope_uses_super_constructor_call_ = true;
|
||||
}
|
||||
if (inner->scope_uses_this_ || inner->inner_scope_uses_this_) {
|
||||
inner_scope_uses_this_ = true;
|
||||
}
|
||||
|
16
src/scopes.h
16
src/scopes.h
@ -217,11 +217,6 @@ class Scope: public ZoneObject {
|
||||
// Inform the scope that the corresponding code uses "super".
|
||||
void RecordSuperPropertyUsage() { scope_uses_super_property_ = true; }
|
||||
|
||||
// Inform the scope that the corresponding code invokes "super" constructor.
|
||||
void RecordSuperConstructorCallUsage() {
|
||||
scope_uses_super_constructor_call_ = true;
|
||||
}
|
||||
|
||||
// Inform the scope that the corresponding code uses "this".
|
||||
void RecordThisUsage() { scope_uses_this_ = true; }
|
||||
|
||||
@ -321,14 +316,6 @@ class Scope: public ZoneObject {
|
||||
bool inner_uses_super_property() const {
|
||||
return inner_scope_uses_super_property_;
|
||||
}
|
||||
// Does this scope calls "super" constructor.
|
||||
bool uses_super_constructor_call() const {
|
||||
return scope_uses_super_constructor_call_;
|
||||
}
|
||||
// Does any inner scope calls "super" constructor.
|
||||
bool inner_uses_super_constructor_call() const {
|
||||
return inner_scope_uses_super_constructor_call_;
|
||||
}
|
||||
// Does this scope access "this".
|
||||
bool uses_this() const { return scope_uses_this_; }
|
||||
// Does any inner scope access "this".
|
||||
@ -543,8 +530,6 @@ class Scope: public ZoneObject {
|
||||
bool scope_uses_arguments_;
|
||||
// This scope uses "super" property ('super.foo').
|
||||
bool scope_uses_super_property_;
|
||||
// This scope uses "super" constructor ('super(..)').
|
||||
bool scope_uses_super_constructor_call_;
|
||||
// This scope uses "this".
|
||||
bool scope_uses_this_;
|
||||
// This scope contains an "use asm" annotation.
|
||||
@ -562,7 +547,6 @@ class Scope: public ZoneObject {
|
||||
bool inner_scope_calls_eval_;
|
||||
bool inner_scope_uses_arguments_;
|
||||
bool inner_scope_uses_super_property_;
|
||||
bool inner_scope_uses_super_constructor_call_;
|
||||
bool inner_scope_uses_this_;
|
||||
bool force_eager_compilation_;
|
||||
bool force_context_allocation_;
|
||||
|
Loading…
Reference in New Issue
Block a user