示例#1
0
void ST_mmgc_threads::test0() {
       startSlave();
       MMGC_GCENTER(gc);
       RCObjectNotifier *obj = new (gc) RCObjectNotifier(&isDead);
       {
          gc->CreateRootFromCurrentStack(kickAndWait, this);
       }

#line 154 "ST_mmgc_threads.st"
verifyPass(result, "result", __FILE__, __LINE__);

#line 156 "ST_mmgc_threads.st"
verifyPass(!isDead, "!isDead", __FILE__, __LINE__);
       gc->ReapZCT();
#line 158 "ST_mmgc_threads.st"
verifyPass(!isDead, "!isDead", __FILE__, __LINE__);
       gc->Collect();
#line 160 "ST_mmgc_threads.st"
verifyPass(!isDead, "!isDead", __FILE__, __LINE__);

       pthread_join(pthread, NULL);

       printf("Ignore this: %d\n", *obj->isDead);

}
示例#2
0
	void HeapMultiname::setMultiname(const Multiname& that)
	{
		MMgc::GC* gc = this->gc();
		const void *container = gc->FindBeginningFast(this);
		WBRC(gc, container, &name.name, that.name);
		
		bool const this_nsset = name.isNsset() != 0;
		bool const that_nsset = that.isNsset() != 0;

		if (this_nsset != that_nsset)
		{
			// gc->rc or vice versa... we have to explicitly null out
			// any existing value (before setting a new one) because WB/WBRC
			// assume any existing value is a GCObject/RCObject respectively.
			if (this_nsset)
				WB_NULL(&name.ns);
			else
				WBRC_NULL(&name.ns);
		}

		if (that_nsset) 
		{
			WB(gc, container, &name.nsset, that.nsset);
		} 
		else 
		{
			WBRC(gc, container, &name.ns, that.ns);
		}

		name.flags = that.flags;
		name.next_index = that.next_index;
	}
示例#3
0
void ST_mmgc_basics::test8() {
    MMGC_GCENTER(gc);
    MyGCObject *mygcobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
verifyPass((MyGCObject *)gc->FindBeginningGuarded(mygcobject)==mygcobject, "(MyGCObject *)gc->FindBeginningGuarded(mygcobject)==mygcobject", __FILE__, __LINE__);
verifyPass((MyGCObject *)gc->FindBeginningFast(mygcobject)==mygcobject, "(MyGCObject *)gc->FindBeginningFast(mygcobject)==mygcobject", __FILE__, __LINE__);

}
示例#4
0
void ST_mmgc_basics::test2() {
    MMGC_GCENTER(gc);
    MyGCObject *mygcobject;
    int inuse=(int)gc->GetBytesInUse();
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
//    AvmLog("bytes in use before %d after %d\n",inuse,(int)gc->GetBytesInUse());
verifyPass(gc->GetBytesInUse()==inuse + sizeof(MyGCObject) + DebugSize(), "gc->GetBytesInUse()==inuse + sizeof(MyGCObject) + DebugSize()", __FILE__, __LINE__);
    delete mygcobject;

}
示例#5
0
	void slaveRun()
	{
		wait();
        {
		 MMGC_GCENTER(gc);	
  	     result &= !isDead;
	     gc->ReapZCT();
  	     result &= !isDead;
	     gc->Collect();
		 result &= !isDead;
		}
 		kick();
	}
示例#6
0
void ST_mmgc_basics::test3() {
    MMGC_GCENTER(gc);
    MyGCObject *mygcobject;
    int inuse=(int)gc->GetBytesInUse();
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
verifyPass((int)gc->GetBytesInUse()>inuse, "(int)gc->GetBytesInUse()>inuse", __FILE__, __LINE__);
    delete mygcobject;
//    AvmLog("collect: inuse=%d current=%d\n",inuse,(int)gc->GetBytesInUse());
    gc->Collect();      
//    AvmLog("collect: inuse=%d current=%d\n",inuse,(int)gc->GetBytesInUse());
verifyPass((int)gc->GetBytesInUse()<=inuse, "(int)gc->GetBytesInUse()<=inuse", __FILE__, __LINE__);

}
示例#7
0
void ST_mmgc_threads::test0() {
	   startSlave();
	   MMGC_GCENTER(gc);
   	   /*RCObject *obj =*/ new (gc) RCObjectNotifier(&isDead);
	   {
          MMGC_GC_ROOT_THREAD(gc);
		  kick();
    	  wait();
       }

verifyPass(result, "result", __FILE__, __LINE__);

verifyPass(!isDead, "!isDead", __FILE__, __LINE__);
	   gc->ReapZCT();
verifyPass(!isDead, "!isDead", __FILE__, __LINE__);
	   gc->Collect();
verifyPass(!isDead, "!isDead", __FILE__, __LINE__);

	   pthread_join(pthread, NULL);

}
示例#8
0
void ST_mmgc_basics::test10() {
    MMGC_GCENTER(gc);
	new (gc) DeleteInFinalizer(new (gc, 100) GCFinalizedObject(), new (gc) GCFinalizedObject());
	//delete m;	delete m; // this verifies we crash, it does	
	gc->Collect(false);
verifyPass(true, "true", __FILE__, __LINE__);
    GCFinalizedObject *gcfo = new (gc) GCFinalizedObject();
    gcfo->~GCFinalizedObject();
    gcfo->~GCFinalizedObject(); // this used to be a deleteing dtor and would crash, not anymore
			 

									
									   

}
示例#9
0
void ST_mmgc_basics::test9() {
    MMGC_GCENTER(gc);
    MyGCObject *mygcobject;
    mygcobject = (MyGCObject *)new (gc) MyGCObject();
    void *obj=gc->Alloc(10024,0);
verifyPass(MMgc::GCLargeAlloc::IsLargeBlock(GetRealPointer(obj))==true, "MMgc::GCLargeAlloc::IsLargeBlock(GetRealPointer(obj))==true", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::FindBeginning(obj)==GetRealPointer(obj), "MMgc::GCLargeAlloc::FindBeginning(obj)==GetRealPointer(obj)", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==false, "MMgc::GCLargeAlloc::IsFinalized(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetFinalize(obj);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==true, "MMgc::GCLargeAlloc::IsFinalized(obj)==true", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::ClearFinalized(obj);
verifyPass(MMgc::GCLargeAlloc::IsFinalized(obj)==false, "MMgc::GCLargeAlloc::IsFinalized(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::ContainsPointers(obj)==false, "MMgc::GCLargeAlloc::ContainsPointers(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==false, "MMgc::GCLargeAlloc::HasWeakRef(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetHasWeakRef(obj,true);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==true, "MMgc::GCLargeAlloc::HasWeakRef(obj)==true", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetHasWeakRef(obj,false);
verifyPass(MMgc::GCLargeAlloc::HasWeakRef(obj)==false, "MMgc::GCLargeAlloc::HasWeakRef(obj)==false", __FILE__, __LINE__);
verifyPass(MMgc::GCLargeAlloc::GetMark(obj)==false, "MMgc::GCLargeAlloc::GetMark(obj)==false", __FILE__, __LINE__);
    MMgc::GCLargeAlloc::SetMark(obj);
verifyPass(MMgc::GCLargeAlloc::GetMark(obj)==true, "MMgc::GCLargeAlloc::GetMark(obj)==true", __FILE__, __LINE__);

}
示例#10
0
void ST_mmgc_basics::test4() {
verifyPass(gc->GetGCHeap()!=NULL, "gc->GetGCHeap()!=NULL", __FILE__, __LINE__);

}
示例#11
0
 // NOTE NOTE NOTE
 // Write barrier note: the container for a HeapMultiname is *not* 'this';
 // HeapMultiname figures as a field in eg QNameObject and XMLListObject.
 // You *must* call FindBeginningFast(this) to get the right container.
 //
 // NOTE NOTE NOTE
 // This version is only safe if 'this' is on the first block of the object - because
 // GC::GetGC() is not reliable otherwise.  See bugzilla 525875.  Use the more
 // reliable version below if in doubt.
 void HeapMultiname::setMultiname(const Multiname& that)
 {
     MMgc::GC* gc = this->gc();
     const void *container = gc->FindBeginningFast(this);
     setMultiname(gc, container, that);
 }