Skip to content

Instantly share code, notes, and snippets.


⭐caitp⭐ caitp

View GitHub Profile
Last active Jul 9, 2020
A shellscript for cross compiling JavaScriptCore/JSC with CMake and
# Automatically generated file; DO NOT EDIT.
# Buildroot 2020.05 Configuration
View 0001-JSC-add-limited-support-for-class-fields.patch
From 4cb549619bcf39b16575f4a5bebf264a8e1b8238 Mon Sep 17 00:00:00 2001
From: Caitlin Potter <>
Date: Fri, 13 Apr 2018 16:59:01 -0400
Subject: [PATCH 1/3] [JSC] add limited support for class fields
supports a very basic subset of the class fields proposal
Source/JavaScriptCore/bytecode/ExecutableInfo.h | 5 +-
.../JavaScriptCore/bytecode/UnlinkedCodeBlock.cpp | 1 +
Source/JavaScriptCore/bytecode/UnlinkedCodeBlock.h | 2 +

I think we need better primitives for yield/yield*/await in v8.

Here's the current stuff:

void BytecodeGenerator::BuildGeneratorSuspend(Suspend* expr, Register value,
                                              RegisterList registers_to_save) {
  RegisterAllocationScope register_scope(this);

  // Save context, registers, and state. Then return.

Walkthrough of the following script (v8:6573).

var logFoo;
var promise1 = Promise.resolve().then( () => logFoo = () => console.log( "foo" ) );
promise1.then( () => logFoo() ).then( logFoo );

1. var logFoo;

View async-gen-race.js
let caps = [];
async function* SpeedRacer() {
yield new Promise(function(resolve, reject) {
caps.push({ resolve, reject });
yield new Promise(function(resolve, reject) {
caps.push({ resolve, reject });
caitp / string-iterator.js
Last active Sep 23, 2016
v8 microbenchmarks for string iterators (
View string-iterator.js
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
new BenchmarkSuite('StringIterators-Spread_OneByteShort', [1000], [
new Benchmark('test', false, false, 0,
Spread_OneByteShort, Spread_OneByteShortSetup,
View gist:d672ede9efacf57e1a26

Right now, the issue with the arguments object is basically the following:

  • Arguments object is not actually allocated in optimized code. Element accesses and access to arguments.length are translated into loading from the stack.
  • This means, you can't touch the stack while the arguments object is alive, because touching the stack would break this optimization (this is why, function calls with the arguments object as a parameter are not allowed, it can't be pushed to the stack).

Rest parameters, currently, do not implement this optimization. So they will always allocate an array (and the array allocation is always done in C++, which is not ideal).

This means, if we can enable optimized code to use rest parameters (I had trouble getting Crankshaft to work, although TurboFan happily just builds the array like it's supposed to), there's no problem passing it to other functions or using methods from Array.prototype.

Of course, if we did avoid allocating an actual object, and just used the stack load strateg

View gist:dc25c497fe1ef4006a12
d8> function fn(a, ...b) { return b; }
d8> fn(1,2,3)
[3, 32767]
View angular-1.3-beta.15.js
* @license AngularJS v1.3.0-beta.15
* (c) 2010-2014 Google, Inc.
* License: MIT
(function(window, document, undefined) {'use strict';
* @description