Skip to content

Commit

Permalink
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/truffle/compiler/pe/pe.rb
Original file line number Diff line number Diff line change
@@ -110,6 +110,8 @@ def report(status, code, message = nil)
puts message ? format(format_str + "\n %s", status, code, message) : format('%14s: %s', status, code)
end

Truffle::Globals.permanently_invalidate :$value

EXAMPLES.each do |example|
next if example.tagged

4 changes: 4 additions & 0 deletions truffle/src/main/java/org/jruby/truffle/core/CoreLibrary.java
Original file line number Diff line number Diff line change
@@ -107,6 +107,8 @@
import org.jruby.truffle.language.control.TruffleFatalException;
import org.jruby.truffle.language.globals.GlobalVariableStorage;
import org.jruby.truffle.language.globals.GlobalVariables;
import org.jruby.truffle.language.globals.TruffleGlobalsNodes;
import org.jruby.truffle.language.globals.TruffleGlobalsNodesFactory;
import org.jruby.truffle.language.loader.CodeLoader;
import org.jruby.truffle.language.loader.SourceLoader;
import org.jruby.truffle.language.methods.DeclarationContext;
@@ -620,6 +622,7 @@ public CoreLibrary(RubyContext context) {
defineModule(truffleModule, "Process");
defineModule(truffleModule, "Binding");
defineModule(truffleModule, "POSIX");
defineModule(truffleModule, "Globals");
psychModule = defineModule("Psych");
psychParserClass = defineClass(psychModule, objectClass, "Parser");
final DynamicObject psychHandlerClass = defineClass(psychModule, objectClass, "Handler");
@@ -842,6 +845,7 @@ public void addCoreMethods() {
coreMethodNodeManager.addCoreMethodNodes(TruffleBindingNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleArrayNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleStringNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(TruffleGlobalsNodesFactory.getFactories());
coreMethodNodeManager.addCoreMethodNodes(BCryptNodesFactory.getFactories());
return null;
}));
Original file line number Diff line number Diff line change
@@ -66,4 +66,9 @@ public void setValue(Object value) {
}
}

public void permanentlyInvalidate() {
changes = Integer.MAX_VALUE;
unchangedAssumption.invalidate();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright (c) 2013, 2016 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
* Eclipse Public License version 1.0
* GNU General Public License version 2
* GNU Lesser General Public License version 2.1
*/
package org.jruby.truffle.language.globals;

import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
import com.oracle.truffle.api.dsl.Specialization;
import com.oracle.truffle.api.object.DynamicObject;
import org.jruby.truffle.builtins.CoreClass;
import org.jruby.truffle.builtins.CoreMethod;
import org.jruby.truffle.builtins.CoreMethodArrayArgumentsNode;

@CoreClass("Truffle::Globals")
public abstract class TruffleGlobalsNodes {

@CoreMethod(names = "permanently_invalidate", onSingleton = true, required = 1)
public abstract static class PermanentlyInvalidateNode extends CoreMethodArrayArgumentsNode {

@TruffleBoundary
@Specialization(guards = "isRubySymbol(name)")
public DynamicObject permanentlyInvalidate(DynamicObject name) {
getContext().getCoreLibrary().getGlobalVariables().getStorage(name.toString()).permanentlyInvalidate();
return nil();
}

}

}

3 comments on commit 4642476

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eregon
Copy link
Member

@eregon eregon commented on 4642476 Jun 27, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about just not using a global to capture the result but the method return value?

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... not sure why I didn't do that originally.

Please sign in to comment.