Skip to content

Instantly share code, notes, and snippets.

⭐caitp⭐ caitp

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

@caitp
caitp / string-iterator.js
Last active Sep 23, 2016
v8 microbenchmarks for string iterators (https://codereview.chromium.org/2358263002)
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,
Spread_OneByteShortTearDown),
]);
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 });
});
}
View promise-walkthrough.md

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 yield.md

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.
View 0001-JSC-add-limited-support-for-class-fields.patch
From 4cb549619bcf39b16575f4a5bebf264a8e1b8238 Mon Sep 17 00:00:00 2001
From: Caitlin Potter <caitp@igalia.com>
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 +
@caitp
caitp / buildJSC.sh
Created Jul 1, 2020
A shellscript for cross compiling JavaScriptCore/JSC with CMake and https://buildroot.org/
View buildJSC.sh
#!/usr/bin/env bash
# A fancy build-jsc script for non-Mac users!
#
# It will let you cross compile usingg buildroot (BRE2, at least) sdks configured with the following:
#
# - C++ support (BR2_TOOLCHAIN_BUILDROOT_CXX, BR2_INSTALL_LIBSTDCPP)
# - WCHAR support (BR2_TOOLCHAIN_BUILDROOT_WCHAR)
# - icu (BR2_PACKAGE_ICU)
#
You can’t perform that action at this time.