| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 578 Object* ptr; | 578 Object* ptr; |
| 579 const char* str; | 579 const char* str; |
| 580 double number; | 580 double number; |
| 581 }; | 581 }; |
| 582 | 582 |
| 583 | 583 |
| 584 // A template-ized version of the IsXXX functions. | 584 // A template-ized version of the IsXXX functions. |
| 585 template <class C> static inline bool Is(Object* obj); | 585 template <class C> static inline bool Is(Object* obj); |
| 586 | 586 |
| 587 | 587 |
| 588 class Object; |
| 589 |
| 590 |
| 591 class TryAllocation BASE_EMBEDDED { |
| 592 public: |
| 593 inline bool ToObject(Object** out) { |
| 594 if (this->IsFailure()) return false; |
| 595 *out = Object::cast(this); |
| 596 return true; |
| 597 } |
| 598 }; |
| 599 |
| 600 |
| 588 // Object is the abstract superclass for all classes in the | 601 // Object is the abstract superclass for all classes in the |
| 589 // object hierarchy. | 602 // object hierarchy. |
| 590 // Object does not use any virtual functions to avoid the | 603 // Object does not use any virtual functions to avoid the |
| 591 // allocation of the C++ vtable. | 604 // allocation of the C++ vtable. |
| 592 // Since Smi and Failure are subclasses of Object no | 605 // Since Smi and Failure are subclasses of Object no |
| 593 // data members can be present in Object. | 606 // data members can be present in Object. |
| 594 class Object BASE_EMBEDDED { | 607 class Object : public TryAllocation { |
| 595 public: | 608 public: |
| 596 // Type testing. | 609 // Type testing. |
| 597 inline bool IsSmi(); | 610 inline bool IsSmi(); |
| 598 inline bool IsHeapObject(); | 611 inline bool IsHeapObject(); |
| 599 inline bool IsHeapNumber(); | 612 inline bool IsHeapNumber(); |
| 600 inline bool IsString(); | 613 inline bool IsString(); |
| 601 inline bool IsSymbol(); | 614 inline bool IsSymbol(); |
| 602 // See objects-inl.h for more details | 615 // See objects-inl.h for more details |
| 603 inline bool IsSeqString(); | 616 inline bool IsSeqString(); |
| 604 inline bool IsExternalString(); | 617 inline bool IsExternalString(); |
| 605 inline bool IsExternalTwoByteString(); | 618 inline bool IsExternalTwoByteString(); |
| 606 inline bool IsExternalAsciiString(); | 619 inline bool IsExternalAsciiString(); |
| 607 inline bool IsSeqTwoByteString(); | 620 inline bool IsSeqTwoByteString(); |
| 608 inline bool IsSeqAsciiString(); | 621 inline bool IsSeqAsciiString(); |
| 609 inline bool IsConsString(); | 622 inline bool IsConsString(); |
| 610 | 623 |
| 611 inline bool IsNumber(); | 624 inline bool IsNumber(); |
| 612 inline bool IsByteArray(); | 625 inline bool IsByteArray(); |
| 613 inline bool IsPixelArray(); | 626 inline bool IsPixelArray(); |
| 614 inline bool IsExternalArray(); | 627 inline bool IsExternalArray(); |
| 615 inline bool IsExternalByteArray(); | 628 inline bool IsExternalByteArray(); |
| 616 inline bool IsExternalUnsignedByteArray(); | 629 inline bool IsExternalUnsignedByteArray(); |
| 617 inline bool IsExternalShortArray(); | 630 inline bool IsExternalShortArray(); |
| 618 inline bool IsExternalUnsignedShortArray(); | 631 inline bool IsExternalUnsignedShortArray(); |
| 619 inline bool IsExternalIntArray(); | 632 inline bool IsExternalIntArray(); |
| 620 inline bool IsExternalUnsignedIntArray(); | 633 inline bool IsExternalUnsignedIntArray(); |
| 621 inline bool IsExternalFloatArray(); | 634 inline bool IsExternalFloatArray(); |
| 622 inline bool IsFailure(); | |
| 623 inline bool IsRetryAfterGC(); | 635 inline bool IsRetryAfterGC(); |
| 624 inline bool IsOutOfMemoryFailure(); | 636 inline bool IsOutOfMemoryFailure(); |
| 625 inline bool IsException(); | 637 inline bool IsException(); |
| 626 inline bool IsJSObject(); | 638 inline bool IsJSObject(); |
| 627 inline bool IsJSContextExtensionObject(); | 639 inline bool IsJSContextExtensionObject(); |
| 628 inline bool IsMap(); | 640 inline bool IsMap(); |
| 629 inline bool IsFixedArray(); | 641 inline bool IsFixedArray(); |
| 630 inline bool IsDescriptorArray(); | 642 inline bool IsDescriptorArray(); |
| 631 inline bool IsContext(); | 643 inline bool IsContext(); |
| 632 inline bool IsCatchContext(); | 644 inline bool IsCatchContext(); |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 813 // | 825 // |
| 814 // The remaining bits is the size of the allocation request in units | 826 // The remaining bits is the size of the allocation request in units |
| 815 // of the pointer size, and is zeroed except for RETRY_AFTER_GC | 827 // of the pointer size, and is zeroed except for RETRY_AFTER_GC |
| 816 // failures. The 25 bits (on a 32 bit platform) gives a representable | 828 // failures. The 25 bits (on a 32 bit platform) gives a representable |
| 817 // range of 2^27 bytes (128MB). | 829 // range of 2^27 bytes (128MB). |
| 818 | 830 |
| 819 // Failure type tag info. | 831 // Failure type tag info. |
| 820 const int kFailureTypeTagSize = 2; | 832 const int kFailureTypeTagSize = 2; |
| 821 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; | 833 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; |
| 822 | 834 |
| 823 class Failure: public Object { | 835 class Failure: public TryAllocation { |
| 824 public: | 836 public: |
| 825 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. | 837 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. |
| 826 enum Type { | 838 enum Type { |
| 827 RETRY_AFTER_GC = 0, | 839 RETRY_AFTER_GC = 0, |
| 828 EXCEPTION = 1, // Returning this marker tells the real exception | 840 EXCEPTION = 1, // Returning this marker tells the real exception |
| 829 // is in Top::pending_exception. | 841 // is in Top::pending_exception. |
| 830 INTERNAL_ERROR = 2, | 842 INTERNAL_ERROR = 2, |
| 831 OUT_OF_MEMORY_EXCEPTION = 3 | 843 OUT_OF_MEMORY_EXCEPTION = 3 |
| 832 }; | 844 }; |
| 833 | 845 |
| (...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1275 inline NumberDictionary* element_dictionary(); // Gets slow elements. | 1287 inline NumberDictionary* element_dictionary(); // Gets slow elements. |
| 1276 // Requires: this->HasFastElements(). | 1288 // Requires: this->HasFastElements(). |
| 1277 inline Object* EnsureWritableFastElements(); | 1289 inline Object* EnsureWritableFastElements(); |
| 1278 | 1290 |
| 1279 // Collects elements starting at index 0. | 1291 // Collects elements starting at index 0. |
| 1280 // Undefined values are placed after non-undefined values. | 1292 // Undefined values are placed after non-undefined values. |
| 1281 // Returns the number of non-undefined values. | 1293 // Returns the number of non-undefined values. |
| 1282 Object* PrepareElementsForSort(uint32_t limit); | 1294 Object* PrepareElementsForSort(uint32_t limit); |
| 1283 // As PrepareElementsForSort, but only on objects where elements is | 1295 // As PrepareElementsForSort, but only on objects where elements is |
| 1284 // a dictionary, and it will stay a dictionary. | 1296 // a dictionary, and it will stay a dictionary. |
| 1285 MUST_USE_RESULT Object* PrepareSlowElementsForSort(uint32_t limit); | 1297 TryAllocation* PrepareSlowElementsForSort(uint32_t limit); |
| 1286 | 1298 |
| 1287 Object* SetProperty(String* key, | 1299 Object* SetProperty(String* key, |
| 1288 Object* value, | 1300 Object* value, |
| 1289 PropertyAttributes attributes); | 1301 PropertyAttributes attributes); |
| 1290 Object* SetProperty(LookupResult* result, | 1302 Object* SetProperty(LookupResult* result, |
| 1291 String* key, | 1303 String* key, |
| 1292 Object* value, | 1304 Object* value, |
| 1293 PropertyAttributes attributes); | 1305 PropertyAttributes attributes); |
| 1294 Object* SetPropertyWithFailedAccessCheck(LookupResult* result, | 1306 Object* SetPropertyWithFailedAccessCheck(LookupResult* result, |
| 1295 String* name, | 1307 String* name, |
| (...skipping 4423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5719 } else { | 5731 } else { |
| 5720 value &= ~(1 << bit_position); | 5732 value &= ~(1 << bit_position); |
| 5721 } | 5733 } |
| 5722 return value; | 5734 return value; |
| 5723 } | 5735 } |
| 5724 }; | 5736 }; |
| 5725 | 5737 |
| 5726 } } // namespace v8::internal | 5738 } } // namespace v8::internal |
| 5727 | 5739 |
| 5728 #endif // V8_OBJECTS_H_ | 5740 #endif // V8_OBJECTS_H_ |
| OLD | NEW |