| 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/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 7684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7695 instrs.EntryPoint(), | 7695 instrs.EntryPoint(), |
| 7696 assembler->prologue_offset(), | 7696 assembler->prologue_offset(), |
| 7697 instrs.size(), | 7697 instrs.size(), |
| 7698 optimized); | 7698 optimized); |
| 7699 | 7699 |
| 7700 const ZoneGrowableArray<int>& pointer_offsets = | 7700 const ZoneGrowableArray<int>& pointer_offsets = |
| 7701 assembler->GetPointerOffsets(); | 7701 assembler->GetPointerOffsets(); |
| 7702 | 7702 |
| 7703 // Allocate the code object. | 7703 // Allocate the code object. |
| 7704 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length())); | 7704 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length())); |
| 7705 | |
| 7706 // Clone the object pool in the old space, if necessary. | |
| 7707 Array& object_pool = Array::Handle( | |
| 7708 Array::MakeArray(assembler->object_pool())); | |
| 7709 if (!object_pool.IsOld()) { | |
| 7710 object_pool ^= Object::Clone(object_pool, Heap::kOld); | |
| 7711 } | |
| 7712 { | 7705 { |
| 7713 NoGCScope no_gc; | 7706 NoGCScope no_gc; |
| 7714 | 7707 |
| 7715 // Set pointer offsets list in Code object and resolve all handles in | 7708 // Set pointer offsets list in Code object and resolve all handles in |
| 7716 // the instruction stream to raw objects. | 7709 // the instruction stream to raw objects. |
| 7717 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); | 7710 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); |
| 7718 for (int i = 0; i < pointer_offsets.length(); i++) { | 7711 for (int i = 0; i < pointer_offsets.length(); i++) { |
| 7719 int offset_in_instrs = pointer_offsets[i]; | 7712 int offset_in_instrs = pointer_offsets[i]; |
| 7720 code.SetPointerOffsetAt(i, offset_in_instrs); | 7713 code.SetPointerOffsetAt(i, offset_in_instrs); |
| 7721 const Object* object = region.Load<const Object*>(offset_in_instrs); | 7714 const Object* object = region.Load<const Object*>(offset_in_instrs); |
| 7722 region.Store<RawObject*>(offset_in_instrs, object->raw()); | 7715 region.Store<RawObject*>(offset_in_instrs, object->raw()); |
| 7723 } | 7716 } |
| 7724 | 7717 |
| 7725 // Hook up Code and Instructions objects. | 7718 // Hook up Code and Instructions objects. |
| 7726 instrs.set_code(code.raw()); | 7719 instrs.set_code(code.raw()); |
| 7727 code.set_instructions(instrs.raw()); | 7720 code.set_instructions(instrs.raw()); |
| 7728 | 7721 |
| 7729 // Set object pool in Instructions object. | 7722 // Set object pool in Instructions object. |
| 7730 instrs.set_object_pool(object_pool.raw()); | 7723 const GrowableObjectArray& object_pool = assembler->object_pool(); |
| 7724 if (object_pool.IsNull()) { |
| 7725 instrs.set_object_pool(Object::empty_array().raw()); |
| 7726 } else { |
| 7727 // TODO(regis): Once MakeArray takes a Heap::Space argument, call it here |
| 7728 // with Heap::kOld and change the ARM and MIPS assemblers to work with a |
| 7729 // GrowableObjectArray in new space. |
| 7730 instrs.set_object_pool(Array::MakeArray(object_pool)); |
| 7731 } |
| 7731 } | 7732 } |
| 7732 return code.raw(); | 7733 return code.raw(); |
| 7733 } | 7734 } |
| 7734 | 7735 |
| 7735 | 7736 |
| 7736 RawCode* Code::FinalizeCode(const Function& function, | 7737 RawCode* Code::FinalizeCode(const Function& function, |
| 7737 Assembler* assembler, | 7738 Assembler* assembler, |
| 7738 bool optimized) { | 7739 bool optimized) { |
| 7739 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. | 7740 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| 7740 if (CodeObservers::AreActive()) { | 7741 if (CodeObservers::AreActive()) { |
| (...skipping 4478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12219 Object& obj = Object::Handle(); | 12220 Object& obj = Object::Handle(); |
| 12220 for (int i = 0; i < len; i++) { | 12221 for (int i = 0; i < len; i++) { |
| 12221 obj = source.At(i); | 12222 obj = source.At(i); |
| 12222 result.SetAt(i, obj); | 12223 result.SetAt(i, obj); |
| 12223 } | 12224 } |
| 12224 return result.raw(); | 12225 return result.raw(); |
| 12225 } | 12226 } |
| 12226 | 12227 |
| 12227 | 12228 |
| 12228 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) { | 12229 RawArray* Array::MakeArray(const GrowableObjectArray& growable_array) { |
| 12229 if (growable_array.IsNull()) { | 12230 ASSERT(!growable_array.IsNull()); |
| 12230 return Array::null(); | 12231 intptr_t used_len = growable_array.Length(); |
| 12232 if (used_len == 0) { |
| 12233 return Object::empty_array().raw(); |
| 12231 } | 12234 } |
| 12232 intptr_t used_len = growable_array.Length(); | |
| 12233 intptr_t capacity_len = growable_array.Capacity(); | 12235 intptr_t capacity_len = growable_array.Capacity(); |
| 12234 Isolate* isolate = Isolate::Current(); | 12236 Isolate* isolate = Isolate::Current(); |
| 12235 const Array& array = Array::Handle(isolate, growable_array.data()); | 12237 const Array& array = Array::Handle(isolate, growable_array.data()); |
| 12236 intptr_t capacity_size = Array::InstanceSize(capacity_len); | 12238 intptr_t capacity_size = Array::InstanceSize(capacity_len); |
| 12237 intptr_t used_size = Array::InstanceSize(used_len); | 12239 intptr_t used_size = Array::InstanceSize(used_len); |
| 12238 NoGCScope no_gc; | 12240 NoGCScope no_gc; |
| 12239 | 12241 |
| 12240 // Update the size in the header field and length of the array object. | 12242 // Update the size in the header field and length of the array object. |
| 12241 uword tags = array.raw_ptr()->tags_; | 12243 uword tags = array.raw_ptr()->tags_; |
| 12242 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); | 12244 ASSERT(kArrayCid == RawObject::ClassIdTag::decode(tags)); |
| (...skipping 1424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13667 } | 13669 } |
| 13668 return result.raw(); | 13670 return result.raw(); |
| 13669 } | 13671 } |
| 13670 | 13672 |
| 13671 | 13673 |
| 13672 const char* WeakProperty::ToCString() const { | 13674 const char* WeakProperty::ToCString() const { |
| 13673 return "_WeakProperty"; | 13675 return "_WeakProperty"; |
| 13674 } | 13676 } |
| 13675 | 13677 |
| 13676 } // namespace dart | 13678 } // namespace dart |
| OLD | NEW |