<commit_before>package org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.nodes;

import org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.FrameAddr;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.layouts.FrameLayoutImpl;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.Occurrence;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.NativeOpBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.TermBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.ReductionFailure;
import org.metaborg.meta.lang.dynsem.interpreter.utils.InterpreterUtils;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;

@NodeChildren({ @NodeChild(value = "frm", type = TermBuild.class), @NodeChild(value = "dec", type = TermBuild.class) })
public abstract class NewFrameAddr extends NativeOpBuild {

	public NewFrameAddr(SourceSection source) {
		super(source);
	}

	@Specialization(guards = { "dec == dec_cached", "shapeCheck(shape, frm)" }, assumptions = {
			"shape.getValidAssumption()" })
	public FrameAddr createCached(DynamicObject frm, Occurrence dec, @Cached("dec") Occurrence dec_cached,
			@Cached("lookupShape(frm)") Shape shape, @Cached("lookupLocation(shape, dec)") Location loc) {
		return new FrameAddr(frm, loc);
	}

	@Specialization(replaces = "createCached", guards = "frm.getShape().isValid()")
	public FrameAddr createUncached(DynamicObject frm, Occurrence dec) {
		return new FrameAddr(frm, frm.getShape().getProperty(dec).getLocation());
	}

	protected Shape lookupShape(DynamicObject frm) {
		CompilerAsserts.neverPartOfCompilation();
		assert FrameLayoutImpl.INSTANCE.isFrame(frm);
		return frm.getShape();
	}
<commit_msg>Removes shape validity assumption (the shape of a frame should NEVER change)<commit_after>package org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.nodes;

import org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.FrameAddr;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.f.layouts.FrameLayoutImpl;
import org.metaborg.meta.lang.dynsem.interpreter.nabl2.sg.Occurrence;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.NativeOpBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.building.TermBuild;
import org.metaborg.meta.lang.dynsem.interpreter.nodes.rules.ReductionFailure;
import org.metaborg.meta.lang.dynsem.interpreter.utils.InterpreterUtils;

import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.dsl.Cached;
import com.oracle.truffle.api.dsl.NodeChild;
import com.oracle.truffle.api.dsl.NodeChildren;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import com.oracle.truffle.api.object.Location;
import com.oracle.truffle.api.object.Property;
import com.oracle.truffle.api.object.Shape;
import com.oracle.truffle.api.source.SourceSection;

@NodeChildren({ @NodeChild(value = "frm", type = TermBuild.class), @NodeChild(value = "dec", type = TermBuild.class) })
public abstract class NewFrameAddr extends NativeOpBuild {

	public NewFrameAddr(SourceSection source) {
		super(source);
	}

	@Specialization(guards = { "dec == dec_cached", "shapeCheck(shape, frm)" })
	public FrameAddr createCached(DynamicObject frm, Occurrence dec, @Cached("dec") Occurrence dec_cached,
			@Cached("lookupShape(frm)") Shape shape, @Cached("lookupLocation(shape, dec)") Location loc) {
		return new FrameAddr(frm, loc);
	}

	@Specialization(replaces = "createCached", guards = "frm.getShape().isValid()")
	public FrameAddr createUncached(DynamicObject frm, Occurrence dec) {
		return new FrameAddr(frm, frm.getShape().getProperty(dec).getLocation());
	}

	protected Shape lookupShape(DynamicObject frm) {
		CompilerAsserts.neverPartOfCompilation();
		assert FrameLayoutImpl.INSTANCE.isFrame(frm);
		return frm.getShape();
	}

{'fraction_non_alphanumeric': 0.12783553875236295, 'fraction_numerical': 0.001890359168241966, 'mean_word_length': 6.310880829015544, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2411469', 'n_tokens_mistral': 1457, 'n_tokens_neox': 1441, 'n_words': 219}