Skip to content

Instantly share code, notes, and snippets.

View caitp's full-sized avatar
💭
more active in FOSS than my github activity might have you believe!

⭐caitp⭐ caitp

💭
more active in FOSS than my github activity might have you believe!
View GitHub Profile
@caitp
caitp / ChatGPT Solves Everything.md
Created December 20, 2022 00:15
ChatGPT Fixes The World

Q: what are some regulations that already exist that, if enforced adequately, could result in an equitable and healthy society in any given chunk of the anglosphere?

A: There are a number of regulations that, if enforced adequately, could contribute to an equitable and healthy society in any given chunk of the Anglosphere. Some examples of these regulations might include:

Employment laws: These laws ensure that workers are treated fairly and have access to safe and healthy working conditions. Anti-discrimination laws: These laws protect individuals from discrimination on the basis of characteristics such as race, gender, sexual orientation, and age. Environmental regulations: These regulations protect the environment and promote sustainable development, which can contribute to the overall health and well-being of a society. Consumer protection laws: These laws protect consumers from deceptive or fraudulent practices, ensuring that they are able to make informed decisions about the products and services

@caitp
caitp / RPI4_BUILDROOT_CONFIG
Last active July 9, 2020 15:56
A shellscript for cross compiling JavaScriptCore/JSC with CMake and https://buildroot.org/
#
# Automatically generated file; DO NOT EDIT.
# Buildroot 2020.05 Configuration
#
BR2_HAVE_DOT_CONFIG=y
BR2_HOST_GCC_AT_LEAST_4_9=y
BR2_HOST_GCC_AT_LEAST_5=y
BR2_HOST_GCC_AT_LEAST_6=y
BR2_HOST_GCC_AT_LEAST_7=y
From 4cb549619bcf39b16575f4a5bebf264a8e1b8238 Mon Sep 17 00:00:00 2001
From: Caitlin Potter <[email protected]>
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;

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
caitp / string-iterator.js
Last active September 23, 2016 14:04
v8 microbenchmarks for string iterators (https://codereview.chromium.org/2358263002)
// 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),
]);

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

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