OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 int TokenEnumerator::GetTokenId(Object* token) { | 60 int TokenEnumerator::GetTokenId(Object* token) { |
61 Isolate* isolate = Isolate::Current(); | 61 Isolate* isolate = Isolate::Current(); |
62 if (token == NULL) return TokenEnumerator::kNoSecurityToken; | 62 if (token == NULL) return TokenEnumerator::kNoSecurityToken; |
63 for (int i = 0; i < token_locations_.length(); ++i) { | 63 for (int i = 0; i < token_locations_.length(); ++i) { |
64 if (*token_locations_[i] == token && !token_removed_[i]) return i; | 64 if (*token_locations_[i] == token && !token_removed_[i]) return i; |
65 } | 65 } |
66 Handle<Object> handle = isolate->global_handles()->Create(token); | 66 Handle<Object> handle = isolate->global_handles()->Create(token); |
67 // handle.location() points to a memory cell holding a pointer | 67 // handle.location() points to a memory cell holding a pointer |
68 // to a token object in the V8's heap. | 68 // to a token object in the V8's heap. |
69 isolate->global_handles()->MakeWeak(handle.location(), this, | 69 isolate->global_handles()->MakeWeak(handle.location(), |
| 70 this, |
| 71 NULL, |
70 TokenRemovedCallback); | 72 TokenRemovedCallback); |
71 token_locations_.Add(handle.location()); | 73 token_locations_.Add(handle.location()); |
72 token_removed_.Add(false); | 74 token_removed_.Add(false); |
73 return token_locations_.length() - 1; | 75 return token_locations_.length() - 1; |
74 } | 76 } |
75 | 77 |
76 | 78 |
77 void TokenEnumerator::TokenRemovedCallback(v8::Persistent<v8::Value> handle, | 79 void TokenEnumerator::TokenRemovedCallback(v8::Isolate* isolate, |
| 80 v8::Persistent<v8::Value> handle, |
78 void* parameter) { | 81 void* parameter) { |
79 reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved( | 82 reinterpret_cast<TokenEnumerator*>(parameter)->TokenRemoved( |
80 Utils::OpenHandle(*handle).location()); | 83 Utils::OpenHandle(*handle).location()); |
81 handle.Dispose(); | 84 handle.Dispose(isolate); |
82 } | 85 } |
83 | 86 |
84 | 87 |
85 void TokenEnumerator::TokenRemoved(Object** token_location) { | 88 void TokenEnumerator::TokenRemoved(Object** token_location) { |
86 for (int i = 0; i < token_locations_.length(); ++i) { | 89 for (int i = 0; i < token_locations_.length(); ++i) { |
87 if (token_locations_[i] == token_location && !token_removed_[i]) { | 90 if (token_locations_[i] == token_location && !token_removed_[i]) { |
88 token_removed_[i] = true; | 91 token_removed_[i] = true; |
89 return; | 92 return; |
90 } | 93 } |
91 } | 94 } |
(...skipping 3488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3580 | 3583 |
3581 | 3584 |
3582 void HeapSnapshotJSONSerializer::SortHashMap( | 3585 void HeapSnapshotJSONSerializer::SortHashMap( |
3583 HashMap* map, List<HashMap::Entry*>* sorted_entries) { | 3586 HashMap* map, List<HashMap::Entry*>* sorted_entries) { |
3584 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) | 3587 for (HashMap::Entry* p = map->Start(); p != NULL; p = map->Next(p)) |
3585 sorted_entries->Add(p); | 3588 sorted_entries->Add(p); |
3586 sorted_entries->Sort(SortUsingEntryValue); | 3589 sorted_entries->Sort(SortUsingEntryValue); |
3587 } | 3590 } |
3588 | 3591 |
3589 } } // namespace v8::internal | 3592 } } // namespace v8::internal |
OLD | NEW |