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

Side by Side Diff: runtime/vm/object.cc

Issue 269253005: Put metadata fields in their owner class. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 7 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
OLDNEW
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 2776 matching lines...) Expand 10 before | Expand all | Expand 10 after
2787 for (intptr_t i = 0; i < len; i++) { 2787 for (intptr_t i = 0; i < len; i++) {
2788 field ^= value.At(i); 2788 field ^= value.At(i);
2789 ASSERT(field.owner() == raw()); 2789 ASSERT(field.owner() == raw());
2790 } 2790 }
2791 #endif 2791 #endif
2792 // The value of static fields is already initialized to null. 2792 // The value of static fields is already initialized to null.
2793 StorePointer(&raw_ptr()->fields_, value.raw()); 2793 StorePointer(&raw_ptr()->fields_, value.raw());
2794 } 2794 }
2795 2795
2796 2796
2797 void Class::AddField(const Field& field) const {
rmacnak 2014/05/08 01:35:21 Cf. AddFunction
2798 const Array& arr = Array::Handle(fields());
2799 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1));
2800 new_arr.SetAt(arr.Length(), field);
2801 SetFields(new_arr);
2802 }
2803
2804
2797 intptr_t Class::FindFieldIndex(const Field& needle) const { 2805 intptr_t Class::FindFieldIndex(const Field& needle) const {
2798 Isolate* isolate = Isolate::Current(); 2806 Isolate* isolate = Isolate::Current();
2799 if (EnsureIsFinalized(isolate) != Error::null()) { 2807 if (EnsureIsFinalized(isolate) != Error::null()) {
2800 return -1; 2808 return -1;
2801 } 2809 }
2802 REUSABLE_ARRAY_HANDLESCOPE(isolate); 2810 REUSABLE_ARRAY_HANDLESCOPE(isolate);
2803 REUSABLE_FIELD_HANDLESCOPE(isolate); 2811 REUSABLE_FIELD_HANDLESCOPE(isolate);
2804 REUSABLE_STRING_HANDLESCOPE(isolate); 2812 REUSABLE_STRING_HANDLESCOPE(isolate);
2805 Array& fields_array = isolate->ArrayHandle(); 2813 Array& fields_array = isolate->ArrayHandle();
2806 Field& field = isolate->FieldHandle(); 2814 Field& field = isolate->FieldHandle();
(...skipping 5454 matching lines...) Expand 10 before | Expand all | Expand 10 after
8261 true, // is_static 8269 true, // is_static
8262 false, // is_final 8270 false, // is_final
8263 false, // is_const 8271 false, // is_const
8264 cls, 8272 cls,
8265 token_pos)); 8273 token_pos));
8266 field.set_type(Type::Handle(Type::DynamicType())); 8274 field.set_type(Type::Handle(Type::DynamicType()));
8267 field.set_value(Array::empty_array()); 8275 field.set_value(Array::empty_array());
8268 GrowableObjectArray& metadata = 8276 GrowableObjectArray& metadata =
8269 GrowableObjectArray::Handle(this->metadata()); 8277 GrowableObjectArray::Handle(this->metadata());
8270 metadata.Add(field, Heap::kOld); 8278 metadata.Add(field, Heap::kOld);
8279 cls.AddField(field);
8271 } 8280 }
8272 8281
8273 8282
8274 void Library::AddClassMetadata(const Class& cls, 8283 void Library::AddClassMetadata(const Class& cls,
8275 const Class& toplevel_class, 8284 const Class& toplevel_class,
8276 intptr_t token_pos) const { 8285 intptr_t token_pos) const {
8277 // We use the toplevel class as the owner of a class's metadata field because 8286 // We use the toplevel class as the owner of a class's metadata field because
8278 // a class's metadata is in scope of the library, not the class. 8287 // a class's metadata is in scope of the library, not the class.
8279 AddMetadata(toplevel_class, 8288 AddMetadata(toplevel_class,
8280 String::Handle(MakeClassMetaName(cls)), 8289 String::Handle(MakeClassMetaName(cls)),
(...skipping 10506 matching lines...) Expand 10 before | Expand all | Expand 10 after
18787 return tag_label.ToCString(); 18796 return tag_label.ToCString();
18788 } 18797 }
18789 18798
18790 18799
18791 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 18800 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
18792 Instance::PrintJSONImpl(stream, ref); 18801 Instance::PrintJSONImpl(stream, ref);
18793 } 18802 }
18794 18803
18795 18804
18796 } // namespace dart 18805 } // namespace dart
OLDNEW
« runtime/vm/class_finalizer.cc ('K') | « runtime/vm/object.h ('k') | tests/lib/lib.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698