| 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 } else if (value == '\\') { | 371 } else if (value == '\\') { |
| 372 return '\\'; | 372 return '\\'; |
| 373 } else if (value == '$') { | 373 } else if (value == '$') { |
| 374 return '$'; | 374 return '$'; |
| 375 } | 375 } |
| 376 UNREACHABLE(); | 376 UNREACHABLE(); |
| 377 return '\0'; | 377 return '\0'; |
| 378 } | 378 } |
| 379 | 379 |
| 380 | 380 |
| 381 void Object::InitNull(Isolate* isolate) { |
| 382 // Should only be run by the vm isolate. |
| 383 ASSERT(isolate == Dart::vm_isolate()); |
| 384 |
| 385 // TODO(iposva): NoSafepointScope needs to be added here. |
| 386 ASSERT(class_class() == null_); |
| 387 |
| 388 Heap* heap = isolate->heap(); |
| 389 |
| 390 // Allocate and initialize the null instance. |
| 391 // 'null_' must be the first object allocated as it is used in allocation to |
| 392 // clear the object. |
| 393 { |
| 394 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); |
| 395 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); |
| 396 // The call below is using 'null_' to initialize itself. |
| 397 InitializeObject(address, kNullCid, Instance::InstanceSize()); |
| 398 } |
| 399 } |
| 400 |
| 401 |
| 381 void Object::InitOnce(Isolate* isolate) { | 402 void Object::InitOnce(Isolate* isolate) { |
| 382 // Should only be run by the vm isolate. | 403 // Should only be run by the vm isolate. |
| 383 ASSERT(isolate == Dart::vm_isolate()); | 404 ASSERT(isolate == Dart::vm_isolate()); |
| 384 | 405 |
| 385 // TODO(iposva): NoSafepointScope needs to be added here. | |
| 386 ASSERT(class_class() == null_); | |
| 387 // Initialize the static vtable values. | 406 // Initialize the static vtable values. |
| 388 { | 407 { |
| 389 Object fake_object; | 408 Object fake_object; |
| 390 Smi fake_smi; | 409 Smi fake_smi; |
| 391 Object::handle_vtable_ = fake_object.vtable(); | 410 Object::handle_vtable_ = fake_object.vtable(); |
| 392 Smi::handle_vtable_ = fake_smi.vtable(); | 411 Smi::handle_vtable_ = fake_smi.vtable(); |
| 393 } | 412 } |
| 394 | 413 |
| 395 Heap* heap = isolate->heap(); | 414 Heap* heap = isolate->heap(); |
| 396 | 415 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 411 transition_sentinel_ = Instance::ReadOnlyHandle(); | 430 transition_sentinel_ = Instance::ReadOnlyHandle(); |
| 412 unknown_constant_ = Instance::ReadOnlyHandle(); | 431 unknown_constant_ = Instance::ReadOnlyHandle(); |
| 413 non_constant_ = Instance::ReadOnlyHandle(); | 432 non_constant_ = Instance::ReadOnlyHandle(); |
| 414 bool_true_ = Bool::ReadOnlyHandle(); | 433 bool_true_ = Bool::ReadOnlyHandle(); |
| 415 bool_false_ = Bool::ReadOnlyHandle(); | 434 bool_false_ = Bool::ReadOnlyHandle(); |
| 416 smi_illegal_cid_ = Smi::ReadOnlyHandle(); | 435 smi_illegal_cid_ = Smi::ReadOnlyHandle(); |
| 417 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); | 436 snapshot_writer_error_ = LanguageError::ReadOnlyHandle(); |
| 418 branch_offset_error_ = LanguageError::ReadOnlyHandle(); | 437 branch_offset_error_ = LanguageError::ReadOnlyHandle(); |
| 419 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); | 438 vm_isolate_snapshot_object_table_ = Array::ReadOnlyHandle(); |
| 420 | 439 |
| 421 | |
| 422 // Allocate and initialize the null instance. | |
| 423 // 'null_' must be the first object allocated as it is used in allocation to | |
| 424 // clear the object. | |
| 425 { | |
| 426 uword address = heap->Allocate(Instance::InstanceSize(), Heap::kOld); | |
| 427 null_ = reinterpret_cast<RawInstance*>(address + kHeapObjectTag); | |
| 428 // The call below is using 'null_' to initialize itself. | |
| 429 InitializeObject(address, kNullCid, Instance::InstanceSize()); | |
| 430 } | |
| 431 | |
| 432 *null_object_ = Object::null(); | 440 *null_object_ = Object::null(); |
| 433 *null_array_ = Array::null(); | 441 *null_array_ = Array::null(); |
| 434 *null_string_ = String::null(); | 442 *null_string_ = String::null(); |
| 435 *null_instance_ = Instance::null(); | 443 *null_instance_ = Instance::null(); |
| 436 *null_type_arguments_ = TypeArguments::null(); | 444 *null_type_arguments_ = TypeArguments::null(); |
| 437 | 445 |
| 438 // Initialize the empty and zero array handles to null_ in order to be able to | 446 // Initialize the empty and zero array handles to null_ in order to be able to |
| 439 // check if the empty and zero arrays were allocated (RAW_NULL is not | 447 // check if the empty and zero arrays were allocated (RAW_NULL is not |
| 440 // available). | 448 // available). |
| 441 *empty_array_ = Array::null(); | 449 *empty_array_ = Array::null(); |
| (...skipping 20371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20813 return tag_label.ToCString(); | 20821 return tag_label.ToCString(); |
| 20814 } | 20822 } |
| 20815 | 20823 |
| 20816 | 20824 |
| 20817 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20825 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
| 20818 Instance::PrintJSONImpl(stream, ref); | 20826 Instance::PrintJSONImpl(stream, ref); |
| 20819 } | 20827 } |
| 20820 | 20828 |
| 20821 | 20829 |
| 20822 } // namespace dart | 20830 } // namespace dart |
| OLD | NEW |