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

Side by Side Diff: src/objects.h

Issue 9181: Push string shape fixes to trunk (version 0.4.3.1). (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 12 years, 1 month 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/log.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 3006 matching lines...) Expand 10 before | Expand all | Expand 10 after
3017 bool is_valid_; 3017 bool is_valid_;
3018 }; 3018 };
3019 3019
3020 3020
3021 // The characteristics of a string are stored in its map. Retrieving these 3021 // The characteristics of a string are stored in its map. Retrieving these
3022 // few bits of information is moderately expensive, involving two memory 3022 // few bits of information is moderately expensive, involving two memory
3023 // loads where the second is dependent on the first. To improve efficiency 3023 // loads where the second is dependent on the first. To improve efficiency
3024 // the shape of the string is given its own class so that it can be retrieved 3024 // the shape of the string is given its own class so that it can be retrieved
3025 // once and used for several string operations. A StringShape is small enough 3025 // once and used for several string operations. A StringShape is small enough
3026 // to be passed by value and is immutable, but be aware that flattening a 3026 // to be passed by value and is immutable, but be aware that flattening a
3027 // string can potentially alter its shape. 3027 // string can potentially alter its shape. Also be aware that a GC caused by
3028 // something else can alter the shape of a string due to ConsString
3029 // shortcutting.
3028 // 3030 //
3029 // Most of the methods designed to interrogate a string as to its exact nature 3031 // Most of the methods designed to interrogate a string as to its exact nature
3030 // have been made into methods on StringShape in order to encourage the use of 3032 // have been made into methods on StringShape in order to encourage the use of
3031 // StringShape. The String class has both a length() and a length(StringShape) 3033 // StringShape. The String class has both a length() and a length(StringShape)
3032 // operation. The former is simpler to type, but the latter is faster if you 3034 // operation. The former is simpler to type, but the latter is faster if you
3033 // need the StringShape for some other operation immediately before or after. 3035 // need the StringShape for some other operation immediately before or after.
3034 class StringShape BASE_EMBEDDED { 3036 class StringShape BASE_EMBEDDED {
3035 public: 3037 public:
3036 inline explicit StringShape(String* s); 3038 inline explicit StringShape(String* s);
3037 inline explicit StringShape(Map* s); 3039 inline explicit StringShape(Map* s);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
3109 inline void TryFlatten(StringShape shape); 3111 inline void TryFlatten(StringShape shape);
3110 3112
3111 Vector<const char> ToAsciiVector(); 3113 Vector<const char> ToAsciiVector();
3112 Vector<const uc16> ToUC16Vector(); 3114 Vector<const uc16> ToUC16Vector();
3113 3115
3114 // Mark the string as an undetectable object. It only applies to 3116 // Mark the string as an undetectable object. It only applies to
3115 // ascii and two byte string types. 3117 // ascii and two byte string types.
3116 bool MarkAsUndetectable(); 3118 bool MarkAsUndetectable();
3117 3119
3118 // Slice the string and return a substring. 3120 // Slice the string and return a substring.
3119 Object* Slice(StringShape shape, int from, int to); 3121 Object* Slice(int from, int to);
3120 3122
3121 // String equality operations. 3123 // String equality operations.
3122 inline bool Equals(String* other); 3124 inline bool Equals(String* other);
3123 bool IsEqualTo(Vector<const char> str); 3125 bool IsEqualTo(Vector<const char> str);
3124 3126
3125 // Return a UTF8 representation of the string. The string is null 3127 // Return a UTF8 representation of the string. The string is null
3126 // terminated but may optionally contain nulls. Length is returned 3128 // terminated but may optionally contain nulls. Length is returned
3127 // in length_output if length_output is not a null pointer The string 3129 // in length_output if length_output is not a null pointer The string
3128 // should be nearly flat, otherwise the performance of this method may 3130 // should be nearly flat, otherwise the performance of this method may
3129 // be very slow (quadratic in the length). Setting robustness_flag to 3131 // be very slow (quadratic in the length). Setting robustness_flag to
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
3464 inline String* buffer(); 3466 inline String* buffer();
3465 inline void set_buffer(String* buffer); 3467 inline void set_buffer(String* buffer);
3466 3468
3467 // The start index of the slice. 3469 // The start index of the slice.
3468 inline int start(); 3470 inline int start();
3469 inline void set_start(int start); 3471 inline void set_start(int start);
3470 3472
3471 // Dispatched behavior. 3473 // Dispatched behavior.
3472 uint16_t SlicedStringGet(int index); 3474 uint16_t SlicedStringGet(int index);
3473 3475
3474 // Flatten any ConsString hiding behind this SlicedString.
3475 Object* SlicedStringFlatten();
3476
3477 // Casting. 3476 // Casting.
3478 static inline SlicedString* cast(Object* obj); 3477 static inline SlicedString* cast(Object* obj);
3479 3478
3480 // Garbage collection support. 3479 // Garbage collection support.
3481 void SlicedStringIterateBody(ObjectVisitor* v); 3480 void SlicedStringIterateBody(ObjectVisitor* v);
3482 3481
3483 // Layout description 3482 // Layout description
3484 static const int kBufferOffset = String::kSize; 3483 static const int kBufferOffset = String::kSize;
3485 static const int kStartOffset = kBufferOffset + kPointerSize; 3484 static const int kStartOffset = kBufferOffset + kPointerSize;
3486 static const int kSize = kStartOffset + kIntSize; 3485 static const int kSize = kStartOffset + kIntSize;
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
4166 } else { 4165 } else {
4167 value &= ~(1 << bit_position); 4166 value &= ~(1 << bit_position);
4168 } 4167 }
4169 return value; 4168 return value;
4170 } 4169 }
4171 }; 4170 };
4172 4171
4173 } } // namespace v8::internal 4172 } } // namespace v8::internal
4174 4173
4175 #endif // V8_OBJECTS_H_ 4174 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/log.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698