Mercurial > hg > graal-compiler
comparison graal/com.oracle.truffle.api.test/src/com/oracle/truffle/api/test/ThreadSafetyTest.java @ 14991:64dcb92ee75a
Truffle: Change signature for Truffle calls from (PackedFrame, Arguments) to (Object[]).
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sun, 06 Apr 2014 17:46:24 +0200 |
parents | 69375786ef70 |
children | f675818d9ad0 |
comparison
equal
deleted
inserted
replaced
14989:a0dbb3628f2a | 14991:64dcb92ee75a |
---|---|
62 final AtomicInteger ai = new AtomicInteger(); | 62 final AtomicInteger ai = new AtomicInteger(); |
63 for (int i = 0; i < numberOfIterations; i++) { | 63 for (int i = 0; i < numberOfIterations; i++) { |
64 executorService.submit(new Runnable() { | 64 executorService.submit(new Runnable() { |
65 public void run() { | 65 public void run() { |
66 try { | 66 try { |
67 Object result = target.call(new TestArguments(5)); | 67 Object result = target.call(new Object[]{5}); |
68 assertEquals(expectedResult, result); | 68 assertEquals(expectedResult, result); |
69 ai.incrementAndGet(); | 69 ai.incrementAndGet(); |
70 } catch (Throwable t) { | 70 } catch (Throwable t) { |
71 PrintStream out = System.out; | 71 PrintStream out = System.out; |
72 out.println(t); | 72 out.println(t); |
76 } | 76 } |
77 executorService.shutdown(); | 77 executorService.shutdown(); |
78 executorService.awaitTermination(90, TimeUnit.SECONDS); | 78 executorService.awaitTermination(90, TimeUnit.SECONDS); |
79 assertTrue("test did not terminate", executorService.isTerminated()); | 79 assertTrue("test did not terminate", executorService.isTerminated()); |
80 assertEquals(numberOfIterations, ai.get()); | 80 assertEquals(numberOfIterations, ai.get()); |
81 } | |
82 | |
83 static class TestArguments extends Arguments { | |
84 final int arg; | |
85 | |
86 public TestArguments(int arg) { | |
87 this.arg = arg; | |
88 } | |
89 } | 81 } |
90 | 82 |
91 static class TestRootNode extends RootNode { | 83 static class TestRootNode extends RootNode { |
92 | 84 |
93 @Child private ValueNode child; | 85 @Child private ValueNode child; |
180 this.valueNode = value; | 172 this.valueNode = value; |
181 } | 173 } |
182 | 174 |
183 @Override | 175 @Override |
184 int execute(VirtualFrame frame) { | 176 int execute(VirtualFrame frame) { |
185 int arg = frame.getArguments(TestArguments.class).arg; | 177 int arg = (Integer) frame.getArguments()[0]; |
186 if (arg > 0) { | 178 if (arg > 0) { |
187 return (int) callNode.call(frame.pack(), new TestArguments(arg - 1)); | 179 return (int) callNode.call(new Object[]{(arg - 1)}); |
188 } else { | 180 } else { |
189 return valueNode.execute(frame); | 181 return valueNode.execute(frame); |
190 } | 182 } |
191 } | 183 } |
192 | 184 |