Revision: 21916
Author: [email protected]
Date: Mon Jun 23 08:51:13 2014 UTC
Log: Make our FOO::cast methods const.
[email protected]
Review URL: https://codereview.chromium.org/347073003
http://code.google.com/p/v8/source/detail?r=21916
Modified:
/branches/bleeding_edge/src/objects-inl.h
/branches/bleeding_edge/src/objects.h
=======================================
--- /branches/bleeding_edge/src/objects-inl.h Fri Jun 20 20:36:49 2014 UTC
+++ /branches/bleeding_edge/src/objects-inl.h Mon Jun 23 08:51:13 2014 UTC
@@ -60,10 +60,17 @@
}
-#define CAST_ACCESSOR(type) \
- type* type::cast(Object* object) { \
- SLOW_ASSERT(object->Is##type()); \
- return reinterpret_cast<type*>(object); \
+// TODO(svenpanne) We use const_cast here and at a few other places to
break our
+// dependency cycle between the cast methods and the predicates. This can
be
+// removed when the predicates are const-correct, too.
+#define CAST_ACCESSOR(type) \
+ type* type::cast(Object* object) { \
+ SLOW_ASSERT(object->Is##type()); \
+ return reinterpret_cast<type*>(object); \
+ } \
+ const type* type::cast(const Object* object) { \
+ SLOW_ASSERT(const_cast<Object*>(object)->Is##type()); \
+ return reinterpret_cast<const type*>(object); \
}
@@ -819,6 +826,11 @@
HeapObject::cast(this)->map() ==
HeapObject::cast(this)->GetHeap()->hash_table_map();
}
+
+
+bool Object::IsWeakHashTable() {
+ return IsHashTable();
+}
bool Object::IsDictionary() {
@@ -827,6 +839,21 @@
}
+bool Object::IsNameDictionary() {
+ return IsDictionary();
+}
+
+
+bool Object::IsSeededNumberDictionary() {
+ return IsDictionary();
+}
+
+
+bool Object::IsUnseededNumberDictionary() {
+ return IsDictionary();
+}
+
+
bool Object::IsStringTable() {
return IsHashTable();
}
@@ -905,6 +932,16 @@
HeapObject::cast(this)->map() ==
HeapObject::cast(this)->GetHeap()->ordered_hash_table_map();
}
+
+
+bool Object::IsOrderedHashSet() {
+ return IsOrderedHashTable();
+}
+
+
+bool Object::IsOrderedHashMap() {
+ return IsOrderedHashTable();
+}
bool Object::IsPrimitive() {
@@ -2099,12 +2136,6 @@
}
#endif // ENABLE_EXTRA_CHECKS
}
-
-
-FixedArrayBase* FixedArrayBase::cast(Object* object) {
- ASSERT(object->IsFixedArrayBase());
- return reinterpret_cast<FixedArrayBase*>(object);
-}
Object* FixedArray::get(int index) {
@@ -3016,84 +3047,109 @@
// Cast operations
-CAST_ACCESSOR(FixedArray)
-CAST_ACCESSOR(FixedDoubleArray)
-CAST_ACCESSOR(FixedTypedArrayBase)
+CAST_ACCESSOR(AccessorInfo)
+CAST_ACCESSOR(ByteArray)
+CAST_ACCESSOR(Cell)
+CAST_ACCESSOR(Code)
+CAST_ACCESSOR(CodeCacheHashTable)
+CAST_ACCESSOR(CompilationCacheTable)
+CAST_ACCESSOR(ConsString)
CAST_ACCESSOR(ConstantPoolArray)
-CAST_ACCESSOR(DescriptorArray)
CAST_ACCESSOR(DeoptimizationInputData)
CAST_ACCESSOR(DeoptimizationOutputData)
CAST_ACCESSOR(DependentCode)
-CAST_ACCESSOR(StringTable)
-CAST_ACCESSOR(JSFunctionResultCache)
-CAST_ACCESSOR(NormalizedMapCache)
-CAST_ACCESSOR(ScopeInfo)
-CAST_ACCESSOR(CompilationCacheTable)
-CAST_ACCESSOR(CodeCacheHashTable)
-CAST_ACCESSOR(PolymorphicCodeCacheHashTable)
-CAST_ACCESSOR(MapCache)
-CAST_ACCESSOR(String)
-CAST_ACCESSOR(SeqString)
-CAST_ACCESSOR(SeqOneByteString)
-CAST_ACCESSOR(SeqTwoByteString)
-CAST_ACCESSOR(SlicedString)
-CAST_ACCESSOR(ConsString)
-CAST_ACCESSOR(ExternalString)
+CAST_ACCESSOR(DescriptorArray)
+CAST_ACCESSOR(ExternalArray)
CAST_ACCESSOR(ExternalAsciiString)
+CAST_ACCESSOR(ExternalFloat32Array)
+CAST_ACCESSOR(ExternalFloat64Array)
+CAST_ACCESSOR(ExternalInt16Array)
+CAST_ACCESSOR(ExternalInt32Array)
+CAST_ACCESSOR(ExternalInt8Array)
+CAST_ACCESSOR(ExternalString)
CAST_ACCESSOR(ExternalTwoByteString)
-CAST_ACCESSOR(Symbol)
-CAST_ACCESSOR(Name)
-CAST_ACCESSOR(JSReceiver)
-CAST_ACCESSOR(JSObject)
-CAST_ACCESSOR(Smi)
-CAST_ACCESSOR(HeapObject)
-CAST_ACCESSOR(HeapNumber)
-CAST_ACCESSOR(Oddball)
-CAST_ACCESSOR(Cell)
-CAST_ACCESSOR(PropertyCell)
-CAST_ACCESSOR(SharedFunctionInfo)
-CAST_ACCESSOR(Map)
-CAST_ACCESSOR(JSFunction)
+CAST_ACCESSOR(ExternalUint16Array)
+CAST_ACCESSOR(ExternalUint32Array)
+CAST_ACCESSOR(ExternalUint8Array)
+CAST_ACCESSOR(ExternalUint8ClampedArray)
+CAST_ACCESSOR(FixedArray)
+CAST_ACCESSOR(FixedArrayBase)
+CAST_ACCESSOR(FixedDoubleArray)
+CAST_ACCESSOR(FixedTypedArrayBase)
+CAST_ACCESSOR(Foreign)
+CAST_ACCESSOR(FreeSpace)
CAST_ACCESSOR(GlobalObject)
-CAST_ACCESSOR(JSGlobalProxy)
-CAST_ACCESSOR(JSGlobalObject)
-CAST_ACCESSOR(JSBuiltinsObject)
-CAST_ACCESSOR(Code)
+CAST_ACCESSOR(HeapNumber)
+CAST_ACCESSOR(HeapObject)
CAST_ACCESSOR(JSArray)
CAST_ACCESSOR(JSArrayBuffer)
CAST_ACCESSOR(JSArrayBufferView)
-CAST_ACCESSOR(JSTypedArray)
+CAST_ACCESSOR(JSBuiltinsObject)
CAST_ACCESSOR(JSDataView)
-CAST_ACCESSOR(JSRegExp)
-CAST_ACCESSOR(JSProxy)
+CAST_ACCESSOR(JSDate)
+CAST_ACCESSOR(JSFunction)
CAST_ACCESSOR(JSFunctionProxy)
-CAST_ACCESSOR(JSSet)
+CAST_ACCESSOR(JSFunctionResultCache)
+CAST_ACCESSOR(JSGeneratorObject)
+CAST_ACCESSOR(JSGlobalObject)
+CAST_ACCESSOR(JSGlobalProxy)
CAST_ACCESSOR(JSMap)
-CAST_ACCESSOR(JSSetIterator)
CAST_ACCESSOR(JSMapIterator)
+CAST_ACCESSOR(JSMessageObject)
+CAST_ACCESSOR(JSModule)
+CAST_ACCESSOR(JSObject)
+CAST_ACCESSOR(JSProxy)
+CAST_ACCESSOR(JSReceiver)
+CAST_ACCESSOR(JSRegExp)
+CAST_ACCESSOR(JSSet)
+CAST_ACCESSOR(JSSetIterator)
+CAST_ACCESSOR(JSTypedArray)
+CAST_ACCESSOR(JSValue)
CAST_ACCESSOR(JSWeakMap)
CAST_ACCESSOR(JSWeakSet)
-CAST_ACCESSOR(Foreign)
-CAST_ACCESSOR(ByteArray)
-CAST_ACCESSOR(FreeSpace)
-CAST_ACCESSOR(ExternalArray)
-CAST_ACCESSOR(ExternalInt8Array)
-CAST_ACCESSOR(ExternalUint8Array)
-CAST_ACCESSOR(ExternalInt16Array)
-CAST_ACCESSOR(ExternalUint16Array)
-CAST_ACCESSOR(ExternalInt32Array)
-CAST_ACCESSOR(ExternalUint32Array)
-CAST_ACCESSOR(ExternalFloat32Array)
-CAST_ACCESSOR(ExternalFloat64Array)
-CAST_ACCESSOR(ExternalUint8ClampedArray)
+CAST_ACCESSOR(Map)
+CAST_ACCESSOR(MapCache)
+CAST_ACCESSOR(Name)
+CAST_ACCESSOR(NameDictionary)
+CAST_ACCESSOR(NormalizedMapCache)
+CAST_ACCESSOR(Object)
+CAST_ACCESSOR(ObjectHashTable)
+CAST_ACCESSOR(Oddball)
+CAST_ACCESSOR(OrderedHashMap)
+CAST_ACCESSOR(OrderedHashSet)
+CAST_ACCESSOR(PolymorphicCodeCacheHashTable)
+CAST_ACCESSOR(PropertyCell)
+CAST_ACCESSOR(ScopeInfo)
+CAST_ACCESSOR(SeededNumberDictionary)
+CAST_ACCESSOR(SeqOneByteString)
+CAST_ACCESSOR(SeqString)
+CAST_ACCESSOR(SeqTwoByteString)
+CAST_ACCESSOR(SharedFunctionInfo)
+CAST_ACCESSOR(SlicedString)
+CAST_ACCESSOR(Smi)
+CAST_ACCESSOR(String)
+CAST_ACCESSOR(StringTable)
CAST_ACCESSOR(Struct)
-CAST_ACCESSOR(AccessorInfo)
+CAST_ACCESSOR(Symbol)
+CAST_ACCESSOR(UnseededNumberDictionary)
+CAST_ACCESSOR(WeakHashTable)
+
template <class Traits>
FixedTypedArray<Traits>* FixedTypedArray<Traits>::cast(Object* object) {
SLOW_ASSERT(object->IsHeapObject() &&
- HeapObject::cast(object)->map()->instance_type() ==
- Traits::kInstanceType);
+ HeapObject::cast(object)->map()->instance_type() ==
+ Traits::kInstanceType);
+ return reinterpret_cast<FixedTypedArray<Traits>*>(object);
+}
+
+
+template <class Traits>
+const FixedTypedArray<Traits>*
+FixedTypedArray<Traits>::cast(const Object* object) {
+ SLOW_ASSERT(const_cast<Object*>(object)->IsHeapObject() &&
+ HeapObject::cast(object)->map()->instance_type() ==
+ Traits::kInstanceType);
return reinterpret_cast<FixedTypedArray<Traits>*>(object);
}
@@ -3106,9 +3162,17 @@
template <typename Derived, typename Shape, typename Key>
HashTable<Derived, Shape, Key>*
HashTable<Derived, Shape, Key>::cast(Object* obj) {
- ASSERT(obj->IsHashTable());
+ SLOW_ASSERT(obj->IsHashTable());
return reinterpret_cast<HashTable*>(obj);
}
+
+
+template <typename Derived, typename Shape, typename Key>
+const HashTable<Derived, Shape, Key>*
+HashTable<Derived, Shape, Key>::cast(const Object* obj) {
+ SLOW_ASSERT(const_cast<Object*>(obj)->IsHashTable());
+ return reinterpret_cast<const HashTable*>(obj);
+}
SMI_ACCESSORS(FixedArrayBase, length, kLengthOffset)
@@ -5883,34 +5947,13 @@
return continuation() == kGeneratorExecuting;
}
-JSGeneratorObject* JSGeneratorObject::cast(Object* obj) {
- ASSERT(obj->IsJSGeneratorObject());
- ASSERT(HeapObject::cast(obj)->Size() == JSGeneratorObject::kSize);
- return reinterpret_cast<JSGeneratorObject*>(obj);
-}
-
-
ACCESSORS(JSModule, context, Object, kContextOffset)
ACCESSORS(JSModule, scope_info, ScopeInfo, kScopeInfoOffset)
-JSModule* JSModule::cast(Object* obj) {
- ASSERT(obj->IsJSModule());
- ASSERT(HeapObject::cast(obj)->Size() == JSModule::kSize);
- return reinterpret_cast<JSModule*>(obj);
-}
-
-
ACCESSORS(JSValue, value, Object, kValueOffset)
-JSValue* JSValue::cast(Object* obj) {
- ASSERT(obj->IsJSValue());
- ASSERT(HeapObject::cast(obj)->Size() == JSValue::kSize);
- return reinterpret_cast<JSValue*>(obj);
-}
-
-
ACCESSORS(JSDate, value, Object, kValueOffset)
ACCESSORS(JSDate, cache_stamp, Object, kCacheStampOffset)
ACCESSORS(JSDate, year, Object, kYearOffset)
@@ -5922,13 +5965,6 @@
ACCESSORS(JSDate, sec, Object, kSecOffset)
-JSDate* JSDate::cast(Object* obj) {
- ASSERT(obj->IsJSDate());
- ASSERT(HeapObject::cast(obj)->Size() == JSDate::kSize);
- return reinterpret_cast<JSDate*>(obj);
-}
-
-
ACCESSORS(JSMessageObject, type, String, kTypeOffset)
ACCESSORS(JSMessageObject, arguments, JSArray, kArgumentsOffset)
ACCESSORS(JSMessageObject, script, Object, kScriptOffset)
@@ -5937,13 +5973,6 @@
SMI_ACCESSORS(JSMessageObject, end_position, kEndPositionOffset)
-JSMessageObject* JSMessageObject::cast(Object* obj) {
- ASSERT(obj->IsJSMessageObject());
- ASSERT(HeapObject::cast(obj)->Size() == JSMessageObject::kSize);
- return reinterpret_cast<JSMessageObject*>(obj);
-}
-
-
INT_ACCESSORS(Code, instruction_size, kInstructionSizeOffset)
INT_ACCESSORS(Code, prologue_offset, kPrologueOffset)
ACCESSORS(Code, relocation_info, ByteArray, kRelocationInfoOffset)
=======================================
--- /branches/bleeding_edge/src/objects.h Fri Jun 20 23:02:36 2014 UTC
+++ /branches/bleeding_edge/src/objects.h Mon Jun 23 08:51:13 2014 UTC
@@ -854,6 +854,12 @@
inline void set_##name(type* value, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
+
+#define DECLARE_CAST(type) \
+ INLINE(static type* cast(Object* object)); \
+ INLINE(static const type* cast(const Object* object));
+
+
class AccessorPair;
class AllocationSite;
class AllocationSiteCreationContext;
@@ -1367,6 +1373,11 @@
INLINE(bool IsSpecObject());
INLINE(bool IsSpecFunction());
INLINE(bool IsTemplateInfo());
+ INLINE(bool IsNameDictionary());
+ INLINE(bool IsSeededNumberDictionary());
+ INLINE(bool IsUnseededNumberDictionary());
+ INLINE(bool IsOrderedHashSet());
+ INLINE(bool IsOrderedHashMap());
bool IsCallable();
// Oddball testing.
@@ -1544,8 +1555,7 @@
// Prints this object without details to a message accumulator.
void ShortPrint(StringStream* accumulator);
- // Casting: This cast is only needed to satisfy macros in objects-inl.h.
- static Object* cast(Object* value) { return value; }
+ DECLARE_CAST(Object)
// Layout description.
static const int kHeaderSize = 0; // Object does not take up any space.
@@ -1582,8 +1592,7 @@
// Returns whether value can be represented in a Smi.
static inline bool IsValid(intptr_t value);
- // Casting.
- static inline Smi* cast(Object* object);
+ DECLARE_CAST(Smi)
// Dispatched behavior.
void SmiPrint(FILE* out = stdout);
@@ -1716,8 +1725,7 @@
Handle<Name> name,
Handle<Code> code);
- // Casting.
- static inline HeapObject* cast(Object* obj);
+ DECLARE_CAST(HeapObject)
// Return the write barrier mode for this. Callers of this function
// must be able to present a reference to an DisallowHeapAllocation
@@ -1812,8 +1820,7 @@
inline double value();
inline void set_value(double value);
- // Casting.
- static inline HeapNumber* cast(Object* obj);
+ DECLARE_CAST(HeapNumber)
// Dispatched behavior.
bool HeapNumberBooleanValue();
@@ -1907,8 +1914,7 @@
OMIT_EXTENSIBILITY_CHECK
};
- // Casting.
- static inline JSReceiver* cast(Object* obj);
+ DECLARE_CAST(JSReceiver)
// Implementation of [[Put]], ECMA-262 5th edition, section 8.12.5.
MUST_USE_RESULT static MaybeHandle<Object> SetProperty(
@@ -2522,8 +2528,7 @@
static Handle<Object> GetDataProperty(Handle<JSObject> object,
Handle<Name> key);
- // Casting.
- static inline JSObject* cast(Object* obj);
+ DECLARE_CAST(JSObject)
// Dispatched behavior.
void JSObjectShortPrint(StringStream* accumulator);
@@ -2873,7 +2878,7 @@
inline int synchronized_length() const;
inline void synchronized_set_length(int value);
- inline static FixedArrayBase* cast(Object* object);
+ DECLARE_CAST(FixedArrayBase)
// Layout description.
// Length is smi tagged when it is stored.
@@ -2947,8 +2952,7 @@
return HeapObject::RawField(this, OffsetOfElementAt(index));
}
- // Casting.
- static inline FixedArray* cast(Object* obj);
+ DECLARE_CAST(FixedArray)
// Maximal allowed size, in bytes, of a single FixedArray.
// Prevents overflowing size computations, as well as extreme memory
@@ -3033,8 +3037,7 @@
inline static double hole_nan_as_double();
inline static double canonical_not_the_hole_nan_as_double();
- // Casting.
- static inline FixedDoubleArray* cast(Object* obj);
+ DECLARE_CAST(FixedDoubleArray)
// Maximal allowed size, in bytes, of a single FixedDoubleArray.
// Prevents overflowing size computations, as well as extreme memory
@@ -3285,8 +3288,7 @@
return offset;
}
- // Casting.
- static inline ConstantPoolArray* cast(Object* obj);
+ DECLARE_CAST(ConstantPoolArray)
// Garbage collection support.
Object** RawFieldOfElementAt(int index) {
@@ -3479,8 +3481,7 @@
int number_of_descriptors,
int slack = 0);
- // Casting.
- static inline DescriptorArray* cast(Object* obj);
+ DECLARE_CAST(DescriptorArray)
// Constant for denoting key was not found.
static const int kNotFound = -1;
@@ -3733,8 +3734,7 @@
void IteratePrefix(ObjectVisitor* visitor);
void IterateElements(ObjectVisitor* visitor);
- // Casting.
- static inline HashTable* cast(Object* obj);
+ DECLARE_CAST(HashTable)
// Compute the probe offset (quadratic probing).
INLINE(static uint32_t GetProbeOffset(uint32_t n)) {
@@ -3907,8 +3907,7 @@
uint16_t c1,
uint16_t c2);
- // Casting.
- static inline StringTable* cast(Object* obj);
+ DECLARE_CAST(StringTable)
private:
template <bool seq_ascii> friend class JsonParser;
@@ -3948,7 +3947,7 @@
Object* Lookup(FixedArray* key);
static Handle<MapCache> Put(
Handle<MapCache> map_cache, Handle<FixedArray> key, Handle<Map>
value);
- static inline MapCache* cast(Object* obj);
+ DECLARE_CAST(MapCache)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache);
@@ -3961,10 +3960,6 @@
typedef HashTable<Derived, Shape, Key> DerivedHashTable;
public:
- static inline Dictionary* cast(Object* obj) {
- return reinterpret_cast<Dictionary*>(obj);
- }
-
// Returns the value at entry.
Object* ValueAt(int entry) {
return this->get(DerivedHashTable::EntryToIndex(entry) + 1);
@@ -4102,10 +4097,7 @@
NameDictionary, NameDictionaryShape, Handle<Name> >
DerivedDictionary;
public:
- static inline NameDictionary* cast(Object* obj) {
- ASSERT(obj->IsDictionary());
- return reinterpret_cast<NameDictionary*>(obj);
- }
+ DECLARE_CAST(NameDictionary)
// Copies enumerable keys to preallocated fixed array.
void CopyEnumKeysTo(FixedArray* storage);
@@ -4153,10 +4145,7 @@
SeededNumberDictionaryShape,
uint32_t> {
public:
- static SeededNumberDictionary* cast(Object* obj) {
- ASSERT(obj->IsDictionary());
- return reinterpret_cast<SeededNumberDictionary*>(obj);
- }
+ DECLARE_CAST(SeededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding).
MUST_USE_RESULT static Handle<SeededNumberDictionary> AtNumberPut(
@@ -4204,10 +4193,7 @@
UnseededNumberDictionaryShape,
uint32_t> {
public:
- static UnseededNumberDictionary* cast(Object* obj) {
- ASSERT(obj->IsDictionary());
- return reinterpret_cast<UnseededNumberDictionary*>(obj);
- }
+ DECLARE_CAST(UnseededNumberDictionary)
// Type specific at put (default NONE attributes is used when adding).
MUST_USE_RESULT static Handle<UnseededNumberDictionary> AtNumberPut(
@@ -4247,10 +4233,7 @@
typedef HashTable<
ObjectHashTable, ObjectHashTableShape, Handle<Object> >
DerivedHashTable;
public:
- static inline ObjectHashTable* cast(Object* obj) {
- ASSERT(obj->IsHashTable());
- return reinterpret_cast<ObjectHashTable*>(obj);
- }
+ DECLARE_CAST(ObjectHashTable)
// Attempt to shrink hash table after removal of key.
MUST_USE_RESULT static inline Handle<ObjectHashTable> Shrink(
@@ -4459,10 +4442,7 @@
class OrderedHashSet: public OrderedHashTable<
OrderedHashSet, JSSetIterator, 1> {
public:
- static OrderedHashSet* cast(Object* obj) {
- ASSERT(obj->IsOrderedHashTable());
- return reinterpret_cast<OrderedHashSet*>(obj);
- }
+ DECLARE_CAST(OrderedHashSet)
bool Contains(Handle<Object> key);
static Handle<OrderedHashSet> Add(
@@ -4476,10 +4456,7 @@
class OrderedHashMap:public OrderedHashTable<
OrderedHashMap, JSMapIterator, 2> {
public:
- static OrderedHashMap* cast(Object* obj) {
- ASSERT(obj->IsOrderedHashTable());
- return reinterpret_cast<OrderedHashMap*>(obj);
- }
+ DECLARE_CAST(OrderedHashMap)
Object* Lookup(Handle<Object> key);
static Handle<OrderedHashMap> Put(
@@ -4517,10 +4494,7 @@
typedef HashTable<
WeakHashTable, WeakHashTableShape<2>, Handle<Object> >
DerivedHashTable;
public:
- static inline WeakHashTable* cast(Object* obj) {
- ASSERT(obj->IsHashTable());
- return reinterpret_cast<WeakHashTable*>(obj);
- }
+ DECLARE_CAST(WeakHashTable)
// Looks up the value associated with the given key. The hole value is
// returned in case the key is not present.
@@ -4582,8 +4556,7 @@
inline int finger_index();
inline void set_finger_index(int finger_index);
- // Casting
- static inline JSFunctionResultCache* cast(Object* obj);
+ DECLARE_CAST(JSFunctionResultCache)
DECLARE_VERIFIER(JSFunctionResultCache)
};
@@ -4598,7 +4571,7 @@
// routines.
class ScopeInfo : public FixedArray {
public:
- static inline ScopeInfo* cast(Object* object);
+ DECLARE_CAST(ScopeInfo)
// Return the type of this scope.
ScopeType scope_type();
@@ -4813,8 +4786,8 @@
void Clear();
- // Casting
- static inline NormalizedMapCache* cast(Object* obj);
+ DECLARE_CAST(NormalizedMapCache)
+
static inline bool IsNormalizedMapCache(Object* obj);
DECLARE_VERIFIER(NormalizedMapCache)
@@ -4861,8 +4834,7 @@
// Returns a pointer to the ByteArray object for a given data start
address.
static inline ByteArray* FromDataStartAddress(Address address);
- // Casting.
- static inline ByteArray* cast(Object* obj);
+ DECLARE_CAST(ByteArray)
// Dispatched behavior.
inline int ByteArraySize() {
@@ -4897,8 +4869,7 @@
inline int Size() { return size(); }
- // Casting.
- static inline FreeSpace* cast(Object* obj);
+ DECLARE_CAST(FreeSpace)
// Dispatched behavior.
DECLARE_PRINTER(FreeSpace)
@@ -4949,8 +4920,7 @@
// external array.
DECL_ACCESSORS(external_pointer, void) // Pointer to the data store.
- // Casting.
- static inline ExternalArray* cast(Object* obj);
+ DECLARE_CAST(ExternalArray)
// Maximal acceptable length for an external array.
static const int kMaxLength = 0x3fffffff;
@@ -4990,8 +4960,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalUint8ClampedArray* cast(Object* obj);
+ DECLARE_CAST(ExternalUint8ClampedArray)
// Dispatched behavior.
DECLARE_PRINTER(ExternalUint8ClampedArray)
@@ -5015,8 +4984,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalInt8Array* cast(Object* obj);
+ DECLARE_CAST(ExternalInt8Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalInt8Array)
@@ -5040,8 +5008,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalUint8Array* cast(Object* obj);
+ DECLARE_CAST(ExternalUint8Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalUint8Array)
@@ -5065,8 +5032,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalInt16Array* cast(Object* obj);
+ DECLARE_CAST(ExternalInt16Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalInt16Array)
@@ -5091,8 +5057,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalUint16Array* cast(Object* obj);
+ DECLARE_CAST(ExternalUint16Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalUint16Array)
@@ -5116,8 +5081,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalInt32Array* cast(Object* obj);
+ DECLARE_CAST(ExternalInt32Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalInt32Array)
@@ -5142,8 +5106,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalUint32Array* cast(Object* obj);
+ DECLARE_CAST(ExternalUint32Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalUint32Array)
@@ -5168,8 +5131,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalFloat32Array* cast(Object* obj);
+ DECLARE_CAST(ExternalFloat32Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalFloat32Array)
@@ -5194,8 +5156,7 @@
uint32_t index,
Handle<Object> value);
- // Casting.
- static inline ExternalFloat64Array* cast(Object* obj);
+ DECLARE_CAST(ExternalFloat64Array)
// Dispatched behavior.
DECLARE_PRINTER(ExternalFloat64Array)
@@ -5208,8 +5169,7 @@
class FixedTypedArrayBase: public FixedArrayBase {
public:
- // Casting:
- static inline FixedTypedArrayBase* cast(Object* obj);
+ DECLARE_CAST(FixedTypedArrayBase)
static const int kDataOffset = kHeaderSize;
@@ -5235,8 +5195,7 @@
typedef typename Traits::ElementType ElementType;
static const InstanceType kInstanceType = Traits::kInstanceType;
- // Casting:
- static inline FixedTypedArray<Traits>* cast(Object* obj);
+ DECLARE_CAST(FixedTypedArray<Traits>)
static inline int ElementOffset(int index) {
return kDataOffset + index * sizeof(ElementType);
@@ -5361,8 +5320,7 @@
int deopt_entry_count,
PretenureFlag pretenure);
- // Casting.
- static inline DeoptimizationInputData* cast(Object* obj);
+ DECLARE_CAST(DeoptimizationInputData)
#ifdef ENABLE_DISASSEMBLER
void DeoptimizationInputDataPrint(FILE* out);
@@ -5408,8 +5366,7 @@
int number_of_deopt_points,
PretenureFlag pretenure);
- // Casting.
- static inline DeoptimizationOutputData* cast(Object* obj);
+ DECLARE_CAST(DeoptimizationOutputData)
#if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER)
void DeoptimizationOutputDataPrint(FILE* out);
@@ -5766,8 +5723,7 @@
int SourcePosition(Address pc);
int SourceStatementPosition(Address pc);
- // Casting.
- static inline Code* cast(Object* obj);
+ DECLARE_CAST(Code)
// Dispatched behavior.
int CodeSize() { return SizeFor(body_size()); }
@@ -6084,7 +6040,7 @@
inline Object* object_at(int i);
inline void clear_at(int i);
inline void copy(int from, int to);
- static inline DependentCode* cast(Object* object);
+ DECLARE_CAST(DependentCode)
static DependentCode* ForObject(Handle<HeapObject> object,
DependencyGroup group);
@@ -6549,8 +6505,7 @@
inobject_properties();
}
- // Casting.
- static inline Map* cast(Object* obj);
+ DECLARE_CAST(Map)
// Code cache operations.
@@ -6842,7 +6797,7 @@
class Struct: public HeapObject {
public:
inline void InitializeBody(int object_size);
- static inline Struct* cast(Object* that);
+ DECLARE_CAST(Struct)
};
@@ -6852,7 +6807,7 @@
// [value]: the boxed contents.
DECL_ACCESSORS(value, Object)
- static inline Box* cast(Object* obj);
+ DECLARE_CAST(Box)
// Dispatched behavior.
DECLARE_PRINTER(Box)
@@ -6943,7 +6898,7 @@
// the 'flags' field.
DECL_BOOLEAN_ACCESSORS(is_shared_cross_origin)
- static inline Script* cast(Object* obj);
+ DECLARE_CAST(Script)
// If script source is an external string, check that the underlying
// resource is accessible. Otherwise, always return true.
@@ -7351,8 +7306,7 @@
void ResetForNewContext(int new_ic_age);
- // Casting.
- static inline SharedFunctionInfo* cast(Object* obj);
+ DECLARE_CAST(SharedFunctionInfo)
// Constants.
static const int kDontAdaptArgumentsSentinel = -1;
@@ -7564,8 +7518,7 @@
inline int stack_handler_index() const;
inline void set_stack_handler_index(int stack_handler_index);
- // Casting.
- static inline JSGeneratorObject* cast(Object* obj);
+ DECLARE_CAST(JSGeneratorObject)
// Dispatched behavior.
DECLARE_PRINTER(JSGeneratorObject)
@@ -7613,8 +7566,7 @@
// [scope_info]: Scope info.
DECL_ACCESSORS(scope_info, ScopeInfo)
- // Casting.
- static inline JSModule* cast(Object* obj);
+ DECLARE_CAST(JSModule)
// Dispatched behavior.
DECLARE_PRINTER(JSModule)
@@ -7799,8 +7751,7 @@
// Prints the name of the function using PrintF.
void PrintName(FILE* out = stdout);
- // Casting.
- static inline JSFunction* cast(Object* obj);
+ DECLARE_CAST(JSFunction)
// Iterates the objects, including code objects indirectly referenced
// through pointers to the first instruction in the code object.
@@ -7863,8 +7814,7 @@
// [hash]: The hash code property (undefined if not initialized yet).
DECL_ACCESSORS(hash, Object)
- // Casting.
- static inline JSGlobalProxy* cast(Object* obj);
+ DECLARE_CAST(JSGlobalProxy)
inline bool IsDetachedFrom(GlobalObject* global);
@@ -7904,8 +7854,7 @@
// Retrieve the property cell used to store a property.
PropertyCell* GetPropertyCell(LookupResult* result);
- // Casting.
- static inline GlobalObject* cast(Object* obj);
+ DECLARE_CAST(GlobalObject)
// Layout description.
static const int kBuiltinsOffset = JSObject::kHeaderSize;
@@ -7922,8 +7871,7 @@
// JavaScript global object.
class JSGlobalObject: public GlobalObject {
public:
- // Casting.
- static inline JSGlobalObject* cast(Object* obj);
+ DECLARE_CAST(JSGlobalObject)
// Ensure that the global object has a cell for the given property name.
static Handle<PropertyCell> EnsurePropertyCell(Handle<JSGlobalObject>
global,
@@ -7955,8 +7903,7 @@
inline Code* javascript_builtin_code(Builtins::JavaScript id);
inline void set_javascript_builtin_code(Builtins::JavaScript id, Code*
value);
- // Casting.
- static inline JSBuiltinsObject* cast(Object* obj);
+ DECLARE_CAST(JSBuiltinsObject)
// Dispatched behavior.
DECLARE_PRINTER(JSBuiltinsObject)
@@ -7991,8 +7938,7 @@
// [value]: the object being wrapped.
DECL_ACCESSORS(value, Object)
- // Casting.
- static inline JSValue* cast(Object* obj);
+ DECLARE_CAST(JSValue)
// Dispatched behavior.
DECLARE_PRINTER(JSValue)
@@ -8033,8 +7979,7 @@
// moment when chached fields were cached.
DECL_ACCESSORS(cache_stamp, Object)
- // Casting.
- static inline JSDate* cast(Object* obj);
+ DECLARE_CAST(JSDate)
// Returns the date field with the specified index.
// See FieldIndex for the list of date fields.
@@ -8129,8 +8074,7 @@
inline int end_position() const;
inline void set_end_position(int value);
- // Casting.
- static inline JSMessageObject* cast(Object* obj);
+ DECLARE_CAST(JSMessageObject)
// Dispatched behavior.
DECLARE_PRINTER(JSMessageObject)
@@ -8214,7 +8158,7 @@
}
}
- static inline JSRegExp* cast(Object* obj);
+ DECLARE_CAST(JSRegExp)
// Dispatched behavior.
DECLARE_VERIFIER(JSRegExp)
@@ -8332,7 +8276,7 @@
JSRegExp::Flags flags, Handle<FixedArray> value);
void Remove(Object* value);
- static inline CompilationCacheTable* cast(Object* obj);
+ DECLARE_CAST(CompilationCacheTable)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
@@ -8361,7 +8305,7 @@
// Remove an object from the cache with the provided internal index.
void RemoveByIndex(Object* name, Code* code, int index);
- static inline CodeCache* cast(Object* obj);
+ DECLARE_CAST(CodeCache)
// Dispatched behavior.
DECLARE_PRINTER(CodeCache)
@@ -8424,7 +8368,7 @@
int GetIndex(Name* name, Code::Flags flags);
void RemoveByIndex(int index);
- static inline CodeCacheHashTable* cast(Object* obj);
+ DECLARE_CAST(CodeCacheHashTable)
// Initial size of the fixed array backing the hash table.
static const int kInitialSize = 64;
@@ -8447,7 +8391,7 @@
// Returns an undefined value if the entry is not found.
Handle<Object> Lookup(MapHandleList* maps, Code::Flags flags);
- static inline PolymorphicCodeCache* cast(Object* obj);
+ DECLARE_CAST(PolymorphicCodeCache)
// Dispatched behavior.
DECLARE_PRINTER(PolymorphicCodeCache)
@@ -8474,7 +8418,7 @@
int code_kind,
Handle<Code> code);
- static inline PolymorphicCodeCacheHashTable* cast(Object* obj);
+ DECLARE_CAST(PolymorphicCodeCacheHashTable)
static const int kInitialSize = 64;
private:
@@ -8499,7 +8443,7 @@
inline bool matches_inlined_type_change_checksum(int checksum);
- static inline TypeFeedbackInfo* cast(Object* obj);
+ DECLARE_CAST(TypeFeedbackInfo)
// Dispatched behavior.
DECLARE_PRINTER(TypeFeedbackInfo)
@@ -8708,7 +8652,7 @@
DECLARE_PRINTER(AllocationSite)
DECLARE_VERIFIER(AllocationSite)
- static inline AllocationSite* cast(Object* obj);
+ DECLARE_CAST(AllocationSite)
static inline AllocationSiteMode GetMode(
ElementsKind boilerplate_elements_kind);
static inline AllocationSiteMode GetMode(ElementsKind from, ElementsKind
to);
@@ -8763,7 +8707,7 @@
DECLARE_PRINTER(AllocationMemento)
DECLARE_VERIFIER(AllocationMemento)
- static inline AllocationMemento* cast(Object* obj);
+ DECLARE_CAST(AllocationMemento)
private:
DISALLOW_IMPLICIT_CONSTRUCTORS(AllocationMemento);
@@ -8783,7 +8727,7 @@
inline int aliased_context_slot() const;
inline void set_aliased_context_slot(int count);
- static inline AliasedArgumentsEntry* cast(Object* obj);
+ DECLARE_CAST(AliasedArgumentsEntry)
// Dispatched behavior.
DECLARE_PRINTER(AliasedArgumentsEntry)
@@ -8925,8 +8869,7 @@
// Conversion.
inline bool AsArrayIndex(uint32_t* index);
- // Casting.
- static inline Name* cast(Object* obj);
+ DECLARE_CAST(Name)
DECLARE_PRINTER(Name)
@@ -9000,8 +8943,7 @@
// [is_private]: whether this is a private symbol.
DECL_BOOLEAN_ACCESSORS(is_private)
- // Casting.
- static inline Symbol* cast(Object* obj);
+ DECLARE_CAST(Symbol)
// Dispatched behavior.
DECLARE_PRINTER(Symbol)
@@ -9222,8 +9164,7 @@
// Conversion.
inline bool AsArrayIndex(uint32_t* index);
- // Casting.
- static inline String* cast(Object* obj);
+ DECLARE_CAST(String)
void PrintOn(FILE* out);
@@ -9359,8 +9300,7 @@
// The SeqString abstract class captures sequential string values.
class SeqString: public String {
public:
- // Casting.
- static inline SeqString* cast(Object* obj);
+ DECLARE_CAST(SeqString)
// Layout description.
static const int kHeaderSize = String::kSize;
@@ -9390,8 +9330,7 @@
inline uint8_t* GetChars();
- // Casting
- static inline SeqOneByteString* cast(Object* obj);
+ DECLARE_CAST(SeqOneByteString)
// Garbage collection support. This method is called by the
// garbage collector to compute the actual size of an AsciiString
@@ -9430,8 +9369,7 @@
// For regexp code.
const uint16_t* SeqTwoByteStringGetData(unsigned start);
- // Casting
- static inline SeqTwoByteString* cast(Object* obj);
+ DECLARE_CAST(SeqTwoByteString)
// Garbage collection support. This method is called by the
// garbage collector to compute the actual size of a TwoByteString
@@ -9482,8 +9420,7 @@
// Dispatched behavior.
uint16_t ConsStringGet(int index);
- // Casting.
- static inline ConsString* cast(Object* obj);
+ DECLARE_CAST(ConsString)
// Layout description.
static const int kFirstOffset = POINTER_SIZE_ALIGN(String::kSize);
@@ -9526,8 +9463,7 @@
// Dispatched behavior.
uint16_t SlicedStringGet(int index);
- // Casting.
- static inline SlicedString* cast(Object* obj);
+ DECLARE_CAST(SlicedString)
// Layout description.
static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize);
@@ -9559,8 +9495,7 @@
// API. Therefore, ExternalStrings should not be used internally.
class ExternalString: public String {
public:
- // Casting
- static inline ExternalString* cast(Object* obj);
+ DECLARE_CAST(ExternalString)
// Layout description.
static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
@@ -9604,8 +9539,7 @@
// Dispatched behavior.
inline uint16_t ExternalAsciiStringGet(int index);
- // Casting.
- static inline ExternalAsciiString* cast(Object* obj);
+ DECLARE_CAST(ExternalAsciiString)
// Garbage collection support.
inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
@@ -9644,8 +9578,7 @@
// For regexp code.
inline const uint16_t* ExternalTwoByteStringGetData(unsigned start);
- // Casting.
- static inline ExternalTwoByteString* cast(Object* obj);
+ DECLARE_CAST(ExternalTwoByteString)
// Garbage collection support.
inline void ExternalTwoByteStringIterateBody(ObjectVisitor* v);
@@ -9810,8 +9743,7 @@
inline byte kind();
inline void set_kind(byte kind);
- // Casting.
- static inline Oddball* cast(Object* obj);
+ DECLARE_CAST(Oddball)
// Dispatched behavior.
DECLARE_VERIFIER(Oddball)
@@ -9858,8 +9790,7 @@
// [value]: value of the global property.
DECL_ACCESSORS(value, Object)
- // Casting.
- static inline Cell* cast(Object* obj);
+ DECLARE_CAST(Cell)
static inline Cell* FromValueAddress(Address value) {
Object* result = FromAddress(value - kValueOffset);
@@ -9913,8 +9844,7 @@
static void AddDependentCompilationInfo(Handle<PropertyCell> cell,
CompilationInfo* info);
- // Casting.
- static inline PropertyCell* cast(Object* obj);
+ DECLARE_CAST(PropertyCell)
inline Address TypeAddress() {
return address() + kTypeOffset;
@@ -9951,8 +9881,7 @@
// [hash]: The hash code property (undefined if not initialized yet).
DECL_ACCESSORS(hash, Object)
- // Casting.
- static inline JSProxy* cast(Object* obj);
+ DECLARE_CAST(JSProxy)
MUST_USE_RESULT static MaybeHandle<Object> GetPropertyWithHandler(
Handle<JSProxy> proxy,
@@ -10067,8 +9996,7 @@
// [construct_trap]: The construct trap.
DECL_ACCESSORS(construct_trap, Object)
- // Casting.
- static inline JSFunctionProxy* cast(Object* obj);
+ DECLARE_CAST(JSFunctionProxy)
// Dispatched behavior.
DECLARE_PRINTER(JSFunctionProxy)
@@ -10098,8 +10026,7 @@
// [set]: the backing hash set containing keys.
DECL_ACCESSORS(table, Object)
- // Casting.
- static inline JSSet* cast(Object* obj);
+ DECLARE_CAST(JSSet)
// Dispatched behavior.
DECLARE_PRINTER(JSSet)
@@ -10119,8 +10046,7 @@
// [table]: the backing hash table mapping keys to values.
DECL_ACCESSORS(table, Object)
- // Casting.
- static inline JSMap* cast(Object* obj);
+ DECLARE_CAST(JSMap)
// Dispatched behavior.
DECLARE_PRINTER(JSMap)
@@ -10194,8 +10120,7 @@
DECLARE_PRINTER(JSSetIterator)
DECLARE_VERIFIER(JSSetIterator)
- // Casting.
- static inline JSSetIterator* cast(Object* obj);
+ DECLARE_CAST(JSSetIterator)
static Handle<Object> ValueForKind(
Handle<JSSetIterator> iterator,
@@ -10213,8 +10138,7 @@
DECLARE_PRINTER(JSMapIterator)
DECLARE_VERIFIER(JSMapIterator)
- // Casting.
- static inline JSMapIterator* cast(Object* obj);
+ DECLARE_CAST(JSMapIterator)
static Handle<Object> ValueForKind(
Handle<JSMapIterator> iterator,
@@ -10246,8 +10170,7 @@
// The JSWeakMap describes EcmaScript Harmony weak maps
class JSWeakMap: public JSWeakCollection {
public:
- // Casting.
- static inline JSWeakMap* cast(Object* obj);
+ DECLARE_CAST(JSWeakMap)
// Dispatched behavior.
DECLARE_PRINTER(JSWeakMap)
@@ -10261,8 +10184,7 @@
// The JSWeakSet describes EcmaScript Harmony weak sets
class JSWeakSet: public JSWeakCollection {
public:
- // Casting.
- static inline JSWeakSet* cast(Object* obj);
+ DECLARE_CAST(JSWeakSet)
// Dispatched behavior.
DECLARE_PRINTER(JSWeakSet)
@@ -10296,8 +10218,7 @@
// [weak_first_array]: weak linked list of views.
DECL_ACCESSORS(weak_first_view, Object)
- // Casting.
- static inline JSArrayBuffer* cast(Object* obj);
+ DECLARE_CAST(JSArrayBuffer)
// Neutering. Only neuters the buffer, not associated typed arrays.
void Neuter();
@@ -10339,8 +10260,7 @@
// [weak_next]: linked list of typed arrays over the same array buffer.
DECL_ACCESSORS(weak_next, Object)
- // Casting.
- static inline JSArrayBufferView* cast(Object* obj);
+ DECLARE_CAST(JSArrayBufferView)
DECLARE_VERIFIER(JSArrayBufferView)
@@ -10366,8 +10286,7 @@
// Neutering. Only neuters this typed array.
void Neuter();
- // Casting.
- static inline JSTypedArray* cast(Object* obj);
+ DECLARE_CAST(JSTypedArray)
ExternalArrayType type();
size_t element_size();
@@ -10397,8 +10316,7 @@
// Only neuters this DataView
void Neuter();
- // Casting.
- static inline JSDataView* cast(Object* obj);
+ DECLARE_CAST(JSDataView)
// Dispatched behavior.
DECLARE_PRINTER(JSDataView)
@@ -10423,8 +10341,7 @@
inline Address foreign_address();
inline void set_foreign_address(Address value);
- // Casting.
- static inline Foreign* cast(Object* obj);
+ DECLARE_CAST(Foreign)
// Dispatched behavior.
inline void ForeignIterateBody(ObjectVisitor* v);
@@ -10486,8 +10403,7 @@
static inline void SetContent(Handle<JSArray> array,
Handle<FixedArrayBase> storage);
- // Casting.
- static inline JSArray* cast(Object* obj);
+ DECLARE_CAST(JSArray)
// Ensures that the fixed array backing the JSArray has at
// least the stated size.
@@ -10557,7 +10473,7 @@
// Checks whether the given receiver is compatible with this accessor.
inline bool IsCompatibleReceiver(Object* receiver);
- static inline AccessorInfo* cast(Object* obj);
+ DECLARE_CAST(AccessorInfo)
// Dispatched behavior.
DECLARE_VERIFIER(AccessorInfo)
@@ -10655,7 +10571,7 @@
public:
DECL_ACCESSORS(serialized_data, ByteArray)
- static inline DeclaredAccessorDescriptor* cast(Object* obj);
+ DECLARE_CAST(DeclaredAccessorDescriptor)
***The diff for this file has been truncated for email.***
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.