| 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 7656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7667 instrs.EntryPoint(), | 7667 instrs.EntryPoint(), |
| 7668 assembler->prologue_offset(), | 7668 assembler->prologue_offset(), |
| 7669 instrs.size(), | 7669 instrs.size(), |
| 7670 optimized); | 7670 optimized); |
| 7671 | 7671 |
| 7672 const ZoneGrowableArray<int>& pointer_offsets = | 7672 const ZoneGrowableArray<int>& pointer_offsets = |
| 7673 assembler->GetPointerOffsets(); | 7673 assembler->GetPointerOffsets(); |
| 7674 | 7674 |
| 7675 // Allocate the code object. | 7675 // Allocate the code object. |
| 7676 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length())); | 7676 Code& code = Code::ZoneHandle(Code::New(pointer_offsets.length())); |
| 7677 |
| 7678 // Clone the object pool in the old space, if necessary. |
| 7679 Array& object_pool = Array::Handle( |
| 7680 Array::MakeArray(assembler->object_pool())); |
| 7681 if (!object_pool.IsOld()) { |
| 7682 object_pool ^= Object::Clone(object_pool, Heap::kOld); |
| 7683 } |
| 7677 { | 7684 { |
| 7678 NoGCScope no_gc; | 7685 NoGCScope no_gc; |
| 7679 | 7686 |
| 7680 // Set pointer offsets list in Code object and resolve all handles in | 7687 // Set pointer offsets list in Code object and resolve all handles in |
| 7681 // the instruction stream to raw objects. | 7688 // the instruction stream to raw objects. |
| 7682 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); | 7689 ASSERT(code.pointer_offsets_length() == pointer_offsets.length()); |
| 7683 for (int i = 0; i < pointer_offsets.length(); i++) { | 7690 for (int i = 0; i < pointer_offsets.length(); i++) { |
| 7684 int offset_in_instrs = pointer_offsets[i]; | 7691 int offset_in_instrs = pointer_offsets[i]; |
| 7685 code.SetPointerOffsetAt(i, offset_in_instrs); | 7692 code.SetPointerOffsetAt(i, offset_in_instrs); |
| 7686 const Object* object = region.Load<const Object*>(offset_in_instrs); | 7693 const Object* object = region.Load<const Object*>(offset_in_instrs); |
| 7687 region.Store<RawObject*>(offset_in_instrs, object->raw()); | 7694 region.Store<RawObject*>(offset_in_instrs, object->raw()); |
| 7688 } | 7695 } |
| 7689 | 7696 |
| 7690 // Hook up Code and Instructions objects. | 7697 // Hook up Code and Instructions objects. |
| 7691 instrs.set_code(code.raw()); | 7698 instrs.set_code(code.raw()); |
| 7692 code.set_instructions(instrs.raw()); | 7699 code.set_instructions(instrs.raw()); |
| 7693 | 7700 |
| 7694 // Set object pool in Instructions object. | 7701 // Set object pool in Instructions object. |
| 7695 instrs.set_object_pool(Array::MakeArray(assembler->object_pool())); | 7702 instrs.set_object_pool(object_pool.raw()); |
| 7696 } | 7703 } |
| 7697 return code.raw(); | 7704 return code.raw(); |
| 7698 } | 7705 } |
| 7699 | 7706 |
| 7700 | 7707 |
| 7701 RawCode* Code::FinalizeCode(const Function& function, | 7708 RawCode* Code::FinalizeCode(const Function& function, |
| 7702 Assembler* assembler, | 7709 Assembler* assembler, |
| 7703 bool optimized) { | 7710 bool optimized) { |
| 7704 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. | 7711 // Calling ToFullyQualifiedCString is very expensive, try to avoid it. |
| 7705 if (CodeObservers::AreActive()) { | 7712 if (CodeObservers::AreActive()) { |
| (...skipping 5926 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13632 } | 13639 } |
| 13633 return result.raw(); | 13640 return result.raw(); |
| 13634 } | 13641 } |
| 13635 | 13642 |
| 13636 | 13643 |
| 13637 const char* WeakProperty::ToCString() const { | 13644 const char* WeakProperty::ToCString() const { |
| 13638 return "_WeakProperty"; | 13645 return "_WeakProperty"; |
| 13639 } | 13646 } |
| 13640 | 13647 |
| 13641 } // namespace dart | 13648 } // namespace dart |
| OLD | NEW |