mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
Process source maps in Rust instead of JS (#1280)
- Improves speed and binary size significantly. - Makes deno_last_exception() output a JSON structure. - Isolate::execute and Isolate::event_loop now return structured, mapped JSError objects on errors. - Removes libdeno functions: libdeno.setGlobalErrorHandler() libdeno.setPromiseRejectHandler() libdeno.setPromiseErrorExaminer() In collaboration with Ryan Dahl.
This commit is contained in:
parent
568ac0c902
commit
c113df1bb8
30 changed files with 854 additions and 807 deletions
|
@ -99,23 +99,9 @@ global.SnapshotBug = () => {
|
|||
};
|
||||
|
||||
global.GlobalErrorHandling = () => {
|
||||
libdeno.setGlobalErrorHandler((message, source, line, col, error) => {
|
||||
libdeno.print(`line ${line} col ${col}`, true);
|
||||
assert("ReferenceError: notdefined is not defined" === message);
|
||||
assert(source === "helloworld.js");
|
||||
assert(line === 3);
|
||||
assert(col === 1);
|
||||
assert(error instanceof Error);
|
||||
libdeno.send(new Uint8Array([42]));
|
||||
});
|
||||
eval("\n\n notdefined()\n//# sourceURL=helloworld.js");
|
||||
};
|
||||
|
||||
global.DoubleGlobalErrorHandlingFails = () => {
|
||||
libdeno.setGlobalErrorHandler((message, source, line, col, error) => {});
|
||||
libdeno.setGlobalErrorHandler((message, source, line, col, error) => {});
|
||||
};
|
||||
|
||||
// Allocate this buf at the top level to avoid GC.
|
||||
const dataBuf = new Uint8Array([3, 4]);
|
||||
|
||||
|
@ -134,33 +120,7 @@ global.DataBuf = () => {
|
|||
b[1] = 8;
|
||||
};
|
||||
|
||||
global.PromiseRejectCatchHandling = () => {
|
||||
let count = 0;
|
||||
let promiseRef = null;
|
||||
// When we have an error, libdeno sends something
|
||||
function assertOrSend(cond) {
|
||||
if (!cond) {
|
||||
libdeno.send(new Uint8Array([42]));
|
||||
}
|
||||
}
|
||||
libdeno.setPromiseErrorExaminer(() => {
|
||||
assertOrSend(count === 2);
|
||||
});
|
||||
libdeno.setPromiseRejectHandler((error, event, promise) => {
|
||||
count++;
|
||||
if (event === "RejectWithNoHandler") {
|
||||
assertOrSend(error instanceof Error);
|
||||
assertOrSend(error.message === "message");
|
||||
assertOrSend(count === 1);
|
||||
promiseRef = promise;
|
||||
} else if (event === "HandlerAddedAfterReject") {
|
||||
assertOrSend(count === 2);
|
||||
assertOrSend(promiseRef === promise);
|
||||
}
|
||||
// Should never reach 3!
|
||||
assertOrSend(count !== 3);
|
||||
});
|
||||
|
||||
global.CheckPromiseErrors = () => {
|
||||
async function fn() {
|
||||
throw new Error("message");
|
||||
}
|
||||
|
@ -169,10 +129,10 @@ global.PromiseRejectCatchHandling = () => {
|
|||
try {
|
||||
await fn();
|
||||
} catch (e) {
|
||||
assertOrSend(count === 2);
|
||||
libdeno.send(new Uint8Array([42]));
|
||||
}
|
||||
})();
|
||||
}
|
||||
};
|
||||
|
||||
global.Shared = () => {
|
||||
const ab = libdeno.shared;
|
||||
|
@ -185,4 +145,4 @@ global.Shared = () => {
|
|||
ui8[0] = 42;
|
||||
ui8[1] = 43;
|
||||
ui8[2] = 44;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue