Gitweb links:

...log 
http://git.netsurf-browser.org/netsurf.git/shortlog/3ba50e85747d31deaa2c4c17950b46fc50019564
...commit 
http://git.netsurf-browser.org/netsurf.git/commit/3ba50e85747d31deaa2c4c17950b46fc50019564
...tree 
http://git.netsurf-browser.org/netsurf.git/tree/3ba50e85747d31deaa2c4c17950b46fc50019564

The branch, master has been updated
       via  3ba50e85747d31deaa2c4c17950b46fc50019564 (commit)
       via  ac512958ffb8382b7d7c76748dc69c7ea49baf70 (commit)
      from  e27df0c0b8081f06fec44562b87b35dc0ad434a3 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=3ba50e85747d31deaa2c4c17950b46fc50019564
commit 3ba50e85747d31deaa2c4c17950b46fc50019564
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    Force a GC to ensure old compartment goes away
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/content/handlers/javascript/duktape/dukky.c 
b/content/handlers/javascript/duktape/dukky.c
index 2755a27..8af3165 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -611,7 +611,11 @@ jsobject *js_newcompartment(jscontext *ctx, void 
*win_priv, void *doc_priv)
        NSLOG(dukky, DEBUG,
              "New javascript/duktape compartment, win_priv=%p, doc_priv=%p", 
win_priv,
              doc_priv);
-       duk_set_top(ctx->ctx, 0);
+       if (CTX != NULL) {
+               duk_set_top(ctx->ctx, 0);
+               duk_gc(ctx->ctx, 0);
+               duk_gc(ctx->ctx, DUK_GC_COMPACT);
+       }
        duk_push_thread(ctx->ctx);
        ctx->thread = duk_require_context(ctx->ctx, -1);
        duk_push_int(CTX, 0);


commitdiff 
http://git.netsurf-browser.org/netsurf.git/commit/?id=ac512958ffb8382b7d7c76748dc69c7ea49baf70
commit ac512958ffb8382b7d7c76748dc69c7ea49baf70
Author: Daniel Silverstone <[email protected]>
Commit: Daniel Silverstone <[email protected]>

    Ensure we clear the cbt entry after finishing a non-recurring callback
    
    Signed-off-by: Daniel Silverstone <[email protected]>

diff --git a/content/handlers/javascript/duktape/Window.bnd 
b/content/handlers/javascript/duktape/Window.bnd
index e19b336..cfc6f1f 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -51,17 +51,21 @@ static void window_remove_callback_bits(duk_context *ctx, 
size_t handle) {
        /* ... */
 }
 
-static void window_call_callback(duk_context *ctx, size_t handle) {
+static void window_call_callback(duk_context *ctx, size_t handle, bool 
clear_entry) {
        NSLOG(dukky, DEEPDEBUG, "ctx=%p, handle=%"PRIsizet, ctx, handle);
        /* Stack is ... */
-       duk_push_context_dump(ctx);
-       NSLOG(dukky, DEEPDEBUG, "On entry to callback, stack is: %s", 
duk_get_string(ctx, -1));
-       duk_pop(ctx);
        duk_push_global_object(ctx);
+       /* ..., win */
        duk_get_prop_string(ctx, -1, WINDOW_CALLBACKS);
+       /* ..., win, cbt */
        duk_push_int(ctx, (duk_int_t)handle);
+       /* ..., win, cbt, handle */
        duk_get_prop(ctx, -2);
        /* ..., win, cbt, cbo */
+       duk_push_context_dump(ctx);
+       NSLOG(dukky, DEEPDEBUG, "On entry to callback, stack is: %s", 
duk_get_string(ctx, -1));
+       duk_pop(ctx);
+       /* ..., win, cbt, cbo */
        /* What we want to do is call cbo.func passing all of cbo.args */
        duk_get_prop_string(ctx, -1, "func");
        duk_get_prop_string(ctx, -2, "args");
@@ -79,7 +83,18 @@ static void window_call_callback(duk_context *ctx, size_t 
handle) {
        duk_pop(ctx);
        (void) dukky_pcall(ctx, arrlen, true);
        /* ..., win, cbt, cbo, retval */
-       duk_pop_n(ctx, 4);
+       if (clear_entry) {
+               NSLOG(dukky, DEEPDEBUG, "Not recurring callback, removing from 
cbt");
+               duk_pop_n(ctx, 2);
+               /* ..., win, cbt */
+               duk_push_int(ctx, (duk_int_t)handle);
+               /* ..., win, cbt, handle */
+               duk_del_prop(ctx, -2);
+               /* ..., win, cbt */
+               duk_pop_n(ctx, 2);
+       } else {
+               duk_pop_n(ctx, 4);
+       }
        /* ... */
        duk_push_context_dump(ctx);
        NSLOG(dukky, DEEPDEBUG, "On leaving callback, stack is: %s", 
duk_get_string(ctx, -1));
@@ -91,7 +106,7 @@ static void window_schedule_callback(void *p) {
 
        NSLOG(dukky, DEEPDEBUG, "Entered window scheduler callback: %"PRIsizet, 
priv->handle);
 
-       window_call_callback(priv->ctx, priv->handle);
+       window_call_callback(priv->ctx, priv->handle, priv->repeat_timeout == 
0);
 
        if (priv->repeat_timeout > 0) {
                /* Reschedule */
@@ -102,7 +117,6 @@ static void window_schedule_callback(void *p) {
                /* Remove this from the ring */
                RING_REMOVE(priv->owner->schedule_ring, priv);
                window_remove_callback_bits(priv->ctx, priv->handle);
-               /* TODO: Remove the entry from the JS part */
                free(priv);
        }
 }


-----------------------------------------------------------------------

Summary of changes:
 content/handlers/javascript/duktape/Window.bnd |   28 ++++++++++++++++++------
 content/handlers/javascript/duktape/dukky.c    |    6 ++++-
 2 files changed, 26 insertions(+), 8 deletions(-)

diff --git a/content/handlers/javascript/duktape/Window.bnd 
b/content/handlers/javascript/duktape/Window.bnd
index e19b336..cfc6f1f 100644
--- a/content/handlers/javascript/duktape/Window.bnd
+++ b/content/handlers/javascript/duktape/Window.bnd
@@ -51,17 +51,21 @@ static void window_remove_callback_bits(duk_context *ctx, 
size_t handle) {
        /* ... */
 }
 
-static void window_call_callback(duk_context *ctx, size_t handle) {
+static void window_call_callback(duk_context *ctx, size_t handle, bool 
clear_entry) {
        NSLOG(dukky, DEEPDEBUG, "ctx=%p, handle=%"PRIsizet, ctx, handle);
        /* Stack is ... */
-       duk_push_context_dump(ctx);
-       NSLOG(dukky, DEEPDEBUG, "On entry to callback, stack is: %s", 
duk_get_string(ctx, -1));
-       duk_pop(ctx);
        duk_push_global_object(ctx);
+       /* ..., win */
        duk_get_prop_string(ctx, -1, WINDOW_CALLBACKS);
+       /* ..., win, cbt */
        duk_push_int(ctx, (duk_int_t)handle);
+       /* ..., win, cbt, handle */
        duk_get_prop(ctx, -2);
        /* ..., win, cbt, cbo */
+       duk_push_context_dump(ctx);
+       NSLOG(dukky, DEEPDEBUG, "On entry to callback, stack is: %s", 
duk_get_string(ctx, -1));
+       duk_pop(ctx);
+       /* ..., win, cbt, cbo */
        /* What we want to do is call cbo.func passing all of cbo.args */
        duk_get_prop_string(ctx, -1, "func");
        duk_get_prop_string(ctx, -2, "args");
@@ -79,7 +83,18 @@ static void window_call_callback(duk_context *ctx, size_t 
handle) {
        duk_pop(ctx);
        (void) dukky_pcall(ctx, arrlen, true);
        /* ..., win, cbt, cbo, retval */
-       duk_pop_n(ctx, 4);
+       if (clear_entry) {
+               NSLOG(dukky, DEEPDEBUG, "Not recurring callback, removing from 
cbt");
+               duk_pop_n(ctx, 2);
+               /* ..., win, cbt */
+               duk_push_int(ctx, (duk_int_t)handle);
+               /* ..., win, cbt, handle */
+               duk_del_prop(ctx, -2);
+               /* ..., win, cbt */
+               duk_pop_n(ctx, 2);
+       } else {
+               duk_pop_n(ctx, 4);
+       }
        /* ... */
        duk_push_context_dump(ctx);
        NSLOG(dukky, DEEPDEBUG, "On leaving callback, stack is: %s", 
duk_get_string(ctx, -1));
@@ -91,7 +106,7 @@ static void window_schedule_callback(void *p) {
 
        NSLOG(dukky, DEEPDEBUG, "Entered window scheduler callback: %"PRIsizet, 
priv->handle);
 
-       window_call_callback(priv->ctx, priv->handle);
+       window_call_callback(priv->ctx, priv->handle, priv->repeat_timeout == 
0);
 
        if (priv->repeat_timeout > 0) {
                /* Reschedule */
@@ -102,7 +117,6 @@ static void window_schedule_callback(void *p) {
                /* Remove this from the ring */
                RING_REMOVE(priv->owner->schedule_ring, priv);
                window_remove_callback_bits(priv->ctx, priv->handle);
-               /* TODO: Remove the entry from the JS part */
                free(priv);
        }
 }
diff --git a/content/handlers/javascript/duktape/dukky.c 
b/content/handlers/javascript/duktape/dukky.c
index 2755a27..8af3165 100644
--- a/content/handlers/javascript/duktape/dukky.c
+++ b/content/handlers/javascript/duktape/dukky.c
@@ -611,7 +611,11 @@ jsobject *js_newcompartment(jscontext *ctx, void 
*win_priv, void *doc_priv)
        NSLOG(dukky, DEBUG,
              "New javascript/duktape compartment, win_priv=%p, doc_priv=%p", 
win_priv,
              doc_priv);
-       duk_set_top(ctx->ctx, 0);
+       if (CTX != NULL) {
+               duk_set_top(ctx->ctx, 0);
+               duk_gc(ctx->ctx, 0);
+               duk_gc(ctx->ctx, DUK_GC_COMPACT);
+       }
        duk_push_thread(ctx->ctx);
        ctx->thread = duk_require_context(ctx->ctx, -1);
        duk_push_int(CTX, 0);


-- 
NetSurf Browser

_______________________________________________
netsurf-commits mailing list
[email protected]
http://listmaster.pepperfish.net/cgi-bin/mailman/listinfo/netsurf-commits-netsurf-browser.org

Reply via email to