@@ -1516,8 +1516,11 @@ public static SixModelObject setwho(SixModelObject o, SixModelObject who, Thread
1516
1516
public static SixModelObject rebless (SixModelObject obj , SixModelObject newType , ThreadContext tc ) {
1517
1517
obj = decont (obj , tc );
1518
1518
newType = decont (newType , tc );
1519
- if (obj .st != newType .st )
1519
+ if (obj .st != newType .st ) {
1520
1520
obj .st .REPR .change_type (tc , obj , newType );
1521
+ if (obj .sc != null )
1522
+ scwbObject (tc , obj );
1523
+ }
1521
1524
return obj ;
1522
1525
}
1523
1526
public static SixModelObject create (SixModelObject obj , ThreadContext tc ) {
@@ -1630,13 +1633,17 @@ public static SixModelObject setmethcache(SixModelObject obj, SixModelObject met
1630
1633
cache .put (iterkey_s (cur , tc ), iterval (cur , tc ));
1631
1634
}
1632
1635
obj .st .MethodCache = cache ;
1636
+ if (obj .st .sc != null )
1637
+ scwbSTable (tc , obj .st );
1633
1638
return obj ;
1634
1639
}
1635
1640
public static SixModelObject setmethcacheauth (SixModelObject obj , long flag , ThreadContext tc ) {
1636
1641
int newFlags = obj .st .ModeFlags & (~STable .METHOD_CACHE_AUTHORITATIVE );
1637
1642
if (flag != 0 )
1638
1643
newFlags = newFlags | STable .METHOD_CACHE_AUTHORITATIVE ;
1639
1644
obj .st .ModeFlags = newFlags ;
1645
+ if (obj .st .sc != null )
1646
+ scwbSTable (tc , obj .st );
1640
1647
return obj ;
1641
1648
}
1642
1649
public static SixModelObject settypecache (SixModelObject obj , SixModelObject types , ThreadContext tc ) {
@@ -1645,11 +1652,15 @@ public static SixModelObject settypecache(SixModelObject obj, SixModelObject typ
1645
1652
for (long i = 0 ; i < elems ; i ++)
1646
1653
cache [(int )i ] = types .at_pos_boxed (tc , i );
1647
1654
obj .st .TypeCheckCache = cache ;
1655
+ if (obj .st .sc != null )
1656
+ scwbSTable (tc , obj .st );
1648
1657
return obj ;
1649
1658
}
1650
1659
public static SixModelObject settypecheckmode (SixModelObject obj , long mode , ThreadContext tc ) {
1651
1660
obj .st .ModeFlags = (int )mode |
1652
1661
(obj .st .ModeFlags & (~STable .TYPE_CHECK_CACHE_FLAG_MASK ));
1662
+ if (obj .st .sc != null )
1663
+ scwbSTable (tc , obj .st );
1653
1664
return obj ;
1654
1665
}
1655
1666
public static long objprimspec (SixModelObject obj , ThreadContext tc ) {
@@ -1781,27 +1792,35 @@ public static String getattr_s(SixModelObject obj, SixModelObject ch, String nam
1781
1792
}
1782
1793
public static SixModelObject bindattr (SixModelObject obj , SixModelObject ch , String name , SixModelObject value , ThreadContext tc ) {
1783
1794
obj .bind_attribute_boxed (tc , decont (ch , tc ), name , STable .NO_HINT , value );
1795
+ if (obj .sc != null )
1796
+ scwbObject (tc , obj );
1784
1797
return value ;
1785
1798
}
1786
1799
public static long bindattr_i (SixModelObject obj , SixModelObject ch , String name , long value , ThreadContext tc ) {
1787
1800
tc .native_i = value ;
1788
1801
obj .bind_attribute_native (tc , decont (ch , tc ), name , STable .NO_HINT );
1789
1802
if (tc .native_type != ThreadContext .NATIVE_INT )
1790
1803
throw ExceptionHandling .dieInternal (tc , "Attribute '" + name + "' is not a native int" );
1804
+ if (obj .sc != null )
1805
+ scwbObject (tc , obj );
1791
1806
return value ;
1792
1807
}
1793
1808
public static double bindattr_n (SixModelObject obj , SixModelObject ch , String name , double value , ThreadContext tc ) {
1794
1809
tc .native_n = value ;
1795
1810
obj .bind_attribute_native (tc , decont (ch , tc ), name , STable .NO_HINT );
1796
1811
if (tc .native_type != ThreadContext .NATIVE_NUM )
1797
1812
throw ExceptionHandling .dieInternal (tc , "Attribute '" + name + "' is not a native num" );
1813
+ if (obj .sc != null )
1814
+ scwbObject (tc , obj );
1798
1815
return value ;
1799
1816
}
1800
1817
public static String bindattr_s (SixModelObject obj , SixModelObject ch , String name , String value , ThreadContext tc ) {
1801
1818
tc .native_s = value ;
1802
1819
obj .bind_attribute_native (tc , decont (ch , tc ), name , STable .NO_HINT );
1803
1820
if (tc .native_type != ThreadContext .NATIVE_STR )
1804
1821
throw ExceptionHandling .dieInternal (tc , "Attribute '" + name + "' is not a native str" );
1822
+ if (obj .sc != null )
1823
+ scwbObject (tc , obj );
1805
1824
return value ;
1806
1825
}
1807
1826
public static long attrinited (SixModelObject obj , SixModelObject ch , String name , ThreadContext tc ) {
@@ -2828,6 +2847,29 @@ public static SixModelObject popcompsc(ThreadContext tc) {
2828
2847
tc .compilingSCs = null ;
2829
2848
return result ;
2830
2849
}
2850
+
2851
+ /* SC write barriers (not really ops, but putting them here with the SC
2852
+ * related bits). */
2853
+ public static void scwbObject (ThreadContext tc , SixModelObject obj ) {
2854
+ int cscSize = tc .compilingSCs == null ? 0 : tc .compilingSCs .size ();
2855
+ if (cscSize == 0 || tc .scwbDisableDepth > 0 )
2856
+ return ;
2857
+ SerializationContext compSC = tc .compilingSCs .get (cscSize - 1 ).referencedSC ;
2858
+ if (obj .sc != compSC ) {
2859
+ compSC .repossessObject (obj .sc , obj );
2860
+ obj .sc = compSC ;
2861
+ }
2862
+ }
2863
+ public static void scwbSTable (ThreadContext tc , STable st ) {
2864
+ int cscSize = tc .compilingSCs == null ? 0 : tc .compilingSCs .size ();
2865
+ if (cscSize == 0 || tc .scwbDisableDepth > 0 )
2866
+ return ;
2867
+ SerializationContext compSC = tc .compilingSCs .get (cscSize - 1 ).referencedSC ;
2868
+ if (st .sc != compSC ) {
2869
+ compSC .repossessSTable (st .sc , st );
2870
+ st .sc = compSC ;
2871
+ }
2872
+ }
2831
2873
2832
2874
/* bitwise operations. */
2833
2875
public static long bitor_i (long valA , long valB ) {
0 commit comments