| 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 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1466 Field& field = Field::Handle(isolate); | 1466 Field& field = Field::Handle(isolate); |
| 1467 Smi& value = Smi::Handle(isolate); | 1467 Smi& value = Smi::Handle(isolate); |
| 1468 String& field_name = String::Handle(isolate); | 1468 String& field_name = String::Handle(isolate); |
| 1469 | 1469 |
| 1470 #define CLASS_LIST_WITH_NULL(V) \ | 1470 #define CLASS_LIST_WITH_NULL(V) \ |
| 1471 V(Null) \ | 1471 V(Null) \ |
| 1472 CLASS_LIST_NO_OBJECT(V) | 1472 CLASS_LIST_NO_OBJECT(V) |
| 1473 | 1473 |
| 1474 #define ADD_SET_FIELD(clazz) \ | 1474 #define ADD_SET_FIELD(clazz) \ |
| 1475 field_name = Symbols::New("cid"#clazz); \ | 1475 field_name = Symbols::New("cid"#clazz); \ |
| 1476 field = Field::New(field_name, true, false, true, true, cls, 0); \ | 1476 field = Field::New(field_name, true, false, true, false, cls, 0); \ |
| 1477 value = Smi::New(k##clazz##Cid); \ | 1477 value = Smi::New(k##clazz##Cid); \ |
| 1478 field.set_value(value); \ | 1478 field.set_value(value); \ |
| 1479 field.set_type(Type::Handle(Type::IntType())); \ | 1479 field.set_type(Type::Handle(Type::IntType())); \ |
| 1480 cls.AddField(field); \ | 1480 cls.AddField(field); \ |
| 1481 | 1481 |
| 1482 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) | 1482 CLASS_LIST_WITH_NULL(ADD_SET_FIELD) |
| 1483 #undef ADD_SET_FIELD | 1483 #undef ADD_SET_FIELD |
| 1484 | 1484 |
| 1485 isolate->object_store()->InitKnownObjects(); | 1485 isolate->object_store()->InitKnownObjects(); |
| 1486 | 1486 |
| (...skipping 5720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7207 Field::InstanceSize(), | 7207 Field::InstanceSize(), |
| 7208 Heap::kOld); | 7208 Heap::kOld); |
| 7209 return reinterpret_cast<RawField*>(raw); | 7209 return reinterpret_cast<RawField*>(raw); |
| 7210 } | 7210 } |
| 7211 | 7211 |
| 7212 | 7212 |
| 7213 RawField* Field::New(const String& name, | 7213 RawField* Field::New(const String& name, |
| 7214 bool is_static, | 7214 bool is_static, |
| 7215 bool is_final, | 7215 bool is_final, |
| 7216 bool is_const, | 7216 bool is_const, |
| 7217 bool is_synthetic, | 7217 bool is_reflectable, |
| 7218 const Class& owner, | 7218 const Class& owner, |
| 7219 intptr_t token_pos) { | 7219 intptr_t token_pos) { |
| 7220 ASSERT(!owner.IsNull()); | 7220 ASSERT(!owner.IsNull()); |
| 7221 const Field& result = Field::Handle(Field::New()); | 7221 const Field& result = Field::Handle(Field::New()); |
| 7222 result.set_name(name); | 7222 result.set_name(name); |
| 7223 result.set_is_static(is_static); | 7223 result.set_is_static(is_static); |
| 7224 if (is_static) { | 7224 if (is_static) { |
| 7225 result.set_value(Object::null_instance()); | 7225 result.set_value(Object::null_instance()); |
| 7226 } else { | 7226 } else { |
| 7227 result.SetOffset(0); | 7227 result.SetOffset(0); |
| 7228 } | 7228 } |
| 7229 result.set_is_final(is_final); | 7229 result.set_is_final(is_final); |
| 7230 result.set_is_const(is_const); | 7230 result.set_is_const(is_const); |
| 7231 result.set_is_synthetic(is_synthetic); | 7231 result.set_is_reflectable(is_reflectable); |
| 7232 result.set_owner(owner); | 7232 result.set_owner(owner); |
| 7233 result.set_token_pos(token_pos); | 7233 result.set_token_pos(token_pos); |
| 7234 result.set_has_initializer(false); | 7234 result.set_has_initializer(false); |
| 7235 result.set_initializer(Function::Handle()); | 7235 result.set_initializer(Function::Handle()); |
| 7236 result.set_is_unboxing_candidate(true); | 7236 result.set_is_unboxing_candidate(true); |
| 7237 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); | 7237 result.set_guarded_cid(FLAG_use_field_guards ? kIllegalCid : kDynamicCid); |
| 7238 result.set_is_nullable(FLAG_use_field_guards ? false : true); | 7238 result.set_is_nullable(FLAG_use_field_guards ? false : true); |
| 7239 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); | 7239 result.set_guarded_list_length_in_object_offset(Field::kUnknownLengthOffset); |
| 7240 // Presently, we only attempt to remember the list length for final fields. | 7240 // Presently, we only attempt to remember the list length for final fields. |
| 7241 if (is_final && FLAG_use_field_guards) { | 7241 if (is_final && FLAG_use_field_guards) { |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7436 Object::empty_array())); | 7436 Object::empty_array())); |
| 7437 ASSERT(result.IsInstance()); | 7437 ASSERT(result.IsInstance()); |
| 7438 // The caller may expect the closure to be allocated in old space. Copy | 7438 // The caller may expect the closure to be allocated in old space. Copy |
| 7439 // the result here, since Object::Clone() is a private method. | 7439 // the result here, since Object::Clone() is a private method. |
| 7440 result = Object::Clone(result, Heap::kOld); | 7440 result = Object::Clone(result, Heap::kOld); |
| 7441 | 7441 |
| 7442 closure_field = Field::New(closure_name, | 7442 closure_field = Field::New(closure_name, |
| 7443 true, // is_static | 7443 true, // is_static |
| 7444 true, // is_final | 7444 true, // is_final |
| 7445 true, // is_const | 7445 true, // is_const |
| 7446 true, // is_synthetic | 7446 false, // is_reflectable |
| 7447 field_owner, | 7447 field_owner, |
| 7448 this->token_pos()); | 7448 this->token_pos()); |
| 7449 closure_field.set_value(Instance::Cast(result)); | 7449 closure_field.set_value(Instance::Cast(result)); |
| 7450 closure_field.set_type(Type::Handle(Type::DynamicType())); | 7450 closure_field.set_type(Type::Handle(Type::DynamicType())); |
| 7451 field_owner.AddField(closure_field); | 7451 field_owner.AddField(closure_field); |
| 7452 | 7452 |
| 7453 return Instance::RawCast(result.raw()); | 7453 return Instance::RawCast(result.raw()); |
| 7454 } | 7454 } |
| 7455 | 7455 |
| 7456 | 7456 |
| (...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9025 | 9025 |
| 9026 | 9026 |
| 9027 void Library::AddMetadata(const Class& cls, | 9027 void Library::AddMetadata(const Class& cls, |
| 9028 const String& name, | 9028 const String& name, |
| 9029 intptr_t token_pos) const { | 9029 intptr_t token_pos) const { |
| 9030 const String& metaname = String::Handle(Symbols::New(name)); | 9030 const String& metaname = String::Handle(Symbols::New(name)); |
| 9031 Field& field = Field::Handle(Field::New(metaname, | 9031 Field& field = Field::Handle(Field::New(metaname, |
| 9032 true, // is_static | 9032 true, // is_static |
| 9033 false, // is_final | 9033 false, // is_final |
| 9034 false, // is_const | 9034 false, // is_const |
| 9035 true, // is_synthetic | 9035 false, // is_reflectable |
| 9036 cls, | 9036 cls, |
| 9037 token_pos)); | 9037 token_pos)); |
| 9038 field.set_type(Type::Handle(Type::DynamicType())); | 9038 field.set_type(Type::Handle(Type::DynamicType())); |
| 9039 field.set_value(Array::empty_array()); | 9039 field.set_value(Array::empty_array()); |
| 9040 GrowableObjectArray& metadata = | 9040 GrowableObjectArray& metadata = |
| 9041 GrowableObjectArray::Handle(this->metadata()); | 9041 GrowableObjectArray::Handle(this->metadata()); |
| 9042 metadata.Add(field, Heap::kOld); | 9042 metadata.Add(field, Heap::kOld); |
| 9043 cls.AddField(field); | 9043 cls.AddField(field); |
| 9044 } | 9044 } |
| 9045 | 9045 |
| (...skipping 1487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10533 StorePointer(&raw_ptr()->metadata_field_, value.raw()); | 10533 StorePointer(&raw_ptr()->metadata_field_, value.raw()); |
| 10534 } | 10534 } |
| 10535 | 10535 |
| 10536 | 10536 |
| 10537 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { | 10537 void Namespace::AddMetadata(intptr_t token_pos, const Class& owner_class) { |
| 10538 ASSERT(Field::Handle(metadata_field()).IsNull()); | 10538 ASSERT(Field::Handle(metadata_field()).IsNull()); |
| 10539 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), | 10539 Field& field = Field::Handle(Field::New(Symbols::TopLevel(), |
| 10540 true, // is_static | 10540 true, // is_static |
| 10541 false, // is_final | 10541 false, // is_final |
| 10542 false, // is_const | 10542 false, // is_const |
| 10543 true, // is_synthetic | 10543 false, // is_reflectable |
| 10544 owner_class, | 10544 owner_class, |
| 10545 token_pos)); | 10545 token_pos)); |
| 10546 field.set_type(Type::Handle(Type::DynamicType())); | 10546 field.set_type(Type::Handle(Type::DynamicType())); |
| 10547 field.set_value(Array::empty_array()); | 10547 field.set_value(Array::empty_array()); |
| 10548 set_metadata_field(field); | 10548 set_metadata_field(field); |
| 10549 owner_class.AddField(field); | 10549 owner_class.AddField(field); |
| 10550 } | 10550 } |
| 10551 | 10551 |
| 10552 | 10552 |
| 10553 RawObject* Namespace::GetMetadata() const { | 10553 RawObject* Namespace::GetMetadata() const { |
| (...skipping 10788 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 21342 return tag_label.ToCString(); | 21342 return tag_label.ToCString(); |
| 21343 } | 21343 } |
| 21344 | 21344 |
| 21345 | 21345 |
| 21346 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21346 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 21347 Instance::PrintJSONImpl(stream, ref); | 21347 Instance::PrintJSONImpl(stream, ref); |
| 21348 } | 21348 } |
| 21349 | 21349 |
| 21350 | 21350 |
| 21351 } // namespace dart | 21351 } // namespace dart |
| OLD | NEW |