Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Profiler / stack trace fixes #645

Merged
merged 32 commits into from Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f576c59
Fumbling toward a transformation on CoronaTotalTime, so far the comma…
ggcrunchy Feb 7, 2019
6626191
Moved some of the time transform stuff into ShaderResource with link …
ggcrunchy Feb 8, 2019
e59f04a
Better argument checking for time transforms
ggcrunchy Feb 9, 2019
e05f972
Whoops, wasn't always linking Program back to ShaderResource
ggcrunchy Feb 10, 2019
c7af750
Removed notes to self about changes
ggcrunchy Feb 11, 2019
9058c1f
timeTransform ignored if no time dependency
ggcrunchy Feb 11, 2019
c01d916
Minor changes
ggcrunchy May 29, 2020
08dc3b6
Maintenance Revert Test
scottrules44 Sep 20, 2021
05b91fb
Simulator: Adding Samsung Galaxy 21 as a skin
scottrules44 Sep 22, 2021
f44be24
Maintenance
scottrules44 Sep 22, 2021
581d844
Android: adding rest of media intents for Android 11
scottrules44 Sep 22, 2021
265be3c
Merge
ggcrunchy Sep 23, 2021
e217c80
Merge
ggcrunchy Oct 4, 2021
ca300c1
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Oct 19, 2021
0b5e1e9
First go at graphics.undefineEffect()
ggcrunchy Nov 9, 2021
b41e624
Revert "First go at graphics.undefineEffect()"
ggcrunchy Nov 10, 2021
5be6193
Merging upstream
ggcrunchy Aug 18, 2022
f38ecec
Merge branch 'master' of https://github.com/ggcrunchy/corona
ggcrunchy Aug 18, 2022
bb395b8
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Dec 16, 2022
5a3c9e5
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Mar 24, 2023
0a67355
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Apr 1, 2023
896920e
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Apr 26, 2023
906a1cd
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy May 24, 2023
100c0b9
Merge branch 'master' of https://github.com/coronalabs/corona
ggcrunchy Oct 13, 2023
fe0c18c
Merge branch 'master' of https://github.com/ggcrunchy/corona
ggcrunchy Oct 27, 2023
37c155b
Revisions of profiler
ggcrunchy Oct 28, 2023
72da89f
Fix for pcall: bookmark should precede call
ggcrunchy Nov 4, 2023
06dd290
Merge branch 'fixes-profiler' of https://github.com/ggcrunchy/corona …
ggcrunchy Nov 4, 2023
7a4af07
Removed WIP-related comments
ggcrunchy Nov 4, 2023
b0f561d
Removed DestroyAll() from Profiling following test on Mac
ggcrunchy Nov 5, 2023
758a7db
Bookmarks now take a userdata, provided with the function
ggcrunchy Nov 5, 2023
0c8a8d4
Merge branch 'fixes-profiler' of https://github.com/ggcrunchy/corona …
ggcrunchy Nov 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
49 changes: 49 additions & 0 deletions external/lua-5.1.3/src/lapi.c
Expand Up @@ -127,6 +127,55 @@ LUA_API void lua_setlevel (lua_State *from, lua_State *to) {
}


LUA_API void lua_setbookmarkf (lua_State *L, lua_BookmarkFunction bookmarkf, void *ud) {
lua_lock(L);
G(L)->bookmark = bookmarkf;
G(L)->bookmarkud = ud;
lua_unlock(L);
}

LUA_API void lua_setlevelid (lua_State *L, int id) {
lua_lock(L);
api_check(L, G(L)->bookmark);
api_check(L, id >= 0 && id < 0xFFFF);
if (id > 0) {
int inuse;
if (L->nBookmarks == L->size_bookmarks) {
luaM_reallocvector(L, L->bookmarks, L->size_bookmarks, L->nBookmarks + 1, int32_t);
L->size_bookmarks = L->nBookmarks + 1;
}
inuse = cast_int(L->ci - L->base_ci);
L->bookmarks[L->nBookmarks] = (inuse << 16) | id;
L->nBookmarks++;
}
else {
api_check(L, L->size_bookmarks);
api_check(L, L->nBookmarks);
L->nBookmarks--;
}
lua_unlock(L);
}

LUA_API void lua_getlevelcounts (lua_State *L, int *ci, int *nbookmarks) {
if (lua_isthread(L, 1))
L = lua_tothread(L, 1);
*ci = cast_int(L->ci - L->base_ci);
*nbookmarks = L->nBookmarks;
}

LUA_API int lua_getlevelid (lua_State *L, int index, int *ci) {
if (lua_isthread(L, 1))
L = lua_tothread(L, 1);
if (index >= 0 && index < L->nBookmarks) {
if (ci)
*ci = L->bookmarks[index] >> 16;
return L->bookmarks[index] & 0xFFFF;
}
else
return -1;
}


LUA_API lua_CFunction lua_atpanic (lua_State *L, lua_CFunction panicf) {
lua_CFunction old;
lua_lock(L);
Expand Down
26 changes: 26 additions & 0 deletions external/lua-5.1.3/src/ldo.c
Expand Up @@ -436,6 +436,7 @@ static int resume_error (lua_State *L, const char *msg) {


LUA_API int lua_resume (lua_State *L, int nargs) {
int i;
int status;
lua_lock(L);
if (L->status != LUA_YIELD && (L->status != 0 || L->ci != L->base_ci))
Expand All @@ -445,11 +446,19 @@ LUA_API int lua_resume (lua_State *L, int nargs) {
luai_userstateresume(L, nargs);
lua_assert(L->errfunc == 0);
L->baseCcalls = ++L->nCcalls;
// Custom for Solar2D:
for (i = 0; i < L->nBookmarks; i++)
G(L)->bookmark(L->bookmarks[i] & 0xFFFF, 1, G(L)->bookmarkud);
// /Custom
status = luaD_rawrunprotected(L, resume, L->top - nargs);
if (status != 0) { /* error? */
L->status = cast_byte(status); /* mark thread as `dead' */
luaD_seterrorobj(L, status, L->top);
L->ci->top = L->top;
// Custom for Solar2D:
for (i = 0; i < L->nBookmarks; i++)
G(L)->bookmark(L->bookmarks[i] & 0xFFFF, 0, G(L)->bookmarkud);
// /Custom
}
else {
lua_assert(L->nCcalls == L->baseCcalls);
Expand All @@ -462,10 +471,15 @@ LUA_API int lua_resume (lua_State *L, int nargs) {


LUA_API int lua_yield (lua_State *L, int nresults) {
int i;
luai_userstateyield(L, nresults);
lua_lock(L);
if (L->nCcalls > L->baseCcalls)
luaG_runerror(L, "attempt to yield across metamethod/C-call boundary");
// Custom for Solar2D:
for (i = L->nBookmarks - 1; i >= 0; i--)
G(L)->bookmark(L->bookmarks[i] & 0xFFFF, 0, G(L)->bookmarkud);
// /Custom
L->base = L->top - nresults; /* protect stack slots below */
L->status = LUA_YIELD;
lua_unlock(L);
Expand All @@ -483,6 +497,7 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
L->errfunc = ef;
status = luaD_rawrunprotected(L, func, u);
if (status != 0) { /* an error occurred? */
int i, pos;
StkId oldtop = restorestack(L, old_top);
luaF_close(L, oldtop); /* close eventual pending closures */
luaD_seterrorobj(L, status, oldtop);
Expand All @@ -492,6 +507,17 @@ int luaD_pcall (lua_State *L, Pfunc func, void *u,
L->savedpc = L->ci->savedpc;
L->allowhook = old_allowhooks;
restore_stack_limit(L);
// Custom for Solar2D:
pos = cast_int(L->ci - L->base_ci);
for (i = L->nBookmarks - 1; i >= 0; i--) {
if ((L->bookmarks[i] >> 16) <= pos)
break;
else {
G(L)->bookmark(L->bookmarks[i] & 0xFFFF, 0, G(L)->bookmarkud);
L->nBookmarks--;
}
}
// /Custom
}
L->errfunc = old_errfunc;
return status;
Expand Down
10 changes: 10 additions & 0 deletions external/lua-5.1.3/src/lstate.c
Expand Up @@ -61,6 +61,7 @@ static void stack_init (lua_State *L1, lua_State *L) {
static void freestack (lua_State *L, lua_State *L1) {
luaM_freearray(L, L1->base_ci, L1->size_ci, CallInfo);
luaM_freearray(L, L1->stack, L1->stacksize, TValue);
luaM_freearray(L, L1->bookmarks, L1->size_bookmarks, int32_t); // Custom for Solar2D
}


Expand Down Expand Up @@ -94,6 +95,11 @@ static void preinit_state (lua_State *L, global_State *g) {
L->openupval = NULL;
L->size_ci = 0;
L->nCcalls = L->baseCcalls = 0;
// Custom for Solar2D:
L->bookmarks = NULL;
L->size_bookmarks = 0;
L->nBookmarks = 0;
// /Custom
L->status = 0;
L->base_ci = L->ci = NULL;
L->savedpc = NULL;
Expand Down Expand Up @@ -166,6 +172,10 @@ LUA_API lua_State *lua_newstate (lua_Alloc f, void *ud) {
setnilvalue(registry(L));
luaZ_initbuffer(L, &g->buff);
g->panic = NULL;
// Custom for Solar2D:
g->bookmark = NULL;
g->bookmarkud = NULL;
// /Custom
g->gcstate = GCSpause;
g->rootgc = obj2gco(L);
g->sweepstrgc = 0;
Expand Down
9 changes: 9 additions & 0 deletions external/lua-5.1.3/src/lstate.h
Expand Up @@ -86,6 +86,10 @@ typedef struct global_State {
int gcpause; /* size of pause between successive GCs */
int gcstepmul; /* GC `granularity' */
lua_CFunction panic; /* to be called in unprotected errors */
// Custom for Solar2D:
lua_BookmarkFunction bookmark; /* called before coroutine resumes and after yields or errors of same, or on pcall error cleanup */
void *bookmarkud; /* auxiliary data to `bookmark' */
// /Custom
TValue l_registry;
struct lua_State *mainthread;
UpVal uvhead; /* head of double-linked list of all open upvalues */
Expand Down Expand Up @@ -113,6 +117,11 @@ struct lua_State {
int size_ci; /* size of array `base_ci' */
unsigned short nCcalls; /* number of nested C calls */
unsigned short baseCcalls; /* nested C calls when resuming coroutine */
// Custom for Solar2D:
int32_t *bookmarks; /* array of call stack bookmarks */
int size_bookmarks; /* size of array `bookmarks' */
unsigned short nBookmarks; /* number of active bookmarks */
// /Custom
lu_byte hookmask;
lu_byte allowhook;
int basehookcount;
Expand Down
12 changes: 12 additions & 0 deletions external/lua-5.1.3/src/lua.h
Expand Up @@ -60,6 +60,9 @@ typedef struct lua_State lua_State;
typedef int (*lua_CFunction) (lua_State *L);


typedef void (*lua_BookmarkFunction) (short mark, int push, void *ud); // Custom for Solar2D


/*
** functions that read/write blocks when loading/dumping Lua chunks
*/
Expand Down Expand Up @@ -306,6 +309,15 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud);
LUA_API void lua_setlevel (lua_State *from, lua_State *to);


// Custom for Solar2D:
LUA_API void lua_setbookmarkf (lua_State *L, lua_BookmarkFunction bookmarkf, void *ud);

LUA_API void lua_setlevelid (lua_State *L, int id);
LUA_API void lua_getlevelcounts (lua_State *L, int *ci, int *nbookmarks);
LUA_API int lua_getlevelid (lua_State *L, int index, int *ci);
// /Custom


/*
** {======================================================================
** Debug API
Expand Down
8 changes: 5 additions & 3 deletions librtt/Display/Rtt_Display.cpp
Expand Up @@ -204,7 +204,8 @@ Display::Display( Runtime& owner )
fShaderFactory( NULL ),
fSpritePlayer( Rtt_NEW( owner.Allocator(), SpritePlayer( owner.Allocator() ) ) ),
fTextureFactory( Rtt_NEW( owner.Allocator(), TextureFactory( * this ) ) ),
fScene( Rtt_NEW( & owner.GetAllocator(), Scene( owner.Allocator(), * this ) ) ),
fScene( Rtt_NEW( owner.GetAllocator(), Scene( owner.Allocator(), * this ) ) ),
fProfilingState( Rtt_NEW( owner.GetAllocator(), ProfilingState( owner.GetAllocator() ) ) ),
fStream( Rtt_NEW( owner.GetAllocator(), GPUStream( owner.GetAllocator() ) ) ),
fTarget( owner.Platform().CreateScreenSurface() ),
fImageSuffix( LUA_REFNIL ),
Expand Down Expand Up @@ -234,6 +235,7 @@ Display::~Display()
Rtt_DELETE( fTarget );
Rtt_DELETE( fStream );
Rtt_DELETE( fScene );
Rtt_DELETE( fProfilingState );
Rtt_DELETE( fTextureFactory );
Rtt_DELETE( fSpritePlayer );
Rtt_DELETE( fShaderFactory );
Expand Down Expand Up @@ -527,7 +529,7 @@ Display::Restart( int newWidth, int newHeight )
void
Display::Update()
{
Profiling::EntryRAII up( GetAllocator(), "update" );
PROFILING_BEGIN( *GetProfilingState(), up, "update" );

up.Add( "Display::Update Begin" );

Expand Down Expand Up @@ -566,7 +568,7 @@ Display::Update()
void
Display::Render()
{
Profiling::EntryRAII rp( GetAllocator(), "render" );
PROFILING_BEGIN( *GetProfilingState(), rp, "render" );

rp.Add( "Display::Render Begin" );

Expand Down
5 changes: 5 additions & 0 deletions librtt/Display/Rtt_Display.h
Expand Up @@ -52,6 +52,7 @@ class String;
class TextureFactory;
class PlatformSurface;
class RenderingStream;
class ProfilingState;

// ----------------------------------------------------------------------------

Expand Down Expand Up @@ -325,6 +326,9 @@ class Display
static bool GetGpuSupportsHighPrecisionFragmentShaders();
static size_t GetMaxVertexTextureUnits();

public:
ProfilingState* GetProfilingState() const { return fProfilingState; }

public:
Scene& GetScene() { return *fScene; }
const Scene& GetScene() const { return *fScene; }
Expand Down Expand Up @@ -380,6 +384,7 @@ class Display
SpritePlayer *fSpritePlayer;
TextureFactory *fTextureFactory;
Scene *fScene;
ProfilingState *fProfilingState;

// TODO: Refactor data structure portions out
// We temporarily use RenderingStream b/c it contains key data
Expand Down