OLD | NEW |
1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 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 "../include/v8-profiler.h" |
| 32 |
31 #include "list-inl.h" | 33 #include "list-inl.h" |
32 | 34 |
33 namespace v8 { | 35 namespace v8 { |
34 namespace internal { | 36 namespace internal { |
35 | 37 |
36 // Structure for tracking global handles. | 38 // Structure for tracking global handles. |
37 // A single list keeps all the allocated global handles. | 39 // A single list keeps all the allocated global handles. |
38 // Destroyed handles stay in the list but is added to the free list. | 40 // Destroyed handles stay in the list but is added to the free list. |
39 // At GC the destroyed global handles are removed from the free list | 41 // At GC the destroyed global handles are removed from the free list |
40 // and deallocated. | 42 // and deallocated. |
41 | 43 |
42 // An object group is treated like a single JS object: if one of object in | 44 // An object group is treated like a single JS object: if one of object in |
43 // the group is alive, all objects in the same group are considered alive. | 45 // the group is alive, all objects in the same group are considered alive. |
44 // An object group is used to simulate object relationship in a DOM tree. | 46 // An object group is used to simulate object relationship in a DOM tree. |
45 class ObjectGroup { | 47 class ObjectGroup { |
46 public: | 48 public: |
47 static ObjectGroup* New(Object*** handles, | 49 static ObjectGroup* New(Object*** handles, |
48 size_t length, | 50 size_t length, |
49 v8::RetainedObjectInfo* info) { | 51 v8::RetainedObjectInfo* info) { |
50 ASSERT(length > 0); | 52 ASSERT(length > 0); |
51 ObjectGroup* group = reinterpret_cast<ObjectGroup*>( | 53 ObjectGroup* group = reinterpret_cast<ObjectGroup*>( |
52 malloc(OFFSET_OF(ObjectGroup, objects_[length]))); | 54 malloc(OFFSET_OF(ObjectGroup, objects_[length]))); |
53 group->length_ = length; | 55 group->length_ = length; |
54 group->info_ = info; | 56 group->info_ = info; |
55 CopyWords(group->objects_, handles, static_cast<int>(length)); | 57 CopyWords(group->objects_, handles, static_cast<int>(length)); |
56 return group; | 58 return group; |
57 } | 59 } |
58 | 60 |
59 void Dispose() { | 61 void Dispose() { |
| 62 if (info_ != NULL) info_->Dispose(); |
60 free(this); | 63 free(this); |
61 } | 64 } |
62 | 65 |
63 size_t length_; | 66 size_t length_; |
64 v8::RetainedObjectInfo* info_; | 67 v8::RetainedObjectInfo* info_; |
65 Object** objects_[1]; // Variable sized array. | 68 Object** objects_[1]; // Variable sized array. |
66 | 69 |
67 private: | 70 private: |
68 void* operator new(size_t size); | 71 void* operator new(size_t size); |
69 void operator delete(void* p); | 72 void operator delete(void* p); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 262 |
260 friend class Isolate; | 263 friend class Isolate; |
261 | 264 |
262 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); | 265 DISALLOW_COPY_AND_ASSIGN(GlobalHandles); |
263 }; | 266 }; |
264 | 267 |
265 | 268 |
266 } } // namespace v8::internal | 269 } } // namespace v8::internal |
267 | 270 |
268 #endif // V8_GLOBAL_HANDLES_H_ | 271 #endif // V8_GLOBAL_HANDLES_H_ |
OLD | NEW |