OLD | NEW |
---|---|
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 4201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4212 unsigned chars); | 4212 unsigned chars); |
4213 | 4213 |
4214 // Identify the map for the external string/symbol with a particular length. | 4214 // Identify the map for the external string/symbol with a particular length. |
4215 static inline Map* StringMap(int length); | 4215 static inline Map* StringMap(int length); |
4216 static inline Map* SymbolMap(int length); | 4216 static inline Map* SymbolMap(int length); |
4217 private: | 4217 private: |
4218 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); | 4218 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalTwoByteString); |
4219 }; | 4219 }; |
4220 | 4220 |
4221 | 4221 |
4222 // Utility superclass for stack-allocated objects that must be updated | |
4223 // on gc. It provides two ways for the gc to update instances, either | |
iposva
2009/09/30 22:19:05
gc -> GC
| |
4224 // iterating or updating after gc. | |
4225 class Relocatable BASE_EMBEDDED { | |
4226 public: | |
iposva
2009/09/30 22:19:05
Presubmit Check: Fail
| |
4227 inline Relocatable() : prev_(top_) { top_ = this; } | |
4228 virtual ~Relocatable() { ASSERT_EQ(top_, this); top_ = prev_; } | |
iposva
2009/09/30 22:19:05
Presubmit Check: Fail
| |
4229 virtual void IterateInstance(ObjectVisitor* v) { } | |
4230 virtual void PostGarbageCollection() { } | |
4231 | |
4232 static void PostGarbageCollectionProcessing(); | |
4233 static int ArchiveSpacePerThread(); | |
4234 static char* ArchiveState(char* to); | |
4235 static char* RestoreState(char* from); | |
4236 static void Iterate(ObjectVisitor* v); | |
4237 static void Iterate(ObjectVisitor* v, Relocatable* top); | |
4238 static char* Iterate(ObjectVisitor* v, char* t); | |
4239 private: | |
iposva
2009/09/30 22:19:05
Presubmit Check: Fail
| |
4240 static Relocatable* top_; | |
4241 Relocatable* prev_; | |
4242 }; | |
4243 | |
4244 | |
4222 // A flat string reader provides random access to the contents of a | 4245 // A flat string reader provides random access to the contents of a |
4223 // string independent of the character width of the string. The handle | 4246 // string independent of the character width of the string. The handle |
4224 // must be valid as long as the reader is being used. | 4247 // must be valid as long as the reader is being used. |
4225 class FlatStringReader BASE_EMBEDDED { | 4248 class FlatStringReader : public Relocatable { |
4226 public: | 4249 public: |
4227 explicit FlatStringReader(Handle<String> str); | 4250 explicit FlatStringReader(Handle<String> str); |
4228 explicit FlatStringReader(Vector<const char> input); | 4251 explicit FlatStringReader(Vector<const char> input); |
4229 ~FlatStringReader(); | 4252 void PostGarbageCollection(); |
4230 void RefreshState(); | |
4231 inline uc32 Get(int index); | 4253 inline uc32 Get(int index); |
4232 int length() { return length_; } | 4254 int length() { return length_; } |
4233 static void PostGarbageCollectionProcessing(); | |
4234 private: | 4255 private: |
4235 String** str_; | 4256 String** str_; |
4236 bool is_ascii_; | 4257 bool is_ascii_; |
4237 int length_; | 4258 int length_; |
4238 const void* start_; | 4259 const void* start_; |
4239 FlatStringReader* prev_; | |
4240 static FlatStringReader* top_; | |
4241 }; | 4260 }; |
4242 | 4261 |
4243 | 4262 |
4244 // Note that StringInputBuffers are not valid across a GC! To fix this | 4263 // Note that StringInputBuffers are not valid across a GC! To fix this |
4245 // it would have to store a String Handle instead of a String* and | 4264 // it would have to store a String Handle instead of a String* and |
4246 // AsciiStringReadBlock would have to be modified to use memcpy. | 4265 // AsciiStringReadBlock would have to be modified to use memcpy. |
4247 // | 4266 // |
4248 // StringInputBuffer is able to traverse any string regardless of how | 4267 // StringInputBuffer is able to traverse any string regardless of how |
4249 // deeply nested a sequence of ConsStrings it is made of. However, | 4268 // deeply nested a sequence of ConsStrings it is made of. However, |
4250 // performance will be better if deep strings are flattened before they | 4269 // performance will be better if deep strings are flattened before they |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4858 } else { | 4877 } else { |
4859 value &= ~(1 << bit_position); | 4878 value &= ~(1 << bit_position); |
4860 } | 4879 } |
4861 return value; | 4880 return value; |
4862 } | 4881 } |
4863 }; | 4882 }; |
4864 | 4883 |
4865 } } // namespace v8::internal | 4884 } } // namespace v8::internal |
4866 | 4885 |
4867 #endif // V8_OBJECTS_H_ | 4886 #endif // V8_OBJECTS_H_ |
OLD | NEW |