| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef V8_GLOBAL_HANDLES_H_ | 28 #ifndef V8_GLOBAL_HANDLES_H_ |
| 29 #define V8_GLOBAL_HANDLES_H_ | 29 #define V8_GLOBAL_HANDLES_H_ |
| 30 | 30 |
| 31 #include <vector> |
| 32 |
| 31 #include "../include/v8.h" | 33 #include "../include/v8.h" |
| 32 #include "../include/v8-profiler.h" | 34 #include "../include/v8-profiler.h" |
| 33 | 35 |
| 34 #include "list.h" | 36 #include "list.h" |
| 35 #include "v8utils.h" | 37 #include "v8utils.h" |
| 36 | 38 |
| 37 namespace v8 { | 39 namespace v8 { |
| 38 namespace internal { | 40 namespace internal { |
| 39 | 41 |
| 40 class GCTracer; | 42 class GCTracer; |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 List<ObjectGroupConnection> object_group_connections_; | 326 List<ObjectGroupConnection> object_group_connections_; |
| 325 List<ObjectGroupRetainerInfo> retainer_infos_; | 327 List<ObjectGroupRetainerInfo> retainer_infos_; |
| 326 List<ObjectGroupConnection> implicit_ref_connections_; | 328 List<ObjectGroupConnection> implicit_ref_connections_; |
| 327 | 329 |
| 328 friend class Isolate; | 330 friend class Isolate; |
| 329 | 331 |
| 330 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 332 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
| 331 }; | 333 }; |
| 332 | 334 |
| 333 | 335 |
| 336 class EternalHandles { |
| 337 public: |
| 338 static const int kInvalidIndex = -1; |
| 339 enum IndexedHandle { |
| 340 I18N_TEMPLATE_ONE, |
| 341 I18N_TEMPLATE_TWO, |
| 342 |
| 343 LAST_INDEX = I18N_TEMPLATE_TWO |
| 344 }; |
| 345 |
| 346 EternalHandles(); |
| 347 ~EternalHandles(); |
| 348 |
| 349 int NumberOfHandles() { return size_; } |
| 350 |
| 351 int Create(Isolate* isolate, Object* object); |
| 352 |
| 353 inline Object** Get(int index) { |
| 354 ASSERT(index >= 0 && index < size_); |
| 355 return &blocks_[index >> kShift][index & kMask]; |
| 356 } |
| 357 |
| 358 inline int GetIndex(IndexedHandle i) { |
| 359 return indexed_handles_[i]; |
| 360 } |
| 361 |
| 362 int CreateIndexed(Isolate* isolate, Object* object, IndexedHandle i) { |
| 363 ASSERT(GetIndex(i) == kInvalidIndex); |
| 364 indexed_handles_[i] = Create(isolate, object); |
| 365 return indexed_handles_[i]; |
| 366 } |
| 367 |
| 368 void IterateAllRoots(ObjectVisitor* visitor); |
| 369 |
| 370 private: |
| 371 static const int kShift = 8; |
| 372 static const int kSize = 1 << kShift; |
| 373 static const int kMask = 0xff; |
| 374 typedef std::vector<Object**> BlockStore; |
| 375 int size_; |
| 376 Object*** blocks_; |
| 377 BlockStore block_store_; |
| 378 int indexed_handles_[LAST_INDEX+1]; |
| 379 |
| 380 DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
| 381 }; |
| 382 |
| 383 |
| 334 } } // namespace v8::internal | 384 } } // namespace v8::internal |
| 335 | 385 |
| 336 #endif // V8_GLOBAL_HANDLES_H_ | 386 #endif // V8_GLOBAL_HANDLES_H_ |
| OLD | NEW |