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

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

Issue 363473004: Hide synthetic metadata field exposed in r35926. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 | « runtime/vm/object.h ('k') | runtime/vm/object_test.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 (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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 789
790 // Set up names for object array and one byte string class which are 790 // Set up names for object array and one byte string class which are
791 // pre-allocated in the vm isolate also. 791 // pre-allocated in the vm isolate also.
792 cls = Dart::vm_isolate()->object_store()->array_class(); 792 cls = Dart::vm_isolate()->object_store()->array_class();
793 cls.set_name(Symbols::_List()); 793 cls.set_name(Symbols::_List());
794 cls = Dart::vm_isolate()->object_store()->one_byte_string_class(); 794 cls = Dart::vm_isolate()->object_store()->one_byte_string_class();
795 cls.set_name(Symbols::OneByteString()); 795 cls.set_name(Symbols::OneByteString());
796 } 796 }
797 797
798 798
799 void Object::CreateInternalMetaData() {
800 // Initialize meta data for VM internal classes.
801 Class& cls = Class::Handle();
802 Array& fields = Array::Handle();
803 Field& fld = Field::Handle();
804 String& name = String::Handle();
805
806 // TODO(iposva): Add more of the VM classes here.
807 cls = context_class_;
808 fields = Array::New(1, Heap::kOld);
809 name = Symbols::New("@parent_");
810 fld = Field::New(name, false, false, false, cls, 0);
811 fields.SetAt(0, fld);
812 cls.SetFields(fields);
813 }
814
815
816 // Make unused space in an object whose type has been transformed safe 799 // Make unused space in an object whose type has been transformed safe
817 // for traversing during GC. 800 // for traversing during GC.
818 // The unused part of the transformed object is marked as an TypedDataInt8Array 801 // The unused part of the transformed object is marked as an TypedDataInt8Array
819 // object. 802 // object.
820 void Object::MakeUnusedSpaceTraversable(const Object& obj, 803 void Object::MakeUnusedSpaceTraversable(const Object& obj,
821 intptr_t original_size, 804 intptr_t original_size,
822 intptr_t used_size) { 805 intptr_t used_size) {
823 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0); 806 ASSERT(Isolate::Current()->no_gc_scope_depth() > 0);
824 ASSERT(!obj.IsNull()); 807 ASSERT(!obj.IsNull());
825 ASSERT(original_size >= used_size); 808 ASSERT(original_size >= used_size);
(...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 Field& field = Field::Handle(isolate); 1364 Field& field = Field::Handle(isolate);
1382 Smi& value = Smi::Handle(isolate); 1365 Smi& value = Smi::Handle(isolate);
1383 String& field_name = String::Handle(isolate); 1366 String& field_name = String::Handle(isolate);
1384 1367
1385 #define CLASS_LIST_WITH_NULL(V) \ 1368 #define CLASS_LIST_WITH_NULL(V) \
1386 V(Null) \ 1369 V(Null) \
1387 CLASS_LIST_NO_OBJECT(V) 1370 CLASS_LIST_NO_OBJECT(V)
1388 1371
1389 #define ADD_SET_FIELD(clazz) \ 1372 #define ADD_SET_FIELD(clazz) \
1390 field_name = Symbols::New("cid"#clazz); \ 1373 field_name = Symbols::New("cid"#clazz); \
1391 field = Field::New(field_name, true, false, true, cls, 0); \ 1374 field = Field::New(field_name, true, false, true, false, cls, 0); \
1392 value = Smi::New(k##clazz##Cid); \ 1375 value = Smi::New(k##clazz##Cid); \
1393 field.set_value(value); \ 1376 field.set_value(value); \
1394 field.set_type(Type::Handle(Type::IntType())); \ 1377 field.set_type(Type::Handle(Type::IntType())); \
1395 cls.AddField(field); \ 1378 cls.AddField(field); \
1396 1379
1397 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) 1380 CLASS_LIST_WITH_NULL(ADD_SET_FIELD)
1398 #undef ADD_SET_FIELD 1381 #undef ADD_SET_FIELD
1399 1382
1400 return Error::null(); 1383 return Error::null();
1401 } 1384 }
(...skipping 5454 matching lines...) Expand 10 before | Expand all | Expand 10 after
6856 Field::InstanceSize(), 6839 Field::InstanceSize(),
6857 Heap::kOld); 6840 Heap::kOld);
6858 return reinterpret_cast<RawField*>(raw); 6841 return reinterpret_cast<RawField*>(raw);
6859 } 6842 }
6860 6843
6861 6844
6862 RawField* Field::New(const String& name, 6845 RawField* Field::New(const String& name,
6863 bool is_static, 6846 bool is_static,
6864 bool is_final, 6847 bool is_final,
6865 bool is_const, 6848 bool is_const,
6849 bool is_synthetic,
6866 const Class& owner, 6850 const Class& owner,
6867 intptr_t token_pos) { 6851 intptr_t token_pos) {
6868 ASSERT(!owner.IsNull()); 6852 ASSERT(!owner.IsNull());
6869 const Field& result = Field::Handle(Field::New()); 6853 const Field& result = Field::Handle(Field::New());
6870 result.set_name(name); 6854 result.set_name(name);
6871 result.set_is_static(is_static); 6855 result.set_is_static(is_static);
6872 if (is_static) { 6856 if (is_static) {
6873 result.set_value(Object::null_instance()); 6857 result.set_value(Object::null_instance());
6874 } else { 6858 } else {
6875 result.SetOffset(0); 6859 result.SetOffset(0);
6876 } 6860 }
6877 result.set_is_final(is_final); 6861 result.set_is_final(is_final);
6878 result.set_is_const(is_const); 6862 result.set_is_const(is_const);
6863 result.set_is_synthetic(is_synthetic);
6879 result.set_owner(owner); 6864 result.set_owner(owner);
6880 result.set_token_pos(token_pos); 6865 result.set_token_pos(token_pos);
6881 result.set_has_initializer(false); 6866 result.set_has_initializer(false);
6882 result.set_is_unboxing_candidate(true); 6867 result.set_is_unboxing_candidate(true);
6883 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); 6868 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid);
6884 result.set_is_nullable(FLAG_use_field_guards ? false : true); 6869 result.set_is_nullable(FLAG_use_field_guards ? false : true);
6885 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); 6870 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset);
6886 // Presently, we only attempt to remember the list length for final fields. 6871 // Presently, we only attempt to remember the list length for final fields.
6887 if (is_final && FLAG_use_field_guards) { 6872 if (is_final && FLAG_use_field_guards) {
6888 result.set_guarded_list_length(Field::kUnknownFixedLength); 6873 result.set_guarded_list_length(Field::kUnknownFixedLength);
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
8468 8453
8469 8454
8470 void Library::AddMetadata(const Class& cls, 8455 void Library::AddMetadata(const Class& cls,
8471 const String& name, 8456 const String& name,
8472 intptr_t token_pos) const { 8457 intptr_t token_pos) const {
8473 const String& metaname = String::Handle(Symbols::New(name)); 8458 const String& metaname = String::Handle(Symbols::New(name));
8474 Field& field = Field::Handle(Field::New(metaname, 8459 Field& field = Field::Handle(Field::New(metaname,
8475 true, // is_static 8460 true, // is_static
8476 false, // is_final 8461 false, // is_final
8477 false, // is_const 8462 false, // is_const
8463 true, // is_synthetic
8478 cls, 8464 cls,
8479 token_pos)); 8465 token_pos));
8480 field.set_type(Type::Handle(Type::DynamicType())); 8466 field.set_type(Type::Handle(Type::DynamicType()));
8481 field.set_value(Array::empty_array()); 8467 field.set_value(Array::empty_array());
8482 GrowableObjectArray& metadata = 8468 GrowableObjectArray& metadata =
8483 GrowableObjectArray::Handle(this->metadata()); 8469 GrowableObjectArray::Handle(this->metadata());
8484 metadata.Add(field, Heap::kOld); 8470 metadata.Add(field, Heap::kOld);
8485 cls.AddField(field); 8471 cls.AddField(field);
8486 } 8472 }
8487 8473
(...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after
9831 StorePointer(&raw_ptr()->metadata_field_, value.raw()); 9817 StorePointer(&raw_ptr()->metadata_field_, value.raw());
9832 } 9818 }
9833 9819
9834 9820
9835 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { 9821 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) {
9836 ASSERT(Field::Handle(metadata_field()).IsNull()); 9822 ASSERT(Field::Handle(metadata_field()).IsNull());
9837 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), 9823 Field& field = Field::Handle(Field::New(Symbols::TopLevel(),
9838 true, // is_static 9824 true, // is_static
9839 false, // is_final 9825 false, // is_final
9840 false, // is_const 9826 false, // is_const
9827 true, // is_synthetic
9841 owner_class, 9828 owner_class,
9842 token_pos)); 9829 token_pos));
9843 field.set_type(Type::Handle(Type::DynamicType())); 9830 field.set_type(Type::Handle(Type::DynamicType()));
9844 field.set_value(Array::empty_array()); 9831 field.set_value(Array::empty_array());
9845 set_metadata_field(field); 9832 set_metadata_field(field);
9846 owner_class.AddField(field); 9833 owner_class.AddField(field);
9847 } 9834 }
9848 9835
9849 9836
9850 RawObject* Namespace::GetMetadata() const { 9837 RawObject* Namespace::GetMetadata() const {
(...skipping 9170 matching lines...) Expand 10 before | Expand all | Expand 10 after
19021 return tag_label.ToCString(); 19008 return tag_label.ToCString();
19022 } 19009 }
19023 19010
19024 19011
19025 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19012 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
19026 Instance::PrintJSONImpl(stream, ref); 19013 Instance::PrintJSONImpl(stream, ref);
19027 } 19014 }
19028 19015
19029 19016
19030 } // namespace dart 19017 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/object_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698