@php-wasm/node-7-4 3.1.61 → 3.1.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/asyncify/7_4_33/php_7_4.wasm +0 -0
- package/asyncify/php_7_4.js +492 -478
- package/jspi/7_4_33/php_7_4.wasm +0 -0
- package/jspi/php_7_4.js +1125 -1111
- package/package.json +3 -3
package/asyncify/php_7_4.js
CHANGED
|
@@ -15,7 +15,7 @@ const currentDirPath =
|
|
|
15
15
|
: path.dirname(fileURLToPath(import.meta.url));
|
|
16
16
|
const dependencyFilename = path.join(currentDirPath, '7_4_33', 'php_7_4.wasm');
|
|
17
17
|
export { dependencyFilename };
|
|
18
|
-
export const dependenciesTotalSize =
|
|
18
|
+
export const dependenciesTotalSize = 18763147;
|
|
19
19
|
const phpVersionString = '7.4.33';
|
|
20
20
|
export function init(RuntimeName, PHPLoader) {
|
|
21
21
|
// The rest of the code comes from the built php.js file and esm-suffix.js
|
|
@@ -8551,6 +8551,14 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
8551
8551
|
|
|
8552
8552
|
_emscripten_resize_heap.sig = 'ip';
|
|
8553
8553
|
|
|
8554
|
+
var runAndAbortIfError = (func) => {
|
|
8555
|
+
try {
|
|
8556
|
+
return func();
|
|
8557
|
+
} catch (e) {
|
|
8558
|
+
abort(e);
|
|
8559
|
+
}
|
|
8560
|
+
};
|
|
8561
|
+
|
|
8554
8562
|
var runtimeKeepalivePush = () => {
|
|
8555
8563
|
runtimeKeepaliveCounter += 1;
|
|
8556
8564
|
};
|
|
@@ -8563,6 +8571,242 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
8563
8571
|
|
|
8564
8572
|
runtimeKeepalivePop.sig = 'v';
|
|
8565
8573
|
|
|
8574
|
+
var Asyncify = {
|
|
8575
|
+
instrumentWasmImports(imports) {
|
|
8576
|
+
var importPattern =
|
|
8577
|
+
/^(invoke_i|invoke_ii|invoke_iii|invoke_iiii|invoke_iiiii|invoke_iiiiii|invoke_iiiiiii|invoke_iiiiiiii|invoke_iiiiiiiii|invoke_iiiiiiiiii|invoke_v|invoke_vi|invoke_vii|invoke_viidii|invoke_viii|invoke_viiii|invoke_viiiii|invoke_viiiiii|invoke_viiiiiii|invoke_viiiiiiiii|invoke_i|invoke_ii|invoke_iii|invoke_iiii|invoke_iiiii|invoke_iiiiii|invoke_iiiiiii|invoke_iiiiiiii|invoke_iiiiiiiiii|invoke_iij|invoke_iiji|invoke_iiij|invoke_iijii|invoke_iijiji|invoke_jii|invoke_jiii|invoke_viijii|invoke_vji|js_open_process|_js_open_process|_asyncjs__js_open_process|js_popen_to_file|_js_popen_to_file|_asyncjs__js_popen_to_file|__syscall_fcntl64|___syscall_fcntl64|_asyncjs___syscall_fcntl64|js_release_file_locks|_js_release_file_locks|_async_js_release_file_locks|js_flock|_js_flock|_async_js_flock|js_fd_read|_js_fd_read|fd_close|_fd_close|_asyncjs__fd_close|close|_close|js_module_onMessage|zend_hash_str_find|_js_module_onMessage|_asyncjs__js_module_onMessage|js_waitpid|_js_waitpid|_asyncjs__js_waitpid|wasm_poll_socket|_wasm_poll_socket|_asyncjs__wasm_poll_socket|_wasm_shutdown|_asyncjs__wasm_shutdown|recv|_recv|setsockopt|_setsockopt|wasm_connect|_wasm_connect|__asyncjs__.*)$/;
|
|
8578
|
+
for (let [x, original] of Object.entries(imports)) {
|
|
8579
|
+
if (typeof original == 'function') {
|
|
8580
|
+
let isAsyncifyImport =
|
|
8581
|
+
original.isAsync || importPattern.test(x);
|
|
8582
|
+
}
|
|
8583
|
+
}
|
|
8584
|
+
},
|
|
8585
|
+
instrumentFunction(original) {
|
|
8586
|
+
var wrapper = (...args) => {
|
|
8587
|
+
Asyncify.exportCallStack.push(original);
|
|
8588
|
+
try {
|
|
8589
|
+
return original(...args);
|
|
8590
|
+
} finally {
|
|
8591
|
+
if (!ABORT) {
|
|
8592
|
+
var top = Asyncify.exportCallStack.pop();
|
|
8593
|
+
Asyncify.maybeStopUnwind();
|
|
8594
|
+
}
|
|
8595
|
+
}
|
|
8596
|
+
};
|
|
8597
|
+
Asyncify.funcWrappers.set(original, wrapper);
|
|
8598
|
+
wrapper.orig = original;
|
|
8599
|
+
return wrapper;
|
|
8600
|
+
},
|
|
8601
|
+
instrumentWasmExports(exports) {
|
|
8602
|
+
var ret = {};
|
|
8603
|
+
for (let [x, original] of Object.entries(exports)) {
|
|
8604
|
+
if (typeof original == 'function') {
|
|
8605
|
+
var wrapper = Asyncify.instrumentFunction(original);
|
|
8606
|
+
ret[x] = wrapper;
|
|
8607
|
+
} else {
|
|
8608
|
+
ret[x] = original;
|
|
8609
|
+
}
|
|
8610
|
+
}
|
|
8611
|
+
return ret;
|
|
8612
|
+
},
|
|
8613
|
+
State: {
|
|
8614
|
+
Normal: 0,
|
|
8615
|
+
Unwinding: 1,
|
|
8616
|
+
Rewinding: 2,
|
|
8617
|
+
Disabled: 3,
|
|
8618
|
+
},
|
|
8619
|
+
state: 0,
|
|
8620
|
+
StackSize: 4096,
|
|
8621
|
+
currData: null,
|
|
8622
|
+
handleSleepReturnValue: 0,
|
|
8623
|
+
exportCallStack: [],
|
|
8624
|
+
callstackFuncToId: new Map(),
|
|
8625
|
+
callStackIdToFunc: new Map(),
|
|
8626
|
+
funcWrappers: new Map(),
|
|
8627
|
+
callStackId: 0,
|
|
8628
|
+
asyncPromiseHandlers: null,
|
|
8629
|
+
sleepCallbacks: [],
|
|
8630
|
+
getCallStackId(func) {
|
|
8631
|
+
if (!Asyncify.callstackFuncToId.has(func)) {
|
|
8632
|
+
var id = Asyncify.callStackId++;
|
|
8633
|
+
Asyncify.callstackFuncToId.set(func, id);
|
|
8634
|
+
Asyncify.callStackIdToFunc.set(id, func);
|
|
8635
|
+
}
|
|
8636
|
+
return Asyncify.callstackFuncToId.get(func);
|
|
8637
|
+
},
|
|
8638
|
+
maybeStopUnwind() {
|
|
8639
|
+
if (
|
|
8640
|
+
Asyncify.currData &&
|
|
8641
|
+
Asyncify.state === Asyncify.State.Unwinding &&
|
|
8642
|
+
Asyncify.exportCallStack.length === 0
|
|
8643
|
+
) {
|
|
8644
|
+
// We just finished unwinding.
|
|
8645
|
+
// Be sure to set the state before calling any other functions to avoid
|
|
8646
|
+
// possible infinite recursion here (For example in debug pthread builds
|
|
8647
|
+
// the dbg() function itself can call back into WebAssembly to get the
|
|
8648
|
+
// current pthread_self() pointer).
|
|
8649
|
+
Asyncify.state = Asyncify.State.Normal;
|
|
8650
|
+
runtimeKeepalivePush();
|
|
8651
|
+
// Keep the runtime alive so that a re-wind can be done later.
|
|
8652
|
+
runAndAbortIfError(_asyncify_stop_unwind);
|
|
8653
|
+
if (typeof Fibers != 'undefined') {
|
|
8654
|
+
Fibers.trampoline();
|
|
8655
|
+
}
|
|
8656
|
+
}
|
|
8657
|
+
},
|
|
8658
|
+
whenDone() {
|
|
8659
|
+
return new Promise((resolve, reject) => {
|
|
8660
|
+
Asyncify.asyncPromiseHandlers = {
|
|
8661
|
+
resolve,
|
|
8662
|
+
reject,
|
|
8663
|
+
};
|
|
8664
|
+
});
|
|
8665
|
+
},
|
|
8666
|
+
allocateData() {
|
|
8667
|
+
// An asyncify data structure has three fields:
|
|
8668
|
+
// 0 current stack pos
|
|
8669
|
+
// 4 max stack pos
|
|
8670
|
+
// 8 id of function at bottom of the call stack (callStackIdToFunc[id] == wasm func)
|
|
8671
|
+
// The Asyncify ABI only interprets the first two fields, the rest is for the runtime.
|
|
8672
|
+
// We also embed a stack in the same memory region here, right next to the structure.
|
|
8673
|
+
// This struct is also defined as asyncify_data_t in emscripten/fiber.h
|
|
8674
|
+
var ptr = _malloc(12 + Asyncify.StackSize);
|
|
8675
|
+
Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
|
|
8676
|
+
Asyncify.setDataRewindFunc(ptr);
|
|
8677
|
+
return ptr;
|
|
8678
|
+
},
|
|
8679
|
+
setDataHeader(ptr, stack, stackSize) {
|
|
8680
|
+
HEAPU32[ptr >> 2] = stack;
|
|
8681
|
+
HEAPU32[(ptr + 4) >> 2] = stack + stackSize;
|
|
8682
|
+
},
|
|
8683
|
+
setDataRewindFunc(ptr) {
|
|
8684
|
+
var bottomOfCallStack = Asyncify.exportCallStack[0];
|
|
8685
|
+
var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
|
|
8686
|
+
HEAP32[(ptr + 8) >> 2] = rewindId;
|
|
8687
|
+
},
|
|
8688
|
+
getDataRewindFunc(ptr) {
|
|
8689
|
+
var id = HEAP32[(ptr + 8) >> 2];
|
|
8690
|
+
var func = Asyncify.callStackIdToFunc.get(id);
|
|
8691
|
+
return func;
|
|
8692
|
+
},
|
|
8693
|
+
doRewind(ptr) {
|
|
8694
|
+
var original = Asyncify.getDataRewindFunc(ptr);
|
|
8695
|
+
var func = Asyncify.funcWrappers.get(original);
|
|
8696
|
+
// Once we have rewound and the stack we no longer need to artificially
|
|
8697
|
+
// keep the runtime alive.
|
|
8698
|
+
runtimeKeepalivePop();
|
|
8699
|
+
return func();
|
|
8700
|
+
},
|
|
8701
|
+
handleSleep(startAsync) {
|
|
8702
|
+
if (ABORT) return;
|
|
8703
|
+
if (Asyncify.state === Asyncify.State.Normal) {
|
|
8704
|
+
// Prepare to sleep. Call startAsync, and see what happens:
|
|
8705
|
+
// if the code decided to call our callback synchronously,
|
|
8706
|
+
// then no async operation was in fact begun, and we don't
|
|
8707
|
+
// need to do anything.
|
|
8708
|
+
var reachedCallback = false;
|
|
8709
|
+
var reachedAfterCallback = false;
|
|
8710
|
+
startAsync((handleSleepReturnValue = 0) => {
|
|
8711
|
+
if (ABORT) return;
|
|
8712
|
+
Asyncify.handleSleepReturnValue = handleSleepReturnValue;
|
|
8713
|
+
reachedCallback = true;
|
|
8714
|
+
if (!reachedAfterCallback) {
|
|
8715
|
+
// We are happening synchronously, so no need for async.
|
|
8716
|
+
return;
|
|
8717
|
+
}
|
|
8718
|
+
Asyncify.state = Asyncify.State.Rewinding;
|
|
8719
|
+
runAndAbortIfError(() =>
|
|
8720
|
+
_asyncify_start_rewind(Asyncify.currData)
|
|
8721
|
+
);
|
|
8722
|
+
if (typeof MainLoop != 'undefined' && MainLoop.func) {
|
|
8723
|
+
MainLoop.resume();
|
|
8724
|
+
}
|
|
8725
|
+
var asyncWasmReturnValue,
|
|
8726
|
+
isError = false;
|
|
8727
|
+
try {
|
|
8728
|
+
asyncWasmReturnValue = Asyncify.doRewind(
|
|
8729
|
+
Asyncify.currData
|
|
8730
|
+
);
|
|
8731
|
+
} catch (err) {
|
|
8732
|
+
asyncWasmReturnValue = err;
|
|
8733
|
+
isError = true;
|
|
8734
|
+
}
|
|
8735
|
+
// Track whether the return value was handled by any promise handlers.
|
|
8736
|
+
var handled = false;
|
|
8737
|
+
if (!Asyncify.currData) {
|
|
8738
|
+
// All asynchronous execution has finished.
|
|
8739
|
+
// `asyncWasmReturnValue` now contains the final
|
|
8740
|
+
// return value of the exported async WASM function.
|
|
8741
|
+
// Note: `asyncWasmReturnValue` is distinct from
|
|
8742
|
+
// `Asyncify.handleSleepReturnValue`.
|
|
8743
|
+
// `Asyncify.handleSleepReturnValue` contains the return
|
|
8744
|
+
// value of the last C function to have executed
|
|
8745
|
+
// `Asyncify.handleSleep()`, where as `asyncWasmReturnValue`
|
|
8746
|
+
// contains the return value of the exported WASM function
|
|
8747
|
+
// that may have called C functions that
|
|
8748
|
+
// call `Asyncify.handleSleep()`.
|
|
8749
|
+
var asyncPromiseHandlers =
|
|
8750
|
+
Asyncify.asyncPromiseHandlers;
|
|
8751
|
+
if (asyncPromiseHandlers) {
|
|
8752
|
+
Asyncify.asyncPromiseHandlers = null;
|
|
8753
|
+
(isError
|
|
8754
|
+
? asyncPromiseHandlers.reject
|
|
8755
|
+
: asyncPromiseHandlers.resolve)(
|
|
8756
|
+
asyncWasmReturnValue
|
|
8757
|
+
);
|
|
8758
|
+
handled = true;
|
|
8759
|
+
}
|
|
8760
|
+
}
|
|
8761
|
+
if (isError && !handled) {
|
|
8762
|
+
// If there was an error and it was not handled by now, we have no choice but to
|
|
8763
|
+
// rethrow that error into the global scope where it can be caught only by
|
|
8764
|
+
// `onerror` or `onunhandledpromiserejection`.
|
|
8765
|
+
throw asyncWasmReturnValue;
|
|
8766
|
+
}
|
|
8767
|
+
});
|
|
8768
|
+
reachedAfterCallback = true;
|
|
8769
|
+
if (!reachedCallback) {
|
|
8770
|
+
// A true async operation was begun; start a sleep.
|
|
8771
|
+
Asyncify.state = Asyncify.State.Unwinding;
|
|
8772
|
+
// TODO: reuse, don't alloc/free every sleep
|
|
8773
|
+
if (!Asyncify._cachedData) {
|
|
8774
|
+
Asyncify._cachedData = Asyncify.allocateData();
|
|
8775
|
+
} else {
|
|
8776
|
+
Asyncify.setDataHeader(
|
|
8777
|
+
Asyncify._cachedData,
|
|
8778
|
+
Asyncify._cachedData + 12,
|
|
8779
|
+
Asyncify.StackSize
|
|
8780
|
+
);
|
|
8781
|
+
Asyncify.setDataRewindFunc(Asyncify._cachedData);
|
|
8782
|
+
}
|
|
8783
|
+
Asyncify.currData = Asyncify._cachedData;
|
|
8784
|
+
if (typeof MainLoop != 'undefined' && MainLoop.func) {
|
|
8785
|
+
MainLoop.pause();
|
|
8786
|
+
}
|
|
8787
|
+
runAndAbortIfError(() =>
|
|
8788
|
+
_asyncify_start_unwind(Asyncify.currData)
|
|
8789
|
+
);
|
|
8790
|
+
}
|
|
8791
|
+
} else if (Asyncify.state === Asyncify.State.Rewinding) {
|
|
8792
|
+
// Stop a resume.
|
|
8793
|
+
Asyncify.state = Asyncify.State.Normal;
|
|
8794
|
+
runAndAbortIfError(_asyncify_stop_rewind);
|
|
8795
|
+
Asyncify.currData = null;
|
|
8796
|
+
// Call all sleep callbacks now that the sleep-resume is all done.
|
|
8797
|
+
Asyncify.sleepCallbacks.forEach(callUserCallback);
|
|
8798
|
+
} else {
|
|
8799
|
+
abort(`invalid state: ${Asyncify.state}`);
|
|
8800
|
+
}
|
|
8801
|
+
return Asyncify.handleSleepReturnValue;
|
|
8802
|
+
},
|
|
8803
|
+
handleAsync: (startAsync) =>
|
|
8804
|
+
Asyncify.handleSleep((wakeUp) => {
|
|
8805
|
+
// TODO: add error handling as a second param when handleSleep implements it.
|
|
8806
|
+
startAsync().then(wakeUp);
|
|
8807
|
+
}),
|
|
8808
|
+
};
|
|
8809
|
+
|
|
8566
8810
|
/** @param {number=} timeout */ var safeSetTimeout = (func, timeout) => {
|
|
8567
8811
|
runtimeKeepalivePush();
|
|
8568
8812
|
return setTimeout(() => {
|
|
@@ -8571,8 +8815,22 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
8571
8815
|
}, timeout);
|
|
8572
8816
|
};
|
|
8573
8817
|
|
|
8574
|
-
var _emscripten_sleep = (ms)
|
|
8575
|
-
Asyncify.handleSleep((wakeUp) =>
|
|
8818
|
+
var _emscripten_sleep = function (ms) {
|
|
8819
|
+
return Asyncify.handleSleep((wakeUp) => {
|
|
8820
|
+
// select() yields between socket reads. Nested zero-delay timers are
|
|
8821
|
+
// clamped by browsers, adding seconds to even a local curl download.
|
|
8822
|
+
// Use a task (not a microtask) so network events still get a turn.
|
|
8823
|
+
if (ms === 0 && globalThis.scheduler?.postTask) {
|
|
8824
|
+
runtimeKeepalivePush();
|
|
8825
|
+
globalThis.scheduler.postTask(() => {
|
|
8826
|
+
runtimeKeepalivePop();
|
|
8827
|
+
callUserCallback(wakeUp);
|
|
8828
|
+
});
|
|
8829
|
+
} else {
|
|
8830
|
+
safeSetTimeout(wakeUp, ms);
|
|
8831
|
+
}
|
|
8832
|
+
});
|
|
8833
|
+
};
|
|
8576
8834
|
|
|
8577
8835
|
_emscripten_sleep.sig = 'vi';
|
|
8578
8836
|
|
|
@@ -9751,418 +10009,174 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
9751
10009
|
var janFirst = new Date(date.year, 0, 1);
|
|
9752
10010
|
var endDate;
|
|
9753
10011
|
if (janFirst.getDay() === 0) {
|
|
9754
|
-
// Jan 1st is a Sunday, and, hence in the 1st CW
|
|
9755
|
-
endDate = addDays(
|
|
9756
|
-
janFirst,
|
|
9757
|
-
weekDayNumber + 7 * (weekNumber - 1)
|
|
9758
|
-
);
|
|
9759
|
-
} else {
|
|
9760
|
-
// Jan 1st is not a Sunday, and, hence still in the 0th CW
|
|
9761
|
-
endDate = addDays(
|
|
9762
|
-
janFirst,
|
|
9763
|
-
7 -
|
|
9764
|
-
janFirst.getDay() +
|
|
9765
|
-
weekDayNumber +
|
|
9766
|
-
7 * (weekNumber - 1)
|
|
9767
|
-
);
|
|
9768
|
-
}
|
|
9769
|
-
date.day = endDate.getDate();
|
|
9770
|
-
date.month = endDate.getMonth();
|
|
9771
|
-
} else if ((value = getMatch('W'))) {
|
|
9772
|
-
// ... and week number (Monday being first day of week)
|
|
9773
|
-
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
|
|
9774
|
-
// All days in a new year preceding the first Monday are considered to be in week 0.
|
|
9775
|
-
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
|
|
9776
|
-
var weekNumber = Number(value);
|
|
9777
|
-
// January 1st
|
|
9778
|
-
var janFirst = new Date(date.year, 0, 1);
|
|
9779
|
-
var endDate;
|
|
9780
|
-
if (janFirst.getDay() === 1) {
|
|
9781
|
-
// Jan 1st is a Monday, and, hence in the 1st CW
|
|
9782
|
-
endDate = addDays(
|
|
9783
|
-
janFirst,
|
|
9784
|
-
weekDayNumber + 7 * (weekNumber - 1)
|
|
9785
|
-
);
|
|
9786
|
-
} else {
|
|
9787
|
-
// Jan 1st is not a Monday, and, hence still in the 0th CW
|
|
9788
|
-
endDate = addDays(
|
|
9789
|
-
janFirst,
|
|
9790
|
-
7 -
|
|
9791
|
-
janFirst.getDay() +
|
|
9792
|
-
1 +
|
|
9793
|
-
weekDayNumber +
|
|
9794
|
-
7 * (weekNumber - 1)
|
|
9795
|
-
);
|
|
9796
|
-
}
|
|
9797
|
-
date.day = endDate.getDate();
|
|
9798
|
-
date.month = endDate.getMonth();
|
|
9799
|
-
}
|
|
9800
|
-
}
|
|
9801
|
-
// time zone
|
|
9802
|
-
if ((value = getMatch('z'))) {
|
|
9803
|
-
// GMT offset as either 'Z' or +-HH:MM or +-HH or +-HHMM
|
|
9804
|
-
if (value.toLowerCase() === 'z') {
|
|
9805
|
-
date.gmtoff = 0;
|
|
9806
|
-
} else {
|
|
9807
|
-
var match = value.match(/^((?:\-|\+)\d\d):?(\d\d)?/);
|
|
9808
|
-
date.gmtoff = match[1] * 3600;
|
|
9809
|
-
if (match[2]) {
|
|
9810
|
-
date.gmtoff +=
|
|
9811
|
-
date.gmtoff > 0 ? match[2] * 60 : -match[2] * 60;
|
|
9812
|
-
}
|
|
9813
|
-
}
|
|
9814
|
-
}
|
|
9815
|
-
/*
|
|
9816
|
-
tm_sec int seconds after the minute 0-61*
|
|
9817
|
-
tm_min int minutes after the hour 0-59
|
|
9818
|
-
tm_hour int hours since midnight 0-23
|
|
9819
|
-
tm_mday int day of the month 1-31
|
|
9820
|
-
tm_mon int months since January 0-11
|
|
9821
|
-
tm_year int years since 1900
|
|
9822
|
-
tm_wday int days since Sunday 0-6
|
|
9823
|
-
tm_yday int days since January 1 0-365
|
|
9824
|
-
tm_isdst int Daylight Saving Time flag
|
|
9825
|
-
tm_gmtoff long offset from GMT (seconds)
|
|
9826
|
-
*/ var fullDate = new Date(
|
|
9827
|
-
date.year,
|
|
9828
|
-
date.month,
|
|
9829
|
-
date.day,
|
|
9830
|
-
date.hour,
|
|
9831
|
-
date.min,
|
|
9832
|
-
date.sec,
|
|
9833
|
-
0
|
|
9834
|
-
);
|
|
9835
|
-
HEAP32[tm >> 2] = fullDate.getSeconds();
|
|
9836
|
-
HEAP32[(tm + 4) >> 2] = fullDate.getMinutes();
|
|
9837
|
-
HEAP32[(tm + 8) >> 2] = fullDate.getHours();
|
|
9838
|
-
HEAP32[(tm + 12) >> 2] = fullDate.getDate();
|
|
9839
|
-
HEAP32[(tm + 16) >> 2] = fullDate.getMonth();
|
|
9840
|
-
HEAP32[(tm + 20) >> 2] = fullDate.getFullYear() - 1900;
|
|
9841
|
-
HEAP32[(tm + 24) >> 2] = fullDate.getDay();
|
|
9842
|
-
HEAP32[(tm + 28) >> 2] =
|
|
9843
|
-
arraySum(
|
|
9844
|
-
isLeapYear(fullDate.getFullYear())
|
|
9845
|
-
? MONTH_DAYS_LEAP
|
|
9846
|
-
: MONTH_DAYS_REGULAR,
|
|
9847
|
-
fullDate.getMonth() - 1
|
|
9848
|
-
) +
|
|
9849
|
-
fullDate.getDate() -
|
|
9850
|
-
1;
|
|
9851
|
-
HEAP32[(tm + 32) >> 2] = 0;
|
|
9852
|
-
HEAP32[(tm + 36) >> 2] = date.gmtoff;
|
|
9853
|
-
// we need to convert the matched sequence into an integer array to take care of UTF-8 characters > 0x7F
|
|
9854
|
-
// TODO: not sure that intArrayFromString handles all unicode characters correctly
|
|
9855
|
-
return buf + lengthBytesUTF8(matches[0]);
|
|
9856
|
-
}
|
|
9857
|
-
return 0;
|
|
9858
|
-
};
|
|
9859
|
-
|
|
9860
|
-
_strptime.sig = 'pppp';
|
|
9861
|
-
|
|
9862
|
-
function _wasm_close(socketd) {
|
|
9863
|
-
return PHPWASM.shutdownSocket(socketd, 2);
|
|
9864
|
-
}
|
|
9865
|
-
|
|
9866
|
-
function _wasm_setsockopt(
|
|
9867
|
-
socketd,
|
|
9868
|
-
level,
|
|
9869
|
-
optionName,
|
|
9870
|
-
optionValuePtr,
|
|
9871
|
-
optionLen
|
|
9872
|
-
) {
|
|
9873
|
-
const optionValue = HEAPU8[optionValuePtr];
|
|
9874
|
-
const SOL_SOCKET = 1;
|
|
9875
|
-
const SO_KEEPALIVE = 9;
|
|
9876
|
-
const SO_RCVTIMEO = 66;
|
|
9877
|
-
const SO_SNDTIMEO = 67;
|
|
9878
|
-
const IPPROTO_TCP = 6;
|
|
9879
|
-
const TCP_NODELAY = 1;
|
|
9880
|
-
if (
|
|
9881
|
-
level === SOL_SOCKET &&
|
|
9882
|
-
(optionName === SO_RCVTIMEO || optionName === SO_SNDTIMEO)
|
|
9883
|
-
) {
|
|
9884
|
-
const timeoutMs = PHPWASM.parseSocketTimeout(
|
|
9885
|
-
optionValuePtr,
|
|
9886
|
-
optionLen
|
|
9887
|
-
);
|
|
9888
|
-
if (timeoutMs === null) {
|
|
9889
|
-
return -1;
|
|
9890
|
-
}
|
|
9891
|
-
const timeouts = PHPWASM.socketTimeouts.get(socketd) || {};
|
|
9892
|
-
if (optionName === SO_RCVTIMEO) {
|
|
9893
|
-
timeouts.receive = timeoutMs;
|
|
9894
|
-
} else {
|
|
9895
|
-
timeouts.send = timeoutMs;
|
|
9896
|
-
}
|
|
9897
|
-
PHPWASM.socketTimeouts.set(socketd, timeouts);
|
|
9898
|
-
return 0;
|
|
9899
|
-
}
|
|
9900
|
-
// Options that we can forward to the WebSocket proxy
|
|
9901
|
-
const isForwardable =
|
|
9902
|
-
(level === SOL_SOCKET && optionName === SO_KEEPALIVE) ||
|
|
9903
|
-
(level === IPPROTO_TCP && optionName === TCP_NODELAY);
|
|
9904
|
-
if (!isForwardable) {
|
|
9905
|
-
console.warn(
|
|
9906
|
-
`Unsupported socket option: ${level}, ${optionName}, ${optionValue}`
|
|
9907
|
-
);
|
|
9908
|
-
return -1;
|
|
9909
|
-
}
|
|
9910
|
-
const ws = PHPWASM.getAllWebSockets(socketd)[0];
|
|
9911
|
-
if (!ws) {
|
|
9912
|
-
return -1;
|
|
9913
|
-
}
|
|
9914
|
-
ws.setSocketOpt(level, optionName, optionValuePtr);
|
|
9915
|
-
return 0;
|
|
9916
|
-
}
|
|
9917
|
-
|
|
9918
|
-
function _wasm_shutdown(socketd, how) {
|
|
9919
|
-
return PHPWASM.shutdownSocket(socketd, how);
|
|
9920
|
-
}
|
|
9921
|
-
|
|
9922
|
-
var runAndAbortIfError = (func) => {
|
|
9923
|
-
try {
|
|
9924
|
-
return func();
|
|
9925
|
-
} catch (e) {
|
|
9926
|
-
abort(e);
|
|
9927
|
-
}
|
|
9928
|
-
};
|
|
9929
|
-
|
|
9930
|
-
var Asyncify = {
|
|
9931
|
-
instrumentWasmImports(imports) {
|
|
9932
|
-
var importPattern =
|
|
9933
|
-
/^(invoke_i|invoke_ii|invoke_iii|invoke_iiii|invoke_iiiii|invoke_iiiiii|invoke_iiiiiii|invoke_iiiiiiii|invoke_iiiiiiiii|invoke_iiiiiiiiii|invoke_v|invoke_vi|invoke_vii|invoke_viidii|invoke_viii|invoke_viiii|invoke_viiiii|invoke_viiiiii|invoke_viiiiiii|invoke_viiiiiiiii|invoke_i|invoke_ii|invoke_iii|invoke_iiii|invoke_iiiii|invoke_iiiiii|invoke_iiiiiii|invoke_iiiiiiii|invoke_iiiiiiiiii|invoke_iij|invoke_iiji|invoke_iiij|invoke_iijii|invoke_iijiji|invoke_jii|invoke_jiii|invoke_viijii|invoke_vji|js_open_process|_js_open_process|_asyncjs__js_open_process|js_popen_to_file|_js_popen_to_file|_asyncjs__js_popen_to_file|__syscall_fcntl64|___syscall_fcntl64|_asyncjs___syscall_fcntl64|js_release_file_locks|_js_release_file_locks|_async_js_release_file_locks|js_flock|_js_flock|_async_js_flock|js_fd_read|_js_fd_read|fd_close|_fd_close|_asyncjs__fd_close|close|_close|js_module_onMessage|zend_hash_str_find|_js_module_onMessage|_asyncjs__js_module_onMessage|js_waitpid|_js_waitpid|_asyncjs__js_waitpid|wasm_poll_socket|_wasm_poll_socket|_asyncjs__wasm_poll_socket|_wasm_shutdown|_asyncjs__wasm_shutdown|recv|_recv|setsockopt|_setsockopt|wasm_connect|_wasm_connect|__asyncjs__.*)$/;
|
|
9934
|
-
for (let [x, original] of Object.entries(imports)) {
|
|
9935
|
-
if (typeof original == 'function') {
|
|
9936
|
-
let isAsyncifyImport =
|
|
9937
|
-
original.isAsync || importPattern.test(x);
|
|
9938
|
-
}
|
|
9939
|
-
}
|
|
9940
|
-
},
|
|
9941
|
-
instrumentFunction(original) {
|
|
9942
|
-
var wrapper = (...args) => {
|
|
9943
|
-
Asyncify.exportCallStack.push(original);
|
|
9944
|
-
try {
|
|
9945
|
-
return original(...args);
|
|
9946
|
-
} finally {
|
|
9947
|
-
if (!ABORT) {
|
|
9948
|
-
var top = Asyncify.exportCallStack.pop();
|
|
9949
|
-
Asyncify.maybeStopUnwind();
|
|
9950
|
-
}
|
|
9951
|
-
}
|
|
9952
|
-
};
|
|
9953
|
-
Asyncify.funcWrappers.set(original, wrapper);
|
|
9954
|
-
wrapper.orig = original;
|
|
9955
|
-
return wrapper;
|
|
9956
|
-
},
|
|
9957
|
-
instrumentWasmExports(exports) {
|
|
9958
|
-
var ret = {};
|
|
9959
|
-
for (let [x, original] of Object.entries(exports)) {
|
|
9960
|
-
if (typeof original == 'function') {
|
|
9961
|
-
var wrapper = Asyncify.instrumentFunction(original);
|
|
9962
|
-
ret[x] = wrapper;
|
|
9963
|
-
} else {
|
|
9964
|
-
ret[x] = original;
|
|
9965
|
-
}
|
|
9966
|
-
}
|
|
9967
|
-
return ret;
|
|
9968
|
-
},
|
|
9969
|
-
State: {
|
|
9970
|
-
Normal: 0,
|
|
9971
|
-
Unwinding: 1,
|
|
9972
|
-
Rewinding: 2,
|
|
9973
|
-
Disabled: 3,
|
|
9974
|
-
},
|
|
9975
|
-
state: 0,
|
|
9976
|
-
StackSize: 4096,
|
|
9977
|
-
currData: null,
|
|
9978
|
-
handleSleepReturnValue: 0,
|
|
9979
|
-
exportCallStack: [],
|
|
9980
|
-
callstackFuncToId: new Map(),
|
|
9981
|
-
callStackIdToFunc: new Map(),
|
|
9982
|
-
funcWrappers: new Map(),
|
|
9983
|
-
callStackId: 0,
|
|
9984
|
-
asyncPromiseHandlers: null,
|
|
9985
|
-
sleepCallbacks: [],
|
|
9986
|
-
getCallStackId(func) {
|
|
9987
|
-
if (!Asyncify.callstackFuncToId.has(func)) {
|
|
9988
|
-
var id = Asyncify.callStackId++;
|
|
9989
|
-
Asyncify.callstackFuncToId.set(func, id);
|
|
9990
|
-
Asyncify.callStackIdToFunc.set(id, func);
|
|
9991
|
-
}
|
|
9992
|
-
return Asyncify.callstackFuncToId.get(func);
|
|
9993
|
-
},
|
|
9994
|
-
maybeStopUnwind() {
|
|
9995
|
-
if (
|
|
9996
|
-
Asyncify.currData &&
|
|
9997
|
-
Asyncify.state === Asyncify.State.Unwinding &&
|
|
9998
|
-
Asyncify.exportCallStack.length === 0
|
|
9999
|
-
) {
|
|
10000
|
-
// We just finished unwinding.
|
|
10001
|
-
// Be sure to set the state before calling any other functions to avoid
|
|
10002
|
-
// possible infinite recursion here (For example in debug pthread builds
|
|
10003
|
-
// the dbg() function itself can call back into WebAssembly to get the
|
|
10004
|
-
// current pthread_self() pointer).
|
|
10005
|
-
Asyncify.state = Asyncify.State.Normal;
|
|
10006
|
-
runtimeKeepalivePush();
|
|
10007
|
-
// Keep the runtime alive so that a re-wind can be done later.
|
|
10008
|
-
runAndAbortIfError(_asyncify_stop_unwind);
|
|
10009
|
-
if (typeof Fibers != 'undefined') {
|
|
10010
|
-
Fibers.trampoline();
|
|
10011
|
-
}
|
|
10012
|
-
}
|
|
10013
|
-
},
|
|
10014
|
-
whenDone() {
|
|
10015
|
-
return new Promise((resolve, reject) => {
|
|
10016
|
-
Asyncify.asyncPromiseHandlers = {
|
|
10017
|
-
resolve,
|
|
10018
|
-
reject,
|
|
10019
|
-
};
|
|
10020
|
-
});
|
|
10021
|
-
},
|
|
10022
|
-
allocateData() {
|
|
10023
|
-
// An asyncify data structure has three fields:
|
|
10024
|
-
// 0 current stack pos
|
|
10025
|
-
// 4 max stack pos
|
|
10026
|
-
// 8 id of function at bottom of the call stack (callStackIdToFunc[id] == wasm func)
|
|
10027
|
-
// The Asyncify ABI only interprets the first two fields, the rest is for the runtime.
|
|
10028
|
-
// We also embed a stack in the same memory region here, right next to the structure.
|
|
10029
|
-
// This struct is also defined as asyncify_data_t in emscripten/fiber.h
|
|
10030
|
-
var ptr = _malloc(12 + Asyncify.StackSize);
|
|
10031
|
-
Asyncify.setDataHeader(ptr, ptr + 12, Asyncify.StackSize);
|
|
10032
|
-
Asyncify.setDataRewindFunc(ptr);
|
|
10033
|
-
return ptr;
|
|
10034
|
-
},
|
|
10035
|
-
setDataHeader(ptr, stack, stackSize) {
|
|
10036
|
-
HEAPU32[ptr >> 2] = stack;
|
|
10037
|
-
HEAPU32[(ptr + 4) >> 2] = stack + stackSize;
|
|
10038
|
-
},
|
|
10039
|
-
setDataRewindFunc(ptr) {
|
|
10040
|
-
var bottomOfCallStack = Asyncify.exportCallStack[0];
|
|
10041
|
-
var rewindId = Asyncify.getCallStackId(bottomOfCallStack);
|
|
10042
|
-
HEAP32[(ptr + 8) >> 2] = rewindId;
|
|
10043
|
-
},
|
|
10044
|
-
getDataRewindFunc(ptr) {
|
|
10045
|
-
var id = HEAP32[(ptr + 8) >> 2];
|
|
10046
|
-
var func = Asyncify.callStackIdToFunc.get(id);
|
|
10047
|
-
return func;
|
|
10048
|
-
},
|
|
10049
|
-
doRewind(ptr) {
|
|
10050
|
-
var original = Asyncify.getDataRewindFunc(ptr);
|
|
10051
|
-
var func = Asyncify.funcWrappers.get(original);
|
|
10052
|
-
// Once we have rewound and the stack we no longer need to artificially
|
|
10053
|
-
// keep the runtime alive.
|
|
10054
|
-
runtimeKeepalivePop();
|
|
10055
|
-
return func();
|
|
10056
|
-
},
|
|
10057
|
-
handleSleep(startAsync) {
|
|
10058
|
-
if (ABORT) return;
|
|
10059
|
-
if (Asyncify.state === Asyncify.State.Normal) {
|
|
10060
|
-
// Prepare to sleep. Call startAsync, and see what happens:
|
|
10061
|
-
// if the code decided to call our callback synchronously,
|
|
10062
|
-
// then no async operation was in fact begun, and we don't
|
|
10063
|
-
// need to do anything.
|
|
10064
|
-
var reachedCallback = false;
|
|
10065
|
-
var reachedAfterCallback = false;
|
|
10066
|
-
startAsync((handleSleepReturnValue = 0) => {
|
|
10067
|
-
if (ABORT) return;
|
|
10068
|
-
Asyncify.handleSleepReturnValue = handleSleepReturnValue;
|
|
10069
|
-
reachedCallback = true;
|
|
10070
|
-
if (!reachedAfterCallback) {
|
|
10071
|
-
// We are happening synchronously, so no need for async.
|
|
10072
|
-
return;
|
|
10073
|
-
}
|
|
10074
|
-
Asyncify.state = Asyncify.State.Rewinding;
|
|
10075
|
-
runAndAbortIfError(() =>
|
|
10076
|
-
_asyncify_start_rewind(Asyncify.currData)
|
|
10077
|
-
);
|
|
10078
|
-
if (typeof MainLoop != 'undefined' && MainLoop.func) {
|
|
10079
|
-
MainLoop.resume();
|
|
10080
|
-
}
|
|
10081
|
-
var asyncWasmReturnValue,
|
|
10082
|
-
isError = false;
|
|
10083
|
-
try {
|
|
10084
|
-
asyncWasmReturnValue = Asyncify.doRewind(
|
|
10085
|
-
Asyncify.currData
|
|
10086
|
-
);
|
|
10087
|
-
} catch (err) {
|
|
10088
|
-
asyncWasmReturnValue = err;
|
|
10089
|
-
isError = true;
|
|
10090
|
-
}
|
|
10091
|
-
// Track whether the return value was handled by any promise handlers.
|
|
10092
|
-
var handled = false;
|
|
10093
|
-
if (!Asyncify.currData) {
|
|
10094
|
-
// All asynchronous execution has finished.
|
|
10095
|
-
// `asyncWasmReturnValue` now contains the final
|
|
10096
|
-
// return value of the exported async WASM function.
|
|
10097
|
-
// Note: `asyncWasmReturnValue` is distinct from
|
|
10098
|
-
// `Asyncify.handleSleepReturnValue`.
|
|
10099
|
-
// `Asyncify.handleSleepReturnValue` contains the return
|
|
10100
|
-
// value of the last C function to have executed
|
|
10101
|
-
// `Asyncify.handleSleep()`, where as `asyncWasmReturnValue`
|
|
10102
|
-
// contains the return value of the exported WASM function
|
|
10103
|
-
// that may have called C functions that
|
|
10104
|
-
// call `Asyncify.handleSleep()`.
|
|
10105
|
-
var asyncPromiseHandlers =
|
|
10106
|
-
Asyncify.asyncPromiseHandlers;
|
|
10107
|
-
if (asyncPromiseHandlers) {
|
|
10108
|
-
Asyncify.asyncPromiseHandlers = null;
|
|
10109
|
-
(isError
|
|
10110
|
-
? asyncPromiseHandlers.reject
|
|
10111
|
-
: asyncPromiseHandlers.resolve)(
|
|
10112
|
-
asyncWasmReturnValue
|
|
10113
|
-
);
|
|
10114
|
-
handled = true;
|
|
10115
|
-
}
|
|
10116
|
-
}
|
|
10117
|
-
if (isError && !handled) {
|
|
10118
|
-
// If there was an error and it was not handled by now, we have no choice but to
|
|
10119
|
-
// rethrow that error into the global scope where it can be caught only by
|
|
10120
|
-
// `onerror` or `onunhandledpromiserejection`.
|
|
10121
|
-
throw asyncWasmReturnValue;
|
|
10012
|
+
// Jan 1st is a Sunday, and, hence in the 1st CW
|
|
10013
|
+
endDate = addDays(
|
|
10014
|
+
janFirst,
|
|
10015
|
+
weekDayNumber + 7 * (weekNumber - 1)
|
|
10016
|
+
);
|
|
10017
|
+
} else {
|
|
10018
|
+
// Jan 1st is not a Sunday, and, hence still in the 0th CW
|
|
10019
|
+
endDate = addDays(
|
|
10020
|
+
janFirst,
|
|
10021
|
+
7 -
|
|
10022
|
+
janFirst.getDay() +
|
|
10023
|
+
weekDayNumber +
|
|
10024
|
+
7 * (weekNumber - 1)
|
|
10025
|
+
);
|
|
10122
10026
|
}
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
if (
|
|
10126
|
-
//
|
|
10127
|
-
|
|
10128
|
-
//
|
|
10129
|
-
|
|
10130
|
-
|
|
10027
|
+
date.day = endDate.getDate();
|
|
10028
|
+
date.month = endDate.getMonth();
|
|
10029
|
+
} else if ((value = getMatch('W'))) {
|
|
10030
|
+
// ... and week number (Monday being first day of week)
|
|
10031
|
+
// Week number of the year (Monday as the first day of the week) as a decimal number [00,53].
|
|
10032
|
+
// All days in a new year preceding the first Monday are considered to be in week 0.
|
|
10033
|
+
var weekDayNumber = DAY_NUMBERS_MON_FIRST[weekDay];
|
|
10034
|
+
var weekNumber = Number(value);
|
|
10035
|
+
// January 1st
|
|
10036
|
+
var janFirst = new Date(date.year, 0, 1);
|
|
10037
|
+
var endDate;
|
|
10038
|
+
if (janFirst.getDay() === 1) {
|
|
10039
|
+
// Jan 1st is a Monday, and, hence in the 1st CW
|
|
10040
|
+
endDate = addDays(
|
|
10041
|
+
janFirst,
|
|
10042
|
+
weekDayNumber + 7 * (weekNumber - 1)
|
|
10043
|
+
);
|
|
10131
10044
|
} else {
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10045
|
+
// Jan 1st is not a Monday, and, hence still in the 0th CW
|
|
10046
|
+
endDate = addDays(
|
|
10047
|
+
janFirst,
|
|
10048
|
+
7 -
|
|
10049
|
+
janFirst.getDay() +
|
|
10050
|
+
1 +
|
|
10051
|
+
weekDayNumber +
|
|
10052
|
+
7 * (weekNumber - 1)
|
|
10136
10053
|
);
|
|
10137
|
-
Asyncify.setDataRewindFunc(Asyncify._cachedData);
|
|
10138
10054
|
}
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10055
|
+
date.day = endDate.getDate();
|
|
10056
|
+
date.month = endDate.getMonth();
|
|
10057
|
+
}
|
|
10058
|
+
}
|
|
10059
|
+
// time zone
|
|
10060
|
+
if ((value = getMatch('z'))) {
|
|
10061
|
+
// GMT offset as either 'Z' or +-HH:MM or +-HH or +-HHMM
|
|
10062
|
+
if (value.toLowerCase() === 'z') {
|
|
10063
|
+
date.gmtoff = 0;
|
|
10064
|
+
} else {
|
|
10065
|
+
var match = value.match(/^((?:\-|\+)\d\d):?(\d\d)?/);
|
|
10066
|
+
date.gmtoff = match[1] * 3600;
|
|
10067
|
+
if (match[2]) {
|
|
10068
|
+
date.gmtoff +=
|
|
10069
|
+
date.gmtoff > 0 ? match[2] * 60 : -match[2] * 60;
|
|
10142
10070
|
}
|
|
10143
|
-
runAndAbortIfError(() =>
|
|
10144
|
-
_asyncify_start_unwind(Asyncify.currData)
|
|
10145
|
-
);
|
|
10146
10071
|
}
|
|
10147
|
-
} else if (Asyncify.state === Asyncify.State.Rewinding) {
|
|
10148
|
-
// Stop a resume.
|
|
10149
|
-
Asyncify.state = Asyncify.State.Normal;
|
|
10150
|
-
runAndAbortIfError(_asyncify_stop_rewind);
|
|
10151
|
-
Asyncify.currData = null;
|
|
10152
|
-
// Call all sleep callbacks now that the sleep-resume is all done.
|
|
10153
|
-
Asyncify.sleepCallbacks.forEach(callUserCallback);
|
|
10154
|
-
} else {
|
|
10155
|
-
abort(`invalid state: ${Asyncify.state}`);
|
|
10156
10072
|
}
|
|
10157
|
-
|
|
10158
|
-
|
|
10159
|
-
|
|
10160
|
-
|
|
10161
|
-
|
|
10162
|
-
|
|
10163
|
-
|
|
10073
|
+
/*
|
|
10074
|
+
tm_sec int seconds after the minute 0-61*
|
|
10075
|
+
tm_min int minutes after the hour 0-59
|
|
10076
|
+
tm_hour int hours since midnight 0-23
|
|
10077
|
+
tm_mday int day of the month 1-31
|
|
10078
|
+
tm_mon int months since January 0-11
|
|
10079
|
+
tm_year int years since 1900
|
|
10080
|
+
tm_wday int days since Sunday 0-6
|
|
10081
|
+
tm_yday int days since January 1 0-365
|
|
10082
|
+
tm_isdst int Daylight Saving Time flag
|
|
10083
|
+
tm_gmtoff long offset from GMT (seconds)
|
|
10084
|
+
*/ var fullDate = new Date(
|
|
10085
|
+
date.year,
|
|
10086
|
+
date.month,
|
|
10087
|
+
date.day,
|
|
10088
|
+
date.hour,
|
|
10089
|
+
date.min,
|
|
10090
|
+
date.sec,
|
|
10091
|
+
0
|
|
10092
|
+
);
|
|
10093
|
+
HEAP32[tm >> 2] = fullDate.getSeconds();
|
|
10094
|
+
HEAP32[(tm + 4) >> 2] = fullDate.getMinutes();
|
|
10095
|
+
HEAP32[(tm + 8) >> 2] = fullDate.getHours();
|
|
10096
|
+
HEAP32[(tm + 12) >> 2] = fullDate.getDate();
|
|
10097
|
+
HEAP32[(tm + 16) >> 2] = fullDate.getMonth();
|
|
10098
|
+
HEAP32[(tm + 20) >> 2] = fullDate.getFullYear() - 1900;
|
|
10099
|
+
HEAP32[(tm + 24) >> 2] = fullDate.getDay();
|
|
10100
|
+
HEAP32[(tm + 28) >> 2] =
|
|
10101
|
+
arraySum(
|
|
10102
|
+
isLeapYear(fullDate.getFullYear())
|
|
10103
|
+
? MONTH_DAYS_LEAP
|
|
10104
|
+
: MONTH_DAYS_REGULAR,
|
|
10105
|
+
fullDate.getMonth() - 1
|
|
10106
|
+
) +
|
|
10107
|
+
fullDate.getDate() -
|
|
10108
|
+
1;
|
|
10109
|
+
HEAP32[(tm + 32) >> 2] = 0;
|
|
10110
|
+
HEAP32[(tm + 36) >> 2] = date.gmtoff;
|
|
10111
|
+
// we need to convert the matched sequence into an integer array to take care of UTF-8 characters > 0x7F
|
|
10112
|
+
// TODO: not sure that intArrayFromString handles all unicode characters correctly
|
|
10113
|
+
return buf + lengthBytesUTF8(matches[0]);
|
|
10114
|
+
}
|
|
10115
|
+
return 0;
|
|
10164
10116
|
};
|
|
10165
10117
|
|
|
10118
|
+
_strptime.sig = 'pppp';
|
|
10119
|
+
|
|
10120
|
+
function _wasm_close(socketd) {
|
|
10121
|
+
return PHPWASM.shutdownSocket(socketd, 2);
|
|
10122
|
+
}
|
|
10123
|
+
|
|
10124
|
+
function _wasm_setsockopt(
|
|
10125
|
+
socketd,
|
|
10126
|
+
level,
|
|
10127
|
+
optionName,
|
|
10128
|
+
optionValuePtr,
|
|
10129
|
+
optionLen
|
|
10130
|
+
) {
|
|
10131
|
+
const optionValue = HEAPU8[optionValuePtr];
|
|
10132
|
+
const SOL_SOCKET = 1;
|
|
10133
|
+
const SO_KEEPALIVE = 9;
|
|
10134
|
+
const SO_RCVTIMEO = 66;
|
|
10135
|
+
const SO_SNDTIMEO = 67;
|
|
10136
|
+
const IPPROTO_TCP = 6;
|
|
10137
|
+
const TCP_NODELAY = 1;
|
|
10138
|
+
if (
|
|
10139
|
+
level === SOL_SOCKET &&
|
|
10140
|
+
(optionName === SO_RCVTIMEO || optionName === SO_SNDTIMEO)
|
|
10141
|
+
) {
|
|
10142
|
+
const timeoutMs = PHPWASM.parseSocketTimeout(
|
|
10143
|
+
optionValuePtr,
|
|
10144
|
+
optionLen
|
|
10145
|
+
);
|
|
10146
|
+
if (timeoutMs === null) {
|
|
10147
|
+
return -1;
|
|
10148
|
+
}
|
|
10149
|
+
const timeouts = PHPWASM.socketTimeouts.get(socketd) || {};
|
|
10150
|
+
if (optionName === SO_RCVTIMEO) {
|
|
10151
|
+
timeouts.receive = timeoutMs;
|
|
10152
|
+
} else {
|
|
10153
|
+
timeouts.send = timeoutMs;
|
|
10154
|
+
}
|
|
10155
|
+
PHPWASM.socketTimeouts.set(socketd, timeouts);
|
|
10156
|
+
return 0;
|
|
10157
|
+
}
|
|
10158
|
+
// Options that we can forward to the WebSocket proxy
|
|
10159
|
+
const isForwardable =
|
|
10160
|
+
(level === SOL_SOCKET && optionName === SO_KEEPALIVE) ||
|
|
10161
|
+
(level === IPPROTO_TCP && optionName === TCP_NODELAY);
|
|
10162
|
+
if (!isForwardable) {
|
|
10163
|
+
console.warn(
|
|
10164
|
+
`Unsupported socket option: ${level}, ${optionName}, ${optionValue}`
|
|
10165
|
+
);
|
|
10166
|
+
return -1;
|
|
10167
|
+
}
|
|
10168
|
+
const ws = PHPWASM.getAllWebSockets(socketd)[0];
|
|
10169
|
+
if (!ws) {
|
|
10170
|
+
return -1;
|
|
10171
|
+
}
|
|
10172
|
+
ws.setSocketOpt(level, optionName, optionValuePtr);
|
|
10173
|
+
return 0;
|
|
10174
|
+
}
|
|
10175
|
+
|
|
10176
|
+
function _wasm_shutdown(socketd, how) {
|
|
10177
|
+
return PHPWASM.shutdownSocket(socketd, how);
|
|
10178
|
+
}
|
|
10179
|
+
|
|
10166
10180
|
var getCFunc = (ident) => {
|
|
10167
10181
|
var func = Module['_' + ident];
|
|
10168
10182
|
// closure exported function
|
|
@@ -10909,14 +10923,7 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
10909
10923
|
_zend_set_user_opcode_handler,
|
|
10910
10924
|
_zend_get_user_opcode_handler,
|
|
10911
10925
|
_zend_get_zval_ptr,
|
|
10912
|
-
_munmap,
|
|
10913
|
-
_fiprintf,
|
|
10914
10926
|
_free,
|
|
10915
|
-
_dlopen,
|
|
10916
|
-
_dlsym,
|
|
10917
|
-
_dlclose,
|
|
10918
|
-
_strcmp,
|
|
10919
|
-
_getenv,
|
|
10920
10927
|
_strlen,
|
|
10921
10928
|
_memcmp,
|
|
10922
10929
|
_strtoll,
|
|
@@ -10927,6 +10934,12 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
10927
10934
|
_memchr,
|
|
10928
10935
|
_strrchr,
|
|
10929
10936
|
_snprintf,
|
|
10937
|
+
_dlopen,
|
|
10938
|
+
_fiprintf,
|
|
10939
|
+
_dlsym,
|
|
10940
|
+
_dlclose,
|
|
10941
|
+
_strcmp,
|
|
10942
|
+
_getenv,
|
|
10930
10943
|
_strncasecmp,
|
|
10931
10944
|
___wasm_setjmp,
|
|
10932
10945
|
___wasm_setjmp_test,
|
|
@@ -10942,6 +10955,7 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
10942
10955
|
___errno_location,
|
|
10943
10956
|
_strtoul,
|
|
10944
10957
|
_write,
|
|
10958
|
+
_munmap,
|
|
10945
10959
|
_fwrite,
|
|
10946
10960
|
_mmap,
|
|
10947
10961
|
_getcwd,
|
|
@@ -11090,13 +11104,13 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11090
11104
|
__ZNSt20bad_array_new_lengthD1Ev,
|
|
11091
11105
|
__ZNSt12length_errorD1Ev,
|
|
11092
11106
|
dynCall_vi,
|
|
11093
|
-
dynCall_vii,
|
|
11094
|
-
dynCall_viii,
|
|
11095
|
-
dynCall_ii,
|
|
11096
11107
|
dynCall_iiii,
|
|
11108
|
+
dynCall_ii,
|
|
11097
11109
|
dynCall_iiiiii,
|
|
11098
11110
|
dynCall_iiiii,
|
|
11111
|
+
dynCall_vii,
|
|
11099
11112
|
dynCall_iii,
|
|
11113
|
+
dynCall_viii,
|
|
11100
11114
|
dynCall_viiiii,
|
|
11101
11115
|
dynCall_iiiiiii,
|
|
11102
11116
|
dynCall_i,
|
|
@@ -11584,14 +11598,7 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11584
11598
|
] = wasmExports['zend_get_user_opcode_handler'];
|
|
11585
11599
|
_zend_get_zval_ptr = Module['_zend_get_zval_ptr'] =
|
|
11586
11600
|
wasmExports['zend_get_zval_ptr'];
|
|
11587
|
-
_munmap = Module['_munmap'] = wasmExports['munmap'];
|
|
11588
|
-
_fiprintf = Module['_fiprintf'] = wasmExports['fiprintf'];
|
|
11589
11601
|
_free = Module['_free'] = wasmExports['free'];
|
|
11590
|
-
_dlopen = Module['_dlopen'] = wasmExports['dlopen'];
|
|
11591
|
-
_dlsym = Module['_dlsym'] = wasmExports['dlsym'];
|
|
11592
|
-
_dlclose = Module['_dlclose'] = wasmExports['dlclose'];
|
|
11593
|
-
_strcmp = Module['_strcmp'] = wasmExports['strcmp'];
|
|
11594
|
-
_getenv = Module['_getenv'] = wasmExports['getenv'];
|
|
11595
11602
|
_strlen = Module['_strlen'] = wasmExports['strlen'];
|
|
11596
11603
|
_memcmp = Module['_memcmp'] = wasmExports['memcmp'];
|
|
11597
11604
|
_strtoll = Module['_strtoll'] = wasmExports['strtoll'];
|
|
@@ -11605,6 +11612,12 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11605
11612
|
_memchr = Module['_memchr'] = wasmExports['memchr'];
|
|
11606
11613
|
_strrchr = Module['_strrchr'] = wasmExports['strrchr'];
|
|
11607
11614
|
_snprintf = Module['_snprintf'] = wasmExports['snprintf'];
|
|
11615
|
+
_dlopen = Module['_dlopen'] = wasmExports['dlopen'];
|
|
11616
|
+
_fiprintf = Module['_fiprintf'] = wasmExports['fiprintf'];
|
|
11617
|
+
_dlsym = Module['_dlsym'] = wasmExports['dlsym'];
|
|
11618
|
+
_dlclose = Module['_dlclose'] = wasmExports['dlclose'];
|
|
11619
|
+
_strcmp = Module['_strcmp'] = wasmExports['strcmp'];
|
|
11620
|
+
_getenv = Module['_getenv'] = wasmExports['getenv'];
|
|
11608
11621
|
_strncasecmp = Module['_strncasecmp'] = wasmExports['strncasecmp'];
|
|
11609
11622
|
___wasm_setjmp = Module['___wasm_setjmp'] =
|
|
11610
11623
|
wasmExports['__wasm_setjmp'];
|
|
@@ -11624,6 +11637,7 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11624
11637
|
wasmExports['__errno_location'];
|
|
11625
11638
|
_strtoul = Module['_strtoul'] = wasmExports['strtoul'];
|
|
11626
11639
|
_write = Module['_write'] = wasmExports['write'];
|
|
11640
|
+
_munmap = Module['_munmap'] = wasmExports['munmap'];
|
|
11627
11641
|
_fwrite = Module['_fwrite'] = wasmExports['fwrite'];
|
|
11628
11642
|
_mmap = Module['_mmap'] = wasmExports['mmap'];
|
|
11629
11643
|
_getcwd = Module['_getcwd'] = wasmExports['getcwd'];
|
|
@@ -11824,13 +11838,13 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11824
11838
|
__ZNSt12length_errorD1Ev = Module['__ZNSt12length_errorD1Ev'] =
|
|
11825
11839
|
wasmExports['_ZNSt12length_errorD1Ev'];
|
|
11826
11840
|
dynCall_vi = dynCalls['vi'] = wasmExports['dynCall_vi'];
|
|
11827
|
-
dynCall_vii = dynCalls['vii'] = wasmExports['dynCall_vii'];
|
|
11828
|
-
dynCall_viii = dynCalls['viii'] = wasmExports['dynCall_viii'];
|
|
11829
|
-
dynCall_ii = dynCalls['ii'] = wasmExports['dynCall_ii'];
|
|
11830
11841
|
dynCall_iiii = dynCalls['iiii'] = wasmExports['dynCall_iiii'];
|
|
11842
|
+
dynCall_ii = dynCalls['ii'] = wasmExports['dynCall_ii'];
|
|
11831
11843
|
dynCall_iiiiii = dynCalls['iiiiii'] = wasmExports['dynCall_iiiiii'];
|
|
11832
11844
|
dynCall_iiiii = dynCalls['iiiii'] = wasmExports['dynCall_iiiii'];
|
|
11845
|
+
dynCall_vii = dynCalls['vii'] = wasmExports['dynCall_vii'];
|
|
11833
11846
|
dynCall_iii = dynCalls['iii'] = wasmExports['dynCall_iii'];
|
|
11847
|
+
dynCall_viii = dynCalls['viii'] = wasmExports['dynCall_viii'];
|
|
11834
11848
|
dynCall_viiiii = dynCalls['viiiii'] = wasmExports['dynCall_viiiii'];
|
|
11835
11849
|
dynCall_iiiiiii = dynCalls['iiiiiii'] = wasmExports['dynCall_iiiiiii'];
|
|
11836
11850
|
dynCall_i = dynCalls['i'] = wasmExports['dynCall_i'];
|
|
@@ -11920,102 +11934,102 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
11920
11934
|
wasmExports['__indirect_function_table'];
|
|
11921
11935
|
}
|
|
11922
11936
|
|
|
11923
|
-
var _core_globals = (Module['_core_globals'] =
|
|
11937
|
+
var _core_globals = (Module['_core_globals'] = 11043520);
|
|
11924
11938
|
|
|
11925
|
-
var _php_ini_opened_path = (Module['_php_ini_opened_path'] =
|
|
11939
|
+
var _php_ini_opened_path = (Module['_php_ini_opened_path'] = 10973512);
|
|
11926
11940
|
|
|
11927
|
-
var _php_ini_scanned_path = (Module['_php_ini_scanned_path'] =
|
|
11941
|
+
var _php_ini_scanned_path = (Module['_php_ini_scanned_path'] = 10973516);
|
|
11928
11942
|
|
|
11929
|
-
var _php_ini_scanned_files = (Module['_php_ini_scanned_files'] =
|
|
11943
|
+
var _php_ini_scanned_files = (Module['_php_ini_scanned_files'] = 10973520);
|
|
11930
11944
|
|
|
11931
|
-
var _sapi_module = (Module['_sapi_module'] =
|
|
11945
|
+
var _sapi_module = (Module['_sapi_module'] = 10987288);
|
|
11932
11946
|
|
|
11933
|
-
var _sapi_globals = (Module['_sapi_globals'] =
|
|
11947
|
+
var _sapi_globals = (Module['_sapi_globals'] = 10987432);
|
|
11934
11948
|
|
|
11935
|
-
var _compiler_globals = (Module['_compiler_globals'] =
|
|
11949
|
+
var _compiler_globals = (Module['_compiler_globals'] = 10971776);
|
|
11936
11950
|
|
|
11937
|
-
var _executor_globals = (Module['_executor_globals'] =
|
|
11951
|
+
var _executor_globals = (Module['_executor_globals'] = 10972192);
|
|
11938
11952
|
|
|
11939
|
-
var _zend_compile_file = (Module['_zend_compile_file'] =
|
|
11953
|
+
var _zend_compile_file = (Module['_zend_compile_file'] = 10973328);
|
|
11940
11954
|
|
|
11941
|
-
var _zend_execute_ex = (Module['_zend_execute_ex'] =
|
|
11955
|
+
var _zend_execute_ex = (Module['_zend_execute_ex'] = 10967464);
|
|
11942
11956
|
|
|
11943
|
-
var _zend_execute_internal = (Module['_zend_execute_internal'] =
|
|
11957
|
+
var _zend_execute_internal = (Module['_zend_execute_internal'] = 10967468);
|
|
11944
11958
|
|
|
11945
|
-
var _zend_write = (Module['_zend_write'] =
|
|
11959
|
+
var _zend_write = (Module['_zend_write'] = 10971712);
|
|
11946
11960
|
|
|
11947
|
-
var _zend_error_cb = (Module['_zend_error_cb'] =
|
|
11961
|
+
var _zend_error_cb = (Module['_zend_error_cb'] = 10971720);
|
|
11948
11962
|
|
|
11949
|
-
var _zend_post_startup_cb = (Module['_zend_post_startup_cb'] =
|
|
11963
|
+
var _zend_post_startup_cb = (Module['_zend_post_startup_cb'] = 10971692);
|
|
11950
11964
|
|
|
11951
|
-
var _module_registry = (Module['_module_registry'] =
|
|
11965
|
+
var _module_registry = (Module['_module_registry'] = 10964112);
|
|
11952
11966
|
|
|
11953
|
-
var _zend_ce_traversable = (Module['_zend_ce_traversable'] =
|
|
11967
|
+
var _zend_ce_traversable = (Module['_zend_ce_traversable'] = 10963760);
|
|
11954
11968
|
|
|
11955
|
-
var _zend_ce_iterator = (Module['_zend_ce_iterator'] =
|
|
11969
|
+
var _zend_ce_iterator = (Module['_zend_ce_iterator'] = 10963768);
|
|
11956
11970
|
|
|
11957
|
-
var _zend_ce_countable = (Module['_zend_ce_countable'] =
|
|
11971
|
+
var _zend_ce_countable = (Module['_zend_ce_countable'] = 10963780);
|
|
11958
11972
|
|
|
11959
|
-
var _zend_ce_exception = (Module['_zend_ce_exception'] =
|
|
11973
|
+
var _zend_ce_exception = (Module['_zend_ce_exception'] = 10963500);
|
|
11960
11974
|
|
|
11961
|
-
var _zend_ce_error = (Module['_zend_ce_error'] =
|
|
11975
|
+
var _zend_ce_error = (Module['_zend_ce_error'] = 10963628);
|
|
11962
11976
|
|
|
11963
11977
|
var _zend_throw_exception_hook = (Module['_zend_throw_exception_hook'] =
|
|
11964
|
-
|
|
11978
|
+
10963492);
|
|
11965
11979
|
|
|
11966
|
-
var _gc_collect_cycles = (Module['_gc_collect_cycles'] =
|
|
11980
|
+
var _gc_collect_cycles = (Module['_gc_collect_cycles'] = 10963940);
|
|
11967
11981
|
|
|
11968
|
-
var _zend_ce_closure = (Module['_zend_ce_closure'] =
|
|
11982
|
+
var _zend_ce_closure = (Module['_zend_ce_closure'] = 10963640);
|
|
11969
11983
|
|
|
11970
|
-
var _zend_empty_string = (Module['_zend_empty_string'] =
|
|
11984
|
+
var _zend_empty_string = (Module['_zend_empty_string'] = 10961824);
|
|
11971
11985
|
|
|
11972
11986
|
var _zend_string_init_interned = (Module['_zend_string_init_interned'] =
|
|
11973
|
-
|
|
11987
|
+
10961892);
|
|
11974
11988
|
|
|
11975
|
-
var _std_object_handlers = (Module['_std_object_handlers'] =
|
|
11989
|
+
var _std_object_handlers = (Module['_std_object_handlers'] = 10207160);
|
|
11976
11990
|
|
|
11977
|
-
var _zend_pass_function = (Module['_zend_pass_function'] =
|
|
11991
|
+
var _zend_pass_function = (Module['_zend_pass_function'] = 10210008);
|
|
11978
11992
|
|
|
11979
11993
|
var ___memory_base = (Module['___memory_base'] = 0);
|
|
11980
11994
|
|
|
11981
11995
|
var ___table_base = (Module['___table_base'] = 1);
|
|
11982
11996
|
|
|
11983
|
-
var _stderr = (Module['_stderr'] =
|
|
11997
|
+
var _stderr = (Module['_stderr'] = 10955008);
|
|
11984
11998
|
|
|
11985
|
-
var ___THREW__ = (Module['___THREW__'] =
|
|
11999
|
+
var ___THREW__ = (Module['___THREW__'] = 11092212);
|
|
11986
12000
|
|
|
11987
|
-
var ___threwValue = (Module['___threwValue'] =
|
|
12001
|
+
var ___threwValue = (Module['___threwValue'] = 11092216);
|
|
11988
12002
|
|
|
11989
|
-
var _stdout = (Module['_stdout'] =
|
|
12003
|
+
var _stdout = (Module['_stdout'] = 10955312);
|
|
11990
12004
|
|
|
11991
|
-
var _timezone = (Module['_timezone'] =
|
|
12005
|
+
var _timezone = (Module['_timezone'] = 11078976);
|
|
11992
12006
|
|
|
11993
|
-
var _tzname = (Module['_tzname'] =
|
|
12007
|
+
var _tzname = (Module['_tzname'] = 11078984);
|
|
11994
12008
|
|
|
11995
|
-
var ___heap_base =
|
|
12009
|
+
var ___heap_base = 12140896;
|
|
11996
12010
|
|
|
11997
12011
|
var __ZNSt3__25ctypeIcE2idE = (Module['__ZNSt3__25ctypeIcE2idE'] =
|
|
11998
|
-
|
|
12012
|
+
11092300);
|
|
11999
12013
|
|
|
12000
12014
|
var __ZTVN10__cxxabiv120__si_class_type_infoE = (Module[
|
|
12001
12015
|
'__ZTVN10__cxxabiv120__si_class_type_infoE'
|
|
12002
|
-
] =
|
|
12016
|
+
] = 10955560);
|
|
12003
12017
|
|
|
12004
12018
|
var __ZTVN10__cxxabiv117__class_type_infoE = (Module[
|
|
12005
12019
|
'__ZTVN10__cxxabiv117__class_type_infoE'
|
|
12006
|
-
] =
|
|
12020
|
+
] = 10955520);
|
|
12007
12021
|
|
|
12008
12022
|
var __ZTVN10__cxxabiv121__vmi_class_type_infoE = (Module[
|
|
12009
12023
|
'__ZTVN10__cxxabiv121__vmi_class_type_infoE'
|
|
12010
|
-
] =
|
|
12024
|
+
] = 10955612);
|
|
12011
12025
|
|
|
12012
12026
|
var __ZTISt20bad_array_new_length = (Module[
|
|
12013
12027
|
'__ZTISt20bad_array_new_length'
|
|
12014
|
-
] =
|
|
12028
|
+
] = 10955684);
|
|
12015
12029
|
|
|
12016
|
-
var __ZTVSt12length_error = (Module['__ZTVSt12length_error'] =
|
|
12030
|
+
var __ZTVSt12length_error = (Module['__ZTVSt12length_error'] = 10955728);
|
|
12017
12031
|
|
|
12018
|
-
var __ZTISt12length_error = (Module['__ZTISt12length_error'] =
|
|
12032
|
+
var __ZTISt12length_error = (Module['__ZTISt12length_error'] = 10955748);
|
|
12019
12033
|
|
|
12020
12034
|
var wasmImports = {
|
|
12021
12035
|
/** @export */ __assert_fail: ___assert_fail,
|
|
@@ -12185,6 +12199,17 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
12185
12199
|
}
|
|
12186
12200
|
}
|
|
12187
12201
|
|
|
12202
|
+
function invoke_iii(index, a1, a2) {
|
|
12203
|
+
var sp = stackSave();
|
|
12204
|
+
try {
|
|
12205
|
+
return dynCalls['iii'](index, a1, a2);
|
|
12206
|
+
} catch (e) {
|
|
12207
|
+
stackRestore(sp);
|
|
12208
|
+
if (e !== e + 0) throw e;
|
|
12209
|
+
_setThrew(1, 0);
|
|
12210
|
+
}
|
|
12211
|
+
}
|
|
12212
|
+
|
|
12188
12213
|
function invoke_vii(index, a1, a2) {
|
|
12189
12214
|
var sp = stackSave();
|
|
12190
12215
|
try {
|
|
@@ -12240,17 +12265,6 @@ export function init(RuntimeName, PHPLoader) {
|
|
|
12240
12265
|
}
|
|
12241
12266
|
}
|
|
12242
12267
|
|
|
12243
|
-
function invoke_iii(index, a1, a2) {
|
|
12244
|
-
var sp = stackSave();
|
|
12245
|
-
try {
|
|
12246
|
-
return dynCalls['iii'](index, a1, a2);
|
|
12247
|
-
} catch (e) {
|
|
12248
|
-
stackRestore(sp);
|
|
12249
|
-
if (e !== e + 0) throw e;
|
|
12250
|
-
_setThrew(1, 0);
|
|
12251
|
-
}
|
|
12252
|
-
}
|
|
12253
|
-
|
|
12254
12268
|
function invoke_viiii(index, a1, a2, a3, a4) {
|
|
12255
12269
|
var sp = stackSave();
|
|
12256
12270
|
try {
|