Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(740)

Side by Side Diff: src/objects.h

Issue 113522: X64: Checked and slightly modified Object layouts to be compatible with 64-bit pointers. (Closed)
Patch Set: Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/log.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // - HeapObject (superclass for everything allocated in the heap) 43 // - HeapObject (superclass for everything allocated in the heap)
44 // - JSObject 44 // - JSObject
45 // - JSArray 45 // - JSArray
46 // - JSRegExp 46 // - JSRegExp
47 // - JSFunction 47 // - JSFunction
48 // - GlobalObject 48 // - GlobalObject
49 // - JSGlobalObject 49 // - JSGlobalObject
50 // - JSBuiltinsObject 50 // - JSBuiltinsObject
51 // - JSGlobalProxy 51 // - JSGlobalProxy
52 // - JSValue 52 // - JSValue
53 // - Script
54 // - Array 53 // - Array
55 // - ByteArray 54 // - ByteArray
56 // - FixedArray 55 // - FixedArray
57 // - DescriptorArray 56 // - DescriptorArray
58 // - HashTable 57 // - HashTable
59 // - Dictionary 58 // - Dictionary
60 // - SymbolTable 59 // - SymbolTable
61 // - CompilationCacheTable 60 // - CompilationCacheTable
62 // - MapCache 61 // - MapCache
63 // - LookupCache 62 // - LookupCache
(...skipping 12 matching lines...) Expand all
76 // - Code 75 // - Code
77 // - Map 76 // - Map
78 // - Oddball 77 // - Oddball
79 // - Proxy 78 // - Proxy
80 // - SharedFunctionInfo 79 // - SharedFunctionInfo
81 // - Struct 80 // - Struct
82 // - AccessorInfo 81 // - AccessorInfo
83 // - AccessCheckInfo 82 // - AccessCheckInfo
84 // - InterceptorInfo 83 // - InterceptorInfo
85 // - CallHandlerInfo 84 // - CallHandlerInfo
86 // - FunctionTemplateInfo 85 // - TemplateInfo
87 // - ObjectTemplateInfo 86 // - FunctionTemplateInfo
87 // - ObjectTemplateInfo
88 // - Script
88 // - SignatureInfo 89 // - SignatureInfo
89 // - TypeSwitchInfo 90 // - TypeSwitchInfo
90 // - DebugInfo 91 // - DebugInfo
91 // - BreakPointInfo 92 // - BreakPointInfo
92 // 93 //
93 // Formats of Object*: 94 // Formats of Object*:
94 // Smi: [31 bit signed int] 0 95 // Smi: [31 bit signed int] 0
95 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 96 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
96 // Failure: [30 bit signed int] 11 97 // Failure: [30 bit signed int] 11
97 98
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 765
765 // Layout description. 766 // Layout description.
766 static const int kHeaderSize = 0; // Object does not take up any space. 767 static const int kHeaderSize = 0; // Object does not take up any space.
767 768
768 private: 769 private:
769 DISALLOW_IMPLICIT_CONSTRUCTORS(Object); 770 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
770 }; 771 };
771 772
772 773
773 // Smi represents integer Numbers that can be stored in 31 bits. 774 // Smi represents integer Numbers that can be stored in 31 bits.
775 // TODO(X64) Increase to 53 bits?
774 // Smis are immediate which means they are NOT allocated in the heap. 776 // Smis are immediate which means they are NOT allocated in the heap.
775 // The this pointer has the following format: [31 bit signed int] 0 777 // The this pointer has the following format: [31 bit signed int] 0
778 // TODO(X64): 31 bits signed int sign-extended to 63 bits.
776 // Smi stands for small integer. 779 // Smi stands for small integer.
777 class Smi: public Object { 780 class Smi: public Object {
778 public: 781 public:
779 // Returns the integer value. 782 // Returns the integer value.
780 inline int value(); 783 inline int value();
781 784
782 // Convert a value to a Smi object. 785 // Convert a value to a Smi object.
783 static inline Smi* FromInt(int value); 786 static inline Smi* FromInt(int value);
784 787
785 static inline Smi* FromIntptr(intptr_t value); 788 static inline Smi* FromIntptr(intptr_t value);
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
1589 1592
1590 // Copy a sub array from the receiver to dest. 1593 // Copy a sub array from the receiver to dest.
1591 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); 1594 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
1592 1595
1593 // Garbage collection support. 1596 // Garbage collection support.
1594 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } 1597 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
1595 1598
1596 // Casting. 1599 // Casting.
1597 static inline FixedArray* cast(Object* obj); 1600 static inline FixedArray* cast(Object* obj);
1598 1601
1602 // Align data at kPointerSize, even if Array.kHeaderSize isn't aligned.
1603 static const int kHeaderSize = OBJECT_SIZE_ALIGN(Array::kHeaderSize);
1604
1599 // Dispatched behavior. 1605 // Dispatched behavior.
1600 int FixedArraySize() { return SizeFor(length()); } 1606 int FixedArraySize() { return SizeFor(length()); }
1601 void FixedArrayIterateBody(ObjectVisitor* v); 1607 void FixedArrayIterateBody(ObjectVisitor* v);
1602 #ifdef DEBUG 1608 #ifdef DEBUG
1603 void FixedArrayPrint(); 1609 void FixedArrayPrint();
1604 void FixedArrayVerify(); 1610 void FixedArrayVerify();
1605 // Checks if two FixedArrays have identical contents. 1611 // Checks if two FixedArrays have identical contents.
1606 bool IsEqualTo(FixedArray* other); 1612 bool IsEqualTo(FixedArray* other);
1607 #endif 1613 #endif
1608 1614
(...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after
2140 class ByteArray: public Array { 2146 class ByteArray: public Array {
2141 public: 2147 public:
2142 // Setter and getter. 2148 // Setter and getter.
2143 inline byte get(int index); 2149 inline byte get(int index);
2144 inline void set(int index, byte value); 2150 inline void set(int index, byte value);
2145 2151
2146 // Treat contents as an int array. 2152 // Treat contents as an int array.
2147 inline int get_int(int index); 2153 inline int get_int(int index);
2148 2154
2149 static int SizeFor(int length) { 2155 static int SizeFor(int length) {
2150 return kHeaderSize + OBJECT_SIZE_ALIGN(length); 2156 return OBJECT_SIZE_ALIGN(kHeaderSize + length);
2151 } 2157 }
2152 // We use byte arrays for free blocks in the heap. Given a desired size in 2158 // We use byte arrays for free blocks in the heap. Given a desired size in
2153 // bytes that is a multiple of the word size and big enough to hold a byte 2159 // bytes that is a multiple of the word size and big enough to hold a byte
2154 // array, this function returns the number of elements a byte array should 2160 // array, this function returns the number of elements a byte array should
2155 // have. 2161 // have.
2156 static int LengthFor(int size_in_bytes) { 2162 static int LengthFor(int size_in_bytes) {
2157 ASSERT(IsAligned(size_in_bytes, kPointerSize)); 2163 ASSERT(IsAligned(size_in_bytes, kPointerSize));
2158 ASSERT(size_in_bytes >= kHeaderSize); 2164 ASSERT(size_in_bytes >= kHeaderSize);
2159 return size_in_bytes - kHeaderSize; 2165 return size_in_bytes - kHeaderSize;
2160 } 2166 }
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
2337 // Casting. 2343 // Casting.
2338 static inline Code* cast(Object* obj); 2344 static inline Code* cast(Object* obj);
2339 2345
2340 // Dispatched behavior. 2346 // Dispatched behavior.
2341 int CodeSize() { return SizeFor(body_size(), sinfo_size()); } 2347 int CodeSize() { return SizeFor(body_size(), sinfo_size()); }
2342 void CodeIterateBody(ObjectVisitor* v); 2348 void CodeIterateBody(ObjectVisitor* v);
2343 #ifdef DEBUG 2349 #ifdef DEBUG
2344 void CodePrint(); 2350 void CodePrint();
2345 void CodeVerify(); 2351 void CodeVerify();
2346 #endif 2352 #endif
2353 // Code entry points are aligned to 32 bytes.
2354 static const int kCodeAlignment = 32;
2355 static const int kCodeAlignmentMask = kCodeAlignment - 1;
2347 2356
2348 // Layout description. 2357 // Layout description.
2349 static const int kInstructionSizeOffset = HeapObject::kHeaderSize; 2358 static const int kInstructionSizeOffset = HeapObject::kHeaderSize;
2350 static const int kRelocationSizeOffset = kInstructionSizeOffset + kIntSize; 2359 static const int kRelocationSizeOffset = kInstructionSizeOffset + kIntSize;
2351 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize; 2360 static const int kSInfoSizeOffset = kRelocationSizeOffset + kIntSize;
2352 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize; 2361 static const int kFlagsOffset = kSInfoSizeOffset + kIntSize;
2353 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize; 2362 static const int kKindSpecificFlagsOffset = kFlagsOffset + kIntSize;
2354 // Add filler objects to align the instruction start following right after 2363 // Add padding to align the instruction start following right after
2355 // the Code object header. 2364 // the Code object header.
2356 static const int kFiller6Offset = kKindSpecificFlagsOffset + kIntSize; 2365 static const int kHeaderSize =
2357 static const int kFiller7Offset = kFiller6Offset + kIntSize; 2366 (kKindSpecificFlagsOffset + kIntSize + kCodeAlignmentMask) &
2358 static const int kHeaderSize = kFiller7Offset + kIntSize; 2367 ~kCodeAlignmentMask;
2359
2360 // Code entry points are aligned to 32 bytes.
2361 static const int kCodeAlignment = 32;
2362 2368
2363 // Byte offsets within kKindSpecificFlagsOffset. 2369 // Byte offsets within kKindSpecificFlagsOffset.
2364 static const int kICFlagOffset = kKindSpecificFlagsOffset + 0; 2370 static const int kICFlagOffset = kKindSpecificFlagsOffset + 0;
2365 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1; 2371 static const int kStubMajorKeyOffset = kKindSpecificFlagsOffset + 1;
2366 2372
2367 // Flags layout. 2373 // Flags layout.
2368 static const int kFlagsICStateShift = 0; 2374 static const int kFlagsICStateShift = 0;
2369 static const int kFlagsKindShift = 3; 2375 static const int kFlagsKindShift = 3;
2370 static const int kFlagsTypeShift = 6; 2376 static const int kFlagsTypeShift = 6;
2371 static const int kFlagsArgumentsCountShift = 9; 2377 static const int kFlagsArgumentsCountShift = 9;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 #endif 2566 #endif
2561 2567
2562 // Layout description. 2568 // Layout description.
2563 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 2569 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
2564 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 2570 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
2565 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; 2571 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
2566 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 2572 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
2567 static const int kInstanceDescriptorsOffset = 2573 static const int kInstanceDescriptorsOffset =
2568 kConstructorOffset + kPointerSize; 2574 kConstructorOffset + kPointerSize;
2569 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; 2575 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize;
2570 static const int kSize = kCodeCacheOffset + kIntSize; 2576 static const int kSize = kCodeCacheOffset + kPointerSize;
2571 2577
2572 // Byte offsets within kInstanceSizesOffset. 2578 // Byte offsets within kInstanceSizesOffset.
2573 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 2579 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
2574 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; 2580 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1;
2575 // The bytes at positions 2 and 3 are not in use at the moment. 2581 // The bytes at positions 2 and 3 are not in use at the moment.
2576 2582
2577 // Byte offsets within kInstanceAttributesOffset attributes. 2583 // Byte offsets within kInstanceAttributesOffset attributes.
2578 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; 2584 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0;
2579 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; 2585 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1;
2580 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; 2586 static const int kBitFieldOffset = kInstanceAttributesOffset + 2;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
2775 // Constants. 2781 // Constants.
2776 static const int kDontAdaptArgumentsSentinel = -1; 2782 static const int kDontAdaptArgumentsSentinel = -1;
2777 2783
2778 // Layout description. 2784 // Layout description.
2779 static const int kNameOffset = HeapObject::kHeaderSize; 2785 static const int kNameOffset = HeapObject::kHeaderSize;
2780 static const int kCodeOffset = kNameOffset + kPointerSize; 2786 static const int kCodeOffset = kNameOffset + kPointerSize;
2781 static const int kLengthOffset = kCodeOffset + kPointerSize; 2787 static const int kLengthOffset = kCodeOffset + kPointerSize;
2782 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize; 2788 static const int kFormalParameterCountOffset = kLengthOffset + kIntSize;
2783 static const int kExpectedNofPropertiesOffset = 2789 static const int kExpectedNofPropertiesOffset =
2784 kFormalParameterCountOffset + kIntSize; 2790 kFormalParameterCountOffset + kIntSize;
2791 static const int kStartPositionAndTypeOffset =
2792 kExpectedNofPropertiesOffset + kIntSize;
2793 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
2794 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
2785 static const int kInstanceClassNameOffset = 2795 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
2786 kExpectedNofPropertiesOffset + kIntSize; 2796 kFunctionTokenPositionOffset + kIntSize;
2787 static const int kExternalReferenceDataOffset = 2797 static const int kExternalReferenceDataOffset =
2788 kInstanceClassNameOffset + kPointerSize; 2798 kInstanceClassNameOffset + kPointerSize;
2789 static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize; 2799 static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize;
2790 static const int kStartPositionAndTypeOffset = kScriptOffset + kPointerSize; 2800 static const int kDebugInfoOffset = kScriptOffset + kPointerSize;
2791 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize;
2792 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize;
2793 static const int kDebugInfoOffset = kFunctionTokenPositionOffset + kIntSize;
2794 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; 2801 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize;
2795 static const int kSize = kInferredNameOffset + kPointerSize; 2802 static const int kSize = kInferredNameOffset + kPointerSize;
2796 2803
2797 private: 2804 private:
2798 // Bit positions in length_and_flg. 2805 // Bit positions in length_and_flg.
2799 // The least significant bit is used as the flag. 2806 // The least significant bit is used as the flag.
2800 static const int kFlagBit = 0; 2807 static const int kFlagBit = 0;
2801 static const int kLengthShift = 1; 2808 static const int kLengthShift = 1;
2802 static const int kLengthMask = ~((1 << kLengthShift) - 1); 2809 static const int kLengthMask = ~((1 << kLengthShift) - 1);
2803 2810
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
3093 inline void SetDataAt(int index, Object* value); 3100 inline void SetDataAt(int index, Object* value);
3094 3101
3095 static inline JSRegExp* cast(Object* obj); 3102 static inline JSRegExp* cast(Object* obj);
3096 3103
3097 // Dispatched behavior. 3104 // Dispatched behavior.
3098 #ifdef DEBUG 3105 #ifdef DEBUG
3099 void JSRegExpVerify(); 3106 void JSRegExpVerify();
3100 #endif 3107 #endif
3101 3108
3102 static const int kDataOffset = JSObject::kHeaderSize; 3109 static const int kDataOffset = JSObject::kHeaderSize;
3103 static const int kSize = kDataOffset + kIntSize; 3110 static const int kSize = kDataOffset + kPointerSize;
3104 3111
3105 // Indices in the data array. 3112 // Indices in the data array.
3106 static const int kTagIndex = 0; 3113 static const int kTagIndex = 0;
3107 static const int kSourceIndex = kTagIndex + 1; 3114 static const int kSourceIndex = kTagIndex + 1;
3108 static const int kFlagsIndex = kSourceIndex + 1; 3115 static const int kFlagsIndex = kSourceIndex + 1;
3109 static const int kDataIndex = kFlagsIndex + 1; 3116 static const int kDataIndex = kFlagsIndex + 1;
3110 // The data fields are used in different ways depending on the 3117 // The data fields are used in different ways depending on the
3111 // value of the tag. 3118 // value of the tag.
3112 // Atom regexps (literal strings). 3119 // Atom regexps (literal strings).
3113 static const int kAtomPatternIndex = kDataIndex; 3120 static const int kAtomPatternIndex = kDataIndex;
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
3506 // Casting 3513 // Casting
3507 static inline SeqAsciiString* cast(Object* obj); 3514 static inline SeqAsciiString* cast(Object* obj);
3508 3515
3509 // Garbage collection support. This method is called by the 3516 // Garbage collection support. This method is called by the
3510 // garbage collector to compute the actual size of an AsciiString 3517 // garbage collector to compute the actual size of an AsciiString
3511 // instance. 3518 // instance.
3512 inline int SeqAsciiStringSize(InstanceType instance_type); 3519 inline int SeqAsciiStringSize(InstanceType instance_type);
3513 3520
3514 // Computes the size for an AsciiString instance of a given length. 3521 // Computes the size for an AsciiString instance of a given length.
3515 static int SizeFor(int length) { 3522 static int SizeFor(int length) {
3516 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kCharSize); 3523 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kCharSize);
3517 } 3524 }
3518 3525
3519 // Layout description. 3526 // Layout description.
3520 static const int kHeaderSize = String::kSize; 3527 static const int kHeaderSize = String::kSize;
3521 3528
3522 // Support for StringInputBuffer. 3529 // Support for StringInputBuffer.
3523 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 3530 inline void SeqAsciiStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
3524 unsigned* offset, 3531 unsigned* offset,
3525 unsigned chars); 3532 unsigned chars);
3526 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining, 3533 inline const unibrow::byte* SeqAsciiStringReadBlock(unsigned* remaining,
(...skipping 24 matching lines...) Expand all
3551 // Casting 3558 // Casting
3552 static inline SeqTwoByteString* cast(Object* obj); 3559 static inline SeqTwoByteString* cast(Object* obj);
3553 3560
3554 // Garbage collection support. This method is called by the 3561 // Garbage collection support. This method is called by the
3555 // garbage collector to compute the actual size of a TwoByteString 3562 // garbage collector to compute the actual size of a TwoByteString
3556 // instance. 3563 // instance.
3557 inline int SeqTwoByteStringSize(InstanceType instance_type); 3564 inline int SeqTwoByteStringSize(InstanceType instance_type);
3558 3565
3559 // Computes the size for a TwoByteString instance of a given length. 3566 // Computes the size for a TwoByteString instance of a given length.
3560 static int SizeFor(int length) { 3567 static int SizeFor(int length) {
3561 return kHeaderSize + OBJECT_SIZE_ALIGN(length * kShortSize); 3568 return OBJECT_SIZE_ALIGN(kHeaderSize + length * kShortSize);
3562 } 3569 }
3563 3570
3564 // Layout description. 3571 // Layout description.
3565 static const int kHeaderSize = String::kSize; 3572 static const int kHeaderSize = String::kSize;
3566 3573
3567 // Support for StringInputBuffer. 3574 // Support for StringInputBuffer.
3568 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 3575 inline void SeqTwoByteStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
3569 unsigned* offset_ptr, 3576 unsigned* offset_ptr,
3570 unsigned chars); 3577 unsigned chars);
3571 3578
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3605 3612
3606 // Casting. 3613 // Casting.
3607 static inline ConsString* cast(Object* obj); 3614 static inline ConsString* cast(Object* obj);
3608 3615
3609 // Garbage collection support. This method is called during garbage 3616 // Garbage collection support. This method is called during garbage
3610 // collection to iterate through the heap pointers in the body of 3617 // collection to iterate through the heap pointers in the body of
3611 // the ConsString. 3618 // the ConsString.
3612 void ConsStringIterateBody(ObjectVisitor* v); 3619 void ConsStringIterateBody(ObjectVisitor* v);
3613 3620
3614 // Layout description. 3621 // Layout description.
3615 static const int kFirstOffset = String::kSize; 3622 static const int kFirstOffset = OBJECT_SIZE_ALIGN(String::kSize);
3616 static const int kSecondOffset = kFirstOffset + kPointerSize; 3623 static const int kSecondOffset = kFirstOffset + kPointerSize;
3617 static const int kSize = kSecondOffset + kPointerSize; 3624 static const int kSize = kSecondOffset + kPointerSize;
3618 3625
3619 // Support for StringInputBuffer. 3626 // Support for StringInputBuffer.
3620 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer, 3627 inline const unibrow::byte* ConsStringReadBlock(ReadBlockBuffer* buffer,
3621 unsigned* offset_ptr, 3628 unsigned* offset_ptr,
3622 unsigned chars); 3629 unsigned chars);
3623 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 3630 inline void ConsStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
3624 unsigned* offset_ptr, 3631 unsigned* offset_ptr,
3625 unsigned chars); 3632 unsigned chars);
(...skipping 23 matching lines...) Expand all
3649 // Dispatched behavior. 3656 // Dispatched behavior.
3650 uint16_t SlicedStringGet(int index); 3657 uint16_t SlicedStringGet(int index);
3651 3658
3652 // Casting. 3659 // Casting.
3653 static inline SlicedString* cast(Object* obj); 3660 static inline SlicedString* cast(Object* obj);
3654 3661
3655 // Garbage collection support. 3662 // Garbage collection support.
3656 void SlicedStringIterateBody(ObjectVisitor* v); 3663 void SlicedStringIterateBody(ObjectVisitor* v);
3657 3664
3658 // Layout description 3665 // Layout description
3666 #if V8_HOST_ARCH_64_BIT
3667 // Optimizations expect buffer to be located at same offset as a ConsString's
3668 // first substring. In 64 bit mode we have room for the size before the
3669 // 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.
3670 static const int kStartOffset = String::kSize;
3671 static const int kBufferOffset = kStartOffset + kIntSize;
3672 static const int kSize = kBufferOffset + kPointerSize;
3673 #else
3659 static const int kBufferOffset = String::kSize; 3674 static const int kBufferOffset = String::kSize;
3660 static const int kStartOffset = kBufferOffset + kPointerSize; 3675 static const int kStartOffset = kBufferOffset + kPointerSize;
3661 static const int kSize = kStartOffset + kIntSize; 3676 static const int kSize = kStartOffset + kIntSize;
3677 #endif
3662 3678
3663 // Support for StringInputBuffer. 3679 // Support for StringInputBuffer.
3664 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, 3680 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer,
3665 unsigned* offset_ptr, 3681 unsigned* offset_ptr,
3666 unsigned chars); 3682 unsigned chars);
3667 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, 3683 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer,
3668 unsigned* offset_ptr, 3684 unsigned* offset_ptr,
3669 unsigned chars); 3685 unsigned chars);
3670 3686
3671 private: 3687 private:
3672 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); 3688 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString);
3673 }; 3689 };
3674 3690
3675 3691
3676 // The ExternalString class describes string values that are backed by 3692 // The ExternalString class describes string values that are backed by
3677 // a string resource that lies outside the V8 heap. ExternalStrings 3693 // a string resource that lies outside the V8 heap. ExternalStrings
3678 // consist of the length field common to all strings, a pointer to the 3694 // consist of the length field common to all strings, a pointer to the
3679 // external resource. It is important to ensure (externally) that the 3695 // external resource. It is important to ensure (externally) that the
3680 // resource is not deallocated while the ExternalString is live in the 3696 // resource is not deallocated while the ExternalString is live in the
3681 // V8 heap. 3697 // V8 heap.
3682 // 3698 //
3683 // The API expects that all ExternalStrings are created through the 3699 // The API expects that all ExternalStrings are created through the
3684 // API. Therefore, ExternalStrings should not be used internally. 3700 // API. Therefore, ExternalStrings should not be used internally.
3685 class ExternalString: public String { 3701 class ExternalString: public String {
3686 public: 3702 public:
3687 // Casting 3703 // Casting
3688 static inline ExternalString* cast(Object* obj); 3704 static inline ExternalString* cast(Object* obj);
3689 3705
3690 // Layout description. 3706 // Layout description.
3691 static const int kResourceOffset = String::kSize; 3707 static const int kResourceOffset = OBJECT_SIZE_ALIGN(String::kSize);
3692 static const int kSize = kResourceOffset + kPointerSize; 3708 static const int kSize = kResourceOffset + kPointerSize;
3693 3709
3694 private: 3710 private:
3695 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); 3711 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
3696 }; 3712 };
3697 3713
3698 3714
3699 // The ExternalAsciiString class is an external string backed by an 3715 // The ExternalAsciiString class is an external string backed by an
3700 // ASCII string. 3716 // ASCII string.
3701 class ExternalAsciiString: public ExternalString { 3717 class ExternalAsciiString: public ExternalString {
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after
4141 static inline ObjectTemplateInfo* cast(Object* obj); 4157 static inline ObjectTemplateInfo* cast(Object* obj);
4142 4158
4143 #ifdef DEBUG 4159 #ifdef DEBUG
4144 void ObjectTemplateInfoPrint(); 4160 void ObjectTemplateInfoPrint();
4145 void ObjectTemplateInfoVerify(); 4161 void ObjectTemplateInfoVerify();
4146 #endif 4162 #endif
4147 4163
4148 static const int kConstructorOffset = TemplateInfo::kHeaderSize; 4164 static const int kConstructorOffset = TemplateInfo::kHeaderSize;
4149 static const int kInternalFieldCountOffset = 4165 static const int kInternalFieldCountOffset =
4150 kConstructorOffset + kPointerSize; 4166 kConstructorOffset + kPointerSize;
4151 static const int kSize = kInternalFieldCountOffset + kHeaderSize; 4167 static const int kSize = kInternalFieldCountOffset + kPointerSize;
Erik Corry 2009/05/18 11:52:11 Good catch.
4152 }; 4168 };
4153 4169
4154 4170
4155 class SignatureInfo: public Struct { 4171 class SignatureInfo: public Struct {
4156 public: 4172 public:
4157 DECL_ACCESSORS(receiver, Object) 4173 DECL_ACCESSORS(receiver, Object)
4158 DECL_ACCESSORS(args, Object) 4174 DECL_ACCESSORS(args, Object)
4159 4175
4160 static inline SignatureInfo* cast(Object* obj); 4176 static inline SignatureInfo* cast(Object* obj);
4161 4177
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 } else { 4388 } else {
4373 value &= ~(1 << bit_position); 4389 value &= ~(1 << bit_position);
4374 } 4390 }
4375 return value; 4391 return value;
4376 } 4392 }
4377 }; 4393 };
4378 4394
4379 } } // namespace v8::internal 4395 } } // namespace v8::internal
4380 4396
4381 #endif // V8_OBJECTS_H_ 4397 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698