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

Side by Side Diff: src/objects.h

Issue 3970005: Make Failure inherit from MaybeObject instead of Object. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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/messages.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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 23 matching lines...) Expand all
34 #if V8_TARGET_ARCH_ARM 34 #if V8_TARGET_ARCH_ARM
35 #include "arm/constants-arm.h" 35 #include "arm/constants-arm.h"
36 #elif V8_TARGET_ARCH_MIPS 36 #elif V8_TARGET_ARCH_MIPS
37 #include "mips/constants-mips.h" 37 #include "mips/constants-mips.h"
38 #endif 38 #endif
39 39
40 // 40 //
41 // Most object types in the V8 JavaScript are described in this file. 41 // Most object types in the V8 JavaScript are described in this file.
42 // 42 //
43 // Inheritance hierarchy: 43 // Inheritance hierarchy:
44 // - MaybeObject (an object or a failure)
45 // - Failure (immediate for marking failed operation)
44 // - Object 46 // - Object
45 // - Smi (immediate small integer) 47 // - Smi (immediate small integer)
46 // - Failure (immediate for marking failed operation)
47 // - HeapObject (superclass for everything allocated in the heap) 48 // - HeapObject (superclass for everything allocated in the heap)
48 // - JSObject 49 // - JSObject
49 // - JSArray 50 // - JSArray
50 // - JSRegExp 51 // - JSRegExp
51 // - JSFunction 52 // - JSFunction
52 // - GlobalObject 53 // - GlobalObject
53 // - JSGlobalObject 54 // - JSGlobalObject
54 // - JSBuiltinsObject 55 // - JSBuiltinsObject
55 // - JSGlobalProxy 56 // - JSGlobalProxy
56 // - JSValue 57 // - JSValue
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 InstanceType type; 578 InstanceType type;
578 Object* ptr; 579 Object* ptr;
579 const char* str; 580 const char* str;
580 double number; 581 double number;
581 }; 582 };
582 583
583 584
584 // A template-ized version of the IsXXX functions. 585 // A template-ized version of the IsXXX functions.
585 template <class C> static inline bool Is(Object* obj); 586 template <class C> static inline bool Is(Object* obj);
586 587
588 class MaybeObject BASE_EMBEDDED {
589 public:
590 inline bool IsFailure();
591 inline bool IsRetryAfterGC();
592 inline bool IsOutOfMemory();
593 inline bool IsException();
594 INLINE(bool IsTheHole());
595 inline bool ToObject(Object** obj) {
596 if (IsFailure()) return false;
597 *obj = reinterpret_cast<Object*>(this);
598 return true;
599 }
600 inline Object* ToObjectUnchecked() {
601 ASSERT(!IsFailure());
602 return reinterpret_cast<Object*>(this);
603 }
604 inline Object* ToObjectChecked() {
605 CHECK(!IsFailure());
606 return reinterpret_cast<Object*>(this);
607 }
608
609 #ifdef DEBUG
610 // Prints this object with details.
611 void Print();
612 void PrintLn();
613 // Verifies the object.
614 void Verify();
615 #endif
616 };
587 617
588 // Object is the abstract superclass for all classes in the 618 // Object is the abstract superclass for all classes in the
589 // object hierarchy. 619 // object hierarchy.
590 // Object does not use any virtual functions to avoid the 620 // Object does not use any virtual functions to avoid the
591 // allocation of the C++ vtable. 621 // allocation of the C++ vtable.
592 // Since Smi and Failure are subclasses of Object no 622 // Since Smi and Failure are subclasses of Object no
593 // data members can be present in Object. 623 // data members can be present in Object.
594 class Object BASE_EMBEDDED { 624 class Object : public MaybeObject {
595 public: 625 public:
596 // Type testing. 626 // Type testing.
597 inline bool IsSmi(); 627 inline bool IsSmi();
598 inline bool IsHeapObject(); 628 inline bool IsHeapObject();
599 inline bool IsHeapNumber(); 629 inline bool IsHeapNumber();
600 inline bool IsString(); 630 inline bool IsString();
601 inline bool IsSymbol(); 631 inline bool IsSymbol();
602 // See objects-inl.h for more details 632 // See objects-inl.h for more details
603 inline bool IsSeqString(); 633 inline bool IsSeqString();
604 inline bool IsExternalString(); 634 inline bool IsExternalString();
605 inline bool IsExternalTwoByteString(); 635 inline bool IsExternalTwoByteString();
606 inline bool IsExternalAsciiString(); 636 inline bool IsExternalAsciiString();
607 inline bool IsSeqTwoByteString(); 637 inline bool IsSeqTwoByteString();
608 inline bool IsSeqAsciiString(); 638 inline bool IsSeqAsciiString();
609 inline bool IsConsString(); 639 inline bool IsConsString();
610 640
611 inline bool IsNumber(); 641 inline bool IsNumber();
612 inline bool IsByteArray(); 642 inline bool IsByteArray();
613 inline bool IsPixelArray(); 643 inline bool IsPixelArray();
614 inline bool IsExternalArray(); 644 inline bool IsExternalArray();
615 inline bool IsExternalByteArray(); 645 inline bool IsExternalByteArray();
616 inline bool IsExternalUnsignedByteArray(); 646 inline bool IsExternalUnsignedByteArray();
617 inline bool IsExternalShortArray(); 647 inline bool IsExternalShortArray();
618 inline bool IsExternalUnsignedShortArray(); 648 inline bool IsExternalUnsignedShortArray();
619 inline bool IsExternalIntArray(); 649 inline bool IsExternalIntArray();
620 inline bool IsExternalUnsignedIntArray(); 650 inline bool IsExternalUnsignedIntArray();
621 inline bool IsExternalFloatArray(); 651 inline bool IsExternalFloatArray();
622 inline bool IsFailure();
623 inline bool IsRetryAfterGC();
624 inline bool IsOutOfMemoryFailure();
625 inline bool IsException();
626 inline bool IsJSObject(); 652 inline bool IsJSObject();
627 inline bool IsJSContextExtensionObject(); 653 inline bool IsJSContextExtensionObject();
628 inline bool IsMap(); 654 inline bool IsMap();
629 inline bool IsFixedArray(); 655 inline bool IsFixedArray();
630 inline bool IsDescriptorArray(); 656 inline bool IsDescriptorArray();
631 inline bool IsContext(); 657 inline bool IsContext();
632 inline bool IsCatchContext(); 658 inline bool IsCatchContext();
633 inline bool IsGlobalContext(); 659 inline bool IsGlobalContext();
634 inline bool IsJSFunction(); 660 inline bool IsJSFunction();
635 inline bool IsCode(); 661 inline bool IsCode();
(...skipping 26 matching lines...) Expand all
662 // function template. 688 // function template.
663 inline bool IsInstanceOf(FunctionTemplateInfo* type); 689 inline bool IsInstanceOf(FunctionTemplateInfo* type);
664 690
665 inline bool IsStruct(); 691 inline bool IsStruct();
666 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name(); 692 #define DECLARE_STRUCT_PREDICATE(NAME, Name, name) inline bool Is##Name();
667 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) 693 STRUCT_LIST(DECLARE_STRUCT_PREDICATE)
668 #undef DECLARE_STRUCT_PREDICATE 694 #undef DECLARE_STRUCT_PREDICATE
669 695
670 // Oddball testing. 696 // Oddball testing.
671 INLINE(bool IsUndefined()); 697 INLINE(bool IsUndefined());
672 INLINE(bool IsTheHole());
673 INLINE(bool IsNull()); 698 INLINE(bool IsNull());
674 INLINE(bool IsTrue()); 699 INLINE(bool IsTrue());
675 INLINE(bool IsFalse()); 700 INLINE(bool IsFalse());
676 701
677 // Extract the number. 702 // Extract the number.
678 inline double Number(); 703 inline double Number();
679 704
680 inline bool HasSpecificClassOf(String* name); 705 inline bool HasSpecificClassOf(String* name);
681 706
682 Object* ToObject(); // ECMA-262 9.9. 707 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9.
683 Object* ToBoolean(); // ECMA-262 9.2. 708 Object* ToBoolean(); // ECMA-262 9.2.
684 709
685 // Convert to a JSObject if needed. 710 // Convert to a JSObject if needed.
686 // global_context is used when creating wrapper object. 711 // global_context is used when creating wrapper object.
687 Object* ToObject(Context* global_context); 712 MUST_USE_RESULT MaybeObject* ToObject(Context* global_context);
688 713
689 // Converts this to a Smi if possible. 714 // Converts this to a Smi if possible.
690 // Failure is returned otherwise. 715 // Failure is returned otherwise.
691 inline Object* ToSmi(); 716 MUST_USE_RESULT inline MaybeObject* ToSmi();
692 717
693 void Lookup(String* name, LookupResult* result); 718 void Lookup(String* name, LookupResult* result);
694 719
695 // Property access. 720 // Property access.
696 inline Object* GetProperty(String* key); 721 MUST_USE_RESULT inline MaybeObject* GetProperty(String* key);
697 inline Object* GetProperty(String* key, PropertyAttributes* attributes); 722 MUST_USE_RESULT inline MaybeObject* GetProperty(
698 Object* GetPropertyWithReceiver(Object* receiver, 723 String* key,
699 String* key, 724 PropertyAttributes* attributes);
700 PropertyAttributes* attributes); 725 MUST_USE_RESULT MaybeObject* GetPropertyWithReceiver(
701 Object* GetProperty(Object* receiver, 726 Object* receiver,
702 LookupResult* result, 727 String* key,
703 String* key, 728 PropertyAttributes* attributes);
704 PropertyAttributes* attributes); 729 MUST_USE_RESULT MaybeObject* GetProperty(Object* receiver,
705 Object* GetPropertyWithCallback(Object* receiver, 730 LookupResult* result,
706 Object* structure, 731 String* key,
707 String* name, 732 PropertyAttributes* attributes);
708 Object* holder); 733 MUST_USE_RESULT MaybeObject* GetPropertyWithCallback(Object* receiver,
709 Object* GetPropertyWithDefinedGetter(Object* receiver, 734 Object* structure,
710 JSFunction* getter); 735 String* name,
736 Object* holder);
737 MUST_USE_RESULT MaybeObject* GetPropertyWithDefinedGetter(Object* receiver,
738 JSFunction* getter);
711 739
712 inline Object* GetElement(uint32_t index); 740 inline MaybeObject* GetElement(uint32_t index);
713 Object* GetElementWithReceiver(Object* receiver, uint32_t index); 741 // For use when we know that no exception can be thrown.
742 inline Object* GetElementNoExceptionThrown(uint32_t index);
743 MaybeObject* GetElementWithReceiver(Object* receiver, uint32_t index);
714 744
715 // Return the object's prototype (might be Heap::null_value()). 745 // Return the object's prototype (might be Heap::null_value()).
716 Object* GetPrototype(); 746 Object* GetPrototype();
717 747
718 // Tries to convert an object to an array index. Returns true and sets 748 // Tries to convert an object to an array index. Returns true and sets
719 // the output parameter if it succeeds. 749 // the output parameter if it succeeds.
720 inline bool ToArrayIndex(uint32_t* index); 750 inline bool ToArrayIndex(uint32_t* index);
721 751
722 // Returns true if this is a JSValue containing a string and the index is 752 // Returns true if this is a JSValue containing a string and the index is
723 // < the length of the string. Used to implement [] on strings. 753 // < the length of the string. Used to implement [] on strings.
724 inline bool IsStringObjectWithCharacterAt(uint32_t index); 754 inline bool IsStringObjectWithCharacterAt(uint32_t index);
725 755
726 #ifdef DEBUG 756 #ifdef DEBUG
727 // Prints this object with details.
728 void Print();
729 void PrintLn();
730 // Verifies the object.
731 void Verify();
732
733 // Verify a pointer is a valid object pointer. 757 // Verify a pointer is a valid object pointer.
734 static void VerifyPointer(Object* p); 758 static void VerifyPointer(Object* p);
735 #endif 759 #endif
736 760
737 // Prints this object without details. 761 // Prints this object without details.
738 void ShortPrint(); 762 void ShortPrint();
739 763
740 // Prints this object without details to a message accumulator. 764 // Prints this object without details to a message accumulator.
741 void ShortPrint(StringStream* accumulator); 765 void ShortPrint(StringStream* accumulator);
742 766
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 // 832 //
809 // The next three bits, 4-6, are an allocation space tag 'sss'. The 833 // The next three bits, 4-6, are an allocation space tag 'sss'. The
810 // allocation space tag is 000 for all failure types except 834 // allocation space tag is 000 for all failure types except
811 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the 835 // RETRY_AFTER_GC. For RETRY_AFTER_GC, the possible values are the
812 // allocation spaces (the encoding is found in globals.h). 836 // allocation spaces (the encoding is found in globals.h).
813 837
814 // Failure type tag info. 838 // Failure type tag info.
815 const int kFailureTypeTagSize = 2; 839 const int kFailureTypeTagSize = 2;
816 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1; 840 const int kFailureTypeTagMask = (1 << kFailureTypeTagSize) - 1;
817 841
818 class Failure: public Object { 842 class Failure: public MaybeObject {
819 public: 843 public:
820 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code. 844 // RuntimeStubs assumes EXCEPTION = 1 in the compiler-generated code.
821 enum Type { 845 enum Type {
822 RETRY_AFTER_GC = 0, 846 RETRY_AFTER_GC = 0,
823 EXCEPTION = 1, // Returning this marker tells the real exception 847 EXCEPTION = 1, // Returning this marker tells the real exception
824 // is in Top::pending_exception. 848 // is in Top::pending_exception.
825 INTERNAL_ERROR = 2, 849 INTERNAL_ERROR = 2,
826 OUT_OF_MEMORY_EXCEPTION = 3 850 OUT_OF_MEMORY_EXCEPTION = 3
827 }; 851 };
828 852
829 inline Type type() const; 853 inline Type type() const;
830 854
831 // Returns the space that needs to be collected for RetryAfterGC failures. 855 // Returns the space that needs to be collected for RetryAfterGC failures.
832 inline AllocationSpace allocation_space() const; 856 inline AllocationSpace allocation_space() const;
833 857
834 inline bool IsInternalError() const; 858 inline bool IsInternalError() const;
835 inline bool IsOutOfMemoryException() const; 859 inline bool IsOutOfMemoryException() const;
836 860
837 static inline Failure* RetryAfterGC(AllocationSpace space); 861 static inline Failure* RetryAfterGC(AllocationSpace space);
838 static inline Failure* RetryAfterGC(); // NEW_SPACE 862 static inline Failure* RetryAfterGC(); // NEW_SPACE
839 static inline Failure* Exception(); 863 static inline Failure* Exception();
840 static inline Failure* InternalError(); 864 static inline Failure* InternalError();
841 static inline Failure* OutOfMemoryException(); 865 static inline Failure* OutOfMemoryException();
842 // Casting. 866 // Casting.
843 static inline Failure* cast(Object* object); 867 static inline Failure* cast(MaybeObject* object);
844 868
845 // Dispatched behavior. 869 // Dispatched behavior.
846 void FailurePrint(); 870 void FailurePrint();
847 void FailurePrint(StringStream* accumulator); 871 void FailurePrint(StringStream* accumulator);
848 #ifdef DEBUG 872 #ifdef DEBUG
849 void FailureVerify(); 873 void FailureVerify();
850 #endif 874 #endif
851 875
852 private: 876 private:
853 inline intptr_t value() const; 877 inline intptr_t value() const;
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 // elements array can have one of the two maps in this mode: 1266 // elements array can have one of the two maps in this mode:
1243 // fixed_array_map or fixed_cow_array_map (for copy-on-write 1267 // fixed_array_map or fixed_cow_array_map (for copy-on-write
1244 // arrays). In the latter case the elements array may be shared by a 1268 // arrays). In the latter case the elements array may be shared by a
1245 // few objects and so before writing to any element the array must 1269 // few objects and so before writing to any element the array must
1246 // be copied. Use EnsureWritableFastElements in this case. 1270 // be copied. Use EnsureWritableFastElements in this case.
1247 // 1271 //
1248 // In the slow mode elements is either a NumberDictionary or a 1272 // In the slow mode elements is either a NumberDictionary or a
1249 // PixelArray or an ExternalArray. 1273 // PixelArray or an ExternalArray.
1250 DECL_ACCESSORS(elements, HeapObject) 1274 DECL_ACCESSORS(elements, HeapObject)
1251 inline void initialize_elements(); 1275 inline void initialize_elements();
1252 inline Object* ResetElements(); 1276 MUST_USE_RESULT inline MaybeObject* ResetElements();
1253 inline ElementsKind GetElementsKind(); 1277 inline ElementsKind GetElementsKind();
1254 inline bool HasFastElements(); 1278 inline bool HasFastElements();
1255 inline bool HasDictionaryElements(); 1279 inline bool HasDictionaryElements();
1256 inline bool HasPixelElements(); 1280 inline bool HasPixelElements();
1257 inline bool HasExternalArrayElements(); 1281 inline bool HasExternalArrayElements();
1258 inline bool HasExternalByteElements(); 1282 inline bool HasExternalByteElements();
1259 inline bool HasExternalUnsignedByteElements(); 1283 inline bool HasExternalUnsignedByteElements();
1260 inline bool HasExternalShortElements(); 1284 inline bool HasExternalShortElements();
1261 inline bool HasExternalUnsignedShortElements(); 1285 inline bool HasExternalUnsignedShortElements();
1262 inline bool HasExternalIntElements(); 1286 inline bool HasExternalIntElements();
1263 inline bool HasExternalUnsignedIntElements(); 1287 inline bool HasExternalUnsignedIntElements();
1264 inline bool HasExternalFloatElements(); 1288 inline bool HasExternalFloatElements();
1265 inline bool AllowsSetElementsLength(); 1289 inline bool AllowsSetElementsLength();
1266 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1290 inline NumberDictionary* element_dictionary(); // Gets slow elements.
1267 // Requires: this->HasFastElements(). 1291 // Requires: this->HasFastElements().
1268 inline Object* EnsureWritableFastElements(); 1292 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1269 1293
1270 // Collects elements starting at index 0. 1294 // Collects elements starting at index 0.
1271 // Undefined values are placed after non-undefined values. 1295 // Undefined values are placed after non-undefined values.
1272 // Returns the number of non-undefined values. 1296 // Returns the number of non-undefined values.
1273 Object* PrepareElementsForSort(uint32_t limit); 1297 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit);
1274 // As PrepareElementsForSort, but only on objects where elements is 1298 // As PrepareElementsForSort, but only on objects where elements is
1275 // a dictionary, and it will stay a dictionary. 1299 // a dictionary, and it will stay a dictionary.
1276 MUST_USE_RESULT Object* PrepareSlowElementsForSort(uint32_t limit); 1300 MUST_USE_RESULT MaybeObject* PrepareSlowElementsForSort(uint32_t limit);
1277 1301
1278 Object* SetProperty(String* key, 1302 MUST_USE_RESULT MaybeObject* SetProperty(String* key,
1279 Object* value, 1303 Object* value,
1280 PropertyAttributes attributes); 1304 PropertyAttributes attributes);
1281 Object* SetProperty(LookupResult* result, 1305 MUST_USE_RESULT MaybeObject* SetProperty(LookupResult* result,
1282 String* key, 1306 String* key,
1283 Object* value, 1307 Object* value,
1284 PropertyAttributes attributes); 1308 PropertyAttributes attributes);
1285 Object* SetPropertyWithFailedAccessCheck(LookupResult* result, 1309 MUST_USE_RESULT MaybeObject* SetPropertyWithFailedAccessCheck(
1286 String* name, 1310 LookupResult* result,
1287 Object* value); 1311 String* name,
1288 Object* SetPropertyWithCallback(Object* structure, 1312 Object* value);
1289 String* name, 1313 MUST_USE_RESULT MaybeObject* SetPropertyWithCallback(Object* structure,
1290 Object* value, 1314 String* name,
1291 JSObject* holder); 1315 Object* value,
1292 Object* SetPropertyWithDefinedSetter(JSFunction* setter, 1316 JSObject* holder);
1293 Object* value); 1317 MUST_USE_RESULT MaybeObject* SetPropertyWithDefinedSetter(JSFunction* setter,
1294 Object* SetPropertyWithInterceptor(String* name, 1318 Object* value);
1295 Object* value, 1319 MUST_USE_RESULT MaybeObject* SetPropertyWithInterceptor(
1296 PropertyAttributes attributes); 1320 String* name,
1297 Object* SetPropertyPostInterceptor(String* name, 1321 Object* value,
1298 Object* value, 1322 PropertyAttributes attributes);
1299 PropertyAttributes attributes); 1323 MUST_USE_RESULT MaybeObject* SetPropertyPostInterceptor(
1300 Object* IgnoreAttributesAndSetLocalProperty(String* key, 1324 String* name,
1301 Object* value, 1325 Object* value,
1302 PropertyAttributes attributes); 1326 PropertyAttributes attributes);
1327 MUST_USE_RESULT MaybeObject* IgnoreAttributesAndSetLocalProperty(
1328 String* key,
1329 Object* value,
1330 PropertyAttributes attributes);
1303 1331
1304 // Retrieve a value in a normalized object given a lookup result. 1332 // Retrieve a value in a normalized object given a lookup result.
1305 // Handles the special representation of JS global objects. 1333 // Handles the special representation of JS global objects.
1306 Object* GetNormalizedProperty(LookupResult* result); 1334 Object* GetNormalizedProperty(LookupResult* result);
1307 1335
1308 // Sets the property value in a normalized object given a lookup result. 1336 // Sets the property value in a normalized object given a lookup result.
1309 // Handles the special representation of JS global objects. 1337 // Handles the special representation of JS global objects.
1310 Object* SetNormalizedProperty(LookupResult* result, Object* value); 1338 Object* SetNormalizedProperty(LookupResult* result, Object* value);
1311 1339
1312 // Sets the property value in a normalized object given (key, value, details). 1340 // Sets the property value in a normalized object given (key, value, details).
1313 // Handles the special representation of JS global objects. 1341 // Handles the special representation of JS global objects.
1314 MUST_USE_RESULT Object* SetNormalizedProperty(String* name, 1342 MUST_USE_RESULT MaybeObject* SetNormalizedProperty(String* name,
1315 Object* value, 1343 Object* value,
1316 PropertyDetails details); 1344 PropertyDetails details);
1317 1345
1318 // Deletes the named property in a normalized object. 1346 // Deletes the named property in a normalized object.
1319 MUST_USE_RESULT Object* DeleteNormalizedProperty(String* name, 1347 MUST_USE_RESULT MaybeObject* DeleteNormalizedProperty(String* name,
1320 DeleteMode mode); 1348 DeleteMode mode);
1321 1349
1322 // Returns the class name ([[Class]] property in the specification). 1350 // Returns the class name ([[Class]] property in the specification).
1323 String* class_name(); 1351 String* class_name();
1324 1352
1325 // Returns the constructor name (the name (possibly, inferred name) of the 1353 // Returns the constructor name (the name (possibly, inferred name) of the
1326 // function that was used to instantiate the object). 1354 // function that was used to instantiate the object).
1327 String* constructor_name(); 1355 String* constructor_name();
1328 1356
1329 // Retrieve interceptors. 1357 // Retrieve interceptors.
1330 InterceptorInfo* GetNamedInterceptor(); 1358 InterceptorInfo* GetNamedInterceptor();
1331 InterceptorInfo* GetIndexedInterceptor(); 1359 InterceptorInfo* GetIndexedInterceptor();
1332 1360
1333 inline PropertyAttributes GetPropertyAttribute(String* name); 1361 inline PropertyAttributes GetPropertyAttribute(String* name);
1334 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver, 1362 PropertyAttributes GetPropertyAttributeWithReceiver(JSObject* receiver,
1335 String* name); 1363 String* name);
1336 PropertyAttributes GetLocalPropertyAttribute(String* name); 1364 PropertyAttributes GetLocalPropertyAttribute(String* name);
1337 1365
1338 MUST_USE_RESULT Object* DefineAccessor(String* name, 1366 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name,
1339 bool is_getter, 1367 bool is_getter,
1340 JSFunction* fun, 1368 JSFunction* fun,
1341 PropertyAttributes attributes); 1369 PropertyAttributes attributes);
1342 Object* LookupAccessor(String* name, bool is_getter); 1370 Object* LookupAccessor(String* name, bool is_getter);
1343 1371
1344 MUST_USE_RESULT Object* DefineAccessor(AccessorInfo* info); 1372 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info);
1345 1373
1346 // Used from Object::GetProperty(). 1374 // Used from Object::GetProperty().
1347 Object* GetPropertyWithFailedAccessCheck(Object* receiver, 1375 MaybeObject* GetPropertyWithFailedAccessCheck(
1348 LookupResult* result, 1376 Object* receiver,
1349 String* name, 1377 LookupResult* result,
1350 PropertyAttributes* attributes); 1378 String* name,
1351 Object* GetPropertyWithInterceptor(JSObject* receiver, 1379 PropertyAttributes* attributes);
1352 String* name, 1380 MaybeObject* GetPropertyWithInterceptor(
1353 PropertyAttributes* attributes); 1381 JSObject* receiver,
1354 Object* GetPropertyPostInterceptor(JSObject* receiver, 1382 String* name,
1355 String* name, 1383 PropertyAttributes* attributes);
1356 PropertyAttributes* attributes); 1384 MaybeObject* GetPropertyPostInterceptor(
1357 Object* GetLocalPropertyPostInterceptor(JSObject* receiver, 1385 JSObject* receiver,
1358 String* name, 1386 String* name,
1359 PropertyAttributes* attributes); 1387 PropertyAttributes* attributes);
1388 MaybeObject* GetLocalPropertyPostInterceptor(JSObject* receiver,
1389 String* name,
1390 PropertyAttributes* attributes);
1360 1391
1361 // Returns true if this is an instance of an api function and has 1392 // Returns true if this is an instance of an api function and has
1362 // been modified since it was created. May give false positives. 1393 // been modified since it was created. May give false positives.
1363 bool IsDirty(); 1394 bool IsDirty();
1364 1395
1365 bool HasProperty(String* name) { 1396 bool HasProperty(String* name) {
1366 return GetPropertyAttribute(name) != ABSENT; 1397 return GetPropertyAttribute(name) != ABSENT;
1367 } 1398 }
1368 1399
1369 // Can cause a GC if it hits an interceptor. 1400 // Can cause a GC if it hits an interceptor.
(...skipping 13 matching lines...) Expand all
1383 // receiver is a JSGlobalProxy then the auxiliary object is a property 1414 // receiver is a JSGlobalProxy then the auxiliary object is a property
1384 // of its prototype. 1415 // of its prototype.
1385 // 1416 //
1386 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be 1417 // Has/Get/SetHiddenPropertiesObject methods don't allow the holder to be
1387 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real 1418 // a JSGlobalProxy. Use BypassGlobalProxy method above to get to the real
1388 // holder. 1419 // holder.
1389 // 1420 //
1390 // These accessors do not touch interceptors or accessors. 1421 // These accessors do not touch interceptors or accessors.
1391 inline bool HasHiddenPropertiesObject(); 1422 inline bool HasHiddenPropertiesObject();
1392 inline Object* GetHiddenPropertiesObject(); 1423 inline Object* GetHiddenPropertiesObject();
1393 inline Object* SetHiddenPropertiesObject(Object* hidden_obj); 1424 MUST_USE_RESULT inline MaybeObject* SetHiddenPropertiesObject(
1425 Object* hidden_obj);
1394 1426
1395 MUST_USE_RESULT Object* DeleteProperty(String* name, DeleteMode mode); 1427 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1396 MUST_USE_RESULT Object* DeleteElement(uint32_t index, DeleteMode mode); 1428 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1397 1429
1398 // Tests for the fast common case for property enumeration. 1430 // Tests for the fast common case for property enumeration.
1399 bool IsSimpleEnum(); 1431 bool IsSimpleEnum();
1400 1432
1401 // Do we want to keep the elements in fast case when increasing the 1433 // Do we want to keep the elements in fast case when increasing the
1402 // capacity? 1434 // capacity?
1403 bool ShouldConvertToSlowElements(int new_capacity); 1435 bool ShouldConvertToSlowElements(int new_capacity);
1404 // Returns true if the backing storage for the slow-case elements of 1436 // Returns true if the backing storage for the slow-case elements of
1405 // this object takes up nearly as much space as a fast-case backing 1437 // this object takes up nearly as much space as a fast-case backing
1406 // storage would. In that case the JSObject should have fast 1438 // storage would. In that case the JSObject should have fast
1407 // elements. 1439 // elements.
1408 bool ShouldConvertToFastElements(); 1440 bool ShouldConvertToFastElements();
1409 1441
1410 // Return the object's prototype (might be Heap::null_value()). 1442 // Return the object's prototype (might be Heap::null_value()).
1411 inline Object* GetPrototype(); 1443 inline Object* GetPrototype();
1412 1444
1413 // Set the object's prototype (only JSObject and null are allowed). 1445 // Set the object's prototype (only JSObject and null are allowed).
1414 Object* SetPrototype(Object* value, bool skip_hidden_prototypes); 1446 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value,
1447 bool skip_hidden_prototypes);
1415 1448
1416 // Tells whether the index'th element is present. 1449 // Tells whether the index'th element is present.
1417 inline bool HasElement(uint32_t index); 1450 inline bool HasElement(uint32_t index);
1418 bool HasElementWithReceiver(JSObject* receiver, uint32_t index); 1451 bool HasElementWithReceiver(JSObject* receiver, uint32_t index);
1419 1452
1420 // Tells whether the index'th element is present and how it is stored. 1453 // Tells whether the index'th element is present and how it is stored.
1421 enum LocalElementType { 1454 enum LocalElementType {
1422 // There is no element with given index. 1455 // There is no element with given index.
1423 UNDEFINED_ELEMENT, 1456 UNDEFINED_ELEMENT,
1424 1457
1425 // Element with given index is handled by interceptor. 1458 // Element with given index is handled by interceptor.
1426 INTERCEPTED_ELEMENT, 1459 INTERCEPTED_ELEMENT,
1427 1460
1428 // Element with given index is character in string. 1461 // Element with given index is character in string.
1429 STRING_CHARACTER_ELEMENT, 1462 STRING_CHARACTER_ELEMENT,
1430 1463
1431 // Element with given index is stored in fast backing store. 1464 // Element with given index is stored in fast backing store.
1432 FAST_ELEMENT, 1465 FAST_ELEMENT,
1433 1466
1434 // Element with given index is stored in slow backing store. 1467 // Element with given index is stored in slow backing store.
1435 DICTIONARY_ELEMENT 1468 DICTIONARY_ELEMENT
1436 }; 1469 };
1437 1470
1438 LocalElementType HasLocalElement(uint32_t index); 1471 LocalElementType HasLocalElement(uint32_t index);
1439 1472
1440 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index); 1473 bool HasElementWithInterceptor(JSObject* receiver, uint32_t index);
1441 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index); 1474 bool HasElementPostInterceptor(JSObject* receiver, uint32_t index);
1442 1475
1443 MUST_USE_RESULT Object* SetFastElement(uint32_t index, Object* value); 1476 MUST_USE_RESULT MaybeObject* SetFastElement(uint32_t index, Object* value);
1444 1477
1445 // Set the index'th array element. 1478 // Set the index'th array element.
1446 // A Failure object is returned if GC is needed. 1479 // A Failure object is returned if GC is needed.
1447 MUST_USE_RESULT Object* SetElement(uint32_t index, Object* value); 1480 MUST_USE_RESULT MaybeObject* SetElement(uint32_t index, Object* value);
1448 1481
1449 // Returns the index'th element. 1482 // Returns the index'th element.
1450 // The undefined object if index is out of bounds. 1483 // The undefined object if index is out of bounds.
1451 Object* GetElementWithReceiver(JSObject* receiver, uint32_t index); 1484 MaybeObject* GetElementWithReceiver(JSObject* receiver, uint32_t index);
1452 Object* GetElementWithInterceptor(JSObject* receiver, uint32_t index); 1485 MaybeObject* GetElementWithInterceptor(JSObject* receiver, uint32_t index);
1453 1486
1454 MUST_USE_RESULT Object* SetFastElementsCapacityAndLength(int capacity, 1487 MUST_USE_RESULT MaybeObject* SetFastElementsCapacityAndLength(int capacity,
1455 int length); 1488 int length);
1456 MUST_USE_RESULT Object* SetSlowElements(Object* length); 1489 MUST_USE_RESULT MaybeObject* SetSlowElements(Object* length);
1457 1490
1458 // Lookup interceptors are used for handling properties controlled by host 1491 // Lookup interceptors are used for handling properties controlled by host
1459 // objects. 1492 // objects.
1460 inline bool HasNamedInterceptor(); 1493 inline bool HasNamedInterceptor();
1461 inline bool HasIndexedInterceptor(); 1494 inline bool HasIndexedInterceptor();
1462 1495
1463 // Support functions for v8 api (needed for correct interceptor behavior). 1496 // Support functions for v8 api (needed for correct interceptor behavior).
1464 bool HasRealNamedProperty(String* key); 1497 bool HasRealNamedProperty(String* key);
1465 bool HasRealElementProperty(uint32_t index); 1498 bool HasRealElementProperty(uint32_t index);
1466 bool HasRealNamedCallbackProperty(String* key); 1499 bool HasRealNamedCallbackProperty(String* key);
1467 1500
1468 // Initializes the array to a certain length 1501 // Initializes the array to a certain length
1469 MUST_USE_RESULT Object* SetElementsLength(Object* length); 1502 MUST_USE_RESULT MaybeObject* SetElementsLength(Object* length);
1470 1503
1471 // Get the header size for a JSObject. Used to compute the index of 1504 // Get the header size for a JSObject. Used to compute the index of
1472 // internal fields as well as the number of internal fields. 1505 // internal fields as well as the number of internal fields.
1473 inline int GetHeaderSize(); 1506 inline int GetHeaderSize();
1474 1507
1475 inline int GetInternalFieldCount(); 1508 inline int GetInternalFieldCount();
1476 inline Object* GetInternalField(int index); 1509 inline Object* GetInternalField(int index);
1477 inline void SetInternalField(int index, Object* value); 1510 inline void SetInternalField(int index, Object* value);
1478 1511
1479 // Lookup a property. If found, the result is valid and has 1512 // Lookup a property. If found, the result is valid and has
(...skipping 28 matching lines...) Expand all
1508 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter); 1541 int GetLocalElementKeys(FixedArray* storage, PropertyAttributes filter);
1509 // Count and fill in the enumerable elements into storage. 1542 // Count and fill in the enumerable elements into storage.
1510 // (storage->length() == NumberOfEnumElements()). 1543 // (storage->length() == NumberOfEnumElements()).
1511 // If storage is NULL, will count the elements without adding 1544 // If storage is NULL, will count the elements without adding
1512 // them to any storage. 1545 // them to any storage.
1513 // Returns the number of enumerable elements. 1546 // Returns the number of enumerable elements.
1514 int GetEnumElementKeys(FixedArray* storage); 1547 int GetEnumElementKeys(FixedArray* storage);
1515 1548
1516 // Add a property to a fast-case object using a map transition to 1549 // Add a property to a fast-case object using a map transition to
1517 // new_map. 1550 // new_map.
1518 Object* AddFastPropertyUsingMap(Map* new_map, 1551 MUST_USE_RESULT MaybeObject* AddFastPropertyUsingMap(Map* new_map,
1519 String* name, 1552 String* name,
1520 Object* value); 1553 Object* value);
1521 1554
1522 // Add a constant function property to a fast-case object. 1555 // Add a constant function property to a fast-case object.
1523 // This leaves a CONSTANT_TRANSITION in the old map, and 1556 // This leaves a CONSTANT_TRANSITION in the old map, and
1524 // if it is called on a second object with this map, a 1557 // if it is called on a second object with this map, a
1525 // normal property is added instead, with a map transition. 1558 // normal property is added instead, with a map transition.
1526 // This avoids the creation of many maps with the same constant 1559 // This avoids the creation of many maps with the same constant
1527 // function, all orphaned. 1560 // function, all orphaned.
1528 Object* AddConstantFunctionProperty(String* name, 1561 MUST_USE_RESULT MaybeObject* AddConstantFunctionProperty(
1529 JSFunction* function, 1562 String* name,
1530 PropertyAttributes attributes); 1563 JSFunction* function,
1564 PropertyAttributes attributes);
1531 1565
1532 Object* ReplaceSlowProperty(String* name, 1566 MUST_USE_RESULT MaybeObject* ReplaceSlowProperty(
1533 Object* value, 1567 String* name,
1534 PropertyAttributes attributes); 1568 Object* value,
1569 PropertyAttributes attributes);
1535 1570
1536 // Converts a descriptor of any other type to a real field, 1571 // Converts a descriptor of any other type to a real field,
1537 // backed by the properties array. Descriptors of visible 1572 // backed by the properties array. Descriptors of visible
1538 // types, such as CONSTANT_FUNCTION, keep their enumeration order. 1573 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1539 // Converts the descriptor on the original object's map to a 1574 // Converts the descriptor on the original object's map to a
1540 // map transition, and the the new field is on the object's new map. 1575 // map transition, and the the new field is on the object's new map.
1541 Object* ConvertDescriptorToFieldAndMapTransition( 1576 MUST_USE_RESULT MaybeObject* ConvertDescriptorToFieldAndMapTransition(
1542 String* name, 1577 String* name,
1543 Object* new_value, 1578 Object* new_value,
1544 PropertyAttributes attributes); 1579 PropertyAttributes attributes);
1545 1580
1546 // Converts a descriptor of any other type to a real field, 1581 // Converts a descriptor of any other type to a real field,
1547 // backed by the properties array. Descriptors of visible 1582 // backed by the properties array. Descriptors of visible
1548 // types, such as CONSTANT_FUNCTION, keep their enumeration order. 1583 // types, such as CONSTANT_FUNCTION, keep their enumeration order.
1549 Object* ConvertDescriptorToField(String* name, 1584 MUST_USE_RESULT MaybeObject* ConvertDescriptorToField(
1550 Object* new_value, 1585 String* name,
1551 PropertyAttributes attributes); 1586 Object* new_value,
1587 PropertyAttributes attributes);
1552 1588
1553 // Add a property to a fast-case object. 1589 // Add a property to a fast-case object.
1554 Object* AddFastProperty(String* name, 1590 MUST_USE_RESULT MaybeObject* AddFastProperty(String* name,
1555 Object* value, 1591 Object* value,
1556 PropertyAttributes attributes); 1592 PropertyAttributes attributes);
1557 1593
1558 // Add a property to a slow-case object. 1594 // Add a property to a slow-case object.
1559 Object* AddSlowProperty(String* name, 1595 MUST_USE_RESULT MaybeObject* AddSlowProperty(String* name,
1560 Object* value, 1596 Object* value,
1561 PropertyAttributes attributes); 1597 PropertyAttributes attributes);
1562 1598
1563 // Add a property to an object. 1599 // Add a property to an object.
1564 Object* AddProperty(String* name, 1600 MUST_USE_RESULT MaybeObject* AddProperty(String* name,
1565 Object* value, 1601 Object* value,
1566 PropertyAttributes attributes); 1602 PropertyAttributes attributes);
1567 1603
1568 // Convert the object to use the canonical dictionary 1604 // Convert the object to use the canonical dictionary
1569 // representation. If the object is expected to have additional properties 1605 // representation. If the object is expected to have additional properties
1570 // added this number can be indicated to have the backing store allocated to 1606 // added this number can be indicated to have the backing store allocated to
1571 // an initial capacity for holding these properties. 1607 // an initial capacity for holding these properties.
1572 Object* NormalizeProperties(PropertyNormalizationMode mode, 1608 MUST_USE_RESULT MaybeObject* NormalizeProperties(
1573 int expected_additional_properties); 1609 PropertyNormalizationMode mode,
1574 Object* NormalizeElements(); 1610 int expected_additional_properties);
1611 MUST_USE_RESULT MaybeObject* NormalizeElements();
1575 1612
1576 Object* UpdateMapCodeCache(String* name, Code* code); 1613 MUST_USE_RESULT MaybeObject* UpdateMapCodeCache(String* name, Code* code);
1577 1614
1578 // Transform slow named properties to fast variants. 1615 // Transform slow named properties to fast variants.
1579 // Returns failure if allocation failed. 1616 // Returns failure if allocation failed.
1580 Object* TransformToFastProperties(int unused_property_fields); 1617 MUST_USE_RESULT MaybeObject* TransformToFastProperties(
1618 int unused_property_fields);
1581 1619
1582 // Access fast-case object properties at index. 1620 // Access fast-case object properties at index.
1583 inline Object* FastPropertyAt(int index); 1621 inline Object* FastPropertyAt(int index);
1584 inline Object* FastPropertyAtPut(int index, Object* value); 1622 inline Object* FastPropertyAtPut(int index, Object* value);
1585 1623
1586 // Access to in object properties. 1624 // Access to in object properties.
1587 inline Object* InObjectPropertyAt(int index); 1625 inline Object* InObjectPropertyAt(int index);
1588 inline Object* InObjectPropertyAtPut(int index, 1626 inline Object* InObjectPropertyAtPut(int index,
1589 Object* value, 1627 Object* value,
1590 WriteBarrierMode mode 1628 WriteBarrierMode mode
1591 = UPDATE_WRITE_BARRIER); 1629 = UPDATE_WRITE_BARRIER);
1592 1630
1593 // initializes the body after properties slot, properties slot is 1631 // initializes the body after properties slot, properties slot is
1594 // initialized by set_properties 1632 // initialized by set_properties
1595 // Note: this call does not update write barrier, it is caller's 1633 // Note: this call does not update write barrier, it is caller's
1596 // reponsibility to ensure that *v* can be collected without WB here. 1634 // reponsibility to ensure that *v* can be collected without WB here.
1597 inline void InitializeBody(int object_size, Object* value); 1635 inline void InitializeBody(int object_size, Object* value);
1598 1636
1599 // Check whether this object references another object 1637 // Check whether this object references another object
1600 bool ReferencesObject(Object* obj); 1638 bool ReferencesObject(Object* obj);
1601 1639
1602 // Casting. 1640 // Casting.
1603 static inline JSObject* cast(Object* obj); 1641 static inline JSObject* cast(Object* obj);
1604 1642
1605 // Disalow further properties to be added to the object. 1643 // Disalow further properties to be added to the object.
1606 MUST_USE_RESULT Object* PreventExtensions(); 1644 MUST_USE_RESULT MaybeObject* PreventExtensions();
1607 1645
1608 1646
1609 // Dispatched behavior. 1647 // Dispatched behavior.
1610 void JSObjectShortPrint(StringStream* accumulator); 1648 void JSObjectShortPrint(StringStream* accumulator);
1611 #ifdef DEBUG 1649 #ifdef DEBUG
1612 void JSObjectPrint(); 1650 void JSObjectPrint();
1613 void JSObjectVerify(); 1651 void JSObjectVerify();
1614 void PrintProperties(); 1652 void PrintProperties();
1615 void PrintElements(); 1653 void PrintElements();
1616 1654
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1661 static const int kHeaderSize = kElementsOffset + kPointerSize; 1699 static const int kHeaderSize = kElementsOffset + kPointerSize;
1662 1700
1663 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize); 1701 STATIC_CHECK(kHeaderSize == Internals::kJSObjectHeaderSize);
1664 1702
1665 class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> { 1703 class BodyDescriptor : public FlexibleBodyDescriptor<kPropertiesOffset> {
1666 public: 1704 public:
1667 static inline int SizeOf(Map* map, HeapObject* object); 1705 static inline int SizeOf(Map* map, HeapObject* object);
1668 }; 1706 };
1669 1707
1670 private: 1708 private:
1671 Object* GetElementWithCallback(Object* receiver, 1709 MUST_USE_RESULT MaybeObject* GetElementWithCallback(Object* receiver,
1672 Object* structure, 1710 Object* structure,
1673 uint32_t index, 1711 uint32_t index,
1674 Object* holder); 1712 Object* holder);
1675 Object* SetElementWithCallback(Object* structure, 1713 MaybeObject* SetElementWithCallback(Object* structure,
1676 uint32_t index, 1714 uint32_t index,
1677 Object* value, 1715 Object* value,
1678 JSObject* holder); 1716 JSObject* holder);
1679 MUST_USE_RESULT Object* SetElementWithInterceptor(uint32_t index, 1717 MUST_USE_RESULT MaybeObject* SetElementWithInterceptor(uint32_t index,
1680 Object* value); 1718 Object* value);
1681 MUST_USE_RESULT Object* SetElementWithoutInterceptor(uint32_t index, 1719 MUST_USE_RESULT MaybeObject* SetElementWithoutInterceptor(uint32_t index,
1682 Object* value); 1720 Object* value);
1683 1721
1684 Object* GetElementPostInterceptor(JSObject* receiver, uint32_t index); 1722 MaybeObject* GetElementPostInterceptor(JSObject* receiver, uint32_t index);
1685 1723
1686 MUST_USE_RESULT Object* DeletePropertyPostInterceptor(String* name, 1724 MUST_USE_RESULT MaybeObject* DeletePropertyPostInterceptor(String* name,
1687 DeleteMode mode); 1725 DeleteMode mode);
1688 MUST_USE_RESULT Object* DeletePropertyWithInterceptor(String* name); 1726 MUST_USE_RESULT MaybeObject* DeletePropertyWithInterceptor(String* name);
1689 1727
1690 MUST_USE_RESULT Object* DeleteElementPostInterceptor(uint32_t index, 1728 MUST_USE_RESULT MaybeObject* DeleteElementPostInterceptor(uint32_t index,
1691 DeleteMode mode); 1729 DeleteMode mode);
1692 MUST_USE_RESULT Object* DeleteElementWithInterceptor(uint32_t index); 1730 MUST_USE_RESULT MaybeObject* DeleteElementWithInterceptor(uint32_t index);
1693 1731
1694 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver, 1732 PropertyAttributes GetPropertyAttributePostInterceptor(JSObject* receiver,
1695 String* name, 1733 String* name,
1696 bool continue_search); 1734 bool continue_search);
1697 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver, 1735 PropertyAttributes GetPropertyAttributeWithInterceptor(JSObject* receiver,
1698 String* name, 1736 String* name,
1699 bool continue_search); 1737 bool continue_search);
1700 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck( 1738 PropertyAttributes GetPropertyAttributeWithFailedAccessCheck(
1701 Object* receiver, 1739 Object* receiver,
1702 LookupResult* result, 1740 LookupResult* result,
1703 String* name, 1741 String* name,
1704 bool continue_search); 1742 bool continue_search);
1705 PropertyAttributes GetPropertyAttribute(JSObject* receiver, 1743 PropertyAttributes GetPropertyAttribute(JSObject* receiver,
1706 LookupResult* result, 1744 LookupResult* result,
1707 String* name, 1745 String* name,
1708 bool continue_search); 1746 bool continue_search);
1709 1747
1710 // Returns true if most of the elements backing storage is used. 1748 // Returns true if most of the elements backing storage is used.
1711 bool HasDenseElements(); 1749 bool HasDenseElements();
1712 1750
1713 bool CanSetCallback(String* name); 1751 bool CanSetCallback(String* name);
1714 MUST_USE_RESULT Object* SetElementCallback(uint32_t index, 1752 MUST_USE_RESULT MaybeObject* SetElementCallback(
1715 Object* structure, 1753 uint32_t index,
1716 PropertyAttributes attributes); 1754 Object* structure,
1717 MUST_USE_RESULT Object* SetPropertyCallback(String* name, 1755 PropertyAttributes attributes);
1718 Object* structure, 1756 MUST_USE_RESULT MaybeObject* SetPropertyCallback(
1719 PropertyAttributes attributes); 1757 String* name,
1720 MUST_USE_RESULT Object* DefineGetterSetter(String* name, 1758 Object* structure,
1721 PropertyAttributes attributes); 1759 PropertyAttributes attributes);
1760 MUST_USE_RESULT MaybeObject* DefineGetterSetter(
1761 String* name,
1762 PropertyAttributes attributes);
1722 1763
1723 void LookupInDescriptor(String* name, LookupResult* result); 1764 void LookupInDescriptor(String* name, LookupResult* result);
1724 1765
1725 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); 1766 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
1726 }; 1767 };
1727 1768
1728 1769
1729 // FixedArray describes fixed-sized arrays with element type Object*. 1770 // FixedArray describes fixed-sized arrays with element type Object*.
1730 class FixedArray: public HeapObject { 1771 class FixedArray: public HeapObject {
1731 public: 1772 public:
(...skipping 18 matching lines...) Expand all
1750 1791
1751 // Setters with less debug checks for the GC to use. 1792 // Setters with less debug checks for the GC to use.
1752 inline void set_unchecked(int index, Smi* value); 1793 inline void set_unchecked(int index, Smi* value);
1753 inline void set_null_unchecked(int index); 1794 inline void set_null_unchecked(int index);
1754 inline void set_unchecked(int index, Object* value, WriteBarrierMode mode); 1795 inline void set_unchecked(int index, Object* value, WriteBarrierMode mode);
1755 1796
1756 // Gives access to raw memory which stores the array's data. 1797 // Gives access to raw memory which stores the array's data.
1757 inline Object** data_start(); 1798 inline Object** data_start();
1758 1799
1759 // Copy operations. 1800 // Copy operations.
1760 inline Object* Copy(); 1801 MUST_USE_RESULT inline MaybeObject* Copy();
1761 MUST_USE_RESULT Object* CopySize(int new_length); 1802 MUST_USE_RESULT MaybeObject* CopySize(int new_length);
1762 1803
1763 // Add the elements of a JSArray to this FixedArray. 1804 // Add the elements of a JSArray to this FixedArray.
1764 MUST_USE_RESULT Object* AddKeysFromJSArray(JSArray* array); 1805 MUST_USE_RESULT MaybeObject* AddKeysFromJSArray(JSArray* array);
1765 1806
1766 // Compute the union of this and other. 1807 // Compute the union of this and other.
1767 MUST_USE_RESULT Object* UnionOfKeys(FixedArray* other); 1808 MUST_USE_RESULT MaybeObject* UnionOfKeys(FixedArray* other);
1768 1809
1769 // Copy a sub array from the receiver to dest. 1810 // Copy a sub array from the receiver to dest.
1770 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len); 1811 void CopyTo(int pos, FixedArray* dest, int dest_pos, int len);
1771 1812
1772 // Garbage collection support. 1813 // Garbage collection support.
1773 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; } 1814 static int SizeFor(int length) { return kHeaderSize + length * kPointerSize; }
1774 1815
1775 // Code Generation support. 1816 // Code Generation support.
1776 static int OffsetOfElementAt(int index) { return SizeFor(index); } 1817 static int OffsetOfElementAt(int index) { return SizeFor(index); }
1777 1818
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1896 // Transfer complete descriptor from another descriptor array to 1937 // Transfer complete descriptor from another descriptor array to
1897 // this one. 1938 // this one.
1898 inline void CopyFrom(int index, DescriptorArray* src, int src_index); 1939 inline void CopyFrom(int index, DescriptorArray* src, int src_index);
1899 1940
1900 // Copy the descriptor array, insert a new descriptor and optionally 1941 // Copy the descriptor array, insert a new descriptor and optionally
1901 // remove map transitions. If the descriptor is already present, it is 1942 // remove map transitions. If the descriptor is already present, it is
1902 // replaced. If a replaced descriptor is a real property (not a transition 1943 // replaced. If a replaced descriptor is a real property (not a transition
1903 // or null), its enumeration index is kept as is. 1944 // or null), its enumeration index is kept as is.
1904 // If adding a real property, map transitions must be removed. If adding 1945 // If adding a real property, map transitions must be removed. If adding
1905 // a transition, they must not be removed. All null descriptors are removed. 1946 // a transition, they must not be removed. All null descriptors are removed.
1906 MUST_USE_RESULT Object* CopyInsert(Descriptor* descriptor, 1947 MUST_USE_RESULT MaybeObject* CopyInsert(Descriptor* descriptor,
1907 TransitionFlag transition_flag); 1948 TransitionFlag transition_flag);
1908 1949
1909 // Remove all transitions. Return a copy of the array with all transitions 1950 // Remove all transitions. Return a copy of the array with all transitions
1910 // removed, or a Failure object if the new array could not be allocated. 1951 // removed, or a Failure object if the new array could not be allocated.
1911 MUST_USE_RESULT Object* RemoveTransitions(); 1952 MUST_USE_RESULT MaybeObject* RemoveTransitions();
1912 1953
1913 // Sort the instance descriptors by the hash codes of their keys. 1954 // Sort the instance descriptors by the hash codes of their keys.
1914 // Does not check for duplicates. 1955 // Does not check for duplicates.
1915 void SortUnchecked(); 1956 void SortUnchecked();
1916 1957
1917 // Sort the instance descriptors by the hash codes of their keys. 1958 // Sort the instance descriptors by the hash codes of their keys.
1918 // Checks the result for duplicates. 1959 // Checks the result for duplicates.
1919 void Sort(); 1960 void Sort();
1920 1961
1921 // Search the instance descriptors for given name. 1962 // Search the instance descriptors for given name.
(...skipping 12 matching lines...) Expand all
1934 // with low=0 and high=2. 1975 // with low=0 and high=2.
1935 int BinarySearch(String* name, int low, int high); 1976 int BinarySearch(String* name, int low, int high);
1936 1977
1937 // Perform a linear search in the instance descriptors represented 1978 // Perform a linear search in the instance descriptors represented
1938 // by this fixed array. len is the number of descriptor indices that are 1979 // by this fixed array. len is the number of descriptor indices that are
1939 // valid. Does not require the descriptors to be sorted. 1980 // valid. Does not require the descriptors to be sorted.
1940 int LinearSearch(String* name, int len); 1981 int LinearSearch(String* name, int len);
1941 1982
1942 // Allocates a DescriptorArray, but returns the singleton 1983 // Allocates a DescriptorArray, but returns the singleton
1943 // empty descriptor array object if number_of_descriptors is 0. 1984 // empty descriptor array object if number_of_descriptors is 0.
1944 MUST_USE_RESULT static Object* Allocate(int number_of_descriptors); 1985 MUST_USE_RESULT static MaybeObject* Allocate(int number_of_descriptors);
1945 1986
1946 // Casting. 1987 // Casting.
1947 static inline DescriptorArray* cast(Object* obj); 1988 static inline DescriptorArray* cast(Object* obj);
1948 1989
1949 // Constant for denoting key was not found. 1990 // Constant for denoting key was not found.
1950 static const int kNotFound = -1; 1991 static const int kNotFound = -1;
1951 1992
1952 static const int kContentArrayIndex = 0; 1993 static const int kContentArrayIndex = 0;
1953 static const int kEnumerationIndexIndex = 1; 1994 static const int kEnumerationIndexIndex = 1;
1954 static const int kFirstIndex = 2; 1995 static const int kFirstIndex = 2;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
2074 void ElementRemoved() { 2115 void ElementRemoved() {
2075 SetNumberOfElements(NumberOfElements() - 1); 2116 SetNumberOfElements(NumberOfElements() - 1);
2076 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1); 2117 SetNumberOfDeletedElements(NumberOfDeletedElements() + 1);
2077 } 2118 }
2078 void ElementsRemoved(int n) { 2119 void ElementsRemoved(int n) {
2079 SetNumberOfElements(NumberOfElements() - n); 2120 SetNumberOfElements(NumberOfElements() - n);
2080 SetNumberOfDeletedElements(NumberOfDeletedElements() + n); 2121 SetNumberOfDeletedElements(NumberOfDeletedElements() + n);
2081 } 2122 }
2082 2123
2083 // Returns a new HashTable object. Might return Failure. 2124 // Returns a new HashTable object. Might return Failure.
2084 MUST_USE_RESULT static Object* Allocate( 2125 MUST_USE_RESULT static MaybeObject* Allocate(
2085 int at_least_space_for, 2126 int at_least_space_for,
2086 PretenureFlag pretenure = NOT_TENURED); 2127 PretenureFlag pretenure = NOT_TENURED);
2087 2128
2088 // Returns the key at entry. 2129 // Returns the key at entry.
2089 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); } 2130 Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
2090 2131
2091 // Tells whether k is a real key. Null and undefined are not allowed 2132 // Tells whether k is a real key. Null and undefined are not allowed
2092 // as keys and can be used to indicate missing or deleted elements. 2133 // as keys and can be used to indicate missing or deleted elements.
2093 bool IsKey(Object* k) { 2134 bool IsKey(Object* k) {
2094 return !k->IsNull() && !k->IsUndefined(); 2135 return !k->IsNull() && !k->IsUndefined();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
2170 2211
2171 static uint32_t FirstProbe(uint32_t hash, uint32_t size) { 2212 static uint32_t FirstProbe(uint32_t hash, uint32_t size) {
2172 return hash & (size - 1); 2213 return hash & (size - 1);
2173 } 2214 }
2174 2215
2175 static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size) { 2216 static uint32_t NextProbe(uint32_t last, uint32_t number, uint32_t size) {
2176 return (last + number) & (size - 1); 2217 return (last + number) & (size - 1);
2177 } 2218 }
2178 2219
2179 // Ensure enough space for n additional elements. 2220 // Ensure enough space for n additional elements.
2180 MUST_USE_RESULT Object* EnsureCapacity(int n, Key key); 2221 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
2181 }; 2222 };
2182 2223
2183 2224
2184 2225
2185 // HashTableKey is an abstract superclass for virtual key behavior. 2226 // HashTableKey is an abstract superclass for virtual key behavior.
2186 class HashTableKey { 2227 class HashTableKey {
2187 public: 2228 public:
2188 // Returns whether the other object matches this key. 2229 // Returns whether the other object matches this key.
2189 virtual bool IsMatch(Object* other) = 0; 2230 virtual bool IsMatch(Object* other) = 0;
2190 // Returns the hash value for this key. 2231 // Returns the hash value for this key.
2191 virtual uint32_t Hash() = 0; 2232 virtual uint32_t Hash() = 0;
2192 // Returns the hash value for object. 2233 // Returns the hash value for object.
2193 virtual uint32_t HashForObject(Object* key) = 0; 2234 virtual uint32_t HashForObject(Object* key) = 0;
2194 // Returns the key object for storing into the hash table. 2235 // Returns the key object for storing into the hash table.
2195 // If allocations fails a failure object is returned. 2236 // If allocations fails a failure object is returned.
2196 MUST_USE_RESULT virtual Object* AsObject() = 0; 2237 MUST_USE_RESULT virtual MaybeObject* AsObject() = 0;
2197 // Required. 2238 // Required.
2198 virtual ~HashTableKey() {} 2239 virtual ~HashTableKey() {}
2199 }; 2240 };
2200 2241
2201 class SymbolTableShape { 2242 class SymbolTableShape {
2202 public: 2243 public:
2203 static bool IsMatch(HashTableKey* key, Object* value) { 2244 static bool IsMatch(HashTableKey* key, Object* value) {
2204 return key->IsMatch(value); 2245 return key->IsMatch(value);
2205 } 2246 }
2206 static uint32_t Hash(HashTableKey* key) { 2247 static uint32_t Hash(HashTableKey* key) {
2207 return key->Hash(); 2248 return key->Hash();
2208 } 2249 }
2209 static uint32_t HashForObject(HashTableKey* key, Object* object) { 2250 static uint32_t HashForObject(HashTableKey* key, Object* object) {
2210 return key->HashForObject(object); 2251 return key->HashForObject(object);
2211 } 2252 }
2212 MUST_USE_RESULT static Object* AsObject(HashTableKey* key) { 2253 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
2213 return key->AsObject(); 2254 return key->AsObject();
2214 } 2255 }
2215 2256
2216 static const int kPrefixSize = 0; 2257 static const int kPrefixSize = 0;
2217 static const int kEntrySize = 1; 2258 static const int kEntrySize = 1;
2218 }; 2259 };
2219 2260
2220 // SymbolTable. 2261 // SymbolTable.
2221 // 2262 //
2222 // No special elements in the prefix and the element size is 1 2263 // No special elements in the prefix and the element size is 1
2223 // because only the symbol itself (the key) needs to be stored. 2264 // because only the symbol itself (the key) needs to be stored.
2224 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> { 2265 class SymbolTable: public HashTable<SymbolTableShape, HashTableKey*> {
2225 public: 2266 public:
2226 // Find symbol in the symbol table. If it is not there yet, it is 2267 // Find symbol in the symbol table. If it is not there yet, it is
2227 // added. The return value is the symbol table which might have 2268 // added. The return value is the symbol table which might have
2228 // been enlarged. If the return value is not a failure, the symbol 2269 // been enlarged. If the return value is not a failure, the symbol
2229 // pointer *s is set to the symbol found. 2270 // pointer *s is set to the symbol found.
2230 Object* LookupSymbol(Vector<const char> str, Object** s); 2271 MUST_USE_RESULT MaybeObject* LookupSymbol(Vector<const char> str, Object** s);
2231 Object* LookupString(String* key, Object** s); 2272 MUST_USE_RESULT MaybeObject* LookupString(String* key, Object** s);
2232 2273
2233 // Looks up a symbol that is equal to the given string and returns 2274 // Looks up a symbol that is equal to the given string and returns
2234 // true if it is found, assigning the symbol to the given output 2275 // true if it is found, assigning the symbol to the given output
2235 // parameter. 2276 // parameter.
2236 bool LookupSymbolIfExists(String* str, String** symbol); 2277 bool LookupSymbolIfExists(String* str, String** symbol);
2237 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol); 2278 bool LookupTwoCharsSymbolIfExists(uint32_t c1, uint32_t c2, String** symbol);
2238 2279
2239 // Casting. 2280 // Casting.
2240 static inline SymbolTable* cast(Object* obj); 2281 static inline SymbolTable* cast(Object* obj);
2241 2282
2242 private: 2283 private:
2243 Object* LookupKey(HashTableKey* key, Object** s); 2284 MUST_USE_RESULT MaybeObject* LookupKey(HashTableKey* key, Object** s);
2244 2285
2245 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable); 2286 DISALLOW_IMPLICIT_CONSTRUCTORS(SymbolTable);
2246 }; 2287 };
2247 2288
2248 2289
2249 class MapCacheShape { 2290 class MapCacheShape {
2250 public: 2291 public:
2251 static bool IsMatch(HashTableKey* key, Object* value) { 2292 static bool IsMatch(HashTableKey* key, Object* value) {
2252 return key->IsMatch(value); 2293 return key->IsMatch(value);
2253 } 2294 }
2254 static uint32_t Hash(HashTableKey* key) { 2295 static uint32_t Hash(HashTableKey* key) {
2255 return key->Hash(); 2296 return key->Hash();
2256 } 2297 }
2257 2298
2258 static uint32_t HashForObject(HashTableKey* key, Object* object) { 2299 static uint32_t HashForObject(HashTableKey* key, Object* object) {
2259 return key->HashForObject(object); 2300 return key->HashForObject(object);
2260 } 2301 }
2261 2302
2262 MUST_USE_RESULT static Object* AsObject(HashTableKey* key) { 2303 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
2263 return key->AsObject(); 2304 return key->AsObject();
2264 } 2305 }
2265 2306
2266 static const int kPrefixSize = 0; 2307 static const int kPrefixSize = 0;
2267 static const int kEntrySize = 2; 2308 static const int kEntrySize = 2;
2268 }; 2309 };
2269 2310
2270 2311
2271 // MapCache. 2312 // MapCache.
2272 // 2313 //
2273 // Maps keys that are a fixed array of symbols to a map. 2314 // Maps keys that are a fixed array of symbols to a map.
2274 // Used for canonicalize maps for object literals. 2315 // Used for canonicalize maps for object literals.
2275 class MapCache: public HashTable<MapCacheShape, HashTableKey*> { 2316 class MapCache: public HashTable<MapCacheShape, HashTableKey*> {
2276 public: 2317 public:
2277 // Find cached value for a string key, otherwise return null. 2318 // Find cached value for a string key, otherwise return null.
2278 Object* Lookup(FixedArray* key); 2319 Object* Lookup(FixedArray* key);
2279 Object* Put(FixedArray* key, Map* value); 2320 MUST_USE_RESULT MaybeObject* Put(FixedArray* key, Map* value);
2280 static inline MapCache* cast(Object* obj); 2321 static inline MapCache* cast(Object* obj);
2281 2322
2282 private: 2323 private:
2283 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache); 2324 DISALLOW_IMPLICIT_CONSTRUCTORS(MapCache);
2284 }; 2325 };
2285 2326
2286 2327
2287 template <typename Shape, typename Key> 2328 template <typename Shape, typename Key>
2288 class Dictionary: public HashTable<Shape, Key> { 2329 class Dictionary: public HashTable<Shape, Key> {
2289 public: 2330 public:
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2340 // Accessors for next enumeration index. 2381 // Accessors for next enumeration index.
2341 void SetNextEnumerationIndex(int index) { 2382 void SetNextEnumerationIndex(int index) {
2342 this->fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index)); 2383 this->fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index));
2343 } 2384 }
2344 2385
2345 int NextEnumerationIndex() { 2386 int NextEnumerationIndex() {
2346 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value(); 2387 return Smi::cast(FixedArray::get(kNextEnumerationIndexIndex))->value();
2347 } 2388 }
2348 2389
2349 // Returns a new array for dictionary usage. Might return Failure. 2390 // Returns a new array for dictionary usage. Might return Failure.
2350 MUST_USE_RESULT static Object* Allocate(int at_least_space_for); 2391 MUST_USE_RESULT static MaybeObject* Allocate(int at_least_space_for);
2351 2392
2352 // Ensure enough space for n additional elements. 2393 // Ensure enough space for n additional elements.
2353 Object* EnsureCapacity(int n, Key key); 2394 MUST_USE_RESULT MaybeObject* EnsureCapacity(int n, Key key);
2354 2395
2355 #ifdef DEBUG 2396 #ifdef DEBUG
2356 void Print(); 2397 void Print();
2357 #endif 2398 #endif
2358 // Returns the key (slow). 2399 // Returns the key (slow).
2359 Object* SlowReverseLookup(Object* value); 2400 Object* SlowReverseLookup(Object* value);
2360 2401
2361 // Sets the entry to (key, value) pair. 2402 // Sets the entry to (key, value) pair.
2362 inline void SetEntry(int entry, 2403 inline void SetEntry(int entry,
2363 Object* key, 2404 Object* key,
2364 Object* value, 2405 Object* value,
2365 PropertyDetails details); 2406 PropertyDetails details);
2366 2407
2367 Object* Add(Key key, Object* value, PropertyDetails details); 2408 MUST_USE_RESULT MaybeObject* Add(Key key,
2409 Object* value,
2410 PropertyDetails details);
2368 2411
2369 protected: 2412 protected:
2370 // Generic at put operation. 2413 // Generic at put operation.
2371 Object* AtPut(Key key, Object* value); 2414 MUST_USE_RESULT MaybeObject* AtPut(Key key, Object* value);
2372 2415
2373 // Add entry to dictionary. 2416 // Add entry to dictionary.
2374 Object* AddEntry(Key key, 2417 MUST_USE_RESULT MaybeObject* AddEntry(Key key,
2375 Object* value, 2418 Object* value,
2376 PropertyDetails details, 2419 PropertyDetails details,
2377 uint32_t hash); 2420 uint32_t hash);
2378 2421
2379 // Generate new enumeration indices to avoid enumeration index overflow. 2422 // Generate new enumeration indices to avoid enumeration index overflow.
2380 Object* GenerateNewEnumerationIndices(); 2423 MUST_USE_RESULT MaybeObject* GenerateNewEnumerationIndices();
2381 static const int kMaxNumberKeyIndex = 2424 static const int kMaxNumberKeyIndex =
2382 HashTable<Shape, Key>::kPrefixStartIndex; 2425 HashTable<Shape, Key>::kPrefixStartIndex;
2383 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 2426 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
2384 }; 2427 };
2385 2428
2386 2429
2387 class StringDictionaryShape { 2430 class StringDictionaryShape {
2388 public: 2431 public:
2389 static inline bool IsMatch(String* key, Object* other); 2432 static inline bool IsMatch(String* key, Object* other);
2390 static inline uint32_t Hash(String* key); 2433 static inline uint32_t Hash(String* key);
2391 static inline uint32_t HashForObject(String* key, Object* object); 2434 static inline uint32_t HashForObject(String* key, Object* object);
2392 MUST_USE_RESULT static inline Object* AsObject(String* key); 2435 MUST_USE_RESULT static inline MaybeObject* AsObject(String* key);
2393 static const int kPrefixSize = 2; 2436 static const int kPrefixSize = 2;
2394 static const int kEntrySize = 3; 2437 static const int kEntrySize = 3;
2395 static const bool kIsEnumerable = true; 2438 static const bool kIsEnumerable = true;
2396 }; 2439 };
2397 2440
2398 2441
2399 class StringDictionary: public Dictionary<StringDictionaryShape, String*> { 2442 class StringDictionary: public Dictionary<StringDictionaryShape, String*> {
2400 public: 2443 public:
2401 static inline StringDictionary* cast(Object* obj) { 2444 static inline StringDictionary* cast(Object* obj) {
2402 ASSERT(obj->IsDictionary()); 2445 ASSERT(obj->IsDictionary());
2403 return reinterpret_cast<StringDictionary*>(obj); 2446 return reinterpret_cast<StringDictionary*>(obj);
2404 } 2447 }
2405 2448
2406 // Copies enumerable keys to preallocated fixed array. 2449 // Copies enumerable keys to preallocated fixed array.
2407 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); 2450 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array);
2408 2451
2409 // For transforming properties of a JSObject. 2452 // For transforming properties of a JSObject.
2410 Object* TransformPropertiesToFastFor(JSObject* obj, 2453 MUST_USE_RESULT MaybeObject* TransformPropertiesToFastFor(
2411 int unused_property_fields); 2454 JSObject* obj,
2455 int unused_property_fields);
2412 2456
2413 // Find entry for key otherwise return kNotFound. Optimzed version of 2457 // Find entry for key otherwise return kNotFound. Optimzed version of
2414 // HashTable::FindEntry. 2458 // HashTable::FindEntry.
2415 int FindEntry(String* key); 2459 int FindEntry(String* key);
2416 }; 2460 };
2417 2461
2418 2462
2419 class NumberDictionaryShape { 2463 class NumberDictionaryShape {
2420 public: 2464 public:
2421 static inline bool IsMatch(uint32_t key, Object* other); 2465 static inline bool IsMatch(uint32_t key, Object* other);
2422 static inline uint32_t Hash(uint32_t key); 2466 static inline uint32_t Hash(uint32_t key);
2423 static inline uint32_t HashForObject(uint32_t key, Object* object); 2467 static inline uint32_t HashForObject(uint32_t key, Object* object);
2424 MUST_USE_RESULT static inline Object* AsObject(uint32_t key); 2468 MUST_USE_RESULT static inline MaybeObject* AsObject(uint32_t key);
2425 static const int kPrefixSize = 2; 2469 static const int kPrefixSize = 2;
2426 static const int kEntrySize = 3; 2470 static const int kEntrySize = 3;
2427 static const bool kIsEnumerable = false; 2471 static const bool kIsEnumerable = false;
2428 }; 2472 };
2429 2473
2430 2474
2431 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> { 2475 class NumberDictionary: public Dictionary<NumberDictionaryShape, uint32_t> {
2432 public: 2476 public:
2433 static NumberDictionary* cast(Object* obj) { 2477 static NumberDictionary* cast(Object* obj) {
2434 ASSERT(obj->IsDictionary()); 2478 ASSERT(obj->IsDictionary());
2435 return reinterpret_cast<NumberDictionary*>(obj); 2479 return reinterpret_cast<NumberDictionary*>(obj);
2436 } 2480 }
2437 2481
2438 // Type specific at put (default NONE attributes is used when adding). 2482 // Type specific at put (default NONE attributes is used when adding).
2439 Object* AtNumberPut(uint32_t key, Object* value); 2483 MUST_USE_RESULT MaybeObject* AtNumberPut(uint32_t key, Object* value);
2440 Object* AddNumberEntry(uint32_t key, 2484 MUST_USE_RESULT MaybeObject* AddNumberEntry(uint32_t key,
2441 Object* value, 2485 Object* value,
2442 PropertyDetails details); 2486 PropertyDetails details);
2443 2487
2444 // Set an existing entry or add a new one if needed. 2488 // Set an existing entry or add a new one if needed.
2445 Object* Set(uint32_t key, Object* value, PropertyDetails details); 2489 MUST_USE_RESULT MaybeObject* Set(uint32_t key,
2490 Object* value,
2491 PropertyDetails details);
2446 2492
2447 void UpdateMaxNumberKey(uint32_t key); 2493 void UpdateMaxNumberKey(uint32_t key);
2448 2494
2449 // If slow elements are required we will never go back to fast-case 2495 // If slow elements are required we will never go back to fast-case
2450 // for the elements kept in this dictionary. We require slow 2496 // for the elements kept in this dictionary. We require slow
2451 // elements if an element has been added at an index larger than 2497 // elements if an element has been added at an index larger than
2452 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called 2498 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called
2453 // when defining a getter or setter with a number key. 2499 // when defining a getter or setter with a number key.
2454 inline bool requires_slow_elements(); 2500 inline bool requires_slow_elements();
2455 inline void set_requires_slow_elements(); 2501 inline void set_requires_slow_elements();
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 }; 2548 };
2503 2549
2504 2550
2505 // The cache for maps used by normalized (dictionary mode) objects. 2551 // The cache for maps used by normalized (dictionary mode) objects.
2506 // Such maps do not have property descriptors, so a typical program 2552 // Such maps do not have property descriptors, so a typical program
2507 // needs very limited number of distinct normalized maps. 2553 // needs very limited number of distinct normalized maps.
2508 class NormalizedMapCache: public FixedArray { 2554 class NormalizedMapCache: public FixedArray {
2509 public: 2555 public:
2510 static const int kEntries = 64; 2556 static const int kEntries = 64;
2511 2557
2512 Object* Get(JSObject* object, PropertyNormalizationMode mode); 2558 MUST_USE_RESULT MaybeObject* Get(JSObject* object,
2559 PropertyNormalizationMode mode);
2513 2560
2514 void Clear(); 2561 void Clear();
2515 2562
2516 // Casting 2563 // Casting
2517 static inline NormalizedMapCache* cast(Object* obj); 2564 static inline NormalizedMapCache* cast(Object* obj);
2518 2565
2519 #ifdef DEBUG 2566 #ifdef DEBUG
2520 void NormalizedMapCacheVerify(); 2567 void NormalizedMapCacheVerify();
2521 #endif 2568 #endif
2522 2569
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2679 2726
2680 2727
2681 class ExternalByteArray: public ExternalArray { 2728 class ExternalByteArray: public ExternalArray {
2682 public: 2729 public:
2683 // Setter and getter. 2730 // Setter and getter.
2684 inline int8_t get(int index); 2731 inline int8_t get(int index);
2685 inline void set(int index, int8_t value); 2732 inline void set(int index, int8_t value);
2686 2733
2687 // This accessor applies the correct conversion from Smi, HeapNumber 2734 // This accessor applies the correct conversion from Smi, HeapNumber
2688 // and undefined. 2735 // and undefined.
2689 Object* SetValue(uint32_t index, Object* value); 2736 MaybeObject* SetValue(uint32_t index, Object* value);
2690 2737
2691 // Casting. 2738 // Casting.
2692 static inline ExternalByteArray* cast(Object* obj); 2739 static inline ExternalByteArray* cast(Object* obj);
2693 2740
2694 #ifdef DEBUG 2741 #ifdef DEBUG
2695 void ExternalByteArrayPrint(); 2742 void ExternalByteArrayPrint();
2696 void ExternalByteArrayVerify(); 2743 void ExternalByteArrayVerify();
2697 #endif // DEBUG 2744 #endif // DEBUG
2698 2745
2699 private: 2746 private:
2700 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalByteArray); 2747 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalByteArray);
2701 }; 2748 };
2702 2749
2703 2750
2704 class ExternalUnsignedByteArray: public ExternalArray { 2751 class ExternalUnsignedByteArray: public ExternalArray {
2705 public: 2752 public:
2706 // Setter and getter. 2753 // Setter and getter.
2707 inline uint8_t get(int index); 2754 inline uint8_t get(int index);
2708 inline void set(int index, uint8_t value); 2755 inline void set(int index, uint8_t value);
2709 2756
2710 // This accessor applies the correct conversion from Smi, HeapNumber 2757 // This accessor applies the correct conversion from Smi, HeapNumber
2711 // and undefined. 2758 // and undefined.
2712 Object* SetValue(uint32_t index, Object* value); 2759 MaybeObject* SetValue(uint32_t index, Object* value);
2713 2760
2714 // Casting. 2761 // Casting.
2715 static inline ExternalUnsignedByteArray* cast(Object* obj); 2762 static inline ExternalUnsignedByteArray* cast(Object* obj);
2716 2763
2717 #ifdef DEBUG 2764 #ifdef DEBUG
2718 void ExternalUnsignedByteArrayPrint(); 2765 void ExternalUnsignedByteArrayPrint();
2719 void ExternalUnsignedByteArrayVerify(); 2766 void ExternalUnsignedByteArrayVerify();
2720 #endif // DEBUG 2767 #endif // DEBUG
2721 2768
2722 private: 2769 private:
2723 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedByteArray); 2770 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedByteArray);
2724 }; 2771 };
2725 2772
2726 2773
2727 class ExternalShortArray: public ExternalArray { 2774 class ExternalShortArray: public ExternalArray {
2728 public: 2775 public:
2729 // Setter and getter. 2776 // Setter and getter.
2730 inline int16_t get(int index); 2777 inline int16_t get(int index);
2731 inline void set(int index, int16_t value); 2778 inline void set(int index, int16_t value);
2732 2779
2733 // This accessor applies the correct conversion from Smi, HeapNumber 2780 // This accessor applies the correct conversion from Smi, HeapNumber
2734 // and undefined. 2781 // and undefined.
2735 Object* SetValue(uint32_t index, Object* value); 2782 MaybeObject* SetValue(uint32_t index, Object* value);
2736 2783
2737 // Casting. 2784 // Casting.
2738 static inline ExternalShortArray* cast(Object* obj); 2785 static inline ExternalShortArray* cast(Object* obj);
2739 2786
2740 #ifdef DEBUG 2787 #ifdef DEBUG
2741 void ExternalShortArrayPrint(); 2788 void ExternalShortArrayPrint();
2742 void ExternalShortArrayVerify(); 2789 void ExternalShortArrayVerify();
2743 #endif // DEBUG 2790 #endif // DEBUG
2744 2791
2745 private: 2792 private:
2746 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalShortArray); 2793 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalShortArray);
2747 }; 2794 };
2748 2795
2749 2796
2750 class ExternalUnsignedShortArray: public ExternalArray { 2797 class ExternalUnsignedShortArray: public ExternalArray {
2751 public: 2798 public:
2752 // Setter and getter. 2799 // Setter and getter.
2753 inline uint16_t get(int index); 2800 inline uint16_t get(int index);
2754 inline void set(int index, uint16_t value); 2801 inline void set(int index, uint16_t value);
2755 2802
2756 // This accessor applies the correct conversion from Smi, HeapNumber 2803 // This accessor applies the correct conversion from Smi, HeapNumber
2757 // and undefined. 2804 // and undefined.
2758 Object* SetValue(uint32_t index, Object* value); 2805 MaybeObject* SetValue(uint32_t index, Object* value);
2759 2806
2760 // Casting. 2807 // Casting.
2761 static inline ExternalUnsignedShortArray* cast(Object* obj); 2808 static inline ExternalUnsignedShortArray* cast(Object* obj);
2762 2809
2763 #ifdef DEBUG 2810 #ifdef DEBUG
2764 void ExternalUnsignedShortArrayPrint(); 2811 void ExternalUnsignedShortArrayPrint();
2765 void ExternalUnsignedShortArrayVerify(); 2812 void ExternalUnsignedShortArrayVerify();
2766 #endif // DEBUG 2813 #endif // DEBUG
2767 2814
2768 private: 2815 private:
2769 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedShortArray); 2816 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedShortArray);
2770 }; 2817 };
2771 2818
2772 2819
2773 class ExternalIntArray: public ExternalArray { 2820 class ExternalIntArray: public ExternalArray {
2774 public: 2821 public:
2775 // Setter and getter. 2822 // Setter and getter.
2776 inline int32_t get(int index); 2823 inline int32_t get(int index);
2777 inline void set(int index, int32_t value); 2824 inline void set(int index, int32_t value);
2778 2825
2779 // This accessor applies the correct conversion from Smi, HeapNumber 2826 // This accessor applies the correct conversion from Smi, HeapNumber
2780 // and undefined. 2827 // and undefined.
2781 Object* SetValue(uint32_t index, Object* value); 2828 MaybeObject* SetValue(uint32_t index, Object* value);
2782 2829
2783 // Casting. 2830 // Casting.
2784 static inline ExternalIntArray* cast(Object* obj); 2831 static inline ExternalIntArray* cast(Object* obj);
2785 2832
2786 #ifdef DEBUG 2833 #ifdef DEBUG
2787 void ExternalIntArrayPrint(); 2834 void ExternalIntArrayPrint();
2788 void ExternalIntArrayVerify(); 2835 void ExternalIntArrayVerify();
2789 #endif // DEBUG 2836 #endif // DEBUG
2790 2837
2791 private: 2838 private:
2792 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalIntArray); 2839 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalIntArray);
2793 }; 2840 };
2794 2841
2795 2842
2796 class ExternalUnsignedIntArray: public ExternalArray { 2843 class ExternalUnsignedIntArray: public ExternalArray {
2797 public: 2844 public:
2798 // Setter and getter. 2845 // Setter and getter.
2799 inline uint32_t get(int index); 2846 inline uint32_t get(int index);
2800 inline void set(int index, uint32_t value); 2847 inline void set(int index, uint32_t value);
2801 2848
2802 // This accessor applies the correct conversion from Smi, HeapNumber 2849 // This accessor applies the correct conversion from Smi, HeapNumber
2803 // and undefined. 2850 // and undefined.
2804 Object* SetValue(uint32_t index, Object* value); 2851 MaybeObject* SetValue(uint32_t index, Object* value);
2805 2852
2806 // Casting. 2853 // Casting.
2807 static inline ExternalUnsignedIntArray* cast(Object* obj); 2854 static inline ExternalUnsignedIntArray* cast(Object* obj);
2808 2855
2809 #ifdef DEBUG 2856 #ifdef DEBUG
2810 void ExternalUnsignedIntArrayPrint(); 2857 void ExternalUnsignedIntArrayPrint();
2811 void ExternalUnsignedIntArrayVerify(); 2858 void ExternalUnsignedIntArrayVerify();
2812 #endif // DEBUG 2859 #endif // DEBUG
2813 2860
2814 private: 2861 private:
2815 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedIntArray); 2862 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalUnsignedIntArray);
2816 }; 2863 };
2817 2864
2818 2865
2819 class ExternalFloatArray: public ExternalArray { 2866 class ExternalFloatArray: public ExternalArray {
2820 public: 2867 public:
2821 // Setter and getter. 2868 // Setter and getter.
2822 inline float get(int index); 2869 inline float get(int index);
2823 inline void set(int index, float value); 2870 inline void set(int index, float value);
2824 2871
2825 // This accessor applies the correct conversion from Smi, HeapNumber 2872 // This accessor applies the correct conversion from Smi, HeapNumber
2826 // and undefined. 2873 // and undefined.
2827 Object* SetValue(uint32_t index, Object* value); 2874 MaybeObject* SetValue(uint32_t index, Object* value);
2828 2875
2829 // Casting. 2876 // Casting.
2830 static inline ExternalFloatArray* cast(Object* obj); 2877 static inline ExternalFloatArray* cast(Object* obj);
2831 2878
2832 #ifdef DEBUG 2879 #ifdef DEBUG
2833 void ExternalFloatArrayPrint(); 2880 void ExternalFloatArrayPrint();
2834 void ExternalFloatArrayVerify(); 2881 void ExternalFloatArrayVerify();
2835 #endif // DEBUG 2882 #endif // DEBUG
2836 2883
2837 private: 2884 private:
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
3185 DECL_ACCESSORS(constructor, Object) 3232 DECL_ACCESSORS(constructor, Object)
3186 3233
3187 inline JSFunction* unchecked_constructor(); 3234 inline JSFunction* unchecked_constructor();
3188 3235
3189 // [instance descriptors]: describes the object. 3236 // [instance descriptors]: describes the object.
3190 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 3237 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
3191 3238
3192 // [stub cache]: contains stubs compiled for this map. 3239 // [stub cache]: contains stubs compiled for this map.
3193 DECL_ACCESSORS(code_cache, Object) 3240 DECL_ACCESSORS(code_cache, Object)
3194 3241
3195 MUST_USE_RESULT Object* CopyDropDescriptors(); 3242 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
3196 3243
3197 MUST_USE_RESULT Object* CopyNormalized(PropertyNormalizationMode mode, 3244 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
3198 NormalizedMapSharingMode sharing); 3245 NormalizedMapSharingMode sharing);
3199 3246
3200 // Returns a copy of the map, with all transitions dropped from the 3247 // Returns a copy of the map, with all transitions dropped from the
3201 // instance descriptors. 3248 // instance descriptors.
3202 MUST_USE_RESULT Object* CopyDropTransitions(); 3249 MUST_USE_RESULT MaybeObject* CopyDropTransitions();
3203 3250
3204 // Returns this map if it has the fast elements bit set, otherwise 3251 // Returns this map if it has the fast elements bit set, otherwise
3205 // returns a copy of the map, with all transitions dropped from the 3252 // returns a copy of the map, with all transitions dropped from the
3206 // descriptors and the fast elements bit set. 3253 // descriptors and the fast elements bit set.
3207 inline Object* GetFastElementsMap(); 3254 MUST_USE_RESULT inline MaybeObject* GetFastElementsMap();
3208 3255
3209 // Returns this map if it has the fast elements bit cleared, 3256 // Returns this map if it has the fast elements bit cleared,
3210 // otherwise returns a copy of the map, with all transitions dropped 3257 // otherwise returns a copy of the map, with all transitions dropped
3211 // from the descriptors and the fast elements bit cleared. 3258 // from the descriptors and the fast elements bit cleared.
3212 inline Object* GetSlowElementsMap(); 3259 MUST_USE_RESULT inline MaybeObject* GetSlowElementsMap();
3213 3260
3214 // Returns the property index for name (only valid for FAST MODE). 3261 // Returns the property index for name (only valid for FAST MODE).
3215 int PropertyIndexFor(String* name); 3262 int PropertyIndexFor(String* name);
3216 3263
3217 // Returns the next free property index (only valid for FAST MODE). 3264 // Returns the next free property index (only valid for FAST MODE).
3218 int NextFreePropertyIndex(); 3265 int NextFreePropertyIndex();
3219 3266
3220 // Returns the number of properties described in instance_descriptors. 3267 // Returns the number of properties described in instance_descriptors.
3221 int NumberOfDescribedProperties(); 3268 int NumberOfDescribedProperties();
3222 3269
3223 // Casting. 3270 // Casting.
3224 static inline Map* cast(Object* obj); 3271 static inline Map* cast(Object* obj);
3225 3272
3226 // Locate an accessor in the instance descriptor. 3273 // Locate an accessor in the instance descriptor.
3227 AccessorDescriptor* FindAccessor(String* name); 3274 AccessorDescriptor* FindAccessor(String* name);
3228 3275
3229 // Code cache operations. 3276 // Code cache operations.
3230 3277
3231 // Clears the code cache. 3278 // Clears the code cache.
3232 inline void ClearCodeCache(); 3279 inline void ClearCodeCache();
3233 3280
3234 // Update code cache. 3281 // Update code cache.
3235 MUST_USE_RESULT Object* UpdateCodeCache(String* name, Code* code); 3282 MUST_USE_RESULT MaybeObject* UpdateCodeCache(String* name, Code* code);
3236 3283
3237 // Returns the found code or undefined if absent. 3284 // Returns the found code or undefined if absent.
3238 Object* FindInCodeCache(String* name, Code::Flags flags); 3285 Object* FindInCodeCache(String* name, Code::Flags flags);
3239 3286
3240 // Returns the non-negative index of the code object if it is in the 3287 // Returns the non-negative index of the code object if it is in the
3241 // cache and -1 otherwise. 3288 // cache and -1 otherwise.
3242 int IndexInCodeCache(Object* name, Code* code); 3289 int IndexInCodeCache(Object* name, Code* code);
3243 3290
3244 // Removes a code object from the code cache at the given index. 3291 // Removes a code object from the code cache at the given index.
3245 void RemoveFromCodeCache(String* name, Code* code, int index); 3292 void RemoveFromCodeCache(String* name, Code* code, int index);
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 3921
3875 // Get and set the prototype property on a JSFunction. If the 3922 // Get and set the prototype property on a JSFunction. If the
3876 // function has an initial map the prototype is set on the initial 3923 // function has an initial map the prototype is set on the initial
3877 // map. Otherwise, the prototype is put in the initial map field 3924 // map. Otherwise, the prototype is put in the initial map field
3878 // until an initial map is needed. 3925 // until an initial map is needed.
3879 inline bool has_prototype(); 3926 inline bool has_prototype();
3880 inline bool has_instance_prototype(); 3927 inline bool has_instance_prototype();
3881 inline Object* prototype(); 3928 inline Object* prototype();
3882 inline Object* instance_prototype(); 3929 inline Object* instance_prototype();
3883 Object* SetInstancePrototype(Object* value); 3930 Object* SetInstancePrototype(Object* value);
3884 MUST_USE_RESULT Object* SetPrototype(Object* value); 3931 MUST_USE_RESULT MaybeObject* SetPrototype(Object* value);
3885 3932
3886 // After prototype is removed, it will not be created when accessed, and 3933 // After prototype is removed, it will not be created when accessed, and
3887 // [[Construct]] from this function will not be allowed. 3934 // [[Construct]] from this function will not be allowed.
3888 Object* RemovePrototype(); 3935 Object* RemovePrototype();
3889 inline bool should_have_prototype(); 3936 inline bool should_have_prototype();
3890 3937
3891 // Accessor for this function's initial map's [[class]] 3938 // Accessor for this function's initial map's [[class]]
3892 // property. This is primarily used by ECMA native functions. This 3939 // property. This is primarily used by ECMA native functions. This
3893 // method sets the class_name field of this function's initial map 3940 // method sets the class_name field of this function's initial map
3894 // to a given value. It creates an initial map if this function does 3941 // to a given value. It creates an initial map if this function does
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
3984 4031
3985 // [global context]: the global context corresponding to this global object. 4032 // [global context]: the global context corresponding to this global object.
3986 DECL_ACCESSORS(global_context, Context) 4033 DECL_ACCESSORS(global_context, Context)
3987 4034
3988 // [global receiver]: the global receiver object of the context 4035 // [global receiver]: the global receiver object of the context
3989 DECL_ACCESSORS(global_receiver, JSObject) 4036 DECL_ACCESSORS(global_receiver, JSObject)
3990 4037
3991 // Retrieve the property cell used to store a property. 4038 // Retrieve the property cell used to store a property.
3992 Object* GetPropertyCell(LookupResult* result); 4039 Object* GetPropertyCell(LookupResult* result);
3993 4040
4041 // This is like GetProperty, but is used when you know the lookup won't fail
4042 // by throwing an exception. This is for the debug and builtins global
4043 // objects, where it is known which properties can be expected to be present
4044 // on the object.
4045 Object* GetPropertyNoExceptionThrown(String* key) {
4046 Object* answer = GetProperty(key)->ToObjectUnchecked();
4047 return answer;
4048 }
4049
3994 // Ensure that the global object has a cell for the given property name. 4050 // Ensure that the global object has a cell for the given property name.
3995 Object* EnsurePropertyCell(String* name); 4051 MUST_USE_RESULT MaybeObject* EnsurePropertyCell(String* name);
3996 4052
3997 // Casting. 4053 // Casting.
3998 static inline GlobalObject* cast(Object* obj); 4054 static inline GlobalObject* cast(Object* obj);
3999 4055
4000 // Layout description. 4056 // Layout description.
4001 static const int kBuiltinsOffset = JSObject::kHeaderSize; 4057 static const int kBuiltinsOffset = JSObject::kHeaderSize;
4002 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize; 4058 static const int kGlobalContextOffset = kBuiltinsOffset + kPointerSize;
4003 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize; 4059 static const int kGlobalReceiverOffset = kGlobalContextOffset + kPointerSize;
4004 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize; 4060 static const int kHeaderSize = kGlobalReceiverOffset + kPointerSize;
4005 4061
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
4215 } 4271 }
4216 4272
4217 static inline uint32_t Hash(HashTableKey* key) { 4273 static inline uint32_t Hash(HashTableKey* key) {
4218 return key->Hash(); 4274 return key->Hash();
4219 } 4275 }
4220 4276
4221 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 4277 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
4222 return key->HashForObject(object); 4278 return key->HashForObject(object);
4223 } 4279 }
4224 4280
4225 MUST_USE_RESULT static Object* AsObject(HashTableKey* key) { 4281 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
4226 return key->AsObject(); 4282 return key->AsObject();
4227 } 4283 }
4228 4284
4229 static const int kPrefixSize = 0; 4285 static const int kPrefixSize = 0;
4230 static const int kEntrySize = 2; 4286 static const int kEntrySize = 2;
4231 }; 4287 };
4232 4288
4233 4289
4234 class CompilationCacheTable: public HashTable<CompilationCacheShape, 4290 class CompilationCacheTable: public HashTable<CompilationCacheShape,
4235 HashTableKey*> { 4291 HashTableKey*> {
4236 public: 4292 public:
4237 // Find cached value for a string key, otherwise return null. 4293 // Find cached value for a string key, otherwise return null.
4238 Object* Lookup(String* src); 4294 Object* Lookup(String* src);
4239 Object* LookupEval(String* src, Context* context); 4295 Object* LookupEval(String* src, Context* context);
4240 Object* LookupRegExp(String* source, JSRegExp::Flags flags); 4296 Object* LookupRegExp(String* source, JSRegExp::Flags flags);
4241 Object* Put(String* src, Object* value); 4297 MaybeObject* Put(String* src, Object* value);
4242 Object* PutEval(String* src, Context* context, Object* value); 4298 MaybeObject* PutEval(String* src, Context* context, Object* value);
4243 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 4299 MaybeObject* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
4244 4300
4245 static inline CompilationCacheTable* cast(Object* obj); 4301 static inline CompilationCacheTable* cast(Object* obj);
4246 4302
4247 private: 4303 private:
4248 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 4304 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
4249 }; 4305 };
4250 4306
4251 4307
4252 class CodeCache: public Struct { 4308 class CodeCache: public Struct {
4253 public: 4309 public:
4254 DECL_ACCESSORS(default_cache, FixedArray) 4310 DECL_ACCESSORS(default_cache, FixedArray)
4255 DECL_ACCESSORS(normal_type_cache, Object) 4311 DECL_ACCESSORS(normal_type_cache, Object)
4256 4312
4257 // Add the code object to the cache. 4313 // Add the code object to the cache.
4258 MUST_USE_RESULT Object* Update(String* name, Code* code); 4314 MUST_USE_RESULT MaybeObject* Update(String* name, Code* code);
4259 4315
4260 // Lookup code object in the cache. Returns code object if found and undefined 4316 // Lookup code object in the cache. Returns code object if found and undefined
4261 // if not. 4317 // if not.
4262 Object* Lookup(String* name, Code::Flags flags); 4318 Object* Lookup(String* name, Code::Flags flags);
4263 4319
4264 // Get the internal index of a code object in the cache. Returns -1 if the 4320 // Get the internal index of a code object in the cache. Returns -1 if the
4265 // code object is not in that cache. This index can be used to later call 4321 // code object is not in that cache. This index can be used to later call
4266 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and 4322 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and
4267 // RemoveByIndex. 4323 // RemoveByIndex.
4268 int GetIndex(Object* name, Code* code); 4324 int GetIndex(Object* name, Code* code);
4269 4325
4270 // Remove an object from the cache with the provided internal index. 4326 // Remove an object from the cache with the provided internal index.
4271 void RemoveByIndex(Object* name, Code* code, int index); 4327 void RemoveByIndex(Object* name, Code* code, int index);
4272 4328
4273 static inline CodeCache* cast(Object* obj); 4329 static inline CodeCache* cast(Object* obj);
4274 4330
4275 #ifdef DEBUG 4331 #ifdef DEBUG
4276 void CodeCachePrint(); 4332 void CodeCachePrint();
4277 void CodeCacheVerify(); 4333 void CodeCacheVerify();
4278 #endif 4334 #endif
4279 4335
4280 static const int kDefaultCacheOffset = HeapObject::kHeaderSize; 4336 static const int kDefaultCacheOffset = HeapObject::kHeaderSize;
4281 static const int kNormalTypeCacheOffset = 4337 static const int kNormalTypeCacheOffset =
4282 kDefaultCacheOffset + kPointerSize; 4338 kDefaultCacheOffset + kPointerSize;
4283 static const int kSize = kNormalTypeCacheOffset + kPointerSize; 4339 static const int kSize = kNormalTypeCacheOffset + kPointerSize;
4284 4340
4285 private: 4341 private:
4286 MUST_USE_RESULT Object* UpdateDefaultCache(String* name, Code* code); 4342 MUST_USE_RESULT MaybeObject* UpdateDefaultCache(String* name, Code* code);
4287 MUST_USE_RESULT Object* UpdateNormalTypeCache(String* name, Code* code); 4343 MUST_USE_RESULT MaybeObject* UpdateNormalTypeCache(String* name, Code* code);
4288 Object* LookupDefaultCache(String* name, Code::Flags flags); 4344 Object* LookupDefaultCache(String* name, Code::Flags flags);
4289 Object* LookupNormalTypeCache(String* name, Code::Flags flags); 4345 Object* LookupNormalTypeCache(String* name, Code::Flags flags);
4290 4346
4291 // Code cache layout of the default cache. Elements are alternating name and 4347 // Code cache layout of the default cache. Elements are alternating name and
4292 // code objects for non normal load/store/call IC's. 4348 // code objects for non normal load/store/call IC's.
4293 static const int kCodeCacheEntrySize = 2; 4349 static const int kCodeCacheEntrySize = 2;
4294 static const int kCodeCacheEntryNameOffset = 0; 4350 static const int kCodeCacheEntryNameOffset = 0;
4295 static const int kCodeCacheEntryCodeOffset = 1; 4351 static const int kCodeCacheEntryCodeOffset = 1;
4296 4352
4297 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); 4353 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache);
4298 }; 4354 };
4299 4355
4300 4356
4301 class CodeCacheHashTableShape { 4357 class CodeCacheHashTableShape {
4302 public: 4358 public:
4303 static inline bool IsMatch(HashTableKey* key, Object* value) { 4359 static inline bool IsMatch(HashTableKey* key, Object* value) {
4304 return key->IsMatch(value); 4360 return key->IsMatch(value);
4305 } 4361 }
4306 4362
4307 static inline uint32_t Hash(HashTableKey* key) { 4363 static inline uint32_t Hash(HashTableKey* key) {
4308 return key->Hash(); 4364 return key->Hash();
4309 } 4365 }
4310 4366
4311 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { 4367 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
4312 return key->HashForObject(object); 4368 return key->HashForObject(object);
4313 } 4369 }
4314 4370
4315 MUST_USE_RESULT static Object* AsObject(HashTableKey* key) { 4371 MUST_USE_RESULT static MaybeObject* AsObject(HashTableKey* key) {
4316 return key->AsObject(); 4372 return key->AsObject();
4317 } 4373 }
4318 4374
4319 static const int kPrefixSize = 0; 4375 static const int kPrefixSize = 0;
4320 static const int kEntrySize = 2; 4376 static const int kEntrySize = 2;
4321 }; 4377 };
4322 4378
4323 4379
4324 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, 4380 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
4325 HashTableKey*> { 4381 HashTableKey*> {
4326 public: 4382 public:
4327 Object* Lookup(String* name, Code::Flags flags); 4383 Object* Lookup(String* name, Code::Flags flags);
4328 MUST_USE_RESULT Object* Put(String* name, Code* code); 4384 MUST_USE_RESULT MaybeObject* Put(String* name, Code* code);
4329 4385
4330 int GetIndex(String* name, Code::Flags flags); 4386 int GetIndex(String* name, Code::Flags flags);
4331 void RemoveByIndex(int index); 4387 void RemoveByIndex(int index);
4332 4388
4333 static inline CodeCacheHashTable* cast(Object* obj); 4389 static inline CodeCacheHashTable* cast(Object* obj);
4334 4390
4335 // Initial size of the fixed array backing the hash table. 4391 // Initial size of the fixed array backing the hash table.
4336 static const int kInitialSize = 64; 4392 static const int kInitialSize = 64;
4337 4393
4338 private: 4394 private:
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
4485 // the second component is the empty string. If allocation fails, 4541 // the second component is the empty string. If allocation fails,
4486 // this function returns a failure. If flattening succeeds, this 4542 // this function returns a failure. If flattening succeeds, this
4487 // function returns the sequential string that is now the first 4543 // function returns the sequential string that is now the first
4488 // component of the cons string. 4544 // component of the cons string.
4489 // 4545 //
4490 // Degenerate cons strings are handled specially by the garbage 4546 // Degenerate cons strings are handled specially by the garbage
4491 // collector (see IsShortcutCandidate). 4547 // collector (see IsShortcutCandidate).
4492 // 4548 //
4493 // Use FlattenString from Handles.cc to flatten even in case an 4549 // Use FlattenString from Handles.cc to flatten even in case an
4494 // allocation failure happens. 4550 // allocation failure happens.
4495 inline Object* TryFlatten(PretenureFlag pretenure = NOT_TENURED); 4551 inline MaybeObject* TryFlatten(PretenureFlag pretenure = NOT_TENURED);
4496 4552
4497 // Convenience function. Has exactly the same behavior as 4553 // Convenience function. Has exactly the same behavior as
4498 // TryFlatten(), except in the case of failure returns the original 4554 // TryFlatten(), except in the case of failure returns the original
4499 // string. 4555 // string.
4500 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED); 4556 inline String* TryFlattenGetString(PretenureFlag pretenure = NOT_TENURED);
4501 4557
4502 Vector<const char> ToAsciiVector(); 4558 Vector<const char> ToAsciiVector();
4503 Vector<const uc16> ToUC16Vector(); 4559 Vector<const uc16> ToUC16Vector();
4504 4560
4505 // Mark the string as an undetectable object. It only applies to 4561 // Mark the string as an undetectable object. It only applies to
4506 // ascii and two byte string types. 4562 // ascii and two byte string types.
4507 bool MarkAsUndetectable(); 4563 bool MarkAsUndetectable();
4508 4564
4509 // Return a substring. 4565 // Return a substring.
4510 Object* SubString(int from, int to, PretenureFlag pretenure = NOT_TENURED); 4566 MUST_USE_RESULT MaybeObject* SubString(int from,
4567 int to,
4568 PretenureFlag pretenure = NOT_TENURED);
4511 4569
4512 // String equality operations. 4570 // String equality operations.
4513 inline bool Equals(String* other); 4571 inline bool Equals(String* other);
4514 bool IsEqualTo(Vector<const char> str); 4572 bool IsEqualTo(Vector<const char> str);
4515 4573
4516 // Return a UTF8 representation of the string. The string is null 4574 // Return a UTF8 representation of the string. The string is null
4517 // terminated but may optionally contain nulls. Length is returned 4575 // terminated but may optionally contain nulls. Length is returned
4518 // in length_output if length_output is not a null pointer The string 4576 // in length_output if length_output is not a null pointer The string
4519 // should be nearly flat, otherwise the performance of this method may 4577 // should be nearly flat, otherwise the performance of this method may
4520 // be very slow (quadratic in the length). Setting robustness_flag to 4578 // be very slow (quadratic in the length). Setting robustness_flag to
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
4702 unsigned max_chars); 4760 unsigned max_chars);
4703 static void ReadBlockIntoBuffer(String* input, 4761 static void ReadBlockIntoBuffer(String* input,
4704 ReadBlockBuffer* buffer, 4762 ReadBlockBuffer* buffer,
4705 unsigned* offset_ptr, 4763 unsigned* offset_ptr,
4706 unsigned max_chars); 4764 unsigned max_chars);
4707 4765
4708 private: 4766 private:
4709 // Try to flatten the top level ConsString that is hiding behind this 4767 // Try to flatten the top level ConsString that is hiding behind this
4710 // string. This is a no-op unless the string is a ConsString. Flatten 4768 // string. This is a no-op unless the string is a ConsString. Flatten
4711 // mutates the ConsString and might return a failure. 4769 // mutates the ConsString and might return a failure.
4712 Object* SlowTryFlatten(PretenureFlag pretenure); 4770 MUST_USE_RESULT MaybeObject* SlowTryFlatten(PretenureFlag pretenure);
4713 4771
4714 static inline bool IsHashFieldComputed(uint32_t field); 4772 static inline bool IsHashFieldComputed(uint32_t field);
4715 4773
4716 // Slow case of String::Equals. This implementation works on any strings 4774 // Slow case of String::Equals. This implementation works on any strings
4717 // but it is most efficient on strings that are almost flat. 4775 // but it is most efficient on strings that are almost flat.
4718 bool SlowEquals(String* other); 4776 bool SlowEquals(String* other);
4719 4777
4720 // Slow case of AsArrayIndex. 4778 // Slow case of AsArrayIndex.
4721 bool SlowAsArrayIndex(uint32_t* index); 4779 bool SlowAsArrayIndex(uint32_t* index);
4722 4780
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
5094 5152
5095 // Casting. 5153 // Casting.
5096 static inline Oddball* cast(Object* obj); 5154 static inline Oddball* cast(Object* obj);
5097 5155
5098 // Dispatched behavior. 5156 // Dispatched behavior.
5099 #ifdef DEBUG 5157 #ifdef DEBUG
5100 void OddballVerify(); 5158 void OddballVerify();
5101 #endif 5159 #endif
5102 5160
5103 // Initialize the fields. 5161 // Initialize the fields.
5104 Object* Initialize(const char* to_string, Object* to_number); 5162 MUST_USE_RESULT MaybeObject* Initialize(const char* to_string,
5163 Object* to_number);
5105 5164
5106 // Layout description. 5165 // Layout description.
5107 static const int kToStringOffset = HeapObject::kHeaderSize; 5166 static const int kToStringOffset = HeapObject::kHeaderSize;
5108 static const int kToNumberOffset = kToStringOffset + kPointerSize; 5167 static const int kToNumberOffset = kToStringOffset + kPointerSize;
5109 static const int kSize = kToNumberOffset + kPointerSize; 5168 static const int kSize = kToNumberOffset + kPointerSize;
5110 5169
5111 typedef FixedBodyDescriptor<kToStringOffset, 5170 typedef FixedBodyDescriptor<kToStringOffset,
5112 kToNumberOffset + kPointerSize, 5171 kToNumberOffset + kPointerSize,
5113 kSize> BodyDescriptor; 5172 kSize> BodyDescriptor;
5114 5173
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
5186 // - slow, backing storage is a HashTable with numbers as keys. 5245 // - slow, backing storage is a HashTable with numbers as keys.
5187 class JSArray: public JSObject { 5246 class JSArray: public JSObject {
5188 public: 5247 public:
5189 // [length]: The length property. 5248 // [length]: The length property.
5190 DECL_ACCESSORS(length, Object) 5249 DECL_ACCESSORS(length, Object)
5191 5250
5192 // Overload the length setter to skip write barrier when the length 5251 // Overload the length setter to skip write barrier when the length
5193 // is set to a smi. This matches the set function on FixedArray. 5252 // is set to a smi. This matches the set function on FixedArray.
5194 inline void set_length(Smi* length); 5253 inline void set_length(Smi* length);
5195 5254
5196 MUST_USE_RESULT Object* JSArrayUpdateLengthFromIndex(uint32_t index, 5255 MUST_USE_RESULT MaybeObject* JSArrayUpdateLengthFromIndex(uint32_t index,
5197 Object* value); 5256 Object* value);
5198 5257
5199 // Initialize the array with the given capacity. The function may 5258 // Initialize the array with the given capacity. The function may
5200 // fail due to out-of-memory situations, but only if the requested 5259 // fail due to out-of-memory situations, but only if the requested
5201 // capacity is non-zero. 5260 // capacity is non-zero.
5202 MUST_USE_RESULT Object* Initialize(int capacity); 5261 MUST_USE_RESULT MaybeObject* Initialize(int capacity);
5203 5262
5204 // Set the content of the array to the content of storage. 5263 // Set the content of the array to the content of storage.
5205 inline void SetContent(FixedArray* storage); 5264 inline void SetContent(FixedArray* storage);
5206 5265
5207 // Casting. 5266 // Casting.
5208 static inline JSArray* cast(Object* obj); 5267 static inline JSArray* cast(Object* obj);
5209 5268
5210 // Uses handles. Ensures that the fixed array backing the JSArray has at 5269 // Uses handles. Ensures that the fixed array backing the JSArray has at
5211 // least the stated size. 5270 // least the stated size.
5212 inline void EnsureSize(int minimum_size_of_backing_fixed_array); 5271 inline void EnsureSize(int minimum_size_of_backing_fixed_array);
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
5714 } else { 5773 } else {
5715 value &= ~(1 << bit_position); 5774 value &= ~(1 << bit_position);
5716 } 5775 }
5717 return value; 5776 return value;
5718 } 5777 }
5719 }; 5778 };
5720 5779
5721 } } // namespace v8::internal 5780 } } // namespace v8::internal
5722 5781
5723 #endif // V8_OBJECTS_H_ 5782 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698