diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RBaseObject.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RBaseObject.java
index 20681ec6eb703962e8ad4df2cd5e1b5d7c4b12fd..52e181b7b495afc5e697ff40bff8347e407e17ff 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RBaseObject.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RBaseObject.java
@@ -1,5 +1,5 @@
 /*
- * 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);
     }
 }
diff --git a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RTypedValue.java b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RTypedValue.java
index 153949e45e9d8ed54ec4614f4b6e9e51ffed9155..66a09ba04184c303325de0635064333a2497634e 100644
--- a/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RTypedValue.java
+++ b/com.oracle.truffle.r.runtime/src/com/oracle/truffle/r/runtime/data/RTypedValue.java
@@ -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);
     }
 }