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 2972 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2983 | 2983 |
2984 | 2984 |
2985 void Class::AddField(const Field& field) const { | 2985 void Class::AddField(const Field& field) const { |
2986 const Array& arr = Array::Handle(fields()); | 2986 const Array& arr = Array::Handle(fields()); |
2987 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); | 2987 const Array& new_arr = Array::Handle(Array::Grow(arr, arr.Length() + 1)); |
2988 new_arr.SetAt(arr.Length(), field); | 2988 new_arr.SetAt(arr.Length(), field); |
2989 SetFields(new_arr); | 2989 SetFields(new_arr); |
2990 } | 2990 } |
2991 | 2991 |
2992 | 2992 |
2993 void Class::AddFields(const GrowableObjectArray& new_fields) const { | 2993 void Class::AddFields(const GrowableArray<const Field*>& new_fields) const { |
2994 const intptr_t num_new_fields = new_fields.Length(); | 2994 const intptr_t num_new_fields = new_fields.length(); |
2995 if (num_new_fields == 0) return; | 2995 if (num_new_fields == 0) return; |
2996 const Array& arr = Array::Handle(fields()); | 2996 const Array& arr = Array::Handle(fields()); |
2997 const intptr_t num_old_fields = arr.Length(); | 2997 const intptr_t num_old_fields = arr.Length(); |
2998 const Array& new_arr = Array::Handle( | 2998 const Array& new_arr = Array::Handle( |
2999 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); | 2999 Array::Grow(arr, num_old_fields + num_new_fields, Heap::kOld)); |
3000 Field& field = Field::Handle(); | |
3001 for (intptr_t i = 0; i < num_new_fields; i++) { | 3000 for (intptr_t i = 0; i < num_new_fields; i++) { |
3002 field ^= new_fields.At(i); | 3001 new_arr.SetAt(i + num_old_fields, *new_fields.At(i)); |
3003 new_arr.SetAt(i + num_old_fields, field); | |
3004 } | 3002 } |
3005 SetFields(new_arr); | 3003 SetFields(new_arr); |
3006 } | 3004 } |
3007 | 3005 |
3008 | 3006 |
3009 intptr_t Class::FindFieldIndex(const Field& needle) const { | 3007 intptr_t Class::FindFieldIndex(const Field& needle) const { |
3010 Isolate* isolate = Isolate::Current(); | 3008 Isolate* isolate = Isolate::Current(); |
3011 if (EnsureIsFinalized(isolate) != Error::null()) { | 3009 if (EnsureIsFinalized(isolate) != Error::null()) { |
3012 return -1; | 3010 return -1; |
3013 } | 3011 } |
(...skipping 8614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
11628 uword size = ExceptionHandlers::InstanceSize(num_handlers); | 11626 uword size = ExceptionHandlers::InstanceSize(num_handlers); |
11629 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, | 11627 RawObject* raw = Object::Allocate(ExceptionHandlers::kClassId, |
11630 size, | 11628 size, |
11631 Heap::kOld); | 11629 Heap::kOld); |
11632 NoSafepointScope no_safepoint; | 11630 NoSafepointScope no_safepoint; |
11633 result ^= raw; | 11631 result ^= raw; |
11634 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); | 11632 result.StoreNonPointer(&result.raw_ptr()->num_entries_, num_handlers); |
11635 } | 11633 } |
11636 const Array& handled_types_data = (num_handlers == 0) ? | 11634 const Array& handled_types_data = (num_handlers == 0) ? |
11637 Object::empty_array() : | 11635 Object::empty_array() : |
11638 Array::Handle(Array::New(num_handlers)); | 11636 Array::Handle(Array::New(num_handlers, Heap::kOld)); |
11639 result.set_handled_types_data(handled_types_data); | 11637 result.set_handled_types_data(handled_types_data); |
11640 return result.raw(); | 11638 return result.raw(); |
11641 } | 11639 } |
11642 | 11640 |
11643 | 11641 |
11644 RawExceptionHandlers* ExceptionHandlers::New(const Array& handled_types_data) { | 11642 RawExceptionHandlers* ExceptionHandlers::New(const Array& handled_types_data) { |
11645 ASSERT(Object::exception_handlers_class() != Class::null()); | 11643 ASSERT(Object::exception_handlers_class() != Class::null()); |
11646 const intptr_t num_handlers = handled_types_data.Length(); | 11644 const intptr_t num_handlers = handled_types_data.Length(); |
11647 if ((num_handlers < 0) || (num_handlers >= kMaxHandlers)) { | 11645 if ((num_handlers < 0) || (num_handlers >= kMaxHandlers)) { |
11648 FATAL1("Fatal error in ExceptionHandlers::New(): " | 11646 FATAL1("Fatal error in ExceptionHandlers::New(): " |
(...skipping 2171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13820 SubtypeTestCache& result = SubtypeTestCache::Handle(); | 13818 SubtypeTestCache& result = SubtypeTestCache::Handle(); |
13821 { | 13819 { |
13822 // SubtypeTestCache objects are long living objects, allocate them in the | 13820 // SubtypeTestCache objects are long living objects, allocate them in the |
13823 // old generation. | 13821 // old generation. |
13824 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, | 13822 RawObject* raw = Object::Allocate(SubtypeTestCache::kClassId, |
13825 SubtypeTestCache::InstanceSize(), | 13823 SubtypeTestCache::InstanceSize(), |
13826 Heap::kOld); | 13824 Heap::kOld); |
13827 NoSafepointScope no_safepoint; | 13825 NoSafepointScope no_safepoint; |
13828 result ^= raw; | 13826 result ^= raw; |
13829 } | 13827 } |
13830 const Array& cache = Array::Handle(Array::New(kTestEntryLength)); | 13828 const Array& cache = Array::Handle(Array::New(kTestEntryLength, Heap::kOld)); |
13831 result.set_cache(cache); | 13829 result.set_cache(cache); |
13832 return result.raw(); | 13830 return result.raw(); |
13833 } | 13831 } |
13834 | 13832 |
13835 | 13833 |
13836 void SubtypeTestCache::set_cache(const Array& value) const { | 13834 void SubtypeTestCache::set_cache(const Array& value) const { |
13837 StorePointer(&raw_ptr()->cache_, value.raw()); | 13835 StorePointer(&raw_ptr()->cache_, value.raw()); |
13838 } | 13836 } |
13839 | 13837 |
13840 | 13838 |
(...skipping 7594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
21435 return tag_label.ToCString(); | 21433 return tag_label.ToCString(); |
21436 } | 21434 } |
21437 | 21435 |
21438 | 21436 |
21439 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { | 21437 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { |
21440 Instance::PrintJSONImpl(stream, ref); | 21438 Instance::PrintJSONImpl(stream, ref); |
21441 } | 21439 } |
21442 | 21440 |
21443 | 21441 |
21444 } // namespace dart | 21442 } // namespace dart |
OLD | NEW |