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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 // - SymbolTable | 71 // - SymbolTable |
72 // - CompilationCacheTable | 72 // - CompilationCacheTable |
73 // - MapCache | 73 // - MapCache |
74 // - Context | 74 // - Context |
75 // - GlobalContext | 75 // - GlobalContext |
76 // - String | 76 // - String |
77 // - SeqString | 77 // - SeqString |
78 // - SeqAsciiString | 78 // - SeqAsciiString |
79 // - SeqTwoByteString | 79 // - SeqTwoByteString |
80 // - ConsString | 80 // - ConsString |
81 // - SlicedString | |
82 // - ExternalString | 81 // - ExternalString |
83 // - ExternalAsciiString | 82 // - ExternalAsciiString |
84 // - ExternalTwoByteString | 83 // - ExternalTwoByteString |
85 // - HeapNumber | 84 // - HeapNumber |
86 // - Code | 85 // - Code |
87 // - Map | 86 // - Map |
88 // - Oddball | 87 // - Oddball |
89 // - Proxy | 88 // - Proxy |
90 // - SharedFunctionInfo | 89 // - SharedFunctionInfo |
91 // - Struct | 90 // - Struct |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // | 202 // |
204 // As an example, a JavaScript object is a heap object and its map | 203 // As an example, a JavaScript object is a heap object and its map |
205 // instance_type is JS_OBJECT_TYPE. | 204 // instance_type is JS_OBJECT_TYPE. |
206 // | 205 // |
207 // The names of the string instance types are intended to systematically | 206 // The names of the string instance types are intended to systematically |
208 // mirror their encoding in the instance_type field of the map. The length | 207 // mirror their encoding in the instance_type field of the map. The length |
209 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is | 208 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is |
210 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is | 209 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is |
211 // mentioned explicitly in the name. Likewise, the default representation is | 210 // mentioned explicitly in the name. Likewise, the default representation is |
212 // considered sequential. It is not mentioned in the name. The other | 211 // considered sequential. It is not mentioned in the name. The other |
213 // representations (eg, CONS, SLICED, EXTERNAL) are explicitly mentioned. | 212 // representations (eg, CONS, EXTERNAL) are explicitly mentioned. |
214 // Finally, the string is either a SYMBOL_TYPE (if it is a symbol) or a | 213 // Finally, the string is either a SYMBOL_TYPE (if it is a symbol) or a |
215 // STRING_TYPE (if it is not a symbol). | 214 // STRING_TYPE (if it is not a symbol). |
216 // | 215 // |
217 // NOTE: The following things are some that depend on the string types having | 216 // NOTE: The following things are some that depend on the string types having |
218 // instance_types that are less than those of all other types: | 217 // instance_types that are less than those of all other types: |
219 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and | 218 // HeapObject::Size, HeapObject::IterateBody, the typeof operator, and |
220 // Object::IsString. | 219 // Object::IsString. |
221 // | 220 // |
222 // NOTE: Everything following JS_VALUE_TYPE is considered a | 221 // NOTE: Everything following JS_VALUE_TYPE is considered a |
223 // JSObject for GC purposes. The first four entries here have typeof | 222 // JSObject for GC purposes. The first four entries here have typeof |
224 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. | 223 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. |
225 #define INSTANCE_TYPE_LIST_ALL(V) \ | 224 #define INSTANCE_TYPE_LIST_ALL(V) \ |
226 V(SHORT_SYMBOL_TYPE) \ | 225 V(SHORT_SYMBOL_TYPE) \ |
227 V(MEDIUM_SYMBOL_TYPE) \ | 226 V(MEDIUM_SYMBOL_TYPE) \ |
228 V(LONG_SYMBOL_TYPE) \ | 227 V(LONG_SYMBOL_TYPE) \ |
229 V(SHORT_ASCII_SYMBOL_TYPE) \ | 228 V(SHORT_ASCII_SYMBOL_TYPE) \ |
230 V(MEDIUM_ASCII_SYMBOL_TYPE) \ | 229 V(MEDIUM_ASCII_SYMBOL_TYPE) \ |
231 V(LONG_ASCII_SYMBOL_TYPE) \ | 230 V(LONG_ASCII_SYMBOL_TYPE) \ |
232 V(SHORT_CONS_SYMBOL_TYPE) \ | 231 V(SHORT_CONS_SYMBOL_TYPE) \ |
233 V(MEDIUM_CONS_SYMBOL_TYPE) \ | 232 V(MEDIUM_CONS_SYMBOL_TYPE) \ |
234 V(LONG_CONS_SYMBOL_TYPE) \ | 233 V(LONG_CONS_SYMBOL_TYPE) \ |
235 V(SHORT_CONS_ASCII_SYMBOL_TYPE) \ | 234 V(SHORT_CONS_ASCII_SYMBOL_TYPE) \ |
236 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE) \ | 235 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE) \ |
237 V(LONG_CONS_ASCII_SYMBOL_TYPE) \ | 236 V(LONG_CONS_ASCII_SYMBOL_TYPE) \ |
238 V(SHORT_SLICED_SYMBOL_TYPE) \ | |
239 V(MEDIUM_SLICED_SYMBOL_TYPE) \ | |
240 V(LONG_SLICED_SYMBOL_TYPE) \ | |
241 V(SHORT_SLICED_ASCII_SYMBOL_TYPE) \ | |
242 V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE) \ | |
243 V(LONG_SLICED_ASCII_SYMBOL_TYPE) \ | |
244 V(SHORT_EXTERNAL_SYMBOL_TYPE) \ | 237 V(SHORT_EXTERNAL_SYMBOL_TYPE) \ |
245 V(MEDIUM_EXTERNAL_SYMBOL_TYPE) \ | 238 V(MEDIUM_EXTERNAL_SYMBOL_TYPE) \ |
246 V(LONG_EXTERNAL_SYMBOL_TYPE) \ | 239 V(LONG_EXTERNAL_SYMBOL_TYPE) \ |
247 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE) \ | 240 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE) \ |
248 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE) \ | 241 V(MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE) \ |
249 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE) \ | 242 V(LONG_EXTERNAL_ASCII_SYMBOL_TYPE) \ |
250 V(SHORT_STRING_TYPE) \ | 243 V(SHORT_STRING_TYPE) \ |
251 V(MEDIUM_STRING_TYPE) \ | 244 V(MEDIUM_STRING_TYPE) \ |
252 V(LONG_STRING_TYPE) \ | 245 V(LONG_STRING_TYPE) \ |
253 V(SHORT_ASCII_STRING_TYPE) \ | 246 V(SHORT_ASCII_STRING_TYPE) \ |
254 V(MEDIUM_ASCII_STRING_TYPE) \ | 247 V(MEDIUM_ASCII_STRING_TYPE) \ |
255 V(LONG_ASCII_STRING_TYPE) \ | 248 V(LONG_ASCII_STRING_TYPE) \ |
256 V(SHORT_CONS_STRING_TYPE) \ | 249 V(SHORT_CONS_STRING_TYPE) \ |
257 V(MEDIUM_CONS_STRING_TYPE) \ | 250 V(MEDIUM_CONS_STRING_TYPE) \ |
258 V(LONG_CONS_STRING_TYPE) \ | 251 V(LONG_CONS_STRING_TYPE) \ |
259 V(SHORT_CONS_ASCII_STRING_TYPE) \ | 252 V(SHORT_CONS_ASCII_STRING_TYPE) \ |
260 V(MEDIUM_CONS_ASCII_STRING_TYPE) \ | 253 V(MEDIUM_CONS_ASCII_STRING_TYPE) \ |
261 V(LONG_CONS_ASCII_STRING_TYPE) \ | 254 V(LONG_CONS_ASCII_STRING_TYPE) \ |
262 V(SHORT_SLICED_STRING_TYPE) \ | |
263 V(MEDIUM_SLICED_STRING_TYPE) \ | |
264 V(LONG_SLICED_STRING_TYPE) \ | |
265 V(SHORT_SLICED_ASCII_STRING_TYPE) \ | |
266 V(MEDIUM_SLICED_ASCII_STRING_TYPE) \ | |
267 V(LONG_SLICED_ASCII_STRING_TYPE) \ | |
268 V(SHORT_EXTERNAL_STRING_TYPE) \ | 255 V(SHORT_EXTERNAL_STRING_TYPE) \ |
269 V(MEDIUM_EXTERNAL_STRING_TYPE) \ | 256 V(MEDIUM_EXTERNAL_STRING_TYPE) \ |
270 V(LONG_EXTERNAL_STRING_TYPE) \ | 257 V(LONG_EXTERNAL_STRING_TYPE) \ |
271 V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \ | 258 V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \ |
272 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE) \ | 259 V(MEDIUM_EXTERNAL_ASCII_STRING_TYPE) \ |
273 V(LONG_EXTERNAL_ASCII_STRING_TYPE) \ | 260 V(LONG_EXTERNAL_ASCII_STRING_TYPE) \ |
274 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 261 V(LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
275 \ | 262 \ |
276 V(MAP_TYPE) \ | 263 V(MAP_TYPE) \ |
277 V(HEAP_NUMBER_TYPE) \ | 264 V(HEAP_NUMBER_TYPE) \ |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
373 short_cons_ascii_symbol, \ | 360 short_cons_ascii_symbol, \ |
374 ShortConsAsciiSymbol) \ | 361 ShortConsAsciiSymbol) \ |
375 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, \ | 362 V(MEDIUM_CONS_ASCII_SYMBOL_TYPE, \ |
376 ConsString::kSize, \ | 363 ConsString::kSize, \ |
377 medium_cons_ascii_symbol, \ | 364 medium_cons_ascii_symbol, \ |
378 MediumConsAsciiSymbol) \ | 365 MediumConsAsciiSymbol) \ |
379 V(LONG_CONS_ASCII_SYMBOL_TYPE, \ | 366 V(LONG_CONS_ASCII_SYMBOL_TYPE, \ |
380 ConsString::kSize, \ | 367 ConsString::kSize, \ |
381 long_cons_ascii_symbol, \ | 368 long_cons_ascii_symbol, \ |
382 LongConsAsciiSymbol) \ | 369 LongConsAsciiSymbol) \ |
383 V(SHORT_SLICED_SYMBOL_TYPE, \ | |
384 SlicedString::kSize, \ | |
385 short_sliced_symbol, \ | |
386 ShortSlicedSymbol) \ | |
387 V(MEDIUM_SLICED_SYMBOL_TYPE, \ | |
388 SlicedString::kSize, \ | |
389 medium_sliced_symbol, \ | |
390 MediumSlicedSymbol) \ | |
391 V(LONG_SLICED_SYMBOL_TYPE, \ | |
392 SlicedString::kSize, \ | |
393 long_sliced_symbol, \ | |
394 LongSlicedSymbol) \ | |
395 V(SHORT_SLICED_ASCII_SYMBOL_TYPE, \ | |
396 SlicedString::kSize, \ | |
397 short_sliced_ascii_symbol, \ | |
398 ShortSlicedAsciiSymbol) \ | |
399 V(MEDIUM_SLICED_ASCII_SYMBOL_TYPE, \ | |
400 SlicedString::kSize, \ | |
401 medium_sliced_ascii_symbol, \ | |
402 MediumSlicedAsciiSymbol) \ | |
403 V(LONG_SLICED_ASCII_SYMBOL_TYPE, \ | |
404 SlicedString::kSize, \ | |
405 long_sliced_ascii_symbol, \ | |
406 LongSlicedAsciiSymbol) \ | |
407 V(SHORT_EXTERNAL_SYMBOL_TYPE, \ | 370 V(SHORT_EXTERNAL_SYMBOL_TYPE, \ |
408 ExternalTwoByteString::kSize, \ | 371 ExternalTwoByteString::kSize, \ |
409 short_external_symbol, \ | 372 short_external_symbol, \ |
410 ShortExternalSymbol) \ | 373 ShortExternalSymbol) \ |
411 V(MEDIUM_EXTERNAL_SYMBOL_TYPE, \ | 374 V(MEDIUM_EXTERNAL_SYMBOL_TYPE, \ |
412 ExternalTwoByteString::kSize, \ | 375 ExternalTwoByteString::kSize, \ |
413 medium_external_symbol, \ | 376 medium_external_symbol, \ |
414 MediumExternalSymbol) \ | 377 MediumExternalSymbol) \ |
415 V(LONG_EXTERNAL_SYMBOL_TYPE, \ | 378 V(LONG_EXTERNAL_SYMBOL_TYPE, \ |
416 ExternalTwoByteString::kSize, \ | 379 ExternalTwoByteString::kSize, \ |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
469 short_cons_ascii_string, \ | 432 short_cons_ascii_string, \ |
470 ShortConsAsciiString) \ | 433 ShortConsAsciiString) \ |
471 V(MEDIUM_CONS_ASCII_STRING_TYPE, \ | 434 V(MEDIUM_CONS_ASCII_STRING_TYPE, \ |
472 ConsString::kSize, \ | 435 ConsString::kSize, \ |
473 medium_cons_ascii_string, \ | 436 medium_cons_ascii_string, \ |
474 MediumConsAsciiString) \ | 437 MediumConsAsciiString) \ |
475 V(LONG_CONS_ASCII_STRING_TYPE, \ | 438 V(LONG_CONS_ASCII_STRING_TYPE, \ |
476 ConsString::kSize, \ | 439 ConsString::kSize, \ |
477 long_cons_ascii_string, \ | 440 long_cons_ascii_string, \ |
478 LongConsAsciiString) \ | 441 LongConsAsciiString) \ |
479 V(SHORT_SLICED_STRING_TYPE, \ | |
480 SlicedString::kSize, \ | |
481 short_sliced_string, \ | |
482 ShortSlicedString) \ | |
483 V(MEDIUM_SLICED_STRING_TYPE, \ | |
484 SlicedString::kSize, \ | |
485 medium_sliced_string, \ | |
486 MediumSlicedString) \ | |
487 V(LONG_SLICED_STRING_TYPE, \ | |
488 SlicedString::kSize, \ | |
489 long_sliced_string, \ | |
490 LongSlicedString) \ | |
491 V(SHORT_SLICED_ASCII_STRING_TYPE, \ | |
492 SlicedString::kSize, \ | |
493 short_sliced_ascii_string, \ | |
494 ShortSlicedAsciiString) \ | |
495 V(MEDIUM_SLICED_ASCII_STRING_TYPE, \ | |
496 SlicedString::kSize, \ | |
497 medium_sliced_ascii_string, \ | |
498 MediumSlicedAsciiString) \ | |
499 V(LONG_SLICED_ASCII_STRING_TYPE, \ | |
500 SlicedString::kSize, \ | |
501 long_sliced_ascii_string, \ | |
502 LongSlicedAsciiString) \ | |
503 V(SHORT_EXTERNAL_STRING_TYPE, \ | 442 V(SHORT_EXTERNAL_STRING_TYPE, \ |
504 ExternalTwoByteString::kSize, \ | 443 ExternalTwoByteString::kSize, \ |
505 short_external_string, \ | 444 short_external_string, \ |
506 ShortExternalString) \ | 445 ShortExternalString) \ |
507 V(MEDIUM_EXTERNAL_STRING_TYPE, \ | 446 V(MEDIUM_EXTERNAL_STRING_TYPE, \ |
508 ExternalTwoByteString::kSize, \ | 447 ExternalTwoByteString::kSize, \ |
509 medium_external_string, \ | 448 medium_external_string, \ |
510 MediumExternalString) \ | 449 MediumExternalString) \ |
511 V(LONG_EXTERNAL_STRING_TYPE, \ | 450 V(LONG_EXTERNAL_STRING_TYPE, \ |
512 ExternalTwoByteString::kSize, \ | 451 ExternalTwoByteString::kSize, \ |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 const uint32_t kStringEncodingMask = 0x4; | 523 const uint32_t kStringEncodingMask = 0x4; |
585 const uint32_t kTwoByteStringTag = 0x0; | 524 const uint32_t kTwoByteStringTag = 0x0; |
586 const uint32_t kAsciiStringTag = 0x4; | 525 const uint32_t kAsciiStringTag = 0x4; |
587 | 526 |
588 // If bit 7 is clear, the low-order 2 bits indicate the representation | 527 // If bit 7 is clear, the low-order 2 bits indicate the representation |
589 // of the string. | 528 // of the string. |
590 const uint32_t kStringRepresentationMask = 0x03; | 529 const uint32_t kStringRepresentationMask = 0x03; |
591 enum StringRepresentationTag { | 530 enum StringRepresentationTag { |
592 kSeqStringTag = 0x0, | 531 kSeqStringTag = 0x0, |
593 kConsStringTag = 0x1, | 532 kConsStringTag = 0x1, |
594 kSlicedStringTag = 0x2, | |
595 kExternalStringTag = 0x3 | 533 kExternalStringTag = 0x3 |
596 }; | 534 }; |
597 | 535 |
598 | 536 |
599 // A ConsString with an empty string as the right side is a candidate | 537 // A ConsString with an empty string as the right side is a candidate |
600 // for being shortcut by the garbage collector unless it is a | 538 // for being shortcut by the garbage collector unless it is a |
601 // symbol. It's not common to have non-flat symbols, so we do not | 539 // symbol. It's not common to have non-flat symbols, so we do not |
602 // shortcut them thereby avoiding turning symbols into strings. See | 540 // shortcut them thereby avoiding turning symbols into strings. See |
603 // heap.cc and mark-compact.cc. | 541 // heap.cc and mark-compact.cc. |
604 const uint32_t kShortcutTypeMask = | 542 const uint32_t kShortcutTypeMask = |
(...skipping 15 matching lines...) Expand all Loading... |
620 kLongStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag, | 558 kLongStringTag | kAsciiStringTag | kSymbolTag | kSeqStringTag, |
621 SHORT_CONS_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kConsStringTag, | 559 SHORT_CONS_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kConsStringTag, |
622 MEDIUM_CONS_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kConsStringTag, | 560 MEDIUM_CONS_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kConsStringTag, |
623 LONG_CONS_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kConsStringTag, | 561 LONG_CONS_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kConsStringTag, |
624 SHORT_CONS_ASCII_SYMBOL_TYPE = | 562 SHORT_CONS_ASCII_SYMBOL_TYPE = |
625 kShortStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, | 563 kShortStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, |
626 MEDIUM_CONS_ASCII_SYMBOL_TYPE = | 564 MEDIUM_CONS_ASCII_SYMBOL_TYPE = |
627 kMediumStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, | 565 kMediumStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, |
628 LONG_CONS_ASCII_SYMBOL_TYPE = | 566 LONG_CONS_ASCII_SYMBOL_TYPE = |
629 kLongStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, | 567 kLongStringTag | kAsciiStringTag | kSymbolTag | kConsStringTag, |
630 SHORT_SLICED_SYMBOL_TYPE = kShortStringTag | kSymbolTag | kSlicedStringTag, | |
631 MEDIUM_SLICED_SYMBOL_TYPE = kMediumStringTag | kSymbolTag | kSlicedStringTag, | |
632 LONG_SLICED_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kSlicedStringTag, | |
633 SHORT_SLICED_ASCII_SYMBOL_TYPE = | |
634 kShortStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag, | |
635 MEDIUM_SLICED_ASCII_SYMBOL_TYPE = | |
636 kMediumStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag, | |
637 LONG_SLICED_ASCII_SYMBOL_TYPE = | |
638 kLongStringTag | kAsciiStringTag | kSymbolTag | kSlicedStringTag, | |
639 SHORT_EXTERNAL_SYMBOL_TYPE = | 568 SHORT_EXTERNAL_SYMBOL_TYPE = |
640 kShortStringTag | kSymbolTag | kExternalStringTag, | 569 kShortStringTag | kSymbolTag | kExternalStringTag, |
641 MEDIUM_EXTERNAL_SYMBOL_TYPE = | 570 MEDIUM_EXTERNAL_SYMBOL_TYPE = |
642 kMediumStringTag | kSymbolTag | kExternalStringTag, | 571 kMediumStringTag | kSymbolTag | kExternalStringTag, |
643 LONG_EXTERNAL_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kExternalStringTag, | 572 LONG_EXTERNAL_SYMBOL_TYPE = kLongStringTag | kSymbolTag | kExternalStringTag, |
644 SHORT_EXTERNAL_ASCII_SYMBOL_TYPE = | 573 SHORT_EXTERNAL_ASCII_SYMBOL_TYPE = |
645 kShortStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, | 574 kShortStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, |
646 MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE = | 575 MEDIUM_EXTERNAL_ASCII_SYMBOL_TYPE = |
647 kMediumStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, | 576 kMediumStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, |
648 LONG_EXTERNAL_ASCII_SYMBOL_TYPE = | 577 LONG_EXTERNAL_ASCII_SYMBOL_TYPE = |
649 kLongStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, | 578 kLongStringTag | kAsciiStringTag | kSymbolTag | kExternalStringTag, |
650 SHORT_STRING_TYPE = kShortStringTag | kSeqStringTag, | 579 SHORT_STRING_TYPE = kShortStringTag | kSeqStringTag, |
651 MEDIUM_STRING_TYPE = kMediumStringTag | kSeqStringTag, | 580 MEDIUM_STRING_TYPE = kMediumStringTag | kSeqStringTag, |
652 LONG_STRING_TYPE = kLongStringTag | kSeqStringTag, | 581 LONG_STRING_TYPE = kLongStringTag | kSeqStringTag, |
653 SHORT_ASCII_STRING_TYPE = kShortStringTag | kAsciiStringTag | kSeqStringTag, | 582 SHORT_ASCII_STRING_TYPE = kShortStringTag | kAsciiStringTag | kSeqStringTag, |
654 MEDIUM_ASCII_STRING_TYPE = kMediumStringTag | kAsciiStringTag | kSeqStringTag, | 583 MEDIUM_ASCII_STRING_TYPE = kMediumStringTag | kAsciiStringTag | kSeqStringTag, |
655 LONG_ASCII_STRING_TYPE = kLongStringTag | kAsciiStringTag | kSeqStringTag, | 584 LONG_ASCII_STRING_TYPE = kLongStringTag | kAsciiStringTag | kSeqStringTag, |
656 SHORT_CONS_STRING_TYPE = kShortStringTag | kConsStringTag, | 585 SHORT_CONS_STRING_TYPE = kShortStringTag | kConsStringTag, |
657 MEDIUM_CONS_STRING_TYPE = kMediumStringTag | kConsStringTag, | 586 MEDIUM_CONS_STRING_TYPE = kMediumStringTag | kConsStringTag, |
658 LONG_CONS_STRING_TYPE = kLongStringTag | kConsStringTag, | 587 LONG_CONS_STRING_TYPE = kLongStringTag | kConsStringTag, |
659 SHORT_CONS_ASCII_STRING_TYPE = | 588 SHORT_CONS_ASCII_STRING_TYPE = |
660 kShortStringTag | kAsciiStringTag | kConsStringTag, | 589 kShortStringTag | kAsciiStringTag | kConsStringTag, |
661 MEDIUM_CONS_ASCII_STRING_TYPE = | 590 MEDIUM_CONS_ASCII_STRING_TYPE = |
662 kMediumStringTag | kAsciiStringTag | kConsStringTag, | 591 kMediumStringTag | kAsciiStringTag | kConsStringTag, |
663 LONG_CONS_ASCII_STRING_TYPE = | 592 LONG_CONS_ASCII_STRING_TYPE = |
664 kLongStringTag | kAsciiStringTag | kConsStringTag, | 593 kLongStringTag | kAsciiStringTag | kConsStringTag, |
665 SHORT_SLICED_STRING_TYPE = kShortStringTag | kSlicedStringTag, | |
666 MEDIUM_SLICED_STRING_TYPE = kMediumStringTag | kSlicedStringTag, | |
667 LONG_SLICED_STRING_TYPE = kLongStringTag | kSlicedStringTag, | |
668 SHORT_SLICED_ASCII_STRING_TYPE = | |
669 kShortStringTag | kAsciiStringTag | kSlicedStringTag, | |
670 MEDIUM_SLICED_ASCII_STRING_TYPE = | |
671 kMediumStringTag | kAsciiStringTag | kSlicedStringTag, | |
672 LONG_SLICED_ASCII_STRING_TYPE = | |
673 kLongStringTag | kAsciiStringTag | kSlicedStringTag, | |
674 SHORT_EXTERNAL_STRING_TYPE = kShortStringTag | kExternalStringTag, | 594 SHORT_EXTERNAL_STRING_TYPE = kShortStringTag | kExternalStringTag, |
675 MEDIUM_EXTERNAL_STRING_TYPE = kMediumStringTag | kExternalStringTag, | 595 MEDIUM_EXTERNAL_STRING_TYPE = kMediumStringTag | kExternalStringTag, |
676 LONG_EXTERNAL_STRING_TYPE = kLongStringTag | kExternalStringTag, | 596 LONG_EXTERNAL_STRING_TYPE = kLongStringTag | kExternalStringTag, |
677 SHORT_EXTERNAL_ASCII_STRING_TYPE = | 597 SHORT_EXTERNAL_ASCII_STRING_TYPE = |
678 kShortStringTag | kAsciiStringTag | kExternalStringTag, | 598 kShortStringTag | kAsciiStringTag | kExternalStringTag, |
679 MEDIUM_EXTERNAL_ASCII_STRING_TYPE = | 599 MEDIUM_EXTERNAL_ASCII_STRING_TYPE = |
680 kMediumStringTag | kAsciiStringTag | kExternalStringTag, | 600 kMediumStringTag | kAsciiStringTag | kExternalStringTag, |
681 LONG_EXTERNAL_ASCII_STRING_TYPE = | 601 LONG_EXTERNAL_ASCII_STRING_TYPE = |
682 kLongStringTag | kAsciiStringTag | kExternalStringTag, | 602 kLongStringTag | kAsciiStringTag | kExternalStringTag, |
683 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE, | 603 LONG_PRIVATE_EXTERNAL_ASCII_STRING_TYPE = LONG_EXTERNAL_ASCII_STRING_TYPE, |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 class Object BASE_EMBEDDED { | 705 class Object BASE_EMBEDDED { |
786 public: | 706 public: |
787 // Type testing. | 707 // Type testing. |
788 inline bool IsSmi(); | 708 inline bool IsSmi(); |
789 inline bool IsHeapObject(); | 709 inline bool IsHeapObject(); |
790 inline bool IsHeapNumber(); | 710 inline bool IsHeapNumber(); |
791 inline bool IsString(); | 711 inline bool IsString(); |
792 inline bool IsSymbol(); | 712 inline bool IsSymbol(); |
793 // See objects-inl.h for more details | 713 // See objects-inl.h for more details |
794 inline bool IsSeqString(); | 714 inline bool IsSeqString(); |
795 inline bool IsSlicedString(); | |
796 inline bool IsExternalString(); | 715 inline bool IsExternalString(); |
797 inline bool IsExternalTwoByteString(); | 716 inline bool IsExternalTwoByteString(); |
798 inline bool IsExternalAsciiString(); | 717 inline bool IsExternalAsciiString(); |
799 inline bool IsSeqTwoByteString(); | 718 inline bool IsSeqTwoByteString(); |
800 inline bool IsSeqAsciiString(); | 719 inline bool IsSeqAsciiString(); |
801 inline bool IsConsString(); | 720 inline bool IsConsString(); |
802 | 721 |
803 inline bool IsNumber(); | 722 inline bool IsNumber(); |
804 inline bool IsByteArray(); | 723 inline bool IsByteArray(); |
805 inline bool IsPixelArray(); | 724 inline bool IsPixelArray(); |
(...skipping 3107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3913 // prone and so we no longer put StringShapes in variables unless there is a | 3832 // prone and so we no longer put StringShapes in variables unless there is a |
3914 // concrete performance benefit at that particular point in the code. | 3833 // concrete performance benefit at that particular point in the code. |
3915 class StringShape BASE_EMBEDDED { | 3834 class StringShape BASE_EMBEDDED { |
3916 public: | 3835 public: |
3917 inline explicit StringShape(String* s); | 3836 inline explicit StringShape(String* s); |
3918 inline explicit StringShape(Map* s); | 3837 inline explicit StringShape(Map* s); |
3919 inline explicit StringShape(InstanceType t); | 3838 inline explicit StringShape(InstanceType t); |
3920 inline bool IsSequential(); | 3839 inline bool IsSequential(); |
3921 inline bool IsExternal(); | 3840 inline bool IsExternal(); |
3922 inline bool IsCons(); | 3841 inline bool IsCons(); |
3923 inline bool IsSliced(); | |
3924 inline bool IsExternalAscii(); | 3842 inline bool IsExternalAscii(); |
3925 inline bool IsExternalTwoByte(); | 3843 inline bool IsExternalTwoByte(); |
3926 inline bool IsSequentialAscii(); | 3844 inline bool IsSequentialAscii(); |
3927 inline bool IsSequentialTwoByte(); | 3845 inline bool IsSequentialTwoByte(); |
3928 inline bool IsSymbol(); | 3846 inline bool IsSymbol(); |
3929 inline StringRepresentationTag representation_tag(); | 3847 inline StringRepresentationTag representation_tag(); |
3930 inline uint32_t full_representation_tag(); | 3848 inline uint32_t full_representation_tag(); |
3931 inline uint32_t size_tag(); | 3849 inline uint32_t size_tag(); |
3932 #ifdef DEBUG | 3850 #ifdef DEBUG |
3933 inline uint32_t type() { return type_; } | 3851 inline uint32_t type() { return type_; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3971 inline bool IsAsciiRepresentation(); | 3889 inline bool IsAsciiRepresentation(); |
3972 inline bool IsTwoByteRepresentation(); | 3890 inline bool IsTwoByteRepresentation(); |
3973 | 3891 |
3974 // Get and set individual two byte chars in the string. | 3892 // Get and set individual two byte chars in the string. |
3975 inline void Set(int index, uint16_t value); | 3893 inline void Set(int index, uint16_t value); |
3976 // Get individual two byte char in the string. Repeated calls | 3894 // Get individual two byte char in the string. Repeated calls |
3977 // to this method are not efficient unless the string is flat. | 3895 // to this method are not efficient unless the string is flat. |
3978 inline uint16_t Get(int index); | 3896 inline uint16_t Get(int index); |
3979 | 3897 |
3980 // Try to flatten the top level ConsString that is hiding behind this | 3898 // Try to flatten the top level ConsString that is hiding behind this |
3981 // string. This is a no-op unless the string is a ConsString or a | 3899 // string. This is a no-op unless the string is a ConsString. Flatten |
3982 // SlicedString. Flatten mutates the ConsString and might return a | 3900 // mutates the ConsString and might return a failure. |
3983 // failure. | |
3984 Object* TryFlatten(); | 3901 Object* TryFlatten(); |
3985 | 3902 |
3986 // Try to flatten the string. Checks first inline to see if it is necessary. | 3903 // Try to flatten the string. Checks first inline to see if it is necessary. |
3987 // Do not handle allocation failures. After calling TryFlattenIfNotFlat, the | 3904 // Do not handle allocation failures. After calling TryFlattenIfNotFlat, the |
3988 // string could still be a ConsString, in which case a failure is returned. | 3905 // string could still be a ConsString, in which case a failure is returned. |
3989 // Use FlattenString from Handles.cc to be sure to flatten. | 3906 // Use FlattenString from Handles.cc to be sure to flatten. |
3990 inline Object* TryFlattenIfNotFlat(); | 3907 inline Object* TryFlattenIfNotFlat(); |
3991 | 3908 |
3992 Vector<const char> ToAsciiVector(); | 3909 Vector<const char> ToAsciiVector(); |
3993 Vector<const uc16> ToUC16Vector(); | 3910 Vector<const uc16> ToUC16Vector(); |
3994 | 3911 |
3995 // Mark the string as an undetectable object. It only applies to | 3912 // Mark the string as an undetectable object. It only applies to |
3996 // ascii and two byte string types. | 3913 // ascii and two byte string types. |
3997 bool MarkAsUndetectable(); | 3914 bool MarkAsUndetectable(); |
3998 | 3915 |
3999 // Slice the string and return a substring. | 3916 // Return a substring. |
4000 Object* Slice(int from, int to); | 3917 Object* SubString(int from, int to); |
4001 | 3918 |
4002 // String equality operations. | 3919 // String equality operations. |
4003 inline bool Equals(String* other); | 3920 inline bool Equals(String* other); |
4004 bool IsEqualTo(Vector<const char> str); | 3921 bool IsEqualTo(Vector<const char> str); |
4005 | 3922 |
4006 // Return a UTF8 representation of the string. The string is null | 3923 // Return a UTF8 representation of the string. The string is null |
4007 // terminated but may optionally contain nulls. Length is returned | 3924 // terminated but may optionally contain nulls. Length is returned |
4008 // in length_output if length_output is not a null pointer The string | 3925 // in length_output if length_output is not a null pointer The string |
4009 // should be nearly flat, otherwise the performance of this method may | 3926 // should be nearly flat, otherwise the performance of this method may |
4010 // be very slow (quadratic in the length). Setting robustness_flag to | 3927 // be very slow (quadratic in the length). Setting robustness_flag to |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4075 | 3992 |
4076 // Maximum number of characters to consider when trying to convert a string | 3993 // Maximum number of characters to consider when trying to convert a string |
4077 // value into an array index. | 3994 // value into an array index. |
4078 static const int kMaxArrayIndexSize = 10; | 3995 static const int kMaxArrayIndexSize = 10; |
4079 | 3996 |
4080 // Max ascii char code. | 3997 // Max ascii char code. |
4081 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; | 3998 static const int kMaxAsciiCharCode = unibrow::Utf8::kMaxOneByteChar; |
4082 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; | 3999 static const unsigned kMaxAsciiCharCodeU = unibrow::Utf8::kMaxOneByteChar; |
4083 static const int kMaxUC16CharCode = 0xffff; | 4000 static const int kMaxUC16CharCode = 0xffff; |
4084 | 4001 |
4085 // Minimum length for a cons or sliced string. | 4002 // Minimum length for a cons string. |
4086 static const int kMinNonFlatLength = 13; | 4003 static const int kMinNonFlatLength = 13; |
4087 | 4004 |
4088 // Mask constant for checking if a string has a computed hash code | 4005 // Mask constant for checking if a string has a computed hash code |
4089 // and if it is an array index. The least significant bit indicates | 4006 // and if it is an array index. The least significant bit indicates |
4090 // whether a hash code has been computed. If the hash code has been | 4007 // whether a hash code has been computed. If the hash code has been |
4091 // computed the 2nd bit tells whether the string can be used as an | 4008 // computed the 2nd bit tells whether the string can be used as an |
4092 // array index. | 4009 // array index. |
4093 static const int kHashComputedMask = 1; | 4010 static const int kHashComputedMask = 1; |
4094 static const int kIsArrayIndexMask = 1 << 1; | 4011 static const int kIsArrayIndexMask = 1 << 1; |
4095 static const int kNofLengthBitFields = 2; | 4012 static const int kNofLengthBitFields = 2; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4148 cursor(cursor_), | 4065 cursor(cursor_), |
4149 capacity(capacity_), | 4066 capacity(capacity_), |
4150 remaining(remaining_) { | 4067 remaining(remaining_) { |
4151 } | 4068 } |
4152 unibrow::byte* util_buffer; | 4069 unibrow::byte* util_buffer; |
4153 unsigned cursor; | 4070 unsigned cursor; |
4154 unsigned capacity; | 4071 unsigned capacity; |
4155 unsigned remaining; | 4072 unsigned remaining; |
4156 }; | 4073 }; |
4157 | 4074 |
4158 // NOTE: If you call StringInputBuffer routines on strings that are | |
4159 // too deeply nested trees of cons and slice strings, then this | |
4160 // routine will overflow the stack. Strings that are merely deeply | |
4161 // nested trees of cons strings do not have a problem apart from | |
4162 // performance. | |
4163 | |
4164 static inline const unibrow::byte* ReadBlock(String* input, | 4075 static inline const unibrow::byte* ReadBlock(String* input, |
4165 ReadBlockBuffer* buffer, | 4076 ReadBlockBuffer* buffer, |
4166 unsigned* offset, | 4077 unsigned* offset, |
4167 unsigned max_chars); | 4078 unsigned max_chars); |
4168 static void ReadBlockIntoBuffer(String* input, | 4079 static void ReadBlockIntoBuffer(String* input, |
4169 ReadBlockBuffer* buffer, | 4080 ReadBlockBuffer* buffer, |
4170 unsigned* offset_ptr, | 4081 unsigned* offset_ptr, |
4171 unsigned max_chars); | 4082 unsigned max_chars); |
4172 | 4083 |
4173 private: | 4084 private: |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4338 unsigned chars); | 4249 unsigned chars); |
4339 | 4250 |
4340 // Minimum length for a cons string. | 4251 // Minimum length for a cons string. |
4341 static const int kMinLength = 13; | 4252 static const int kMinLength = 13; |
4342 | 4253 |
4343 private: | 4254 private: |
4344 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); | 4255 DISALLOW_IMPLICIT_CONSTRUCTORS(ConsString); |
4345 }; | 4256 }; |
4346 | 4257 |
4347 | 4258 |
4348 // The SlicedString class describes string values that are slices of | |
4349 // some other string. SlicedStrings consist of a reference to an | |
4350 // underlying heap-allocated string value, a start index, and the | |
4351 // length field common to all strings. | |
4352 class SlicedString: public String { | |
4353 public: | |
4354 // The underlying string buffer. | |
4355 inline String* buffer(); | |
4356 inline void set_buffer(String* buffer); | |
4357 | |
4358 // The start index of the slice. | |
4359 inline int start(); | |
4360 inline void set_start(int start); | |
4361 | |
4362 // Dispatched behavior. | |
4363 uint16_t SlicedStringGet(int index); | |
4364 | |
4365 // Casting. | |
4366 static inline SlicedString* cast(Object* obj); | |
4367 | |
4368 // Garbage collection support. | |
4369 void SlicedStringIterateBody(ObjectVisitor* v); | |
4370 | |
4371 // Layout description | |
4372 #if V8_HOST_ARCH_64_BIT | |
4373 // Optimizations expect buffer to be located at same offset as a ConsString's | |
4374 // first substring. In 64 bit mode we have room for the start offset before | |
4375 // the buffer. | |
4376 static const int kStartOffset = String::kSize; | |
4377 static const int kBufferOffset = kStartOffset + kIntSize; | |
4378 static const int kSize = kBufferOffset + kPointerSize; | |
4379 #else | |
4380 static const int kBufferOffset = String::kSize; | |
4381 static const int kStartOffset = kBufferOffset + kPointerSize; | |
4382 static const int kSize = kStartOffset + kIntSize; | |
4383 #endif | |
4384 | |
4385 // Support for StringInputBuffer. | |
4386 inline const unibrow::byte* SlicedStringReadBlock(ReadBlockBuffer* buffer, | |
4387 unsigned* offset_ptr, | |
4388 unsigned chars); | |
4389 inline void SlicedStringReadBlockIntoBuffer(ReadBlockBuffer* buffer, | |
4390 unsigned* offset_ptr, | |
4391 unsigned chars); | |
4392 | |
4393 private: | |
4394 DISALLOW_IMPLICIT_CONSTRUCTORS(SlicedString); | |
4395 }; | |
4396 | |
4397 | |
4398 // The ExternalString class describes string values that are backed by | 4259 // The ExternalString class describes string values that are backed by |
4399 // a string resource that lies outside the V8 heap. ExternalStrings | 4260 // a string resource that lies outside the V8 heap. ExternalStrings |
4400 // consist of the length field common to all strings, a pointer to the | 4261 // consist of the length field common to all strings, a pointer to the |
4401 // external resource. It is important to ensure (externally) that the | 4262 // external resource. It is important to ensure (externally) that the |
4402 // resource is not deallocated while the ExternalString is live in the | 4263 // resource is not deallocated while the ExternalString is live in the |
4403 // V8 heap. | 4264 // V8 heap. |
4404 // | 4265 // |
4405 // The API expects that all ExternalStrings are created through the | 4266 // The API expects that all ExternalStrings are created through the |
4406 // API. Therefore, ExternalStrings should not be used internally. | 4267 // API. Therefore, ExternalStrings should not be used internally. |
4407 class ExternalString: public String { | 4268 class ExternalString: public String { |
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5161 } else { | 5022 } else { |
5162 value &= ~(1 << bit_position); | 5023 value &= ~(1 << bit_position); |
5163 } | 5024 } |
5164 return value; | 5025 return value; |
5165 } | 5026 } |
5166 }; | 5027 }; |
5167 | 5028 |
5168 } } // namespace v8::internal | 5029 } } // namespace v8::internal |
5169 | 5030 |
5170 #endif // V8_OBJECTS_H_ | 5031 #endif // V8_OBJECTS_H_ |
OLD | NEW |