예제 #1
0
void GarbageCollector::updatePointersOf(Oop object)
{
    // Get the object header.
	auto header = object.header;

	// Mark recursively the children
	auto format = header->objectFormat;
	if(format == OF_FIXED_SIZE ||
	   format == OF_VARIABLE_SIZE_NO_IVARS ||
	   format == OF_VARIABLE_SIZE_IVARS ||
       format == OF_WEAK_VARIABLE_SIZE ||
       format == OF_WEAK_FIXED_SIZE )
	{
		auto slotCount = header->slotCount;
		auto headerSize = sizeof(ObjectHeader);
		if(slotCount == 255)
            slotCount = reinterpret_cast<uint64_t*> (header)[-1];

		// Traverse the slots.
		auto slots = reinterpret_cast<Oop*> (object.pointer + headerSize);
		for(size_t i = 0; i < slotCount; ++i)
			updatePointer(&slots[i]);

	}

	// Special handling of compiled method literals
	if(format >= OF_COMPILED_METHOD)
	{
		auto compiledMethod = reinterpret_cast<CompiledMethod*> (object.pointer);
		auto literalCount = compiledMethod->getLiteralCount();
		auto literals = compiledMethod->getFirstLiteralPointer();
		for(size_t i = 0; i < literalCount; ++i)
			updatePointer(&literals[i]);
	}
}
예제 #2
0
void updateOldObject(OBJ object) {
	*(object + OBJECT_OP_FIELD) = objectPointerFor(object);
	
	updatePointer(object + OBJECT_NEXT_REMEMBERED_INDEX_FIELD);
	
	updateYoungObject(object);
}
예제 #3
0
unsigned int mainMenu()
{
   int selection;
   unsigned long int loopCount;

   DISPLAY_OFF;
   HIDE_BKG;

   move_bkg(0,0);

   set_bkg_palette( 7, 1, &menuPalCGB[28] );
   set_bkg_palette( 6, 1, &menuPalCGB[24] );
   set_bkg_palette( 5, 1, &menuPalCGB[20] );
   set_bkg_palette( 4, 1, &menuPalCGB[16] );
   set_bkg_palette( 3, 1, &menuPalCGB[12] );
   set_bkg_palette( 2, 1, &menuPalCGB[8] );
   set_bkg_palette( 1, 1, &menuPalCGB[4] );
   set_bkg_palette( 0, 1, &menuPalCGB[0] );

   set_bkg_data( 0, 141, menuTiles );

   VBK_REG = 1;
   set_bkg_tiles(0,0,menuMapWidth,menuMapHeight,menuPal);

   VBK_REG = 0;
   set_bkg_tiles(0,0,menuMapWidth,menuMapHeight,menuMap);

   SHOW_BKG;
   DISPLAY_ON;

   setupPointer();

   loopCount = 0;
   do
   {
      loopCount++;
      if((loopCount % 125) == 0)
         updatePointer(); /* animate the pointer */

      selection = checkButtons();

   } while(!selection); /* user hasn't made a selection */
   set_sprite_tile(0, 0); /* set to straight pointer while waiting */
   while(joypad() & (J_A | J_START)); /* wait for the user to let up */

   /* "Shoot" the pointer across the screen */
   loopCount = 0;
   while((pointerX + loopCount) <= 168)
   {
   	move_sprite(0, pointerX + loopCount, pointerYPositions[currSelection]);
      loopCount++;
      delay(4);
   }


   hidePointer();

   return selection;
}
예제 #4
0
void updateYoungObject(OBJ object) {
	updatePointer(object + OBJECT_CLASS_FIELD);
	
	int field = *(object + OBJECT_NAMED_POINTER_FIRST_FIELD);
	int fieldEnd;
	
	if(*(object + OBJECT_CLASS_FIELD) == METHODCONTEXT_OP) {
		fieldEnd = *(object + OBJECT_INDEXABLE_POINTER_FIRST_FIELD) + *(object + *(object + OBJECT_NAMED_POINTER_FIRST_FIELD) + METHODCONTEXT_STACK_POINTER);
	}
	else {
		fieldEnd = *(object + OBJECT_INDEXABLE_BYTE_FIRST_FIELD);
	}
	
	for(; field < fieldEnd; ++field) {
		updatePointer(object + field);
	}
}
예제 #5
0
void updateOldObjectsPhase(OBJ spaceStart, OBJ spaceEnd) {
	OBJ position = spaceStart;
	
	while(position < spaceEnd) {
		updateOldObject(position);
		
		// object size is the first field
		position += *position;
	}
	
	updatePointer(&firstRememberedObject);
}
예제 #6
0
파일: update.hpp 프로젝트: alzwded/etc
void update(int value)
{
	updateAnimations();
	updatePointer();
	updatePlayer();
	updateBullet();
	updateCubes();
	updateExplosions();
	updateScore();

	// comunica cata cuburi mai sunt
	sprintf_s(_windowTitle, 39, "JakCube - %d cubes left", _evilCubes.size());
	_windowTitle[39] = NULL;
	glutSetWindowTitle(_windowTitle);

	glutPostRedisplay();
	glutTimerFunc(25, update, 0);
}
예제 #7
0
void
HippoCanvas::onMouseLeave(WPARAM wParam, LPARAM lParam)
{
    if (!containsMouse_)
        return;

    // g_debug("Deactivating tooltip on leave");
    tooltip_->deactivate();

    containsMouse_ = false;

    if (root_ != (HippoCanvasItem*) NULL) {
        // FIXME Windows does not provide coordinates here, so we'd have to save
        // the last move event coordinates or request the current coords or something
        // like that
        hippo_canvas_item_emit_motion_notify_event(root_,
                0, 0, HIPPO_MOTION_DETAIL_LEAVE);
    }

    updatePointer(-1, -1);
}
예제 #8
0
void
HippoCanvas::onMouseMove(WPARAM wParam, LPARAM lParam)
{
    int x, y;

    if (!getMouseCoords(lParam, &x, &y))
        return;

    if (x == lastMoveX_ && y == lastMoveY_) {
        // we didn't really move. I don't know why Windows does this.
        return;
    }
    lastMoveX_ = x;
    lastMoveY_ = y;

    // FIXME what we really want here is that if the mouse is still 
    // on the same logical UI component (which may or may not be
    // a separate canvas item), we update the tooltip, otherwise
    // we hide the tooltip. A case where this happens is that with
    // non-NW-gravity windows, we get a motion event on size allocate,
    // and that should not usually clear the tooltip as long as the 
    // pointer stays inside the same item. But also, just the user
    // moving within one item really shouldn't clear the tip.
    // We could just check whether the results of get_tooltip have
    // changed (for_area and the tip text), but that isn't good enough
    // since both can change when we're still inside the same item.

    //updateTooltip(false, x, y);
    tooltip_->deactivate();

    bool entered;

    entered = false;
    if (!containsMouse_) {
        // request a WM_MOUSELEAVE message
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(tme);
        tme.dwFlags = TME_LEAVE;
        tme.hwndTrack = window_;
        if (TrackMouseEvent(&tme) != 0) {
            containsMouse_ = true;
            entered = true;
        } else {
            g_warning("Failed to track mouse leave");
            return;
        }
    }

    g_assert(containsMouse_);

    if (root_ != (HippoCanvasItem*) NULL) {
        startTrackingHover();

        if (entered) {
            hippo_canvas_item_emit_motion_notify_event(root_,
                x, y, HIPPO_MOTION_DETAIL_ENTER);
        }
        hippo_canvas_item_emit_motion_notify_event(root_,
            x, y, HIPPO_MOTION_DETAIL_WITHIN);
    }

    updatePointer(x, y);
}
예제 #9
0
 ///Decrements weak ref count
 void decWeak() {
   m_weakRefCount--;
   updatePointer();
 }
예제 #10
0
 ///Increments weak ref count
 void incWeak() {
   getRef(); //We want an error to be raised when someone tries to make a weak pointer to bad data.
   m_weakRefCount++;
   updatePointer();
 }
예제 #11
0
 ///Decrements strong ref count
 void decStrong() {
   m_strongRefCount--;
   updatePointer();
 }
예제 #12
0
 ///Increments strong ref count
 void incStrong() {
   getRef(); //We want an error to be raised when someone tries to make a shared pointer to bad data.
   m_strongRefCount++;
   updatePointer();
 }
예제 #13
0
void GarbageCollector::compact()
{
    auto heap = memoryManager->getHeap();
    auto lowestAddress = heap->getAddressSpace();
    auto endAddress = lowestAddress + heap->getSize();

    //--------------------------------------------------------------------------
    // First Pass
    // Compute the forwarding locations.
    auto freeAddress = lowestAddress;
    auto live = lowestAddress;
    uint64_t freeCount = 0;
    while(live < endAddress)
    {
        auto liveHeader = reinterpret_cast<AllocatedObject*> (live);
        auto liveSize = liveHeader->computeSize();

        // Is this object not condemned?
        if(liveHeader->header().gcColor != White)
        {
            liveHeader->setForwardingPointer(freeAddress + sizeof(void*));
            freeAddress += liveSize;
        }
        else
        {
            //printf("Free %s\n", memoryManager->getContext()->getClassNameOfObject(Oop::fromPointer(&liveHeader->header)).c_str());
            liveHeader->setForwardingPointer(nullptr);
            ++freeCount;
        }

        // Process the next object.
        live += liveSize;
    }

    assert(freeAddress <= live);
    assert(live == endAddress);

    // Are we freeing objects.
    if(!freeCount)
    {
        // Abort the compaction.
        abortCompaction();
        return;
    }

    //--------------------------------------------------------------------------
    // Second Pass
    // Update the object pointers.
    live = lowestAddress;
    while(live < endAddress)
    {
        auto liveHeader = reinterpret_cast<AllocatedObject*> (live);
        auto liveSize = liveHeader->computeSize();

        // Is this object not condemned?
        if(liveHeader->header().gcColor != White)
            updatePointersOf(Oop::fromPointer(&liveHeader->header()));

        // Process the next object.
        live += liveSize;
    }
    assert(live == endAddress);

    // Update the root pointers.
    onRootsDo([&](Oop &pointer) {
        updatePointer(&pointer);
    });

    // Some elements were not allocated by myself. Update their pointers.
    for(auto &nativeObject : nativeObjects)
        updatePointersOf(nativeObject);

    //--------------------------------------------------------------------------
    // Third Pass
    // Move the objects
    live = lowestAddress;
    while(live < endAddress)
    {
        auto liveHeader = reinterpret_cast<AllocatedObject*> (live);
        auto liveSize = liveHeader->computeSize();

        // Is this object not condemned?
        if(liveHeader->header().gcColor != White)
        {
            // Clear the color of the object for the next garbage collection.
            liveHeader->header().gcColor = White;

            // Move the object.
            auto destination = liveHeader->getForwardingDestination();
            //printf("Move %p %p\n", destination, liveHeader);
            memmove(destination, liveHeader, liveSize);

        }

        // Process the next object.
        live += liveSize;
    }
    assert(live == endAddress);

    // Set the white color of the native objects.
    for(auto &nativeObject : nativeObjects)
        nativeObject.header->gcColor = White;

    // Set the new heap size.
    heap->setSize(freeAddress - lowestAddress);
    //printf("Compaction ended\n");
}
예제 #14
0
파일: vm.c 프로젝트: mib/smalltalk-vm
// used by old space GC
void updateVmRegisters() {
	updatePointer(&mainContext);
	updatePointer(&exceptionHandlerContext);
	
	updateVmScriptRegisters();
}