This for loop:
for (let i = 0, getI = () => i; i < 3; i++)
console.log(getI());
unrolls to:
This for loop:
for (let i = 0, getI = () => i; i < 3; i++)
console.log(getI());
unrolls to:
use std::{path::PathBuf, fs::File, env, collections::HashMap, rc::Rc, cell::RefCell, fmt::Display}; | |
use itertools::Itertools; | |
use fastanvil::*; | |
use rayon::prelude::{ParallelIterator, IntoParallelIterator}; | |
#[derive(Clone, Eq, PartialEq, Debug)] | |
struct BlockDescriptor { | |
name: String, | |
x: i64, |
Rollup builds doesn't scale well in large apps. You need to increase Node's memory with --max-old-space-size=4096
to handle all the modules. This is one of Vite's highest-rated issue.
This file documents various findings and attempts to improve this issue.
NOTE: I've only been reading Rollup's source code for a while, so some of these may not be accurate.
const CH_BRACE_L = 0x7b as const; | |
const CH_BRACE_R = 0x7d as const; | |
const CH_SQUARE_L = 0x5b as const; | |
const CH_SQUARE_R = 0x5d as const; | |
const CH_QUOTE_D = 0x22 as const; | |
const CH_ESCAPE = 0x5c as const; | |
const CH_COMMA = 0x2c as const; | |
const CH_COLON = 0x3a as const; | |
const CH_DOT = 0x2e as const; | |
const CH_MINUS = 0x2d as const; |
Note: this was originally several Reddit posts, chained and linked. But now that Reddit is dying I've finally moved them out. Sorry about the mess.
URL: https://www.reddit.com/r/ProgrammingLanguages/comments/up206c/stack_machines_for_compilers/i8ikupw/ Summary: stack-based vs register-based in general.
There are a wide variety of machines that can be described as "stack-based" or "register-based", but not all of them are practical. And there are a lot of other decisions that affect that practicality (do variables have names or only address/indexes? fixed-width or variable-width instructions? are you interpreting the bytecode (and if so, are you using machine stack frames?) or turning it into machine code? how many registers are there, and how many are special? how do you represent multiple types of variable? how many scopes are there(various kinds of global, local, member, ...)? how much effort/complexity can you afford to put into your machine? etc.)
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<title>Document</title> | |
</head> | |
<body> | |
<div id="app"></div> | |
<script type="module"> |
const assert = @import("std").debug.assert; | |
fn compressBlock(writer: anytype, src: []const u8) !void { | |
var table = [_]u32{0} ** 4096; // size is pow2. bump to match more. ideal = (0xffff+1) / sizeof(u32) | |
var anchor: u32 = 0; | |
if (src.len > 12) { // LZ4 spec restriction: last match must start 12b before end of block. | |
var pos: u32 = 0; | |
while (pos + 4 < src.len - 5) { // LZ4 spec restriction: last 5b are always literal. | |
const blk: u32 = @bitCast(src[pos..][0..4].*); |
type instruction = | |
| In | Out | |
| Increase | Decrease | |
| Move | Jump | |
| MoveBack | JumpBack | |
| Ignore | |
let parse = | |
List.map | |
@@ function |