Skip to content

Commit bc01bfd

Browse files
committed
Update GC.start to accept keyword arguments
1 parent e8550d9 commit bc01bfd

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Bug fixes:
4949
* Run `END` keyword block only once at exit.
5050
* Implement Numeric#clone method to return self.
5151
* Fixed `Symbol#to_proc` to create proc with nil `source_location` (#1663).
52+
* Make `GC.start` work with keyword arguments.
5253

5354
Compatibility:
5455

spec/ruby/core/gc/start_spec.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
GC.start.should == nil
66
GC.start.should == nil
77
end
8+
9+
it "accepts keyword arguments" do
10+
GC.start(full_mark: true, immediate_sweep: true).should == nil
11+
end
812
end

src/main/java/org/truffleruby/core/GCNodes.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,6 @@
2323
@CoreModule("GC")
2424
public abstract class GCNodes {
2525

26-
@CoreMethod(names = "start", onSingleton = true)
27-
public static abstract class GCStartNode extends CoreMethodArrayArgumentsNode {
28-
29-
@TruffleBoundary
30-
@Specialization
31-
protected DynamicObject vmGCStart() {
32-
getContext().getMarkingService().queueMarking();
33-
System.gc();
34-
return nil();
35-
}
36-
37-
}
38-
3926
@CoreMethod(names = "count", onSingleton = true)
4027
public abstract static class CountNode extends CoreMethodArrayArgumentsNode {
4128

src/main/java/org/truffleruby/core/VMPrimitiveNodes.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,19 @@ protected Object doCatch(Object tag, DynamicObject block,
103103
}
104104
}
105105

106+
@Primitive(name = "vm_gc_start")
107+
public static abstract class VMGCStartPrimitiveNode extends PrimitiveArrayArgumentsNode {
108+
109+
@TruffleBoundary
110+
@Specialization
111+
protected DynamicObject vmGCStart() {
112+
getContext().getMarkingService().queueMarking();
113+
System.gc();
114+
return nil();
115+
}
116+
117+
}
118+
106119
// The hard #exit!
107120
@Primitive(name = "vm_exit", lowerFixnum = 0)
108121
public static abstract class VMExitNode extends PrimitiveArrayArgumentsNode {

src/main/ruby/truffleruby/core/gc.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def self.run(force)
3939
start
4040
end
4141

42+
def self.start(full_mark: true, immediate_sweep: true)
43+
TrufflePrimitive.vm_gc_start()
44+
end
45+
4246
# Totally fake.
4347
def self.stress
4448
@stress_level ||= false

0 commit comments

Comments
 (0)