5656import com .oracle .truffle .api .profiles .ConditionProfile ;
5757import com .oracle .truffle .js .nodes .JavaScriptNode ;
5858import com .oracle .truffle .js .nodes .binary .JSAddNode ;
59- import com .oracle .truffle .js .nodes .binary .JSBinaryNode ;
6059import com .oracle .truffle .js .nodes .binary .JSSubtractNode ;
6160import com .oracle .truffle .js .nodes .cast .JSToNumericNode ;
6261import com .oracle .truffle .js .nodes .instrumentation .JSTags .ReadVariableTag ;
6362import com .oracle .truffle .js .nodes .instrumentation .JSTags .WriteVariableTag ;
64- import com .oracle .truffle .js .nodes .unary .JSUnaryNode ;
6563import com .oracle .truffle .js .runtime .BigInt ;
6664import com .oracle .truffle .js .runtime .JSRuntime ;
6765import com .oracle .truffle .js .runtime .SafeInteger ;
@@ -203,18 +201,8 @@ abstract class LocalVarOpMaterializedNode extends LocalVarIncNode {
203201 super (from .op , from .frameSlot , from .hasTemporalDeadZone , from .scopeFrameNode );
204202
205203 JavaScriptNode readOld = JSReadFrameSlotNode .create (frameSlot , scopeFrameNode , hasTemporalDeadZone );
206- JavaScriptNode convert = JSToNumericNode .create (readOld );
207- if (materializedTags != null ) {
208- // need to force materialization, because the convert node might not have source section
209- // at this point
210- JavaScriptNode materializedConvertNode = (JavaScriptNode ) convert .materializeInstrumentableNodes (materializedTags );
211- if (convert == materializedConvertNode ) {
212- convert = cloneUninitialized (convert , materializedTags );
213- } else {
214- convert = materializedConvertNode ;
215- }
216- }
217- convertOld = JSWriteFrameSlotNode .create (frameSlot , scopeFrameNode , convert , hasTemporalDeadZone );
204+ JavaScriptNode convert = (JavaScriptNode ) JSToNumericNode .create (readOld ).materializeInstrumentableNodes (materializedTags );
205+ convertOld = cloneUninitialized (JSWriteFrameSlotNode .create (frameSlot , scopeFrameNode , convert , hasTemporalDeadZone ), materializedTags );
218206
219207 JavaScriptNode readTmp = JSReadFrameSlotNode .create (frameSlot , scopeFrameNode , hasTemporalDeadZone );
220208 JavaScriptNode one = JSConstantNode .createInt (1 );
@@ -224,26 +212,15 @@ abstract class LocalVarOpMaterializedNode extends LocalVarIncNode {
224212 } else {
225213 opNode = JSAddNode .create (readTmp , one );
226214 }
227- if (materializedTags != null ) {
228- // need to force materialization, because the convert node might not have source section
229- // at this point
230- JavaScriptNode materializedOpNode = (JavaScriptNode ) opNode .materializeInstrumentableNodes (materializedTags );
231- if (opNode == materializedOpNode ) {
232- opNode = cloneUninitialized (opNode , materializedTags );
233- } else {
234- opNode = materializedOpNode ;
235- }
236- }
237- this .writeNew = JSWriteFrameSlotNode .create (frameSlot , scopeFrameNode , opNode , hasTemporalDeadZone );
238- // The readTmp and one nodes are no longer valid, they have been cloned
239- if (opNode instanceof JSBinaryNode ) {
240- transferSourceSectionAddExpressionTag (from , ((JSBinaryNode ) opNode ).getLeft ());
241- transferSourceSectionAddExpressionTag (from , ((JSBinaryNode ) opNode ).getRight ());
242- } else if (opNode instanceof JSUnaryNode ) {
243- transferSourceSectionAddExpressionTag (from , ((JSUnaryNode ) opNode ).getOperand ());
244- }
245- transferSourceSectionAddExpressionTag (from , writeNew );
215+ /*
216+ * Have to transfer source sections before cloning and materialization. Some nodes might
217+ * become instrumentable by this operation.
218+ */
219+ transferSourceSectionAddExpressionTag (from , readTmp );
220+ transferSourceSectionAddExpressionTag (from , one );
246221 transferSourceSectionAddExpressionTag (from , opNode );
222+ this .writeNew = cloneUninitialized (JSWriteFrameSlotNode .create (frameSlot , scopeFrameNode , opNode , hasTemporalDeadZone ), materializedTags );
223+ transferSourceSectionAddExpressionTag (from , writeNew );
247224 transferSourceSectionAndTags (from , this );
248225 }
249226
0 commit comments