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:
Ryan Dahl 2018-12-06 23:05:36 -05:00 committed by GitHub
parent 568ac0c902
commit c113df1bb8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 854 additions and 807 deletions

View file

@ -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;
}
};