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