50
50
import com .oracle .truffle .api .library .ExportMessage ;
51
51
import com .oracle .truffle .api .nodes .Node ;
52
52
import com .oracle .truffle .api .object .Shape ;
53
+ import com .oracle .truffle .api .profiles .InlinedBranchProfile ;
53
54
import com .oracle .truffle .api .source .SourceSection ;
54
55
55
56
@ SuppressWarnings ("truffle-abstract-export" )
@@ -115,7 +116,7 @@ public boolean hasSourceLocation() {
115
116
116
117
@ ExportMessage
117
118
public boolean isArrayElementModifiable (long index ,
118
- @ Cached . Exclusive @ Cached IndexNodes .NormalizeIndexCustomMessageNode normalize ,
119
+ @ Exclusive @ Cached IndexNodes .NormalizeIndexCustomMessageNode normalize ,
119
120
@ Exclusive @ Cached GilNode gil ) {
120
121
boolean mustRelease = gil .acquire ();
121
122
try {
@@ -145,7 +146,7 @@ public boolean isArrayElementInsertable(long index,
145
146
146
147
@ ExportMessage
147
148
public boolean isArrayElementRemovable (long index ,
148
- @ Cached . Exclusive @ Cached IndexNodes .NormalizeIndexCustomMessageNode normalize ,
149
+ @ Exclusive @ Cached IndexNodes .NormalizeIndexCustomMessageNode normalize ,
149
150
@ Exclusive @ Cached GilNode gil ) {
150
151
boolean mustRelease = gil .acquire ();
151
152
try {
@@ -165,17 +166,24 @@ public boolean isArrayElementRemovable(long index,
165
166
public void writeArrayElement (long index , Object value ,
166
167
@ Bind ("$node" ) Node inliningTarget ,
167
168
@ Cached PForeignToPTypeNode convert ,
168
- @ Cached . Exclusive @ Cached SequenceStorageNodes .SetItemScalarNode setItem ,
169
+ @ Exclusive @ Cached SequenceStorageNodes .SetItemScalarGeneralizingNode setItem ,
169
170
@ Cached SequenceStorageNodes .AppendNode appendNode ,
171
+ @ Cached InlinedBranchProfile generalizedProfile ,
170
172
@ Exclusive @ Cached GilNode gil ) throws InvalidArrayIndexException {
171
173
boolean mustRelease = gil .acquire ();
172
174
try {
173
175
final int len = store .length ();
176
+ value = convert .executeConvert (value );
174
177
try {
178
+ SequenceStorage newStorage ;
175
179
if (index == len ) {
176
- appendNode .execute (inliningTarget , store , convert . executeConvert ( value ) , SequenceStorageNodes .ListGeneralizationNode .SUPPLIER );
180
+ newStorage = appendNode .execute (inliningTarget , store , value , SequenceStorageNodes .ListGeneralizationNode .SUPPLIER );
177
181
} else {
178
- setItem .execute (inliningTarget , store , PInt .intValueExact (index ), convert .executeConvert (value ));
182
+ newStorage = setItem .execute (inliningTarget , store , PInt .intValueExact (index ), value , SequenceStorageNodes .ListGeneralizationNode .SUPPLIER );
183
+ }
184
+ if (newStorage != store ) {
185
+ generalizedProfile .enter (inliningTarget );
186
+ store = newStorage ;
179
187
}
180
188
} catch (OverflowException e ) {
181
189
CompilerDirectives .transferToInterpreterAndInvalidate ();
0 commit comments