#ifndef V8_PROPERTY_H_
#define V8_PROPERTY_H_
-#include "src/isolate.h"
#include "src/factory.h"
#include "src/field-index.h"
#include "src/field-index-inl.h"
+#include "src/isolate.h"
#include "src/types.h"
namespace v8 {
namespace internal {
+class OStream;
+
// Abstraction for elements in instance-descriptor arrays.
//
// Each descriptor has a key, property attributes, property type,
}
}
- Handle<Name> GetKey() { return key_; }
- Handle<Object> GetValue() { return value_; }
- PropertyDetails GetDetails() { return details_; }
-
-#ifdef OBJECT_PRINT
- void Print(FILE* out);
-#endif
+ Handle<Name> GetKey() const { return key_; }
+ Handle<Object> GetValue() const { return value_; }
+ PropertyDetails GetDetails() const { return details_; }
void SetSortedKeyIndex(int index) { details_ = details_.set_pointer(index); }
};
+OStream& operator<<(OStream& os, const Descriptor& d);
+
+
class FieldDescriptor V8_FINAL : public Descriptor {
public:
FieldDescriptor(Handle<Name> key,
}
~LookupResult() {
- ASSERT(isolate()->top_lookup_result() == this);
+ DCHECK(isolate()->top_lookup_result() == this);
isolate()->set_top_lookup_result(next_);
}
return value->FitsRepresentation(representation()) &&
GetFieldType()->NowContains(value);
case CONSTANT:
- ASSERT(GetConstant() != *value ||
+ DCHECK(GetConstant() != *value ||
value->FitsRepresentation(representation()));
return GetConstant() == *value;
case CALLBACKS:
}
JSObject* holder() const {
- ASSERT(IsFound());
+ DCHECK(IsFound());
return JSObject::cast(holder_);
}
JSProxy* proxy() const {
- ASSERT(IsHandler());
+ DCHECK(IsHandler());
return JSProxy::cast(holder_);
}
PropertyType type() const {
- ASSERT(IsFound());
+ DCHECK(IsFound());
return details_.type();
}
Representation representation() const {
- ASSERT(IsFound());
- ASSERT(details_.type() != NONEXISTENT);
+ DCHECK(IsFound());
+ DCHECK(details_.type() != NONEXISTENT);
return details_.representation();
}
PropertyAttributes GetAttributes() const {
- ASSERT(IsFound());
- ASSERT(details_.type() != NONEXISTENT);
+ DCHECK(IsFound());
+ DCHECK(details_.type() != NONEXISTENT);
return details_.attributes();
}
}
bool IsFastPropertyType() const {
- ASSERT(IsFound());
+ DCHECK(IsFound());
return IsTransition() || type() != NORMAL;
}
// Property callbacks does not include transitions to callbacks.
bool IsPropertyCallbacks() const {
- ASSERT(!(details_.type() == CALLBACKS && !IsFound()));
+ DCHECK(!(details_.type() == CALLBACKS && !IsFound()));
return !IsTransition() && details_.type() == CALLBACKS;
}
bool IsReadOnly() const {
- ASSERT(IsFound());
- ASSERT(details_.type() != NONEXISTENT);
+ DCHECK(IsFound());
+ DCHECK(details_.type() != NONEXISTENT);
return details_.IsReadOnly();
}
bool IsField() const {
- ASSERT(!(details_.type() == FIELD && !IsFound()));
+ DCHECK(!(details_.type() == FIELD && !IsFound()));
return IsDescriptorOrDictionary() && type() == FIELD;
}
bool IsNormal() const {
- ASSERT(!(details_.type() == NORMAL && !IsFound()));
+ DCHECK(!(details_.type() == NORMAL && !IsFound()));
return IsDescriptorOrDictionary() && type() == NORMAL;
}
bool IsConstant() const {
- ASSERT(!(details_.type() == CONSTANT && !IsFound()));
+ DCHECK(!(details_.type() == CONSTANT && !IsFound()));
return IsDescriptorOrDictionary() && type() == CONSTANT;
}
return true;
case CALLBACKS: {
Object* callback = GetCallbackObject();
- ASSERT(!callback->IsForeign());
+ DCHECK(!callback->IsForeign());
return callback->IsAccessorInfo();
}
case HANDLER:
}
Map* GetTransitionTarget() const {
- ASSERT(IsTransition());
+ DCHECK(IsTransition());
return transition_;
}
}
int GetDescriptorIndex() const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE);
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE);
return number_;
}
FieldIndex GetFieldIndex() const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE ||
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
lookup_type_ == TRANSITION_TYPE);
return FieldIndex::ForLookupResult(this);
}
}
int GetDictionaryEntry() const {
- ASSERT(lookup_type_ == DICTIONARY_TYPE);
+ DCHECK(lookup_type_ == DICTIONARY_TYPE);
return number_;
}
JSFunction* GetConstantFunction() const {
- ASSERT(type() == CONSTANT);
+ DCHECK(type() == CONSTANT);
return JSFunction::cast(GetValue());
}
Object* GetConstantFromMap(Map* map) const {
- ASSERT(type() == CONSTANT);
+ DCHECK(type() == CONSTANT);
return GetValueFromMap(map);
}
}
Object* GetConstant() const {
- ASSERT(type() == CONSTANT);
+ DCHECK(type() == CONSTANT);
return GetValue();
}
Object* GetCallbackObject() const {
- ASSERT(!IsTransition());
- ASSERT(type() == CALLBACKS);
+ DCHECK(!IsTransition());
+ DCHECK(type() == CALLBACKS);
return GetValue();
}
-#ifdef OBJECT_PRINT
- void Print(FILE* out);
-#endif
-
Object* GetValue() const {
if (lookup_type_ == DESCRIPTOR_TYPE) {
return GetValueFromMap(holder()->map());
return GetValueFromMap(transition_);
}
// In the dictionary case, the data is held in the value field.
- ASSERT(lookup_type_ == DICTIONARY_TYPE);
+ DCHECK(lookup_type_ == DICTIONARY_TYPE);
return holder()->GetNormalizedProperty(this);
}
Object* GetValueFromMap(Map* map) const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE ||
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
lookup_type_ == TRANSITION_TYPE);
- ASSERT(number_ < map->NumberOfOwnDescriptors());
+ DCHECK(number_ < map->NumberOfOwnDescriptors());
return map->instance_descriptors()->GetValue(number_);
}
int GetFieldIndexFromMap(Map* map) const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE ||
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
lookup_type_ == TRANSITION_TYPE);
- ASSERT(number_ < map->NumberOfOwnDescriptors());
+ DCHECK(number_ < map->NumberOfOwnDescriptors());
return map->instance_descriptors()->GetFieldIndex(number_);
}
HeapType* GetFieldType() const {
- ASSERT(type() == FIELD);
+ DCHECK(type() == FIELD);
if (lookup_type_ == DESCRIPTOR_TYPE) {
return GetFieldTypeFromMap(holder()->map());
}
- ASSERT(lookup_type_ == TRANSITION_TYPE);
+ DCHECK(lookup_type_ == TRANSITION_TYPE);
return GetFieldTypeFromMap(transition_);
}
HeapType* GetFieldTypeFromMap(Map* map) const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE ||
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
lookup_type_ == TRANSITION_TYPE);
- ASSERT(number_ < map->NumberOfOwnDescriptors());
+ DCHECK(number_ < map->NumberOfOwnDescriptors());
return map->instance_descriptors()->GetFieldType(number_);
}
}
Map* GetFieldOwnerFromMap(Map* map) const {
- ASSERT(lookup_type_ == DESCRIPTOR_TYPE ||
+ DCHECK(lookup_type_ == DESCRIPTOR_TYPE ||
lookup_type_ == TRANSITION_TYPE);
- ASSERT(number_ < map->NumberOfOwnDescriptors());
+ DCHECK(number_ < map->NumberOfOwnDescriptors());
return map->FindFieldOwner(number_);
}
+ bool ReceiverIsHolder(Handle<Object> receiver) {
+ if (*receiver == holder()) return true;
+ if (lookup_type_ == TRANSITION_TYPE) return true;
+ return false;
+ }
+
void Iterate(ObjectVisitor* visitor);
private:
PropertyDetails details_;
};
+
+OStream& operator<<(OStream& os, const LookupResult& r);
} } // namespace v8::internal
#endif // V8_PROPERTY_H_