Lines Matching refs:segment
42 // Segment ID (SID) is in range [1, kMaxSID-1]
43 // Segment Set ID (SSID) is in range [-kMaxSID+1, -1]
221 // Segment ID.
257 // Singleton: id > 0 (id == Segment's id)
1639 // -------- Segment -------------------{{{1
1640 class Segment {
1701 Segment *seg = GetInternal(sid);
1707 Printf("Segment: reused SID %d\n", sid.raw());
1715 Segment *seg = GetSegmentByIndex(n_segments_);
1723 Printf("Segment: allocated SID %d\n", n_segments_);
1734 // Initialize the contents of the given segment.
1740 Segment *seg = GetInternal(sid);
1756 ScopedMallocCostCenter malloc_cc("Segment::AddNewSegment()");
1764 Segment *seg = GetInternal(sid);
1771 Printf("Segment::AssertLive: failed on sid=%d n_segments = %dline=%d\n",
1774 Segment *seg = GetInternal(sid);
1776 Printf("Segment::AssertLive: failed on sid=%d line=%d\n",
1784 static INLINE Segment *Get(SID sid) {
1786 Segment *res = GetInternal(sid);
1793 Segment *seg = GetInternal(sid);
1798 Printf("Segment: recycled SID %d\n", sid.raw());
1803 ScopedMallocCostCenter malloc_cc("Segment::RecycleOneSid()");
1804 Segment *seg = GetInternal(sid);
1818 Segment *seg = GetInternal(sid);
1828 Segment *seg = GetInternal(sid);
1863 Segment *seg = Get(sid);
1880 const Segment *seg_a = Get(a);
1881 const Segment *seg_b = Get(b);
1896 Printf("Segment::ShowSegmentStats:\n");
1901 Segment *seg = GetInternal(SID(i));
1916 (sizeof(Segment) * kMaxSID) >> 20,
1917 sizeof(Segment), kMaxSID >> 20);
1923 all_segments_ = new Segment[kMaxSID];
1925 memset(all_segments_, 0, kMaxSID * sizeof(Segment));
1927 memset(all_segments_, -1, sizeof(Segment));
1941 static INLINE Segment *GetSegmentByIndex(int32_t index) {
1944 static INLINE Segment *GetInternal(SID sid) {
1947 Segment *res = GetSegmentByIndex(sid.raw());
1962 static Segment *all_segments_;
1977 Segment *Segment::all_segments_;
1978 uintptr_t **Segment::all_stacks_;
1979 size_t Segment::n_stack_chunks_;
1980 int32_t Segment::n_segments_;
1981 vector<SID> *Segment::reusable_sids_;
2004 Segment::AssertLive(ssid.GetSingleton(), line);
2050 Segment::Unref(sid, "SegmentSet::Recycle");
2062 Segment::Ref(ssid.GetSingleton(), where);
2074 Segment::Unref(ssid.GetSingleton(), where);
2135 return "{" + Segment::ToStringTidOnly(SID(ssid.raw())) + "}";
2188 Segment::AssertLive(ssid.GetSingleton(), line);
2193 Segment::AssertLive(sid, line);
2215 static Segment *GetSegmentForNonSingleton(SSID ssid, int32_t i, int line) {
2216 return Segment::Get(GetSID(ssid, i, line));
2284 Segment::Ref(sid, "SegmentSet::FindExistingOrAlocateAndCopy");
2475 if (Segment::HappensBeforeOrSameThread(sid, sid_to_remove))
2497 Segment::AssertLive(new_sid, __LINE__);
2507 Segment::AssertLive(old_sid, __LINE__);
2510 // The new segment equals the old one - nothing has changed.
2514 old_tid = Segment::Get(old_sid)->tid();
2515 new_tid = Segment::Get(new_sid)->tid();
2517 // The new segment is in the same thread - just replace the SID.
2521 if (Segment::HappensBefore(old_sid, new_sid)) {
2522 // The new segment is in another thread, but old segment
2527 DCHECK(!Segment::HappensBefore(new_sid, old_sid));
2548 DCHECK(!Segment::HappensBefore(new_sid, old_sid));
2549 DCHECK(!Segment::HappensBefore(old_sid, new_sid));
2580 Segment::AssertLive(sid, __LINE__);
2581 if (Segment::HappensBeforeOrSameThread(sid, sid_to_remove))
2582 continue; // Skip this segment from the result.
2604 Segment::AssertLive(new_sid, __LINE__);
2605 const Segment *new_seg = Segment::Get(new_sid);
2617 Segment::AssertLive(sid, __LINE__);
2618 const Segment *seg = Segment::Get(sid);
2631 // Optimization: if a segment with the same VTS and LS
2636 // we have another segment from the same thread => replace it.
2643 // there was no segment with this tid, put it now.
2648 if (!Segment::HappensBefore(sid, new_sid)) {
2649 DCHECK(!Segment::HappensBefore(new_sid, sid));
2665 // we need to forget one segment. Which? The oldest one.
2667 Segment *oldest_segment = NULL;
2671 Segment *s = Segment::Get(tmp_sids[i]);
2707 Segment::AssertLive(sid1, __LINE__);
2712 Segment::AssertLive(sid2, __LINE__);
2714 bool hb1 = Segment::HappensBefore(sid1, sid2);
2715 bool hb2 = Segment::HappensBefore(sid2, sid1);
2719 Segment::ToString(sid1).c_str(),
2720 Segment::ToString(sid2).c_str(),
2721 Segment::Get(sid1)->vts()->ToString().c_str(),
2722 Segment::Get(sid2)->vts()->ToString().c_str());
2724 CHECK(!Segment::HappensBefore(GetSID(i), GetSID(j)));
2725 CHECK(!Segment::HappensBefore(GetSID(j), GetSID(i)));
2726 CHECK(Segment::Get(sid1)->tid() < Segment::Get(sid2)->tid());
2741 res += Segment::ToStringWithLocks(sid);
2753 Segment::AssertLive(sid, __LINE__);
2754 res += Segment::ToStringTidOnly(sid).c_str();
2763 SID sid1 = Segment::AddNewSegment(TID(0), VTS::Parse("[0:2;]"), ls, ls);
2764 SID sid2 = Segment::AddNewSegment(TID(1), VTS::Parse("[0:1; 1:1]"), ls, ls);
2765 SID sid3 = Segment::AddNewSegment(TID(2), VTS::Parse("[0:1; 2:1]"), ls, ls);
2766 SID sid4 = Segment::AddNewSegment(TID(3), VTS::Parse("[0:1; 3:1]"), ls, ls);
2767 SID sid5 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 2:2; 3:2;]"),
2769 SID sid6 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 1:2; 2:2; 3:2;]"),
3498 for (int i = 1; i < Segment::NumberOfSegments(); i++) {
3499 if (Segment::ProfileSeg(SID(i)) && all_sids.count(SID(i)) == 0) {
3500 // Printf("Segment SID %d: missing in storage; ref=%d\n", i,
3501 // Segment::Get(SID(i))->ref_count());
4012 // the same VTS and LS as the current segment.
4014 // recent segment if it is the same or not used anymore (see Search()).
4031 Segment::Ref(sid, "RecentSegmentsCache::ShortenQueue");
4041 // TODO(timurrrr): we can probably move the matched segment to the head
4047 Segment::AssertLive(sid, __LINE__);
4048 Segment *seg = Segment::Get(sid);
4051 // The current segment is not used anywhere else,
4053 // The refcount of an unused segment is equal to
4055 // *) 2 if it is the current segment of the Thread.
4060 // Check three top entries of the call stack of the recent segment.
4061 // If they match the current segment stack, don't create a new segment.
4066 uintptr_t *emb_trace = Segment::embedded_stack_trace(sid);
4085 Segment::Unref(sid, "RecentSegmentsCache::ShortenQueue");
4450 Segment *segment() const {
4452 Segment::AssertLive(sid(), __LINE__);
4453 return Segment::Get(sid());
4457 return segment()->vts();
4689 Segment::ToString(sid()).c_str());
4709 vts()->ToString().c_str(), Segment::ToString(sid()).c_str(),
4720 SID new_sid = Segment::AddNewSegment(tid(), new_vts,
4728 Segment::Ref(new_sid, "Thread::NewSegmentWithoutUnrefingOld");
4731 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
4742 Segment::Unref(old_sid, "Thread::NewSegment");
4791 Segment::Ref(match, "Thread::HandleSblockEnter");
4797 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
4802 // We have a fresh ready-to-use segment in thread local cache.
4805 Segment::SetupFreshSid(fresh_sid, tid(), vts()->Clone(),
4808 Segment::Ref(fresh_sid, "Thread::HandleSblockEnter-1");
4811 FillEmbeddedStackTrace(Segment::embedded_stack_trace(sid()));
5172 // When creating a new segment on SBLOCK_ENTER, we need to get a fresh SID
5179 Segment::Unref(sid, where);
5181 if (Segment::UnrefNoRecycle(sid, where) == 0) {
5192 Segment::AssertLive(sid, __LINE__);
5193 DCHECK(Segment::Get(sid)->ref_count() == 0);
5194 Segment::RecycleOneSid(sid);
5214 Segment::AllocateFreshSegments(n_requested_sids, &fresh_sids_[cur_size]);
5219 Segment::RecycleOneFreshSid(fresh_sids_[i]);
5229 SID sid_; // Current segment ID.
5321 Segment *seg() { return Segment::Get(sid); }
5323 string StackTraceString() { return Segment::StackTraceString(sid); }
5338 // run out of some resources (most likely, segment IDs).
5366 Segment::ForgetAllState();
5396 if (Segment::NumberOfSegments() > kMaxSIDBeforeFlush) {
5400 Segment::ShowSegmentStats();
5402 ForgetAllStateAndStartOver(thr, "run out of segment IDs");
5622 Segment *seg = Segment::Get(thr->sid());
5632 Segment *seg = SegmentSet::GetSegmentForNonSingleton(ssid, s, __LINE__);
5648 Segment *seg = Segment::Get(concurrent_sid);
5649 if (Segment::HappensBeforeOrSameThread(concurrent_sid, sid)) continue;
5670 Report("%s", Segment::StackTraceString(concurrent_sid).c_str());
5706 uintptr_t concurrent_pc = *Segment::embedded_stack_trace(*it);
6275 // Are we out of segment IDs?
6521 VTS *vts = thread->segment()->vts()->Clone();
6557 VTS *vts = thread->segment()->vts();
6751 // return true if the current pair of read/write segment sets
6762 Segment *w1_seg = Segment::Get(w1_sid);
6767 LSID w2_ls = Segment::Get(ss->GetSID(w2))->lsid(true);
6779 Segment *r_seg = Segment::Get(r_sid);
6781 if (Segment::HappensBeforeOrSameThread(w1_sid, r_sid))
6856 // Tuple segment sets and check for race.
6877 if (tid == Segment::Get(wr_sid)->tid()) {
6888 Segment::Ref(cur_sid, "FastPath01");
6900 Segment::Ref(cur_sid, "FastPath00");
6908 // same segment.
6918 if (tid == Segment::Get(rd_sid)->tid()) {
6928 Segment::Ref(cur_sid, "FastPath10");
6938 if (tid == Segment::Get(wr_sid)->tid()) {
6950 if (tid == Segment::Get(rd_sid)->tid()) {
6961 } else if (tid == Segment::Get(rd_sid)->tid() &&
6962 tid == Segment::Get(wr_sid)->tid()) {
6972 Segment::Ref(cur_sid, "FastPath11");
7047 // singleton segment should have ref count > 0.
7049 Segment *seg = Segment::Get(sid);
7251 DCHECK(thr->lsid(false) == thr->segment()->lsid(false));
7252 DCHECK(thr->lsid(true) == thr->segment()->lsid(true));
7441 Segment::Ref(info.sid, __FUNCTION__);
7445 Segment::ToString(thr->sid()).c_str(),
7446 thr->segment()->vts()->ToString().c_str(),
7499 Segment::Unref(info->sid, __FUNCTION__);
7523 // Segment::Unref for all the unmapped memory.
7524 Segment::Unref(h_info->sid, __FUNCTION__);
7623 Segment::ToString(child->sid()).c_str(),
7660 Segment::AssertLive(parent_thr->sid(), __LINE__);
8372 ScopedMallocCostCenter cc1("Segment::InitClassMembers");
8373 Segment::InitClassMembers();
8512 // - Compress stack traces (64-bit only. may save up to 36 bytes per segment).