Skip to content
Snippets Groups Projects
Commit e4b2360a authored by Lukas Stadler's avatar Lukas Stadler
Browse files

[GR-2737] Optimized bit ops for GP bits.

parents 806422cb a73021ef
No related branches found
No related tags found
No related merge requests found
/*
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
......@@ -48,16 +48,16 @@ abstract class RBaseObject implements RTypedValue {
@Override
public final boolean isS4() {
return (getGPBits() & S4_MASK) == S4_MASK;
return (getTypedValueInfo() & S4_MASK_SHIFTED) != 0;
}
@Override
public final void setS4() {
setGPBits(getGPBits() | S4_MASK);
setTypedValueInfo(getTypedValueInfo() | S4_MASK_SHIFTED);
}
@Override
public final void unsetS4() {
setGPBits(getGPBits() & ~S4_MASK);
setTypedValueInfo(getTypedValueInfo() & ~S4_MASK_SHIFTED);
}
}
......@@ -27,6 +27,8 @@ public interface RTypedValue extends RTruffleObject {
int GP_BITS_MASK_SHIFT = 8;
int GP_BITS_MASK = 0xFFFF << GP_BITS_MASK_SHIFT;
int S4_MASK_SHIFTED = 1 << (4 + GP_BITS_MASK_SHIFT);
RType getRType();
int getTypedValueInfo();
......@@ -42,14 +44,14 @@ public interface RTypedValue extends RTruffleObject {
}
default boolean isS4() {
return (getGPBits() & S4_MASK) == S4_MASK;
return (getTypedValueInfo() & S4_MASK_SHIFTED) != 0;
}
default void setS4() {
setGPBits(getGPBits() | S4_MASK);
setTypedValueInfo(getTypedValueInfo() | S4_MASK_SHIFTED);
}
default void unsetS4() {
setGPBits(getGPBits() & ~S4_MASK);
setTypedValueInfo(getTypedValueInfo() & ~S4_MASK_SHIFTED);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment