Home | History | Annotate | Download | only in tsan

Lines Matching refs:VTS

1123 // -------- VTS ------------------ {{{1
1124 class VTS {
1127 return sizeof(VTS) + size * sizeof(TS);
1137 static VTS *Create(size_t size) {
1144 ScopedMallocCostCenter cc("VTS::Create (from free list)");
1149 ScopedMallocCostCenter cc("VTS::Create (from new[])");
1153 VTS *res = new(mem) VTS(size);
1158 static void Unref(VTS *vts) {
1159 if (!vts) return;
1160 CHECK_GT(vts->ref_count_, 0);
1161 if (AtomicDecrementRefcount(&vts->ref_count_) == 0) {
1162 size_t size = vts->size_; // can't use vts->size().
1165 free_lists_[rounded_size]->Deallocate(vts);
1169 delete vts;
1175 static VTS *CreateSingleton(TID tid, int32_t clk = 1) {
1176 VTS *res = Create(1);
1182 VTS *Clone() {
1188 static VTS *CopyAndTick(const VTS *vts, TID id_to_tick) {
1189 CHECK(vts->ref_count_);
1190 VTS *res = Create(vts->size());
1193 res->arr_[i] = vts->arr_[i];
1203 static VTS *Join(const VTS *vts_a, const VTS *vts_b) {
1243 VTS *res = VTS::Create(t - result_ts.begin());
1265 static INLINE bool HappensBeforeCached(const VTS *vts_a, const VTS *vts_b) {
1278 static NOINLINE bool HappensBefore(const VTS *vts_a, const VTS *vts_b) {
1348 const VTS *vts1 = Parse(test_vts[i]);
1350 const VTS *vts2 = Parse(test_vts[j]);
1362 Printf("VTS::test();\n");
1363 VTS *v1 = CreateSingleton(TID(0));
1364 VTS *v2 = CreateSingleton(TID(1));
1365 VTS *v3 = CreateSingleton(TID(2));
1366 VTS *v4 = CreateSingleton(TID(3));
1368 VTS *v12 = Join(v1, v2);
1370 VTS *v34 = Join(v3, v4);
1373 VTS *x1 = Parse("[0:4; 3:6; 4:2;]");
1379 // Parse VTS string in the form "[0:4; 3:6; 4:2;]".
1380 static VTS *Parse(const char *str) {
1399 VTS *res = Create(vec.size());
1420 explicit VTS(size_t size)
1428 ~VTS() {}
1454 int32_t VTS::uniq_id_counter_;
1455 VTS::HBCache *VTS::hb_cache_;
1456 FreeList **VTS::free_lists_;
1459 // This class is somewhat similar to VTS,
1714 VTS *vts() const { return vts_; }
1767 DCHECK(!seg->vts());
1781 // This VTS may not be empty due to ForgetAllState().
1782 VTS::Unref(seg->vts_);
1799 static INLINE void SetupFreshSid(SID sid, TID tid, VTS *vts,
1801 DCHECK(vts);
1811 seg->vts_ = vts;
1818 static INLINE SID AddNewSegment(TID tid, VTS *vts,
1823 SetupFreshSid(sid, tid, vts, rd_lockset, wr_lockset);
1829 return seg->vts() != NULL;
1839 if (!seg->vts()) {
1843 DCHECK(seg->vts());
1851 DCHECK(res->vts());
1871 if (!seg->vts()) return false; // Already recycled.
1872 VTS::Unref(seg->vts_);
1947 const VTS *vts_a = seg_a->vts();
1948 const VTS *vts_b = seg_b->vts();
1949 res = VTS::HappensBeforeCached(vts_a, vts_b);
2022 VTS *vts_;
2163 // * otherwise, we recycle this SSID (delete its VTS, etc) and push
2696 if (seg->vts() == new_seg->vts() &&
2699 // Optimization: if a segment with the same VTS and LS
2741 oldest_segment->vts()->uniq_id() > s->vts()->uniq_id()) {
2789 Segment::Get(sid1)->vts()->ToString().c_str(),
2790 Segment::Get(sid2)->vts()->ToString().c_str());
2831 SID sid1 = Segment::AddNewSegment(TID(0), VTS::Parse("[0:2;]"), ls, ls);
2832 SID sid2 = Segment::AddNewSegment(TID(1), VTS::Parse("[0:1; 1:1]"), ls, ls);
2833 SID sid3 = Segment::AddNewSegment(TID(2), VTS::Parse("[0:1; 2:1]"), ls, ls);
2834 SID sid4 = Segment::AddNewSegment(TID(3), VTS::Parse("[0:1; 3:1]"), ls, ls);
2835 SID sid5 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 2:2; 3:2;]"),
2837 SID sid6 = Segment::AddNewSegment(TID(4), VTS::Parse("[0:3; 1:2; 2:2; 3:2;]"),
3631 VTS *vts; // The point where this range has been published.
3637 // Maps 'mem+size' to the PublishInfoMap{mem, size, vts}.
3642 // Get a VTS where 'a' has been published,
3644 static const VTS *GetPublisherVTS(uintptr_t a) {
3655 // Printf("GetPublisherVTS: a=%p vts=%p\n", a, info.vts);
3656 return info.vts;
3675 CHECK(info.vts);
3708 VTS::Unref(info.vts);
3718 // Publish range [a, b) in addr's CacheLine with vts.
3720 uintptr_t b, VTS *vts) {
3741 pub_info.vts = vts->Clone();
3745 Printf("PublishRange : [%p,%p) %p %s vts=%p\n",
3746 a, b, tag, pub_info.mask.ToString().c_str(), vts);
3751 static void PublishRange(TSanThread *thr, uintptr_t a, uintptr_t b, VTS *vts) {
3760 PublishRangeInOneLine(thr, tag, a - tag, b - tag, vts);
3764 PublishRangeInOneLine(thr, a, a - a_tag, CacheLine::kLineSize, vts);
3767 PublishRangeInOneLine(thr, tag_i, 0, CacheLine::kLineSize, vts);
3770 PublishRangeInOneLine(thr, line2_tag, 0, b - line2_tag, vts);
3949 // the same VTS and LS as the current segment.
3954 // VTS changes or we do ForgetAllState.
4138 VTS *vts;
4177 VTS::Unref(to_delete->vts);
4197 !VTS::HappensBeforeCached(r2->vts, r3->vts)) {
4236 TSanThread(TID tid, TID parent_tid, VTS *vts, StackTrace *creation_context,
4258 rand_state_((unsigned)(tid.raw() + (uintptr_t)vts
4262 NewSegmentWithoutUnrefingOld("TSanThread Creation", vts);
4405 VTS *vts() const {
4406 return segment()->vts();
4417 vts_at_exit_ = vts()->Clone();
4424 // Return the TID of the joined child and it's vts
4425 TID HandleThreadJoinAfter(VTS **vts_at_exit, TID joined_tid) {
4430 // In that case we just take the current vts.
4432 *vts_at_exit = joined_thread->vts()->Clone();
4470 atomicity_region->vts = vts()->Clone();
4617 (it->second.vts)->ToString().c_str());
4622 VTS::Unref(it->second.vts);
4638 const VTS *signaller_vts = it->second.vts;
4645 vts()->ToString().c_str(),
4655 if (!signaller->vts) {
4656 signaller->vts = vts()->Clone();
4658 VTS *new_vts = VTS::Join(signaller->vts, vts());
4659 VTS::Unref(signaller->vts);
4660 signaller->vts = new_vts;
4665 vts()->ToString().c_str(), Segment::ToString(sid()).c_str(),
4666 (signaller->vts)->ToString().c_str());
4674 VTS *new_vts) {
4679 if (old_sid.raw() != 0 && new_vts != vts()) {
4680 // Flush the cache if VTS changed - the VTS won't repeat.
4692 vts()->ToString().c_str());
4695 void INLINE NewSegment(const char *call_site, VTS *new_vts) {
4704 NewSegment(__FUNCTION__, vts()->Clone());
4710 NewSegment(__FUNCTION__, vts()->Clone());
4725 VTS *new_vts = vts()->Clone();
4761 Segment::SetupFreshSid(fresh_sid, tid(), vts()->Clone(),
4778 void NewSegmentForWait(const VTS *signaller_vts) {
4779 const VTS *current_vts = vts();
4785 if (!VTS::HappensBeforeCached(signaller_vts, current_vts)) {
4786 VTS *new_vts = VTS::Join(current_vts, signaller_vts);
4789 DCHECK(VTS::HappensBeforeCached(signaller_vts, vts()));
4793 VTS *cur_vts = vts();
4794 VTS *new_vts = VTS::CopyAndTick(cur_vts, tid());
4800 // 2. What was the vector clock of the parent thread (vts).
4804 VTS *vts;
4820 // Store ctx and vts under TID(0).
4823 info.vts = vts()->Clone();
4824 CHECK(info.ctx && info.vts);
4826 // Tick vts.
4849 void HandleChildThreadStart(TID child_tid, VTS **vts, StackTrace **ctx) {
4856 CHECK(info.ctx && info.vts);
4861 CHECK(info.ctx && info.vts);
4866 info.vts = parent->vts()->Clone();
4870 VTS *singleton = VTS::CreateSingleton(child_tid);
4871 *vts = VTS::Join(singleton, info.vts);
4872 VTS::Unref(singleton);
4873 VTS::Unref(info.vts);
4879 parent->vts()->ToString().c_str(),
4880 (*vts)->ToString().c_str());
4886 // Parent should have ticked its VTS so there should be no h-b.
4887 DCHECK(!VTS::HappensBefore(parent->vts(), *vts));
4939 // We are blocking the first time after reset. Clear the VTS.
4942 VTS::Unref(signaller.vts);
4943 signaller.vts = NULL;
5097 thr->sid_ = SID(); // Reset the old SID so we don't try to read its VTS.
5098 VTS *singleton_vts = VTS::CreateSingleton(TID(i), 2);
5106 VTS::Unref(info.vts);
5107 // The parent's VTS should neither happen-before nor equal the child's.
5108 info.vts = VTS::CreateSingleton(TID(i), 1);
5111 VTS::Unref(thr->vts_at_exit_);
5217 VTS *vts_at_exit_;
5241 VTS *vts;
5248 VTS::Unref(it->second.vts);
5258 // signaller address -> VTS
5309 // Similar to Signaller::vts.
5310 VTS* vts;
5420 deque<VTS*> putters;
5484 VTS::FlushHBCache();
5492 for (deque<VTS*>::iterator it2 = pcq.putters.begin();
5494 VTS::Unref(*it2);
5495 *it2 = VTS::CreateSingleton(TID(0), 1);
5894 // Report(" sid=%d; vts=%s\n", thr->sid().raw(),
5895 // thr->vts()->ToString().c_str());
6658 VTS *vts = thread->segment()->vts()->Clone();
6659 pcq.putters.push_back(vts);
6669 VTS *putter = pcq.putters.front();
6674 VTS::Unref(putter);
6694 VTS *vts = thread->segment()->vts();
6695 PublishRange(thread, mem, mem + size, vts);
7158 const VTS *signaller_vts = GetPublisherVTS(addr);
7598 thr->segment()->vts()->ToString().c_str(),
7690 VTS *vts = NULL;
7694 vts = VTS::CreateSingleton(child_tid);
7698 vts = VTS::CreateSingleton(child_tid);
7703 parent->HandleChildThreadStart(child_tid, &vts, &creation_context);
7710 vts, creation_context, call_stack);
7778 child->vts()->ToString().c_str());
7810 VTS *vts_at_exit = NULL;
7818 child_tid.raw(), parent_thr->vts()->ToString().c_str());
8571 VTS::InitClassMembers();
8708 // what entry the read returns. A separate VTS (happens-before edges)
8809 hist.clk = thr->vts()->clk(thr->tid());
8810 if (hist.vts != 0) {
8811 VTS::Unref(hist.vts);
8812 hist.vts = 0;
8816 // Update VTS according to memory access type and memory ordering.
8819 if (hprv.vts != 0) {
8820 hist.vts = VTS::Join(hprv.vts, thr->vts());
8822 hist.vts = thr->vts()->Clone();
8824 } else if (hprv.vts != 0) {
8825 hist.vts = hprv.vts->Clone();
8827 if (is_acquire && hprv.vts != 0) {
8828 thr->NewSegmentForWait(hprv.vts);
8833 hist.vts = thr->vts()->Clone();
8837 // Update the thread's VTS if it's relese memory access.
8843 thr->vts()->ToString().c_str(),
8845 hist.vts->ToString().c_str());
8874 " val=%llu) vts=%u\n",
8877 (unsigned)thr->vts()->clk(hist.tid));
8898 } else if (thr->vts()->clk(hist.tid) >= hist.clk) {
8919 if (hist0->vts != 0) {
8920 thr->NewSegmentForWait(hist0->vts);
8926 thr->vts()->ToString().c_str(),
8990 if (init == false && hist[i].vts != 0)
8991 VTS::Unref(hist[i].vts);
8992 hist[i].vts = 0;