Skip to content

Remove local sharing logic #2540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
42 changes: 21 additions & 21 deletions cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import binaryen from "../lib/binaryen.js";
import * as assemblyscriptJS from "assemblyscript";

// Use the TS->JS variant by default
var assemblyscript = assemblyscriptJS;
let assemblyscript = assemblyscriptJS;

// Use the AS->Wasm variant as an option (experimental)
const wasmPos = process.argv.indexOf("--wasm");
Expand Down Expand Up @@ -115,7 +115,7 @@ export function configToArguments(options, argv = []) {
/** Convenience function that parses and compiles source strings directly. */
export async function compileString(sources, config = {}) {
if (typeof sources === "string") sources = { [`input${extension}`]: sources };
var argv = [
let argv = [
"--outFile", "binary",
"--textFile", "text",
];
Expand Down Expand Up @@ -182,11 +182,11 @@ export async function main(argv, options) {
);
}

var module = null;
var binaryenModule = null;
let module = null;
let binaryenModule = null;

// Prepares the result object
var prepareResult = (error, result = {}) => {
let prepareResult = (error, result = {}) => {
if (error) {
stderr.write(`${stderrColors.red("FAILURE ")}${error.stack.replace(/^ERROR: /i, "")}${EOL}`);
}
Expand All @@ -213,8 +213,8 @@ export async function main(argv, options) {

// Print the help message if requested or no source files are provided
if (opts.help || (!argv.length && !configHasEntries)) {
var out = opts.help ? stdout : stderr;
var colors = opts.help ? stdoutColors : stderrColors;
let out = opts.help ? stdout : stderr;
let colors = opts.help ? stdoutColors : stderrColors;
out.write([
colors.white("SYNTAX"),
" " + colors.cyan("asc") + " [entryFile ...] [options]",
Expand Down Expand Up @@ -295,7 +295,7 @@ export async function main(argv, options) {
}

// Set up options
var program, runtime;
let program, runtime;
const compilerOptions = assemblyscript.newOptions();
switch (opts.runtime) {
case "stub": runtime = 0; break;
Expand Down Expand Up @@ -358,7 +358,7 @@ export async function main(argv, options) {
}

// Disable default features if specified
var features;
let features;
if ((features = opts.disable) != null) {
if (typeof features === "string") features = features.split(",");
for (let i = 0, k = features.length; i < k; ++i) {
Expand All @@ -381,8 +381,8 @@ export async function main(argv, options) {
}

// Set up optimization levels
var optimizeLevel = 0;
var shrinkLevel = 0;
let optimizeLevel = 0;
let shrinkLevel = 0;
if (opts.optimize) {
optimizeLevel = defaultOptimizeLevel;
shrinkLevel = defaultShrinkLevel;
Expand Down Expand Up @@ -518,8 +518,8 @@ export async function main(argv, options) {

// Gets the file matching the specified source path, imported at the given dependee path
async function getFile(internalPath, dependeePath) {
var sourceText = null; // text reported back to the compiler
var sourcePath = null; // path reported back to the compiler
let sourceText = null; // text reported back to the compiler
let sourcePath = null; // path reported back to the compiler

// Try file.ext, file/index.ext, file.d.ext
if (!internalPath.startsWith(libraryPrefix)) {
Expand Down Expand Up @@ -602,7 +602,7 @@ export async function main(argv, options) {

// Parses the backlog of imported files after including entry files
async function parseBacklog() {
var backlog;
let backlog;
while ((backlog = getBacklog()).length) {
let files = [];
for (let internalPath of backlog) {
Expand Down Expand Up @@ -733,7 +733,7 @@ export async function main(argv, options) {
? assemblyscript.getBinaryenModuleRef(module)
: module.ref
);
var numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
let numErrors = checkDiagnostics(program, stderr, opts.disableWarning, options.reportDiagnostic, stderrColors.enabled);
if (numErrors) {
const err = Error(`${numErrors} compile error(s)`);
err.stack = err.message; // omit stack
Expand Down Expand Up @@ -1132,7 +1132,7 @@ async function getConfig(file, baseDir, readFile) {
/** Checks diagnostics emitted so far for errors. */
export function checkDiagnostics(program, stderr, disableWarning, reportDiagnostic, useColors) {
if (typeof useColors === "undefined" && stderr) useColors = stderr.isTTY;
var numErrors = 0;
let numErrors = 0;
do {
let diagnostic = assemblyscript.nextDiagnostic(program);
if (!diagnostic) break;
Expand Down Expand Up @@ -1224,13 +1224,13 @@ export class Stats {
}
}

var allocBuffer = typeof global !== "undefined" && global.Buffer
let allocBuffer = typeof global !== "undefined" && global.Buffer
? global.Buffer.allocUnsafe || (len => new global.Buffer(len))
: len => new Uint8Array(len);

/** Creates a memory stream that can be used in place of stdout/stderr. */
export function createMemoryStream(fn) {
var stream = [];
let stream = [];
stream.write = function(chunk) {
if (fn) fn(chunk);
if (typeof chunk === "string") {
Expand All @@ -1244,9 +1244,9 @@ export function createMemoryStream(fn) {
stream.length = 0;
};
stream.toBuffer = function() {
var offset = 0, i = 0, k = this.length;
let offset = 0, i = 0, k = this.length;
while (i < k) offset += this[i++].length;
var buffer = allocBuffer(offset);
let buffer = allocBuffer(offset);
offset = i = 0;
while (i < k) {
buffer.set(this[i], offset);
Expand All @@ -1256,7 +1256,7 @@ export function createMemoryStream(fn) {
return buffer;
};
stream.toString = function() {
var buffer = this.toBuffer();
let buffer = this.toBuffer();
return utf8.read(buffer, 0, buffer.length);
};
return stream;
Expand Down
2 changes: 1 addition & 1 deletion cli/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"description": [
"Overrides the stack size. Only relevant for incremental GC",
"or when using a custom runtime that requires stack space.",
"Defaults to 0 without and to 16384 with incremental GC."
"Defaults to 0 without and to 32768 with incremental GC."
],
"default": 0,
"type": "i"
Expand Down
2 changes: 1 addition & 1 deletion lib/loader/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function postInstantiate(extendedExports, instance) {
const length = str.length;
const ptr = __new(length << 1, STRING_ID);
const U16 = new Uint16Array(memory.buffer);
for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
for (let i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
return ptr;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/loader/tests/assembly/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ export class Car {
}

export function sum(arr: Int32Array): i32 {
var v = 0;
let v = 0;
for (let i = 0, k = arr.length; i < k; ++i) v += arr[i];
return v;
}

export function sumStatic(arr: StaticArray<i32>): i32 {
var v = 0;
let v = 0;
for (let i = 0, k = arr.length; i < k; ++i) v += arr[i];
return v;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/loader/tests/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
if (!c) throw Error("assertion failed");
}
(async () => {
var module;
let module;

module = await exports.instantiate(fetch("./build/debug.wasm"));
assert(module.memory);
Expand All @@ -25,7 +25,7 @@
module = await exports.instantiateStreaming(await fetch("./build/debug.wasm"));
assert(module.memory);

var instantiateStreaming = WebAssembly.instantiateStreaming;
let instantiateStreaming = WebAssembly.instantiateStreaming;
delete WebAssembly.instantiateStreaming;

module = await exports.instantiate(fetch("./build/debug.wasm"));
Expand Down
8 changes: 4 additions & 4 deletions lib/loader/tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ async function wrapToResponse(source) {
}

function test(file) {
var buffer = fs.readFileSync(__dirname + "/build/" + file);
var result = loader.instantiateSync(buffer, {});
let buffer = fs.readFileSync(__dirname + "/build/" + file);
let result = loader.instantiateSync(buffer, {});
const exports = result.exports;

console.log(inspect(exports, true, 100, true));
Expand Down Expand Up @@ -251,7 +251,7 @@ function test(file) {
// TBD: table is no more exported by default to allow more optimizations

// should be able to get a function from the table and just call it with variable arguments
// var fn = module.getFunction(module.varadd_ref);
// let fn = module.getFunction(module.varadd_ref);
// assert.strictEqual(fn(), 3);
// assert.strictEqual(fn(2, 3), 5);
// assert.strictEqual(fn(2), 4);
Expand All @@ -262,7 +262,7 @@ function test(file) {

// NOTE: Class exports have been removed in 0.20
// should be able to use a class
// var car = new exports.Car(5);
// let car = new exports.Car(5);
// assert.strictEqual(car.numDoors, 5);
// assert.strictEqual(car.isDoorsOpen, 0);
// car.openDoors();
Expand Down
8 changes: 4 additions & 4 deletions lib/loader/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ var loader = (function(exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
exports.demangle = demangle;
exports.instantiate = instantiate;
exports.instantiateStreaming = instantiateStreaming;
exports.instantiateSync = instantiateSync;
exports.instantiateStreaming = instantiateStreaming;
exports.demangle = demangle;
exports.default = void 0;
// Runtime header offsets
const ID_OFFSET = -8;
const SIZE_OFFSET = -4; // Runtime ids
Expand Down Expand Up @@ -182,7 +182,7 @@ var loader = (function(exports) {

const U16 = new Uint16Array(memory.buffer);

for (var i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);
for (let i = 0, p = ptr >>> 1; i < length; ++i) U16[p + i] = str.charCodeAt(i);

return ptr;
}
Expand Down
30 changes: 15 additions & 15 deletions lib/rtrace/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class Rtrace {
initial: ((this.memory.buffer.byteLength + PAGE_MASK) & ~PAGE_MASK) >>> PAGE_SIZE_BITS
});
} else {
var diff = this.memory.buffer.byteLength - this.shadow.buffer.byteLength;
let diff = this.memory.buffer.byteLength - this.shadow.buffer.byteLength;
if (diff > 0) this.shadow.grow(diff >>> 16);
}
}
Expand All @@ -105,10 +105,10 @@ export class Rtrace {
if (info.ptr < this.shadowStart) {
this.shadowStart = info.ptr;
}
var len = info.size >>> PTR_SIZE_BITS;
var view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
var errored = false;
var start = oldSize >>> PTR_SIZE_BITS;
let len = info.size >>> PTR_SIZE_BITS;
let view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
let errored = false;
let start = oldSize >>> PTR_SIZE_BITS;
for (let i = 0; i < start; ++i) {
if (view[i] != info.ptr && !errored) {
this.onerror(Error("shadow region mismatch: " + view[i] + " != " + info.ptr), info);
Expand All @@ -128,10 +128,10 @@ export class Rtrace {
/** Unmarks a block's presence in shadow memory. */
unmarkShadow(info, oldSize = info.size) {
assert(this.shadow && this.shadow.byteLength == this.memory.byteLength);
var len = oldSize >>> PTR_SIZE_BITS;
var view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
var errored = false;
var start = 0;
let len = oldSize >>> PTR_SIZE_BITS;
let view = new PTR_VIEW(this.shadow.buffer, info.ptr, len);
let errored = false;
let start = 0;
if (oldSize != info.size) {
assert(oldSize > info.size);
start = info.size >>> PTR_SIZE_BITS;
Expand All @@ -149,7 +149,7 @@ export class Rtrace {
accessShadow(ptr, size, isLoad, isRT) {
this.syncShadow();
if (ptr < this.shadowStart) return;
var value = new Uint32Array(this.shadow.buffer, ptr & ~PTR_MASK, 1)[0];
let value = new Uint32Array(this.shadow.buffer, ptr & ~PTR_MASK, 1)[0];
if (value != 0) return;
if (!isRT) {
let stack = trimStacktrace(new Error().stack, 2);
Expand Down Expand Up @@ -211,7 +211,7 @@ export class Rtrace {
onalloc(ptr) {
this.syncShadow();
++this.allocCount;
var info = this.getBlockInfo(ptr);
let info = this.getBlockInfo(ptr);
if (this.blocks.has(ptr)) {
this.onerror(Error("duplicate alloc: " + ptr), info);
} else {
Expand Down Expand Up @@ -247,8 +247,8 @@ export class Rtrace {
onmove(oldPtr, newPtr) {
this.syncShadow();
++this.moveCount;
var oldInfo = this.getBlockInfo(oldPtr);
var newInfo = this.getBlockInfo(newPtr);
let oldInfo = this.getBlockInfo(oldPtr);
let newInfo = this.getBlockInfo(newPtr);
if (!this.blocks.has(oldPtr)) {
this.onerror(Error("orphaned move (old): " + oldPtr), oldInfo);
} else {
Expand Down Expand Up @@ -285,7 +285,7 @@ export class Rtrace {
onfree(ptr) {
this.syncShadow();
++this.freeCount;
var info = this.getBlockInfo(ptr);
let info = this.getBlockInfo(ptr);
if (!this.blocks.has(ptr)) {
this.onerror(Error("orphaned free: " + ptr), info);
} else {
Expand Down Expand Up @@ -323,7 +323,7 @@ export class Rtrace {
}

onyield(total) {
var pause = hrtime() - this.interruptStart;
let pause = hrtime() - this.interruptStart;
if (pause >= 1) console.log("interrupted for " + pause.toFixed(1) + "ms");
this.plot(total, pause);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-dts.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ OutputStream.prototype.toString = function () {
};

function transformTypes(sourceFile) {
var numReplaced = 0;
let numReplaced = 0;
console.log("transforming:");
var result = ts.transform(sourceFile, [
let result = ts.transform(sourceFile, [
function (context) {
const visit = node => {
node = ts.visitEachChild(node, visit, context);
Expand Down
6 changes: 3 additions & 3 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ const diagnosticsPlugin = {
out.push("/** Enum of available diagnostic codes. */\n");
out.push("export enum DiagnosticCode {\n");

var first = true;
let first = true;
const messages = JSON.parse(fs.readFileSync(path.join(dirname, "..", "src", "diagnosticMessages.json")));
Object.keys(messages).forEach(text => {
var key = makeKey(text);
let key = makeKey(text);
if (first)
first = false;
else {
Expand Down Expand Up @@ -233,7 +233,7 @@ const cliBuild = esbuild.build({

// Optionally build definitions (takes a while)

var buildingDefinitions = false;
let buildingDefinitions = false;

function buildDefinitions() {
const startTime = Date.now();
Expand Down
10 changes: 5 additions & 5 deletions scripts/hexfloat.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ <h1>Hexadecimal float to decimal float converter</h1>
<script src="hexfloat.js"></script>
<script>
function convert(form) {
var isF64 = document.getElementById("f64").checked;
var pre = document.getElementById("pre").value;
var post = document.getElementById("post").value;
var input = document.getElementById("input").value;
let isF64 = document.getElementById("f64").checked;
let pre = document.getElementById("pre").value;
let post = document.getElementById("post").value;
let input = document.getElementById("input").value;
document.getElementById("output").value = input
.replace(/\b(\-?0x[0-9a-fA-F]*(?:\.[0-9a-fA-F]+)?[pP][+-]?[0-9]+\b)/g, ($0, $1) => {
var val = parse($1);
let val = parse($1);
return val.toPrecision(isF64 ? 18 : 10);
})
.replace(/(\d\.[0-9])0+\b/g, "$1")
Expand Down
Loading