Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
| 6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
| 7 | 7 |
| 8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
| 9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
| 10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
| (...skipping 2804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2815 bool is_reflectable() const { | 2815 bool is_reflectable() const { |
| 2816 return ReflectableBit::decode(raw_ptr()->kind_bits_); | 2816 return ReflectableBit::decode(raw_ptr()->kind_bits_); |
| 2817 } | 2817 } |
| 2818 bool is_double_initialized() const { | 2818 bool is_double_initialized() const { |
| 2819 return DoubleInitializedBit::decode(raw_ptr()->kind_bits_); | 2819 return DoubleInitializedBit::decode(raw_ptr()->kind_bits_); |
| 2820 } | 2820 } |
| 2821 void set_is_double_initialized(bool value) const { | 2821 void set_is_double_initialized(bool value) const { |
| 2822 set_kind_bits(DoubleInitializedBit::update(value, raw_ptr()->kind_bits_)); | 2822 set_kind_bits(DoubleInitializedBit::update(value, raw_ptr()->kind_bits_)); |
| 2823 } | 2823 } |
| 2824 | 2824 |
| 2825 inline intptr_t Offset() const; | 2825 inline intptr_t InstanceFieldOffset() const; |
| 2826 inline void SetOffset(intptr_t value_in_bytes) const; | 2826 inline void SetInstanceFieldOffset(intptr_t offset_in_bytes) const; |
| 2827 | 2827 |
| 2828 RawInstance* value() const; | 2828 RawInstance* StaticFieldValue() const; |
|
rmacnak
2015/09/01 16:54:55
FWIW, the service protocol simply calls this "stat
siva
2015/09/03 23:32:09
Acknowledged.
| |
| 2829 void set_value(const Instance& value) const; | 2829 void SetStaticFieldValue(const Instance& value, |
| 2830 bool save_initial_value = false) const; | |
| 2830 | 2831 |
| 2831 RawClass* owner() const; | 2832 RawClass* owner() const; |
| 2832 RawClass* origin() const; // Either mixin class, or same as owner(). | 2833 RawClass* origin() const; // Either mixin class, or same as owner(). |
| 2833 | 2834 |
| 2834 RawAbstractType* type() const { return raw_ptr()->type_; } | 2835 RawAbstractType* type() const { return raw_ptr()->type_; } |
| 2835 void set_type(const AbstractType& value) const; | 2836 void set_type(const AbstractType& value) const; |
| 2836 | 2837 |
| 2837 static intptr_t InstanceSize() { | 2838 static intptr_t InstanceSize() { |
| 2838 return RoundedAllocationSize(sizeof(RawField)); | 2839 return RoundedAllocationSize(sizeof(RawField)); |
| 2839 } | 2840 } |
| 2840 | 2841 |
| 2841 static RawField* New(const String& name, | 2842 static RawField* New(const String& name, |
| 2842 bool is_static, | 2843 bool is_static, |
| 2843 bool is_final, | 2844 bool is_final, |
| 2844 bool is_const, | 2845 bool is_const, |
| 2845 bool is_reflectable, | 2846 bool is_reflectable, |
| 2846 const Class& owner, | 2847 const Class& owner, |
| 2847 intptr_t token_pos); | 2848 intptr_t token_pos); |
| 2848 | 2849 |
| 2849 // Allocate new field object, clone values from this field. The | 2850 // Allocate new field object, clone values from this field. The |
| 2850 // owner of the clone is new_owner. | 2851 // owner of the clone is new_owner. |
| 2851 RawField* Clone(const Class& new_owner) const; | 2852 RawField* Clone(const Class& new_owner) const; |
| 2852 | 2853 |
| 2853 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } | 2854 static intptr_t instance_field_offset() { |
| 2855 return OFFSET_OF(RawField, value_.offset_); | |
| 2856 } | |
| 2857 static intptr_t static_value_offset() { | |
| 2858 return OFFSET_OF(RawField, value_.static_value_); | |
| 2859 } | |
| 2854 | 2860 |
| 2855 static intptr_t kind_bits_offset() { return OFFSET_OF(RawField, kind_bits_); } | 2861 static intptr_t kind_bits_offset() { return OFFSET_OF(RawField, kind_bits_); } |
| 2856 | 2862 |
| 2857 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 2863 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
| 2858 | 2864 |
| 2859 bool has_initializer() const { | 2865 bool has_initializer() const { |
| 2860 return HasInitializerBit::decode(raw_ptr()->kind_bits_); | 2866 return HasInitializerBit::decode(raw_ptr()->kind_bits_); |
| 2861 } | 2867 } |
| 2862 void set_has_initializer(bool has_initializer) const { | 2868 void set_has_initializer(bool has_initializer) const { |
| 2863 set_kind_bits(HasInitializerBit::update(has_initializer, | 2869 set_kind_bits(HasInitializerBit::update(has_initializer, |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2954 // Add the given code object to the list of dependent ones. | 2960 // Add the given code object to the list of dependent ones. |
| 2955 void RegisterDependentCode(const Code& code) const; | 2961 void RegisterDependentCode(const Code& code) const; |
| 2956 | 2962 |
| 2957 // Deoptimize all dependent code objects. | 2963 // Deoptimize all dependent code objects. |
| 2958 void DeoptimizeDependentCode() const; | 2964 void DeoptimizeDependentCode() const; |
| 2959 | 2965 |
| 2960 bool IsUninitialized() const; | 2966 bool IsUninitialized() const; |
| 2961 | 2967 |
| 2962 void EvaluateInitializer() const; | 2968 void EvaluateInitializer() const; |
| 2963 | 2969 |
| 2964 RawFunction* initializer() const { | 2970 RawFunction* PrecompiledInitializer() const { |
| 2965 return raw_ptr()->initializer_; | 2971 return raw_ptr()->initializer_.precompiled_initializer_; |
| 2966 } | 2972 } |
| 2967 void set_initializer(const Function& initializer) const; | 2973 void SetPrecompiledInitializer(const Function& initializer) const; |
| 2974 bool HasPrecompiledInitializer() const; | |
| 2975 | |
| 2976 RawInstance* SavedInitialStaticValue() const { | |
| 2977 return raw_ptr()->initializer_.saved_initial_value_; | |
| 2978 } | |
| 2979 void SetSavedInitialStaticValue(const Instance& value) const; | |
| 2968 | 2980 |
| 2969 // For static fields only. Constructs a closure that gets/sets the | 2981 // For static fields only. Constructs a closure that gets/sets the |
| 2970 // field value. | 2982 // field value. |
| 2971 RawInstance* GetterClosure() const; | 2983 RawInstance* GetterClosure() const; |
| 2972 RawInstance* SetterClosure() const; | 2984 RawInstance* SetterClosure() const; |
| 2973 RawInstance* AccessorClosure(bool make_setter) const; | 2985 RawInstance* AccessorClosure(bool make_setter) const; |
| 2974 | 2986 |
| 2975 // Constructs getter and setter names for fields and vice versa. | 2987 // Constructs getter and setter names for fields and vice versa. |
| 2976 static RawString* GetterName(const String& field_name); | 2988 static RawString* GetterName(const String& field_name); |
| 2977 static RawString* GetterSymbol(const String& field_name); | 2989 static RawString* GetterSymbol(const String& field_name); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3029 } | 3041 } |
| 3030 void set_kind_bits(intptr_t value) const { | 3042 void set_kind_bits(intptr_t value) const { |
| 3031 StoreNonPointer(&raw_ptr()->kind_bits_, static_cast<uint8_t>(value)); | 3043 StoreNonPointer(&raw_ptr()->kind_bits_, static_cast<uint8_t>(value)); |
| 3032 } | 3044 } |
| 3033 | 3045 |
| 3034 static RawField* New(); | 3046 static RawField* New(); |
| 3035 | 3047 |
| 3036 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); | 3048 FINAL_HEAP_OBJECT_IMPLEMENTATION(Field, Object); |
| 3037 friend class Class; | 3049 friend class Class; |
| 3038 friend class HeapProfiler; | 3050 friend class HeapProfiler; |
| 3051 friend class RawField; | |
| 3039 }; | 3052 }; |
| 3040 | 3053 |
| 3041 | 3054 |
| 3042 class LiteralToken : public Object { | 3055 class LiteralToken : public Object { |
| 3043 public: | 3056 public: |
| 3044 Token::Kind kind() const { return raw_ptr()->kind_; } | 3057 Token::Kind kind() const { return raw_ptr()->kind_; } |
| 3045 RawString* literal() const { return raw_ptr()->literal_; } | 3058 RawString* literal() const { return raw_ptr()->literal_; } |
| 3046 RawObject* value() const { return raw_ptr()->value_; } | 3059 RawObject* value() const { return raw_ptr()->value_; } |
| 3047 | 3060 |
| 3048 static intptr_t InstanceSize() { | 3061 static intptr_t InstanceSize() { |
| (...skipping 1832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4881 | 4894 |
| 4882 protected: | 4895 protected: |
| 4883 virtual void PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const; | 4896 virtual void PrintSharedInstanceJSON(JSONObject* jsobj, bool ref) const; |
| 4884 | 4897 |
| 4885 private: | 4898 private: |
| 4886 RawObject** FieldAddrAtOffset(intptr_t offset) const { | 4899 RawObject** FieldAddrAtOffset(intptr_t offset) const { |
| 4887 ASSERT(IsValidFieldOffset(offset)); | 4900 ASSERT(IsValidFieldOffset(offset)); |
| 4888 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset); | 4901 return reinterpret_cast<RawObject**>(raw_value() - kHeapObjectTag + offset); |
| 4889 } | 4902 } |
| 4890 RawObject** FieldAddr(const Field& field) const { | 4903 RawObject** FieldAddr(const Field& field) const { |
| 4891 return FieldAddrAtOffset(field.Offset()); | 4904 return FieldAddrAtOffset(field.InstanceFieldOffset()); |
| 4892 } | 4905 } |
| 4893 RawObject** NativeFieldsAddr() const { | 4906 RawObject** NativeFieldsAddr() const { |
| 4894 return FieldAddrAtOffset(sizeof(RawObject)); | 4907 return FieldAddrAtOffset(sizeof(RawObject)); |
| 4895 } | 4908 } |
| 4896 | 4909 |
| 4897 void SetFieldAtOffset(intptr_t offset, const Object& value) const { | 4910 void SetFieldAtOffset(intptr_t offset, const Object& value) const { |
| 4898 StorePointer(FieldAddrAtOffset(offset), value.raw()); | 4911 StorePointer(FieldAddrAtOffset(offset), value.raw()); |
| 4899 } | 4912 } |
| 4900 bool IsValidFieldOffset(intptr_t offset) const; | 4913 bool IsValidFieldOffset(intptr_t offset) const; |
| 4901 | 4914 |
| (...skipping 3039 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7941 Isolate* isolate = Isolate::Current(); | 7954 Isolate* isolate = Isolate::Current(); |
| 7942 Heap* isolate_heap = isolate->heap(); | 7955 Heap* isolate_heap = isolate->heap(); |
| 7943 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); | 7956 Heap* vm_isolate_heap = Dart::vm_isolate()->heap(); |
| 7944 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || | 7957 ASSERT(isolate_heap->Contains(RawObject::ToAddr(raw_)) || |
| 7945 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); | 7958 vm_isolate_heap->Contains(RawObject::ToAddr(raw_))); |
| 7946 } | 7959 } |
| 7947 #endif | 7960 #endif |
| 7948 } | 7961 } |
| 7949 | 7962 |
| 7950 | 7963 |
| 7951 intptr_t Field::Offset() const { | 7964 intptr_t Field::InstanceFieldOffset() const { |
| 7952 ASSERT(!is_static()); // Offset is valid only for instance fields. | 7965 ASSERT(!is_static()); // Valid only for dart instance fields. |
| 7953 intptr_t value = Smi::Value(reinterpret_cast<RawSmi*>(raw_ptr()->value_)); | 7966 intptr_t value = Smi::Value(raw_ptr()->value_.offset_); |
| 7954 return (value * kWordSize); | 7967 return (value * kWordSize); |
| 7955 } | 7968 } |
| 7956 | 7969 |
| 7957 | 7970 |
| 7958 void Field::SetOffset(intptr_t value_in_bytes) const { | 7971 void Field::SetInstanceFieldOffset(intptr_t offset_in_bytes) const { |
| 7959 ASSERT(!is_static()); // SetOffset is valid only for instance fields. | 7972 ASSERT(!is_static()); // Valid only for dart instance fields. |
| 7960 ASSERT(kWordSize != 0); | 7973 ASSERT(kWordSize != 0); |
| 7961 StorePointer(&raw_ptr()->value_, | 7974 StorePointer(&raw_ptr()->value_.offset_, |
| 7962 static_cast<RawInstance*>(Smi::New(value_in_bytes / kWordSize))); | 7975 Smi::New(offset_in_bytes / kWordSize)); |
| 7963 } | 7976 } |
| 7964 | 7977 |
| 7965 | 7978 |
| 7966 void Context::SetAt(intptr_t index, const Object& value) const { | 7979 void Context::SetAt(intptr_t index, const Object& value) const { |
| 7967 StorePointer(ObjectAddr(index), value.raw()); | 7980 StorePointer(ObjectAddr(index), value.raw()); |
| 7968 } | 7981 } |
| 7969 | 7982 |
| 7970 | 7983 |
| 7971 intptr_t Instance::GetNativeField(int index) const { | 7984 intptr_t Instance::GetNativeField(int index) const { |
| 7972 ASSERT(IsValidNativeIndex(index)); | 7985 ASSERT(IsValidNativeIndex(index)); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8051 | 8064 |
| 8052 | 8065 |
| 8053 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, | 8066 RawObject* MegamorphicCache::GetTargetFunction(const Array& array, |
| 8054 intptr_t index) { | 8067 intptr_t index) { |
| 8055 return array.At((index * kEntryLength) + kTargetFunctionIndex); | 8068 return array.At((index * kEntryLength) + kTargetFunctionIndex); |
| 8056 } | 8069 } |
| 8057 | 8070 |
| 8058 } // namespace dart | 8071 } // namespace dart |
| 8059 | 8072 |
| 8060 #endif // VM_OBJECT_H_ | 8073 #endif // VM_OBJECT_H_ |
| OLD | NEW |