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

Side by Side Diff: src/objects.h

Issue 7600025: Create a common subclass for arrays (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: review feedback Created 9 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « src/mips/stub-cache-mips.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 // - JSRegExp 55 // - JSRegExp
56 // - JSFunction 56 // - JSFunction
57 // - GlobalObject 57 // - GlobalObject
58 // - JSGlobalObject 58 // - JSGlobalObject
59 // - JSBuiltinsObject 59 // - JSBuiltinsObject
60 // - JSGlobalProxy 60 // - JSGlobalProxy
61 // - JSValue 61 // - JSValue
62 // - JSMessageObject 62 // - JSMessageObject
63 // - JSProxy 63 // - JSProxy
64 // - JSFunctionProxy 64 // - JSFunctionProxy
65 // - ByteArray
66 // - ExternalArray
67 // - ExternalPixelArray
68 // - ExternalByteArray
69 // - ExternalUnsignedByteArray
70 // - ExternalShortArray
71 // - ExternalUnsignedShortArray
72 // - ExternalIntArray
73 // - ExternalUnsignedIntArray
74 // - ExternalFloatArray
75 // - FixedArrayBase 65 // - FixedArrayBase
66 // - ByteArray
76 // - FixedArray 67 // - FixedArray
77 // - DescriptorArray 68 // - DescriptorArray
78 // - HashTable 69 // - HashTable
79 // - Dictionary 70 // - Dictionary
80 // - SymbolTable 71 // - SymbolTable
81 // - CompilationCacheTable 72 // - CompilationCacheTable
82 // - CodeCacheHashTable 73 // - CodeCacheHashTable
83 // - MapCache 74 // - MapCache
84 // - Context 75 // - Context
85 // - JSFunctionResultCache 76 // - JSFunctionResultCache
86 // - SerializedScopeInfo 77 // - SerializedScopeInfo
87 // - FixedDoubleArray 78 // - FixedDoubleArray
79 // - ExternalArray
80 // - ExternalPixelArray
81 // - ExternalByteArray
82 // - ExternalUnsignedByteArray
83 // - ExternalShortArray
84 // - ExternalUnsignedShortArray
85 // - ExternalIntArray
86 // - ExternalUnsignedIntArray
87 // - ExternalFloatArray
88 // - String 88 // - String
89 // - SeqString 89 // - SeqString
90 // - SeqAsciiString 90 // - SeqAsciiString
91 // - SeqTwoByteString 91 // - SeqTwoByteString
92 // - ConsString 92 // - ConsString
93 // - ExternalString 93 // - ExternalString
94 // - ExternalAsciiString 94 // - ExternalAsciiString
95 // - ExternalTwoByteString 95 // - ExternalTwoByteString
96 // - HeapNumber 96 // - HeapNumber
97 // - Code 97 // - Code
(...skipping 1979 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 inline void set_length(int value); 2077 inline void set_length(int value);
2078 2078
2079 inline static FixedArrayBase* cast(Object* object); 2079 inline static FixedArrayBase* cast(Object* object);
2080 2080
2081 // Layout description. 2081 // Layout description.
2082 // Length is smi tagged when it is stored. 2082 // Length is smi tagged when it is stored.
2083 static const int kLengthOffset = HeapObject::kHeaderSize; 2083 static const int kLengthOffset = HeapObject::kHeaderSize;
2084 static const int kHeaderSize = kLengthOffset + kPointerSize; 2084 static const int kHeaderSize = kLengthOffset + kPointerSize;
2085 }; 2085 };
2086 2086
2087
2087 class FixedDoubleArray; 2088 class FixedDoubleArray;
2088 2089
2089 // FixedArray describes fixed-sized arrays with element type Object*. 2090 // FixedArray describes fixed-sized arrays with element type Object*.
2090 class FixedArray: public FixedArrayBase { 2091 class FixedArray: public FixedArrayBase {
2091 public: 2092 public:
2092 // Setter and getter for elements. 2093 // Setter and getter for elements.
2093 inline Object* get(int index); 2094 inline Object* get(int index);
2094 // Setter that uses write barrier. 2095 // Setter that uses write barrier.
2095 inline void set(int index, Object* value); 2096 inline void set(int index, Object* value);
2096 inline bool is_the_hole(int index); 2097 inline bool is_the_hole(int index);
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 3047
3047 #ifdef DEBUG 3048 #ifdef DEBUG
3048 void NormalizedMapCacheVerify(); 3049 void NormalizedMapCacheVerify();
3049 #endif 3050 #endif
3050 }; 3051 };
3051 3052
3052 3053
3053 // ByteArray represents fixed sized byte arrays. Used by the outside world, 3054 // ByteArray represents fixed sized byte arrays. Used by the outside world,
3054 // such as PCRE, and also by the memory allocator and garbage collector to 3055 // such as PCRE, and also by the memory allocator and garbage collector to
3055 // fill in free blocks in the heap. 3056 // fill in free blocks in the heap.
3056 class ByteArray: public HeapObject { 3057 class ByteArray: public FixedArrayBase {
3057 public: 3058 public:
3058 // [length]: length of the array.
3059 inline int length();
3060 inline void set_length(int value);
3061
3062 // Setter and getter. 3059 // Setter and getter.
3063 inline byte get(int index); 3060 inline byte get(int index);
3064 inline void set(int index, byte value); 3061 inline void set(int index, byte value);
3065 3062
3066 // Treat contents as an int array. 3063 // Treat contents as an int array.
3067 inline int get_int(int index); 3064 inline int get_int(int index);
3068 3065
3069 static int SizeFor(int length) { 3066 static int SizeFor(int length) {
3070 return OBJECT_POINTER_ALIGN(kHeaderSize + length); 3067 return OBJECT_POINTER_ALIGN(kHeaderSize + length);
3071 } 3068 }
(...skipping 24 matching lines...) Expand all
3096 inline void ByteArrayPrint() { 3093 inline void ByteArrayPrint() {
3097 ByteArrayPrint(stdout); 3094 ByteArrayPrint(stdout);
3098 } 3095 }
3099 void ByteArrayPrint(FILE* out); 3096 void ByteArrayPrint(FILE* out);
3100 #endif 3097 #endif
3101 #ifdef DEBUG 3098 #ifdef DEBUG
3102 void ByteArrayVerify(); 3099 void ByteArrayVerify();
3103 #endif 3100 #endif
3104 3101
3105 // Layout description. 3102 // Layout description.
3106 // Length is smi tagged when it is stored.
3107 static const int kLengthOffset = HeapObject::kHeaderSize;
3108 static const int kHeaderSize = kLengthOffset + kPointerSize;
3109
3110 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 3103 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3111 3104
3112 // Maximal memory consumption for a single ByteArray. 3105 // Maximal memory consumption for a single ByteArray.
3113 static const int kMaxSize = 512 * MB; 3106 static const int kMaxSize = 512 * MB;
3114 // Maximal length of a single ByteArray. 3107 // Maximal length of a single ByteArray.
3115 static const int kMaxLength = kMaxSize - kHeaderSize; 3108 static const int kMaxLength = kMaxSize - kHeaderSize;
3116 3109
3117 private: 3110 private:
3118 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 3111 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
3119 }; 3112 };
3120 3113
3121 3114
3122 // An ExternalArray represents a fixed-size array of primitive values 3115 // An ExternalArray represents a fixed-size array of primitive values
3123 // which live outside the JavaScript heap. Its subclasses are used to 3116 // which live outside the JavaScript heap. Its subclasses are used to
3124 // implement the CanvasArray types being defined in the WebGL 3117 // implement the CanvasArray types being defined in the WebGL
3125 // specification. As of this writing the first public draft is not yet 3118 // specification. As of this writing the first public draft is not yet
3126 // available, but Khronos members can access the draft at: 3119 // available, but Khronos members can access the draft at:
3127 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html 3120 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html
3128 // 3121 //
3129 // The semantics of these arrays differ from CanvasPixelArray. 3122 // The semantics of these arrays differ from CanvasPixelArray.
3130 // Out-of-range values passed to the setter are converted via a C 3123 // Out-of-range values passed to the setter are converted via a C
3131 // cast, not clamping. Out-of-range indices cause exceptions to be 3124 // cast, not clamping. Out-of-range indices cause exceptions to be
3132 // raised rather than being silently ignored. 3125 // raised rather than being silently ignored.
3133 class ExternalArray: public HeapObject { 3126 class ExternalArray: public FixedArrayBase {
3134 public: 3127 public:
3135 // [length]: length of the array.
3136 inline int length();
3137 inline void set_length(int value);
3138 3128
3139 inline bool is_the_hole(int index) { return false; } 3129 inline bool is_the_hole(int index) { return false; }
3140 3130
3141 // [external_pointer]: The pointer to the external memory area backing this 3131 // [external_pointer]: The pointer to the external memory area backing this
3142 // external array. 3132 // external array.
3143 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. 3133 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store.
3144 3134
3145 // Casting. 3135 // Casting.
3146 static inline ExternalArray* cast(Object* obj); 3136 static inline ExternalArray* cast(Object* obj);
3147 3137
3148 // Maximal acceptable length for an external array. 3138 // Maximal acceptable length for an external array.
3149 static const int kMaxLength = 0x3fffffff; 3139 static const int kMaxLength = 0x3fffffff;
3150 3140
3151 // ExternalArray headers are not quadword aligned. 3141 // ExternalArray headers are not quadword aligned.
3152 static const int kLengthOffset = HeapObject::kHeaderSize;
3153 static const int kExternalPointerOffset = 3142 static const int kExternalPointerOffset =
3154 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); 3143 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize);
3155 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; 3144 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
3156 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 3145 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3157 3146
3158 private: 3147 private:
3159 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); 3148 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray);
3160 }; 3149 };
3161 3150
3162 3151
3163 // A ExternalPixelArray represents a fixed-size byte array with special 3152 // A ExternalPixelArray represents a fixed-size byte array with special
3164 // semantics used for implementing the CanvasPixelArray object. Please see the 3153 // semantics used for implementing the CanvasPixelArray object. Please see the
(...skipping 4156 matching lines...) Expand 10 before | Expand all | Expand 10 after
7321 } else { 7310 } else {
7322 value &= ~(1 << bit_position); 7311 value &= ~(1 << bit_position);
7323 } 7312 }
7324 return value; 7313 return value;
7325 } 7314 }
7326 }; 7315 };
7327 7316
7328 } } // namespace v8::internal 7317 } } // namespace v8::internal
7329 7318
7330 #endif // V8_OBJECTS_H_ 7319 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mips/stub-cache-mips.cc ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698