summaryrefslogtreecommitdiffstats
path: root/src/property-details.h
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2016-03-22 12:00:34 +0000
committerBen Murdoch <benm@google.com>2016-04-05 15:27:36 +0100
commit014dc512cdd3e367bee49a713fdc5ed92584a3e5 (patch)
tree742b8bb81c9998b13f6a801f8e0bec6ae9a568c1 /src/property-details.h
parent094c92c64194bd11593e915f372914dcfccf9dd2 (diff)
downloadandroid_external_v8-014dc512cdd3e367bee49a713fdc5ed92584a3e5.tar.gz
android_external_v8-014dc512cdd3e367bee49a713fdc5ed92584a3e5.tar.bz2
android_external_v8-014dc512cdd3e367bee49a713fdc5ed92584a3e5.zip
Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28 Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
Diffstat (limited to 'src/property-details.h')
-rw-r--r--src/property-details.h144
1 files changed, 107 insertions, 37 deletions
diff --git a/src/property-details.h b/src/property-details.h
index 6140e0d4..44f32cbc 100644
--- a/src/property-details.h
+++ b/src/property-details.h
@@ -9,30 +9,51 @@
#include "src/allocation.h"
#include "src/utils.h"
-// Ecma-262 3rd 8.6.1
+namespace v8 {
+namespace internal {
+
+// ES6 6.1.7.1
enum PropertyAttributes {
- NONE = v8::None,
- READ_ONLY = v8::ReadOnly,
- DONT_ENUM = v8::DontEnum,
- DONT_DELETE = v8::DontDelete,
+ NONE = ::v8::None,
+ READ_ONLY = ::v8::ReadOnly,
+ DONT_ENUM = ::v8::DontEnum,
+ DONT_DELETE = ::v8::DontDelete,
- SEALED = DONT_DELETE,
- FROZEN = SEALED | READ_ONLY,
+ ALL_ATTRIBUTES_MASK = READ_ONLY | DONT_ENUM | DONT_DELETE,
- STRING = 8, // Used to filter symbols and string names
- SYMBOLIC = 16,
- PRIVATE_SYMBOL = 32,
+ SEALED = DONT_DELETE,
+ FROZEN = SEALED | READ_ONLY,
- DONT_SHOW = DONT_ENUM | SYMBOLIC | PRIVATE_SYMBOL,
- ABSENT = 64 // Used in runtime to indicate a property is absent.
+ ABSENT = 64, // Used in runtime to indicate a property is absent.
// 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.
+
+ // When creating a property, EVAL_DECLARED used to indicate that the property
+ // came from a sloppy-mode direct eval, and certain checks need to be done.
+ // Cannot be stored in or returned from a descriptor's attributes bitfield.
+ EVAL_DECLARED = 128
};
-namespace v8 {
-namespace internal {
+enum PropertyFilter {
+ ALL_PROPERTIES = 0,
+ ONLY_WRITABLE = 1,
+ ONLY_ENUMERABLE = 2,
+ ONLY_CONFIGURABLE = 4,
+ 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));
+STATIC_ASSERT(ONLY_WRITABLE == static_cast<PropertyFilter>(READ_ONLY));
+STATIC_ASSERT(ONLY_ENUMERABLE == static_cast<PropertyFilter>(DONT_ENUM));
+STATIC_ASSERT(ONLY_CONFIGURABLE == static_cast<PropertyFilter>(DONT_DELETE));
+STATIC_ASSERT(((SKIP_STRINGS | SKIP_SYMBOLS | ONLY_ALL_CAN_READ) &
+ ALL_ATTRIBUTES_MASK) == 0);
+
class Smi;
template<class> class TypeImpl;
@@ -43,22 +64,22 @@ class TypeInfo;
// Type of properties.
// Order of kinds is significant.
// Must fit in the BitField PropertyDetails::KindField.
-enum PropertyKind { DATA = 0, ACCESSOR = 1 };
+enum PropertyKind { kData = 0, kAccessor = 1 };
// Order of modes is significant.
// Must fit in the BitField PropertyDetails::StoreModeField.
-enum PropertyLocation { IN_OBJECT = 0, IN_DESCRIPTOR = 1 };
+enum PropertyLocation { kField = 0, kDescriptor = 1 };
// Order of properties is significant.
// Must fit in the BitField PropertyDetails::TypeField.
-// A copy of this is in mirror-debugger.js.
+// A copy of this is in debug/mirrors.js.
enum PropertyType {
- FIELD = (IN_OBJECT << 1) | DATA,
- CONSTANT = (IN_DESCRIPTOR << 1) | DATA,
- ACCESSOR_FIELD = (IN_OBJECT << 1) | ACCESSOR,
- CALLBACKS = (IN_DESCRIPTOR << 1) | ACCESSOR
+ DATA = (kField << 1) | kData,
+ DATA_CONSTANT = (kDescriptor << 1) | kData,
+ ACCESSOR = (kField << 1) | kAccessor,
+ ACCESSOR_CONSTANT = (kDescriptor << 1) | kAccessor
};
@@ -95,8 +116,6 @@ class Representation {
static Representation FromKind(Kind kind) { return Representation(kind); }
- static Representation FromType(Type* type);
-
bool Equals(const Representation& other) const {
return kind_ == other.kind_;
}
@@ -187,16 +206,37 @@ static const int kInvalidEnumCacheSentinel =
(1 << kDescriptorIndexBitCount) - 1;
+enum class PropertyCellType {
+ // 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.
+ kInvalidated = kConstant, // Cell has been deleted or invalidated.
+
+ // For dictionaries not holding cells.
+ kNoCell = kMutable,
+};
+
+
+enum class PropertyCellConstantType {
+ kSmi,
+ kStableMap,
+};
+
+
// PropertyDetails captures type and attributes for a property.
// They are used both in property dictionaries and instance descriptors.
class PropertyDetails BASE_EMBEDDED {
public:
- PropertyDetails(PropertyAttributes attributes,
- PropertyType type,
- int index) {
- value_ = TypeField::encode(type)
- | AttributesField::encode(attributes)
- | DictionaryStorageField::encode(index);
+ PropertyDetails(PropertyAttributes attributes, PropertyType type, int index,
+ PropertyCellType cell_type) {
+ value_ = TypeField::encode(type) | AttributesField::encode(attributes) |
+ DictionaryStorageField::encode(index) |
+ PropertyCellTypeField::encode(cell_type);
DCHECK(type == this->type());
DCHECK(attributes == this->attributes());
@@ -212,14 +252,41 @@ class PropertyDetails BASE_EMBEDDED {
| FieldIndexField::encode(field_index);
}
+ 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);
+ }
+
+ static PropertyDetails Empty() {
+ return PropertyDetails(NONE, DATA, 0, PropertyCellType::kNoCell);
+ }
+
int pointer() const { return DescriptorPointer::decode(value_); }
- PropertyDetails set_pointer(int i) { return PropertyDetails(value_, i); }
+ 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;
+ }
PropertyDetails CopyWithRepresentation(Representation representation) const {
return PropertyDetails(value_, representation);
}
- PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) {
+ PropertyDetails CopyAddAttributes(PropertyAttributes new_attributes) const {
new_attributes =
static_cast<PropertyAttributes>(attributes() | new_attributes);
return PropertyDetails(value_, new_attributes);
@@ -258,8 +325,6 @@ class PropertyDetails BASE_EMBEDDED {
inline int field_width_in_words() const;
- inline PropertyDetails AsDeleted() const;
-
static bool IsValidIndex(int index) {
return DictionaryStorageField::is_valid(index);
}
@@ -267,17 +332,21 @@ class PropertyDetails BASE_EMBEDDED {
bool IsReadOnly() const { return (attributes() & READ_ONLY) != 0; }
bool IsConfigurable() const { return (attributes() & DONT_DELETE) == 0; }
bool IsDontEnum() const { return (attributes() & DONT_ENUM) != 0; }
- bool IsDeleted() const { return DeletedField::decode(value_) != 0; }
+ PropertyCellType cell_type() const {
+ return PropertyCellTypeField::decode(value_);
+ }
// Bit fields in value_ (type, shift, size). Must be public so the
// constants can be embedded in generated code.
class KindField : public BitField<PropertyKind, 0, 1> {};
class LocationField : public BitField<PropertyLocation, 1, 1> {};
class AttributesField : public BitField<PropertyAttributes, 2, 3> {};
+ static const int kAttributesReadOnlyMask =
+ (READ_ONLY << AttributesField::kShift);
// Bit fields for normalized objects.
- class DeletedField : public BitField<uint32_t, 5, 1> {};
- class DictionaryStorageField : public BitField<uint32_t, 6, 24> {};
+ class PropertyCellTypeField : public BitField<PropertyCellType, 5, 2> {};
+ class DictionaryStorageField : public BitField<uint32_t, 7, 24> {};
// Bit fields for fast objects.
class RepresentationField : public BitField<uint32_t, 5, 4> {};
@@ -323,6 +392,7 @@ class PropertyDetails BASE_EMBEDDED {
std::ostream& operator<<(std::ostream& os,
const PropertyAttributes& attributes);
std::ostream& operator<<(std::ostream& os, const PropertyDetails& details);
-} } // namespace v8::internal
+} // namespace internal
+} // namespace v8
#endif // V8_PROPERTY_DETAILS_H_