Skip to content

Commit

Permalink
[GR-11805] Don't use Object.equals for Class, correct ordering of equ…
Browse files Browse the repository at this point in the history
…als on constants.

PullRequest: graal/2191
  • Loading branch information
lukasstadler committed Sep 26, 2018
2 parents 5b33148 + 1c87ec4 commit 012b224
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ private void parseArguments() {
int end = source.lastIndexOf('}');
if (start != -1 && end != -1) {
registerName = source.substring(start + 1, end);
} else if (source.equals(CONSTRAINT_REG) || source.equals(CONSTRAINT_REG_L)) {
} else if (CONSTRAINT_REG.equals(source) || CONSTRAINT_REG_L.equals(source)) {
registerName = TEMP_REGISTER_PREFIX + argInfo.size();
isAnonymous = true;
} else if (source.length() == 1 && Character.isDigit(source.charAt(0))) {
Expand Down Expand Up @@ -1877,7 +1877,7 @@ private LLVMExpressionNode getOperandAddress(Type type, AsmOperand operand) {
AsmOperand offset = op.getOffset();
int shift = op.getShift();
LLVMExpressionNode baseAddress;
assert op.getSegment() == null || op.getSegment().equals("%fs");
assert op.getSegment() == null || "%fs".equals(op.getSegment());
LLVMExpressionNode segment = null;
if (op.getSegment() != null) {
segment = new LLVMAMD64GetTlsNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class LLVMInfo {
sysname = System.getProperty("os.name");
release = System.getProperty("os.version");
String arch = System.getProperty("os.arch");
if (arch.equals("amd64")) {
if ("amd64".equals(arch)) {
arch = "x86_64";
}
machine = arch;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public LLVMArithmetic execute(LLVMArithmetic x, LLVMArithmetic y,
}

LLVMArithmeticOpNode createNode(Object x, Object y) {
if (x instanceof LLVMArithmetic && x.getClass().equals(y.getClass())) {
if (x instanceof LLVMArithmetic && x.getClass() == y.getClass()) {
return ((LLVMArithmetic) x).createAddNode();
} else {
throw new AssertionError("unsupported operand types: " + x.getClass() + ", " + y.getClass());
Expand All @@ -106,7 +106,7 @@ public LLVMArithmetic execute(LLVMArithmetic x, LLVMArithmetic y,
}

LLVMArithmeticOpNode createNode(Object x, Object y) {
if (x instanceof LLVMArithmetic && x.getClass().equals(y.getClass())) {
if (x instanceof LLVMArithmetic && x.getClass() == y.getClass()) {
return ((LLVMArithmetic) x).createSubNode();
} else {
throw new AssertionError("unsupported operand types: " + x.getClass() + ", " + y.getClass());
Expand All @@ -132,7 +132,7 @@ public LLVMArithmetic execute(LLVMArithmetic x, LLVMArithmetic y,
}

LLVMArithmeticOpNode createNode(Object x, Object y) {
if (x instanceof LLVMArithmetic && x.getClass().equals(y.getClass())) {
if (x instanceof LLVMArithmetic && x.getClass() == y.getClass()) {
return ((LLVMArithmetic) x).createMulNode();
} else {
throw new AssertionError("unsupported operand types: " + x.getClass() + ", " + y.getClass());
Expand All @@ -158,7 +158,7 @@ public LLVMArithmetic execute(LLVMArithmetic x, LLVMArithmetic y,
}

LLVMArithmeticOpNode createNode(Object x, Object y) {
if (x instanceof LLVMArithmetic && x.getClass().equals(y.getClass())) {
if (x instanceof LLVMArithmetic && x.getClass() == y.getClass()) {
return ((LLVMArithmetic) x).createDivNode();
} else {
throw new AssertionError("unsupported operand types: " + x.getClass() + ", " + y.getClass());
Expand All @@ -184,7 +184,7 @@ public LLVMArithmetic execute(LLVMArithmetic x, LLVMArithmetic y,
}

LLVMArithmeticOpNode createNode(Object x, Object y) {
if (x instanceof LLVMArithmetic && x.getClass().equals(y.getClass())) {
if (x instanceof LLVMArithmetic && x.getClass() == y.getClass()) {
return ((LLVMArithmetic) x).createRemNode();
} else {
throw new AssertionError("unsupported operand types: " + x.getClass() + ", " + y.getClass());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected LLVMPointer doPointer(LLVMPointer value) {
if (localState != GENERIC) {
if (localState == SPECIALIZED_POINTER) {
LLVMPointer v = cachedPointer;
if (value.equals(v)) {
if (v.equals(value)) {
return v.export(value.getExportType());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public List<String> getDTRPath() {

private static ElfSectionHeaderTable.Entry getDynamiSHEntry(ElfSectionHeaderTable sht) {
for (ElfSectionHeaderTable.Entry e : sht.getEntries()) {
if (e.getName(sht).equals(".dynamic")) {
if (".dynamic".equals(e.getName(sht))) {
return e;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BigInteger getValue() {
@Override
public String toString() {
if (getType().getBitSize() == 1) {
return value.equals(BigInteger.ZERO) ? "false" : "true";
return BigInteger.ZERO.equals(value) ? "false" : "true";
}
return value.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ public LLVM80BitFloat abs() {
}

public boolean isPositiveInfinity() {
return this.equals(POSITIVE_INFINITY);
return POSITIVE_INFINITY.equals(this);
}

public boolean isNegativeInfinity() {
return equals(NEGATIVE_INFINITY);
return NEGATIVE_INFINITY.equals(this);
}

public boolean isInfinity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,14 @@ public static boolean isTrue(String option) {

public static List<String> getPolyglotOptionSearchPaths(TruffleLanguage.Env env) {
String libraryPathOption = env.getOptions().get(LIBRARY_PATH);
String[] libraryPath = libraryPathOption.equals("") ? new String[0] : libraryPathOption.split(OPTION_ARRAY_SEPARATOR);
String[] libraryPath = "".equals(libraryPathOption) ? new String[0] : libraryPathOption.split(OPTION_ARRAY_SEPARATOR);
return Arrays.asList(libraryPath);
}

public static List<String> getPolyglotOptionExternalLibraries(TruffleLanguage.Env env) {
CompilerAsserts.neverPartOfCompilation();
String librariesOption = env.getOptions().get(LIBRARIES);
String[] userLibraries = librariesOption.equals("") ? new String[0] : librariesOption.split(OPTION_ARRAY_SEPARATOR);
String[] userLibraries = "".equals(librariesOption) ? new String[0] : librariesOption.split(OPTION_ARRAY_SEPARATOR);
return Arrays.asList(userLibraries);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public List<ContextExtension> createContextExtensions(LLVMContext context) {
@Override
@SuppressWarnings("deprecation")
public <E> E getCapability(Class<E> type) {
if (type.equals(LLVMMemory.class)) {
if (type == LLVMMemory.class) {
return type.cast(LLVMNativeMemory.getInstance());
} else if (type.equals(UnsafeArrayAccess.class)) {
} else if (type == UnsafeArrayAccess.class) {
return type.cast(UnsafeArrayAccess.getInstance());
}
return null;
Expand Down

0 comments on commit 012b224

Please sign in to comment.