зеркало из https://github.com/mozilla/pluotsorbet.git
Yield test and benchmark.
This commit is contained in:
Родитель
9f5839232e
Коммит
154b738e59
|
@ -0,0 +1,22 @@
|
|||
package benchmark;
|
||||
|
||||
import com.sun.cldchi.jvm.JVM;
|
||||
import org.mozilla.internal.Sys;
|
||||
|
||||
public class YieldBench {
|
||||
void runBenchmark() {
|
||||
long start = JVM.monotonicTimeMillis();
|
||||
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
Thread.yield();
|
||||
}
|
||||
|
||||
System.out.println("Unwinds: " + Sys.getUnwindCount());
|
||||
System.out.println(JVM.monotonicTimeMillis() - start);
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
YieldBench bench = new YieldBench();
|
||||
bench.runBenchmark();
|
||||
}
|
||||
}
|
8
int.ts
8
int.ts
|
@ -401,7 +401,6 @@ module J2ME {
|
|||
frame.monitor = monitor;
|
||||
$.ctx.monitorEnter(monitor);
|
||||
if (U === VMState.Pausing || U === VMState.Stopping) {
|
||||
debugger;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -1383,7 +1382,6 @@ module J2ME {
|
|||
if (op === Bytecodes.GETSTATIC) {
|
||||
classInitAndUnwindCheck(fieldInfo.classInfo, opPC);
|
||||
if (U) {
|
||||
debugger;
|
||||
return;
|
||||
}
|
||||
object = fieldInfo.classInfo.getStaticObject($.ctx);
|
||||
|
@ -1420,7 +1418,6 @@ module J2ME {
|
|||
if (isStatic) {
|
||||
classInitAndUnwindCheck(fieldInfo.classInfo, opPC);
|
||||
if (U) {
|
||||
debugger;
|
||||
return;
|
||||
}
|
||||
object = fieldInfo.classInfo.getStaticObject($.ctx);
|
||||
|
@ -1459,7 +1456,6 @@ module J2ME {
|
|||
thread.set(fp, sp, pc);
|
||||
classInitAndUnwindCheck(classInfo, opPC);
|
||||
if (U) {
|
||||
debugger;
|
||||
return;
|
||||
}
|
||||
loadThreadState();
|
||||
|
@ -1688,10 +1684,6 @@ module J2ME {
|
|||
return;
|
||||
}
|
||||
|
||||
if (!release) {
|
||||
assert(!(returnValue instanceof Long.constructor), "NO LONGS ALLOWED");
|
||||
}
|
||||
|
||||
kind = signatureKinds[0];
|
||||
|
||||
// Push return value.
|
||||
|
|
|
@ -77,6 +77,11 @@ public final class Sys {
|
|||
*/
|
||||
public native static void eval(String src);
|
||||
|
||||
/**
|
||||
* Returns the total number of times the VM has unwound threads.
|
||||
*/
|
||||
public native static int getUnwindCount();
|
||||
|
||||
public static void throwException(Exception e) throws Exception {
|
||||
throw e;
|
||||
}
|
||||
|
|
14
nat.ts
14
nat.ts
|
@ -95,9 +95,19 @@ module J2ME {
|
|||
}));
|
||||
};
|
||||
|
||||
Native["java/lang/Thread.isAlive.()Z"] = function() {
|
||||
return this.alive ? 1 : 0;
|
||||
};
|
||||
|
||||
Native["java/lang/Thread.yield.()V"] = function() {
|
||||
$.yield("Thread.yield");
|
||||
$.ctx.nativeThread.advancePastInvokeBytecode();
|
||||
};
|
||||
|
||||
Native["java/lang/Object.wait.(J)V"] = function(timeoutL: number, timeoutH: number) {
|
||||
release || assert(timeoutH === 0, "H: " + timeoutH);
|
||||
$.ctx.wait(this, timeoutL);
|
||||
$.ctx.nativeThread.advancePastInvokeBytecode();
|
||||
};
|
||||
|
||||
Native["java/lang/Object.notify.()V"] = function() {
|
||||
|
@ -107,4 +117,8 @@ module J2ME {
|
|||
Native["java/lang/Object.notifyAll.()V"] = function() {
|
||||
$.ctx.notify(this, true);
|
||||
};
|
||||
|
||||
Native["org/mozilla/internal/Sys.getUnwindCount.()I"] = function() {
|
||||
return unwindCount;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -508,14 +508,6 @@ Native["java/lang/Thread.start0.()V"] = function() {
|
|||
newCtx.start();
|
||||
}
|
||||
|
||||
Native["java/lang/Thread.isAlive.()Z"] = function() {
|
||||
return this.alive ? 1 : 0;
|
||||
};
|
||||
|
||||
Native["java/lang/Thread.yield.()V"] = function() {
|
||||
$.yield("Thread.yield");
|
||||
};
|
||||
|
||||
Native["java/lang/Thread.activeCount.()I"] = function() {
|
||||
return $.ctx.runtime.threadCount;
|
||||
};
|
||||
|
|
|
@ -168,6 +168,7 @@ public class ShellTestlets {
|
|||
"gnu/testlet/java/lang/Math/sin",
|
||||
"gnu/testlet/java/util/Vector/copyInto",
|
||||
"gnu/testlet/java/lang/Thread/sleep",
|
||||
"gnu/testlet/java/lang/Thread/yield",
|
||||
null
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
// Tags: JDK1.0
|
||||
|
||||
// Copyright (C) 2002 Free Software Foundation, Inc.
|
||||
// Written by Mark Wielaard (mark@klomp.org)
|
||||
|
||||
// This file is part of Mauve.
|
||||
|
||||
// Mauve is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation; either version 2, or (at your option)
|
||||
// any later version.
|
||||
|
||||
// Mauve is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Mauve; see the file COPYING. If not, write to
|
||||
// the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA. */
|
||||
|
||||
|
||||
package gnu.testlet.java.lang.Thread;
|
||||
|
||||
import gnu.testlet.Testlet;
|
||||
import gnu.testlet.TestHarness;
|
||||
import com.sun.cldchi.jvm.JVM;
|
||||
import org.mozilla.internal.Sys;
|
||||
|
||||
public class yield extends Thread implements Testlet
|
||||
{
|
||||
public int getExpectedPass() { return 1; }
|
||||
public int getExpectedFail() { return 0; }
|
||||
public int getExpectedKnownFail() { return 0; }
|
||||
|
||||
public void test (TestHarness harness)
|
||||
{
|
||||
long start = Sys.getUnwindCount();
|
||||
for (int i = 0; i < 100; i++) {
|
||||
Thread.yield();
|
||||
}
|
||||
harness.check((Sys.getUnwindCount() - start) == 100, "Not enough unwinds.");
|
||||
System.out.println("Unwinds: " + (Sys.getUnwindCount() - start));
|
||||
}
|
||||
}
|
||||
|
Загрузка…
Ссылка в новой задаче