{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
if (locals_count >= 128) {
Label ok;
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
if (locals_count >= 128) {
}
FunctionKind kind() { return FunctionKindBits::decode(bitfield_); }
- bool is_arrow() {
- return IsArrowFunction(FunctionKindBits::decode(bitfield_));
- }
- bool is_generator() {
- return IsGeneratorFunction(FunctionKindBits::decode(bitfield_));
- }
- bool is_concise_method() {
- return IsConciseMethod(FunctionKindBits::decode(bitfield_));
- }
- bool is_default_constructor() {
- return IsDefaultConstructor(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, 6> {};
};
FunctionKind kind() const {
return FunctionKindBits::decode(sub_minor_key());
}
- bool is_arrow() const { return IsArrowFunction(kind()); }
- bool is_generator() const { return IsGeneratorFunction(kind()); }
- bool is_concise_method() const { return IsConciseMethod(kind()); }
- bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
private:
STATIC_ASSERT(LANGUAGE_END == 3);
class LanguageModeBits : public BitField<LanguageMode, 0, 2> {};
- class FunctionKindBits : public BitField<FunctionKind, 2, 4> {};
+ class FunctionKindBits : public BitField<FunctionKind, 2, 6> {};
DEFINE_CALL_INTERFACE_DESCRIPTOR(FastNewClosure);
DEFINE_HYDROGEN_CODE_STUB(FastNewClosure, HydrogenCodeStub);
FunctionLiteral* function = info->function();
if (FLAG_experimental_classes) return true;
if (!function->uses_super_constructor_call()) return true;
- if (function->is_default_constructor()) return true;
+ if (IsDefaultConstructor(function->kind())) return true;
ZoneList<Statement*>* body = function->body();
CHECK(body->length() > 0);
: SLOPPY_GENERATOR_FUNCTION_MAP_INDEX;
}
- if (IsArrowFunction(kind) || IsConciseMethod(kind)) {
+ if (IsArrowFunction(kind) || IsConciseMethod(kind) ||
+ IsAccessorFunction(kind)) {
return is_strict(language_mode)
? STRICT_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX
: SLOPPY_FUNCTION_WITHOUT_PROTOTYPE_MAP_INDEX;
enum FunctionKind {
kNormalFunction = 0,
- kArrowFunction = 1,
- kGeneratorFunction = 2,
- kConciseMethod = 4,
+ kArrowFunction = 1 << 0,
+ kGeneratorFunction = 1 << 1,
+ kConciseMethod = 1 << 2,
kConciseGeneratorMethod = kGeneratorFunction | kConciseMethod,
- kDefaultConstructor = 8,
- kSubclassConstructor = 16
+ kAccessorFunction = 1 << 3,
+ kDefaultConstructor = 1 << 4,
+ kSubclassConstructor = 1 << 5
};
kind == FunctionKind::kGeneratorFunction ||
kind == FunctionKind::kConciseMethod ||
kind == FunctionKind::kConciseGeneratorMethod ||
+ kind == FunctionKind::kAccessorFunction ||
kind == FunctionKind::kDefaultConstructor ||
kind == FunctionKind::kSubclassConstructor;
}
}
+inline bool IsAccessorFunction(FunctionKind kind) {
+ DCHECK(IsValidFunctionKind(kind));
+ return kind & FunctionKind::kAccessorFunction;
+}
+
+
inline bool IsDefaultConstructor(FunctionKind kind) {
DCHECK(IsValidFunctionKind(kind));
return kind & FunctionKind::kDefaultConstructor;
}
+
inline bool IsSubclassConstructor(FunctionKind kind) {
DCHECK(IsValidFunctionKind(kind));
return kind & FunctionKind::kSubclassConstructor;
bool has_no_literals() const {
return HasNoLiteralsField::decode(bit_field_);
}
- bool is_arrow() const { return IsArrowFunction(kind()); }
- bool is_generator() const { return IsGeneratorFunction(kind()); }
- bool is_concise_method() const { return IsConciseMethod(kind()); }
- bool is_default_constructor() const { return IsDefaultConstructor(kind()); }
FunctionKind kind() const { return FunctionKindField::decode(bit_field_); }
LanguageMode language_mode() const {
return LanguageModeField::decode(bit_field_);
bool IsDeletable() const OVERRIDE { return true; }
- class FunctionKindField : public BitField<FunctionKind, 0, 4> {};
- class PretenureField : public BitField<bool, 5, 1> {};
- class HasNoLiteralsField : public BitField<bool, 6, 1> {};
+ class FunctionKindField : public BitField<FunctionKind, 0, 6> {};
+ class PretenureField : public BitField<bool, 6, 1> {};
+ class HasNoLiteralsField : public BitField<bool, 7, 1> {};
STATIC_ASSERT(LANGUAGE_END == 3);
- class LanguageModeField : public BitField<LanguageMode, 7, 2> {};
+ class LanguageModeField : public BitField<LanguageMode, 8, 2> {};
Handle<SharedFunctionInfo> shared_info_;
uint32_t bit_field_;
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count == 1) {
__ push(Immediate(isolate()->factory()->undefined_value()));
} else if (locals_count > 1) {
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
if (locals_count >= 128) {
Label ok;
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
if (locals_count >= 128) {
Label ok;
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_generator, kIsGenerator)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_concise_method,
kIsConciseMethod)
+BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_accessor_function,
+ kIsAccessorFunction)
BOOL_ACCESSORS(SharedFunctionInfo, compiler_hints, is_default_constructor,
kIsDefaultConstructor)
// Indicates that this function is a concise method.
DECL_BOOLEAN_ACCESSORS(is_concise_method)
+ // Indicates that this function is an accessor (getter or setter).
+ DECL_BOOLEAN_ACCESSORS(is_accessor_function)
+
// Indicates that this function is a default constructor.
DECL_BOOLEAN_ACCESSORS(is_default_constructor)
kIsArrow,
kIsGenerator,
kIsConciseMethod,
+ kIsAccessorFunction,
kIsDefaultConstructor,
kIsSubclassConstructor,
kIsAsmFunction,
// Add hints for other modes when they're added.
STATIC_ASSERT(LANGUAGE_END == 3);
- class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 5> {};
+ class FunctionKindBits : public BitField<FunctionKind, kIsArrow, 6> {};
class DeoptCountBits : public BitField<int, 0, 4> {};
class OptReenableTriesBits : public BitField<int, 4, 18> {};
Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count > 0) {
if (locals_count >= 128) {
Label ok;
typename Traits::Type::FunctionLiteral value = this->ParseFunctionLiteral(
name, scanner()->location(),
false, // reserved words are allowed here
- FunctionKind::kNormalFunction, RelocInfo::kNoPosition,
+ FunctionKind::kAccessorFunction, RelocInfo::kNoPosition,
FunctionLiteral::ANONYMOUS_EXPRESSION,
is_get ? FunctionLiteral::GETTER_ARITY : FunctionLiteral::SETTER_ARITY,
CHECK_OK_CUSTOM(EmptyObjectLiteralProperty));
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count == 1) {
__ PushRoot(Heap::kUndefinedValueRootIndex);
} else if (locals_count > 1) {
{ Comment cmnt(masm_, "[ Allocate locals");
int locals_count = info->scope()->num_stack_slots();
// Generators allocate locals, if any, in context slots.
- DCHECK(!info->function()->is_generator() || locals_count == 0);
+ DCHECK(!IsGeneratorFunction(info->function()->kind()) || locals_count == 0);
if (locals_count == 1) {
__ push(Immediate(isolate()->factory()->undefined_value()));
} else if (locals_count > 1) {
--- /dev/null
+// Copyright 2014 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+
+(function TestGetter() {
+ var o = {
+ get x() {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.get);
+ assertFalse('prototype' in desc.get);
+
+ assertThrows(function() {
+ new desc.get();
+ }, TypeError);
+})();
+
+
+(function TestSetter() {
+ var o = {
+ set x(_) {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.set);
+ assertFalse('prototype' in desc.set);
+
+ assertThrows(function() {
+ new desc.set();
+ }, TypeError);
+})();
+
+
+(function TestBoth() {
+ var o = {
+ get x() {},
+ set x(_) {}
+ };
+ var desc = Object.getOwnPropertyDescriptor(o, 'x');
+ assertEquals('function', typeof desc.get);
+ assertEquals('function', typeof desc.set);
+ assertFalse('prototype' in desc.get);
+ assertFalse('prototype' in desc.set);
+
+ assertThrows(function() {
+ new desc.get();
+ }, TypeError);
+ assertThrows(function() {
+ new desc.set();
+ }, TypeError);
+})();
assertTrue(descr.configurable);
assertFalse(descr.enumerable);
assertEquals('function', typeof descr.get);
+ assertFalse('prototype' in descr.get);
assertEquals(undefined, descr.set);
}
assertFalse(descr.enumerable);
assertEquals(undefined, descr.get);
assertEquals('function', typeof descr.set);
+ assertFalse('prototype' in descr.set);
}
assertFalse(descr.enumerable);
assertEquals('function', typeof descr.get);
assertEquals('function', typeof descr.set);
+ assertFalse('prototype' in descr.get);
+ assertFalse('prototype' in descr.set);
}