| 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/assembler.h" | 5 #include "vm/assembler.h" |
| 6 | 6 |
| 7 #include "platform/utils.h" | 7 #include "platform/utils.h" |
| 8 #include "vm/cpu.h" | 8 #include "vm/cpu.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 buffer_->has_ensured_capacity_ = false; | 55 buffer_->has_ensured_capacity_ = false; |
| 56 // Make sure the generated instruction doesn't take up more | 56 // Make sure the generated instruction doesn't take up more |
| 57 // space than the minimum gap. | 57 // space than the minimum gap. |
| 58 intptr_t delta = gap_ - ComputeGap(); | 58 intptr_t delta = gap_ - ComputeGap(); |
| 59 ASSERT(delta <= kMinimumGap); | 59 ASSERT(delta <= kMinimumGap); |
| 60 } | 60 } |
| 61 #endif | 61 #endif |
| 62 | 62 |
| 63 | 63 |
| 64 AssemblerBuffer::AssemblerBuffer() | 64 AssemblerBuffer::AssemblerBuffer() |
| 65 : pointer_offsets_(new ZoneGrowableArray<int>(16)) { | 65 : pointer_offsets_(new ZoneGrowableArray<intptr_t>(16)) { |
| 66 static const intptr_t kInitialBufferCapacity = 4 * KB; | 66 static const intptr_t kInitialBufferCapacity = 4 * KB; |
| 67 contents_ = NewContents(kInitialBufferCapacity); | 67 contents_ = NewContents(kInitialBufferCapacity); |
| 68 cursor_ = contents_; | 68 cursor_ = contents_; |
| 69 limit_ = ComputeLimit(contents_, kInitialBufferCapacity); | 69 limit_ = ComputeLimit(contents_, kInitialBufferCapacity); |
| 70 fixup_ = NULL; | 70 fixup_ = NULL; |
| 71 #if defined(DEBUG) | 71 #if defined(DEBUG) |
| 72 has_ensured_capacity_ = false; | 72 has_ensured_capacity_ = false; |
| 73 fixups_processed_ = false; | 73 fixups_processed_ = false; |
| 74 #endif | 74 #endif |
| 75 | 75 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 limit_ = ComputeLimit(new_contents, new_capacity); | 129 limit_ = ComputeLimit(new_contents, new_capacity); |
| 130 | 130 |
| 131 // Verify internal state. | 131 // Verify internal state. |
| 132 ASSERT(Capacity() == new_capacity); | 132 ASSERT(Capacity() == new_capacity); |
| 133 ASSERT(Size() == old_size); | 133 ASSERT(Size() == old_size); |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 class PatchCodeWithHandle : public AssemblerFixup { | 137 class PatchCodeWithHandle : public AssemblerFixup { |
| 138 public: | 138 public: |
| 139 PatchCodeWithHandle(ZoneGrowableArray<int>* pointer_offsets, | 139 PatchCodeWithHandle(ZoneGrowableArray<intptr_t>* pointer_offsets, |
| 140 const Object& object) | 140 const Object& object) |
| 141 : pointer_offsets_(pointer_offsets), object_(object) { | 141 : pointer_offsets_(pointer_offsets), object_(object) { |
| 142 } | 142 } |
| 143 | 143 |
| 144 void Process(const MemoryRegion& region, int position) { | 144 void Process(const MemoryRegion& region, intptr_t position) { |
| 145 // Patch the handle into the code. Once the instructions are installed into | 145 // Patch the handle into the code. Once the instructions are installed into |
| 146 // a raw code object and the pointer offsets are setup, the handle is | 146 // a raw code object and the pointer offsets are setup, the handle is |
| 147 // resolved. | 147 // resolved. |
| 148 region.Store<const Object*>(position, &object_); | 148 region.Store<const Object*>(position, &object_); |
| 149 pointer_offsets_->Add(position); | 149 pointer_offsets_->Add(position); |
| 150 } | 150 } |
| 151 | 151 |
| 152 private: | 152 private: |
| 153 ZoneGrowableArray<int>* pointer_offsets_; | 153 ZoneGrowableArray<intptr_t>* pointer_offsets_; |
| 154 const Object& object_; | 154 const Object& object_; |
| 155 }; | 155 }; |
| 156 | 156 |
| 157 | 157 |
| 158 void AssemblerBuffer::EmitObject(const Object& object) { | 158 void AssemblerBuffer::EmitObject(const Object& object) { |
| 159 // Since we are going to store the handle as part of the fixup information | 159 // Since we are going to store the handle as part of the fixup information |
| 160 // the handle needs to be a zone handle. | 160 // the handle needs to be a zone handle. |
| 161 ASSERT(object.IsNotTemporaryScopedHandle()); | 161 ASSERT(object.IsNotTemporaryScopedHandle()); |
| 162 ASSERT(object.IsOld()); | 162 ASSERT(object.IsOld()); |
| 163 EmitFixup(new PatchCodeWithHandle(pointer_offsets_, object)); | 163 EmitFixup(new PatchCodeWithHandle(pointer_offsets_, object)); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 | 213 |
| 214 for (intptr_t i = 0; i < comments_.length(); i++) { | 214 for (intptr_t i = 0; i < comments_.length(); i++) { |
| 215 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); | 215 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); |
| 216 comments.SetCommentAt(i, comments_[i]->comment()); | 216 comments.SetCommentAt(i, comments_[i]->comment()); |
| 217 } | 217 } |
| 218 | 218 |
| 219 return comments; | 219 return comments; |
| 220 } | 220 } |
| 221 | 221 |
| 222 } // namespace dart | 222 } // namespace dart |
| OLD | NEW |