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 5360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5371 StorePointer(&raw_ptr()->patched_class_, value.raw()); | 5371 StorePointer(&raw_ptr()->patched_class_, value.raw()); |
5372 } | 5372 } |
5373 | 5373 |
5374 | 5374 |
5375 void PatchClass::set_source_class(const Class& value) const { | 5375 void PatchClass::set_source_class(const Class& value) const { |
5376 StorePointer(&raw_ptr()->source_class_, value.raw()); | 5376 StorePointer(&raw_ptr()->source_class_, value.raw()); |
5377 } | 5377 } |
5378 | 5378 |
5379 | 5379 |
5380 bool Function::HasBreakpoint() const { | 5380 bool Function::HasBreakpoint() const { |
5381 return Isolate::Current()->debugger()->HasBreakpoint(*this); | 5381 Thread* thread = Thread::Current(); |
| 5382 return thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); |
5382 } | 5383 } |
5383 | 5384 |
5384 | 5385 |
5385 void Function::SetInstructions(const Code& value) const { | 5386 void Function::SetInstructions(const Code& value) const { |
5386 StorePointer(&raw_ptr()->code_, value.raw()); | 5387 StorePointer(&raw_ptr()->code_, value.raw()); |
5387 StoreNonPointer(&raw_ptr()->entry_point_, value.EntryPoint()); | 5388 StoreNonPointer(&raw_ptr()->entry_point_, value.EntryPoint()); |
5388 } | 5389 } |
5389 | 5390 |
5390 void Function::AttachCode(const Code& value) const { | 5391 void Function::AttachCode(const Code& value) const { |
5391 // Finish setting up code before activating it. | 5392 // Finish setting up code before activating it. |
(...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5902 } | 5903 } |
5903 | 5904 |
5904 | 5905 |
5905 void Function::SetIsNativeAutoSetupScope(bool value) const { | 5906 void Function::SetIsNativeAutoSetupScope(bool value) const { |
5906 ASSERT(is_native()); | 5907 ASSERT(is_native()); |
5907 set_is_optimizable(value); | 5908 set_is_optimizable(value); |
5908 } | 5909 } |
5909 | 5910 |
5910 | 5911 |
5911 bool Function::CanBeInlined() const { | 5912 bool Function::CanBeInlined() const { |
| 5913 Thread* thread = Thread::Current(); |
5912 return is_inlinable() && | 5914 return is_inlinable() && |
5913 !is_generated_body() && | 5915 !is_generated_body() && |
5914 !Isolate::Current()->debugger()->HasBreakpoint(*this); | 5916 !thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone()); |
5915 } | 5917 } |
5916 | 5918 |
5917 | 5919 |
5918 intptr_t Function::NumParameters() const { | 5920 intptr_t Function::NumParameters() const { |
5919 return num_fixed_parameters() + NumOptionalParameters(); | 5921 return num_fixed_parameters() + NumOptionalParameters(); |
5920 } | 5922 } |
5921 | 5923 |
5922 | 5924 |
5923 intptr_t Function::NumImplicitParameters() const { | 5925 intptr_t Function::NumImplicitParameters() const { |
5924 if (kind() == RawFunction::kConstructor) { | 5926 if (kind() == RawFunction::kConstructor) { |
(...skipping 15705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21630 RawUserTag* UserTag::New(const String& label, Heap::Space space) { | 21632 RawUserTag* UserTag::New(const String& label, Heap::Space space) { |
21631 Thread* thread = Thread::Current(); | 21633 Thread* thread = Thread::Current(); |
21632 Isolate* isolate = thread->isolate(); | 21634 Isolate* isolate = thread->isolate(); |
21633 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 21635 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
21634 // Canonicalize by name. | 21636 // Canonicalize by name. |
21635 UserTag& result = UserTag::Handle(FindTagInIsolate(thread, label)); | 21637 UserTag& result = UserTag::Handle(FindTagInIsolate(thread, label)); |
21636 if (!result.IsNull()) { | 21638 if (!result.IsNull()) { |
21637 // Tag already exists, return existing instance. | 21639 // Tag already exists, return existing instance. |
21638 return result.raw(); | 21640 return result.raw(); |
21639 } | 21641 } |
21640 if (TagTableIsFull(isolate)) { | 21642 if (TagTableIsFull(thread)) { |
21641 const String& error = String::Handle( | 21643 const String& error = String::Handle( |
21642 String::NewFormatted("UserTag instance limit (%" Pd ") reached.", | 21644 String::NewFormatted("UserTag instance limit (%" Pd ") reached.", |
21643 UserTags::kMaxUserTags)); | 21645 UserTags::kMaxUserTags)); |
21644 const Array& args = Array::Handle(Array::New(1)); | 21646 const Array& args = Array::Handle(Array::New(1)); |
21645 args.SetAt(0, error); | 21647 args.SetAt(0, error); |
21646 Exceptions::ThrowByType(Exceptions::kUnsupported, args); | 21648 Exceptions::ThrowByType(Exceptions::kUnsupported, args); |
21647 } | 21649 } |
21648 // No tag with label exists, create and register with isolate tag table. | 21650 // No tag with label exists, create and register with isolate tag table. |
21649 { | 21651 { |
21650 RawObject* raw = Object::Allocate(UserTag::kClassId, | 21652 RawObject* raw = Object::Allocate(UserTag::kClassId, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21697 return UserTag::null(); | 21699 return UserTag::null(); |
21698 } | 21700 } |
21699 | 21701 |
21700 | 21702 |
21701 void UserTag::AddTagToIsolate(Thread* thread, const UserTag& tag) { | 21703 void UserTag::AddTagToIsolate(Thread* thread, const UserTag& tag) { |
21702 Isolate* isolate = thread->isolate(); | 21704 Isolate* isolate = thread->isolate(); |
21703 Zone* zone = thread->zone(); | 21705 Zone* zone = thread->zone(); |
21704 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 21706 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
21705 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( | 21707 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( |
21706 zone, isolate->tag_table()); | 21708 zone, isolate->tag_table()); |
21707 ASSERT(!TagTableIsFull(isolate)); | 21709 ASSERT(!TagTableIsFull(thread)); |
21708 #if defined(DEBUG) | 21710 #if defined(DEBUG) |
21709 // Verify that no existing tag has the same tag id. | 21711 // Verify that no existing tag has the same tag id. |
21710 UserTag& other = UserTag::Handle(isolate->current_zone()); | 21712 UserTag& other = UserTag::Handle(thread->zone()); |
21711 for (intptr_t i = 0; i < tag_table.Length(); i++) { | 21713 for (intptr_t i = 0; i < tag_table.Length(); i++) { |
21712 other ^= tag_table.At(i); | 21714 other ^= tag_table.At(i); |
21713 ASSERT(!other.IsNull()); | 21715 ASSERT(!other.IsNull()); |
21714 ASSERT(tag.tag() != other.tag()); | 21716 ASSERT(tag.tag() != other.tag()); |
21715 } | 21717 } |
21716 #endif | 21718 #endif |
21717 // Generate the UserTag tag id by taking the length of the isolate's | 21719 // Generate the UserTag tag id by taking the length of the isolate's |
21718 // tag table + kUserTagIdOffset. | 21720 // tag table + kUserTagIdOffset. |
21719 uword tag_id = tag_table.Length() + UserTags::kUserTagIdOffset; | 21721 uword tag_id = tag_table.Length() + UserTags::kUserTagIdOffset; |
21720 ASSERT(tag_id >= UserTags::kUserTagIdOffset); | 21722 ASSERT(tag_id >= UserTags::kUserTagIdOffset); |
21721 ASSERT(tag_id < (UserTags::kUserTagIdOffset + UserTags::kMaxUserTags)); | 21723 ASSERT(tag_id < (UserTags::kUserTagIdOffset + UserTags::kMaxUserTags)); |
21722 tag.set_tag(tag_id); | 21724 tag.set_tag(tag_id); |
21723 tag_table.Add(tag); | 21725 tag_table.Add(tag); |
21724 } | 21726 } |
21725 | 21727 |
21726 | 21728 |
21727 bool UserTag::TagTableIsFull(Isolate* isolate) { | 21729 bool UserTag::TagTableIsFull(Thread* thread) { |
| 21730 Isolate* isolate = thread->isolate(); |
21728 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 21731 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
21729 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( | 21732 const GrowableObjectArray& tag_table = GrowableObjectArray::Handle( |
21730 isolate->current_zone(), isolate->tag_table()); | 21733 thread->zone(), isolate->tag_table()); |
21731 ASSERT(tag_table.Length() <= UserTags::kMaxUserTags); | 21734 ASSERT(tag_table.Length() <= UserTags::kMaxUserTags); |
21732 return tag_table.Length() == UserTags::kMaxUserTags; | 21735 return tag_table.Length() == UserTags::kMaxUserTags; |
21733 } | 21736 } |
21734 | 21737 |
21735 | 21738 |
21736 RawUserTag* UserTag::FindTagById(uword tag_id) { | 21739 RawUserTag* UserTag::FindTagById(uword tag_id) { |
21737 Thread* thread = Thread::Current(); | 21740 Thread* thread = Thread::Current(); |
21738 Zone* zone = thread->zone(); | 21741 Zone* zone = thread->zone(); |
21739 Isolate* isolate = thread->isolate(); | 21742 Isolate* isolate = thread->isolate(); |
21740 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); | 21743 ASSERT(isolate->tag_table() != GrowableObjectArray::null()); |
(...skipping 15 matching lines...) Expand all Loading... |
21756 return tag_label.ToCString(); | 21759 return tag_label.ToCString(); |
21757 } | 21760 } |
21758 | 21761 |
21759 | 21762 |
21760 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21763 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21761 Instance::PrintJSONImpl(stream, ref); | 21764 Instance::PrintJSONImpl(stream, ref); |
21762 } | 21765 } |
21763 | 21766 |
21764 | 21767 |
21765 } // namespace dart | 21768 } // namespace dart |
OLD | NEW |