| 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 Code::Comments& comments = Code::Comments::New(comments_.length()); | 234 Code::Comments& comments = Code::Comments::New(comments_.length()); |
| 235 | 235 |
| 236 for (intptr_t i = 0; i < comments_.length(); i++) { | 236 for (intptr_t i = 0; i < comments_.length(); i++) { |
| 237 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); | 237 comments.SetPCOffsetAt(i, comments_[i]->pc_offset()); |
| 238 comments.SetCommentAt(i, comments_[i]->comment()); | 238 comments.SetCommentAt(i, comments_[i]->comment()); |
| 239 } | 239 } |
| 240 | 240 |
| 241 return comments; | 241 return comments; |
| 242 } | 242 } |
| 243 | 243 |
| 244 |
| 245 intptr_t ObjectPool::AddObject(const Object& obj, Patchability patchable) { |
| 246 if (object_pool_.IsNull()) { |
| 247 // The object pool cannot be used in the vm isolate. |
| 248 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 249 object_pool_ = GrowableObjectArray::New(Heap::kOld); |
| 250 } |
| 251 object_pool_.Add(obj, Heap::kOld); |
| 252 patchable_pool_entries_.Add(patchable); |
| 253 if (patchable == kNotPatchable) { |
| 254 // The object isn't patchable. Record the index for fast lookup. |
| 255 object_pool_index_table_.Insert( |
| 256 ObjIndexPair(&obj, object_pool_.Length() - 1)); |
| 257 } |
| 258 return object_pool_.Length() - 1; |
| 259 } |
| 260 |
| 261 |
| 262 intptr_t ObjectPool::AddExternalLabel(const ExternalLabel* label, |
| 263 Patchability patchable) { |
| 264 // The object pool cannot be used in the vm isolate. |
| 265 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 266 ASSERT(!object_pool_.IsNull()); |
| 267 const uword address = label->address(); |
| 268 ASSERT(Utils::IsAligned(address, 4)); |
| 269 // The address is stored in the object array as a RawSmi. |
| 270 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address)); |
| 271 return AddObject(smi, patchable); |
| 272 } |
| 273 |
| 274 |
| 275 intptr_t ObjectPool::FindObject(const Object& obj, Patchability patchable) { |
| 276 // The object pool cannot be used in the vm isolate. |
| 277 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 278 ASSERT(!object_pool_.IsNull()); |
| 279 |
| 280 // If the object is not patchable, check if we've already got it in the |
| 281 // object pool. |
| 282 if (patchable == kNotPatchable) { |
| 283 intptr_t idx = object_pool_index_table_.Lookup(&obj); |
| 284 if (idx != ObjIndexPair::kNoIndex) { |
| 285 ASSERT(patchable_pool_entries_[idx] == kNotPatchable); |
| 286 return idx; |
| 287 } |
| 288 } |
| 289 |
| 290 return AddObject(obj, patchable); |
| 291 } |
| 292 |
| 293 |
| 294 intptr_t ObjectPool::FindExternalLabel(const ExternalLabel* label, |
| 295 Patchability patchable) { |
| 296 // The object pool cannot be used in the vm isolate. |
| 297 ASSERT(Isolate::Current() != Dart::vm_isolate()); |
| 298 ASSERT(!object_pool_.IsNull()); |
| 299 const uword address = label->address(); |
| 300 ASSERT(Utils::IsAligned(address, 4)); |
| 301 // The address is stored in the object array as a RawSmi. |
| 302 const Smi& smi = Smi::Handle(reinterpret_cast<RawSmi*>(address)); |
| 303 return FindObject(smi, patchable); |
| 304 } |
| 305 |
| 306 |
| 244 } // namespace dart | 307 } // namespace dart |
| OLD | NEW |