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

Side by Side Diff: src/objects.h

Issue 7778013: NewGC: Merge bleeding edge up to 9009. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
Patch Set: Created 9 years, 3 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')
Property Changes:
Modified: svn:mergeinfo
Merged /branches/bleeding_edge/src/objects.h:r8863-9019
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // - JSRegExp 56 // - JSRegExp
57 // - JSFunction 57 // - JSFunction
58 // - GlobalObject 58 // - GlobalObject
59 // - JSGlobalObject 59 // - JSGlobalObject
60 // - JSBuiltinsObject 60 // - JSBuiltinsObject
61 // - JSGlobalProxy 61 // - JSGlobalProxy
62 // - JSValue 62 // - JSValue
63 // - JSMessageObject 63 // - JSMessageObject
64 // - JSProxy 64 // - JSProxy
65 // - JSFunctionProxy 65 // - JSFunctionProxy
66 // - ByteArray
67 // - FreeSpace
68 // - ExternalArray
69 // - ExternalPixelArray
70 // - ExternalByteArray
71 // - ExternalUnsignedByteArray
72 // - ExternalShortArray
73 // - ExternalUnsignedShortArray
74 // - ExternalIntArray
75 // - ExternalUnsignedIntArray
76 // - ExternalFloatArray
77 // - FixedArrayBase 66 // - FixedArrayBase
67 // - ByteArray
78 // - FixedArray 68 // - FixedArray
79 // - DescriptorArray 69 // - DescriptorArray
80 // - HashTable 70 // - HashTable
81 // - Dictionary 71 // - Dictionary
82 // - SymbolTable 72 // - SymbolTable
83 // - CompilationCacheTable 73 // - CompilationCacheTable
84 // - CodeCacheHashTable 74 // - CodeCacheHashTable
85 // - MapCache 75 // - MapCache
86 // - Context 76 // - Context
87 // - JSFunctionResultCache 77 // - JSFunctionResultCache
88 // - SerializedScopeInfo 78 // - SerializedScopeInfo
89 // - FixedDoubleArray 79 // - FixedDoubleArray
80 // - ExternalArray
81 // - ExternalPixelArray
82 // - ExternalByteArray
83 // - ExternalUnsignedByteArray
84 // - ExternalShortArray
85 // - ExternalUnsignedShortArray
86 // - ExternalIntArray
87 // - ExternalUnsignedIntArray
88 // - ExternalFloatArray
90 // - String 89 // - String
91 // - SeqString 90 // - SeqString
92 // - SeqAsciiString 91 // - SeqAsciiString
93 // - SeqTwoByteString 92 // - SeqTwoByteString
94 // - ConsString 93 // - ConsString
95 // - ExternalString 94 // - ExternalString
96 // - ExternalAsciiString 95 // - ExternalAsciiString
97 // - ExternalTwoByteString 96 // - ExternalTwoByteString
98 // - HeapNumber 97 // - HeapNumber
99 // - Code 98 // - Code
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 V(CALL_HANDLER_INFO_TYPE) \ 317 V(CALL_HANDLER_INFO_TYPE) \
319 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 318 V(FUNCTION_TEMPLATE_INFO_TYPE) \
320 V(OBJECT_TEMPLATE_INFO_TYPE) \ 319 V(OBJECT_TEMPLATE_INFO_TYPE) \
321 V(SIGNATURE_INFO_TYPE) \ 320 V(SIGNATURE_INFO_TYPE) \
322 V(TYPE_SWITCH_INFO_TYPE) \ 321 V(TYPE_SWITCH_INFO_TYPE) \
323 V(SCRIPT_TYPE) \ 322 V(SCRIPT_TYPE) \
324 V(CODE_CACHE_TYPE) \ 323 V(CODE_CACHE_TYPE) \
325 V(POLYMORPHIC_CODE_CACHE_TYPE) \ 324 V(POLYMORPHIC_CODE_CACHE_TYPE) \
326 \ 325 \
327 V(FIXED_ARRAY_TYPE) \ 326 V(FIXED_ARRAY_TYPE) \
327 V(FIXED_DOUBLE_ARRAY_TYPE) \
328 V(SHARED_FUNCTION_INFO_TYPE) \ 328 V(SHARED_FUNCTION_INFO_TYPE) \
329 \ 329 \
330 V(JS_MESSAGE_OBJECT_TYPE) \ 330 V(JS_MESSAGE_OBJECT_TYPE) \
331 \ 331 \
332 V(JS_VALUE_TYPE) \ 332 V(JS_VALUE_TYPE) \
333 V(JS_OBJECT_TYPE) \ 333 V(JS_OBJECT_TYPE) \
334 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ 334 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
335 V(JS_GLOBAL_OBJECT_TYPE) \ 335 V(JS_GLOBAL_OBJECT_TYPE) \
336 V(JS_BUILTINS_OBJECT_TYPE) \ 336 V(JS_BUILTINS_OBJECT_TYPE) \
337 V(JS_GLOBAL_PROXY_TYPE) \ 337 V(JS_GLOBAL_PROXY_TYPE) \
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
632 inline bool name(); \ 632 inline bool name(); \
633 inline void set_##name(bool value); \ 633 inline void set_##name(bool value); \
634 634
635 635
636 #define DECL_ACCESSORS(name, type) \ 636 #define DECL_ACCESSORS(name, type) \
637 inline type* name(); \ 637 inline type* name(); \
638 inline void set_##name(type* value, \ 638 inline void set_##name(type* value, \
639 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ 639 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
640 640
641 641
642 class DictionaryElementsAccessor;
642 class ElementsAccessor; 643 class ElementsAccessor;
644 class FixedArrayBase;
645 class ObjectVisitor;
643 class StringStream; 646 class StringStream;
644 class ObjectVisitor;
645 class DictionaryElementsAccessor;
646 class Failure; 647 class Failure;
647 648
648 struct ValueInfo : public Malloced { 649 struct ValueInfo : public Malloced {
649 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } 650 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { }
650 InstanceType type; 651 InstanceType type;
651 Object* ptr; 652 Object* ptr;
652 const char* str; 653 const char* str;
653 double number; 654 double number;
654 }; 655 };
655 656
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 V(JSObject) \ 742 V(JSObject) \
742 V(JSContextExtensionObject) \ 743 V(JSContextExtensionObject) \
743 V(Map) \ 744 V(Map) \
744 V(DescriptorArray) \ 745 V(DescriptorArray) \
745 V(DeoptimizationInputData) \ 746 V(DeoptimizationInputData) \
746 V(DeoptimizationOutputData) \ 747 V(DeoptimizationOutputData) \
747 V(FixedArray) \ 748 V(FixedArray) \
748 V(FixedDoubleArray) \ 749 V(FixedDoubleArray) \
749 V(Context) \ 750 V(Context) \
750 V(GlobalContext) \ 751 V(GlobalContext) \
752 V(SerializedScopeInfo) \
751 V(JSFunction) \ 753 V(JSFunction) \
752 V(Code) \ 754 V(Code) \
753 V(Oddball) \ 755 V(Oddball) \
754 V(SharedFunctionInfo) \ 756 V(SharedFunctionInfo) \
755 V(JSValue) \ 757 V(JSValue) \
756 V(JSMessageObject) \ 758 V(JSMessageObject) \
757 V(StringWrapper) \ 759 V(StringWrapper) \
758 V(Foreign) \ 760 V(Foreign) \
759 V(Boolean) \ 761 V(Boolean) \
760 V(JSArray) \ 762 V(JSArray) \
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 // elements array can have one of three maps in this mode: 1379 // elements array can have one of three maps in this mode:
1378 // fixed_array_map, non_strict_arguments_elements_map or 1380 // fixed_array_map, non_strict_arguments_elements_map or
1379 // fixed_cow_array_map (for copy-on-write arrays). In the latter case 1381 // fixed_cow_array_map (for copy-on-write arrays). In the latter case
1380 // the elements array may be shared by a few objects and so before 1382 // the elements array may be shared by a few objects and so before
1381 // writing to any element the array must be copied. Use 1383 // writing to any element the array must be copied. Use
1382 // EnsureWritableFastElements in this case. 1384 // EnsureWritableFastElements in this case.
1383 // 1385 //
1384 // In the slow mode the elements is either a NumberDictionary, an 1386 // In the slow mode the elements is either a NumberDictionary, an
1385 // ExternalArray, or a FixedArray parameter map for a (non-strict) 1387 // ExternalArray, or a FixedArray parameter map for a (non-strict)
1386 // arguments object. 1388 // arguments object.
1387 DECL_ACCESSORS(elements, HeapObject) 1389 DECL_ACCESSORS(elements, FixedArrayBase)
1388 inline void initialize_elements(); 1390 inline void initialize_elements();
1389 MUST_USE_RESULT inline MaybeObject* ResetElements(); 1391 MUST_USE_RESULT inline MaybeObject* ResetElements();
1390 inline ElementsKind GetElementsKind(); 1392 inline ElementsKind GetElementsKind();
1391 inline ElementsAccessor* GetElementsAccessor(); 1393 inline ElementsAccessor* GetElementsAccessor();
1392 inline bool HasFastElements(); 1394 inline bool HasFastElements();
1393 inline bool HasFastDoubleElements(); 1395 inline bool HasFastDoubleElements();
1394 inline bool HasDictionaryElements(); 1396 inline bool HasDictionaryElements();
1395 inline bool HasExternalPixelElements(); 1397 inline bool HasExternalPixelElements();
1396 inline bool HasExternalArrayElements(); 1398 inline bool HasExternalArrayElements();
1397 inline bool HasExternalByteElements(); 1399 inline bool HasExternalByteElements();
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1969 inline void set_length(int value); 1971 inline void set_length(int value);
1970 1972
1971 inline static FixedArrayBase* cast(Object* object); 1973 inline static FixedArrayBase* cast(Object* object);
1972 1974
1973 // Layout description. 1975 // Layout description.
1974 // Length is smi tagged when it is stored. 1976 // Length is smi tagged when it is stored.
1975 static const int kLengthOffset = HeapObject::kHeaderSize; 1977 static const int kLengthOffset = HeapObject::kHeaderSize;
1976 static const int kHeaderSize = kLengthOffset + kPointerSize; 1978 static const int kHeaderSize = kLengthOffset + kPointerSize;
1977 }; 1979 };
1978 1980
1981
1979 class FixedDoubleArray; 1982 class FixedDoubleArray;
1980 1983
1981 // FixedArray describes fixed-sized arrays with element type Object*. 1984 // FixedArray describes fixed-sized arrays with element type Object*.
1982 class FixedArray: public FixedArrayBase { 1985 class FixedArray: public FixedArrayBase {
1983 public: 1986 public:
1984 // Setter and getter for elements. 1987 // Setter and getter for elements.
1985 inline Object* get(int index); 1988 inline Object* get(int index);
1986 // Setter that uses write barrier. 1989 // Setter that uses write barrier.
1987 inline void set(int index, Object* value); 1990 inline void set(int index, Object* value);
1988 inline bool is_the_hole(int index); 1991 inline bool is_the_hole(int index);
(...skipping 24 matching lines...) Expand all
2013 // Copy operations. 2016 // Copy operations.
2014 MUST_USE_RESULT inline MaybeObject* Copy(); 2017 MUST_USE_RESULT inline MaybeObject* Copy();
2015 MUST_USE_RESULT MaybeObject* CopySize(int new_length); 2018 MUST_USE_RESULT MaybeObject* CopySize(int new_length);
2016 2019
2017 // Add the elements of a JSArray to this FixedArray. 2020 // Add the elements of a JSArray to this FixedArray.
2018 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array); 2021 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array);
2019 2022
2020 // Compute the union of this and other. 2023 // Compute the union of this and other.
2021 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other); 2024 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other);
2022 2025
2023 // Compute the union of this and other.
2024 MUST_USE_RESULT MaybeObject* UnionOfDoubleKeys(
2025 FixedDoubleArray* other);
2026
2027 // Copy a sub array from the receiver to dest. 2026 // Copy a sub array from the receiver to dest.
2028 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); 2027 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
2029 2028
2030 // Garbage collection support. 2029 // Garbage collection support.
2031 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } 2030 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
2032 2031
2033 // Code Generation support. 2032 // Code Generation support.
2034 static int OffsetOfElementAt(int index) { return SizeFor(index); } 2033 static int OffsetOfElementAt(int index) { return SizeFor(index); }
2035 2034
2036 // Casting. 2035 // Casting.
(...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after
2941 static inline NormalizedMapCache* cast(Object* obj); 2940 static inline NormalizedMapCache* cast(Object* obj);
2942 2941
2943 #ifdef DEBUG 2942 #ifdef DEBUG
2944 void NormalizedMapCacheVerify(); 2943 void NormalizedMapCacheVerify();
2945 #endif 2944 #endif
2946 }; 2945 };
2947 2946
2948 2947
2949 // ByteArray represents fixed sized byte arrays. Used for the relocation info 2948 // ByteArray represents fixed sized byte arrays. Used for the relocation info
2950 // that is attached to code objects. 2949 // that is attached to code objects.
2951 class ByteArray: public HeapObject { 2950 class ByteArray: public FixedArrayBase {
2952 public: 2951 public:
2953 // [length]: length of the array.
2954 inline int length();
2955 inline void set_length(int value);
2956
2957 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } 2952 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); }
2958 2953
2959 // Setter and getter. 2954 // Setter and getter.
2960 inline byte get(int index); 2955 inline byte get(int index);
2961 inline void set(int index, byte value); 2956 inline void set(int index, byte value);
2962 2957
2963 // Treat contents as an int array. 2958 // Treat contents as an int array.
2964 inline int get_int(int index); 2959 inline int get_int(int index);
2965 2960
2966 static int SizeFor(int length) { 2961 static int SizeFor(int length) {
(...skipping 26 matching lines...) Expand all
2993 inline void ByteArrayPrint() { 2988 inline void ByteArrayPrint() {
2994 ByteArrayPrint(stdout); 2989 ByteArrayPrint(stdout);
2995 } 2990 }
2996 void ByteArrayPrint(FILE* out); 2991 void ByteArrayPrint(FILE* out);
2997 #endif 2992 #endif
2998 #ifdef DEBUG 2993 #ifdef DEBUG
2999 void ByteArrayVerify(); 2994 void ByteArrayVerify();
3000 #endif 2995 #endif
3001 2996
3002 // Layout description. 2997 // Layout description.
3003 // Length is smi tagged when it is stored.
3004 static const int kLengthOffset = HeapObject::kHeaderSize;
3005 static const int kHeaderSize = kLengthOffset + kPointerSize;
3006
3007 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 2998 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3008 2999
3009 // Maximal memory consumption for a single ByteArray. 3000 // Maximal memory consumption for a single ByteArray.
3010 static const int kMaxSize = 512 * MB; 3001 static const int kMaxSize = 512 * MB;
3011 // Maximal length of a single ByteArray. 3002 // Maximal length of a single ByteArray.
3012 static const int kMaxLength = kMaxSize - kHeaderSize; 3003 static const int kMaxLength = kMaxSize - kHeaderSize;
3013 3004
3014 private: 3005 private:
3015 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 3006 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
3016 }; 3007 };
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3058 // which live outside the JavaScript heap. Its subclasses are used to 3049 // which live outside the JavaScript heap. Its subclasses are used to
3059 // implement the CanvasArray types being defined in the WebGL 3050 // implement the CanvasArray types being defined in the WebGL
3060 // specification. As of this writing the first public draft is not yet 3051 // specification. As of this writing the first public draft is not yet
3061 // available, but Khronos members can access the draft at: 3052 // available, but Khronos members can access the draft at:
3062 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html 3053 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html
3063 // 3054 //
3064 // The semantics of these arrays differ from CanvasPixelArray. 3055 // The semantics of these arrays differ from CanvasPixelArray.
3065 // Out-of-range values passed to the setter are converted via a C 3056 // Out-of-range values passed to the setter are converted via a C
3066 // cast, not clamping. Out-of-range indices cause exceptions to be 3057 // cast, not clamping. Out-of-range indices cause exceptions to be
3067 // raised rather than being silently ignored. 3058 // raised rather than being silently ignored.
3068 class ExternalArray: public HeapObject { 3059 class ExternalArray: public FixedArrayBase {
3069 public: 3060 public:
3070 // [length]: length of the array.
3071 inline int length();
3072 inline void set_length(int value);
3073 3061
3074 inline bool is_the_hole(int index) { return false; } 3062 inline bool is_the_hole(int index) { return false; }
3075 3063
3076 // [external_pointer]: The pointer to the external memory area backing this 3064 // [external_pointer]: The pointer to the external memory area backing this
3077 // external array. 3065 // external array.
3078 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store. 3066 DECL_ACCESSORS(external_pointer, void) // Pointer to the data store.
3079 3067
3080 // Casting. 3068 // Casting.
3081 static inline ExternalArray* cast(Object* obj); 3069 static inline ExternalArray* cast(Object* obj);
3082 3070
3083 // Maximal acceptable length for an external array. 3071 // Maximal acceptable length for an external array.
3084 static const int kMaxLength = 0x3fffffff; 3072 static const int kMaxLength = 0x3fffffff;
3085 3073
3086 // ExternalArray headers are not quadword aligned. 3074 // ExternalArray headers are not quadword aligned.
3087 static const int kLengthOffset = HeapObject::kHeaderSize;
3088 static const int kExternalPointerOffset = 3075 static const int kExternalPointerOffset =
3089 POINTER_SIZE_ALIGN(kLengthOffset + kIntSize); 3076 POINTER_SIZE_ALIGN(FixedArrayBase::kLengthOffset + kPointerSize);
3090 static const int kHeaderSize = kExternalPointerOffset + kPointerSize; 3077 static const int kHeaderSize = kExternalPointerOffset + kPointerSize;
3091 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); 3078 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
3092 3079
3093 private: 3080 private:
3094 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray); 3081 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalArray);
3095 }; 3082 };
3096 3083
3097 3084
3098 // A ExternalPixelArray represents a fixed-size byte array with special 3085 // A ExternalPixelArray represents a fixed-size byte array with special
3099 // semantics used for implementing the CanvasPixelArray object. Please see the 3086 // semantics used for implementing the CanvasPixelArray object. Please see the
(...skipping 1265 matching lines...) Expand 10 before | Expand all | Expand 10 after
4365 // on the object (the one the id is set for), and a label. 4352 // on the object (the one the id is set for), and a label.
4366 // 4353 //
4367 // Installation of ids for the selected builtin functions is handled 4354 // Installation of ids for the selected builtin functions is handled
4368 // by the bootstrapper. 4355 // by the bootstrapper.
4369 // 4356 //
4370 // NOTE: Order is important: math functions should be at the end of 4357 // NOTE: Order is important: math functions should be at the end of
4371 // the list and MathFloor should be the first math function. 4358 // the list and MathFloor should be the first math function.
4372 #define FUNCTIONS_WITH_ID_LIST(V) \ 4359 #define FUNCTIONS_WITH_ID_LIST(V) \
4373 V(Array.prototype, push, ArrayPush) \ 4360 V(Array.prototype, push, ArrayPush) \
4374 V(Array.prototype, pop, ArrayPop) \ 4361 V(Array.prototype, pop, ArrayPop) \
4362 V(Function.prototype, apply, FunctionApply) \
4375 V(String.prototype, charCodeAt, StringCharCodeAt) \ 4363 V(String.prototype, charCodeAt, StringCharCodeAt) \
4376 V(String.prototype, charAt, StringCharAt) \ 4364 V(String.prototype, charAt, StringCharAt) \
4377 V(String, fromCharCode, StringFromCharCode) \ 4365 V(String, fromCharCode, StringFromCharCode) \
4378 V(Math, floor, MathFloor) \ 4366 V(Math, floor, MathFloor) \
4379 V(Math, round, MathRound) \ 4367 V(Math, round, MathRound) \
4380 V(Math, ceil, MathCeil) \ 4368 V(Math, ceil, MathCeil) \
4381 V(Math, abs, MathAbs) \ 4369 V(Math, abs, MathAbs) \
4382 V(Math, log, MathLog) \ 4370 V(Math, log, MathLog) \
4383 V(Math, sin, MathSin) \ 4371 V(Math, sin, MathSin) \
4384 V(Math, cos, MathCos) \ 4372 V(Math, cos, MathCos) \
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after
5717 inline explicit StringShape(InstanceType t); 5705 inline explicit StringShape(InstanceType t);
5718 inline bool IsSequential(); 5706 inline bool IsSequential();
5719 inline bool IsExternal(); 5707 inline bool IsExternal();
5720 inline bool IsCons(); 5708 inline bool IsCons();
5721 inline bool IsExternalAscii(); 5709 inline bool IsExternalAscii();
5722 inline bool IsExternalTwoByte(); 5710 inline bool IsExternalTwoByte();
5723 inline bool IsSequentialAscii(); 5711 inline bool IsSequentialAscii();
5724 inline bool IsSequentialTwoByte(); 5712 inline bool IsSequentialTwoByte();
5725 inline bool IsSymbol(); 5713 inline bool IsSymbol();
5726 inline StringRepresentationTag representation_tag(); 5714 inline StringRepresentationTag representation_tag();
5715 inline uint32_t encoding_tag();
5727 inline uint32_t full_representation_tag(); 5716 inline uint32_t full_representation_tag();
5728 inline uint32_t size_tag(); 5717 inline uint32_t size_tag();
5729 #ifdef DEBUG 5718 #ifdef DEBUG
5730 inline uint32_t type() { return type_; } 5719 inline uint32_t type() { return type_; }
5731 inline void invalidate() { valid_ = false; } 5720 inline void invalidate() { valid_ = false; }
5732 inline bool valid() { return valid_; } 5721 inline bool valid() { return valid_; }
5733 #else 5722 #else
5734 inline void invalidate() { } 5723 inline void invalidate() { }
5735 #endif 5724 #endif
5736 5725
(...skipping 11 matching lines...) Expand all
5748 // The String abstract class captures JavaScript string values: 5737 // The String abstract class captures JavaScript string values:
5749 // 5738 //
5750 // Ecma-262: 5739 // Ecma-262:
5751 // 4.3.16 String Value 5740 // 4.3.16 String Value
5752 // A string value is a member of the type String and is a finite 5741 // A string value is a member of the type String and is a finite
5753 // ordered sequence of zero or more 16-bit unsigned integer values. 5742 // ordered sequence of zero or more 16-bit unsigned integer values.
5754 // 5743 //
5755 // All string values have a length field. 5744 // All string values have a length field.
5756 class String: public HeapObject { 5745 class String: public HeapObject {
5757 public: 5746 public:
5747 // Representation of the flat content of a String.
5748 // A non-flat string doesn't have flat content.
5749 // A flat string has content that's encoded as a sequence of either
5750 // ASCII chars or two-byte UC16.
5751 // Returned by String::GetFlatContent().
5752 class FlatContent {
5753 public:
5754 // Returns true if the string is flat and this structure contains content.
5755 bool IsFlat() { return state_ != NON_FLAT; }
5756 // Returns true if the structure contains ASCII content.
5757 bool IsAscii() { return state_ == ASCII; }
5758 // Returns true if the structure contains two-byte content.
5759 bool IsTwoByte() { return state_ == TWO_BYTE; }
5760
5761 // Return the ASCII content of the string. Only use if IsAscii() returns
5762 // true.
5763 Vector<const char> ToAsciiVector() {
5764 ASSERT_EQ(ASCII, state_);
5765 return Vector<const char>::cast(buffer_);
5766 }
5767 // Return the two-byte content of the string. Only use if IsTwoByte()
5768 // returns true.
5769 Vector<const uc16> ToUC16Vector() {
5770 ASSERT_EQ(TWO_BYTE, state_);
5771 return Vector<const uc16>::cast(buffer_);
5772 }
5773
5774 private:
5775 enum State { NON_FLAT, ASCII, TWO_BYTE };
5776
5777 // Constructors only used by String::GetFlatContent().
5778 explicit FlatContent(Vector<const char> chars)
5779 : buffer_(Vector<const byte>::cast(chars)),
5780 state_(ASCII) { }
5781 explicit FlatContent(Vector<const uc16> chars)
5782 : buffer_(Vector<const byte>::cast(chars)),
5783 state_(TWO_BYTE) { }
5784 FlatContent() : buffer_(), state_(NON_FLAT) { }
5785
5786 Vector<const byte> buffer_;
5787 State state_;
5788
5789 friend class String;
5790 };
5791
5758 // Get and set the length of the string. 5792 // Get and set the length of the string.
5759 inline int length(); 5793 inline int length();
5760 inline void set_length(int value); 5794 inline void set_length(int value);
5761 5795
5762 // Get and set the hash field of the string. 5796 // Get and set the hash field of the string.
5763 inline uint32_t hash_field(); 5797 inline uint32_t hash_field();
5764 inline void set_hash_field(uint32_t value); 5798 inline void set_hash_field(uint32_t value);
5765 5799
5766 inline bool IsAsciiRepresentation(); 5800 inline bool IsAsciiRepresentation();
5767 inline bool IsTwoByteRepresentation(); 5801 inline bool IsTwoByteRepresentation();
5768 5802
5769 // Returns whether this string has ascii chars, i.e. all of them can 5803 // Returns whether this string has only ASCII chars, i.e. all of them can
5770 // be ascii encoded. This might be the case even if the string is 5804 // be ASCII encoded. This might be the case even if the string is
5771 // two-byte. Such strings may appear when the embedder prefers 5805 // two-byte. Such strings may appear when the embedder prefers
5772 // two-byte external representations even for ascii data. 5806 // two-byte external representations even for ASCII data.
5773 // 5807 //
5774 // NOTE: this should be considered only a hint. False negatives are 5808 // NOTE: this should be considered only a hint. False negatives are
5775 // possible. 5809 // possible.
5776 inline bool HasOnlyAsciiChars(); 5810 inline bool HasOnlyAsciiChars();
5777 5811
5778 // Get and set individual two byte chars in the string. 5812 // Get and set individual two byte chars in the string.
5779 inline void Set(int index, uint16_t value); 5813 inline void Set(int index, uint16_t value);
5780 // Get individual two byte char in the string. Repeated calls 5814 // Get individual two byte char in the string. Repeated calls
5781 // to this method are not efficient unless the string is flat. 5815 // to this method are not efficient unless the string is flat.
5782 inline uint16_t Get(int index); 5816 inline uint16_t Get(int index);
(...skipping 13 matching lines...) Expand all
5796 // 5830 //
5797 // Use FlattenString from Handles.cc to flatten even in case an 5831 // Use FlattenString from Handles.cc to flatten even in case an
5798 // allocation failure happens. 5832 // allocation failure happens.
5799 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED); 5833 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED);
5800 5834
5801 // Convenience function. Has exactly the same behavior as 5835 // Convenience function. Has exactly the same behavior as
5802 // TryFlatten(), except in the case of failure returns the original 5836 // TryFlatten(), except in the case of failure returns the original
5803 // string. 5837 // string.
5804 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); 5838 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED);
5805 5839
5806 Vector<const char> ToAsciiVector(); 5840 // Tries to return the content of a flat string as a structure holding either
5807 Vector<const uc16> ToUC16Vector(); 5841 // a flat vector of char or of uc16.
5842 // If the string isn't flat, and therefore doesn't have flat content, the
5843 // returned structure will report so, and can't provide a vector of either
5844 // kind.
5845 FlatContent GetFlatContent();
5808 5846
5809 // Mark the string as an undetectable object. It only applies to 5847 // Mark the string as an undetectable object. It only applies to
5810 // ascii and two byte string types. 5848 // ascii and two byte string types.
5811 bool MarkAsUndetectable(); 5849 bool MarkAsUndetectable();
5812 5850
5813 // Return a substring. 5851 // Return a substring.
5814 MUST_USE_RESULT MaybeObject* SubString(int from, 5852 MUST_USE_RESULT MaybeObject* SubString(int from,
5815 int to, 5853 int to,
5816 PretenureFlag pretenure = NOT_TENURED); 5854 PretenureFlag pretenure = NOT_TENURED);
5817 5855
(...skipping 1426 matching lines...) Expand 10 before | Expand all | Expand 10 after
7244 } else { 7282 } else {
7245 value &= ~(1 << bit_position); 7283 value &= ~(1 << bit_position);
7246 } 7284 }
7247 return value; 7285 return value;
7248 } 7286 }
7249 }; 7287 };
7250 7288
7251 } } // namespace v8::internal 7289 } } // namespace v8::internal
7252 7290
7253 #endif // V8_OBJECTS_H_ 7291 #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