OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 V(EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \ | 341 V(EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \ |
342 V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ | 342 V(EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ |
343 V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \ | 343 V(SHORT_EXTERNAL_INTERNALIZED_STRING_TYPE) \ |
344 V(SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \ | 344 V(SHORT_EXTERNAL_ASCII_INTERNALIZED_STRING_TYPE) \ |
345 V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ | 345 V(SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE) \ |
346 \ | 346 \ |
347 V(SYMBOL_TYPE) \ | 347 V(SYMBOL_TYPE) \ |
348 V(MAP_TYPE) \ | 348 V(MAP_TYPE) \ |
349 V(CODE_TYPE) \ | 349 V(CODE_TYPE) \ |
350 V(ODDBALL_TYPE) \ | 350 V(ODDBALL_TYPE) \ |
351 V(CELL_TYPE) \ | |
Michael Starzinger
2013/06/12 13:23:25
Can we add the "Cell" type to the type hierarchy A
danno
2013/06/12 14:24:28
Done.
| |
351 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 352 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
352 V(BOX_TYPE) \ | 353 V(BOX_TYPE) \ |
353 \ | 354 \ |
354 V(HEAP_NUMBER_TYPE) \ | 355 V(HEAP_NUMBER_TYPE) \ |
355 V(FOREIGN_TYPE) \ | 356 V(FOREIGN_TYPE) \ |
356 V(BYTE_ARRAY_TYPE) \ | 357 V(BYTE_ARRAY_TYPE) \ |
357 V(FREE_SPACE_TYPE) \ | 358 V(FREE_SPACE_TYPE) \ |
358 /* Note: the order of these external array */ \ | 359 /* Note: the order of these external array */ \ |
359 /* types is relied upon in */ \ | 360 /* types is relied upon in */ \ |
360 /* Object::IsExternalArray(). */ \ | 361 /* Object::IsExternalArray(). */ \ |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
662 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = | 663 SHORT_EXTERNAL_INTERNALIZED_STRING_WITH_ONE_BYTE_DATA_TYPE = |
663 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kInternalizedTag, | 664 SHORT_EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE | kInternalizedTag, |
664 | 665 |
665 // Non-string names | 666 // Non-string names |
666 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE | 667 SYMBOL_TYPE = kNotStringTag, // LAST_NAME_TYPE, FIRST_NONSTRING_TYPE |
667 | 668 |
668 // Objects allocated in their own spaces (never in new space). | 669 // Objects allocated in their own spaces (never in new space). |
669 MAP_TYPE, | 670 MAP_TYPE, |
670 CODE_TYPE, | 671 CODE_TYPE, |
671 ODDBALL_TYPE, | 672 ODDBALL_TYPE, |
673 CELL_TYPE, | |
672 JS_GLOBAL_PROPERTY_CELL_TYPE, | 674 JS_GLOBAL_PROPERTY_CELL_TYPE, |
673 BOX_TYPE, | 675 BOX_TYPE, |
674 | 676 |
675 // "Data", objects that cannot contain non-map-word pointers to heap | 677 // "Data", objects that cannot contain non-map-word pointers to heap |
676 // objects. | 678 // objects. |
677 HEAP_NUMBER_TYPE, | 679 HEAP_NUMBER_TYPE, |
678 FOREIGN_TYPE, | 680 FOREIGN_TYPE, |
679 BYTE_ARRAY_TYPE, | 681 BYTE_ARRAY_TYPE, |
680 FREE_SPACE_TYPE, | 682 FREE_SPACE_TYPE, |
681 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 683 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
834 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 836 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
835 | 837 |
836 | 838 |
837 class AccessorPair; | 839 class AccessorPair; |
838 class DictionaryElementsAccessor; | 840 class DictionaryElementsAccessor; |
839 class ElementsAccessor; | 841 class ElementsAccessor; |
840 class Failure; | 842 class Failure; |
841 class FixedArrayBase; | 843 class FixedArrayBase; |
842 class ObjectVisitor; | 844 class ObjectVisitor; |
843 class StringStream; | 845 class StringStream; |
846 class Type; | |
844 | 847 |
845 struct ValueInfo : public Malloced { | 848 struct ValueInfo : public Malloced { |
846 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 849 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
847 InstanceType type; | 850 InstanceType type; |
848 Object* ptr; | 851 Object* ptr; |
849 const char* str; | 852 const char* str; |
850 double number; | 853 double number; |
851 }; | 854 }; |
852 | 855 |
853 | 856 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1004 V(CodeCacheHashTable) \ | 1007 V(CodeCacheHashTable) \ |
1005 V(PolymorphicCodeCacheHashTable) \ | 1008 V(PolymorphicCodeCacheHashTable) \ |
1006 V(MapCache) \ | 1009 V(MapCache) \ |
1007 V(Primitive) \ | 1010 V(Primitive) \ |
1008 V(GlobalObject) \ | 1011 V(GlobalObject) \ |
1009 V(JSGlobalObject) \ | 1012 V(JSGlobalObject) \ |
1010 V(JSBuiltinsObject) \ | 1013 V(JSBuiltinsObject) \ |
1011 V(JSGlobalProxy) \ | 1014 V(JSGlobalProxy) \ |
1012 V(UndetectableObject) \ | 1015 V(UndetectableObject) \ |
1013 V(AccessCheckNeeded) \ | 1016 V(AccessCheckNeeded) \ |
1017 V(Cell) \ | |
1014 V(JSGlobalPropertyCell) \ | 1018 V(JSGlobalPropertyCell) \ |
1015 V(ObjectHashTable) \ | 1019 V(ObjectHashTable) \ |
1016 | 1020 |
1017 | 1021 |
1018 // Object is the abstract superclass for all classes in the | 1022 // Object is the abstract superclass for all classes in the |
1019 // object hierarchy. | 1023 // object hierarchy. |
1020 // Object does not use any virtual functions to avoid the | 1024 // Object does not use any virtual functions to avoid the |
1021 // allocation of the C++ vtable. | 1025 // allocation of the C++ vtable. |
1022 // Since Smi and Failure are subclasses of Object no | 1026 // Since Smi and Failure are subclasses of Object no |
1023 // data members can be present in Object. | 1027 // data members can be present in Object. |
(...skipping 3347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4371 // Casting. | 4375 // Casting. |
4372 static inline DeoptimizationOutputData* cast(Object* obj); | 4376 static inline DeoptimizationOutputData* cast(Object* obj); |
4373 | 4377 |
4374 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) | 4378 #if defined(OBJECT_PRINT) || defined(ENABLE_DISASSEMBLER) |
4375 void DeoptimizationOutputDataPrint(FILE* out); | 4379 void DeoptimizationOutputDataPrint(FILE* out); |
4376 #endif | 4380 #endif |
4377 }; | 4381 }; |
4378 | 4382 |
4379 | 4383 |
4380 // Forward declaration. | 4384 // Forward declaration. |
4385 class Cell; | |
4381 class JSGlobalPropertyCell; | 4386 class JSGlobalPropertyCell; |
4382 | 4387 |
4383 // TypeFeedbackCells is a fixed array used to hold the association between | 4388 // TypeFeedbackCells is a fixed array used to hold the association between |
4384 // cache cells and AST ids for code generated by the full compiler. | 4389 // cache cells and AST ids for code generated by the full compiler. |
4385 // The format of the these objects is | 4390 // The format of the these objects is |
4386 // [i * 2]: Global property cell of ith cache cell. | 4391 // [i * 2]: Global property cell of ith cache cell. |
4387 // [i * 2 + 1]: Ast ID for ith cache cell. | 4392 // [i * 2 + 1]: Ast ID for ith cache cell. |
4388 class TypeFeedbackCells: public FixedArray { | 4393 class TypeFeedbackCells: public FixedArray { |
4389 public: | 4394 public: |
4390 int CellCount() { return length() / 2; } | 4395 int CellCount() { return length() / 2; } |
4391 static int LengthOfFixedArray(int cell_count) { return cell_count * 2; } | 4396 static int LengthOfFixedArray(int cell_count) { return cell_count * 2; } |
4392 | 4397 |
4393 // Accessors for AST ids associated with cache values. | 4398 // Accessors for AST ids associated with cache values. |
4394 inline TypeFeedbackId AstId(int index); | 4399 inline TypeFeedbackId AstId(int index); |
4395 inline void SetAstId(int index, TypeFeedbackId id); | 4400 inline void SetAstId(int index, TypeFeedbackId id); |
4396 | 4401 |
4397 // Accessors for global property cells holding the cache values. | 4402 // Accessors for global property cells holding the cache values. |
4398 inline JSGlobalPropertyCell* Cell(int index); | 4403 inline Cell* GetCell(int index); |
4399 inline void SetCell(int index, JSGlobalPropertyCell* cell); | 4404 inline void SetCell(int index, Cell* cell); |
4400 | 4405 |
4401 // The object that indicates an uninitialized cache. | 4406 // The object that indicates an uninitialized cache. |
4402 static inline Handle<Object> UninitializedSentinel(Isolate* isolate); | 4407 static inline Handle<Object> UninitializedSentinel(Isolate* isolate); |
4403 | 4408 |
4404 // The object that indicates a megamorphic state. | 4409 // The object that indicates a megamorphic state. |
4405 static inline Handle<Object> MegamorphicSentinel(Isolate* isolate); | 4410 static inline Handle<Object> MegamorphicSentinel(Isolate* isolate); |
4406 | 4411 |
4407 // The object that indicates a monomorphic state of Array with | 4412 // The object that indicates a monomorphic state of Array with |
4408 // ElementsKind | 4413 // ElementsKind |
4409 static inline Handle<Object> MonomorphicArraySentinel(Isolate* isolate, | 4414 static inline Handle<Object> MonomorphicArraySentinel(Isolate* isolate, |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5396 | 5401 |
5397 int NumberOfOwnDescriptors() { | 5402 int NumberOfOwnDescriptors() { |
5398 return NumberOfOwnDescriptorsBits::decode(bit_field3()); | 5403 return NumberOfOwnDescriptorsBits::decode(bit_field3()); |
5399 } | 5404 } |
5400 | 5405 |
5401 void SetNumberOfOwnDescriptors(int number) { | 5406 void SetNumberOfOwnDescriptors(int number) { |
5402 ASSERT(number <= instance_descriptors()->number_of_descriptors()); | 5407 ASSERT(number <= instance_descriptors()->number_of_descriptors()); |
5403 set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number)); | 5408 set_bit_field3(NumberOfOwnDescriptorsBits::update(bit_field3(), number)); |
5404 } | 5409 } |
5405 | 5410 |
5406 inline JSGlobalPropertyCell* RetrieveDescriptorsPointer(); | 5411 inline Cell* RetrieveDescriptorsPointer(); |
5407 | 5412 |
5408 int EnumLength() { | 5413 int EnumLength() { |
5409 return EnumLengthBits::decode(bit_field3()); | 5414 return EnumLengthBits::decode(bit_field3()); |
5410 } | 5415 } |
5411 | 5416 |
5412 void SetEnumLength(int length) { | 5417 void SetEnumLength(int length) { |
5413 if (length != kInvalidEnumCache) { | 5418 if (length != kInvalidEnumCache) { |
5414 ASSERT(length >= 0); | 5419 ASSERT(length >= 0); |
5415 ASSERT(length == 0 || instance_descriptors()->HasEnumCache()); | 5420 ASSERT(length == 0 || instance_descriptors()->HasEnumCache()); |
5416 ASSERT(length <= NumberOfOwnDescriptors()); | 5421 ASSERT(length <= NumberOfOwnDescriptors()); |
(...skipping 3133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8550 | 8555 |
8551 STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset); | 8556 STATIC_CHECK(kKindOffset == Internals::kOddballKindOffset); |
8552 STATIC_CHECK(kNull == Internals::kNullOddballKind); | 8557 STATIC_CHECK(kNull == Internals::kNullOddballKind); |
8553 STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind); | 8558 STATIC_CHECK(kUndefined == Internals::kUndefinedOddballKind); |
8554 | 8559 |
8555 private: | 8560 private: |
8556 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); | 8561 DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball); |
8557 }; | 8562 }; |
8558 | 8563 |
8559 | 8564 |
8560 class JSGlobalPropertyCell: public HeapObject { | 8565 class Cell: public HeapObject { |
8561 public: | 8566 public: |
8562 // [value]: value of the global property. | |
Michael Starzinger
2013/06/12 13:23:25
I actually like the comment lines and sometimes gr
danno
2013/06/12 14:24:28
Done.
| |
8563 DECL_ACCESSORS(value, Object) | 8567 DECL_ACCESSORS(value, Object) |
8564 | 8568 |
8565 // Casting. | 8569 // Casting. |
8566 static inline JSGlobalPropertyCell* cast(Object* obj); | 8570 static inline Cell* cast(Object* obj); |
8567 | 8571 |
8568 static inline JSGlobalPropertyCell* FromValueAddress(Address value) { | 8572 static inline Cell* FromValueAddress(Address value) { |
8569 return cast(FromAddress(value - kValueOffset)); | 8573 Object* result = FromAddress(value - kValueOffset); |
8574 ASSERT(result->IsCell() || result->IsJSGlobalPropertyCell()); | |
8575 return static_cast<Cell*>(result); | |
8570 } | 8576 } |
8571 | 8577 |
8572 inline Address ValueAddress() { | 8578 inline Address ValueAddress() { |
8573 return address() + kValueOffset; | 8579 return address() + kValueOffset; |
8574 } | 8580 } |
8575 | 8581 |
8576 // Dispatched behavior. | 8582 // Dispatched behavior. |
8577 DECLARE_PRINTER(JSGlobalPropertyCell) | 8583 DECLARE_PRINTER(Cell) |
8578 DECLARE_VERIFIER(JSGlobalPropertyCell) | 8584 DECLARE_VERIFIER(Cell) |
8579 | 8585 |
8580 // Layout description. | 8586 // Layout description. |
8581 static const int kValueOffset = HeapObject::kHeaderSize; | 8587 static const int kValueOffset = HeapObject::kHeaderSize; |
8582 static const int kSize = kValueOffset + kPointerSize; | 8588 static const int kSize = kValueOffset + kPointerSize; |
8583 | 8589 |
8584 typedef FixedBodyDescriptor<kValueOffset, | 8590 typedef FixedBodyDescriptor<kValueOffset, |
8585 kValueOffset + kPointerSize, | 8591 kValueOffset + kPointerSize, |
8586 kSize> BodyDescriptor; | 8592 kSize> BodyDescriptor; |
8587 | 8593 |
8588 private: | 8594 private: |
8595 DISALLOW_IMPLICIT_CONSTRUCTORS(Cell); | |
8596 }; | |
8597 | |
8598 | |
8599 class JSGlobalPropertyCell: public Cell { | |
8600 public: | |
8601 Type* type(); | |
8602 void set_type(Type* value, WriteBarrierMode mode = UPDATE_WRITE_BARRIER); | |
Michael Starzinger
2013/06/12 13:23:25
Can we use the DECL_ACCESSORS macro to declare thi
danno
2013/06/12 14:24:28
No, unfortunately not. Note that they are not inli
| |
8603 | |
8604 // Casting. | |
8605 static inline JSGlobalPropertyCell* cast(Object* obj); | |
8606 | |
8607 inline Address TypeAddress() { | |
8608 return address() + kTypeOffset; | |
8609 } | |
8610 | |
8611 // Dispatched behavior. | |
8612 DECLARE_PRINTER(JSGlobalPropertyCell) | |
8613 DECLARE_VERIFIER(JSGlobalPropertyCell) | |
8614 | |
8615 // Layout description. | |
8616 static const int kTypeOffset = kValueOffset + kPointerSize; | |
8617 static const int kSize = kTypeOffset + kPointerSize; | |
8618 | |
8619 typedef FixedBodyDescriptor< | |
8620 kValueOffset, | |
Michael Starzinger
2013/06/12 13:23:25
nit: Should fit into three lines if we remove the
danno
2013/06/12 14:24:28
Done.
| |
8621 kTypeOffset + kPointerSize, | |
8622 JSGlobalPropertyCell::kSize> BodyDescriptor; | |
8623 | |
8624 private: | |
8625 DECL_ACCESSORS(type_raw, Object) | |
8589 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); | 8626 DISALLOW_IMPLICIT_CONSTRUCTORS(JSGlobalPropertyCell); |
8590 }; | 8627 }; |
8591 | 8628 |
8592 | 8629 |
8593 // The JSProxy describes EcmaScript Harmony proxies | 8630 // The JSProxy describes EcmaScript Harmony proxies |
8594 class JSProxy: public JSReceiver { | 8631 class JSProxy: public JSReceiver { |
8595 public: | 8632 public: |
8596 // [handler]: The handler property. | 8633 // [handler]: The handler property. |
8597 DECL_ACCESSORS(handler, Object) | 8634 DECL_ACCESSORS(handler, Object) |
8598 | 8635 |
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
9681 } else { | 9718 } else { |
9682 value &= ~(1 << bit_position); | 9719 value &= ~(1 << bit_position); |
9683 } | 9720 } |
9684 return value; | 9721 return value; |
9685 } | 9722 } |
9686 }; | 9723 }; |
9687 | 9724 |
9688 } } // namespace v8::internal | 9725 } } // namespace v8::internal |
9689 | 9726 |
9690 #endif // V8_OBJECTS_H_ | 9727 #endif // V8_OBJECTS_H_ |
OLD | NEW |