ES6 Classes: Remove tracking of super construct calls.
authorarv <arv@chromium.org>
Fri, 13 Feb 2015 22:26:17 +0000 (14:26 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 13 Feb 2015 22:26:34 +0000 (22:26 +0000)
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}

src/ast.cc
src/ast.h
src/objects-inl.h
src/objects.cc
src/objects.h
src/parser.cc
src/preparser.h
src/scopes.cc
src/scopes.h

index 2d4d3d57bf3805faee5fad1b055cd1dcf5255168..02c264fa29507ac16a2352372a195e9e701c8cc6 100644 (file)
@@ -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(
index 0229880b799138ef2e6af5e70a5277c4ccb20843..68cbb38e8b6902b9ed908c812113a4d6d0019205 100644 (file)
--- a/src/ast.h
+++ b/src/ast.h
@@ -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() &&
index 5e6e32c7945ab08435876923fa8d0526cf6358c2..1aa342c548562f3e704c6c17898947fa4cb70025 100644 (file)
@@ -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)
index c92b5f1fddd7f76a16107ef5212a57551e84b4c6..7e5ea1453021a06e9590d6953b13fe8faae14099 100644 (file)
@@ -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());
 }
 
index e1287088b3495cee1bcc698527f4754c0e70b63a..ca6c938d47bb729905d9241c1a03404467bf06c1 100644 (file)
@@ -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,
index 8526f48d1cea5e310ceb38a64aba80001d5fb770..c2ec33364a727d84ef34bc1c0d0276f5cdb7aaa5 100644 (file)
@@ -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 {
index fa72794159e07b7bc5c7818bb4bb8f9dc4407941..c11bbd1629f66cf05aa0de2597504f8ede45a840 100644 (file)
@@ -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());
     }
   }
index b32c9a30666a722ede924057c01e7bf7fc789b34..05cd2e7c16ef50b2a0375f1db55c32a2c82e93b5 100644 (file)
@@ -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;
       }
index 2cc8b3e9569bf80bc11d49dfdda733d134ef7f73..84439be6156142c3d693315a97c94944eb53d418 100644 (file)
@@ -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_;