Revision: 21891
Author: [email protected]
Date: Fri Jun 20 07:20:44 2014 UTC
Log: Make the internal parts of our external API a bit more
const-correct.
[email protected]
Review URL: https://codereview.chromium.org/343583002
http://code.google.com/p/v8/source/detail?r=21891
Modified:
/branches/bleeding_edge/include/v8.h
=======================================
--- /branches/bleeding_edge/include/v8.h Wed Jun 18 07:30:56 2014 UTC
+++ /branches/bleeding_edge/include/v8.h Fri Jun 20 07:20:44 2014 UTC
@@ -5459,7 +5459,7 @@
template <> struct SmiTagging<4> {
static const int kSmiShiftSize = 0;
static const int kSmiValueSize = 31;
- V8_INLINE static int SmiToInt(internal::Object* value) {
+ V8_INLINE static int SmiToInt(const internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Throw away top 32 bits and shift down (requires >> to be sign
extending).
return static_cast<int>(reinterpret_cast<intptr_t>(value)) >>
shift_bits;
@@ -5487,7 +5487,7 @@
template <> struct SmiTagging<8> {
static const int kSmiShiftSize = 31;
static const int kSmiValueSize = 32;
- V8_INLINE static int SmiToInt(internal::Object* value) {
+ V8_INLINE static int SmiToInt(const internal::Object* value) {
int shift_bits = kSmiTagSize + kSmiShiftSize;
// Shift down and throw away top 32 bits.
return static_cast<int>(reinterpret_cast<intptr_t>(value) >>
shift_bits);
@@ -5575,12 +5575,12 @@
#endif
}
- V8_INLINE static bool HasHeapObjectTag(internal::Object* value) {
+ V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) {
return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) ==
kHeapObjectTag);
}
- V8_INLINE static int SmiValue(internal::Object* value) {
+ V8_INLINE static int SmiValue(const internal::Object* value) {
return PlatformSmiTagging::SmiToInt(value);
}
@@ -5592,13 +5592,13 @@
return PlatformSmiTagging::IsValidSmi(value);
}
- V8_INLINE static int GetInstanceType(internal::Object* obj) {
+ V8_INLINE static int GetInstanceType(const internal::Object* obj) {
typedef internal::Object O;
O* map = ReadField<O*>(obj, kHeapObjectMapOffset);
return ReadField<uint8_t>(map, kMapInstanceTypeOffset);
}
- V8_INLINE static int GetOddballKind(internal::Object* obj) {
+ V8_INLINE static int GetOddballKind(const internal::Object* obj) {
typedef internal::Object O;
return SmiValue(ReadField<O*>(obj, kOddballKindOffset));
}
@@ -5631,18 +5631,19 @@
*addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value);
}
- V8_INLINE static void SetEmbedderData(v8::Isolate *isolate,
+ V8_INLINE static void SetEmbedderData(v8::Isolate* isolate,
uint32_t slot,
- void *data) {
+ void* data) {
uint8_t *addr = reinterpret_cast<uint8_t *>(isolate) +
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
*reinterpret_cast<void**>(addr) = data;
}
- V8_INLINE static void* GetEmbedderData(v8::Isolate* isolate, uint32_t
slot) {
- uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) +
+ V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate,
+ uint32_t slot) {
+ const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) +
kIsolateEmbedderDataOffset + slot * kApiPointerSize;
- return *reinterpret_cast<void**>(addr);
+ return *reinterpret_cast<void* const*>(addr);
}
V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate,
@@ -5652,16 +5653,17 @@
}
template <typename T>
- V8_INLINE static T ReadField(internal::Object* ptr, int offset) {
- uint8_t* addr = reinterpret_cast<uint8_t*>(ptr) + offset -
kHeapObjectTag;
- return *reinterpret_cast<T*>(addr);
+ V8_INLINE static T ReadField(const internal::Object* ptr, int offset) {
+ const uint8_t* addr =
+ reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag;
+ return *reinterpret_cast<const T*>(addr);
}
template <typename T>
- V8_INLINE static T ReadEmbedderData(v8::Context* context, int index) {
+ V8_INLINE static T ReadEmbedderData(const v8::Context* context, int
index) {
typedef internal::Object O;
typedef internal::Internals I;
- O* ctx = *reinterpret_cast<O**>(context);
+ O* ctx = *reinterpret_cast<O* const*>(context);
int embedder_data_offset = I::kContextHeaderSize +
(internal::kApiPointerSize * I::kContextEmbedderDataIndex);
O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset);
--
--
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.