| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 258   object_pool_.Add(entry); | 258   object_pool_.Add(entry); | 
| 259   if (patchable == kNotPatchable) { | 259   if (patchable == kNotPatchable) { | 
| 260     // The object isn't patchable. Record the index for fast lookup. | 260     // The object isn't patchable. Record the index for fast lookup. | 
| 261     object_pool_index_table_.Insert( | 261     object_pool_index_table_.Insert( | 
| 262         ObjIndexPair(entry, object_pool_.length() - 1)); | 262         ObjIndexPair(entry, object_pool_.length() - 1)); | 
| 263   } | 263   } | 
| 264   return object_pool_.length() - 1; | 264   return object_pool_.length() - 1; | 
| 265 } | 265 } | 
| 266 | 266 | 
| 267 | 267 | 
| 268 intptr_t ObjectPoolWrapper::AddExternalLabel(const ExternalLabel* label, |  | 
| 269                                              Patchability patchable) { |  | 
| 270   return AddObject(ObjectPool::Entry(label->address(), |  | 
| 271                                      ObjectPool::kExternalLabel), |  | 
| 272                    patchable); |  | 
| 273 } |  | 
| 274 |  | 
| 275 |  | 
| 276 intptr_t ObjectPoolWrapper::FindObject(ObjectPool::Entry entry, | 268 intptr_t ObjectPoolWrapper::FindObject(ObjectPool::Entry entry, | 
| 277                                        Patchability patchable) { | 269                                        Patchability patchable) { | 
| 278   // If the object is not patchable, check if we've already got it in the | 270   // If the object is not patchable, check if we've already got it in the | 
| 279   // object pool. | 271   // object pool. | 
| 280   if (patchable == kNotPatchable) { | 272   if (patchable == kNotPatchable) { | 
| 281     intptr_t idx = object_pool_index_table_.Lookup(entry); | 273     intptr_t idx = object_pool_index_table_.Lookup(entry); | 
| 282     if (idx != ObjIndexPair::kNoIndex) { | 274     if (idx != ObjIndexPair::kNoIndex) { | 
| 283       return idx; | 275       return idx; | 
| 284     } | 276     } | 
| 285   } | 277   } | 
| 286 | 278 | 
| 287   return AddObject(entry, patchable); | 279   return AddObject(entry, patchable); | 
| 288 } | 280 } | 
| 289 | 281 | 
| 290 | 282 | 
| 291 intptr_t ObjectPoolWrapper::FindObject(const Object& obj, | 283 intptr_t ObjectPoolWrapper::FindObject(const Object& obj, | 
| 292                                        Patchability patchable) { | 284                                        Patchability patchable) { | 
| 293   return FindObject(ObjectPool::Entry(&obj), patchable); | 285   return FindObject(ObjectPool::Entry(&obj), patchable); | 
| 294 } | 286 } | 
| 295 | 287 | 
| 296 | 288 | 
| 297 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) { | 289 intptr_t ObjectPoolWrapper::FindImmediate(uword imm) { | 
| 298   return FindObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), | 290   return FindObject(ObjectPool::Entry(imm, ObjectPool::kImmediate), | 
| 299                     kNotPatchable); | 291                     kNotPatchable); | 
| 300 } | 292 } | 
| 301 | 293 | 
| 302 | 294 | 
| 303 intptr_t ObjectPoolWrapper::FindExternalLabel(const ExternalLabel* label, |  | 
| 304                                               Patchability patchable) { |  | 
| 305   return FindObject(ObjectPool::Entry(label->address(), |  | 
| 306                                       ObjectPool::kExternalLabel), |  | 
| 307                     patchable); |  | 
| 308 } |  | 
| 309 |  | 
| 310 |  | 
| 311 intptr_t ObjectPoolWrapper::FindNativeEntry(const ExternalLabel* label, | 295 intptr_t ObjectPoolWrapper::FindNativeEntry(const ExternalLabel* label, | 
| 312                                             Patchability patchable) { | 296                                             Patchability patchable) { | 
| 313   return FindObject(ObjectPool::Entry(label->address(), | 297   return FindObject(ObjectPool::Entry(label->address(), | 
| 314                                       ObjectPool::kNativeEntry), | 298                                       ObjectPool::kNativeEntry), | 
| 315                     patchable); | 299                     patchable); | 
| 316 } | 300 } | 
| 317 | 301 | 
| 318 | 302 | 
| 319 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() { | 303 RawObjectPool* ObjectPoolWrapper::MakeObjectPool() { | 
| 320   intptr_t len = object_pool_.length(); | 304   intptr_t len = object_pool_.length(); | 
| 321   if (len == 0) { | 305   if (len == 0) { | 
| 322     return Object::empty_object_pool().raw(); | 306     return Object::empty_object_pool().raw(); | 
| 323   } | 307   } | 
| 324   const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len)); | 308   const ObjectPool& result = ObjectPool::Handle(ObjectPool::New(len)); | 
| 325   const TypedData& info_array = TypedData::Handle(result.info_array()); | 309   const TypedData& info_array = TypedData::Handle(result.info_array()); | 
| 326   for (intptr_t i = 0; i < len; ++i) { | 310   for (intptr_t i = 0; i < len; ++i) { | 
| 327     ObjectPool::EntryType info = object_pool_[i].type_; | 311     ObjectPool::EntryType info = object_pool_[i].type_; | 
| 328     info_array.SetInt8(i, static_cast<int8_t>(info)); | 312     info_array.SetInt8(i, static_cast<int8_t>(info)); | 
| 329     if (info == ObjectPool::kTaggedObject) { | 313     if (info == ObjectPool::kTaggedObject) { | 
| 330       result.SetObjectAt(i, *object_pool_[i].obj_); | 314       result.SetObjectAt(i, *object_pool_[i].obj_); | 
| 331     } else { | 315     } else { | 
| 332       result.SetRawValueAt(i, object_pool_[i].raw_value_); | 316       result.SetRawValueAt(i, object_pool_[i].raw_value_); | 
| 333     } | 317     } | 
| 334   } | 318   } | 
| 335   return result.raw(); | 319   return result.raw(); | 
| 336 } | 320 } | 
| 337 | 321 | 
| 338 | 322 | 
| 339 }  // namespace dart | 323 }  // namespace dart | 
| OLD | NEW | 
|---|