289 karma · joined Apr 24, 2013 (13y ago) · 148 submissions
comment 7mo ago · link · parent
I did something related in the past: https://github.com/RussellSprouts/6502-enumerator. It uses C++ templates to share an emulator implementation between z3-powered symbolic execution and actual execution. It was meant to find equivalence between random instruction sequences for peephole optimization, rather than optimizing a specific input sequence.
Shadow instructions are very interesting and cursed. I've seen them used in very limited circumstances for NOP-slides for timing code: https://www.pagetable.com/?p=669. It would be fun to see it applied in otherwise normal code. My enumerator wouldn't support this -- it didn't execute actual 6502 instructions from bytes -- it had its own internal representation for `the first arbitrary absolute pointer` or `the second arbitrary immediate constant`. These would either be initialized with random concrete values or z3 variables.
comment 1y ago · link · parent
comment 2y ago · link · parent
In Halide, you specify the algorithm at a high level, then specify the "schedule" (execution order, vectorization, storage) separately. Then, it verifies that the two match. For tight loops like image kernels, it's often counter-intuitive which execution plan will give the best performance, so being able to experiment with the guarantee that you are still implementing the algorithm correctly is valuable.
For a database, it would be as if you could send a high level SQL query and an execution plan together.
Halide is very specific, but I could imagine a general-purpose language with a Python-like high level representation for code behavior, with the option to specify a lower-level implementation with a lot of performance annotations.
comment 3y ago · link · parent
This reminds me of how Forth `if` and `then` can be compiled in a single pass -- `if` writes the branch instruction and pushes the current instruction pointer to the stack, and `then` pops it and patches the instruction to point to the current instruction pointer.
comment 3y ago · link · parent
The inline assembly integration looks nice too -- accessing the arguments and return address as fields on the function makes a lot of sense.
comment 4y ago · link · parent
import {Something} from './file';
console.log(Something.PROP);
TypeScript doesn't know what to emit without type information. If Something is a class, then the JS will look the same. But if it's a const enum, then TypeScript has to erase the Something.PROP expression and replace it with the constant value of that enum member, since Something will not exist at runtime.comment 4y ago · link · parent
Const enums are erased at compile time. If you have a reference to `MyEnum.VAR`, TS has to check whether the enum is a const enum, and if so, replace with something like `1 /* VAR */`. This means that the type information in one file (where the enum is defined) is necessary to determine the proper output of any file that uses it.
comment 6y ago · link · parent
comment 7y ago · link · parent
See my other comment for details: https://news.ycombinator.com/item?id=20960710
comment 7y ago · link · parent
There are only brief glimpses in the video, but here's what that looks like: https://imgur.com/a/AkOAzgF
The 14 left-right powered rail tracks are the music channels. Each vertical slice is a tick of music, and they are grouped into 9, the max length of a powered rail signal. The presence of an observer block underneath the rail indicates a note. The whole machine appears to be 128 x 14 bits. It has a serial read interface.
In more detail:
From the bottom of the image to the top you see:
- A row of redstone blocks, pistons, and redstone wire.
- A row of repeaters facing north
- A row of repeaters facing west
- An observer facing north
- 14 east-west powered rail/observer wires, sending signals to the east.
- In a layer underneath the east-west observer-rail wires, alternating columns of rails and redstone wire facing north-south. (Not visible in the picture)
- (A mirror image of the bottom)
The west facing repeaters control the current read location. The machine sends a signal until they all turn on, then waits until they all turn off, then turns them on again, etc. When one of the repeaters toggles between on and off, the north-facing observer above it sends a pulse. The pulse travels upwards in the north-south rail (in the invisible lower layer), and then if an observer is present, the signal is sent east along the east-west line for the channel.
The bottom two rows form a pause mechanism. The redstone block, piston, redstone wire row is an instant repeater line. When the north-facing repeaters are turned on, they will lock the west-facing repeaters in whatever state they are in. Using instant wire ensures the pause will happen immediately.
The whole system is mirrored at the top since the north-south rails in the lower layer can only send a signal up to 9 blocks. With read signals coming from both sides, this design could support up to 18 channels.
One last detail -- one column of music is read every 2 redstone ticks, so most of the repeaters are set to a 2 tick delay. However, the signal for a channel must be repeated using an observer every 9 blocks (adding a 1 tick delay), so the first repeater in each 9 block section is set to 1 tick. This compensates for the delay.
EDIT: I originally stated that there were 14 channels, but I overlooked that it's double-layered, and that there's a similar quad-layered system on the other side. There are 50 channels in total.
comment 8y ago · link · parent
[0]: http://grammar.ccc.commnet.edu/grammar/twain.htm
[1]: http://www.lettersofnote.com/2012/05/iorz-feixfuli-m-j-yilz....
comment 8y ago · link · parent
See: Automatic Generation of Peephole Superoptimizers, Sorav Bansal and Alex Aiken, ASPLOS 2006. https://theory.stanford.edu/~aiken/publications/papers/asplo...
My implementation: https://github.com/RussellSprouts/6502-enumerator
comment 8y ago · link · parent
[1]: http://dmitry.gr/?r=05.Projects&proj=07.%20Linux%20on%208bit
comment 8y ago · link · parent
It doesn't use "the" -- it's clear from context whether something is a type name or reference, so you just use "Node". To handle multiple variables of the same type, you can use Node, Node', Node'', etc.
It also supports phrasal methods, where arguments can appear in the middle of the method name. For example, what would be divide(x, y) could be defined as divide(x)By(y) instead.
comment 8y ago · link · parent
comment 8y ago · link · parent
It's not highlighted much in the writeup, but most of the interaction takes place in the terminal. The original assignments just use text mode. The graphics mode got started when I tried to implement ANSI escape codes in the terminal, but some of the effects weren't possible in text mode. I changed the bootloader to switch the system into a known graphics mode, then implemented a terminal emulator on top of that. From there it was just a small matter of mouse drivers and windowing commands.
JOS is a unix-inspired exokernel. It has virtual memory with thread isolation, a pre-emptive scheduler (round-robin, I think), and IPC. Everything else lives in user-land. As alluded to, the disk drivers even run in a user-land process which has been given access to the disk IO port. My windowing system is also a user-land process, which leases out buffers of memory as windows and has been given access to the memory-mapped screen buffer.
comment 9y ago · link · parent
While it may be political commentary, including a headline from a widely known newspaper also proves that the block was created sometime after that date.
comment 9y ago · link · parent
https://blogs.msdn.microsoft.com/commandline/2016/11/17/do-n...
comment 9y ago · link · parent
For the background, there are two layers -- the 2 pattern tables are 256 8x8 tile images each using 2 bpp color. The name tables are what is actually displayed. Each tile in the background is an index into one of the pattern tables. (Determined by a global selection bit).
However, in some cartridges, the pattern tables are mapped to RAM. This lets the game simulate drawing into the framebuffer directly. Some games use this for drawing variable width fonts, for example. Battletoads does some cool parallax effects. It turns out that the pattern tables have just enough bits to fill the whole screen with a monochrome image, so you could treat it as a framebuffer (it requires timing changes to midframe, though). I created a demo for that http://forums.nesdev.com/viewtopic.php?f=22&t=14884
comment 9y ago · link · parent