summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorPhilip Chimento <philip@endlessm.com>2016-11-22 13:37:12 -0500
committerPhilip Chimento <philip@endlessm.com>2016-12-09 19:44:37 -0800
commit72c0298c5f9df9036ed67fd504db84cbc028daaa (patch)
treeb83429cfc670bd5679241b47316987c1c3d2e920 /util
parente0fd6b6079187d41394d30e68d45f5b038214832 (diff)
downloadgjs-72c0298c5f9df9036ed67fd504db84cbc028daaa.tar.gz
js: Workaround for function with custom prototype
It's not possible in JS to directly create a function object with a custom prototype. We previously got around this by directly altering the prototype by setting the __proto__ property, but SpiderMonkey now conspicuously warns that this will make your code slow. It would be possible to do this with ES6 Proxy objects, although SpiderMonkey 31 doesn't support the particular getPrototypeOf() proxy trap that we would need in order to implement this correctly --- at least not in JS. Therefore we implement the proxy in C++. We add a debug topic for proxies and a memory counter. All in all, the proxy is probably still slower than a function object with a real prototype would be, but hopefully faster than direct alteration of the prototype. At the very least we can avoid printing a big warning every time our class framework is used. https://bugzilla.gnome.org/show_bug.cgi?id=751252
Diffstat (limited to 'util')
-rw-r--r--util/log.cpp3
-rw-r--r--util/log.h1
2 files changed, 4 insertions, 0 deletions
diff --git a/util/log.cpp b/util/log.cpp
index 38901dbe..f787cbd6 100644
--- a/util/log.cpp
+++ b/util/log.cpp
@@ -248,6 +248,9 @@ _Pragma("GCC diagnostic pop")
case GJS_DEBUG_GERROR:
prefix = "JS G ERR";
break;
+ case GJS_DEBUG_PROXY:
+ prefix = "JS CPROXY";
+ break;
default:
prefix = "???";
break;
diff --git a/util/log.h b/util/log.h
index dc8228b3..7adf466b 100644
--- a/util/log.h
+++ b/util/log.h
@@ -59,6 +59,7 @@ typedef enum {
GJS_DEBUG_BYTE_ARRAY,
GJS_DEBUG_GERROR,
GJS_DEBUG_GFUNDAMENTAL,
+ GJS_DEBUG_PROXY,
} GjsDebugTopic;
/* These defines are because we have some pretty expensive and