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

Side by Side Diff: src/objects.h

Issue 6903060: Version 3.3.2.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: '' Created 9 years, 8 months 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/mirror-debugger.js ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 HEAP_NUMBER_TYPE, 516 HEAP_NUMBER_TYPE,
517 PROXY_TYPE, 517 PROXY_TYPE,
518 BYTE_ARRAY_TYPE, 518 BYTE_ARRAY_TYPE,
519 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE 519 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE
520 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, 520 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE,
521 EXTERNAL_SHORT_ARRAY_TYPE, 521 EXTERNAL_SHORT_ARRAY_TYPE,
522 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, 522 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE,
523 EXTERNAL_INT_ARRAY_TYPE, 523 EXTERNAL_INT_ARRAY_TYPE,
524 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, 524 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE,
525 EXTERNAL_FLOAT_ARRAY_TYPE, 525 EXTERNAL_FLOAT_ARRAY_TYPE,
526 EXTERNAL_DOUBLE_ARRAY_TYPE,
526 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 527 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
527 FILLER_TYPE, // LAST_DATA_TYPE 528 FILLER_TYPE, // LAST_DATA_TYPE
528 529
529 // Structs. 530 // Structs.
530 ACCESSOR_INFO_TYPE, 531 ACCESSOR_INFO_TYPE,
531 ACCESS_CHECK_INFO_TYPE, 532 ACCESS_CHECK_INFO_TYPE,
532 INTERCEPTOR_INFO_TYPE, 533 INTERCEPTOR_INFO_TYPE,
533 CALL_HANDLER_INFO_TYPE, 534 CALL_HANDLER_INFO_TYPE,
534 FUNCTION_TEMPLATE_INFO_TYPE, 535 FUNCTION_TEMPLATE_INFO_TYPE,
535 OBJECT_TEMPLATE_INFO_TYPE, 536 OBJECT_TEMPLATE_INFO_TYPE,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 642 }
642 inline Object* ToObjectUnchecked() { 643 inline Object* ToObjectUnchecked() {
643 ASSERT(!IsFailure()); 644 ASSERT(!IsFailure());
644 return reinterpret_cast<Object*>(this); 645 return reinterpret_cast<Object*>(this);
645 } 646 }
646 inline Object* ToObjectChecked() { 647 inline Object* ToObjectChecked() {
647 CHECK(!IsFailure()); 648 CHECK(!IsFailure());
648 return reinterpret_cast<Object*>(this); 649 return reinterpret_cast<Object*>(this);
649 } 650 }
650 651
652 template<typename T>
653 inline bool To(T** obj) {
654 if (IsFailure()) return false;
655 *obj = T::cast(reinterpret_cast<Object*>(this));
656 return true;
657 }
658
651 #ifdef OBJECT_PRINT 659 #ifdef OBJECT_PRINT
652 // Prints this object with details. 660 // Prints this object with details.
653 inline void Print() { 661 inline void Print() {
654 Print(stdout); 662 Print(stdout);
655 }; 663 };
656 inline void PrintLn() { 664 inline void PrintLn() {
657 PrintLn(stdout); 665 PrintLn(stdout);
658 } 666 }
659 void Print(FILE* out); 667 void Print(FILE* out);
660 void PrintLn(FILE* out); 668 void PrintLn(FILE* out);
(...skipping 23 matching lines...) Expand all
684 V(SeqAsciiString) \ 692 V(SeqAsciiString) \
685 \ 693 \
686 V(ExternalArray) \ 694 V(ExternalArray) \
687 V(ExternalByteArray) \ 695 V(ExternalByteArray) \
688 V(ExternalUnsignedByteArray) \ 696 V(ExternalUnsignedByteArray) \
689 V(ExternalShortArray) \ 697 V(ExternalShortArray) \
690 V(ExternalUnsignedShortArray) \ 698 V(ExternalUnsignedShortArray) \
691 V(ExternalIntArray) \ 699 V(ExternalIntArray) \
692 V(ExternalUnsignedIntArray) \ 700 V(ExternalUnsignedIntArray) \
693 V(ExternalFloatArray) \ 701 V(ExternalFloatArray) \
702 V(ExternalDoubleArray) \
694 V(ExternalPixelArray) \ 703 V(ExternalPixelArray) \
695 V(ByteArray) \ 704 V(ByteArray) \
696 V(JSObject) \ 705 V(JSObject) \
697 V(JSContextExtensionObject) \ 706 V(JSContextExtensionObject) \
698 V(Map) \ 707 V(Map) \
699 V(DescriptorArray) \ 708 V(DescriptorArray) \
700 V(DeoptimizationInputData) \ 709 V(DeoptimizationInputData) \
701 V(DeoptimizationOutputData) \ 710 V(DeoptimizationOutputData) \
702 V(FixedArray) \ 711 V(FixedArray) \
703 V(Context) \ 712 V(Context) \
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 FAST_ELEMENTS, 1338 FAST_ELEMENTS,
1330 // All the kinds below are "slow". 1339 // All the kinds below are "slow".
1331 DICTIONARY_ELEMENTS, 1340 DICTIONARY_ELEMENTS,
1332 EXTERNAL_BYTE_ELEMENTS, 1341 EXTERNAL_BYTE_ELEMENTS,
1333 EXTERNAL_UNSIGNED_BYTE_ELEMENTS, 1342 EXTERNAL_UNSIGNED_BYTE_ELEMENTS,
1334 EXTERNAL_SHORT_ELEMENTS, 1343 EXTERNAL_SHORT_ELEMENTS,
1335 EXTERNAL_UNSIGNED_SHORT_ELEMENTS, 1344 EXTERNAL_UNSIGNED_SHORT_ELEMENTS,
1336 EXTERNAL_INT_ELEMENTS, 1345 EXTERNAL_INT_ELEMENTS,
1337 EXTERNAL_UNSIGNED_INT_ELEMENTS, 1346 EXTERNAL_UNSIGNED_INT_ELEMENTS,
1338 EXTERNAL_FLOAT_ELEMENTS, 1347 EXTERNAL_FLOAT_ELEMENTS,
1348 EXTERNAL_DOUBLE_ELEMENTS,
1339 EXTERNAL_PIXEL_ELEMENTS 1349 EXTERNAL_PIXEL_ELEMENTS
1340 }; 1350 };
1341 1351
1342 // [properties]: Backing storage for properties. 1352 // [properties]: Backing storage for properties.
1343 // properties is a FixedArray in the fast case and a Dictionary in the 1353 // properties is a FixedArray in the fast case and a Dictionary in the
1344 // slow case. 1354 // slow case.
1345 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties. 1355 DECL_ACCESSORS(properties, FixedArray) // Get and set fast properties.
1346 inline void initialize_properties(); 1356 inline void initialize_properties();
1347 inline bool HasFastProperties(); 1357 inline bool HasFastProperties();
1348 inline StringDictionary* property_dictionary(); // Gets slow properties. 1358 inline StringDictionary* property_dictionary(); // Gets slow properties.
(...skipping 21 matching lines...) Expand all
1370 inline bool HasDictionaryElements(); 1380 inline bool HasDictionaryElements();
1371 inline bool HasExternalPixelElements(); 1381 inline bool HasExternalPixelElements();
1372 inline bool HasExternalArrayElements(); 1382 inline bool HasExternalArrayElements();
1373 inline bool HasExternalByteElements(); 1383 inline bool HasExternalByteElements();
1374 inline bool HasExternalUnsignedByteElements(); 1384 inline bool HasExternalUnsignedByteElements();
1375 inline bool HasExternalShortElements(); 1385 inline bool HasExternalShortElements();
1376 inline bool HasExternalUnsignedShortElements(); 1386 inline bool HasExternalUnsignedShortElements();
1377 inline bool HasExternalIntElements(); 1387 inline bool HasExternalIntElements();
1378 inline bool HasExternalUnsignedIntElements(); 1388 inline bool HasExternalUnsignedIntElements();
1379 inline bool HasExternalFloatElements(); 1389 inline bool HasExternalFloatElements();
1390 inline bool HasExternalDoubleElements();
1380 inline bool AllowsSetElementsLength(); 1391 inline bool AllowsSetElementsLength();
1381 inline NumberDictionary* element_dictionary(); // Gets slow elements. 1392 inline NumberDictionary* element_dictionary(); // Gets slow elements.
1382 // Requires: this->HasFastElements(). 1393 // Requires: this->HasFastElements().
1383 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements(); 1394 MUST_USE_RESULT inline MaybeObject* EnsureWritableFastElements();
1384 1395
1385 // Collects elements starting at index 0. 1396 // Collects elements starting at index 0.
1386 // Undefined values are placed after non-undefined values. 1397 // Undefined values are placed after non-undefined values.
1387 // Returns the number of non-undefined values. 1398 // Returns the number of non-undefined values.
1388 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit); 1399 MUST_USE_RESULT MaybeObject* PrepareElementsForSort(uint32_t limit);
1389 // As PrepareElementsForSort, but only on objects where elements is 1400 // As PrepareElementsForSort, but only on objects where elements is
(...skipping 1696 matching lines...) Expand 10 before | Expand all | Expand 10 after
3086 #endif 3097 #endif
3087 #ifdef DEBUG 3098 #ifdef DEBUG
3088 void ExternalFloatArrayVerify(); 3099 void ExternalFloatArrayVerify();
3089 #endif // DEBUG 3100 #endif // DEBUG
3090 3101
3091 private: 3102 private:
3092 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray); 3103 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalFloatArray);
3093 }; 3104 };
3094 3105
3095 3106
3107 class ExternalDoubleArray: public ExternalArray {
3108 public:
3109 // Setter and getter.
3110 inline double get(int index);
3111 inline void set(int index, double value);
3112
3113 // This accessor applies the correct conversion from Smi, HeapNumber
3114 // and undefined.
3115 MaybeObject* SetValue(uint32_t index, Object* value);
3116
3117 // Casting.
3118 static inline ExternalDoubleArray* cast(Object* obj);
3119
3120 #ifdef OBJECT_PRINT
3121 inline void ExternalDoubleArrayPrint() {
3122 ExternalDoubleArrayPrint(stdout);
3123 }
3124 void ExternalDoubleArrayPrint(FILE* out);
3125 #endif // OBJECT_PRINT
3126 #ifdef DEBUG
3127 void ExternalDoubleArrayVerify();
3128 #endif // DEBUG
3129
3130 private:
3131 DISALLOW_IMPLICIT_CONSTRUCTORS(ExternalDoubleArray);
3132 };
3133
3134
3096 // DeoptimizationInputData is a fixed array used to hold the deoptimization 3135 // DeoptimizationInputData is a fixed array used to hold the deoptimization
3097 // data for code generated by the Hydrogen/Lithium compiler. It also 3136 // data for code generated by the Hydrogen/Lithium compiler. It also
3098 // contains information about functions that were inlined. If N different 3137 // contains information about functions that were inlined. If N different
3099 // functions were inlined then first N elements of the literal array will 3138 // functions were inlined then first N elements of the literal array will
3100 // contain these functions. 3139 // contain these functions.
3101 // 3140 //
3102 // It can be empty. 3141 // It can be empty.
3103 class DeoptimizationInputData: public FixedArray { 3142 class DeoptimizationInputData: public FixedArray {
3104 public: 3143 public:
3105 // Layout description. Indices in the array. 3144 // Layout description. Indices in the array.
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after
3705 DECL_ACCESSORS(constructor, Object) 3744 DECL_ACCESSORS(constructor, Object)
3706 3745
3707 inline JSFunction* unchecked_constructor(); 3746 inline JSFunction* unchecked_constructor();
3708 3747
3709 // [instance descriptors]: describes the object. 3748 // [instance descriptors]: describes the object.
3710 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 3749 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
3711 3750
3712 // [stub cache]: contains stubs compiled for this map. 3751 // [stub cache]: contains stubs compiled for this map.
3713 DECL_ACCESSORS(code_cache, Object) 3752 DECL_ACCESSORS(code_cache, Object)
3714 3753
3754 // [prototype transitions]: cache of prototype transitions.
3755 // Prototype transition is a transition that happens
3756 // when we change object's prototype to a new one.
3757 // Cache format:
3758 // 0: finger - index of the first free cell in the cache
3759 // 1 + 2 * i: prototype
3760 // 2 + 2 * i: target map
3761 DECL_ACCESSORS(prototype_transitions, FixedArray)
3762 inline FixedArray* unchecked_prototype_transitions();
3763
3715 // Lookup in the map's instance descriptors and fill out the result 3764 // Lookup in the map's instance descriptors and fill out the result
3716 // with the given holder if the name is found. The holder may be 3765 // with the given holder if the name is found. The holder may be
3717 // NULL when this function is used from the compiler. 3766 // NULL when this function is used from the compiler.
3718 void LookupInDescriptors(JSObject* holder, 3767 void LookupInDescriptors(JSObject* holder,
3719 String* name, 3768 String* name,
3720 LookupResult* result); 3769 LookupResult* result);
3721 3770
3722 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 3771 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
3723 3772
3724 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode, 3773 MUST_USE_RESULT MaybeObject* CopyNormalized(PropertyNormalizationMode mode,
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
3804 inline void set_visitor_id(int visitor_id); 3853 inline void set_visitor_id(int visitor_id);
3805 3854
3806 // Returns the isolate/heap this map belongs to. 3855 // Returns the isolate/heap this map belongs to.
3807 inline Isolate* isolate(); 3856 inline Isolate* isolate();
3808 inline Heap* heap(); 3857 inline Heap* heap();
3809 3858
3810 typedef void (*TraverseCallback)(Map* map, void* data); 3859 typedef void (*TraverseCallback)(Map* map, void* data);
3811 3860
3812 void TraverseTransitionTree(TraverseCallback callback, void* data); 3861 void TraverseTransitionTree(TraverseCallback callback, void* data);
3813 3862
3863 static const int kMaxCachedPrototypeTransitions = 256;
3864
3865 Object* GetPrototypeTransition(Object* prototype);
3866
3867 MaybeObject* PutPrototypeTransition(Object* prototype, Map* map);
3868
3814 static const int kMaxPreAllocatedPropertyFields = 255; 3869 static const int kMaxPreAllocatedPropertyFields = 255;
3815 3870
3816 // Layout description. 3871 // Layout description.
3817 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 3872 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
3818 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 3873 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
3819 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; 3874 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize;
3820 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; 3875 static const int kConstructorOffset = kPrototypeOffset + kPointerSize;
3821 static const int kInstanceDescriptorsOffset = 3876 static const int kInstanceDescriptorsOffset =
3822 kConstructorOffset + kPointerSize; 3877 kConstructorOffset + kPointerSize;
3823 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; 3878 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize;
3824 static const int kPadStart = kCodeCacheOffset + kPointerSize; 3879 static const int kPrototypeTransitionsOffset =
3880 kCodeCacheOffset + kPointerSize;
3881 static const int kPadStart = kPrototypeTransitionsOffset + kPointerSize;
3825 static const int kSize = MAP_POINTER_ALIGN(kPadStart); 3882 static const int kSize = MAP_POINTER_ALIGN(kPadStart);
3826 3883
3827 // Layout of pointer fields. Heap iteration code relies on them 3884 // Layout of pointer fields. Heap iteration code relies on them
3828 // being continiously allocated. 3885 // being continiously allocated.
3829 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset; 3886 static const int kPointerFieldsBeginOffset = Map::kPrototypeOffset;
3830 static const int kPointerFieldsEndOffset = 3887 static const int kPointerFieldsEndOffset =
3831 Map::kCodeCacheOffset + kPointerSize; 3888 Map::kPrototypeTransitionsOffset + kPointerSize;
3832 3889
3833 // Byte offsets within kInstanceSizesOffset. 3890 // Byte offsets within kInstanceSizesOffset.
3834 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; 3891 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0;
3835 static const int kInObjectPropertiesByte = 1; 3892 static const int kInObjectPropertiesByte = 1;
3836 static const int kInObjectPropertiesOffset = 3893 static const int kInObjectPropertiesOffset =
3837 kInstanceSizesOffset + kInObjectPropertiesByte; 3894 kInstanceSizesOffset + kInObjectPropertiesByte;
3838 static const int kPreAllocatedPropertyFieldsByte = 2; 3895 static const int kPreAllocatedPropertyFieldsByte = 2;
3839 static const int kPreAllocatedPropertyFieldsOffset = 3896 static const int kPreAllocatedPropertyFieldsOffset =
3840 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; 3897 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte;
3841 static const int kVisitorIdByte = 3; 3898 static const int kVisitorIdByte = 3;
(...skipping 2806 matching lines...) Expand 10 before | Expand all | Expand 10 after
6648 } else { 6705 } else {
6649 value &= ~(1 << bit_position); 6706 value &= ~(1 << bit_position);
6650 } 6707 }
6651 return value; 6708 return value;
6652 } 6709 }
6653 }; 6710 };
6654 6711
6655 } } // namespace v8::internal 6712 } } // namespace v8::internal
6656 6713
6657 #endif // V8_OBJECTS_H_ 6714 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/mirror-debugger.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698