wip polyfill [ci skip]
diff --git a/src/legacy_vm_support_polyfills.js b/src/legacy_vm_support_polyfills.js
new file mode 100644
index 0000000..c61503f
--- /dev/null
+++ b/src/legacy_vm_support_polyfills.js
@@ -0,0 +1,20 @@
+if (typeof Promise === 'undefined') {
+  // Minimal Promise polyfill, enough for emscripten's simple internal usage.
+  Promise = function(func) {
+    var then; // FIXME stackify!
+    var that = this;
+    this.then = function(then_) {
+      then = then_;
+      return that;
+    };
+    setTimeout(function() {
+      func(function promise_resolve() {
+        if (then) {
+          return then.apply(null, arguments);
+        }
+      }, abort);
+    }, 0);
+    return this;
+  };
+}
+
diff --git a/src/preamble.js b/src/preamble.js
index aac253b..43d2473 100644
--- a/src/preamble.js
+++ b/src/preamble.js
@@ -73,6 +73,10 @@
 #endif
 #endif // USE_PTHREADS
 
+#if LEGACY_VM_SUPPORT
+#include "legacy_vm_support_polyfills.js"
+#endif
+
 //========================================
 // Runtime essentials
 //========================================