Reviewers: Dmitry Lomov (chromium),

Message:
PTAL

Description:
Classes: Cleanup default constructor flag

Now that we keep track of whether a function contains super we do not
need kDefaultConstructorCallSuper

BUG=None
LOG=Y
[email protected]

Please review this at https://codereview.chromium.org/718833002/

Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+24, -40 lines):
  M src/ast.h
  M src/ast.cc
  M src/code-stubs.h
  M src/compiler.cc
  M src/globals.h
  M src/hydrogen-instructions.h
  M src/objects.h
  M src/objects-inl.h
  M src/parser.cc


Index: src/ast.cc
diff --git a/src/ast.cc b/src/ast.cc
index 2edd51ecde537a845fc0a08fff4a13371de62439..b04efaa0929902b72795d4831dd209584b43630a 100644
--- a/src/ast.cc
+++ b/src/ast.cc
@@ -151,7 +151,7 @@ StrictMode FunctionLiteral::strict_mode() const {
 }


-bool FunctionLiteral::needs_super_binding() const {
+bool FunctionLiteral::uses_super() const {
   DCHECK_NOT_NULL(scope());
   return scope()->uses_super() || scope()->inner_uses_super();
 }
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index d19028d04f1d233bdbda46df868e43ac99416c65..7faaaef21e279f606900d8c58d5fff942f904728 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -2497,11 +2497,11 @@ class FunctionLiteral FINAL : public Expression {
   bool is_expression() const { return IsExpression::decode(bitfield_); }
   bool is_anonymous() const { return IsAnonymous::decode(bitfield_); }
   StrictMode strict_mode() const;
-  bool needs_super_binding() const;
+  bool uses_super() const;

   static bool NeedsHomeObject(Expression* literal) {
     return literal != NULL && literal->IsFunctionLiteral() &&
-           literal->AsFunctionLiteral()->needs_super_binding();
+           literal->AsFunctionLiteral()->uses_super();
   }

   int materialized_literal_count() { return materialized_literal_count_; }
@@ -2585,9 +2585,6 @@ class FunctionLiteral FINAL : public Expression {
   bool is_default_constructor() {
     return IsDefaultConstructor(FunctionKindBits::decode(bitfield_));
   }
-  bool is_default_constructor_call_super() {
- return IsDefaultConstructorCallSuper(FunctionKindBits::decode(bitfield_));
-  }

   int ast_node_count() { return ast_properties_.node_count(); }
   AstProperties::Flags* flags() { return ast_properties_.flags(); }
@@ -2659,7 +2656,7 @@ class FunctionLiteral FINAL : public Expression {
   class HasDuplicateParameters : public BitField<ParameterFlag, 3, 1> {};
   class IsFunction : public BitField<IsFunctionFlag, 4, 1> {};
   class IsParenthesized : public BitField<IsParenthesizedFlag, 5, 1> {};
-  class FunctionKindBits : public BitField<FunctionKind, 6, 5> {};
+  class FunctionKindBits : public BitField<FunctionKind, 6, 4> {};
 };


Index: src/code-stubs.h
diff --git a/src/code-stubs.h b/src/code-stubs.h
index 4166d3daa6484b18f7318130d8bcb42f39586176..8af4b04a18a6a279d5916e8cb2dadd45cd528792 100644
--- a/src/code-stubs.h
+++ b/src/code-stubs.h
@@ -576,13 +576,10 @@ class FastNewClosureStub : public HydrogenCodeStub {
   bool is_generator() const { return IsGeneratorFunction(kind()); }
   bool is_concise_method() const { return IsConciseMethod(kind()); }
bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
-  bool is_default_constructor_call_super() const {
-    return IsDefaultConstructorCallSuper(kind());
-  }

  private:
   class StrictModeBits : public BitField<StrictMode, 0, 1> {};
-  class FunctionKindBits : public BitField<FunctionKind, 1, 5> {};
+  class FunctionKindBits : public BitField<FunctionKind, 1, 4> {};

   DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewClosure);
   DEFINE_HYDROGEN_CODE_STUB(FastNewClosure, HydrogenCodeStub);
Index: src/compiler.cc
diff --git a/src/compiler.cc b/src/compiler.cc
index ba5f3fd56ea511d39162be59ff77f22f85cc9c22..ff1d357b4c80a96e04b5afe0a5dc274146d377c3 100644
--- a/src/compiler.cc
+++ b/src/compiler.cc
@@ -607,6 +607,7 @@ static void SetFunctionInfo(Handle<SharedFunctionInfo> function_info,
   function_info->set_bailout_reason(lit->dont_optimize_reason());
   function_info->set_dont_cache(lit->flags()->Contains(kDontCache));
   function_info->set_kind(lit->kind());
+  function_info->set_uses_super(lit->uses_super());
   function_info->set_asm_function(lit->scope()->asm_function());
 }

@@ -1333,6 +1334,7 @@ Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo(
   RecordFunctionCompilation(Logger::FUNCTION_TAG, &info, result);
   result->set_allows_lazy_compilation(allow_lazy);
result->set_allows_lazy_compilation_without_context(allow_lazy_without_ctx);
+  result->set_uses_super(literal->uses_super());

   // Set the expected number of properties for instances and return
   // the resulting function.
Index: src/globals.h
diff --git a/src/globals.h b/src/globals.h
index dd49ef3b17fcf8c5d55df5ad689d887cfdeb60dc..20cd46de11ffac8c7418277c722fca237313a204 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -784,8 +784,7 @@ enum FunctionKind {
   kGeneratorFunction = 2,
   kConciseMethod = 4,
   kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod,
-  kDefaultConstructor = 8,
-  kDefaultConstructorCallSuper = 16
+  kDefaultConstructor = 8
 };


@@ -795,8 +794,7 @@ inline bool IsValidFunctionKind(FunctionKind kind) {
          kind == FunctionKind::kGeneratorFunction ||
          kind == FunctionKind::kConciseMethod ||
          kind == FunctionKind::kConciseGeneratorMethod ||
-         kind == FunctionKind::kDefaultConstructor ||
-         kind == FunctionKind::kDefaultConstructorCallSuper;
+         kind == FunctionKind::kDefaultConstructor;
 }


@@ -824,10 +822,6 @@ inline bool IsDefaultConstructor(FunctionKind kind) {
 }


-inline bool IsDefaultConstructorCallSuper(FunctionKind kind) {
-  DCHECK(IsValidFunctionKind(kind));
-  return kind & FunctionKind::kDefaultConstructorCallSuper;
-}
 } }  // namespace v8::internal

 namespace i = v8::internal;
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index 8994a87edb5875b7bd3f7b018b3ff3bc94791750..5fb939f8b9d55ff943dcd2c0d453c2b04146041c 100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -7567,9 +7567,6 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> {
   bool is_generator() const { return IsGeneratorFunction(kind()); }
   bool is_concise_method() const { return IsConciseMethod(kind()); }
bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
-  bool is_default_constructor_call_super() const {
-    return IsDefaultConstructorCallSuper(kind());
-  }
FunctionKind kind() const { return FunctionKindField::decode(bit_field_); } StrictMode strict_mode() const { return StrictModeField::decode(bit_field_); }

@@ -7589,7 +7586,7 @@ class HFunctionLiteral FINAL : public HTemplateInstruction<1> {

   virtual bool IsDeletable() const OVERRIDE { return true; }

-  class FunctionKindField : public BitField<FunctionKind, 0, 5> {};
+  class FunctionKindField : public BitField<FunctionKind, 0, 4> {};
   class PretenureField : public BitField<bool, 5, 1> {};
   class HasNoLiteralsField : public BitField<bool, 6, 1> {};
   class StrictModeField : public BitField<StrictMode, 7, 1> {};
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index e7dcd631a85eadf901eb9c36659d067e49f81998..7bad1690f665597fc4ee828902599727ed6a6276 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -5771,6 +5771,7 @@ void SharedFunctionInfo::set_kind(FunctionKind kind) {
 }


+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super, kUsesSuper)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
                kInlineBuiltin)
@@ -5788,9 +5789,6 @@ BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_concise_method,
                kIsConciseMethod)
 BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_default_constructor,
                kIsDefaultConstructor)
-BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints,
-               is_default_constructor_call_super,
-               kIsDefaultConstructorCallSuper)

 ACCESSORS(CodeCache, default_cache, FixedArray, kDefaultCacheOffset)
 ACCESSORS(CodeCache, normal_type_cache, Object, kNormalTypeCacheOffset)
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index aba2cc923f5b82fa2cb00bb56c580d66a9c3ff56..1428bf9fcf059dd22be69d1fcc3a7215bb64955d 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -6824,6 +6824,10 @@ class SharedFunctionInfo: public HeapObject {
// False if the function definitely does not allocate an arguments object.
   DECL_BOOLEAN_ACCESSORS(uses_arguments)

+  // Indicates that this function uses super. This is needed to set up the
+  // [[HomeObject]] on the function instance.
+  DECL_BOOLEAN_ACCESSORS(uses_super)
+
   // True if the function has any duplicated parameter names.
   DECL_BOOLEAN_ACCESSORS(has_duplicate_parameters)

@@ -6871,10 +6875,6 @@ class SharedFunctionInfo: public HeapObject {
   // Indicates that this function is a default constructor.
   DECL_BOOLEAN_ACCESSORS(is_default_constructor)

- // Indicates that this function is a default constructor that needs to call
-  // super.
-  DECL_BOOLEAN_ACCESSORS(is_default_constructor_call_super)
-
   // Indicates that this function is an asm function.
   DECL_BOOLEAN_ACCESSORS(asm_function)

@@ -7105,6 +7105,7 @@ class SharedFunctionInfo: public HeapObject {
     kOptimizationDisabled,
     kStrictModeFunction,
     kUsesArguments,
+    kUsesSuper,
     kHasDuplicateParameters,
     kNative,
     kInlineBuiltin,
@@ -7118,13 +7119,12 @@ class SharedFunctionInfo: public HeapObject {
     kIsGenerator,
     kIsConciseMethod,
     kIsDefaultConstructor,
-    kIsDefaultConstructorCallSuper,
     kIsAsmFunction,
     kDeserialized,
     kCompilerHintsCount  // Pseudo entry
   };

-  class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 5> {};
+  class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 4> {};

   class DeoptCountBits : public BitField<int, 0, 4> {};
   class OptReenableTriesBits : public BitField<int, 4, 18> {};
Index: src/parser.cc
diff --git a/src/parser.cc b/src/parser.cc
index 4c813554e7e07174bf1994f08713dab426a8303a..8e16ce01869ca972b79dc937efb15c067bfb1cd4 100644
--- a/src/parser.cc
+++ b/src/parser.cc
@@ -284,8 +284,6 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
   AstProperties ast_properties;
   BailoutReason dont_optimize_reason = kNoReason;
   const AstRawString* name = ast_value_factory()->empty_string();
- FunctionKind kind = call_super ? FunctionKind::kDefaultConstructorCallSuper
-                                 : FunctionKind::kDefaultConstructor;

   Scope* function_scope = NewScope(scope, FUNCTION_SCOPE);
   function_scope->SetStrictMode(STRICT);
@@ -309,6 +307,7 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope, Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args,
           pos);
       body->Add(factory()->NewExpressionStatement(call, pos), zone());
+      function_scope->RecordSuperUsage();
     }

materialized_literal_count = function_state.materialized_literal_count(); @@ -324,7 +323,8 @@ FunctionLiteral* Parser::DefaultConstructor(bool call_super, Scope* scope,
       materialized_literal_count, expected_property_count, handler_count,
       parameter_count, FunctionLiteral::kNoDuplicateParameters,
       FunctionLiteral::ANONYMOUS_EXPRESSION, FunctionLiteral::kIsFunction,
-      FunctionLiteral::kNotParenthesized, kind, pos);
+ FunctionLiteral::kNotParenthesized, FunctionKind::kDefaultConstructor,
+      pos);

   function_literal->set_ast_properties(&ast_properties);
   function_literal->set_dont_optimize_reason(dont_optimize_reason);
@@ -1069,11 +1069,10 @@ FunctionLiteral* Parser::ParseLazy(Utf16CharacterStream* source) {
       Expression* expression = ParseExpression(false, &ok);
       DCHECK(expression->IsFunctionLiteral());
       result = expression->AsFunctionLiteral();
-    } else if (shared_info->is_default_constructor() ||
-               shared_info->is_default_constructor_call_super()) {
-      result = DefaultConstructor(
-          shared_info->is_default_constructor_call_super(), scope,
-          shared_info->start_position(), shared_info->end_position());
+    } else if (shared_info->is_default_constructor()) {
+      result = DefaultConstructor(shared_info->uses_super(), scope,
+                                  shared_info->start_position(),
+                                  shared_info->end_position());
     } else {
       result = ParseFunctionLiteral(raw_name, Scanner::Location::invalid(),
false, // Strict mode name already checked.


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to