| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // - CompilationCacheTable | 79 // - CompilationCacheTable |
| 80 // - CodeCacheHashTable | 80 // - CodeCacheHashTable |
| 81 // - MapCache | 81 // - MapCache |
| 82 // - Context | 82 // - Context |
| 83 // - JSFunctionResultCache | 83 // - JSFunctionResultCache |
| 84 // - SerializedScopeInfo | 84 // - SerializedScopeInfo |
| 85 // - String | 85 // - String |
| 86 // - SeqString | 86 // - SeqString |
| 87 // - SeqAsciiString | 87 // - SeqAsciiString |
| 88 // - SeqTwoByteString | 88 // - SeqTwoByteString |
| 89 // - SlicedString |
| 89 // - ConsString | 90 // - ConsString |
| 90 // - ExternalString | 91 // - ExternalString |
| 91 // - ExternalAsciiString | 92 // - ExternalAsciiString |
| 92 // - ExternalTwoByteString | 93 // - ExternalTwoByteString |
| 93 // - HeapNumber | 94 // - HeapNumber |
| 94 // - Code | 95 // - Code |
| 95 // - Map | 96 // - Map |
| 96 // - Oddball | 97 // - Oddball |
| 97 // - Foreign | 98 // - Foreign |
| 98 // - SharedFunctionInfo | 99 // - SharedFunctionInfo |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 V(ASCII_SYMBOL_TYPE) \ | 274 V(ASCII_SYMBOL_TYPE) \ |
| 274 V(CONS_SYMBOL_TYPE) \ | 275 V(CONS_SYMBOL_TYPE) \ |
| 275 V(CONS_ASCII_SYMBOL_TYPE) \ | 276 V(CONS_ASCII_SYMBOL_TYPE) \ |
| 276 V(EXTERNAL_SYMBOL_TYPE) \ | 277 V(EXTERNAL_SYMBOL_TYPE) \ |
| 277 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ | 278 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ |
| 278 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ | 279 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ |
| 279 V(STRING_TYPE) \ | 280 V(STRING_TYPE) \ |
| 280 V(ASCII_STRING_TYPE) \ | 281 V(ASCII_STRING_TYPE) \ |
| 281 V(CONS_STRING_TYPE) \ | 282 V(CONS_STRING_TYPE) \ |
| 282 V(CONS_ASCII_STRING_TYPE) \ | 283 V(CONS_ASCII_STRING_TYPE) \ |
| 284 V(SLICED_STRING_TYPE) \ |
| 283 V(EXTERNAL_STRING_TYPE) \ | 285 V(EXTERNAL_STRING_TYPE) \ |
| 284 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ | 286 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ |
| 285 V(EXTERNAL_ASCII_STRING_TYPE) \ | 287 V(EXTERNAL_ASCII_STRING_TYPE) \ |
| 286 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 288 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
| 287 \ | 289 \ |
| 288 V(MAP_TYPE) \ | 290 V(MAP_TYPE) \ |
| 289 V(CODE_TYPE) \ | 291 V(CODE_TYPE) \ |
| 290 V(ODDBALL_TYPE) \ | 292 V(ODDBALL_TYPE) \ |
| 291 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 293 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
| 292 \ | 294 \ |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 389 ascii_string, \ | 391 ascii_string, \ |
| 390 AsciiString) \ | 392 AsciiString) \ |
| 391 V(CONS_STRING_TYPE, \ | 393 V(CONS_STRING_TYPE, \ |
| 392 ConsString::kSize, \ | 394 ConsString::kSize, \ |
| 393 cons_string, \ | 395 cons_string, \ |
| 394 ConsString) \ | 396 ConsString) \ |
| 395 V(CONS_ASCII_STRING_TYPE, \ | 397 V(CONS_ASCII_STRING_TYPE, \ |
| 396 ConsString::kSize, \ | 398 ConsString::kSize, \ |
| 397 cons_ascii_string, \ | 399 cons_ascii_string, \ |
| 398 ConsAsciiString) \ | 400 ConsAsciiString) \ |
| 401 V(SLICED_STRING_TYPE, \ |
| 402 SlicedString::kSize, \ |
| 403 sliced_string, \ |
| 404 SlicedString) \ |
| 405 V(SLICED_ASCII_STRING_TYPE, \ |
| 406 SlicedString::kSize, \ |
| 407 sliced_ascii_string, \ |
| 408 SlicedAsciiString) \ |
| 399 V(EXTERNAL_STRING_TYPE, \ | 409 V(EXTERNAL_STRING_TYPE, \ |
| 400 ExternalTwoByteString::kSize, \ | 410 ExternalTwoByteString::kSize, \ |
| 401 external_string, \ | 411 external_string, \ |
| 402 ExternalString) \ | 412 ExternalString) \ |
| 403 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ | 413 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ |
| 404 ExternalTwoByteString::kSize, \ | 414 ExternalTwoByteString::kSize, \ |
| 405 external_string_with_ascii_data, \ | 415 external_string_with_ascii_data, \ |
| 406 ExternalStringWithAsciiData) \ | 416 ExternalStringWithAsciiData) \ |
| 407 V(EXTERNAL_ASCII_STRING_TYPE, \ | 417 V(EXTERNAL_ASCII_STRING_TYPE, \ |
| 408 ExternalAsciiString::kSize, \ | 418 ExternalAsciiString::kSize, \ |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 const uint32_t kStringEncodingMask = 0x4; | 472 const uint32_t kStringEncodingMask = 0x4; |
| 463 const uint32_t kTwoByteStringTag = 0x0; | 473 const uint32_t kTwoByteStringTag = 0x0; |
| 464 const uint32_t kAsciiStringTag = 0x4; | 474 const uint32_t kAsciiStringTag = 0x4; |
| 465 | 475 |
| 466 // If bit 7 is clear, the low-order 2 bits indicate the representation | 476 // If bit 7 is clear, the low-order 2 bits indicate the representation |
| 467 // of the string. | 477 // of the string. |
| 468 const uint32_t kStringRepresentationMask = 0x03; | 478 const uint32_t kStringRepresentationMask = 0x03; |
| 469 enum StringRepresentationTag { | 479 enum StringRepresentationTag { |
| 470 kSeqStringTag = 0x0, | 480 kSeqStringTag = 0x0, |
| 471 kConsStringTag = 0x1, | 481 kConsStringTag = 0x1, |
| 472 kExternalStringTag = 0x2 | 482 kExternalStringTag = 0x2, |
| 483 kSlicedStringTag = 0x3 |
| 473 }; | 484 }; |
| 474 const uint32_t kIsConsStringMask = 0x1; | 485 const uint32_t kIsIndirectStringMask = 0x1; |
| 486 const uint32_t kIsIndirectStringTag = 0x1; |
| 487 STATIC_ASSERT( |
| 488 (kConsStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
| 489 STATIC_ASSERT( |
| 490 (kSlicedStringTag & kIsIndirectStringMask) == kIsIndirectStringTag); |
| 475 | 491 |
| 476 // If bit 7 is clear, then bit 3 indicates whether this two-byte | 492 // If bit 7 is clear, then bit 3 indicates whether this two-byte |
| 477 // string actually contains ascii data. | 493 // string actually contains ascii data. |
| 478 const uint32_t kAsciiDataHintMask = 0x08; | 494 const uint32_t kAsciiDataHintMask = 0x08; |
| 479 const uint32_t kAsciiDataHintTag = 0x08; | 495 const uint32_t kAsciiDataHintTag = 0x08; |
| 480 | 496 |
| 481 | 497 |
| 482 // A ConsString with an empty string as the right side is a candidate | 498 // A ConsString with an empty string as the right side is a candidate |
| 483 // for being shortcut by the garbage collector unless it is a | 499 // for being shortcut by the garbage collector unless it is a |
| 484 // symbol. It's not common to have non-flat symbols, so we do not | 500 // symbol. It's not common to have non-flat symbols, so we do not |
| (...skipping 14 matching lines...) Expand all Loading... |
| 499 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, | 515 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, |
| 500 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, | 516 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, |
| 501 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = | 517 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = |
| 502 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, | 518 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, |
| 503 EXTERNAL_ASCII_SYMBOL_TYPE = | 519 EXTERNAL_ASCII_SYMBOL_TYPE = |
| 504 kAsciiStringTag | kSymbolTag | kExternalStringTag, | 520 kAsciiStringTag | kSymbolTag | kExternalStringTag, |
| 505 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, | 521 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, |
| 506 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, | 522 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, |
| 507 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, | 523 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, |
| 508 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, | 524 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, |
| 525 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, |
| 526 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, |
| 509 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, | 527 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, |
| 510 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = | 528 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = |
| 511 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, | 529 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, |
| 512 // LAST_STRING_TYPE | 530 // LAST_STRING_TYPE |
| 513 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, | 531 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, |
| 514 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, | 532 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, |
| 515 | 533 |
| 516 // Objects allocated in their own spaces (never in new space). | 534 // Objects allocated in their own spaces (never in new space). |
| 517 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 535 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
| 518 CODE_TYPE, | 536 CODE_TYPE, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 V(HeapObject) \ | 720 V(HeapObject) \ |
| 703 V(Number) \ | 721 V(Number) \ |
| 704 | 722 |
| 705 #define HEAP_OBJECT_TYPE_LIST(V) \ | 723 #define HEAP_OBJECT_TYPE_LIST(V) \ |
| 706 V(HeapNumber) \ | 724 V(HeapNumber) \ |
| 707 V(String) \ | 725 V(String) \ |
| 708 V(Symbol) \ | 726 V(Symbol) \ |
| 709 V(SeqString) \ | 727 V(SeqString) \ |
| 710 V(ExternalString) \ | 728 V(ExternalString) \ |
| 711 V(ConsString) \ | 729 V(ConsString) \ |
| 730 V(SlicedString) \ |
| 712 V(ExternalTwoByteString) \ | 731 V(ExternalTwoByteString) \ |
| 713 V(ExternalAsciiString) \ | 732 V(ExternalAsciiString) \ |
| 714 V(SeqTwoByteString) \ | 733 V(SeqTwoByteString) \ |
| 715 V(SeqAsciiString) \ | 734 V(SeqAsciiString) \ |
| 716 \ | 735 \ |
| 717 V(ExternalArray) \ | 736 V(ExternalArray) \ |
| 718 V(ExternalByteArray) \ | 737 V(ExternalByteArray) \ |
| 719 V(ExternalUnsignedByteArray) \ | 738 V(ExternalUnsignedByteArray) \ |
| 720 V(ExternalShortArray) \ | 739 V(ExternalShortArray) \ |
| 721 V(ExternalUnsignedShortArray) \ | 740 V(ExternalUnsignedShortArray) \ |
| (...skipping 4980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5702 // prone and so we no longer put StringShapes in variables unless there is a | 5721 // prone and so we no longer put StringShapes in variables unless there is a |
| 5703 // concrete performance benefit at that particular point in the code. | 5722 // concrete performance benefit at that particular point in the code. |
| 5704 class StringShape BASE_EMBEDDED { | 5723 class StringShape BASE_EMBEDDED { |
| 5705 public: | 5724 public: |
| 5706 inline explicit StringShape(String* s); | 5725 inline explicit StringShape(String* s); |
| 5707 inline explicit StringShape(Map* s); | 5726 inline explicit StringShape(Map* s); |
| 5708 inline explicit StringShape(InstanceType t); | 5727 inline explicit StringShape(InstanceType t); |
| 5709 inline bool IsSequential(); | 5728 inline bool IsSequential(); |
| 5710 inline bool IsExternal(); | 5729 inline bool IsExternal(); |
| 5711 inline bool IsCons(); | 5730 inline bool IsCons(); |
| 5731 inline bool IsSliced(); |
| 5712 inline bool IsExternalAscii(); | 5732 inline bool IsExternalAscii(); |
| 5713 inline bool IsExternalTwoByte(); | 5733 inline bool IsExternalTwoByte(); |
| 5714 inline bool IsSequentialAscii(); | 5734 inline bool IsSequentialAscii(); |
| 5715 inline bool IsSequentialTwoByte(); | 5735 inline bool IsSequentialTwoByte(); |
| 5716 inline bool IsSymbol(); | 5736 inline bool IsSymbol(); |
| 5717 inline StringRepresentationTag representation_tag(); | 5737 inline StringRepresentationTag representation_tag(); |
| 5718 inline uint32_t full_representation_tag(); | 5738 inline uint32_t full_representation_tag(); |
| 5719 inline uint32_t size_tag(); | 5739 inline uint32_t size_tag(); |
| 5720 #ifdef DEBUG | 5740 #ifdef DEBUG |
| 5721 inline uint32_t type() { return type_; } | 5741 inline uint32_t type() { return type_; } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6221 static const int kMinLength = 13; | 6241 static const int kMinLength = 13; |
| 6222 | 6242 |
| 6223 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> | 6243 typedef FixedBodyDescriptor<kFirstOffset, kSecondOffset + kPointerSize, kSize> |
| 6224 BodyDescriptor; | 6244 BodyDescriptor; |
| 6225 | 6245 |
| 6226 private: | 6246 private: |
| 6227 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 6247 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
| 6228 }; | 6248 }; |
| 6229 | 6249 |
| 6230 | 6250 |
| 6251 class SlicedString: public String { |
| 6252 public: |
| 6253 |
| 6254 inline String* parent(); |
| 6255 inline void set_parent(String* parent); |
| 6256 inline int offset(); |
| 6257 inline void set_offset(int offset); |
| 6258 |
| 6259 // Dispatched behavior. |
| 6260 uint16_t SlicedStringGet(int index); |
| 6261 |
| 6262 // Casting. |
| 6263 static inline SlicedString* cast(Object* obj); |
| 6264 |
| 6265 // Layout description. |
| 6266 static const int kParentOffset = POINTER_SIZE_ALIGN(String::kSize); |
| 6267 static const int kOffsetOffset = kParentOffset + kPointerSize; |
| 6268 static const int kSize = kOffsetOffset + kPointerSize; |
| 6269 |
| 6270 // Support for StringInputBuffer |
| 6271 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, |
| 6272 unsigned* offset_ptr, |
| 6273 unsigned chars); |
| 6274 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, |
| 6275 unsigned* offset_ptr, |
| 6276 unsigned chars); |
| 6277 // Minimum length for a sliced string. |
| 6278 static const int kMinLength = 13; |
| 6279 |
| 6280 typedef FixedBodyDescriptor<kParentOffset, |
| 6281 kOffsetOffset + kPointerSize, kSize> |
| 6282 BodyDescriptor; |
| 6283 |
| 6284 private: |
| 6285 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); |
| 6286 }; |
| 6287 |
| 6288 |
| 6231 // The ExternalString class describes string values that are backed by | 6289 // The ExternalString class describes string values that are backed by |
| 6232 // a string resource that lies outside the V8 heap. ExternalStrings | 6290 // a string resource that lies outside the V8 heap. ExternalStrings |
| 6233 // consist of the length field common to all strings, a pointer to the | 6291 // consist of the length field common to all strings, a pointer to the |
| 6234 // external resource. It is important to ensure (externally) that the | 6292 // external resource. It is important to ensure (externally) that the |
| 6235 // resource is not deallocated while the ExternalString is live in the | 6293 // resource is not deallocated while the ExternalString is live in the |
| 6236 // V8 heap. | 6294 // V8 heap. |
| 6237 // | 6295 // |
| 6238 // The API expects that all ExternalStrings are created through the | 6296 // The API expects that all ExternalStrings are created through the |
| 6239 // API. Therefore, ExternalStrings should not be used internally. | 6297 // API. Therefore, ExternalStrings should not be used internally. |
| 6240 class ExternalString: public String { | 6298 class ExternalString: public String { |
| (...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7203 } else { | 7261 } else { |
| 7204 value &= ~(1 << bit_position); | 7262 value &= ~(1 << bit_position); |
| 7205 } | 7263 } |
| 7206 return value; | 7264 return value; |
| 7207 } | 7265 } |
| 7208 }; | 7266 }; |
| 7209 | 7267 |
| 7210 } } // namespace v8::internal | 7268 } } // namespace v8::internal |
| 7211 | 7269 |
| 7212 #endif // V8_OBJECTS_H_ | 7270 #endif // V8_OBJECTS_H_ |
| OLD | NEW |