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 4647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5089 StorePointer(&raw_ptr()->patched_class_, value.raw()); | 5097 StorePointer(&raw_ptr()->patched_class_, value.raw()); |
5090 } | 5098 } |
5091 | 5099 |
5092 | 5100 |
5093 void PatchClass::set_source_class(const Class& value) const { | 5101 void PatchClass::set_source_class(const Class& value) const { |
5094 StorePointer(&raw_ptr()->source_class_, value.raw()); | 5102 StorePointer(&raw_ptr()->source_class_, value.raw()); |
5095 } | 5103 } |
5096 | 5104 |
5097 | 5105 |
5098 bool Function::HasBreakpoint() const { | 5106 bool Function::HasBreakpoint() const { |
| 5107 ASSERT(Isolate::Current()->debugger() != NULL); |
5099 return Isolate::Current()->debugger()->HasBreakpoint(*this); | 5108 return Isolate::Current()->debugger()->HasBreakpoint(*this); |
5100 } | 5109 } |
5101 | 5110 |
5102 | 5111 |
5103 void Function::SetInstructions(const Code& value) const { | 5112 void Function::SetInstructions(const Code& value) const { |
5104 StorePointer(&raw_ptr()->instructions_, value.instructions()); | 5113 StorePointer(&raw_ptr()->instructions_, value.instructions()); |
5105 } | 5114 } |
5106 | 5115 |
5107 void Function::AttachCode(const Code& value) const { | 5116 void Function::AttachCode(const Code& value) const { |
5108 SetInstructions(value); | 5117 SetInstructions(value); |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5620 } | 5629 } |
5621 | 5630 |
5622 | 5631 |
5623 void Function::SetIsNativeAutoSetupScope(bool value) const { | 5632 void Function::SetIsNativeAutoSetupScope(bool value) const { |
5624 ASSERT(is_native()); | 5633 ASSERT(is_native()); |
5625 set_is_optimizable(value); | 5634 set_is_optimizable(value); |
5626 } | 5635 } |
5627 | 5636 |
5628 | 5637 |
5629 bool Function::CanBeInlined() const { | 5638 bool Function::CanBeInlined() const { |
| 5639 ASSERT(Isolate::Current()->debugger() != NULL); |
5630 return is_inlinable() && | 5640 return is_inlinable() && |
5631 !is_generated_body() && | 5641 !is_generated_body() && |
5632 HasCode() && | 5642 HasCode() && |
5633 !Isolate::Current()->debugger()->HasBreakpoint(*this); | 5643 !Isolate::Current()->debugger()->HasBreakpoint(*this); |
5634 } | 5644 } |
5635 | 5645 |
5636 | 5646 |
5637 intptr_t Function::NumParameters() const { | 5647 intptr_t Function::NumParameters() const { |
5638 return num_fixed_parameters() + NumOptionalParameters(); | 5648 return num_fixed_parameters() + NumOptionalParameters(); |
5639 } | 5649 } |
(...skipping 6582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12222 for (intptr_t i = kSCallTableEntryLength; | 12232 for (intptr_t i = kSCallTableEntryLength; |
12223 i < value.Length(); | 12233 i < value.Length(); |
12224 i += kSCallTableEntryLength) { | 12234 i += kSCallTableEntryLength) { |
12225 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); | 12235 ASSERT(value.At(i - kSCallTableEntryLength) < value.At(i)); |
12226 } | 12236 } |
12227 #endif // DEBUG | 12237 #endif // DEBUG |
12228 } | 12238 } |
12229 | 12239 |
12230 | 12240 |
12231 bool Code::HasBreakpoint() const { | 12241 bool Code::HasBreakpoint() const { |
| 12242 ASSERT(Isolate::Current()->debugger() != NULL); |
12232 return Isolate::Current()->debugger()->HasBreakpoint(*this); | 12243 return Isolate::Current()->debugger()->HasBreakpoint(*this); |
12233 } | 12244 } |
12234 | 12245 |
12235 | 12246 |
12236 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, | 12247 RawTypedData* Code::GetDeoptInfoAtPc(uword pc, |
12237 ICData::DeoptReasonId* deopt_reason, | 12248 ICData::DeoptReasonId* deopt_reason, |
12238 uint32_t* deopt_flags) const { | 12249 uint32_t* deopt_flags) const { |
12239 ASSERT(is_optimized()); | 12250 ASSERT(is_optimized()); |
12240 const Instructions& instrs = Instructions::Handle(instructions()); | 12251 const Instructions& instrs = Instructions::Handle(instructions()); |
12241 uword code_entry = instrs.EntryPoint(); | 12252 uword code_entry = instrs.EntryPoint(); |
(...skipping 8610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
20852 return tag_label.ToCString(); | 20863 return tag_label.ToCString(); |
20853 } | 20864 } |
20854 | 20865 |
20855 | 20866 |
20856 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 20867 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
20857 Instance::PrintJSONImpl(stream, ref); | 20868 Instance::PrintJSONImpl(stream, ref); |
20858 } | 20869 } |
20859 | 20870 |
20860 | 20871 |
20861 } // namespace dart | 20872 } // namespace dart |
OLD | NEW |