OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2014 Google Inc. All rights reserved. | 2 * Copyright (C) 2014 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... |
41 int GCInfoTable::s_gcInfoIndex = 0; | 41 int GCInfoTable::s_gcInfoIndex = 0; |
42 | 42 |
43 size_t GCInfoTable::s_gcInfoTableSize = 0; | 43 size_t GCInfoTable::s_gcInfoTableSize = 0; |
44 GCInfo const** s_gcInfoTable = nullptr; | 44 GCInfo const** s_gcInfoTable = nullptr; |
45 | 45 |
46 void GCInfoTable::ensureGCInfoIndex(const GCInfo* gcInfo, size_t* gcInfoIndexSlo
t) | 46 void GCInfoTable::ensureGCInfoIndex(const GCInfo* gcInfo, size_t* gcInfoIndexSlo
t) |
47 { | 47 { |
48 ASSERT(gcInfo); | 48 ASSERT(gcInfo); |
49 ASSERT(gcInfoIndexSlot); | 49 ASSERT(gcInfoIndexSlot); |
50 // Keep a global GCInfoTable lock while allocating a new slot. | 50 // Keep a global GCInfoTable lock while allocating a new slot. |
51 AtomicallyInitializedStatic(Mutex&, mutex = *new Mutex); | 51 AtomicallyInitializedStaticReference(Mutex, mutex, new Mutex); |
52 MutexLocker locker(mutex); | 52 MutexLocker locker(mutex); |
53 | 53 |
54 // If more than one thread ends up allocating a slot for | 54 // If more than one thread ends up allocating a slot for |
55 // the same GCInfo, have later threads reuse the slot | 55 // the same GCInfo, have later threads reuse the slot |
56 // allocated by the first. | 56 // allocated by the first. |
57 if (*gcInfoIndexSlot) | 57 if (*gcInfoIndexSlot) |
58 return; | 58 return; |
59 | 59 |
60 int index = ++s_gcInfoIndex; | 60 int index = ++s_gcInfoIndex; |
61 size_t gcInfoIndex = static_cast<size_t>(index); | 61 size_t gcInfoIndex = static_cast<size_t>(index); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 #if !defined(COMPONENT_BUILD) | 102 #if !defined(COMPONENT_BUILD) |
103 // On component builds we cannot compare the gcInfos as they are statically | 103 // On component builds we cannot compare the gcInfos as they are statically |
104 // defined in each of the components and hence will not match. | 104 // defined in each of the components and hence will not match. |
105 BaseHeapPage* page = pageFromObject(payload); | 105 BaseHeapPage* page = pageFromObject(payload); |
106 ASSERT(page->orphaned() || HeapObjectHeader::fromPayload(payload)->gcInfoInd
ex() == gcInfoIndex); | 106 ASSERT(page->orphaned() || HeapObjectHeader::fromPayload(payload)->gcInfoInd
ex() == gcInfoIndex); |
107 #endif | 107 #endif |
108 } | 108 } |
109 #endif | 109 #endif |
110 | 110 |
111 } | 111 } |
OLD | NEW |