Skip to content

Instantly share code, notes, and snippets.

View sjrd's full-sized avatar

Sébastien Doeraene sjrd

View GitHub Profile
@sjrd
sjrd / reversi-fastopt.js.diff
Created October 17, 2014 22:02
Differences in reversi-fastopt.js from optimizing AnonFunctions to optimizing Closures
diff --git "a/C:\\Users\\Sepi\\Documents\\Projets\\reversi-fastopt.js" "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\examples\\reversi\\target\\scala-2.11\\reversi-fastopt.js"
index 2eba7e5..d384cf7 100644
--- "a/C:\\Users\\Sepi\\Documents\\Projets\\reversi-fastopt.js"
+++ "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\examples\\reversi\\target\\scala-2.11\\reversi-fastopt.js"
@@ -906,6 +906,12 @@ ScalaJS.i.sc_GenSetLike$class__equals__sc_GenSetLike__O__Z = (function($$this, t
return false
}
});
+ScalaJS.i.sc_IndexedSeqLike$class__toBuffer__sc_IndexedSeqLike__scm_Buffer = (function($$this) {
+ var result = new ScalaJS.c.scm_ArrayBuffer().init___I($$this.size__I());
@sjrd
sjrd / TypedArrayFloatBuffer.js
Created February 22, 2015 22:18
Translation to JS of Scala.js' TypedArrayFloatBuffer
ScalaJS.c.Ljava_nio_TypedArrayFloatBuffer.prototype = new ScalaJS.h.Ljava_nio_FloatBuffer();
ScalaJS.c.Ljava_nio_TypedArrayFloatBuffer.prototype.constructor = ScalaJS.c.Ljava_nio_TypedArrayFloatBuffer;
/** @constructor */
ScalaJS.h.Ljava_nio_TypedArrayFloatBuffer = (function() {
/*<skip>*/
});
ScalaJS.h.Ljava_nio_TypedArrayFloatBuffer.prototype = ScalaJS.c.Ljava_nio_TypedArrayFloatBuffer.prototype;
ScalaJS.c.Ljava_nio_TypedArrayFloatBuffer.prototype.slice__Ljava_nio_FloatBuffer = (function() {
var slicedTypedArray = this.$$undtypedArray$3["subarray"](this.java$nio$Buffer$$$undposition$1, this.$$undlimit$1);
var initialLimit = ScalaJS.uI(slicedTypedArray["length"]);
@sjrd
sjrd / deltablue-es5.js
Created May 8, 2015 13:42
Scala.js benchmarks: ES5.1, ES6 and ES6 Strong Mode -- run with `$ d8 --harmony-rest-parameters --strong-mode file.js`
this['console'] = {};
this['console']['log'] = this['print'];
(function(){
'use strict';
/* Scala.js runtime support
* Copyright 2013 LAMP/EPFL
* Author: Sébastien Doeraene
*/
/* ---------------------------------- *
@sjrd
sjrd / parser-combinators-fastopt.js
Last active August 29, 2015 14:20
Emitted code for PoC fast macro-free parser combinators in Scala.js
ScalaJS.c.LScalaJSExample$.prototype.parse__T__T = (function(s) {
var jsx$2 = ScalaJS.m.sjsr_RuntimeString$();
if (((ScalaJS.uI(s["length"]) > 0) && ((65535 & ScalaJS.uI(s["charCodeAt"](0))) === 104))) {
var value = new ScalaJS.c.jl_Character().init___C(104);
var r1_$_success$1 = true;
var r1_$_value$1 = value;
var r1_$_nextPos$1 = 1
} else {
var r1_$_success$1 = false;
var r1_$_value$1 = null;
Welcome to Scala version 2.11.1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_31).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import scala.collection.JavaConversions._
import scala.collection.JavaConversions._
scala> val list = new java.util.ArrayList[Int]
list: java.util.ArrayList[Int] = []
[info] Scala.js IR: found 6 potential binary incompatibilities (filtered 5)
[error] * synthetic method org$scalajs$core$ir$Traversers$Traverser$$$anonfun$17$adapted(scala.Tuple2)java.lang.Object in class org.scalajs.core.ir.Traversers#Traverser's type has changed; was (scala.Tuple2)java.lang.Object, is now: (org.scalajs.core.ir.Trees#Tree)java.lang.Object
[error] filter with: ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.scalajs.core.ir.Traversers#Traverser.org$scalajs$core$ir$Traversers$Traverser$$$anonfun$17$adapted")
[error] * synthetic method org$scalajs$core$ir$Traversers$Traverser$$$anonfun$19$adapted(org.scalajs.core.ir.Trees#Tree)java.lang.Object in class org.scalajs.core.ir.Traversers#Traverser's type has changed; was (org.scalajs.core.ir.Trees#Tree)java.lang.Object, is now: (scala.Tuple2)java.lang.Object
[error] filter with: ProblemFilters.exclude[IncompatibleMethTypeProblem]("org.scalajs.core.ir.Traversers#Traverser.org$scalajs$core$ir$Traversers$Traverser$$$anonfun$19$adapted")
@sjrd
sjrd / Deep dive into Scala.js internals.md
Created January 22, 2016 14:53
ScalaDays 2016 Proposals

Have you ever dreamed of understanding how Scala.js works under the covers? Knowing your way around its codebase? This is your chance! This advanced talk will take you to the deepest parts of Scala.js: its compiler, its Intermediate Representation, its linker and its optimizer.

Through live coding within the Scala.js codebase, we will explain how the Scala.js compilation pipeline works, and how you can modify it. After this talk, you will understand the Scala.js IR and be able to manipulate it. And you'll be ready to write your custom Linker Plugins!

Attendees are expected to be proficient in Scala and have some compiler background (e.g., knowing what an AST is is vital).

[error] error: scala.reflect.internal.FatalError:
[error] Could not generate raw function maker for JS function: Found a non-apply method method $anonfun$4 in
@SerialVersionUID(value = 0) final <synthetic> class anonfun$toJSPromise$extension$1 extends scala.scalajs.js
.Function with scala.scalajs.js.Function2 with Serializable {
[error] final def apply(arg1: scala.scalajs.js.Function1, arg2: scala.scalajs.js.Function1): Unit = anonfun$
toJSPromise$extension$1.this.$this$1.onComplete({
[error] ((x0$2: scala.util.Try) => anonfun$toJSPromise$extension$1.this.$anonfun$4(arg1, arg2, x0$2))
[error] }, anonfun$toJSPromise$extension$1.this.executor$1);
[error] final <bridge> <artifact> def apply(arg1: Object, arg2: Object): Object = {
[error] anonfun$toJSPromise$extension$1.this.apply(arg1.$asInstanceOf[scala.scalajs.js.Function1](), arg2.
package example
import scala.scalajs.js
import org.scalajs.dom
@js.native
trait EventName extends js.Any {
type EventType <: dom.Event
}
@sjrd
sjrd / test-suite-fastopt.js.diff
Created June 7, 2016 21:48
Impact of PreTransUnaryOp and PreTransBinaryOp on the Scala.js test suite
diff --git "a/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\test-suite\\js\\target\\scala-2.11\\scalajs-test-suite-test-fastopt.js" "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs-test-suite-test-fastopt.js"
index 98365f8..338b8c6 100644
--- "a/C:\\Users\\Sepi\\Documents\\Projets\\scalajs\\test-suite\\js\\target\\scala-2.11\\scalajs-test-suite-test-fastopt.js"
+++ "b/C:\\Users\\Sepi\\Documents\\Projets\\scalajs-test-suite-test-fastopt.js"
@@ -30731,7 +30731,6 @@ $c_Lorg_scalajs_testsuite_compiler_OptimizerTest.prototype.must$undnot$undbreak$
if (isEmpty$4) {
/*<skip>*/
};
- var lastElement$4 = (isEmpty$4 ? (((-1) + x) | 0) : 2);
var isEmpty$4$1 = (x < 2);