Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1130)

Side by Side Diff: src/objects.h

Issue 8681007: Rolling back r10049 due to webkit failures. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 // JSObject for GC purposes. The first four entries here have typeof 225 // JSObject for GC purposes. The first four entries here have typeof
226 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'. 226 // 'object', whereas JS_FUNCTION_TYPE has typeof 'function'.
227 #define INSTANCE_TYPE_LIST_ALL(V) \ 227 #define INSTANCE_TYPE_LIST_ALL(V) \
228 V(SYMBOL_TYPE) \ 228 V(SYMBOL_TYPE) \
229 V(ASCII_SYMBOL_TYPE) \ 229 V(ASCII_SYMBOL_TYPE) \
230 V(CONS_SYMBOL_TYPE) \ 230 V(CONS_SYMBOL_TYPE) \
231 V(CONS_ASCII_SYMBOL_TYPE) \ 231 V(CONS_ASCII_SYMBOL_TYPE) \
232 V(EXTERNAL_SYMBOL_TYPE) \ 232 V(EXTERNAL_SYMBOL_TYPE) \
233 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \ 233 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \
234 V(EXTERNAL_ASCII_SYMBOL_TYPE) \ 234 V(EXTERNAL_ASCII_SYMBOL_TYPE) \
235 V(SHORT_EXTERNAL_SYMBOL_TYPE) \
236 V(SHORT_EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE) \
237 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE) \
238 V(STRING_TYPE) \ 235 V(STRING_TYPE) \
239 V(ASCII_STRING_TYPE) \ 236 V(ASCII_STRING_TYPE) \
240 V(CONS_STRING_TYPE) \ 237 V(CONS_STRING_TYPE) \
241 V(CONS_ASCII_STRING_TYPE) \ 238 V(CONS_ASCII_STRING_TYPE) \
242 V(SLICED_STRING_TYPE) \ 239 V(SLICED_STRING_TYPE) \
243 V(EXTERNAL_STRING_TYPE) \ 240 V(EXTERNAL_STRING_TYPE) \
244 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \ 241 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \
245 V(EXTERNAL_ASCII_STRING_TYPE) \ 242 V(EXTERNAL_ASCII_STRING_TYPE) \
246 V(SHORT_EXTERNAL_STRING_TYPE) \
247 V(SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE) \
248 V(SHORT_EXTERNAL_ASCII_STRING_TYPE) \
249 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ 243 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \
250 \ 244 \
251 V(MAP_TYPE) \ 245 V(MAP_TYPE) \
252 V(CODE_TYPE) \ 246 V(CODE_TYPE) \
253 V(ODDBALL_TYPE) \ 247 V(ODDBALL_TYPE) \
254 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ 248 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \
255 \ 249 \
256 V(HEAP_NUMBER_TYPE) \ 250 V(HEAP_NUMBER_TYPE) \
257 V(FOREIGN_TYPE) \ 251 V(FOREIGN_TYPE) \
258 V(BYTE_ARRAY_TYPE) \ 252 V(BYTE_ARRAY_TYPE) \
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 external_symbol, \ 333 external_symbol, \
340 ExternalSymbol) \ 334 ExternalSymbol) \
341 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE, \ 335 V(EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE, \
342 ExternalTwoByteString::kSize, \ 336 ExternalTwoByteString::kSize, \
343 external_symbol_with_ascii_data, \ 337 external_symbol_with_ascii_data, \
344 ExternalSymbolWithAsciiData) \ 338 ExternalSymbolWithAsciiData) \
345 V(EXTERNAL_ASCII_SYMBOL_TYPE, \ 339 V(EXTERNAL_ASCII_SYMBOL_TYPE, \
346 ExternalAsciiString::kSize, \ 340 ExternalAsciiString::kSize, \
347 external_ascii_symbol, \ 341 external_ascii_symbol, \
348 ExternalAsciiSymbol) \ 342 ExternalAsciiSymbol) \
349 V(SHORT_EXTERNAL_SYMBOL_TYPE, \
350 ExternalTwoByteString::kShortSize, \
351 short_external_symbol, \
352 ShortExternalSymbol) \
353 V(SHORT_EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE, \
354 ExternalTwoByteString::kShortSize, \
355 short_external_symbol_with_ascii_data, \
356 ShortExternalSymbolWithAsciiData) \
357 V(SHORT_EXTERNAL_ASCII_SYMBOL_TYPE, \
358 ExternalAsciiString::kShortSize, \
359 short_external_ascii_symbol, \
360 ShortExternalAsciiSymbol) \
361 V(STRING_TYPE, \ 343 V(STRING_TYPE, \
362 kVariableSizeSentinel, \ 344 kVariableSizeSentinel, \
363 string, \ 345 string, \
364 String) \ 346 String) \
365 V(ASCII_STRING_TYPE, \ 347 V(ASCII_STRING_TYPE, \
366 kVariableSizeSentinel, \ 348 kVariableSizeSentinel, \
367 ascii_string, \ 349 ascii_string, \
368 AsciiString) \ 350 AsciiString) \
369 V(CONS_STRING_TYPE, \ 351 V(CONS_STRING_TYPE, \
370 ConsString::kSize, \ 352 ConsString::kSize, \
(...skipping 15 matching lines...) Expand all
386 ExternalTwoByteString::kSize, \ 368 ExternalTwoByteString::kSize, \
387 external_string, \ 369 external_string, \
388 ExternalString) \ 370 ExternalString) \
389 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \ 371 V(EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \
390 ExternalTwoByteString::kSize, \ 372 ExternalTwoByteString::kSize, \
391 external_string_with_ascii_data, \ 373 external_string_with_ascii_data, \
392 ExternalStringWithAsciiData) \ 374 ExternalStringWithAsciiData) \
393 V(EXTERNAL_ASCII_STRING_TYPE, \ 375 V(EXTERNAL_ASCII_STRING_TYPE, \
394 ExternalAsciiString::kSize, \ 376 ExternalAsciiString::kSize, \
395 external_ascii_string, \ 377 external_ascii_string, \
396 ExternalAsciiString) \ 378 ExternalAsciiString)
397 V(SHORT_EXTERNAL_STRING_TYPE, \
398 ExternalTwoByteString::kShortSize, \
399 short_external_string, \
400 ShortExternalString) \
401 V(SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE, \
402 ExternalTwoByteString::kShortSize, \
403 short_external_string_with_ascii_data, \
404 ShortExternalStringWithAsciiData) \
405 V(SHORT_EXTERNAL_ASCII_STRING_TYPE, \
406 ExternalAsciiString::kShortSize, \
407 short_external_ascii_string, \
408 ShortExternalAsciiString)
409 379
410 // A struct is a simple object a set of object-valued fields. Including an 380 // A struct is a simple object a set of object-valued fields. Including an
411 // object type in this causes the compiler to generate most of the boilerplate 381 // object type in this causes the compiler to generate most of the boilerplate
412 // code for the class including allocation and garbage collection routines, 382 // code for the class including allocation and garbage collection routines,
413 // casts and predicates. All you need to define is the class, methods and 383 // casts and predicates. All you need to define is the class, methods and
414 // object verification routines. Easy, no? 384 // object verification routines. Easy, no?
415 // 385 //
416 // Note that for subtle reasons related to the ordering or numerical values of 386 // Note that for subtle reasons related to the ordering or numerical values of
417 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST 387 // type tags, elements in this list have to be added to the INSTANCE_TYPE_LIST
418 // manually. 388 // manually.
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 // Use this mask to distinguish between cons and slice only after making 452 // Use this mask to distinguish between cons and slice only after making
483 // sure that the string is one of the two (an indirect string). 453 // sure that the string is one of the two (an indirect string).
484 const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag; 454 const uint32_t kSlicedNotConsMask = kSlicedStringTag & ~kConsStringTag;
485 STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask) && kSlicedNotConsMask != 0); 455 STATIC_ASSERT(IS_POWER_OF_TWO(kSlicedNotConsMask) && kSlicedNotConsMask != 0);
486 456
487 // If bit 7 is clear, then bit 3 indicates whether this two-byte 457 // If bit 7 is clear, then bit 3 indicates whether this two-byte
488 // string actually contains ascii data. 458 // string actually contains ascii data.
489 const uint32_t kAsciiDataHintMask = 0x08; 459 const uint32_t kAsciiDataHintMask = 0x08;
490 const uint32_t kAsciiDataHintTag = 0x08; 460 const uint32_t kAsciiDataHintTag = 0x08;
491 461
492 // If bit 7 is clear and string representation indicates an external string,
493 // then bit 4 indicates whether the data pointer is cached.
494 const uint32_t kShortExternalStringMask = 0x10;
495 const uint32_t kShortExternalStringTag = 0x10;
496
497 462
498 // A ConsString with an empty string as the right side is a candidate 463 // A ConsString with an empty string as the right side is a candidate
499 // for being shortcut by the garbage collector unless it is a 464 // for being shortcut by the garbage collector unless it is a
500 // symbol. It's not common to have non-flat symbols, so we do not 465 // symbol. It's not common to have non-flat symbols, so we do not
501 // shortcut them thereby avoiding turning symbols into strings. See 466 // shortcut them thereby avoiding turning symbols into strings. See
502 // heap.cc and mark-compact.cc. 467 // heap.cc and mark-compact.cc.
503 const uint32_t kShortcutTypeMask = 468 const uint32_t kShortcutTypeMask =
504 kIsNotStringMask | 469 kIsNotStringMask |
505 kIsSymbolMask | 470 kIsSymbolMask |
506 kStringRepresentationMask; 471 kStringRepresentationMask;
507 const uint32_t kShortcutTypeTag = kConsStringTag; 472 const uint32_t kShortcutTypeTag = kConsStringTag;
508 473
509 474
510 enum InstanceType { 475 enum InstanceType {
511 // String types. 476 // String types.
512 SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kSeqStringTag, 477 SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kSeqStringTag,
513 ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSeqStringTag, 478 ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kSeqStringTag,
514 CONS_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kConsStringTag, 479 CONS_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kConsStringTag,
515 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag, 480 CONS_ASCII_SYMBOL_TYPE = kAsciiStringTag | kSymbolTag | kConsStringTag,
516 SHORT_EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag |
517 kExternalStringTag | kShortExternalStringTag,
518 SHORT_EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE =
519 kTwoByteStringTag | kSymbolTag | kExternalStringTag |
520 kAsciiDataHintTag | kShortExternalStringTag,
521 SHORT_EXTERNAL_ASCII_SYMBOL_TYPE = kAsciiStringTag | kExternalStringTag |
522 kSymbolTag | kShortExternalStringTag,
523 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag, 481 EXTERNAL_SYMBOL_TYPE = kTwoByteStringTag | kSymbolTag | kExternalStringTag,
524 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE = 482 EXTERNAL_SYMBOL_WITH_ASCII_DATA_TYPE =
525 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag, 483 kTwoByteStringTag | kSymbolTag | kExternalStringTag | kAsciiDataHintTag,
526 EXTERNAL_ASCII_SYMBOL_TYPE = 484 EXTERNAL_ASCII_SYMBOL_TYPE =
527 kAsciiStringTag | kSymbolTag | kExternalStringTag, 485 kAsciiStringTag | kSymbolTag | kExternalStringTag,
528 STRING_TYPE = kTwoByteStringTag | kSeqStringTag, 486 STRING_TYPE = kTwoByteStringTag | kSeqStringTag,
529 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag, 487 ASCII_STRING_TYPE = kAsciiStringTag | kSeqStringTag,
530 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag, 488 CONS_STRING_TYPE = kTwoByteStringTag | kConsStringTag,
531 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag, 489 CONS_ASCII_STRING_TYPE = kAsciiStringTag | kConsStringTag,
532 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag, 490 SLICED_STRING_TYPE = kTwoByteStringTag | kSlicedStringTag,
533 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag, 491 SLICED_ASCII_STRING_TYPE = kAsciiStringTag | kSlicedStringTag,
534 SHORT_EXTERNAL_STRING_TYPE =
535 kTwoByteStringTag | kExternalStringTag | kShortExternalStringTag,
536 SHORT_EXTERNAL_STRING_WITH_ASCII_DATA_TYPE =
537 kTwoByteStringTag | kExternalStringTag |
538 kAsciiDataHintTag | kShortExternalStringTag,
539 SHORT_EXTERNAL_ASCII_STRING_TYPE =
540 kAsciiStringTag | kExternalStringTag | kShortExternalStringTag,
541 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag, 492 EXTERNAL_STRING_TYPE = kTwoByteStringTag | kExternalStringTag,
542 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE = 493 EXTERNAL_STRING_WITH_ASCII_DATA_TYPE =
543 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag, 494 kTwoByteStringTag | kExternalStringTag | kAsciiDataHintTag,
544 // LAST_STRING_TYPE 495 // LAST_STRING_TYPE
545 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag, 496 EXTERNAL_ASCII_STRING_TYPE = kAsciiStringTag | kExternalStringTag,
546 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE, 497 PRIVATE_EXTERNAL_ASCII_STRING_TYPE = EXTERNAL_ASCII_STRING_TYPE,
547 498
548 // Objects allocated in their own spaces (never in new space). 499 // Objects allocated in their own spaces (never in new space).
549 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE 500 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE
550 CODE_TYPE, 501 CODE_TYPE,
(...skipping 6246 matching lines...) Expand 10 before | Expand all | Expand 10 after
6797 // 6748 //
6798 // The API expects that all ExternalStrings are created through the 6749 // The API expects that all ExternalStrings are created through the
6799 // API. Therefore, ExternalStrings should not be used internally. 6750 // API. Therefore, ExternalStrings should not be used internally.
6800 class ExternalString: public String { 6751 class ExternalString: public String {
6801 public: 6752 public:
6802 // Casting 6753 // Casting
6803 static inline ExternalString* cast(Object* obj); 6754 static inline ExternalString* cast(Object* obj);
6804 6755
6805 // Layout description. 6756 // Layout description.
6806 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize); 6757 static const int kResourceOffset = POINTER_SIZE_ALIGN(String::kSize);
6807 static const int kShortSize = kResourceOffset + kPointerSize;
6808 static const int kResourceDataOffset = kResourceOffset + kPointerSize; 6758 static const int kResourceDataOffset = kResourceOffset + kPointerSize;
6809 static const int kSize = kResourceDataOffset + kPointerSize; 6759 static const int kSize = kResourceDataOffset + kPointerSize;
6810 6760
6811 // Return whether external string is short (data pointer is not cached). 6761 // Clear the cached pointer to the character array provided by the resource.
6812 inline bool is_short(); 6762 // This cache is updated the first time the character array is accessed.
6763 inline void clear_data_cache();
6813 6764
6814 STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset); 6765 STATIC_CHECK(kResourceOffset == Internals::kStringResourceOffset);
6815 6766
6816 private: 6767 private:
6817 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString); 6768 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalString);
6818 }; 6769 };
6819 6770
6820 6771
6821 // The ExternalAsciiString class is an external string backed by an 6772 // The ExternalAsciiString class is an external string backed by an
6822 // ASCII string. 6773 // ASCII string.
6823 class ExternalAsciiString: public ExternalString { 6774 class ExternalAsciiString: public ExternalString {
6824 public: 6775 public:
6825 static const bool kHasAsciiEncoding = true; 6776 static const bool kHasAsciiEncoding = true;
6826 6777
6827 typedef v8::String::ExternalAsciiStringResource Resource; 6778 typedef v8::String::ExternalAsciiStringResource Resource;
6828 6779
6829 // The underlying resource. 6780 // The underlying resource.
6830 inline const Resource* resource(); 6781 inline const Resource* resource();
6831 inline void set_resource(const Resource* buffer); 6782 inline void set_resource(const Resource* buffer);
6832 6783
6833 // Update the pointer cache to the external character array.
6834 // The cached pointer is always valid, as the external character array does =
6835 // not move during lifetime. Deserialization is the only exception, after
6836 // which the pointer cache has to be refreshed.
6837 inline void update_data_cache();
6838
6839 inline const char* GetChars(); 6784 inline const char* GetChars();
6840 6785
6841 // Dispatched behavior. 6786 // Dispatched behavior.
6842 inline uint16_t ExternalAsciiStringGet(int index); 6787 inline uint16_t ExternalAsciiStringGet(int index);
6843 6788
6844 // Casting. 6789 // Casting.
6845 static inline ExternalAsciiString* cast(Object* obj); 6790 static inline ExternalAsciiString* cast(Object* obj);
6846 6791
6847 // Garbage collection support. 6792 // Garbage collection support.
6848 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v); 6793 inline void ExternalAsciiStringIterateBody(ObjectVisitor* v);
(...skipping 19 matching lines...) Expand all
6868 class ExternalTwoByteString: public ExternalString { 6813 class ExternalTwoByteString: public ExternalString {
6869 public: 6814 public:
6870 static const bool kHasAsciiEncoding = false; 6815 static const bool kHasAsciiEncoding = false;
6871 6816
6872 typedef v8::String::ExternalStringResource Resource; 6817 typedef v8::String::ExternalStringResource Resource;
6873 6818
6874 // The underlying string resource. 6819 // The underlying string resource.
6875 inline const Resource* resource(); 6820 inline const Resource* resource();
6876 inline void set_resource(const Resource* buffer); 6821 inline void set_resource(const Resource* buffer);
6877 6822
6878 // Update the pointer cache to the external character array.
6879 // The cached pointer is always valid, as the external character array does =
6880 // not move during lifetime. Deserialization is the only exception, after
6881 // which the pointer cache has to be refreshed.
6882 inline void update_data_cache();
6883
6884 inline const uint16_t* GetChars(); 6823 inline const uint16_t* GetChars();
6885 6824
6886 // Dispatched behavior. 6825 // Dispatched behavior.
6887 inline uint16_t ExternalTwoByteStringGet(int index); 6826 inline uint16_t ExternalTwoByteStringGet(int index);
6888 6827
6889 // For regexp code. 6828 // For regexp code.
6890 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start); 6829 inline const uint16_t* ExternalTwoByteStringGetData(unsigned start);
6891 6830
6892 // Casting. 6831 // Casting.
6893 static inline ExternalTwoByteString* cast(Object* obj); 6832 static inline ExternalTwoByteString* cast(Object* obj);
(...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after
7945 } else { 7884 } else {
7946 value &= ~(1 << bit_position); 7885 value &= ~(1 << bit_position);
7947 } 7886 }
7948 return value; 7887 return value;
7949 } 7888 }
7950 }; 7889 };
7951 7890
7952 } } // namespace v8::internal 7891 } } // namespace v8::internal
7953 7892
7954 #endif // V8_OBJECTS_H_ 7893 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ia32/codegen-ia32.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698