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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 81 AbstractTypeArguments* Object::null_abstract_type_arguments_ = NULL; | 81 AbstractTypeArguments* Object::null_abstract_type_arguments_ = NULL; |
| 82 Array* Object::empty_array_ = NULL; | 82 Array* Object::empty_array_ = NULL; |
| 83 Instance* Object::sentinel_ = NULL; | 83 Instance* Object::sentinel_ = NULL; |
| 84 Instance* Object::transition_sentinel_ = NULL; | 84 Instance* Object::transition_sentinel_ = NULL; |
| 85 Instance* Object::unknown_constant_ = NULL; | 85 Instance* Object::unknown_constant_ = NULL; |
| 86 Instance* Object::non_constant_ = NULL; | 86 Instance* Object::non_constant_ = NULL; |
| 87 Bool* Object::bool_true_ = NULL; | 87 Bool* Object::bool_true_ = NULL; |
| 88 Bool* Object::bool_false_ = NULL; | 88 Bool* Object::bool_false_ = NULL; |
| 89 Smi* Object::smi_illegal_cid_ = NULL; | 89 Smi* Object::smi_illegal_cid_ = NULL; |
| 90 LanguageError* Object::snapshot_writer_error_ = NULL; | 90 LanguageError* Object::snapshot_writer_error_ = NULL; |
| 91 LanguageError* Object::branch_offset_error_ = NULL; | |
| 91 | 92 |
| 92 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); | 93 RawObject* Object::null_ = reinterpret_cast<RawObject*>(RAW_NULL); |
| 93 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 94 RawClass* Object::class_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 94 RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 95 RawClass* Object::null_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 95 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 96 RawClass* Object::dynamic_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 96 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 97 RawClass* Object::void_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 97 RawClass* Object::unresolved_class_class_ = | 98 RawClass* Object::unresolved_class_class_ = |
| 98 reinterpret_cast<RawClass*>(RAW_NULL); | 99 reinterpret_cast<RawClass*>(RAW_NULL); |
| 99 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL); | 100 RawClass* Object::type_arguments_class_ = reinterpret_cast<RawClass*>(RAW_NULL); |
| 100 RawClass* Object::instantiated_type_arguments_class_ = | 101 RawClass* Object::instantiated_type_arguments_class_ = |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 353 null_abstract_type_arguments_ = AbstractTypeArguments::ReadOnlyHandle(); | 354 null_abstract_type_arguments_ = AbstractTypeArguments::ReadOnlyHandle(); |
| 354 empty_array_ = Array::ReadOnlyHandle(); | 355 empty_array_ = Array::ReadOnlyHandle(); |
| 355 sentinel_ = Instance::ReadOnlyHandle(); | 356 sentinel_ = Instance::ReadOnlyHandle(); |
| 356 transition_sentinel_ = Instance::ReadOnlyHandle(); | 357 transition_sentinel_ = Instance::ReadOnlyHandle(); |
| 357 unknown_constant_ = Instance::ReadOnlyHandle(); | 358 unknown_constant_ = Instance::ReadOnlyHandle(); |
| 358 non_constant_ = Instance::ReadOnlyHandle(); | 359 non_constant_ = Instance::ReadOnlyHandle(); |
| 359 bool_true_ = Bool::ReadOnlyHandle(); | 360 bool_true_ = Bool::ReadOnlyHandle(); |
| 360 bool_false_ = Bool::ReadOnlyHandle(); | 361 bool_false_ = Bool::ReadOnlyHandle(); |
| 361 smi_illegal_cid_ = Smi::ReadOnlyHandle(); | 362 smi_illegal_cid_ = Smi::ReadOnlyHandle(); |
| 362 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); | 363 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); |
| 364 branch_offset_error_ = LanguageError::ReadOnlyHandle(); | |
| 365 | |
| 363 | 366 |
| 364 // Allocate and initialize the null instance. | 367 // Allocate and initialize the null instance. |
| 365 // 'null_' must be the first object allocated as it is used in allocation to | 368 // 'null_' must be the first object allocated as it is used in allocation to |
| 366 // clear the object. | 369 // clear the object. |
| 367 { | 370 { |
| 368 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); | 371 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); |
| 369 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); | 372 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); |
| 370 // The call below is using 'null_' to initialize itself. | 373 // The call below is using 'null_' to initialize itself. |
| 371 InitializeObject(address, kNullCid, Instance::InstanceSize()); | 374 InitializeObject(address, kNullCid, Instance::InstanceSize()); |
| 372 } | 375 } |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 563 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); | 566 reinterpret_cast<RawArray*>(address + kHeapObjectTag)); |
| 564 empty_array_->raw()->ptr()->length_ = Smi::New(0); | 567 empty_array_->raw()->ptr()->length_ = Smi::New(0); |
| 565 } | 568 } |
| 566 | 569 |
| 567 // Allocate and initialize singleton true and false boolean objects. | 570 // Allocate and initialize singleton true and false boolean objects. |
| 568 cls = Class::New<Bool>(); | 571 cls = Class::New<Bool>(); |
| 569 isolate->object_store()->set_bool_class(cls); | 572 isolate->object_store()->set_bool_class(cls); |
| 570 *bool_true_ = Bool::New(true); | 573 *bool_true_ = Bool::New(true); |
| 571 *bool_false_ = Bool::New(false); | 574 *bool_false_ = Bool::New(false); |
| 572 | 575 |
| 573 *smi_illegal_cid_ = Smi::New(kIllegalCid); | 576 *smi_illegal_cid_ = Smi::New(kIllegalCid); |
|
siva
2013/08/09 18:54:03
String& error_str = String::Handle();
error_str =
zra
2013/08/09 19:50:36
Done.
| |
| 574 *snapshot_writer_error_ = | 577 *snapshot_writer_error_ = |
| 575 LanguageError::New(String::Handle(String::New("SnapshotWriter Error"))); | 578 LanguageError::New(String::Handle(String::New("SnapshotWriter Error"))); |
| 579 *branch_offset_error_ = | |
| 580 LanguageError::New(String::Handle(String::New("Branch offset overflow"))); | |
| 576 | 581 |
| 577 ASSERT(!null_object_->IsSmi()); | 582 ASSERT(!null_object_->IsSmi()); |
| 578 ASSERT(!null_array_->IsSmi()); | 583 ASSERT(!null_array_->IsSmi()); |
| 579 ASSERT(null_array_->IsArray()); | 584 ASSERT(null_array_->IsArray()); |
| 580 ASSERT(!null_string_->IsSmi()); | 585 ASSERT(!null_string_->IsSmi()); |
| 581 ASSERT(null_string_->IsString()); | 586 ASSERT(null_string_->IsString()); |
| 582 ASSERT(!null_instance_->IsSmi()); | 587 ASSERT(!null_instance_->IsSmi()); |
| 583 ASSERT(null_instance_->IsInstance()); | 588 ASSERT(null_instance_->IsInstance()); |
| 584 ASSERT(!null_abstract_type_arguments_->IsSmi()); | 589 ASSERT(!null_abstract_type_arguments_->IsSmi()); |
| 585 ASSERT(null_abstract_type_arguments_->IsAbstractTypeArguments()); | 590 ASSERT(null_abstract_type_arguments_->IsAbstractTypeArguments()); |
| 586 ASSERT(!empty_array_->IsSmi()); | 591 ASSERT(!empty_array_->IsSmi()); |
| 587 ASSERT(empty_array_->IsArray()); | 592 ASSERT(empty_array_->IsArray()); |
| 588 ASSERT(!sentinel_->IsSmi()); | 593 ASSERT(!sentinel_->IsSmi()); |
| 589 ASSERT(sentinel_->IsInstance()); | 594 ASSERT(sentinel_->IsInstance()); |
| 590 ASSERT(!transition_sentinel_->IsSmi()); | 595 ASSERT(!transition_sentinel_->IsSmi()); |
| 591 ASSERT(transition_sentinel_->IsInstance()); | 596 ASSERT(transition_sentinel_->IsInstance()); |
| 592 ASSERT(!unknown_constant_->IsSmi()); | 597 ASSERT(!unknown_constant_->IsSmi()); |
| 593 ASSERT(unknown_constant_->IsInstance()); | 598 ASSERT(unknown_constant_->IsInstance()); |
| 594 ASSERT(!non_constant_->IsSmi()); | 599 ASSERT(!non_constant_->IsSmi()); |
| 595 ASSERT(non_constant_->IsInstance()); | 600 ASSERT(non_constant_->IsInstance()); |
| 596 ASSERT(!bool_true_->IsSmi()); | 601 ASSERT(!bool_true_->IsSmi()); |
| 597 ASSERT(bool_true_->IsBool()); | 602 ASSERT(bool_true_->IsBool()); |
| 598 ASSERT(!bool_false_->IsSmi()); | 603 ASSERT(!bool_false_->IsSmi()); |
| 599 ASSERT(bool_false_->IsBool()); | 604 ASSERT(bool_false_->IsBool()); |
| 600 ASSERT(smi_illegal_cid_->IsSmi()); | 605 ASSERT(smi_illegal_cid_->IsSmi()); |
| 601 ASSERT(!snapshot_writer_error_->IsSmi()); | 606 ASSERT(!snapshot_writer_error_->IsSmi()); |
| 602 ASSERT(snapshot_writer_error_->IsLanguageError()); | 607 ASSERT(snapshot_writer_error_->IsLanguageError()); |
| 608 ASSERT(!branch_offset_error_->IsSmi()); | |
| 609 ASSERT(branch_offset_error_->IsLanguageError()); | |
| 603 } | 610 } |
| 604 | 611 |
| 605 | 612 |
| 606 #define SET_CLASS_NAME(class_name, name) \ | 613 #define SET_CLASS_NAME(class_name, name) \ |
| 607 cls = class_name##_class(); \ | 614 cls = class_name##_class(); \ |
| 608 cls.set_name(Symbols::name()); \ | 615 cls.set_name(Symbols::name()); \ |
| 609 | 616 |
| 610 void Object::RegisterSingletonClassNames() { | 617 void Object::RegisterSingletonClassNames() { |
| 611 Class& cls = Class::Handle(); | 618 Class& cls = Class::Handle(); |
| 612 | 619 |
| (...skipping 13964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 14577 } | 14584 } |
| 14578 | 14585 |
| 14579 | 14586 |
| 14580 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { | 14587 void MirrorReference::PrintToJSONStream(JSONStream* stream, bool ref) const { |
| 14581 stream->OpenObject(); | 14588 stream->OpenObject(); |
| 14582 stream->CloseObject(); | 14589 stream->CloseObject(); |
| 14583 } | 14590 } |
| 14584 | 14591 |
| 14585 | 14592 |
| 14586 } // namespace dart | 14593 } // namespace dart |
| OLD | NEW |