Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 5273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5284 // Regular expressions | 5284 // Regular expressions |
| 5285 // The regular expression holds a single reference to a FixedArray in | 5285 // The regular expression holds a single reference to a FixedArray in |
| 5286 // the kDataOffset field. | 5286 // the kDataOffset field. |
| 5287 // The FixedArray contains the following data: | 5287 // The FixedArray contains the following data: |
| 5288 // - tag : type of regexp implementation (not compiled yet, atom or irregexp) | 5288 // - tag : type of regexp implementation (not compiled yet, atom or irregexp) |
| 5289 // - reference to the original source string | 5289 // - reference to the original source string |
| 5290 // - reference to the original flag string | 5290 // - reference to the original flag string |
| 5291 // If it is an atom regexp | 5291 // If it is an atom regexp |
| 5292 // - a reference to a literal string to search for | 5292 // - a reference to a literal string to search for |
| 5293 // If it is an irregexp regexp: | 5293 // If it is an irregexp regexp: |
| 5294 // - a reference to code for ASCII inputs (bytecode or compiled). | 5294 // - a reference to code for ASCII inputs (bytecode or compiled), or a smi |
| 5295 // - a reference to code for UC16 inputs (bytecode or compiled). | 5295 // used for tracking the last usage (used for code flushing). |
| 5296 // - a reference to code for UC16 inputs (bytecode or compiled), or a smi | |
| 5297 // used for tracking the last usage (used for code flushing).. | |
|
Erik Corry
2011/06/30 18:48:25
Missing description of the 'saved' fields.
| |
| 5296 // - max number of registers used by irregexp implementations. | 5298 // - max number of registers used by irregexp implementations. |
| 5297 // - number of capture registers (output values) of the regexp. | 5299 // - number of capture registers (output values) of the regexp. |
| 5298 class JSRegExp: public JSObject { | 5300 class JSRegExp: public JSObject { |
| 5299 public: | 5301 public: |
| 5300 // Meaning of Type: | 5302 // Meaning of Type: |
| 5301 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. | 5303 // NOT_COMPILED: Initial value. No data has been stored in the JSRegExp yet. |
| 5302 // ATOM: A simple string to match against using an indexOf operation. | 5304 // ATOM: A simple string to match against using an indexOf operation. |
| 5303 // IRREGEXP: Compiled with Irregexp. | 5305 // IRREGEXP: Compiled with Irregexp. |
| 5304 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. | 5306 // IRREGEXP_NATIVE: Compiled to native code with Irregexp. |
| 5305 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; | 5307 enum Type { NOT_COMPILED, ATOM, IRREGEXP }; |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 5318 | 5320 |
| 5319 DECL_ACCESSORS(data, Object) | 5321 DECL_ACCESSORS(data, Object) |
| 5320 | 5322 |
| 5321 inline Type TypeTag(); | 5323 inline Type TypeTag(); |
| 5322 inline int CaptureCount(); | 5324 inline int CaptureCount(); |
| 5323 inline Flags GetFlags(); | 5325 inline Flags GetFlags(); |
| 5324 inline String* Pattern(); | 5326 inline String* Pattern(); |
| 5325 inline Object* DataAt(int index); | 5327 inline Object* DataAt(int index); |
| 5326 // Set implementation data after the object has been prepared. | 5328 // Set implementation data after the object has been prepared. |
| 5327 inline void SetDataAt(int index, Object* value); | 5329 inline void SetDataAt(int index, Object* value); |
| 5330 | |
| 5331 // Used during GC when flushing code or setting age. | |
| 5332 inline Object* DataAtUnchecked(int index); | |
| 5333 inline void SetDataAtUnchecked(int index, Object* value, Heap* heap); | |
| 5334 inline Type TypeTagUnchecked(); | |
| 5335 | |
| 5328 static int code_index(bool is_ascii) { | 5336 static int code_index(bool is_ascii) { |
| 5329 if (is_ascii) { | 5337 if (is_ascii) { |
| 5330 return kIrregexpASCIICodeIndex; | 5338 return kIrregexpASCIICodeIndex; |
| 5331 } else { | 5339 } else { |
| 5332 return kIrregexpUC16CodeIndex; | 5340 return kIrregexpUC16CodeIndex; |
| 5333 } | 5341 } |
| 5334 } | 5342 } |
| 5335 | 5343 |
| 5344 static int saved_code_index(bool is_ascii) { | |
| 5345 if (is_ascii) { | |
| 5346 return kIrregexpASCIICodeSavedIndex; | |
| 5347 } else { | |
| 5348 return kIrregexpUC16CodeSavedIndex; | |
| 5349 } | |
| 5350 } | |
| 5351 | |
| 5336 static inline JSRegExp* cast(Object* obj); | 5352 static inline JSRegExp* cast(Object* obj); |
| 5337 | 5353 |
| 5338 // Dispatched behavior. | 5354 // Dispatched behavior. |
| 5339 #ifdef DEBUG | 5355 #ifdef DEBUG |
| 5340 void JSRegExpVerify(); | 5356 void JSRegExpVerify(); |
| 5341 #endif | 5357 #endif |
| 5342 | 5358 |
| 5343 static const int kDataOffset = JSObject::kHeaderSize; | 5359 static const int kDataOffset = JSObject::kHeaderSize; |
| 5344 static const int kSize = kDataOffset + kPointerSize; | 5360 static const int kSize = kDataOffset + kPointerSize; |
| 5345 | 5361 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 5356 static const int kAtomDataSize = kAtomPatternIndex + 1; | 5372 static const int kAtomDataSize = kAtomPatternIndex + 1; |
| 5357 | 5373 |
| 5358 // Irregexp compiled code or bytecode for ASCII. If compilation | 5374 // Irregexp compiled code or bytecode for ASCII. If compilation |
| 5359 // fails, this fields hold an exception object that should be | 5375 // fails, this fields hold an exception object that should be |
| 5360 // thrown if the regexp is used again. | 5376 // thrown if the regexp is used again. |
| 5361 static const int kIrregexpASCIICodeIndex = kDataIndex; | 5377 static const int kIrregexpASCIICodeIndex = kDataIndex; |
| 5362 // Irregexp compiled code or bytecode for UC16. If compilation | 5378 // Irregexp compiled code or bytecode for UC16. If compilation |
| 5363 // fails, this fields hold an exception object that should be | 5379 // fails, this fields hold an exception object that should be |
| 5364 // thrown if the regexp is used again. | 5380 // thrown if the regexp is used again. |
| 5365 static const int kIrregexpUC16CodeIndex = kDataIndex + 1; | 5381 static const int kIrregexpUC16CodeIndex = kDataIndex + 1; |
| 5382 | |
| 5383 // Saved instance of Irregexp compiled code or bytecode for ASCII that | |
| 5384 // is a potential candidate for flushing. | |
| 5385 static const int kIrregexpASCIICodeSavedIndex = kDataIndex + 2; | |
| 5386 // Saved instance of Irregexp compiled code or bytecode for UC16 that is | |
| 5387 // a potential candidate for flushing. | |
| 5388 static const int kIrregexpUC16CodeSavedIndex = kDataIndex + 3; | |
| 5389 | |
| 5366 // Maximal number of registers used by either ASCII or UC16. | 5390 // Maximal number of registers used by either ASCII or UC16. |
| 5367 // Only used to check that there is enough stack space | 5391 // Only used to check that there is enough stack space |
| 5368 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 2; | 5392 static const int kIrregexpMaxRegisterCountIndex = kDataIndex + 4; |
| 5369 // Number of captures in the compiled regexp. | 5393 // Number of captures in the compiled regexp. |
| 5370 static const int kIrregexpCaptureCountIndex = kDataIndex + 3; | 5394 static const int kIrregexpCaptureCountIndex = kDataIndex + 5; |
| 5371 | 5395 |
| 5372 static const int kIrregexpDataSize = kIrregexpCaptureCountIndex + 1; | 5396 static const int kIrregexpDataSize = kIrregexpCaptureCountIndex + 1; |
| 5373 | 5397 |
| 5374 // Offsets directly into the data fixed array. | 5398 // Offsets directly into the data fixed array. |
| 5375 static const int kDataTagOffset = | 5399 static const int kDataTagOffset = |
| 5376 FixedArray::kHeaderSize + kTagIndex * kPointerSize; | 5400 FixedArray::kHeaderSize + kTagIndex * kPointerSize; |
| 5377 static const int kDataAsciiCodeOffset = | 5401 static const int kDataAsciiCodeOffset = |
| 5378 FixedArray::kHeaderSize + kIrregexpASCIICodeIndex * kPointerSize; | 5402 FixedArray::kHeaderSize + kIrregexpASCIICodeIndex * kPointerSize; |
| 5379 static const int kDataUC16CodeOffset = | 5403 static const int kDataUC16CodeOffset = |
| 5380 FixedArray::kHeaderSize + kIrregexpUC16CodeIndex * kPointerSize; | 5404 FixedArray::kHeaderSize + kIrregexpUC16CodeIndex * kPointerSize; |
| 5381 static const int kIrregexpCaptureCountOffset = | 5405 static const int kIrregexpCaptureCountOffset = |
| 5382 FixedArray::kHeaderSize + kIrregexpCaptureCountIndex * kPointerSize; | 5406 FixedArray::kHeaderSize + kIrregexpCaptureCountIndex * kPointerSize; |
| 5383 | 5407 |
| 5384 // In-object fields. | 5408 // In-object fields. |
| 5385 static const int kSourceFieldIndex = 0; | 5409 static const int kSourceFieldIndex = 0; |
| 5386 static const int kGlobalFieldIndex = 1; | 5410 static const int kGlobalFieldIndex = 1; |
| 5387 static const int kIgnoreCaseFieldIndex = 2; | 5411 static const int kIgnoreCaseFieldIndex = 2; |
| 5388 static const int kMultilineFieldIndex = 3; | 5412 static const int kMultilineFieldIndex = 3; |
| 5389 static const int kLastIndexFieldIndex = 4; | 5413 static const int kLastIndexFieldIndex = 4; |
| 5390 static const int kInObjectFieldCount = 5; | 5414 static const int kInObjectFieldCount = 5; |
| 5415 | |
| 5416 // The uninitialized value for a regexp code object. | |
| 5417 static const int kUninitializedValue = -1; | |
| 5391 }; | 5418 }; |
| 5392 | 5419 |
| 5393 | 5420 |
| 5394 class CompilationCacheShape { | 5421 class CompilationCacheShape { |
| 5395 public: | 5422 public: |
| 5396 static inline bool IsMatch(HashTableKey* key, Object* value) { | 5423 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 5397 return key->IsMatch(value); | 5424 return key->IsMatch(value); |
| 5398 } | 5425 } |
| 5399 | 5426 |
| 5400 static inline uint32_t Hash(HashTableKey* key) { | 5427 static inline uint32_t Hash(HashTableKey* key) { |
| (...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7132 } else { | 7159 } else { |
| 7133 value &= ~(1 << bit_position); | 7160 value &= ~(1 << bit_position); |
| 7134 } | 7161 } |
| 7135 return value; | 7162 return value; |
| 7136 } | 7163 } |
| 7137 }; | 7164 }; |
| 7138 | 7165 |
| 7139 } } // namespace v8::internal | 7166 } } // namespace v8::internal |
| 7140 | 7167 |
| 7141 #endif // V8_OBJECTS_H_ | 7168 #endif // V8_OBJECTS_H_ |
| OLD | NEW |