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

Side by Side Diff: runtime/vm/raw_object.h

Issue 2895183002: More compact string representation on 64 bit. (Closed)
Patch Set: Created 3 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 | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_RAW_OBJECT_H_ 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_
6 #define RUNTIME_VM_RAW_OBJECT_H_ 6 #define RUNTIME_VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 class RawObject { 259 class RawObject {
260 public: 260 public:
261 // The tags field which is a part of the object header uses the following 261 // The tags field which is a part of the object header uses the following
262 // bit fields for storing tags. 262 // bit fields for storing tags.
263 enum TagBits { 263 enum TagBits {
264 kMarkBit = 0, 264 kMarkBit = 0,
265 kCanonicalBit = 1, 265 kCanonicalBit = 1,
266 kVMHeapObjectBit = 2, 266 kVMHeapObjectBit = 2,
267 kRememberedBit = 3, 267 kRememberedBit = 3,
268 kReservedTagPos = 4, // kReservedBit{100K,1M,10M} 268 kReservedTagPos = 4, // kReservedBit{100K,1M,10M}
269 #if defined(ARCH_IS_32_BIT)
270 kReservedTagSize = 4, 269 kReservedTagSize = 4,
271 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 270 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8
272 kSizeTagSize = 8, 271 kSizeTagSize = 8,
273 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 272 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16
274 kClassIdTagSize = 16, 273 kClassIdTagSize = 16,
275 #elif defined(ARCH_IS_64_BIT)
276 kReservedTagSize = 12,
277 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 16
278 kSizeTagSize = 16,
279 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 32
280 kClassIdTagSize = 32,
281 #else
282 #error Unexpected architecture word size
283 #endif
284 }; 274 };
285 275
286 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte)); 276 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte));
287 277
288 // Encodes the object size in the tag in units of object alignment. 278 // Encodes the object size in the tag in units of object alignment.
289 class SizeTag { 279 class SizeTag {
290 public: 280 public:
291 static const intptr_t kMaxSizeTag = ((1 << RawObject::kSizeTagSize) - 1) 281 static const intptr_t kMaxSizeTag = ((1 << RawObject::kSizeTagSize) - 1)
292 << kObjectAlignmentLog2; 282 << kObjectAlignmentLog2;
293 283
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 friend class ClassStatsVisitor; 597 friend class ClassStatsVisitor;
608 template <bool> 598 template <bool>
609 friend class MarkingVisitorBase; 599 friend class MarkingVisitorBase;
610 friend class Mint; 600 friend class Mint;
611 friend class Object; 601 friend class Object;
612 friend class OneByteString; // StoreSmi 602 friend class OneByteString; // StoreSmi
613 friend class RawCode; 603 friend class RawCode;
614 friend class RawExternalTypedData; 604 friend class RawExternalTypedData;
615 friend class RawInstructions; 605 friend class RawInstructions;
616 friend class RawInstance; 606 friend class RawInstance;
607 friend class RawString;
617 friend class RawTypedData; 608 friend class RawTypedData;
618 friend class Scavenger; 609 friend class Scavenger;
619 friend class ScavengerVisitor; 610 friend class ScavengerVisitor;
620 friend class SizeExcludingClassVisitor; // GetClassId 611 friend class SizeExcludingClassVisitor; // GetClassId
621 friend class InstanceAccumulator; // GetClassId 612 friend class InstanceAccumulator; // GetClassId
622 friend class RetainingPathVisitor; // GetClassId 613 friend class RetainingPathVisitor; // GetClassId
623 friend class SkippedCodeFunctions; // StorePointer 614 friend class SkippedCodeFunctions; // StorePointer
624 friend class ImageReader; // tags_ check 615 friend class ImageReader; // tags_ check
625 friend class ImageWriter; 616 friend class ImageWriter;
626 friend class AssemblyImageWriter; 617 friend class AssemblyImageWriter;
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 }; 1847 };
1857 COMPILE_ASSERT(sizeof(RawDouble) == 16); 1848 COMPILE_ASSERT(sizeof(RawDouble) == 16);
1858 1849
1859 1850
1860 class RawString : public RawInstance { 1851 class RawString : public RawInstance {
1861 RAW_HEAP_OBJECT_IMPLEMENTATION(String); 1852 RAW_HEAP_OBJECT_IMPLEMENTATION(String);
1862 1853
1863 protected: 1854 protected:
1864 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1855 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1865 RawSmi* length_; 1856 RawSmi* length_;
1857 #if !defined(HASH_IN_OBJECT_HEADER)
1866 RawSmi* hash_; 1858 RawSmi* hash_;
1867 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); } 1859 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->hash_); }
1860 #else
1861 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1862 #endif
1868 1863
1864 private:
1869 friend class Library; 1865 friend class Library;
1866 friend class OneByteStringSerializationCluster;
1867 friend class TwoByteStringSerializationCluster;
1868 friend class OneByteStringDeserializationCluster;
1869 friend class TwoByteStringDeserializationCluster;
1870 friend class RODataSerializationCluster;
1870 }; 1871 };
1871 1872
1872 1873
1873 class RawOneByteString : public RawString { 1874 class RawOneByteString : public RawString {
1874 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); 1875 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString);
1875 1876
1876 // Variable length data follows here. 1877 // Variable length data follows here.
1877 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1878 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1878 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 1879 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1879 1880
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after
2446 inline intptr_t RawObject::NumberOfTypedDataClasses() { 2447 inline intptr_t RawObject::NumberOfTypedDataClasses() {
2447 // Make sure this is updated when new TypedData types are added. 2448 // Make sure this is updated when new TypedData types are added.
2448 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); 2449 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14);
2449 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid == 2450 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
2450 kTypedDataInt8ArrayViewCid + 15); 2451 kTypedDataInt8ArrayViewCid + 15);
2451 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2452 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2452 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2453 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2453 return (kNullCid - kTypedDataInt8ArrayCid); 2454 return (kNullCid - kTypedDataInt8ArrayCid);
2454 } 2455 }
2455 2456
2457
2456 } // namespace dart 2458 } // namespace dart
2457 2459
2458 #endif // RUNTIME_VM_RAW_OBJECT_H_ 2460 #endif // RUNTIME_VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698