Removed IsTransitionType predicate.
With the upcoming changes to CALLBACKS properties, a predicate on the transition
type alone doesn't make sense anymore: For CALLBACKS one has to look into the
property's value to decide, and there is even the possibility of having a an
accessor function *and* a transition in the same property.
I am not completely happy with some parts of this CL, because they contain
redundant code, but given the various representations we currently have for
property type/value pairs, I can see no easy way around that. Perhaps one can
improve this a bit in a different CL, the current diversity really, really hurts
productivity...
As a bonus, this CL includes a few minor things:
* CaseClause::RecordTypeFeedback has been cleaned up and it handles the
NULL_DESCRIPTOR case correctly now. Under some (very unlikely) circumstances,
we previously missed some opportunities for monomorphic calls. In general, it
is rather unfortunate that NULL_DESCRIPTOR "shines through", it is just a
hack for the inability to remove a descriptor entry during GC, something
callers shouldn't have to be aware of.
* DescriptorArray::CopyInsert has been cleaned up a bit, preparing it for later
CALLBACKS-related changes.
* LookupResult::Print is now more informative for CONSTANT_TRANSITION.
Review URL: https://chromiumcodereview.appspot.com/9320066
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10600 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-02-03 13:37:13 +00:00
|
|
|
// Copyright 2012 the V8 project authors. All rights reserved.
|
2014-04-29 06:42:26 +00:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
#ifndef V8_PROPERTY_DETAILS_H_
|
|
|
|
#define V8_PROPERTY_DETAILS_H_
|
|
|
|
|
2014-06-03 08:12:43 +00:00
|
|
|
#include "include/v8.h"
|
|
|
|
#include "src/allocation.h"
|
|
|
|
#include "src/utils.h"
|
2011-11-08 10:43:25 +00:00
|
|
|
|
2015-12-02 16:30:06 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// ES6 6.1.7.1
|
2011-11-08 10:43:25 +00:00
|
|
|
enum PropertyAttributes {
|
2015-12-02 16:30:06 +00:00
|
|
|
NONE = ::v8::None,
|
|
|
|
READ_ONLY = ::v8::ReadOnly,
|
|
|
|
DONT_ENUM = ::v8::DontEnum,
|
|
|
|
DONT_DELETE = ::v8::DontDelete,
|
|
|
|
|
|
|
|
ALL_ATTRIBUTES_MASK = READ_ONLY | DONT_ENUM | DONT_DELETE,
|
Get rid of static module allocation, do it in code.
Modules now have their own local scope, represented by their own context.
Module instance objects have an accessor for every export that forwards
access to the respective slot from the module's context. (Exports that are
modules themselves, however, are simple data properties.)
All modules have a _hosting_ scope/context, which (currently) is the
(innermost) enclosing global scope. To deal with recursion, nested modules
are hosted by the same scope as global ones.
For every (global or nested) module literal, the hosting context has an
internal slot that points directly to the respective module context. This
enables quick access to (statically resolved) module members by 2-dimensional
access through the hosting context. For example,
module A {
let x;
module B { let y; }
}
module C { let z; }
allocates contexts as follows:
[header| .A | .B | .C | A | C ] (global)
| | |
| | +-- [header| z ] (module)
| |
| +------- [header| y ] (module)
|
+------------ [header| x | B ] (module)
Here, .A, .B, .C are the internal slots pointing to the hosted module
contexts, whereas A, B, C hold the actual instance objects (note that every
module context also points to the respective instance object through its
extension slot in the header).
To deal with arbitrary recursion and aliases between modules,
they are created and initialized in several stages. Each stage applies to
all modules in the hosting global scope, including nested ones.
1. Allocate: for each module _literal_, allocate the module contexts and
respective instance object and wire them up. This happens in the
PushModuleContext runtime function, as generated by AllocateModules
(invoked by VisitDeclarations in the hosting scope).
2. Bind: for each module _declaration_ (i.e. literals as well as aliases),
assign the respective instance object to respective local variables. This
happens in VisitModuleDeclaration, and uses the instance objects created
in the previous stage.
For each module _literal_, this phase also constructs a module descriptor
for the next stage. This happens in VisitModuleLiteral.
3. Populate: invoke the DeclareModules runtime function to populate each
_instance_ object with accessors for it exports. This is generated by
DeclareModules (invoked by VisitDeclarations in the hosting scope again),
and uses the descriptors generated in the previous stage.
4. Initialize: execute the module bodies (and other code) in sequence. This
happens by the separate statements generated for module bodies. To reenter
the module scopes properly, the parser inserted ModuleStatements.
R=mstarzinger@chromium.org,svenpanne@chromium.org
BUG=
Review URL: https://codereview.chromium.org/11093074
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-11-22 10:25:22 +00:00
|
|
|
|
2015-10-12 14:30:46 +00:00
|
|
|
SEALED = DONT_DELETE,
|
|
|
|
FROZEN = SEALED | READ_ONLY,
|
Get rid of static module allocation, do it in code.
Modules now have their own local scope, represented by their own context.
Module instance objects have an accessor for every export that forwards
access to the respective slot from the module's context. (Exports that are
modules themselves, however, are simple data properties.)
All modules have a _hosting_ scope/context, which (currently) is the
(innermost) enclosing global scope. To deal with recursion, nested modules
are hosted by the same scope as global ones.
For every (global or nested) module literal, the hosting context has an
internal slot that points directly to the respective module context. This
enables quick access to (statically resolved) module members by 2-dimensional
access through the hosting context. For example,
module A {
let x;
module B { let y; }
}
module C { let z; }
allocates contexts as follows:
[header| .A | .B | .C | A | C ] (global)
| | |
| | +-- [header| z ] (module)
| |
| +------- [header| y ] (module)
|
+------------ [header| x | B ] (module)
Here, .A, .B, .C are the internal slots pointing to the hosted module
contexts, whereas A, B, C hold the actual instance objects (note that every
module context also points to the respective instance object through its
extension slot in the header).
To deal with arbitrary recursion and aliases between modules,
they are created and initialized in several stages. Each stage applies to
all modules in the hosting global scope, including nested ones.
1. Allocate: for each module _literal_, allocate the module contexts and
respective instance object and wire them up. This happens in the
PushModuleContext runtime function, as generated by AllocateModules
(invoked by VisitDeclarations in the hosting scope).
2. Bind: for each module _declaration_ (i.e. literals as well as aliases),
assign the respective instance object to respective local variables. This
happens in VisitModuleDeclaration, and uses the instance objects created
in the previous stage.
For each module _literal_, this phase also constructs a module descriptor
for the next stage. This happens in VisitModuleLiteral.
3. Populate: invoke the DeclareModules runtime function to populate each
_instance_ object with accessors for it exports. This is generated by
DeclareModules (invoked by VisitDeclarations in the hosting scope again),
and uses the descriptors generated in the previous stage.
4. Initialize: execute the module bodies (and other code) in sequence. This
happens by the separate statements generated for module bodies. To reenter
the module scopes properly, the parser inserted ModuleStatements.
R=mstarzinger@chromium.org,svenpanne@chromium.org
BUG=
Review URL: https://codereview.chromium.org/11093074
git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13033 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
2012-11-22 10:25:22 +00:00
|
|
|
|
2015-10-12 14:30:46 +00:00
|
|
|
ABSENT = 64, // Used in runtime to indicate a property is absent.
|
2011-11-08 10:43:25 +00:00
|
|
|
// ABSENT can never be stored in or returned from a descriptor's attributes
|
|
|
|
// bitfield. It is only used as a return value meaning the attributes of
|
|
|
|
// a non-existent property.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2015-12-02 16:30:06 +00:00
|
|
|
enum PropertyFilter {
|
|
|
|
ALL_PROPERTIES = 0,
|
2015-12-09 16:59:29 +00:00
|
|
|
ONLY_WRITABLE = 1,
|
2015-12-02 16:30:06 +00:00
|
|
|
ONLY_ENUMERABLE = 2,
|
2015-12-09 16:59:29 +00:00
|
|
|
ONLY_CONFIGURABLE = 4,
|
2015-12-02 16:30:06 +00:00
|
|
|
SKIP_STRINGS = 8,
|
|
|
|
SKIP_SYMBOLS = 16,
|
|
|
|
ONLY_ALL_CAN_READ = 32,
|
|
|
|
ENUMERABLE_STRINGS = ONLY_ENUMERABLE | SKIP_SYMBOLS,
|
|
|
|
};
|
|
|
|
// Enable fast comparisons of PropertyAttributes against PropertyFilters.
|
|
|
|
STATIC_ASSERT(ALL_PROPERTIES == static_cast<PropertyFilter>(NONE));
|
2015-12-09 16:59:29 +00:00
|
|
|
STATIC_ASSERT(ONLY_WRITABLE == static_cast<PropertyFilter>(READ_ONLY));
|
2015-12-02 16:30:06 +00:00
|
|
|
STATIC_ASSERT(ONLY_ENUMERABLE == static_cast<PropertyFilter>(DONT_ENUM));
|
2015-12-09 16:59:29 +00:00
|
|
|
STATIC_ASSERT(ONLY_CONFIGURABLE == static_cast<PropertyFilter>(DONT_DELETE));
|
2015-12-02 16:30:06 +00:00
|
|
|
STATIC_ASSERT(((SKIP_STRINGS | SKIP_SYMBOLS | ONLY_ALL_CAN_READ) &
|
|
|
|
ALL_ATTRIBUTES_MASK) == 0);
|
2016-05-04 16:15:10 +00:00
|
|
|
STATIC_ASSERT(ALL_PROPERTIES ==
|
|
|
|
static_cast<PropertyFilter>(v8::PropertyFilter::ALL_PROPERTIES));
|
|
|
|
STATIC_ASSERT(ONLY_WRITABLE ==
|
|
|
|
static_cast<PropertyFilter>(v8::PropertyFilter::ONLY_WRITABLE));
|
|
|
|
STATIC_ASSERT(ONLY_ENUMERABLE ==
|
|
|
|
static_cast<PropertyFilter>(v8::PropertyFilter::ONLY_ENUMERABLE));
|
|
|
|
STATIC_ASSERT(ONLY_CONFIGURABLE == static_cast<PropertyFilter>(
|
|
|
|
v8::PropertyFilter::ONLY_CONFIGURABLE));
|
|
|
|
STATIC_ASSERT(SKIP_STRINGS ==
|
|
|
|
static_cast<PropertyFilter>(v8::PropertyFilter::SKIP_STRINGS));
|
|
|
|
STATIC_ASSERT(SKIP_SYMBOLS ==
|
|
|
|
static_cast<PropertyFilter>(v8::PropertyFilter::SKIP_SYMBOLS));
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
class Smi;
|
2013-07-05 09:26:22 +00:00
|
|
|
class TypeInfo;
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
// Type of properties.
|
2014-12-12 13:05:56 +00:00
|
|
|
// Order of kinds is significant.
|
|
|
|
// Must fit in the BitField PropertyDetails::KindField.
|
2015-01-19 17:49:13 +00:00
|
|
|
enum PropertyKind { kData = 0, kAccessor = 1 };
|
2014-12-12 13:05:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
// Order of modes is significant.
|
|
|
|
// Must fit in the BitField PropertyDetails::StoreModeField.
|
2015-01-19 17:49:13 +00:00
|
|
|
enum PropertyLocation { kField = 0, kDescriptor = 1 };
|
2014-12-12 13:05:56 +00:00
|
|
|
|
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
// Order of properties is significant.
|
|
|
|
// Must fit in the BitField PropertyDetails::TypeField.
|
2015-07-31 11:07:50 +00:00
|
|
|
// A copy of this is in debug/mirrors.js.
|
2014-12-12 13:05:56 +00:00
|
|
|
enum PropertyType {
|
2015-01-19 17:49:13 +00:00
|
|
|
DATA = (kField << 1) | kData,
|
|
|
|
DATA_CONSTANT = (kDescriptor << 1) | kData,
|
|
|
|
ACCESSOR = (kField << 1) | kAccessor,
|
|
|
|
ACCESSOR_CONSTANT = (kDescriptor << 1) | kAccessor
|
2014-12-12 13:05:56 +00:00
|
|
|
};
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
|
2013-04-26 15:30:41 +00:00
|
|
|
class Representation {
|
|
|
|
public:
|
|
|
|
enum Kind {
|
|
|
|
kNone,
|
2013-11-08 17:35:58 +00:00
|
|
|
kInteger8,
|
|
|
|
kUInteger8,
|
|
|
|
kInteger16,
|
|
|
|
kUInteger16,
|
2013-04-26 15:30:41 +00:00
|
|
|
kSmi,
|
|
|
|
kInteger32,
|
|
|
|
kDouble,
|
2013-05-10 17:17:50 +00:00
|
|
|
kHeapObject,
|
2013-04-26 15:30:41 +00:00
|
|
|
kTagged,
|
|
|
|
kExternal,
|
|
|
|
kNumRepresentations
|
|
|
|
};
|
|
|
|
|
|
|
|
Representation() : kind_(kNone) { }
|
|
|
|
|
|
|
|
static Representation None() { return Representation(kNone); }
|
|
|
|
static Representation Tagged() { return Representation(kTagged); }
|
2013-11-08 17:35:58 +00:00
|
|
|
static Representation Integer8() { return Representation(kInteger8); }
|
|
|
|
static Representation UInteger8() { return Representation(kUInteger8); }
|
|
|
|
static Representation Integer16() { return Representation(kInteger16); }
|
2014-01-10 12:19:01 +00:00
|
|
|
static Representation UInteger16() { return Representation(kUInteger16); }
|
2013-04-26 15:30:41 +00:00
|
|
|
static Representation Smi() { return Representation(kSmi); }
|
|
|
|
static Representation Integer32() { return Representation(kInteger32); }
|
|
|
|
static Representation Double() { return Representation(kDouble); }
|
2013-05-10 17:17:50 +00:00
|
|
|
static Representation HeapObject() { return Representation(kHeapObject); }
|
2013-04-26 15:30:41 +00:00
|
|
|
static Representation External() { return Representation(kExternal); }
|
|
|
|
|
|
|
|
static Representation FromKind(Kind kind) { return Representation(kind); }
|
|
|
|
|
2013-05-02 15:41:02 +00:00
|
|
|
bool Equals(const Representation& other) const {
|
2013-04-26 15:30:41 +00:00
|
|
|
return kind_ == other.kind_;
|
|
|
|
}
|
|
|
|
|
2013-05-07 10:32:23 +00:00
|
|
|
bool IsCompatibleForLoad(const Representation& other) const {
|
|
|
|
return (IsDouble() && other.IsDouble()) ||
|
|
|
|
(!IsDouble() && !other.IsDouble());
|
|
|
|
}
|
|
|
|
|
2013-06-14 14:16:03 +00:00
|
|
|
bool IsCompatibleForStore(const Representation& other) const {
|
|
|
|
return Equals(other);
|
|
|
|
}
|
|
|
|
|
2013-05-02 15:41:02 +00:00
|
|
|
bool is_more_general_than(const Representation& other) const {
|
2013-11-25 14:41:46 +00:00
|
|
|
if (kind_ == kExternal && other.kind_ == kNone) return true;
|
|
|
|
if (kind_ == kExternal && other.kind_ == kExternal) return false;
|
|
|
|
if (kind_ == kNone && other.kind_ == kExternal) return false;
|
|
|
|
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(kind_ != kExternal);
|
|
|
|
DCHECK(other.kind_ != kExternal);
|
2014-02-28 11:07:10 +00:00
|
|
|
if (IsHeapObject()) return other.IsNone();
|
2013-11-08 17:35:58 +00:00
|
|
|
if (kind_ == kUInteger8 && other.kind_ == kInteger8) return false;
|
|
|
|
if (kind_ == kUInteger16 && other.kind_ == kInteger16) return false;
|
2013-04-26 15:30:41 +00:00
|
|
|
return kind_ > other.kind_;
|
|
|
|
}
|
|
|
|
|
2013-05-02 15:41:02 +00:00
|
|
|
bool fits_into(const Representation& other) const {
|
|
|
|
return other.is_more_general_than(*this) || other.Equals(*this);
|
|
|
|
}
|
|
|
|
|
2013-04-26 15:30:41 +00:00
|
|
|
Representation generalize(Representation other) {
|
2013-05-10 17:17:50 +00:00
|
|
|
if (other.fits_into(*this)) return *this;
|
|
|
|
if (other.is_more_general_than(*this)) return other;
|
|
|
|
return Representation::Tagged();
|
2013-04-26 15:30:41 +00:00
|
|
|
}
|
|
|
|
|
2013-11-08 17:35:58 +00:00
|
|
|
int size() const {
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(!IsNone());
|
2013-11-08 17:35:58 +00:00
|
|
|
if (IsInteger8() || IsUInteger8()) {
|
|
|
|
return sizeof(uint8_t);
|
|
|
|
}
|
|
|
|
if (IsInteger16() || IsUInteger16()) {
|
|
|
|
return sizeof(uint16_t);
|
|
|
|
}
|
|
|
|
if (IsInteger32()) {
|
|
|
|
return sizeof(uint32_t);
|
|
|
|
}
|
|
|
|
return kPointerSize;
|
|
|
|
}
|
|
|
|
|
2013-04-26 15:30:41 +00:00
|
|
|
Kind kind() const { return static_cast<Kind>(kind_); }
|
|
|
|
bool IsNone() const { return kind_ == kNone; }
|
2013-11-08 17:35:58 +00:00
|
|
|
bool IsInteger8() const { return kind_ == kInteger8; }
|
|
|
|
bool IsUInteger8() const { return kind_ == kUInteger8; }
|
|
|
|
bool IsInteger16() const { return kind_ == kInteger16; }
|
|
|
|
bool IsUInteger16() const { return kind_ == kUInteger16; }
|
2013-04-26 15:30:41 +00:00
|
|
|
bool IsTagged() const { return kind_ == kTagged; }
|
|
|
|
bool IsSmi() const { return kind_ == kSmi; }
|
2013-05-23 08:32:07 +00:00
|
|
|
bool IsSmiOrTagged() const { return IsSmi() || IsTagged(); }
|
2013-04-26 15:30:41 +00:00
|
|
|
bool IsInteger32() const { return kind_ == kInteger32; }
|
2013-05-27 08:43:58 +00:00
|
|
|
bool IsSmiOrInteger32() const { return IsSmi() || IsInteger32(); }
|
2013-04-26 15:30:41 +00:00
|
|
|
bool IsDouble() const { return kind_ == kDouble; }
|
2013-05-10 17:17:50 +00:00
|
|
|
bool IsHeapObject() const { return kind_ == kHeapObject; }
|
2013-04-26 15:30:41 +00:00
|
|
|
bool IsExternal() const { return kind_ == kExternal; }
|
|
|
|
bool IsSpecialization() const {
|
2013-11-08 17:35:58 +00:00
|
|
|
return IsInteger8() || IsUInteger8() ||
|
|
|
|
IsInteger16() || IsUInteger16() ||
|
|
|
|
IsSmi() || IsInteger32() || IsDouble();
|
2013-04-26 15:30:41 +00:00
|
|
|
}
|
|
|
|
const char* Mnemonic() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
explicit Representation(Kind k) : kind_(k) { }
|
|
|
|
|
|
|
|
// Make sure kind fits in int8.
|
|
|
|
STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte));
|
|
|
|
|
|
|
|
int8_t kind_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-11-18 11:44:06 +00:00
|
|
|
static const int kDescriptorIndexBitCount = 10;
|
|
|
|
// The maximum number of descriptors we want in a descriptor array (should
|
|
|
|
// fit in a page).
|
|
|
|
static const int kMaxNumberOfDescriptors =
|
|
|
|
(1 << kDescriptorIndexBitCount) - 2;
|
|
|
|
static const int kInvalidEnumCacheSentinel =
|
|
|
|
(1 << kDescriptorIndexBitCount) - 1;
|
|
|
|
|
2015-03-17 13:27:25 +00:00
|
|
|
enum class PropertyCellType {
|
2015-04-27 14:01:15 +00:00
|
|
|
// Meaningful when a property cell does not contain the hole.
|
|
|
|
kUndefined, // The PREMONOMORPHIC of property cells.
|
|
|
|
kConstant, // Cell has been assigned only once.
|
|
|
|
kConstantType, // Cell has been assigned only one type.
|
|
|
|
kMutable, // Cell will no longer be tracked as constant.
|
|
|
|
|
|
|
|
// Meaningful when a property cell contains the hole.
|
|
|
|
kUninitialized = kUndefined, // Cell has never been initialized.
|
2016-07-07 12:32:15 +00:00
|
|
|
kInvalidated = kConstant, // Cell has been deleted, invalidated or never
|
|
|
|
// existed.
|
2015-04-27 14:01:15 +00:00
|
|
|
|
|
|
|
// For dictionaries not holding cells.
|
|
|
|
kNoCell = kMutable,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum class PropertyCellConstantType {
|
|
|
|
kSmi,
|
|
|
|
kStableMap,
|
2015-03-17 13:27:25 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
// PropertyDetails captures type and attributes for a property.
|
|
|
|
// They are used both in property dictionaries and instance descriptors.
|
|
|
|
class PropertyDetails BASE_EMBEDDED {
|
|
|
|
public:
|
2015-03-17 13:27:25 +00:00
|
|
|
PropertyDetails(PropertyAttributes attributes, PropertyType type, int index,
|
|
|
|
PropertyCellType cell_type) {
|
|
|
|
value_ = TypeField::encode(type) | AttributesField::encode(attributes) |
|
|
|
|
DictionaryStorageField::encode(index) |
|
|
|
|
PropertyCellTypeField::encode(cell_type);
|
2011-11-08 10:43:25 +00:00
|
|
|
|
2014-08-04 11:34:54 +00:00
|
|
|
DCHECK(type == this->type());
|
|
|
|
DCHECK(attributes == this->attributes());
|
2013-05-07 13:09:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDetails(PropertyAttributes attributes,
|
|
|
|
PropertyType type,
|
2013-05-31 19:11:09 +00:00
|
|
|
Representation representation,
|
|
|
|
int field_index = 0) {
|
2013-05-07 13:09:23 +00:00
|
|
|
value_ = TypeField::encode(type)
|
|
|
|
| AttributesField::encode(attributes)
|
2013-05-31 19:11:09 +00:00
|
|
|
| RepresentationField::encode(EncodeRepresentation(representation))
|
|
|
|
| FieldIndexField::encode(field_index);
|
2011-11-08 10:43:25 +00:00
|
|
|
}
|
|
|
|
|
2015-02-16 15:25:33 +00:00
|
|
|
PropertyDetails(PropertyAttributes attributes, PropertyKind kind,
|
|
|
|
PropertyLocation location, Representation representation,
|
|
|
|
int field_index = 0) {
|
|
|
|
value_ = KindField::encode(kind) | LocationField::encode(location) |
|
|
|
|
AttributesField::encode(attributes) |
|
|
|
|
RepresentationField::encode(EncodeRepresentation(representation)) |
|
|
|
|
FieldIndexField::encode(field_index);
|
|
|
|
}
|
|
|
|
|
2016-07-07 12:32:15 +00:00
|
|
|
static PropertyDetails Empty(
|
|
|
|
PropertyCellType cell_type = PropertyCellType::kNoCell) {
|
|
|
|
return PropertyDetails(NONE, DATA, 0, cell_type);
|
2015-03-17 13:27:25 +00:00
|
|
|
}
|
|
|
|
|
2014-02-18 11:30:51 +00:00
|
|
|
int pointer() const { return DescriptorPointer::decode(value_); }
|
2012-08-27 13:47:34 +00:00
|
|
|
|
2015-03-17 13:27:25 +00:00
|
|
|
PropertyDetails set_pointer(int i) const {
|
|
|
|
return PropertyDetails(value_, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDetails set_cell_type(PropertyCellType type) const {
|
|
|
|
PropertyDetails details = *this;
|
|
|
|
details.value_ = PropertyCellTypeField::update(details.value_, type);
|
|
|
|
return details;
|
|
|
|
}
|
|
|
|
|
|
|
|
PropertyDetails set_index(int index) const {
|
|
|
|
PropertyDetails details = *this;
|
|
|
|
details.value_ = DictionaryStorageField::update(details.value_, index);
|
|
|
|
return details;
|
|
|
|
}
|
2012-08-27 13:47:34 +00:00
|
|
|
|
2014-02-18 11:30:51 +00:00
|
|
|
PropertyDetails CopyWithRepresentation(Representation representation) const {
|
2013-04-26 15:30:41 +00:00
|
|
|
return PropertyDetails(value_, representation);
|
|
|
|
}
|
2015-03-17 13:27:25 +00:00
|
|
|
PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) const {
|
2013-05-23 07:05:58 +00:00
|
|
|
new_attributes =
|
|
|
|
static_cast<PropertyAttributes>(attributes() | new_attributes);
|
|
|
|
return PropertyDetails(value_, new_attributes);
|
|
|
|
}
|
2013-04-26 15:30:41 +00:00
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
// Conversion for storing details as Object*.
|
|
|
|
explicit inline PropertyDetails(Smi* smi);
|
2014-02-18 11:30:51 +00:00
|
|
|
inline Smi* AsSmi() const;
|
2011-11-08 10:43:25 +00:00
|
|
|
|
2013-04-26 15:30:41 +00:00
|
|
|
static uint8_t EncodeRepresentation(Representation representation) {
|
2013-05-07 13:09:23 +00:00
|
|
|
return representation.kind();
|
2013-04-26 15:30:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Representation DecodeRepresentation(uint32_t bits) {
|
|
|
|
return Representation::FromKind(static_cast<Representation::Kind>(bits));
|
|
|
|
}
|
|
|
|
|
2014-12-12 13:05:56 +00:00
|
|
|
PropertyKind kind() const { return KindField::decode(value_); }
|
|
|
|
PropertyLocation location() const { return LocationField::decode(value_); }
|
|
|
|
|
2014-02-18 11:30:51 +00:00
|
|
|
PropertyType type() const { return TypeField::decode(value_); }
|
2011-11-08 10:43:25 +00:00
|
|
|
|
2012-10-11 10:52:58 +00:00
|
|
|
PropertyAttributes attributes() const {
|
|
|
|
return AttributesField::decode(value_);
|
|
|
|
}
|
2011-11-08 10:43:25 +00:00
|
|
|
|
2014-02-18 11:30:51 +00:00
|
|
|
int dictionary_index() const {
|
2012-08-27 13:47:34 +00:00
|
|
|
return DictionaryStorageField::decode(value_);
|
|
|
|
}
|
|
|
|
|
2014-02-18 11:30:51 +00:00
|
|
|
Representation representation() const {
|
2013-04-26 15:30:41 +00:00
|
|
|
return DecodeRepresentation(RepresentationField::decode(value_));
|
|
|
|
}
|
|
|
|
|
2014-11-19 11:45:17 +00:00
|
|
|
int field_index() const { return FieldIndexField::decode(value_); }
|
2013-05-31 19:11:09 +00:00
|
|
|
|
2014-11-11 10:24:52 +00:00
|
|
|
inline int field_width_in_words() const;
|
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
static bool IsValidIndex(int index) {
|
2012-08-27 13:47:34 +00:00
|
|
|
return DictionaryStorageField::is_valid(index);
|
2011-11-08 10:43:25 +00:00
|
|
|
}
|
|
|
|
|
2012-10-11 10:52:58 +00:00
|
|
|
bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
|
2014-08-21 09:34:47 +00:00
|
|
|
bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
|
2012-10-11 10:52:58 +00:00
|
|
|
bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
|
2016-02-11 13:17:12 +00:00
|
|
|
bool IsEnumerable() const { return !IsDontEnum(); }
|
2015-03-17 13:27:25 +00:00
|
|
|
PropertyCellType cell_type() const {
|
|
|
|
return PropertyCellTypeField::decode(value_);
|
|
|
|
}
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
// Bit fields in value_ (type, shift, size). Must be public so the
|
|
|
|
// constants can be embedded in generated code.
|
2014-12-12 13:05:56 +00:00
|
|
|
class KindField : public BitField<PropertyKind, 0, 1> {};
|
|
|
|
class LocationField : public BitField<PropertyLocation, 1, 1> {};
|
2014-08-26 16:32:51 +00:00
|
|
|
class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
|
2015-07-27 18:45:26 +00:00
|
|
|
static const int kAttributesReadOnlyMask =
|
|
|
|
(READ_ONLY << AttributesField::kShift);
|
2013-05-31 19:11:09 +00:00
|
|
|
|
|
|
|
// Bit fields for normalized objects.
|
2015-03-17 13:27:25 +00:00
|
|
|
class PropertyCellTypeField : public BitField<PropertyCellType, 5, 2> {};
|
|
|
|
class DictionaryStorageField : public BitField<uint32_t, 7, 24> {};
|
2013-05-31 19:11:09 +00:00
|
|
|
|
|
|
|
// Bit fields for fast objects.
|
2014-08-26 16:32:51 +00:00
|
|
|
class RepresentationField : public BitField<uint32_t, 5, 4> {};
|
|
|
|
class DescriptorPointer
|
|
|
|
: public BitField<uint32_t, 9, kDescriptorIndexBitCount> {}; // NOLINT
|
|
|
|
class FieldIndexField
|
|
|
|
: public BitField<uint32_t, 9 + kDescriptorIndexBitCount,
|
|
|
|
kDescriptorIndexBitCount> {}; // NOLINT
|
2014-11-19 11:45:17 +00:00
|
|
|
|
2014-12-12 13:05:56 +00:00
|
|
|
// NOTE: TypeField overlaps with KindField and LocationField.
|
|
|
|
class TypeField : public BitField<PropertyType, 0, 2> {};
|
|
|
|
STATIC_ASSERT(KindField::kNext == LocationField::kShift);
|
|
|
|
STATIC_ASSERT(TypeField::kShift == KindField::kShift);
|
|
|
|
STATIC_ASSERT(TypeField::kNext == LocationField::kNext);
|
|
|
|
|
2014-11-19 11:45:17 +00:00
|
|
|
// All bits for both fast and slow objects must fit in a smi.
|
|
|
|
STATIC_ASSERT(DictionaryStorageField::kNext <= 31);
|
|
|
|
STATIC_ASSERT(FieldIndexField::kNext <= 31);
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
static const int kInitialIndex = 1;
|
|
|
|
|
2014-11-19 11:45:17 +00:00
|
|
|
#ifdef OBJECT_PRINT
|
|
|
|
// For our gdb macros, we should perhaps change these in the future.
|
|
|
|
void Print(bool dictionary_mode);
|
|
|
|
#endif
|
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
private:
|
2012-08-27 13:47:34 +00:00
|
|
|
PropertyDetails(int value, int pointer) {
|
2013-04-26 15:30:41 +00:00
|
|
|
value_ = DescriptorPointer::update(value, pointer);
|
|
|
|
}
|
|
|
|
PropertyDetails(int value, Representation representation) {
|
|
|
|
value_ = RepresentationField::update(
|
|
|
|
value, EncodeRepresentation(representation));
|
2012-08-27 13:47:34 +00:00
|
|
|
}
|
2013-05-23 07:05:58 +00:00
|
|
|
PropertyDetails(int value, PropertyAttributes attributes) {
|
|
|
|
value_ = AttributesField::update(value, attributes);
|
|
|
|
}
|
2012-08-27 13:47:34 +00:00
|
|
|
|
2011-11-08 10:43:25 +00:00
|
|
|
uint32_t value_;
|
|
|
|
};
|
|
|
|
|
2014-10-23 11:31:33 +00:00
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os,
|
|
|
|
const PropertyAttributes& attributes);
|
|
|
|
std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
|
2015-09-30 13:46:56 +00:00
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
2011-11-08 10:43:25 +00:00
|
|
|
|
|
|
|
#endif // V8_PROPERTY_DETAILS_H_
|