}
-#define INT_ACCESSORS(holder, name, offset) \
- int holder::name() { return READ_INT_FIELD(this, offset); } \
+#define INT_ACCESSORS(holder, name, offset) \
+ int holder::name() const { return READ_INT_FIELD(this, offset); } \
void holder::set_##name(int value) { WRITE_INT_FIELD(this, offset, value); }
-#define ACCESSORS(holder, name, type, offset) \
- type* holder::name() { return type::cast(READ_FIELD(this, offset)); } \
- void holder::set_##name(type* value, WriteBarrierMode mode) { \
- WRITE_FIELD(this, offset, value); \
- CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
+#define ACCESSORS(holder, name, type, offset) \
+ type* holder::name() const { return type::cast(READ_FIELD(this, offset)); } \
+ void holder::set_##name(type* value, WriteBarrierMode mode) { \
+ WRITE_FIELD(this, offset, value); \
+ CONDITIONAL_WRITE_BARRIER(GetHeap(), this, offset, value, mode); \
}
// Getter that returns a tagged Smi and setter that writes a tagged Smi.
-#define ACCESSORS_TO_SMI(holder, name, offset) \
- Smi* holder::name() { return Smi::cast(READ_FIELD(this, offset)); } \
- void holder::set_##name(Smi* value, WriteBarrierMode mode) { \
- WRITE_FIELD(this, offset, value); \
+#define ACCESSORS_TO_SMI(holder, name, offset) \
+ Smi* holder::name() const { return Smi::cast(READ_FIELD(this, offset)); } \
+ void holder::set_##name(Smi* value, WriteBarrierMode mode) { \
+ WRITE_FIELD(this, offset, value); \
}
// Getter that returns a Smi as an int and writes an int as a Smi.
#define SMI_ACCESSORS(holder, name, offset) \
- int holder::name() { \
+ int holder::name() const { \
Object* value = READ_FIELD(this, offset); \
return Smi::cast(value)->value(); \
} \
}
#define SYNCHRONIZED_SMI_ACCESSORS(holder, name, offset) \
- int holder::synchronized_##name() { \
+ int holder::synchronized_##name() const { \
Object* value = ACQUIRE_READ_FIELD(this, offset); \
return Smi::cast(value)->value(); \
} \
}
#define NOBARRIER_SMI_ACCESSORS(holder, name, offset) \
- int holder::nobarrier_##name() { \
+ int holder::nobarrier_##name() const { \
Object* value = NOBARRIER_READ_FIELD(this, offset); \
return Smi::cast(value)->value(); \
} \
}
#define BOOL_GETTER(holder, field, name, offset) \
- bool holder::name() { \
+ bool holder::name() const { \
return BooleanBit::get(field(), offset); \
} \
#define BOOL_ACCESSORS(holder, field, name, offset) \
- bool holder::name() { \
+ bool holder::name() const { \
return BooleanBit::get(field(), offset); \
} \
void holder::set_##name(bool value) { \
#define FIELD_ADDR(p, offset) \
(reinterpret_cast<byte*>(p) + offset - kHeapObjectTag)
+#define FIELD_ADDR_CONST(p, offset) \
+ (reinterpret_cast<const byte*>(p) + offset - kHeapObjectTag)
+
#define READ_FIELD(p, offset) \
- (*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<Object* const*>(FIELD_ADDR_CONST(p, offset)))
#define ACQUIRE_READ_FIELD(p, offset) \
reinterpret_cast<Object*>(base::Acquire_Load( \
- reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset))))
+ reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
#define NOBARRIER_READ_FIELD(p, offset) \
reinterpret_cast<Object*>(base::NoBarrier_Load( \
- reinterpret_cast<base::AtomicWord*>(FIELD_ADDR(p, offset))))
+ reinterpret_cast<const base::AtomicWord*>(FIELD_ADDR_CONST(p, offset))))
#define WRITE_FIELD(p, offset, value) \
(*reinterpret_cast<Object**>(FIELD_ADDR(p, offset)) = value)
#ifndef V8_TARGET_ARCH_MIPS
#define READ_DOUBLE_FIELD(p, offset) \
- (*reinterpret_cast<double*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const double*>(FIELD_ADDR_CONST(p, offset)))
#else // V8_TARGET_ARCH_MIPS
// Prevent gcc from using load-double (mips ldc1) on (possibly)
// non-64-bit aligned HeapNumber::value.
- static inline double read_double_field(void* p, int offset) {
+ static inline double read_double_field(const void* p, int offset) {
union conversion {
double d;
uint32_t u[2];
} c;
- c.u[0] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)));
- c.u[1] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset + 4)));
+ c.u[0] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR_CONST(p, offset)));
+ c.u[1] = (*reinterpret_cast<uint32_t*>(FIELD_ADDR_CONST(p, offset + 4)));
return c.d;
}
#define READ_DOUBLE_FIELD(p, offset) read_double_field(p, offset)
#define READ_INT_FIELD(p, offset) \
- (*reinterpret_cast<int*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const int*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_INT_FIELD(p, offset, value) \
(*reinterpret_cast<int*>(FIELD_ADDR(p, offset)) = value)
#define READ_INTPTR_FIELD(p, offset) \
- (*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const intptr_t*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_INTPTR_FIELD(p, offset, value) \
(*reinterpret_cast<intptr_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_UINT32_FIELD(p, offset) \
- (*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const uint32_t*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_UINT32_FIELD(p, offset, value) \
(*reinterpret_cast<uint32_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_INT32_FIELD(p, offset) \
- (*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const int32_t*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_INT32_FIELD(p, offset, value) \
(*reinterpret_cast<int32_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_INT64_FIELD(p, offset) \
- (*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const int64_t*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_INT64_FIELD(p, offset, value) \
(*reinterpret_cast<int64_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_SHORT_FIELD(p, offset) \
- (*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const uint16_t*>(FIELD_ADDR_CONST(p, offset)))
#define WRITE_SHORT_FIELD(p, offset, value) \
(*reinterpret_cast<uint16_t*>(FIELD_ADDR(p, offset)) = value)
#define READ_BYTE_FIELD(p, offset) \
- (*reinterpret_cast<byte*>(FIELD_ADDR(p, offset)))
+ (*reinterpret_cast<const byte*>(FIELD_ADDR_CONST(p, offset)))
#define NOBARRIER_READ_BYTE_FIELD(p, offset) \
static_cast<byte>(base::NoBarrier_Load( \
static_cast<base::Atomic8>(value));
Object** HeapObject::RawField(HeapObject* obj, int byte_offset) {
- return &READ_FIELD(obj, byte_offset);
+ return reinterpret_cast<Object**>(FIELD_ADDR(obj, byte_offset));
}
-int Smi::value() {
+int Smi::value() const {
return Internals::SmiValue(this);
}
}
-MapWord MapWord::FromMap(Map* map) {
+MapWord MapWord::FromMap(const Map* map) {
return MapWord(reinterpret_cast<uintptr_t>(map));
}
#endif
-Heap* HeapObject::GetHeap() {
+Heap* HeapObject::GetHeap() const {
Heap* heap =
- MemoryChunk::FromAddress(reinterpret_cast<Address>(this))->heap();
+ MemoryChunk::FromAddress(reinterpret_cast<const byte*>(this))->heap();
SLOW_ASSERT(heap != NULL);
return heap;
}
}
-Map* HeapObject::map() {
+Map* HeapObject::map() const {
#ifdef DEBUG
// Clear mark potentially added by PathTracer.
uintptr_t raw_value =
}
-MapWord HeapObject::map_word() {
+MapWord HeapObject::map_word() const {
return MapWord(
reinterpret_cast<uintptr_t>(NOBARRIER_READ_FIELD(this, kMapOffset)));
}
}
-MapWord HeapObject::synchronized_map_word() {
+MapWord HeapObject::synchronized_map_word() const {
return MapWord(
reinterpret_cast<uintptr_t>(ACQUIRE_READ_FIELD(this, kMapOffset)));
}
}
-FixedArrayBase* JSObject::elements() {
+FixedArrayBase* JSObject::elements() const {
Object* array = READ_FIELD(this, kElementsOffset);
return static_cast<FixedArrayBase*>(array);
}
}
-Object* Cell::value() {
+Object* Cell::value() const {
return READ_FIELD(this, kValueOffset);
}
ACCESSORS(PropertyCell, dependent_code, DependentCode, kDependentCodeOffset)
-Object* PropertyCell::type_raw() {
+Object* PropertyCell::type_raw() const {
return READ_FIELD(this, kTypeOffset);
}
}
-void* ExternalArray::external_pointer() {
+void* ExternalArray::external_pointer() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kExternalPointerOffset);
return reinterpret_cast<void*>(ptr);
}
}
-Object* Map::prototype() {
+Object* Map::prototype() const {
return READ_FIELD(this, kPrototypeOffset);
}
}
-bool Map::HasTransitionArray() {
+bool Map::HasTransitionArray() const {
Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset);
return object->IsTransitionArray();
}
}
-TransitionArray* Map::transitions() {
+TransitionArray* Map::transitions() const {
ASSERT(HasTransitionArray());
Object* object = READ_FIELD(this, kTransitionsOrBackPointerOffset);
return TransitionArray::cast(object);
#define PSEUDO_SMI_ACCESSORS_LO(holder, name, offset) \
STATIC_ASSERT(holder::offset % kPointerSize == 0); \
- int holder::name() { \
+ int holder::name() const { \
int value = READ_INT_FIELD(this, offset); \
ASSERT(kHeapObjectTag == 1); \
ASSERT((value & kHeapObjectTag) == 0); \
}
-Code* SharedFunctionInfo::code() {
+Code* SharedFunctionInfo::code() const {
return Code::cast(READ_FIELD(this, kCodeOffset));
}
}
-ScopeInfo* SharedFunctionInfo::scope_info() {
+ScopeInfo* SharedFunctionInfo::scope_info() const {
return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset));
}
#define ORDERED_HASH_TABLE_ITERATOR_ACCESSORS(name, type, offset) \
template<class Derived, class TableType> \
- type* OrderedHashTableIterator<Derived, TableType>::name() { \
+ type* OrderedHashTableIterator<Derived, TableType>::name() const { \
return type::cast(READ_FIELD(this, offset)); \
} \
template<class Derived, class TableType> \
ACCESSORS(JSArray, length, Object, kLengthOffset)
-void* JSArrayBuffer::backing_store() {
+void* JSArrayBuffer::backing_store() const {
intptr_t ptr = READ_INTPTR_FIELD(this, kBackingStoreOffset);
return reinterpret_cast<void*>(ptr);
}
#undef BOOL_GETTER
#undef BOOL_ACCESSORS
#undef FIELD_ADDR
+#undef FIELD_ADDR_CONST
#undef READ_FIELD
#undef NOBARRIER_READ_FIELD
#undef WRITE_FIELD
#define DECL_BOOLEAN_ACCESSORS(name) \
- inline bool name(); \
+ inline bool name() const; \
inline void set_##name(bool value); \
#define DECL_ACCESSORS(name, type) \
- inline type* name(); \
+ inline type* name() const; \
inline void set_##name(type* value, \
WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
class Smi: public Object {
public:
// Returns the integer value.
- inline int value();
+ inline int value() const;
// Convert a value to a Smi object.
static inline Smi* FromInt(int value);
// Normal state: the map word contains a map pointer.
// Create a map word from a map pointer.
- static inline MapWord FromMap(Map* map);
+ static inline MapWord FromMap(const Map* map);
// View this map word as a map pointer.
inline Map* ToMap();
public:
// [map]: Contains a map which contains the object's reflective
// information.
- inline Map* map();
+ inline Map* map() const;
inline void set_map(Map* value);
// The no-write-barrier version. This is OK if the object is white and in
// new space, or if the value is an immortal immutable object, like the maps
// Get the map using acquire load.
inline Map* synchronized_map();
- inline MapWord synchronized_map_word();
+ inline MapWord synchronized_map_word() const;
// Set the map using release store
inline void synchronized_set_map(Map* value);
// During garbage collection, the map word of a heap object does not
// necessarily contain a map pointer.
- inline MapWord map_word();
+ inline MapWord map_word() const;
inline void set_map_word(MapWord map_word);
// The Heap the object was allocated in. Used also to access Isolate.
- inline Heap* GetHeap();
+ inline Heap* GetHeap() const;
// Convenience method to get current isolate.
inline Isolate* GetIsolate();
class FixedArrayBase: public HeapObject {
public:
// [length]: length of the array.
- inline int length();
+ inline int length() const;
inline void set_length(int value);
// Get and set the length using acquire loads and release stores.
- inline int synchronized_length();
+ inline int synchronized_length() const;
inline void synchronized_set_length(int value);
inline static FixedArrayBase* cast(Object* object);
class FreeSpace: public HeapObject {
public:
// [size]: size of the free space including the header.
- inline int size();
+ inline int size() const;
inline void set_size(int value);
- inline int nobarrier_size();
+ inline int nobarrier_size() const;
inline void nobarrier_set_size(int value);
inline int Size() { return size(); }
#endif // ENABLE_DISASSEMBLER
// [instruction_size]: Size of the native instructions
- inline int instruction_size();
+ inline int instruction_size() const;
inline void set_instruction_size(int value);
// [relocation_info]: Code relocation information
// [ic_age]: Inline caching age: the value of the Heap::global_ic_age
// at the moment when this object was created.
inline void set_ic_age(int count);
- inline int ic_age();
+ inline int ic_age() const;
// [prologue_offset]: Offset of the function prologue, used for aging
// FUNCTIONs and OPTIMIZED_FUNCTIONs.
- inline int prologue_offset();
+ inline int prologue_offset() const;
inline void set_prologue_offset(int offset);
// Unchecked accessors to be used during GC.
// map with DICTIONARY_ELEMENTS was found in the prototype chain.
bool DictionaryElementsInPrototypeChainOnly();
- inline bool HasTransitionArray();
+ inline bool HasTransitionArray() const;
inline bool HasElementsTransition();
inline Map* elements_transition_map();
static Handle<TransitionArray> SetElementsTransitionMap(
// [length]: The function length - usually the number of declared parameters.
// Use up to 2^30 parameters.
- inline int length();
+ inline int length() const;
inline void set_length(int value);
// [formal parameter count]: The declared number of parameters.
- inline int formal_parameter_count();
+ inline int formal_parameter_count() const;
inline void set_formal_parameter_count(int value);
// Set the formal parameter count so the function code will be
inline void DontAdaptArguments();
// [expected_nof_properties]: Expected number of properties for the function.
- inline int expected_nof_properties();
+ inline int expected_nof_properties() const;
inline void set_expected_nof_properties(int value);
// [feedback_vector] - accumulates ast node feedback from full-codegen and
DECL_ACCESSORS(script, Object)
// [num_literals]: Number of literals used by this function.
- inline int num_literals();
+ inline int num_literals() const;
inline void set_num_literals(int value);
// [start_position_and_type]: Field used to store both the source code
// and whether or not the function is a toplevel function. The two
// least significants bit indicates whether the function is an
// expression and the rest contains the source code position.
- inline int start_position_and_type();
+ inline int start_position_and_type() const;
inline void set_start_position_and_type(int value);
// [debug info]: Debug information.
String* DebugName();
// Position of the 'function' token in the script source.
- inline int function_token_position();
+ inline int function_token_position() const;
inline void set_function_token_position(int function_token_position);
// Position of this function in the script source.
inline void set_start_position(int start_position);
// End position of this function in the script source.
- inline int end_position();
+ inline int end_position() const;
inline void set_end_position(int end_position);
// Is this function a function expression in the source code.
// Bit field containing various information collected by the compiler to
// drive optimization.
- inline int compiler_hints();
+ inline int compiler_hints() const;
inline void set_compiler_hints(int value);
- inline int ast_node_count();
+ inline int ast_node_count() const;
inline void set_ast_node_count(int count);
- inline int profiler_ticks();
+ inline int profiler_ticks() const;
inline void set_profiler_ticks(int ticks);
// Inline cache age is used to infer whether the function survived a context
// Stores deopt_count, opt_reenable_tries and ic_age as bit-fields.
inline void set_counters(int value);
- inline int counters();
+ inline int counters() const;
// Stores opt_count and bailout_reason as bit-fields.
inline void set_opt_count_and_bailout_reason(int value);
- inline int opt_count_and_bailout_reason();
+ inline int opt_count_and_bailout_reason() const;
void set_bailout_reason(BailoutReason reason) {
set_opt_count_and_bailout_reason(
// A positive offset indicates a suspended generator. The special
// kGeneratorExecuting and kGeneratorClosed values indicate that a generator
// cannot be resumed.
- inline int continuation();
+ inline int continuation() const;
inline void set_continuation(int continuation);
inline bool is_closed();
inline bool is_executing();
// [stack_handler_index]: Index of first stack handler in operand_stack, or -1
// if the captured activation had no stack handler.
- inline int stack_handler_index();
+ inline int stack_handler_index() const;
inline void set_stack_handler_index(int stack_handler_index);
// Casting.
DECL_ACCESSORS(stack_frames, Object)
// [start_position]: the start position in the script for the error message.
- inline int start_position();
+ inline int start_position() const;
inline void set_start_position(int value);
// [end_position]: the end position in the script for the error message.
- inline int end_position();
+ inline int end_position() const;
inline void set_end_position(int value);
// Casting.
// - all attributes are available as part if the property details
class AliasedArgumentsEntry: public Struct {
public:
- inline int aliased_context_slot();
+ inline int aliased_context_slot() const;
inline void set_aliased_context_slot(int count);
static inline AliasedArgumentsEntry* cast(Object* obj);
};
// Get and set the length of the string.
- inline int length();
+ inline int length() const;
inline void set_length(int value);
// Get and set the length of the string using acquire loads and release
// stores.
- inline int synchronized_length();
+ inline int synchronized_length() const;
inline void synchronized_set_length(int value);
// Returns whether this string has only ASCII chars, i.e. all of them can
inline String* parent();
inline void set_parent(String* parent,
WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
- inline int offset();
+ inline int offset() const;
inline void set_offset(int offset);
// Dispatched behavior.
DECL_ACCESSORS(access_check_info, Object)
DECL_ACCESSORS(flag, Smi)
- inline int length();
+ inline int length() const;
inline void set_length(int value);
// Following properties use flag bits.