From 5be903bf50770558f5f85126c4e035445cf1f8f3 Mon Sep 17 00:00:00 2001 From: Jaroslav Tulach Date: Thu, 28 Jan 2016 08:47:19 +0100 Subject: [PATCH 1/3] Using slightly faster version of bck2brwsr in the JBox2D benchmark. --- samples/benchmark/README.md | 4 ++-- samples/benchmark/pom.xml | 9 +-------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/samples/benchmark/README.md b/samples/benchmark/README.md index 7cc449341..fd8d1034d 100644 --- a/samples/benchmark/README.md +++ b/samples/benchmark/README.md @@ -1,5 +1,5 @@ -TeaVM, GWT, HotSport JBox2D Benchmark -===================================== +TeaVM, GWT, HotSpot, Bck2Brwsr JBox2D Benchmark +=============================================== Compares the speed of execution on a complex [JBox2D](http://www.jbox2d.org/) CPU extensive computation. JavaScript produced by TeaVM and GWT can be compared by running diff --git a/samples/benchmark/pom.xml b/samples/benchmark/pom.xml index 03634bc92..f1e5ceac9 100644 --- a/samples/benchmark/pom.xml +++ b/samples/benchmark/pom.xml @@ -19,7 +19,7 @@ Compares performance of the JavaScript code produced by TeaVM and GWT - 0.14 + 0.17 @@ -64,13 +64,6 @@ html5-canvas 0.7.2 - - com.dukescript.canvas - canvas-api - 0.7.2 - bck2brwsr - provided - org.apidesign.bck2brwsr ko-bck2brwsr From eb2e08da3fd65ed22f19ce3b6a01e83f95645857 Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Fri, 5 Feb 2016 15:02:41 -0800 Subject: [PATCH 2/3] Fixed NPE in LinkedList.remove(e) --- .../main/java/org/teavm/classlib/java/util/TLinkedList.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java b/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java index ff98a6b97..d91237ac4 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TLinkedList.java @@ -343,10 +343,10 @@ public class TLinkedList extends TAbstractSequentialList implements TDeque } removeEntry(currentEntry); if (currentEntry == prevEntry) { - prevEntry = nextEntry.previous; + prevEntry = hasNext() ? nextEntry.previous : null; --index; } else if (currentEntry == nextEntry) { - nextEntry = prevEntry.next; + nextEntry = hasPrevious() ? prevEntry.next : null; } --size; version = modCount; From 9a52a277b953a5f92a7a9c9bbce3f8a5bc2741b3 Mon Sep 17 00:00:00 2001 From: Steve Hannah Date: Wed, 17 Feb 2016 11:46:10 -0800 Subject: [PATCH 3/3] Added Timer.scheduleTaskAtFixedRate() method --- .../org/teavm/classlib/java/util/TTimer.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/classlib/src/main/java/org/teavm/classlib/java/util/TTimer.java b/classlib/src/main/java/org/teavm/classlib/java/util/TTimer.java index aeb24a736..7e5df559b 100644 --- a/classlib/src/main/java/org/teavm/classlib/java/util/TTimer.java +++ b/classlib/src/main/java/org/teavm/classlib/java/util/TTimer.java @@ -81,4 +81,33 @@ public class TTimer extends TObject { }; task.nativeTimerId = Window.setTimeout(handler, (int) delay); } + + public void scheduleAtFixedRate(final TTimerTask task, long delay, long period) { + if (cancelled || task.timer != null || task.nativeTimerId >= 0) { + throw new TIllegalStateException(); + } + final long[] nextStartTime = new long[]{System.currentTimeMillis() + delay}; + task.timer = this; + TimerHandler handler = new TimerHandler() { + @Override public void onTimer() { + new Thread(() -> { + if (cancelled || task.timer == null) { + return; + } + long nextDelay = nextStartTime[0] - System.currentTimeMillis(); + if (nextDelay < 0 ) { + nextDelay = 0; + } + task.nativeTimerId = Window.setTimeout(this, (int) nextDelay); + nextStartTime[0] += period; + TTimerTask.performOnce(task); + if (!cancelled) { + task.timer = TTimer.this; + } + }).start(); + } + }; + task.nativeTimerId = Window.setTimeout(handler, (int) delay); + nextStartTime[0] += period; + } }