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

Side by Side Diff: src/objects.h

Issue 196139: X64: Convert smis to holding 32 bits of payload. (Closed)
Patch Set: Addressed review comments. Forwarded to head. Created 11 years, 2 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/macros.py ('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-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 886 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 // Layout description. 897 // Layout description.
898 static const int kHeaderSize = 0; // Object does not take up any space. 898 static const int kHeaderSize = 0; // Object does not take up any space.
899 899
900 private: 900 private:
901 DISALLOW_IMPLICIT_CONSTRUCTORS(Object); 901 DISALLOW_IMPLICIT_CONSTRUCTORS(Object);
902 }; 902 };
903 903
904 904
905 // Smi represents integer Numbers that can be stored in 31 bits. 905 // Smi represents integer Numbers that can be stored in 31 bits.
906 // Smis are immediate which means they are NOT allocated in the heap. 906 // Smis are immediate which means they are NOT allocated in the heap.
907 // The this pointer has the following format: [31 bit signed int] 0
908 // For long smis it has the following format:
909 // [32 bit signed int] [31 bits zero padding] 0
907 // Smi stands for small integer. 910 // Smi stands for small integer.
908 // The this pointer has the following format: [31 bit signed int] 0
909 // On 64-bit, the top 32 bits of the pointer is allowed to have any
910 // value.
911 class Smi: public Object { 911 class Smi: public Object {
912 public: 912 public:
913 // Returns the integer value. 913 // Returns the integer value.
914 inline int value(); 914 inline int value();
915 915
916 // Convert a value to a Smi object. 916 // Convert a value to a Smi object.
917 static inline Smi* FromInt(int value); 917 static inline Smi* FromInt(int value);
918 918
919 static inline Smi* FromIntptr(intptr_t value); 919 static inline Smi* FromIntptr(intptr_t value);
920 920
921 // Returns whether value can be represented in a Smi. 921 // Returns whether value can be represented in a Smi.
922 static inline bool IsValid(intptr_t value); 922 static inline bool IsValid(intptr_t value);
923 923
924 static inline bool IsIntptrValid(intptr_t);
925
926 // Casting. 924 // Casting.
927 static inline Smi* cast(Object* object); 925 static inline Smi* cast(Object* object);
928 926
929 // Dispatched behavior. 927 // Dispatched behavior.
930 void SmiPrint(); 928 void SmiPrint();
931 void SmiPrint(StringStream* accumulator); 929 void SmiPrint(StringStream* accumulator);
932 #ifdef DEBUG 930 #ifdef DEBUG
933 void SmiVerify(); 931 void SmiVerify();
934 #endif 932 #endif
935 933
936 static const int kSmiNumBits = 31; 934 static const int kMinValue = (-1 << (kSmiValueSize - 1));
937 // Min and max limits for Smi values. 935 static const int kMaxValue = -(kMinValue + 1);
938 static const int kMinValue = -(1 << (kSmiNumBits - 1));
939 static const int kMaxValue = (1 << (kSmiNumBits - 1)) - 1;
940 936
941 private: 937 private:
942 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi); 938 DISALLOW_IMPLICIT_CONSTRUCTORS(Smi);
943 }; 939 };
944 940
945 941
946 // Failure is used for reporting out of memory situations and 942 // Failure is used for reporting out of memory situations and
947 // propagating exceptions through the runtime system. Failure objects 943 // propagating exceptions through the runtime system. Failure objects
948 // are transient and cannot occur as part of the object graph. 944 // are transient and cannot occur as part of the object graph.
949 // 945 //
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
2488 Object* SetValue(uint32_t index, Object* value); 2484 Object* SetValue(uint32_t index, Object* value);
2489 2485
2490 // Casting. 2486 // Casting.
2491 static inline PixelArray* cast(Object* obj); 2487 static inline PixelArray* cast(Object* obj);
2492 2488
2493 #ifdef DEBUG 2489 #ifdef DEBUG
2494 void PixelArrayPrint(); 2490 void PixelArrayPrint();
2495 void PixelArrayVerify(); 2491 void PixelArrayVerify();
2496 #endif // DEBUG 2492 #endif // DEBUG
2497 2493
2494 // Maximal acceptable length for a pixel array.
2495 static const int kMaxLength = 0x3fffffff;
2496
2498 // PixelArray headers are not quadword aligned. 2497 // PixelArray headers are not quadword aligned.
2499 static const int kExternalPointerOffset = Array::kAlignedSize; 2498 static const int kExternalPointerOffset = Array::kAlignedSize;
2500 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; 2499 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
2501 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize); 2500 static const int kAlignedSize = OBJECT_SIZE_ALIGN(kHeaderSize);
2502 2501
2503 private: 2502 private:
2504 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray); 2503 DISALLOW_IMPLICIT_CONSTRUCTORS(PixelArray);
2505 }; 2504 };
2506 2505
2507 2506
(...skipping 1334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3842 // Array index strings this short can keep their index in the hash 3841 // Array index strings this short can keep their index in the hash
3843 // field. 3842 // field.
3844 static const int kMaxCachedArrayIndexLength = 7; 3843 static const int kMaxCachedArrayIndexLength = 7;
3845 3844
3846 // Shift constants for retriving length and hash code from 3845 // Shift constants for retriving length and hash code from
3847 // length/hash field. 3846 // length/hash field.
3848 static const int kHashShift = kNofLengthBitFields; 3847 static const int kHashShift = kNofLengthBitFields;
3849 static const int kShortLengthShift = kHashShift + kShortStringTag; 3848 static const int kShortLengthShift = kHashShift + kShortStringTag;
3850 static const int kMediumLengthShift = kHashShift + kMediumStringTag; 3849 static const int kMediumLengthShift = kHashShift + kMediumStringTag;
3851 static const int kLongLengthShift = kHashShift + kLongStringTag; 3850 static const int kLongLengthShift = kHashShift + kLongStringTag;
3851 // Maximal string length that can be stored in the hash/length field.
3852 static const int kMaxLength = (1 << (32 - kLongLengthShift)) - 1;
3852 3853
3853 // Limit for truncation in short printing. 3854 // Limit for truncation in short printing.
3854 static const int kMaxShortPrintLength = 1024; 3855 static const int kMaxShortPrintLength = 1024;
3855 3856
3856 // Support for regular expressions. 3857 // Support for regular expressions.
3857 const uc16* GetTwoByteData(); 3858 const uc16* GetTwoByteData();
3858 const uc16* GetTwoByteData(unsigned start); 3859 const uc16* GetTwoByteData(unsigned start);
3859 3860
3860 // Support for StringInputBuffer 3861 // Support for StringInputBuffer
3861 static const unibrow::byte* ReadBlock(String* input, 3862 static const unibrow::byte* ReadBlock(String* input,
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after
4884 } else { 4885 } else {
4885 value &= ~(1 << bit_position); 4886 value &= ~(1 << bit_position);
4886 } 4887 }
4887 return value; 4888 return value;
4888 } 4889 }
4889 }; 4890 };
4890 4891
4891 } } // namespace v8::internal 4892 } } // namespace v8::internal
4892 4893
4893 #endif // V8_OBJECTS_H_ 4894 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/macros.py ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698