8000 DO NOT MERGE Simulation: What if we dropped support for ES 5.1. by sjrd · Pull Request #5129 · scala-js/scala-js · GitHub
[go: up one dir, main page]

Skip to content

DO NOT MERGE Simulation: What if we dropped support for ES 5.1. #5129

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -278,27 +278,27 @@ def Tasks = [
setJavaVersion $java
npm install &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSStage in Global := FullOptStage' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
'set scalaJSStage in Global := FullOptStage' \
++$scala $testSuite$v/test &&
sbtretry 'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withESFeatures(_.withESVersion(ESVersion.$esVersion)))' \
'set Seq(jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion), MyScalaJSPlugin.wantSourceMaps in $testSuite.v$v := ("$esVersion" != "ES5_1"))' \
'set jsEnv in $testSuite.v$v := new NodeJSEnvForcePolyfills(ESVersion.$esVersion)' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= makeCompliant' \
'set scalaJSLinkerConfig in $testSuite.v$v ~= (_.withOptimizer(false))' \
++$scala $testSuite$v/test
Expand Down Expand Up @@ -542,7 +542,6 @@ def otherScalaVersions = [
def scala3Version = "3.6.3"

def allESVersions = [
"ES5_1",
"ES2015",
// "ES2016", // Technically we have the '**' operator dependent on ES2016, but it's not enough to justify testing this version
"ES2017",
Expand All @@ -561,11 +560,9 @@ mainScalaVersions.each { scalaVersion ->
}
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "true", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-custom-esversion", scala: scalaVersion, java: mainJavaVersion, esVersion: "ES5_1", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "testSuiteEx"])
quickMatrix.add([task: "test-suite-default-esversion", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "test-suite-custom-esversion", scala: scalaVersion, java: mainJavaVersion, esVersion: "ES5_1", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "test-suite-webassembly", scala: scalaVersion, java: mainJavaVersion, testMinify: "false", testSuite: "scalaTestSuite"])
quickMatrix.add([task: "bootstrap", scala: scalaVersion, java: mainJavaVersion])
quickMatrix.add([task: "partest-fastopt", scala: scalaVersion, java: mainJavaVersion, partestopts: ""])
Expand Down
2 changes: 1 addition & 1 deletion ir/shared/src/main/scala/org/scalajs/ir/Trees.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ object Trees {
object LinkTimeProperty {
final val ProductionMode = "core/productionMode"
final val ESVersion = "core/esVersion"
final val UseECMAScript2015Semantics = "core/useECMAScript2015Semantics"
final val UseECMAScript2015Semantics = "core/useECMAScript2015Semantics" // legacy, always true
final val IsWebAssembly = "core/isWebAssembly"
final val LinkerVersion = "core/linkerVersion"
}
Expand Down
14 changes: 1 addition & 13 deletions javalib/src/main/scala/java/lang/Character.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,19 +128,7 @@ object Character {
if (!isValidCodePoint(codePoint))
throw new IllegalArgumentException()

if (LinkingInfo.esVersion >= ESVersion.ES2015) {
js.Dynamic.global.String.fromCodePoint(codePoint).asInstanceOf[String]
} else {
if (codePoint < MIN_SUPPLEMENTARY_CODE_POINT) {
js.Dynamic.global.String
.fromCharCode(codePoint)
.asInstanceOf[String]
} else {
js.Dynamic.global.String
.fromCharCode(highSurrogate(codePoint).toInt, lowSurrogate(codePoint).toInt)
.asInstanceOf[String]
}
}
js.Dynamic.global.String.fromCodePoint(codePoint).asInstanceOf[String]
}

// Low-level code point and code unit manipulations -------------------------
Expand Down
59 changes: 5 additions & 54 deletions javalib/src/main/scala/java/lang/ClassValue.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,62 +22,13 @@ import scala.scalajs.LinkingInfo.ESVersion
import Utils._

abstract class ClassValue[T] protected () {
private val jsMap: js.Map[Class[_], T] = {
if (LinkingInfo.esVersion >= ESVersion.ES2015 || js.typeOf(js.Dynamic.global.Map) != "undefined")
new js.Map()
else
null
}

@inline
private def useJSMap: scala.Boolean = {
/* The linking-info test allows to constant-fold this method as `true` when
* emitting ES 2015 code, which allows to dead-code-eliminate the branches
* using `HashMap`s, and therefore `HashMap` itself.
*/
LinkingInfo.esVersion >= ESVersion.ES2015 || jsMap != null
}

/* We use a HashMap instead of an IdentityHashMap because the latter is
* implemented in terms of the former anyway, to a HashMap is leaner and
* faster.
*/
private val javaMap: HashMap[Class[_], T] =
if (useJSMap) null
else new HashMap()
private val jsMap: js.Map[Class[_], T] = new js.Map()

protected def computeValue(`type`: Class[_]): T

def get(`type`: Class[_]): T = {
if (useJSMap) {
mapGetOrElseUpdate(jsMap, `type`)(() => computeValue(`type`))
} else {
/* We first perform `get`, and if the result is null, we use
* `containsKey` to disambiguate a present null from an absent key.
* Since the purpose of ClassValue is to be used a cache indexed by Class
* values, the expected use case will have more hits than misses, and so
* this ordering should be faster on average than first performing `has`
* then `get`.
*/
javaMap.get(`type`) match {
case null =>
if (javaMap.containsKey(`type`)) {
7413 null.asInstanceOf[T]
} else {
val newValue = computeValue(`type`)
javaMap.put(`type`, newValue)
newValue
}
case value =>
value
}
}
}
def get(`type`: Class[_]): T =
mapGetOrElseUpdate(jsMap, `type`)(() => computeValue(`type`))

def remove(`type`: Class[_]): Unit = {
if (useJSMap)
jsMap.delete(`type`)
else
javaMap.remove(`type`)
}
def remove(`type`: Class[_]): Unit =
jsMap.delete(`type`)
}
Loading
0