Index: src/objects.h |
diff --git a/src/objects.h b/src/objects.h |
index 2619c891bd5c5cf7f64769b5a65a9ad90afb2d88..2b802fd0b893c2c4ba06e78b07539f3a07a18992 100644 |
--- a/src/objects.h |
+++ b/src/objects.h |
@@ -50,7 +50,6 @@ |
// - JSBuiltinsObject |
// - JSGlobalProxy |
// - JSValue |
-// - Script |
// - Array |
// - ByteArray |
// - FixedArray |
@@ -83,8 +82,10 @@ |
// - AccessCheckInfo |
// - InterceptorInfo |
// - CallHandlerInfo |
-// - FunctionTemplateInfo |
-// - ObjectTemplateInfo |
+// - TemplateInfo |
+// - FunctionTemplateInfo |
+// - ObjectTemplateInfo |
+// - Script |
// - SignatureInfo |
// - TypeSwitchInfo |
// - DebugInfo |
@@ -771,8 +772,10 @@ class Object BASE_EMBEDDED { |
// Smi represents integer Numbers that can be stored in 31 bits. |
+// TODO(X64) Increase to 53 bits? |
// Smis are immediate which means they are NOT allocated in the heap. |
// The this pointer has the following format: [31 bit signed int] 0 |
+// TODO(X64): 31 bits signed int sign-extended to 63 bits. |
// Smi stands for small integer. |
class Smi: public Object { |
public: |
@@ -1596,6 +1599,9 @@ class FixedArray: public Array { |
// Casting. |
static inline FixedArray* cast(Object* obj); |
+ // Align data at kPointerSize, even if Array.kHeaderSize isn't aligned. |
+ static const int kHeaderSize = OBJECT_SIZE_ALIGN(Array::kHeaderSize); |
+ |
// Dispatched behavior. |
int FixedArraySize() { return SizeFor(length()); } |
void FixedArrayIterateBody(ObjectVisitor* v); |
@@ -2147,7 +2153,7 @@ class ByteArray: public Array { |
inline int get_int(int index); |
static int SizeFor(int length) { |
- return kHeaderSize + OBJECT_SIZE_ALIGN(length); |
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length); |
} |
// We use byte arrays for free blocks in the heap. Given a desired size in |
// bytes that is a multiple of the word size and big enough to hold a byte |
@@ -2344,6 +2350,9 @@ class Code: public HeapObject { |
void CodePrint(); |
void CodeVerify(); |
#endif |
+ // Code entry points are aligned to 32 bytes. |
+ static const int kCodeAlignment = 32; |
+ static const int kCodeAlignmentMask = kCodeAlignment - 1; |
// Layout description. |
static const int kInstructionSizeOffset = HeapObject::kHeaderSize; |
@@ -2351,14 +2360,11 @@ class Code: public HeapObject { |
static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; |
static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; |
static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; |
- // Add filler objects to align the instruction start following right after |
+ // Add padding to align the instruction start following right after |
// the Code object header. |
- static const int kFiller6Offset = kKindSpecificFlagsOffset + kIntSize; |
- static const int kFiller7Offset = kFiller6Offset + kIntSize; |
- static const int kHeaderSize = kFiller7Offset + kIntSize; |
- |
- // Code entry points are aligned to 32 bytes. |
- static const int kCodeAlignment = 32; |
+ static const int kHeaderSize = |
+ (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) & |
+ ~kCodeAlignmentMask; |
// Byte offsets within kKindSpecificFlagsOffset. |
static const int kICFlagOffset = kKindSpecificFlagsOffset + 0; |
@@ -2567,7 +2573,7 @@ class Map: public HeapObject { |
static const int kInstanceDescriptorsOffset = |
kConstructorOffset + kPointerSize; |
static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
- static const int kSize = kCodeCacheOffset + kIntSize; |
+ static const int kSize = kCodeCacheOffset + kPointerSize; |
// Byte offsets within kInstanceSizesOffset. |
static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
@@ -2782,15 +2788,16 @@ class SharedFunctionInfo: public HeapObject { |
static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; |
static const int kExpectedNofPropertiesOffset = |
kFormalParameterCountOffset + kIntSize; |
- static const int kInstanceClassNameOffset = |
+ static const int kStartPositionAndTypeOffset = |
kExpectedNofPropertiesOffset + kIntSize; |
+ static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
+ static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
+ static const int kInstanceClassNameOffset = |
William Hesse
2009/05/18 11:41:30
Are you depending on the fact that you have an eve
Lasse Reichstein
2009/05/18 12:08:23
I am relying on that, but I think documentation sh
|
+ kFunctionTokenPositionOffset + kIntSize; |
static const int kExternalReferenceDataOffset = |
kInstanceClassNameOffset + kPointerSize; |
static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize; |
- static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize; |
- static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
- static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
- static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize; |
+ static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
static const int kSize = kInferredNameOffset + kPointerSize; |
@@ -3100,7 +3107,7 @@ class JSRegExp: public JSObject { |
#endif |
static const int kDataOffset = JSObject::kHeaderSize; |
- static const int kSize = kDataOffset + kIntSize; |
+ static const int kSize = kDataOffset + kPointerSize; |
// Indices in the data array. |
static const int kTagIndex = 0; |
@@ -3513,7 +3520,7 @@ class SeqAsciiString: public SeqString { |
// Computes the size for an AsciiString instance of a given length. |
static int SizeFor(int length) { |
- return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); |
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize); |
} |
// Layout description. |
@@ -3558,7 +3565,7 @@ class SeqTwoByteString: public SeqString { |
// Computes the size for a TwoByteString instance of a given length. |
static int SizeFor(int length) { |
- return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); |
+ return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize); |
} |
// Layout description. |
@@ -3612,7 +3619,7 @@ class ConsString: public String { |
void ConsStringIterateBody(ObjectVisitor* v); |
// Layout description. |
- static const int kFirstOffset = String::kSize; |
+ static const int kFirstOffset = OBJECT_SIZE_ALIGN(String::kSize); |
static const int kSecondOffset = kFirstOffset + kPointerSize; |
static const int kSize = kSecondOffset + kPointerSize; |
@@ -3656,9 +3663,18 @@ class SlicedString: public String { |
void SlicedStringIterateBody(ObjectVisitor* v); |
// Layout description |
+#if V8_HOST_ARCH_64_BIT |
+ // Optimizations expect buffer to be located at same offset as a ConsString's |
+ // first substring. In 64 bit mode we have room for the size before the |
+ // buffer. |
Erik Corry
2009/05/18 11:52:11
Clever. I suggest the following comment:
Each cha
Lasse Reichstein
2009/05/18 12:08:23
Done.
|
+ static const int kStartOffset = String::kSize; |
+ static const int kBufferOffset = kStartOffset + kIntSize; |
+ static const int kSize = kBufferOffset + kPointerSize; |
+#else |
static const int kBufferOffset = String::kSize; |
static const int kStartOffset = kBufferOffset + kPointerSize; |
static const int kSize = kStartOffset + kIntSize; |
+#endif |
// Support for StringInputBuffer. |
inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, |
@@ -3688,7 +3704,7 @@ class ExternalString: public String { |
static inline ExternalString* cast(Object* obj); |
// Layout description. |
- static const int kResourceOffset = String::kSize; |
+ static const int kResourceOffset = OBJECT_SIZE_ALIGN(String::kSize); |
static const int kSize = kResourceOffset + kPointerSize; |
private: |
@@ -4148,7 +4164,7 @@ class ObjectTemplateInfo: public TemplateInfo { |
static const int kConstructorOffset = TemplateInfo::kHeaderSize; |
static const int kInternalFieldCountOffset = |
kConstructorOffset + kPointerSize; |
- static const int kSize = kInternalFieldCountOffset + kHeaderSize; |
+ static const int kSize = kInternalFieldCountOffset + kPointerSize; |
Erik Corry
2009/05/18 11:52:11
Good catch.
|
}; |