void V8DOMWindowShell::disposeContext(bool weak)
{
    ASSERT(!m_context.get().IsWeak());
    m_perContextData.clear();

    if (m_context.isEmpty())
        return;

    m_frame->loader()->client()->willReleaseScriptContext(m_context.get(), m_world->worldId());

    if (!weak)
        m_context.clear();
    else {
        ASSERT(!m_world->isMainWorld());
        destroyGlobal();
        m_frame = 0;
        m_context.get().MakeWeak(this, isolatedContextWeakCallback);
    }

    // It's likely that disposing the context has created a lot of
    // garbage. Notify V8 about this so it'll have a chance of cleaning
    // it up when idle.
    if (m_world->isMainWorld()) {
        bool isMainFrame = m_frame->page() && (m_frame->page()->mainFrame() == m_frame);
        V8GCForContextDispose::instance().notifyContextDisposed(isMainFrame);
    }
}
Beispiel #2
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR lpstrCmdLine, int nCmdShow)
{
	createGlobal();
	FrameWindow mw;
	mw.CreateEx();
	mw.ShowWindow(SW_MAXIMIZE);
	mw.UpdateWindow();
	MSG m;
	::ZeroMemory(&m, sizeof(m));
	for (;;)
	{
		::ZeroMemory(&m, sizeof(m));
		if (::PeekMessage(&m, NULL, 0, 0, PM_NOREMOVE))
		{
			::GetMessage(&m, NULL, 0, 0);
			if (m.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&m);
			::DispatchMessage(&m);
		}
		else
		{
			mw.onIdle();
		}
	}
	destroyGlobal();
	return 0;
}
Beispiel #3
0
V8Proxy::~V8Proxy()
{
    clearForClose();
    destroyGlobal();
}
Beispiel #4
0
int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE , LPTSTR lpstrCmdLine, int nCmdShow)
{
	createGlobal();
	FrameWindow mw;
	mw.CreateEx();
	mw.ShowWindow(SW_SHOWMAXIMIZED);
	mw.UpdateWindow();
	MSG m;
	::ZeroMemory(&m, sizeof(m));
	float life = 0.0f;
	float frame = 0.0f;
	float fps = 0.0f;
	const size_t tDuration = 1000;
	const size_t tInterval = 1000/65;
	float inter = tInterval;
	for (;;)
	{
		::ZeroMemory(&m, sizeof(m));
		if (::PeekMessage(&m, NULL, 0, 0, PM_NOREMOVE))
		{
			::GetMessage(&m, NULL, 0, 0);
			if (m.message == WM_QUIT)
			{
				break;
			}
			::TranslateMessage(&m);
			::DispatchMessage(&m);
		}
		else
		{
			// GetTickCount only has a guaranteed resolution of 1/18th of a second, which is pretty horrible for game timing
			//Retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.
			float beforeRun = ::timeGetTime();
			mw.onIdle(inter);
			float afterRun = ::timeGetTime();
			float timeRun = afterRun - beforeRun;
			if (timeRun > tInterval)
			{
				inter = timeRun;
			}
			else
			{
				inter = tInterval;
			}
			++frame;
			float timeSleep = tInterval - timeRun;
			//¼ÆËãFPS
			life += inter;
			if (life >= tDuration)
			{
				fps = 1000.0f * frame / life;
				mw.setFPS(fps);
				life = 0.0f;
				frame = 0.0f;
			}
			//ÏÞÖ¡
			while(timeSleep >= 1.0f)
			{
				Sleep(1);
				--timeSleep;
			}
		}
	}
	destroyGlobal();

	return 0;
}