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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2999 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3010 | 3010 |
| 3011 | 3011 |
| 3012 void Class::SetFields(const Array& value) const { | 3012 void Class::SetFields(const Array& value) const { |
| 3013 ASSERT(!value.IsNull()); | 3013 ASSERT(!value.IsNull()); |
| 3014 #if defined(DEBUG) | 3014 #if defined(DEBUG) |
| 3015 // Verify that all the fields in the array have this class as owner. | 3015 // Verify that all the fields in the array have this class as owner. |
| 3016 Field& field = Field::Handle(); | 3016 Field& field = Field::Handle(); |
| 3017 intptr_t len = value.Length(); | 3017 intptr_t len = value.Length(); |
| 3018 for (intptr_t i = 0; i < len; i++) { | 3018 for (intptr_t i = 0; i < len; i++) { |
| 3019 field ^= value.At(i); | 3019 field ^= value.At(i); |
| 3020 ASSERT(field.owner() == raw()); | 3020 ASSERT(field.IsOriginal()); |
| 3021 ASSERT(field.Owner() == raw()); | |
| 3021 } | 3022 } |
| 3022 #endif | 3023 #endif |
| 3023 // The value of static fields is already initialized to null. | 3024 // The value of static fields is already initialized to null. |
| 3024 StorePointer(&raw_ptr()->fields_, value.raw()); | 3025 StorePointer(&raw_ptr()->fields_, value.raw()); |
| 3025 } | 3026 } |
| 3026 | 3027 |
| 3027 | 3028 |
| 3028 void Class::AddField(const Field& field) const { | 3029 void Class::AddField(const Field& field) const { |
| 3029 const Array& arr = Array::Handle(fields()); | 3030 const Array& arr = Array::Handle(fields()); |
| 3030 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); | 3031 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); |
| (...skipping 3748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6779 } | 6780 } |
| 6780 } | 6781 } |
| 6781 array.SetAt(0, edge_counters_array); | 6782 array.SetAt(0, edge_counters_array); |
| 6782 set_ic_data_array(array); | 6783 set_ic_data_array(array); |
| 6783 } | 6784 } |
| 6784 | 6785 |
| 6785 | 6786 |
| 6786 void Function::RestoreICDataMap( | 6787 void Function::RestoreICDataMap( |
| 6787 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, | 6788 ZoneGrowableArray<const ICData*>* deopt_id_to_ic_data, |
| 6788 bool clone_ic_data) const { | 6789 bool clone_ic_data) const { |
| 6790 if (FLAG_force_clone_compiler_objects) { | |
| 6791 clone_ic_data = true; | |
| 6792 } | |
| 6789 ASSERT(deopt_id_to_ic_data->is_empty()); | 6793 ASSERT(deopt_id_to_ic_data->is_empty()); |
| 6790 Zone* zone = Thread::Current()->zone(); | 6794 Zone* zone = Thread::Current()->zone(); |
| 6791 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); | 6795 const Array& saved_ic_data = Array::Handle(zone, ic_data_array()); |
| 6792 if (saved_ic_data.IsNull()) { | 6796 if (saved_ic_data.IsNull()) { |
| 6793 // Could happen with deferred loading. | 6797 // Could happen with deferred loading. |
| 6794 return; | 6798 return; |
| 6795 } | 6799 } |
| 6796 const intptr_t saved_length = saved_ic_data.Length(); | 6800 const intptr_t saved_length = saved_ic_data.Length(); |
| 6797 ASSERT(saved_length > 0); | 6801 ASSERT(saved_length > 0); |
| 6798 if (saved_length > 1) { | 6802 if (saved_length > 1) { |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6975 Heap::kOld); | 6979 Heap::kOld); |
| 6976 return reinterpret_cast<RawRedirectionData*>(raw); | 6980 return reinterpret_cast<RawRedirectionData*>(raw); |
| 6977 } | 6981 } |
| 6978 | 6982 |
| 6979 | 6983 |
| 6980 const char* RedirectionData::ToCString() const { | 6984 const char* RedirectionData::ToCString() const { |
| 6981 return "RedirectionData class"; | 6985 return "RedirectionData class"; |
| 6982 } | 6986 } |
| 6983 | 6987 |
| 6984 | 6988 |
| 6989 Field* Field::CloneFromOriginal() const { | |
| 6990 return &Field::ZoneHandle(this->Clone(*this)); | |
| 6991 } | |
| 6992 | |
| 6993 | |
| 6994 RawField* Field::Original() const { | |
| 6995 if (IsNull()) { | |
| 6996 return Field::null(); | |
| 6997 } | |
| 6998 Object& obj = Object::Handle(raw_ptr()->owner_); | |
| 6999 if (obj.IsField()) { | |
| 7000 return Field::RawCast(obj.raw()); | |
| 7001 } else { | |
| 7002 return this->raw(); | |
| 7003 } | |
| 7004 } | |
| 7005 | |
| 7006 | |
| 7007 void Field::SetOriginal(const Field& value) const { | |
| 7008 ASSERT(value.IsOriginal()); | |
| 7009 ASSERT(!value.IsNull()); | |
| 7010 StorePointer(&raw_ptr()->owner_, reinterpret_cast<RawObject*>(value.raw())); | |
| 7011 } | |
| 7012 | |
| 7013 | |
| 6985 RawString* Field::GetterName(const String& field_name) { | 7014 RawString* Field::GetterName(const String& field_name) { |
| 6986 return String::Concat(Symbols::GetterPrefix(), field_name); | 7015 return String::Concat(Symbols::GetterPrefix(), field_name); |
| 6987 } | 7016 } |
| 6988 | 7017 |
| 6989 | 7018 |
| 6990 RawString* Field::GetterSymbol(const String& field_name) { | 7019 RawString* Field::GetterSymbol(const String& field_name) { |
| 6991 return Symbols::FromConcat(Symbols::GetterPrefix(), field_name); | 7020 return Symbols::FromConcat(Symbols::GetterPrefix(), field_name); |
| 6992 } | 7021 } |
| 6993 | 7022 |
| 6994 | 7023 |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7029 } | 7058 } |
| 7030 | 7059 |
| 7031 | 7060 |
| 7032 bool Field::IsSetterName(const String& function_name) { | 7061 bool Field::IsSetterName(const String& function_name) { |
| 7033 return function_name.StartsWith(Symbols::SetterPrefix()); | 7062 return function_name.StartsWith(Symbols::SetterPrefix()); |
| 7034 } | 7063 } |
| 7035 | 7064 |
| 7036 | 7065 |
| 7037 void Field::set_name(const String& value) const { | 7066 void Field::set_name(const String& value) const { |
| 7038 ASSERT(value.IsSymbol()); | 7067 ASSERT(value.IsSymbol()); |
| 7068 ASSERT(IsOriginal()); | |
| 7039 StorePointer(&raw_ptr()->name_, value.raw()); | 7069 StorePointer(&raw_ptr()->name_, value.raw()); |
| 7040 } | 7070 } |
| 7041 | 7071 |
| 7042 | 7072 |
| 7043 RawClass* Field::owner() const { | 7073 RawObject* Field::RawOwner() const { |
| 7044 const Object& obj = Object::Handle(raw_ptr()->owner_); | 7074 const Field& field = Field::Handle(Original()); |
| 7075 ASSERT(field.IsOriginal()); | |
| 7076 ASSERT(!Object::Handle(field.raw_ptr()->owner_).IsField()); | |
| 7077 return field.raw_ptr()->owner_; | |
|
siva
2016/02/25 23:38:33
Maybe
if (IsOriginal()) {
return raw_ptr()->
srdjan
2016/02/26 00:40:42
Done.
| |
| 7078 } | |
| 7079 | |
| 7080 | |
| 7081 RawClass* Field::Owner() const { | |
| 7082 const Field& field = Field::Handle(Original()); | |
| 7083 ASSERT(field.IsOriginal()); | |
| 7084 const Object& obj = Object::Handle(field.raw_ptr()->owner_); | |
| 7045 if (obj.IsClass()) { | 7085 if (obj.IsClass()) { |
| 7046 return Class::Cast(obj).raw(); | 7086 return Class::Cast(obj).raw(); |
| 7047 } | 7087 } |
| 7048 ASSERT(obj.IsPatchClass()); | 7088 ASSERT(obj.IsPatchClass()); |
| 7049 return PatchClass::Cast(obj).patched_class(); | 7089 return PatchClass::Cast(obj).patched_class(); |
|
siva
2016/02/25 23:38:33
See comment below in Field::Origin
srdjan
2016/02/26 00:40:43
Discussed offline, leaving it as it is so that the
| |
| 7050 } | 7090 } |
| 7051 | 7091 |
| 7052 | 7092 |
| 7053 RawClass* Field::origin() const { | 7093 RawClass* Field::Origin() const { |
| 7054 const Object& obj = Object::Handle(raw_ptr()->owner_); | 7094 const Field& field = Field::Handle(Original()); |
| 7095 ASSERT(field.IsOriginal()); | |
| 7096 const Object& obj = Object::Handle(field.raw_ptr()->owner_); | |
| 7055 if (obj.IsClass()) { | 7097 if (obj.IsClass()) { |
| 7056 return Class::Cast(obj).raw(); | 7098 return Class::Cast(obj).raw(); |
| 7057 } | 7099 } |
| 7058 ASSERT(obj.IsPatchClass()); | 7100 ASSERT(obj.IsPatchClass()); |
| 7059 return PatchClass::Cast(obj).origin_class(); | 7101 return PatchClass::Cast(obj).origin_class(); |
|
siva
2016/02/25 23:38:33
Wouldn't it be more efficient to write this as :
O
srdjan
2016/02/26 00:40:43
Discussed offline, leaving it as it is so that the
| |
| 7060 } | 7102 } |
| 7061 | 7103 |
| 7062 | 7104 |
| 7063 RawScript* Field::script() const { | 7105 RawScript* Field::Script() const { |
| 7064 const Object& obj = Object::Handle(raw_ptr()->owner_); | 7106 const Field& field = Field::Handle(Original()); |
| 7107 ASSERT(field.IsOriginal()); | |
| 7108 const Object& obj = Object::Handle(field.raw_ptr()->owner_); | |
| 7065 if (obj.IsClass()) { | 7109 if (obj.IsClass()) { |
| 7066 return Class::Cast(obj).script(); | 7110 return Class::Cast(obj).script(); |
| 7067 } | 7111 } |
| 7068 ASSERT(obj.IsPatchClass()); | 7112 ASSERT(obj.IsPatchClass()); |
| 7069 return PatchClass::Cast(obj).script(); | 7113 return PatchClass::Cast(obj).script(); |
|
siva
2016/02/25 23:38:33
Ditto comment.
srdjan
2016/02/26 00:40:42
Discussed offline, leaving it as it is so that the
| |
| 7070 } | 7114 } |
| 7071 | 7115 |
| 7072 | 7116 |
| 7073 // Called at finalization time | 7117 // Called at finalization time |
| 7074 void Field::SetFieldType(const AbstractType& value) const { | 7118 void Field::SetFieldType(const AbstractType& value) const { |
| 7075 ASSERT(Thread::Current()->IsMutatorThread()); | 7119 ASSERT(Thread::Current()->IsMutatorThread()); |
| 7120 ASSERT(IsOriginal()); | |
| 7076 ASSERT(!value.IsNull()); | 7121 ASSERT(!value.IsNull()); |
| 7077 if (value.raw() != type()) { | 7122 if (value.raw() != type()) { |
| 7078 StorePointer(&raw_ptr()->type_, value.raw()); | 7123 StorePointer(&raw_ptr()->type_, value.raw()); |
| 7079 } | 7124 } |
| 7080 } | 7125 } |
| 7081 | 7126 |
| 7082 | 7127 |
| 7083 RawField* Field::New() { | 7128 RawField* Field::New() { |
| 7084 ASSERT(Object::field_class() != Class::null()); | 7129 ASSERT(Object::field_class() != Class::null()); |
| 7085 RawObject* raw = Object::Allocate(Field::kClassId, | 7130 RawObject* raw = Object::Allocate(Field::kClassId, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7152 } else { | 7197 } else { |
| 7153 result.set_guarded_list_length(Field::kNoFixedLength); | 7198 result.set_guarded_list_length(Field::kNoFixedLength); |
| 7154 } | 7199 } |
| 7155 return result.raw(); | 7200 return result.raw(); |
| 7156 } | 7201 } |
| 7157 | 7202 |
| 7158 | 7203 |
| 7159 RawField* Field::Clone(const Class& new_owner) const { | 7204 RawField* Field::Clone(const Class& new_owner) const { |
| 7160 Field& clone = Field::Handle(); | 7205 Field& clone = Field::Handle(); |
| 7161 clone ^= Object::Clone(*this, Heap::kOld); | 7206 clone ^= Object::Clone(*this, Heap::kOld); |
| 7162 const Class& owner = Class::Handle(this->owner()); | 7207 const Class& owner = Class::Handle(this->Owner()); |
| 7163 const PatchClass& clone_owner = | 7208 const PatchClass& clone_owner = |
| 7164 PatchClass::Handle(PatchClass::New(new_owner, owner)); | 7209 PatchClass::Handle(PatchClass::New(new_owner, owner)); |
| 7165 clone.set_owner(clone_owner); | 7210 clone.set_owner(clone_owner); |
| 7166 if (!clone.is_static()) { | 7211 if (!clone.is_static()) { |
| 7167 clone.SetOffset(0); | 7212 clone.SetOffset(0); |
| 7168 } | 7213 } |
| 7169 if (new_owner.NumTypeParameters() > 0) { | 7214 if (new_owner.NumTypeParameters() > 0) { |
| 7170 // Adjust the field type to refer to type parameters of the new owner. | 7215 // Adjust the field type to refer to type parameters of the new owner. |
| 7171 AbstractType& type = AbstractType::Handle(clone.type()); | 7216 AbstractType& type = AbstractType::Handle(clone.type()); |
| 7172 type ^= type.CloneUninstantiated(new_owner); | 7217 type ^= type.CloneUninstantiated(new_owner); |
| 7173 clone.SetFieldType(type); | 7218 clone.SetFieldType(type); |
| 7174 } | 7219 } |
| 7175 return clone.raw(); | 7220 return clone.raw(); |
| 7176 } | 7221 } |
| 7177 | 7222 |
| 7178 | 7223 |
| 7224 RawField* Field::Clone(const Field& original) const { | |
| 7225 if (original.IsNull()) { | |
| 7226 return Field::null(); | |
| 7227 } | |
| 7228 ASSERT(original.IsOriginal()); | |
| 7229 Field& clone = Field::Handle(); | |
| 7230 clone ^= Object::Clone(*this, Heap::kOld); | |
| 7231 clone.SetOriginal(original); | |
| 7232 return clone.raw(); | |
| 7233 } | |
| 7234 | |
| 7235 | |
| 7179 RawString* Field::UserVisibleName() const { | 7236 RawString* Field::UserVisibleName() const { |
| 7180 if (FLAG_show_internal_names) { | 7237 if (FLAG_show_internal_names) { |
| 7181 return name(); | 7238 return name(); |
| 7182 } | 7239 } |
| 7183 return String::ScrubName(String::Handle(name())); | 7240 return String::ScrubName(String::Handle(name())); |
| 7184 } | 7241 } |
| 7185 | 7242 |
| 7186 | 7243 |
| 7187 intptr_t Field::guarded_list_length() const { | 7244 intptr_t Field::guarded_list_length() const { |
| 7188 return Smi::Value(raw_ptr()->guarded_list_length_); | 7245 return Smi::Value(raw_ptr()->guarded_list_length_); |
| 7189 } | 7246 } |
| 7190 | 7247 |
| 7191 | 7248 |
| 7192 void Field::set_guarded_list_length(intptr_t list_length) const { | 7249 void Field::set_guarded_list_length(intptr_t list_length) const { |
| 7193 ASSERT(Thread::Current()->IsMutatorThread()); | 7250 ASSERT(Thread::Current()->IsMutatorThread()); |
| 7251 ASSERT(IsOriginal()); | |
| 7194 StoreSmi(&raw_ptr()->guarded_list_length_, Smi::New(list_length)); | 7252 StoreSmi(&raw_ptr()->guarded_list_length_, Smi::New(list_length)); |
| 7195 } | 7253 } |
| 7196 | 7254 |
| 7197 | 7255 |
| 7198 intptr_t Field::guarded_list_length_in_object_offset() const { | 7256 intptr_t Field::guarded_list_length_in_object_offset() const { |
| 7199 return raw_ptr()->guarded_list_length_in_object_offset_ + kHeapObjectTag; | 7257 return raw_ptr()->guarded_list_length_in_object_offset_ + kHeapObjectTag; |
| 7200 } | 7258 } |
| 7201 | 7259 |
| 7202 | 7260 |
| 7203 void Field::set_guarded_list_length_in_object_offset( | 7261 void Field::set_guarded_list_length_in_object_offset( |
| 7204 intptr_t list_length_offset) const { | 7262 intptr_t list_length_offset) const { |
| 7205 ASSERT(Thread::Current()->IsMutatorThread()); | 7263 ASSERT(Thread::Current()->IsMutatorThread()); |
| 7264 ASSERT(IsOriginal()); | |
| 7206 StoreNonPointer(&raw_ptr()->guarded_list_length_in_object_offset_, | 7265 StoreNonPointer(&raw_ptr()->guarded_list_length_in_object_offset_, |
| 7207 static_cast<int8_t>(list_length_offset - kHeapObjectTag)); | 7266 static_cast<int8_t>(list_length_offset - kHeapObjectTag)); |
| 7208 ASSERT(guarded_list_length_in_object_offset() == list_length_offset); | 7267 ASSERT(guarded_list_length_in_object_offset() == list_length_offset); |
| 7209 } | 7268 } |
| 7210 | 7269 |
| 7211 | 7270 |
| 7212 const char* Field::ToCString() const { | 7271 const char* Field::ToCString() const { |
| 7213 if (IsNull()) { | 7272 if (IsNull()) { |
| 7214 return "Field::null"; | 7273 return "Field::null"; |
| 7215 } | 7274 } |
| 7216 const char* kF0 = is_static() ? " static" : ""; | 7275 const char* kF0 = is_static() ? " static" : ""; |
| 7217 const char* kF1 = is_final() ? " final" : ""; | 7276 const char* kF1 = is_final() ? " final" : ""; |
| 7218 const char* kF2 = is_const() ? " const" : ""; | 7277 const char* kF2 = is_const() ? " const" : ""; |
| 7219 const char* field_name = String::Handle(name()).ToCString(); | 7278 const char* field_name = String::Handle(name()).ToCString(); |
| 7220 const Class& cls = Class::Handle(owner()); | 7279 const Class& cls = Class::Handle(Owner()); |
| 7221 const char* cls_name = String::Handle(cls.Name()).ToCString(); | 7280 const char* cls_name = String::Handle(cls.Name()).ToCString(); |
| 7222 return OS::SCreate(Thread::Current()->zone(), | 7281 return OS::SCreate(Thread::Current()->zone(), |
| 7223 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2); | 7282 "Field <%s.%s>:%s%s%s", cls_name, field_name, kF0, kF1, kF2); |
| 7224 } | 7283 } |
| 7225 | 7284 |
| 7226 | 7285 |
| 7227 // Build a closure object that gets (or sets) the contents of a static | 7286 // Build a closure object that gets (or sets) the contents of a static |
| 7228 // field f and cache the closure in a newly created static field | 7287 // field f and cache the closure in a newly created static field |
| 7229 // named #f (or #f= in case of a setter). | 7288 // named #f (or #f= in case of a setter). |
| 7230 RawInstance* Field::AccessorClosure(bool make_setter) const { | 7289 RawInstance* Field::AccessorClosure(bool make_setter) const { |
| 7231 ASSERT(is_static()); | 7290 ASSERT(is_static()); |
| 7232 const Class& field_owner = Class::Handle(owner()); | 7291 const Class& field_owner = Class::Handle(Owner()); |
| 7233 | 7292 |
| 7234 String& closure_name = String::Handle(this->name()); | 7293 String& closure_name = String::Handle(this->name()); |
| 7235 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); | 7294 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); |
| 7236 if (make_setter) { | 7295 if (make_setter) { |
| 7237 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); | 7296 closure_name = Symbols::FromConcat(Symbols::HashMark(), closure_name); |
| 7238 } | 7297 } |
| 7239 | 7298 |
| 7240 Field& closure_field = Field::Handle(); | 7299 Field& closure_field = Field::Handle(); |
| 7241 closure_field = field_owner.LookupStaticField(closure_name); | 7300 closure_field = field_owner.LookupStaticField(closure_name); |
| 7242 if (!closure_field.IsNull()) { | 7301 if (!closure_field.IsNull()) { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7292 return AccessorClosure(true); | 7351 return AccessorClosure(true); |
| 7293 } | 7352 } |
| 7294 | 7353 |
| 7295 | 7354 |
| 7296 RawArray* Field::dependent_code() const { | 7355 RawArray* Field::dependent_code() const { |
| 7297 return raw_ptr()->dependent_code_; | 7356 return raw_ptr()->dependent_code_; |
| 7298 } | 7357 } |
| 7299 | 7358 |
| 7300 | 7359 |
| 7301 void Field::set_dependent_code(const Array& array) const { | 7360 void Field::set_dependent_code(const Array& array) const { |
| 7361 ASSERT(IsOriginal()); | |
| 7302 StorePointer(&raw_ptr()->dependent_code_, array.raw()); | 7362 StorePointer(&raw_ptr()->dependent_code_, array.raw()); |
| 7303 } | 7363 } |
| 7304 | 7364 |
| 7305 | 7365 |
| 7306 class FieldDependentArray : public WeakCodeReferences { | 7366 class FieldDependentArray : public WeakCodeReferences { |
| 7307 public: | 7367 public: |
| 7308 explicit FieldDependentArray(const Field& field) | 7368 explicit FieldDependentArray(const Field& field) |
| 7309 : WeakCodeReferences(Array::Handle(field.dependent_code())), | 7369 : WeakCodeReferences(Array::Handle(field.dependent_code())), |
| 7310 field_(field) {} | 7370 field_(field) {} |
| 7311 | 7371 |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 7335 Isolate::Current()->IncrFieldInvalidationGen(); | 7395 Isolate::Current()->IncrFieldInvalidationGen(); |
| 7336 } | 7396 } |
| 7337 | 7397 |
| 7338 private: | 7398 private: |
| 7339 const Field& field_; | 7399 const Field& field_; |
| 7340 DISALLOW_COPY_AND_ASSIGN(FieldDependentArray); | 7400 DISALLOW_COPY_AND_ASSIGN(FieldDependentArray); |
| 7341 }; | 7401 }; |
| 7342 | 7402 |
| 7343 | 7403 |
| 7344 void Field::RegisterDependentCode(const Code& code) const { | 7404 void Field::RegisterDependentCode(const Code& code) const { |
| 7405 ASSERT(IsOriginal()); | |
| 7345 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); | 7406 DEBUG_ASSERT(IsMutatorOrAtSafepoint()); |
| 7346 ASSERT(code.is_optimized()); | 7407 ASSERT(code.is_optimized()); |
| 7347 FieldDependentArray a(*this); | 7408 FieldDependentArray a(*this); |
| 7348 a.Register(code); | 7409 a.Register(code); |
| 7349 } | 7410 } |
| 7350 | 7411 |
| 7351 | 7412 |
| 7352 void Field::DeoptimizeDependentCode() const { | 7413 void Field::DeoptimizeDependentCode() const { |
| 7414 ASSERT(IsOriginal()); | |
| 7353 ASSERT(Thread::Current()->IsMutatorThread()); | 7415 ASSERT(Thread::Current()->IsMutatorThread()); |
| 7354 FieldDependentArray a(*this); | 7416 FieldDependentArray a(*this); |
| 7355 a.DisableCode(); | 7417 a.DisableCode(); |
| 7356 } | 7418 } |
| 7357 | 7419 |
| 7358 | 7420 |
| 7359 bool Field::IsUninitialized() const { | 7421 bool Field::IsUninitialized() const { |
| 7360 const Instance& value = Instance::Handle(raw_ptr()->value_.static_value_); | 7422 const Instance& value = Instance::Handle(raw_ptr()->value_.static_value_); |
| 7361 ASSERT(value.raw() != Object::transition_sentinel().raw()); | 7423 ASSERT(value.raw() != Object::transition_sentinel().raw()); |
| 7362 return value.raw() == Object::sentinel().raw(); | 7424 return value.raw() == Object::sentinel().raw(); |
| 7363 } | 7425 } |
| 7364 | 7426 |
| 7365 | 7427 |
| 7366 void Field::SetPrecompiledInitializer(const Function& initializer) const { | 7428 void Field::SetPrecompiledInitializer(const Function& initializer) const { |
| 7429 ASSERT(IsOriginal()); | |
| 7367 StorePointer(&raw_ptr()->initializer_.precompiled_, initializer.raw()); | 7430 StorePointer(&raw_ptr()->initializer_.precompiled_, initializer.raw()); |
| 7368 } | 7431 } |
| 7369 | 7432 |
| 7370 | 7433 |
| 7371 bool Field::HasPrecompiledInitializer() const { | 7434 bool Field::HasPrecompiledInitializer() const { |
| 7372 return raw_ptr()->initializer_.precompiled_->IsHeapObject() && | 7435 return raw_ptr()->initializer_.precompiled_->IsHeapObject() && |
| 7373 raw_ptr()->initializer_.precompiled_->IsFunction(); | 7436 raw_ptr()->initializer_.precompiled_->IsFunction(); |
| 7374 } | 7437 } |
| 7375 | 7438 |
| 7376 | 7439 |
| 7377 void Field::SetSavedInitialStaticValue(const Instance& value) const { | 7440 void Field::SetSavedInitialStaticValue(const Instance& value) const { |
| 7441 ASSERT(IsOriginal()); | |
| 7378 ASSERT(!HasPrecompiledInitializer()); | 7442 ASSERT(!HasPrecompiledInitializer()); |
| 7379 StorePointer(&raw_ptr()->initializer_.saved_value_, value.raw()); | 7443 StorePointer(&raw_ptr()->initializer_.saved_value_, value.raw()); |
| 7380 } | 7444 } |
| 7381 | 7445 |
| 7382 | 7446 |
| 7383 void Field::EvaluateInitializer() const { | 7447 void Field::EvaluateInitializer() const { |
| 7448 ASSERT(IsOriginal()); | |
| 7384 ASSERT(is_static()); | 7449 ASSERT(is_static()); |
| 7385 if (StaticValue() == Object::sentinel().raw()) { | 7450 if (StaticValue() == Object::sentinel().raw()) { |
| 7386 SetStaticValue(Object::transition_sentinel()); | 7451 SetStaticValue(Object::transition_sentinel()); |
| 7387 const Object& value = | 7452 const Object& value = |
| 7388 Object::Handle(Compiler::EvaluateStaticInitializer(*this)); | 7453 Object::Handle(Compiler::EvaluateStaticInitializer(*this)); |
| 7389 if (value.IsError()) { | 7454 if (value.IsError()) { |
| 7390 SetStaticValue(Object::null_instance()); | 7455 SetStaticValue(Object::null_instance()); |
| 7391 Exceptions::PropagateError(Error::Cast(value)); | 7456 Exceptions::PropagateError(Error::Cast(value)); |
| 7392 UNREACHABLE(); | 7457 UNREACHABLE(); |
| 7393 } | 7458 } |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7475 } | 7540 } |
| 7476 } | 7541 } |
| 7477 | 7542 |
| 7478 return Thread::Current()->zone()->PrintToString("<%s %s>", | 7543 return Thread::Current()->zone()->PrintToString("<%s %s>", |
| 7479 is_nullable() ? "nullable" : "not-nullable", | 7544 is_nullable() ? "nullable" : "not-nullable", |
| 7480 class_name); | 7545 class_name); |
| 7481 } | 7546 } |
| 7482 | 7547 |
| 7483 | 7548 |
| 7484 void Field::InitializeGuardedListLengthInObjectOffset() const { | 7549 void Field::InitializeGuardedListLengthInObjectOffset() const { |
| 7550 ASSERT(IsOriginal()); | |
| 7485 if (needs_length_check() && | 7551 if (needs_length_check() && |
| 7486 (guarded_list_length() != Field::kUnknownFixedLength)) { | 7552 (guarded_list_length() != Field::kUnknownFixedLength)) { |
| 7487 const intptr_t offset = GetListLengthOffset(guarded_cid()); | 7553 const intptr_t offset = GetListLengthOffset(guarded_cid()); |
| 7488 set_guarded_list_length_in_object_offset(offset); | 7554 set_guarded_list_length_in_object_offset(offset); |
| 7489 ASSERT(offset != Field::kUnknownLengthOffset); | 7555 ASSERT(offset != Field::kUnknownLengthOffset); |
| 7490 } else { | 7556 } else { |
| 7491 set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); | 7557 set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); |
| 7492 } | 7558 } |
| 7493 } | 7559 } |
| 7494 | 7560 |
| 7495 | 7561 |
| 7496 bool Field::UpdateGuardedCidAndLength(const Object& value) const { | 7562 bool Field::UpdateGuardedCidAndLength(const Object& value) const { |
| 7563 ASSERT(IsOriginal()); | |
| 7497 const intptr_t cid = value.GetClassId(); | 7564 const intptr_t cid = value.GetClassId(); |
| 7498 | 7565 |
| 7499 if (guarded_cid() == kIllegalCid) { | 7566 if (guarded_cid() == kIllegalCid) { |
| 7500 // Field is assigned first time. | 7567 // Field is assigned first time. |
| 7501 set_guarded_cid(cid); | 7568 set_guarded_cid(cid); |
| 7502 set_is_nullable(cid == kNullCid); | 7569 set_is_nullable(cid == kNullCid); |
| 7503 | 7570 |
| 7504 // Start tracking length if needed. | 7571 // Start tracking length if needed. |
| 7505 ASSERT((guarded_list_length() == Field::kUnknownFixedLength) || | 7572 ASSERT((guarded_list_length() == Field::kUnknownFixedLength) || |
| 7506 (guarded_list_length() == Field::kNoFixedLength)); | 7573 (guarded_list_length() == Field::kNoFixedLength)); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7554 set_guarded_list_length(Field::kNoFixedLength); | 7621 set_guarded_list_length(Field::kNoFixedLength); |
| 7555 set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); | 7622 set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); |
| 7556 } | 7623 } |
| 7557 | 7624 |
| 7558 // Expected class id or nullability of the field changed. | 7625 // Expected class id or nullability of the field changed. |
| 7559 return true; | 7626 return true; |
| 7560 } | 7627 } |
| 7561 | 7628 |
| 7562 | 7629 |
| 7563 void Field::RecordStore(const Object& value) const { | 7630 void Field::RecordStore(const Object& value) const { |
| 7631 ASSERT(IsOriginal()); | |
| 7564 if (!FLAG_use_field_guards) { | 7632 if (!FLAG_use_field_guards) { |
| 7565 return; | 7633 return; |
| 7566 } | 7634 } |
| 7567 | 7635 |
| 7568 if (FLAG_trace_field_guards) { | 7636 if (FLAG_trace_field_guards) { |
| 7569 THR_Print("Store %s %s <- %s\n", | 7637 THR_Print("Store %s %s <- %s\n", |
| 7570 ToCString(), | 7638 ToCString(), |
| 7571 GuardedPropertiesAsCString(), | 7639 GuardedPropertiesAsCString(), |
| 7572 value.ToCString()); | 7640 value.ToCString()); |
| 7573 } | 7641 } |
| (...skipping 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8915 } | 8983 } |
| 8916 | 8984 |
| 8917 | 8985 |
| 8918 static RawString* MakeClassMetaName(const Class& cls) { | 8986 static RawString* MakeClassMetaName(const Class& cls) { |
| 8919 return Symbols::FromConcat(Symbols::At(), String::Handle(cls.Name())); | 8987 return Symbols::FromConcat(Symbols::At(), String::Handle(cls.Name())); |
| 8920 } | 8988 } |
| 8921 | 8989 |
| 8922 | 8990 |
| 8923 static RawString* MakeFieldMetaName(const Field& field) { | 8991 static RawString* MakeFieldMetaName(const Field& field) { |
| 8924 const String& cname = | 8992 const String& cname = |
| 8925 String::Handle(MakeClassMetaName(Class::Handle(field.origin()))); | 8993 String::Handle(MakeClassMetaName(Class::Handle(field.Origin()))); |
| 8926 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); | 8994 GrowableHandlePtrArray<const String> pieces(Thread::Current()->zone(), 3); |
| 8927 pieces.Add(cname); | 8995 pieces.Add(cname); |
| 8928 pieces.Add(Symbols::At()); | 8996 pieces.Add(Symbols::At()); |
| 8929 pieces.Add(String::Handle(field.name())); | 8997 pieces.Add(String::Handle(field.name())); |
| 8930 return Symbols::FromConcatAll(pieces); | 8998 return Symbols::FromConcatAll(pieces); |
| 8931 } | 8999 } |
| 8932 | 9000 |
| 8933 | 9001 |
| 8934 static RawString* MakeFunctionMetaName(const Function& func) { | 9002 static RawString* MakeFunctionMetaName(const Function& func) { |
| 8935 const String& cname = | 9003 const String& cname = |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9380 Class& cls = Class::Handle(); | 9448 Class& cls = Class::Handle(); |
| 9381 Script& owner_script = Script::Handle(); | 9449 Script& owner_script = Script::Handle(); |
| 9382 DictionaryIterator it(*this); | 9450 DictionaryIterator it(*this); |
| 9383 while (it.HasNext()) { | 9451 while (it.HasNext()) { |
| 9384 entry = it.GetNext(); | 9452 entry = it.GetNext(); |
| 9385 if (entry.IsClass()) { | 9453 if (entry.IsClass()) { |
| 9386 owner_script = Class::Cast(entry).script(); | 9454 owner_script = Class::Cast(entry).script(); |
| 9387 } else if (entry.IsFunction()) { | 9455 } else if (entry.IsFunction()) { |
| 9388 owner_script = Function::Cast(entry).script(); | 9456 owner_script = Function::Cast(entry).script(); |
| 9389 } else if (entry.IsField()) { | 9457 } else if (entry.IsField()) { |
| 9390 owner_script = Field::Cast(entry).script(); | 9458 owner_script = Field::Cast(entry).Script(); |
| 9391 } else { | 9459 } else { |
| 9392 continue; | 9460 continue; |
| 9393 } | 9461 } |
| 9394 AddScriptIfUnique(scripts, owner_script); | 9462 AddScriptIfUnique(scripts, owner_script); |
| 9395 } | 9463 } |
| 9396 | 9464 |
| 9397 // Add all scripts from patch classes. | 9465 // Add all scripts from patch classes. |
| 9398 GrowableObjectArray& patches = GrowableObjectArray::Handle(patch_classes()); | 9466 GrowableObjectArray& patches = GrowableObjectArray::Handle(patch_classes()); |
| 9399 for (intptr_t i = 0; i < patches.Length(); i++) { | 9467 for (intptr_t i = 0; i < patches.Length(); i++) { |
| 9400 entry = patches.At(i); | 9468 entry = patches.At(i); |
| (...skipping 12021 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 21422 return UserTag::null(); | 21490 return UserTag::null(); |
| 21423 } | 21491 } |
| 21424 | 21492 |
| 21425 | 21493 |
| 21426 const char* UserTag::ToCString() const { | 21494 const char* UserTag::ToCString() const { |
| 21427 const String& tag_label = String::Handle(label()); | 21495 const String& tag_label = String::Handle(label()); |
| 21428 return tag_label.ToCString(); | 21496 return tag_label.ToCString(); |
| 21429 } | 21497 } |
| 21430 | 21498 |
| 21431 } // namespace dart | 21499 } // namespace dart |
| OLD | NEW |