Skip to content
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

Merge from upstream #1

Merged
merged 42 commits into from May 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
27c2361
Rework I/O buffering (#633)
jonas Apr 21, 2017
0740a05
Fix #665: change return type of string.strtok from CChar to CString (…
rwhaling Apr 21, 2017
c530523
Implement reader for stdin (#622)
fduraffourg Apr 22, 2017
c9a43fc
Throw IllegalArgumentException when specified buffer size is 0 (#660)
zaneli Apr 24, 2017
bb19ecf
Bump Scala version to 2.11.11 (#661)
densh Apr 24, 2017
b36631b
GPL compatibility and obligations when copying code (#560)
fommil Apr 24, 2017
656c6c3
Clarify license notices (#663)
densh Apr 24, 2017
8041de7
Use FileInputStream/FileOutputStream for System.{in, out, err} (#659)
densh Apr 24, 2017
a66addd
Cross-publish nscplugin against 2.11.8, 2.11.11 (#665)
densh Apr 25, 2017
6bd8da0
Simplify name mangling (#664)
densh Apr 25, 2017
c30b00c
Add support for java.lang.Class.{isInstance, isAssignableFrom, isInte…
densh Apr 26, 2017
8d4797b
Update docs for 0.2 release (#669)
densh Apr 26, 2017
6300153
Release 0.2.0 (#670)
densh Apr 26, 2017
bc90a95
Update versions numbers on sbt doc page (#671)
densh Apr 26, 2017
ba121a5
Link release notes for 0.2.0 (#672)
densh Apr 26, 2017
82ceb25
Warn but not error if older JVM is found (#674)
densh Apr 27, 2017
2612e58
Release 0.2.1 (#677)
densh Apr 27, 2017
74197cd
Improve `run/java-io-file` scripted test (#675)
Duhemm Apr 28, 2017
806b303
Remove unused imports (#680)
zaneli Apr 28, 2017
f7b085d
Update version number in the docs (#681)
densh Apr 28, 2017
1cbceb3
GC Compiler changes (#682)
LukasKellenberger Apr 29, 2017
caa7adf
Remove semicolons at end of the line (#684)
zaneli Apr 29, 2017
804df93
Don't allocate Val.Zero for reference types (#683)
densh May 1, 2017
f1ff1ea
Initial naive implementation of selector-based row displacement (#686)
densh May 2, 2017
1fae34c
Change return types to CInt (#690)
ekrich May 3, 2017
7f899c2
Store module instance in the module array directly (#697)
densh May 4, 2017
834affa
Make sure sbt is executable on travis (#704)
MasseGuillaume May 6, 2017
c177380
Fix imports to make IntelliJ happy (#713)
ekrich May 9, 2017
d89462e
Clarify recommended LLVM minimum version and library dependencies (#706)
jonas May 9, 2017
89b08f8
Preliminary support for segfault-based safepoints (#711)
densh May 9, 2017
db8374e
Probe target without pipes (#705)
jonas May 11, 2017
03128b3
Add constant value for benchmark iterations (#717)
LukasKellenberger May 16, 2017
3b83b79
Add flush to FileOutputStream and remove default no-op flush (#702)
ekrich May 16, 2017
d1255a5
Add scopes to the tasks defined by the sbt plugin (#714)
Duhemm May 16, 2017
d034230
Improve documentation (#708)
tindzk May 17, 2017
b176026
Derive path-based package names in a file system agnostic way (#715)
jonas May 18, 2017
da05612
Fix #719 (#723)
densh May 18, 2017
dfd4814
Make `StackTraceElement` closer to Java's impl (#724)
Duhemm May 21, 2017
5c72c17
Add script to format C/C++ code (#632)
jonas May 21, 2017
7e8afe3
Support for a large subset of `java.nio` (#694)
Duhemm May 21, 2017
afdac07
Fix grp.c formatting (#728)
densh May 21, 2017
11003bf
Fix logic for opening `FileChannel`s (#729)
Duhemm May 24, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions .clang-format
@@ -0,0 +1,9 @@
---
# Documentation: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
# Sorting includes breaks the build.
SortIncludes: false
...
13 changes: 9 additions & 4 deletions .travis.yml
Expand Up @@ -10,9 +10,9 @@ matrix:
language: scala
before_install:
- sudo apt-get -qq update
- sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.7 main' >> /etc/apt/sources.list"
- sudo sh -c "echo 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list"
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
- sudo sh -c "echo 'deb http://apt.llvm.org/precise/ llvm-toolchain-precise-3.7 main' >> /etc/apt/sources.list"
- sudo sh -c "echo 'deb http://apt.llvm.org/precise/ llvm-toolchain-precise main' >> /etc/apt/sources.list"
- wget -O - http://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
- sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
- sudo apt-get -qq update
- |
Expand Down Expand Up @@ -46,6 +46,9 @@ matrix:
- brew link bdw-gc
- brew install jq
- brew install re2
- brew install llvm@4
- export PATH="/usr/local/opt/llvm@4/bin:$PATH"
env: CLANG_FORMAT_PATH="/usr/local/opt/llvm@4/bin/clang-format"

env:
global:
Expand All @@ -55,6 +58,7 @@ env:
- secure: "lAh0fiYHWaNd9Z/slDzGj2gSUF1oDwaNBlZX6eeIASFZO2W+HF79UqD/ZGsTn58Ek1XJ9FLWk0+3BIHpoLBv7S7kj2QG8AVGi4EkhvvPc/7RjcO8EM3uN8KXY/XjlDJEI4BmxX1XuzPvwhhbTuk7NY+9DFqhWV3V5xYmtMt5yJ6rbu3NROGHoiiJvBvhzKHbjkoIX0dX/dHAS2bUcRmv6BZiBA9nI1WiDMTrRjnTm1x/v4kqLG5k4UwbBRU33foFzZJrFs04jJ47GXdczCyAH7Xu+NtvxRni9fjUgEKa75PtN4XLn8GRXC6u7HCPfHz2cHTeLyLxxKK1DZ+P08+bkG4MdoaknlN7HUg1gf9zWQYuanUMiqIMry5+URT9A5Jno+Kkr9UKJKqRHxBYVLenTqVCAj8KQONdEm5vCSkqv3dfpQRrljf4CX20vO28cDqXpOTzYdFOApH3Ah8I9uXmysnto9DgVJG3ZX7ibZ6gIHE5cpZuJsBFlVYAdEEygPhRKJrtnmZO7cL7pUIWT8nj3buOuU9uK1+JpWQ32GV+vyJolDRYamxrKLNbp/SVwWHaQk8+igj4zfS42XNDbOtD6KbHdwMzRH4AdpIR8ZWfB2BXSaY9XE0fWGDgG2h+7yropmMa3DWTdT8OWdXiPkn0TDhT2GhVNwxh5G4OB1nGpgw="

before_script:
- sudo chmod +x /usr/local/bin/sbt
- if [ "$TRAVIS_PULL_REQUEST" != "false" ] ; then
echo "Incoming pull request from https://github.com/$TRAVIS_REPO_SLUG/pull/$TRAVIS_PULL_REQUEST";
author=$(curl -u dummy4dummy:dummy2dummy -s "https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST" | jq -r ".user.login");
Expand All @@ -74,5 +78,6 @@ before_script:

script:
- java -version
- if [ -n "$CLANG_FORMAT_PATH" ]; then bin/clangfmt --test; fi
- bin/scalafmt --test
- sbt -J-Xmx2G ";rebuild ;test-all"
- sbt -J-Xmx2G rebuild "set scriptedBufferLog in sbtScalaNative := false" test-all
27 changes: 0 additions & 27 deletions LICENSE

This file was deleted.

1,545 changes: 1,545 additions & 0 deletions LICENSE.md

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -8,5 +8,5 @@

## License

Scala Native is distributed under [the Scala license](
https://github.com/scala-native/scala-native/blob/master/LICENSE).
Scala Native is distributed under the Scala license.
[See LICENSE.md for details](https://github.com/scala-native/scala-native/blob/master/LICENSE.md)
25 changes: 12 additions & 13 deletions benchmarks/src/main/scala/benchmarks/Benchmark.scala
Expand Up @@ -14,26 +14,25 @@ case class BenchmarkFailed(override val name: String, cause: Throwable)
case class BenchmarkDisabled(override val name: String)
extends BenchmarkResult(name, true)

abstract class Benchmark[T] {
sealed class BenchmarkRunningTime(val iterations: Int)

case object VeryLongRunningTime extends BenchmarkRunningTime(20)
case object LongRunningTime extends BenchmarkRunningTime(1000)
case object MediumRunningTime extends BenchmarkRunningTime(10000)
case object ShortRunningTime extends BenchmarkRunningTime(30000)
case object UnknownRunningTime extends BenchmarkRunningTime(1)

abstract class Benchmark[T]() {
def run(): T
def check(t: T): Boolean

def iterations(): Int = {
// Run once to estimate how long this benchmark takes
val nsPerBenchmark = 3e9.toLong
val timeEstimate = estimateTime()
Math.max(20, (nsPerBenchmark / timeEstimate).toInt)
}
val runningTime: BenchmarkRunningTime

def iterations(): Int = runningTime.iterations

private class BenchmarkDisabledException extends Exception
final def disableBenchmark(): Nothing = throw new BenchmarkDisabledException

final def estimateTime(): Long = {
val start = System.nanoTime()
val _ = try { run() } catch { case _: Throwable => () }
System.nanoTime() - start
}

final def loop(iterations: Int): BenchmarkResult =
try {
var success: Boolean = true
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/src/main/scala/benchmarks/DummyBenchmark.scala
@@ -1,6 +1,9 @@
package benchmarks

class DummyBenchmark extends Benchmark[Int] {

override val runningTime: BenchmarkRunningTime = ShortRunningTime

override def run(): Int =
(1 to 1000).sum

Expand Down
6 changes: 5 additions & 1 deletion benchmarks/src/main/scala/benchmarks/Formats.scala
Expand Up @@ -39,7 +39,11 @@ object TextFormat extends Format {
"avg [ms]")
}

val rows = results.map {
val rows = results.sortBy {
case _: BenchmarkCompleted => 0
case _: BenchmarkDisabled => 1
case _: BenchmarkFailed => 2
} map {
case completed: BenchmarkCompleted =>
CompletedRow(completed)
case failed: BenchmarkFailed =>
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/main/scala/benchmarks/Main.scala
Expand Up @@ -4,11 +4,11 @@ import java.lang.System.exit

object Main {
def main(args: Array[String]): Unit = {
val benchmarks = Discover.discovered
val benchmarks = Discover.discovered.sortBy(_.getClass.getSimpleName)

val opts = Opts(args)
val results = benchmarks.map { bench =>
val iterations = if (!opts.test) bench.iterations else 1
val iterations = if (!opts.test) bench.iterations() else 1
bench.loop(iterations)
bench.loop(iterations)
}
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/src/main/scala/bounce/BounceBenchmark.scala
Expand Up @@ -22,6 +22,7 @@
*/
package bounce

import benchmarks.{BenchmarkRunningTime, ShortRunningTime}
import som.Random

class BounceBenchmark extends benchmarks.Benchmark[Int] {
Expand Down Expand Up @@ -51,6 +52,8 @@ class BounceBenchmark extends benchmarks.Benchmark[Int] {
}
}

override val runningTime: BenchmarkRunningTime = ShortRunningTime

override def run(): Int = {
val random = new Random()

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/brainfuck/BrainfuckBenchmark.scala
Expand Up @@ -26,7 +26,11 @@

package brainfuck

import benchmarks.{BenchmarkRunningTime, LongRunningTime}

class BrainfuckBenchmark extends benchmarks.Benchmark[String] {
override val runningTime: BenchmarkRunningTime = LongRunningTime

override def run(): String = {
new Program(Program.asText).run
}
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/src/main/scala/cd/CDBenchmark.scala
Expand Up @@ -21,13 +21,16 @@
*/
package cd

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}
import som._

class CDBenchmark extends benchmarks.Benchmark[(Int, Int)] {

private val numAircrafts = Array(1000, 500, 250, 100, 10)
private var i = 0

override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): (Int, Int) = {
val aircrafts = numAircrafts(i % numAircrafts.length)
i = i + 1
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/deltablue/DeltaBlueBenchmark.scala
Expand Up @@ -44,10 +44,14 @@ package deltablue
* I've kept it this way to avoid deviating too much from the original
* implementation.
*/
import benchmarks.{BenchmarkRunningTime, MediumRunningTime}

import scala.collection.mutable.{ArrayBuffer, ListBuffer, Stack}

class DeltaBlueBenchmark extends benchmarks.Benchmark[Unit] {

override val runningTime: BenchmarkRunningTime = MediumRunningTime

override def run(): Unit = {
chainTest(100)
projectionTest(100)
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/gcbench/GCBenchBenchmark.scala
Expand Up @@ -40,9 +40,13 @@

package gcbench

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}

class GCBenchBenchmark extends benchmarks.Benchmark[(Node, Array[Double])] {
override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): (Node, Array[Double]) = GCBenchBenchmark.start()

override def check(result: (Node, Array[Double])): Boolean =
result._1 != null && result._2(1000) == 1.0 / 1000

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/havlak/HavlakBenchmark.scala
Expand Up @@ -21,8 +21,12 @@
*/
package havlak

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}

class HavlakBenchmark extends benchmarks.Benchmark[Array[Int]] {

override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): Array[Int] =
new LoopTesterApp().main(15, 50, 10, 10, 5)

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/json/JsonBenchmark.scala
Expand Up @@ -20,6 +20,7 @@
* SOFTWARE.
******************************************************************************/
package json
import benchmarks.{BenchmarkRunningTime, LongRunningTime}

/**
* This benchmark uses a variant of the JsonParser that operates only on
Expand All @@ -28,6 +29,9 @@ package json
* @author smarr
*/
class JsonBenchmark extends benchmarks.Benchmark[JsonValue] {

override val runningTime: BenchmarkRunningTime = LongRunningTime

override def run(): JsonValue = {
(new JsonPureStringParser(rapBenchmarkMinified)).parse()
}
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/list/ListBenchmark.scala
Expand Up @@ -22,6 +22,8 @@
*/
package list

import benchmarks.{BenchmarkRunningTime, ShortRunningTime}

class ListBenchmark extends benchmarks.Benchmark[Int] {
final class Element(var value: Any, var next: Element = null) {
def length(): Int = {
Expand All @@ -33,6 +35,8 @@ class ListBenchmark extends benchmarks.Benchmark[Int] {
}
}

override val runningTime: BenchmarkRunningTime = ShortRunningTime

override def run(): Int = {
val result = tail(makeList(15), makeList(10), makeList(6))
result.length()
Expand Down
@@ -1,7 +1,12 @@
package listperm

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}

class ListPermutationsBenchmark extends benchmarks.Benchmark[Int] {
val size = 8

override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): Int = {
val permIter = (0 until size).toList.permutations

Expand Down
Expand Up @@ -42,11 +42,15 @@
// http://benchmarksgame.alioth.debian.org/u64q/program.php?test=mandelbrot&lang=yarv&id=3
package mandelbrot

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}

class MandelbrotBenchmark extends benchmarks.Benchmark[(Int, Int)] {

private val sizes = List(750, 500, 1)
private var i = 0

override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): (Int, Int) = {
val size = sizes(i % sizes.length)
i = i + 1
Expand Down
5 changes: 5 additions & 0 deletions benchmarks/src/main/scala/nbody/NbodyBenchmark.scala
Expand Up @@ -5,7 +5,12 @@
*/
package nbody

import benchmarks.{BenchmarkRunningTime, VeryLongRunningTime}

class NbodyBenchmark extends benchmarks.Benchmark[Double] {

override val runningTime: BenchmarkRunningTime = VeryLongRunningTime

override def run(): Double = {
val system = new NBodySystem()

Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/permute/PermuteBenchmark.scala
Expand Up @@ -22,10 +22,14 @@
*/
package permute

import benchmarks.{BenchmarkRunningTime, ShortRunningTime}

class PermuteBenchmark extends benchmarks.Benchmark[Int] {
var count: Int = _
var v: Array[Int] = _

override val runningTime: BenchmarkRunningTime = ShortRunningTime

override def run(): Int = {
count = 0
v = new Array[Int](6)
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/queens/QueensBenchmark.scala
Expand Up @@ -22,12 +22,16 @@
*/
package queens

import benchmarks.{BenchmarkRunningTime, MediumRunningTime}

class QueensBenchmark extends benchmarks.Benchmark[Boolean] {
var freeMaxs: Array[Boolean] = _
var freeRows: Array[Boolean] = _
var freeMins: Array[Boolean] = _
var queenRows: Array[Int] = _

override val runningTime: BenchmarkRunningTime = MediumRunningTime

override def run(): Boolean = {
var result = true
(0 until 10).foreach { i =>
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/richards/RichardsBenchmark.scala
Expand Up @@ -45,12 +45,16 @@

package richards

import benchmarks.{BenchmarkRunningTime, ShortRunningTime}

/**
* Richards simulates the task dispatcher of an operating system.
*/
class RichardsBenchmark extends benchmarks.Benchmark[(Int, Int)] {
import Richards._

override val runningTime: BenchmarkRunningTime = ShortRunningTime

override def run(): (Int, Int) = {
val scheduler = new Scheduler()
scheduler.addIdleTask(ID_IDLE, 0, null, COUNT)
Expand Down
4 changes: 4 additions & 0 deletions benchmarks/src/main/scala/sha512/SHA512Benchmark.scala
Expand Up @@ -36,11 +36,15 @@
*/

package sha512
import benchmarks.{BenchmarkRunningTime, UnknownRunningTime}

/**
* SHA-512 hashing.
*/
class SHA512Benchmark extends benchmarks.Benchmark[Boolean] {

override val runningTime: BenchmarkRunningTime = UnknownRunningTime

override def run(): Boolean = {
disableBenchmark()
// Fails
Expand Down