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

Side by Side Diff: src/objects.h

Issue 7618040: Version 3.5.5. (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: 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/mksnapshot.cc ('k') | src/objects.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 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 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 inline bool name(); \ 628 inline bool name(); \
629 inline void set_##name(bool value); \ 629 inline void set_##name(bool value); \
630 630
631 631
632 #define DECL_ACCESSORS(name, type) \ 632 #define DECL_ACCESSORS(name, type) \
633 inline type* name(); \ 633 inline type* name(); \
634 inline void set_##name(type* value, \ 634 inline void set_##name(type* value, \
635 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ 635 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
636 636
637 637
638 class DictionaryElementsAccessor;
638 class ElementsAccessor; 639 class ElementsAccessor;
640 class FixedArrayBase;
641 class ObjectVisitor;
639 class StringStream; 642 class StringStream;
640 class ObjectVisitor;
641 class DictionaryElementsAccessor;
642 643
643 struct ValueInfo : public Malloced { 644 struct ValueInfo : public Malloced {
644 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } 645 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { }
645 InstanceType type; 646 InstanceType type;
646 Object* ptr; 647 Object* ptr;
647 const char* str; 648 const char* str;
648 double number; 649 double number;
649 }; 650 };
650 651
651 652
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 V(JSObject) \ 737 V(JSObject) \
737 V(JSContextExtensionObject) \ 738 V(JSContextExtensionObject) \
738 V(Map) \ 739 V(Map) \
739 V(DescriptorArray) \ 740 V(DescriptorArray) \
740 V(DeoptimizationInputData) \ 741 V(DeoptimizationInputData) \
741 V(DeoptimizationOutputData) \ 742 V(DeoptimizationOutputData) \
742 V(FixedArray) \ 743 V(FixedArray) \
743 V(FixedDoubleArray) \ 744 V(FixedDoubleArray) \
744 V(Context) \ 745 V(Context) \
745 V(GlobalContext) \ 746 V(GlobalContext) \
747 V(SerializedScopeInfo) \
746 V(JSFunction) \ 748 V(JSFunction) \
747 V(Code) \ 749 V(Code) \
748 V(Oddball) \ 750 V(Oddball) \
749 V(SharedFunctionInfo) \ 751 V(SharedFunctionInfo) \
750 V(JSValue) \ 752 V(JSValue) \
751 V(JSMessageObject) \ 753 V(JSMessageObject) \
752 V(StringWrapper) \ 754 V(StringWrapper) \
753 V(Foreign) \ 755 V(Foreign) \
754 V(Boolean) \ 756 V(Boolean) \
755 V(JSArray) \ 757 V(JSArray) \
(...skipping 729 matching lines...) Expand 10 before | Expand all | Expand 10 after
1485 // elements array can have one of three maps in this mode: 1487 // elements array can have one of three maps in this mode:
1486 // fixed_array_map, non_strict_arguments_elements_map or 1488 // fixed_array_map, non_strict_arguments_elements_map or
1487 // fixed_cow_array_map (for copy-on-write arrays). In the latter case 1489 // fixed_cow_array_map (for copy-on-write arrays). In the latter case
1488 // the elements array may be shared by a few objects and so before 1490 // the elements array may be shared by a few objects and so before
1489 // writing to any element the array must be copied. Use 1491 // writing to any element the array must be copied. Use
1490 // EnsureWritableFastElements in this case. 1492 // EnsureWritableFastElements in this case.
1491 // 1493 //
1492 // In the slow mode the elements is either a NumberDictionary, an 1494 // In the slow mode the elements is either a NumberDictionary, an
1493 // ExternalArray, or a FixedArray parameter map for a (non-strict) 1495 // ExternalArray, or a FixedArray parameter map for a (non-strict)
1494 // arguments object. 1496 // arguments object.
1495 DECL_ACCESSORS(elements, HeapObject) 1497 DECL_ACCESSORS(elements, FixedArrayBase)
1496 inline void initialize_elements(); 1498 inline void initialize_elements();
1497 MUST_USE_RESULT inline MaybeObject* ResetElements(); 1499 MUST_USE_RESULT inline MaybeObject* ResetElements();
1498 inline ElementsKind GetElementsKind(); 1500 inline ElementsKind GetElementsKind();
1499 inline ElementsAccessor* GetElementsAccessor(); 1501 inline ElementsAccessor* GetElementsAccessor();
1500 inline bool HasFastElements(); 1502 inline bool HasFastElements();
1501 inline bool HasFastDoubleElements(); 1503 inline bool HasFastDoubleElements();
1502 inline bool HasDictionaryElements(); 1504 inline bool HasDictionaryElements();
1503 inline bool HasExternalPixelElements(); 1505 inline bool HasExternalPixelElements();
1504 inline bool HasExternalArrayElements(); 1506 inline bool HasExternalArrayElements();
1505 inline bool HasExternalByteElements(); 1507 inline bool HasExternalByteElements();
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 inline void set_length(int value); 2079 inline void set_length(int value);
2078 2080
2079 inline static FixedArrayBase* cast(Object* object); 2081 inline static FixedArrayBase* cast(Object* object);
2080 2082
2081 // Layout description. 2083 // Layout description.
2082 // Length is smi tagged when it is stored. 2084 // Length is smi tagged when it is stored.
2083 static const int kLengthOffset = HeapObject::kHeaderSize; 2085 static const int kLengthOffset = HeapObject::kHeaderSize;
2084 static const int kHeaderSize = kLengthOffset + kPointerSize; 2086 static const int kHeaderSize = kLengthOffset + kPointerSize;
2085 }; 2087 };
2086 2088
2089
2087 class FixedDoubleArray; 2090 class FixedDoubleArray;
2088 2091
2089 // FixedArray describes fixed-sized arrays with element type Object*. 2092 // FixedArray describes fixed-sized arrays with element type Object*.
2090 class FixedArray: public FixedArrayBase { 2093 class FixedArray: public FixedArrayBase {
2091 public: 2094 public:
2092 // Setter and getter for elements. 2095 // Setter and getter for elements.
2093 inline Object* get(int index); 2096 inline Object* get(int index);
2094 // Setter that uses write barrier. 2097 // Setter that uses write barrier.
2095 inline void set(int index, Object* value); 2098 inline void set(int index, Object* value);
2096 inline bool is_the_hole(int index); 2099 inline bool is_the_hole(int index);
(...skipping 949 matching lines...) Expand 10 before | Expand all | Expand 10 after
3046 3049
3047 #ifdef DEBUG 3050 #ifdef DEBUG
3048 void NormalizedMapCacheVerify(); 3051 void NormalizedMapCacheVerify();
3049 #endif 3052 #endif
3050 }; 3053 };
3051 3054
3052 3055
3053 // ByteArray represents fixed sized byte arrays. Used by the outside world, 3056 // 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 3057 // such as PCRE, and also by the memory allocator and garbage collector to
3055 // fill in free blocks in the heap. 3058 // fill in free blocks in the heap.
3056 class ByteArray: public HeapObject { 3059 class ByteArray: public FixedArrayBase {
3057 public: 3060 public:
3058 // [length]: length of the array.
3059 inline int length();
3060 inline void set_length(int value);
3061
3062 // Setter and getter. 3061 // Setter and getter.
3063 inline byte get(int index); 3062 inline byte get(int index);
3064 inline void set(int index, byte value); 3063 inline void set(int index, byte value);
3065 3064
3066 // Treat contents as an int array. 3065 // Treat contents as an int array.
3067 inline int get_int(int index); 3066 inline int get_int(int index);
3068 3067
3069 static int SizeFor(int length) { 3068 static int SizeFor(int length) {
3070 return OBJECT_POINTER_ALIGN(kHeaderSize + length); 3069 return OBJECT_POINTER_ALIGN(kHeaderSize + length);
3071 } 3070 }
(...skipping 24 matching lines...) Expand all
3096 inline void ByteArrayPrint() { 3095 inline void ByteArrayPrint() {
3097 ByteArrayPrint(stdout); 3096 ByteArrayPrint(stdout);
3098 } 3097 }
3099 void ByteArrayPrint(FILE* out); 3098 void ByteArrayPrint(FILE* out);
3100 #endif 3099 #endif
3101 #ifdef DEBUG 3100 #ifdef DEBUG
3102 void ByteArrayVerify(); 3101 void ByteArrayVerify();
3103 #endif 3102 #endif
3104 3103
3105 // Layout description. 3104 // 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); 3105 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3111 3106
3112 // Maximal memory consumption for a single ByteArray. 3107 // Maximal memory consumption for a single ByteArray.
3113 static const int kMaxSize = 512 * MB; 3108 static const int kMaxSize = 512 * MB;
3114 // Maximal length of a single ByteArray. 3109 // Maximal length of a single ByteArray.
3115 static const int kMaxLength = kMaxSize - kHeaderSize; 3110 static const int kMaxLength = kMaxSize - kHeaderSize;
3116 3111
3117 private: 3112 private:
3118 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 3113 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
3119 }; 3114 };
3120 3115
3121 3116
3122 // An ExternalArray represents a fixed-size array of primitive values 3117 // An ExternalArray represents a fixed-size array of primitive values
3123 // which live outside the JavaScript heap. Its subclasses are used to 3118 // which live outside the JavaScript heap. Its subclasses are used to
3124 // implement the CanvasArray types being defined in the WebGL 3119 // implement the CanvasArray types being defined in the WebGL
3125 // specification. As of this writing the first public draft is not yet 3120 // specification. As of this writing the first public draft is not yet
3126 // available, but Khronos members can access the draft at: 3121 // available, but Khronos members can access the draft at:
3127 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html 3122 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html
3128 // 3123 //
3129 // The semantics of these arrays differ from CanvasPixelArray. 3124 // The semantics of these arrays differ from CanvasPixelArray.
3130 // Out-of-range values passed to the setter are converted via a C 3125 // 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 3126 // cast, not clamping. Out-of-range indices cause exceptions to be
3132 // raised rather than being silently ignored. 3127 // raised rather than being silently ignored.
3133 class ExternalArray: public HeapObject { 3128 class ExternalArray: public FixedArrayBase {
3134 public: 3129 public:
3135 // [length]: length of the array.
3136 inline int length();
3137 inline void set_length(int value);
3138 3130
3139 inline bool is_the_hole(int index) { return false; } 3131 inline bool is_the_hole(int index) { return false; }
3140 3132
3141 // [external_pointer]: The pointer to the external memory area backing this 3133 // [external_pointer]: The pointer to the external memory area backing this
3142 // external array. 3134 // external array.
3143 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. 3135 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store.
3144 3136
3145 // Casting. 3137 // Casting.
3146 static inline ExternalArray* cast(Object* obj); 3138 static inline ExternalArray* cast(Object* obj);
3147 3139
3148 // Maximal acceptable length for an external array. 3140 // Maximal acceptable length for an external array.
3149 static const int kMaxLength = 0x3fffffff; 3141 static const int kMaxLength = 0x3fffffff;
3150 3142
3151 // ExternalArray headers are not quadword aligned. 3143 // ExternalArray headers are not quadword aligned.
3152 static const int kLengthOffset = HeapObject::kHeaderSize;
3153 static const int kExternalPointerOffset = 3144 static const int kExternalPointerOffset =
3154 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); 3145 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize);
3155 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; 3146 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
3156 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 3147 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3157 3148
3158 private: 3149 private:
3159 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); 3150 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray);
3160 }; 3151 };
3161 3152
3162 3153
3163 // A ExternalPixelArray represents a fixed-size byte array with special 3154 // A ExternalPixelArray represents a fixed-size byte array with special
3164 // semantics used for implementing the CanvasPixelArray object. Please see the 3155 // semantics used for implementing the CanvasPixelArray object. Please see the
(...skipping 1272 matching lines...) Expand 10 before | Expand all | Expand 10 after
4437 // on the object (the one the id is set for), and a label. 4428 // on the object (the one the id is set for), and a label.
4438 // 4429 //
4439 // Installation of ids for the selected builtin functions is handled 4430 // Installation of ids for the selected builtin functions is handled
4440 // by the bootstrapper. 4431 // by the bootstrapper.
4441 // 4432 //
4442 // NOTE: Order is important: math functions should be at the end of 4433 // NOTE: Order is important: math functions should be at the end of
4443 // the list and MathFloor should be the first math function. 4434 // the list and MathFloor should be the first math function.
4444 #define FUNCTIONS_WITH_ID_LIST(V) \ 4435 #define FUNCTIONS_WITH_ID_LIST(V) \
4445 V(Array.prototype, push, ArrayPush) \ 4436 V(Array.prototype, push, ArrayPush) \
4446 V(Array.prototype, pop, ArrayPop) \ 4437 V(Array.prototype, pop, ArrayPop) \
4438 V(Function.prototype, apply, FunctionApply) \
4447 V(String.prototype, charCodeAt, StringCharCodeAt) \ 4439 V(String.prototype, charCodeAt, StringCharCodeAt) \
4448 V(String.prototype, charAt, StringCharAt) \ 4440 V(String.prototype, charAt, StringCharAt) \
4449 V(String, fromCharCode, StringFromCharCode) \ 4441 V(String, fromCharCode, StringFromCharCode) \
4450 V(Math, floor, MathFloor) \ 4442 V(Math, floor, MathFloor) \
4451 V(Math, round, MathRound) \ 4443 V(Math, round, MathRound) \
4452 V(Math, ceil, MathCeil) \ 4444 V(Math, ceil, MathCeil) \
4453 V(Math, abs, MathAbs) \ 4445 V(Math, abs, MathAbs) \
4454 V(Math, log, MathLog) \ 4446 V(Math, log, MathLog) \
4455 V(Math, sin, MathSin) \ 4447 V(Math, sin, MathSin) \
4456 V(Math, cos, MathCos) \ 4448 V(Math, cos, MathCos) \
(...skipping 2863 matching lines...) Expand 10 before | Expand all | Expand 10 after
7320 } else { 7312 } else {
7321 value &= ~(1 << bit_position); 7313 value &= ~(1 << bit_position);
7322 } 7314 }
7323 return value; 7315 return value;
7324 } 7316 }
7325 }; 7317 };
7326 7318
7327 } } // namespace v8::internal 7319 } } // namespace v8::internal
7328 7320
7329 #endif // V8_OBJECTS_H_ 7321 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mksnapshot.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698