}
-bool FunctionLiteral::needs_super_binding() const {
+bool FunctionLiteral::uses_super() const {
DCHECK_NOT_NULL(scope());
return scope()->uses_super() || scope()->inner_uses_super();
}
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_; }
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(); }
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> {};
};
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);
MaybeDisableOptimization(function_info, 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());
}
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.
kGeneratorFunction = 2,
kConciseMethod = 4,
kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod,
- kDefaultConstructor = 8,
- kDefaultConstructorCallSuper = 16
+ kDefaultConstructor = 8
};
kind == FunctionKind::kGeneratorFunction ||
kind == FunctionKind::kConciseMethod ||
kind == FunctionKind::kConciseGeneratorMethod ||
- kind == FunctionKind::kDefaultConstructor ||
- kind == FunctionKind::kDefaultConstructorCallSuper;
+ kind == FunctionKind::kDefaultConstructor;
}
}
-inline bool IsDefaultConstructorCallSuper(FunctionKind kind) {
- DCHECK(IsValidFunctionKind(kind));
- return kind & FunctionKind::kDefaultConstructorCallSuper;
-}
} } // namespace v8::internal
namespace i = v8::internal;
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_); }
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> {};
}
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, uses_super, kUsesSuper)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, native, kNative)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, inline_builtin,
kInlineBuiltin)
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)
// 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)
// 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)
kOptimizationDisabled,
kStrictModeFunction,
kUsesArguments,
+ kUsesSuper,
kHasDuplicateParameters,
kNative,
kInlineBuiltin,
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> {};
int parameter_count = 0;
AstProperties ast_properties;
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);
Runtime::FunctionForId(Runtime::kDefaultConstructorSuperCall), args,
pos);
body->Add(factory()->NewExpressionStatement(call, pos), zone());
+ function_scope->RecordSuperUsage();
}
materialized_literal_count = function_state.materialized_literal_count();
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);
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.