aboutsummaryrefslogtreecommitdiff
path: root/src/preamble.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/preamble.js')
-rw-r--r--src/preamble.js34
1 files changed, 25 insertions, 9 deletions
diff --git a/src/preamble.js b/src/preamble.js
index 9bc68d8f..6f3a969c 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -503,6 +503,7 @@ function allocate(slab, types, allocator, ptr) {
Module['allocate'] = allocate;
function Pointer_stringify(ptr, /* optional */ length) {
+#if UTF_STRING_SUPPORT
var utf8 = new Runtime.UTF8Processor();
var nullTerminated = typeof(length) == "undefined";
var ret = "";
@@ -519,18 +520,16 @@ function Pointer_stringify(ptr, /* optional */ length) {
if (!nullTerminated && i == length) break;
}
return ret;
+#else
+#if USE_TYPED_ARRAYS == 2
+ return String.fromCharCode.apply(String, HEAPU8.subarray(ptr, ptr + (length || _strlen(ptr))));
+#else
+ throw 'unsupported combination';
+#endif
+#endif
}
Module['Pointer_stringify'] = Pointer_stringify;
-function Array_stringify(array) {
- var ret = "";
- for (var i = 0; i < array.length; i++) {
- ret += String.fromCharCode(array[i]);
- }
- return ret;
-}
-Module['Array_stringify'] = Array_stringify;
-
// Memory management
var PAGE_SIZE = 4096;
@@ -848,5 +847,22 @@ Module['removeRunDependency'] = removeRunDependency;
Module["preloadedImages"] = {}; // maps url to image data
Module["preloadedAudios"] = {}; // maps url to audio data
+#if PGO
+var PGOMonitor = {
+ called: {},
+ dump: function() {
+ var dead = [];
+ for (var i = 0; i < this.allGenerated.length; i++) {
+ var func = this.allGenerated[i];
+ if (!this.called[func]) dead.push(func);
+ }
+ Module.print('-s DEAD_FUNCTIONS=\'' + JSON.stringify(dead) + '\'\n');
+ }
+};
+__ATEXIT__.push({ func: function() { PGOMonitor.dump() } });
+if (!Module.preRun) Module.preRun = [];
+Module.preRun.push(function() { addRunDependency('pgo') });
+#endif
+
// === Body ===