-
Notifications
You must be signed in to change notification settings - Fork 19
Fix some non-bug IntelliJ warnings #124
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,7 +80,7 @@ public void run() { | |
| var export = instance.export(functionName); | ||
| var params = new long[type.params().size()]; | ||
| for (var i = 0; i < type.params().size(); i++) { | ||
| params[i] = Long.valueOf(arguments[i]); | ||
| params[i] = arguments[i]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| } | ||
|
|
||
| var result = export.apply(params); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -254,7 +254,7 @@ public static int i32_ge_u(int a, int b) { | |
| var prop = System.getProperty("endive.memCopyWorkaround"); | ||
|
|
||
| if (prop != null) { | ||
| memCopyWorkaround = Boolean.valueOf(prop); | ||
| memCopyWorkaround = Boolean.parseBoolean(prop); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| } else { | ||
| memCopyWorkaround = shouldUseMemWorkaround(); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,8 +39,8 @@ interface LockWithTimeout { | |
| int lock(Instance instance, int mutexAddr, long expected); | ||
| } | ||
|
|
||
| private static MemoryLimits memoryLimits = new MemoryLimits(1, 1, true); | ||
| private static List<Supplier<Memory>> memories = | ||
| private static final MemoryLimits memoryLimits = new MemoryLimits(1, 1, true); | ||
| private static final List<Supplier<Memory>> memories = | ||
| List.of( | ||
| () -> new ByteArrayMemory(memoryLimits), | ||
| () -> new ByteBufferMemory(memoryLimits)); | ||
|
|
@@ -53,7 +53,7 @@ interface LockWithTimeout { | |
| instBuilder.withMachineFactory(MachineFactoryCompiler::compile), | ||
| // build time compiler | ||
| (instBuilder) -> instBuilder.withMachineFactory(ThreadsExampleModule::create)); | ||
| private static List<LockWithTimeout> locks = | ||
| private static final List<LockWithTimeout> locks = | ||
| List.of( | ||
| ThreadsProposalTest::lockMutexWithTimeout, | ||
| ThreadsProposalTest::lock64MutexWithTimeout); | ||
|
|
@@ -309,7 +309,7 @@ public void atomicFenceOrder( | |
| () -> { | ||
| long a; | ||
| do { | ||
| a = (long) fencedReadAndVerify.apply()[0]; | ||
| a = fencedReadAndVerify.apply()[0]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant: |
||
| } while (a < minIterations); | ||
| }); | ||
| done.set(true); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -227,7 +227,7 @@ public void shouldSupportMemoryFactoryOverride() { | |
| return new ByteBufferMemory(limits); | ||
| }) | ||
| .build(); | ||
| assertEquals(true, memoryCreated.get()); | ||
| assertTrue(memoryCreated.get()); | ||
| } | ||
|
|
||
| @Test | ||
|
|
@@ -396,17 +396,17 @@ public void shouldConsumeStackLoopOperations() { | |
| assertEquals(factorial(number), result[0]); | ||
|
|
||
| // IIUC: 3 values returning from last CALL + 1 result | ||
| assertTrue(finalStackSize.get() == 4L); | ||
| assertEquals(4L, finalStackSize.get()); | ||
| } | ||
|
|
||
| @Test | ||
| public void shouldEasilyObtainExportedEntities() { | ||
| var instance = Instance.builder(loadModule("compiled/exports.wat.wasm")).build(); | ||
|
|
||
| assertNotNull(instance.exports().memory("mem").pages()); | ||
| assertNotNull(instance.exports().table("tab").size()); | ||
| assertNotNull(instance.exports().tag("tag").tagType()); | ||
| assertNotNull(instance.exports().global("glob1").getValue()); | ||
| instance.exports().memory("mem").pages(); | ||
| instance.exports().table("tab").size(); | ||
| instance.exports().tag("tag").tagType(); | ||
| instance.exports().global("glob1").getValue(); | ||
| assertNotNull(instance.exports().function("get-1").apply()); | ||
| } | ||
|
|
||
|
|
@@ -576,6 +576,7 @@ public void timeoutExecution() throws Exception { | |
| ExecutorService service = Executors.newSingleThreadExecutor(); | ||
| var future = service.submit(() -> function.apply()); | ||
| assertThrows(TimeoutException.class, () -> future.get(100, TimeUnit.MILLISECONDS)); | ||
| service.shutdown(); | ||
| } | ||
|
|
||
| // Testing tail call edge cases | ||
|
|
@@ -858,10 +859,7 @@ public void hostFunctionStackOverflowShouldBeWrapped() { | |
| }); | ||
| var instance = | ||
| Instance.builder(loadModule("compiled/host-function.wat.wasm")) | ||
| .withImportValues( | ||
| ImportValues.builder() | ||
| .addFunction(new HostFunction[] {func}) | ||
| .build()) | ||
| .withImportValues(ImportValues.builder().addFunction(func).build()) | ||
|
Comment on lines
-861
to
+862
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed the explicit |
||
| .build(); | ||
| var logIt = instance.export("logIt"); | ||
| var e = assertThrows(WasmEngineException.class, logIt::apply); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1376,13 +1376,9 @@ private static byte addSatU(byte a, byte b) { | |
| } | ||
| } | ||
|
|
||
| private static long addSatU(short a, Short b) { | ||
| private static long addSatU(short a, short b) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this boxing was unintentional? Side note: This
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Correct, thanks for fixing.
We haven't been using a lot of SIMD so far, that's an area that would benefit some love(hooking them up in the compiler/s etc.) if you are interested in a bigger challenge 🙂 . |
||
| int result = Short.toUnsignedInt(a) + Short.toUnsignedInt(b); | ||
| if (result >= 0xFFFF) { | ||
| return 0xFFFF; | ||
| } else { | ||
| return result; | ||
| } | ||
| return Math.min(result, 0xFFFF); | ||
| } | ||
|
|
||
| private static byte subSatS(byte a, byte b) { | ||
|
|
@@ -3000,7 +2996,7 @@ private static void I8x16_SWIZZLE(MStack stack) { | |
| long resultHigh = 0L; | ||
|
|
||
| for (int i = 0; i < 16; i++) { | ||
| long id = 0; | ||
| long id; | ||
| if (i < 8) { | ||
| id = (idxLow >> (i * 8)) & 0xFFL; | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,7 +143,7 @@ public CompilationUnit generate(String name, Wast wast, String wasmClasspath) { | |
| "store", | ||
| new NameExpr("new Store().addImportValues(Spectest.toImportValues())")); | ||
|
|
||
| String currentWasmFile = null; | ||
| String currentWasmFile; | ||
| for (var cmd : wast.commands()) { | ||
| switch (cmd.type()) { | ||
| case MODULE: | ||
|
|
@@ -428,7 +428,7 @@ private List<Expression> generateAssert(String varName, Command cmd, String modu | |
| .collect(Collectors.toList()) | ||
| : List.<String>of(); | ||
| var adaptedArgs = | ||
| (args == null || args.size() == 0) | ||
| args.isEmpty() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| ? "" | ||
| : args.stream().collect(Collectors.joining(").add(", ".add(", ")")); | ||
| invocationMethod = ".apply(ArgsAdapter.builder()" + adaptedArgs + ".build()" + ")"; | ||
|
|
@@ -601,11 +601,11 @@ private void generateAssertThrows( | |
|
|
||
| String wasmFile = getWasmFile(cmd, wasmClasspath); | ||
|
|
||
| var assignementStmt = (cmd.text() != null) ? "var exception = " : ""; | ||
| var assignmentStmt = (cmd.text() != null) ? "var exception = " : ""; | ||
|
|
||
| var assertThrows = | ||
| new NameExpr( | ||
| assignementStmt | ||
| assignmentStmt | ||
| + "assertThrows(" | ||
| + exceptionType | ||
| + ".class, () -> " | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,7 +134,7 @@ public NameExpr toAssertion(String resultVar, String moduleName) { | |
| if (value == null) { | ||
| // according to | ||
| // https://github.com/WebAssembly/spec/blob/05949f507908aac3ad2a21661b5c39fa013da950/interpreter/script/js.ml#L150 | ||
| // ref.func should check that its a function, and ref.extern should check the returned | ||
| // ref.func should check that it's a function, and ref.extern should check the returned | ||
| // reference is not null | ||
| switch (type) { | ||
| case FUNC_REF: | ||
|
|
@@ -285,14 +285,14 @@ public String shortLaneValue(String v) { | |
|
|
||
| public String intLaneValue(String v) { | ||
| var longValue = Long.parseLong(v); | ||
| return Integer.toUnsignedString((int) (0xFFFFFFFF & longValue)) + "L"; | ||
| return Integer.toUnsignedString((int) longValue) + "L"; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems this was redundant; Or should this be kept to make the intention explicit?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Direct casting seems correct to me, please add this fix 🙏 |
||
| } | ||
|
|
||
| /** | ||
| * Generate assertion for CallResult from applyWithRefs. | ||
| * | ||
| * Object ref types use cr.refResult(i) and compare with Java null/not-null. | ||
| * Numeric types use cr.longResult(i) and compare with expected values. | ||
| * <p>Object ref types use {@code cr.refResult(i)} and compare with Java null/not-null. | ||
| * Numeric types use {@code cr.longResult(i)} and compare with expected values. | ||
| */ | ||
| public NameExpr toRefAssertion(String resultVar, String moduleName) { | ||
| if (value == null) { | ||
|
|
@@ -392,7 +392,7 @@ public String toArgsValue() { | |
| case EQ_REF: | ||
| case I31_REF: | ||
| case FUNC_REF: | ||
| if (value[0].toString().equals("null")) { | ||
| if (value[0].equals("null")) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Was calling
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| return "Value.REF_NULL_VALUE"; | ||
| } | ||
| return value[0]; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| # test-gen-plugin | ||
|
|
||
| <internal-usage-only> | ||
| > [!WARNING] | ||
| > internal-usage-only | ||
|
|
||
| A maven plugin that handles the test generation that exercises both the wasm package and the runtime package. Tests are parsed from the [Wasm testsuite](https://github.com/WebAssembly/testsuite) and generate Java JUnit tests. | ||
| A Maven plugin that handles the test generation that exercises both the wasm package and the runtime package. Tests are parsed from the [Wasm testsuite](https://github.com/WebAssembly/testsuite) and generate Java JUnit tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Section did not exist anymore