Skip to content

Commit eef9dc3

Browse files
committed
Remove outdated, and now unnecessary, SVM-specific parse operations.
1 parent ed796f7 commit eef9dc3

File tree

2 files changed

+3
-38
lines changed

2 files changed

+3
-38
lines changed

src/main/java/org/truffleruby/RubyContext.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@
8989

9090
public class RubyContext {
9191

92-
public static RubyContext FIRST_INSTANCE = null;
93-
9492
private final RubyLanguage language;
9593
@CompilationFinal private TruffleLanguage.Env env;
9694

@@ -156,10 +154,6 @@ public class RubyContext {
156154
public RubyContext(RubyLanguage language, TruffleLanguage.Env env) {
157155
Metrics.printTime("before-context-constructor");
158156

159-
if (FIRST_INSTANCE == null) {
160-
FIRST_INSTANCE = this;
161-
}
162-
163157
this.preInitializing = preInitializeContexts;
164158
RubyContext.preInitializeContexts = false; // Only the first context is pre-initialized
165159
this.preInitialized = preInitializing;

src/main/java/org/truffleruby/parser/parser/ParserRopeOperations.java

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,48 +10,19 @@
1010
package org.truffleruby.parser.parser;
1111

1212
import com.oracle.truffle.api.CompilerDirectives;
13-
import com.oracle.truffle.api.TruffleOptions;
1413
import org.jcodings.Encoding;
15-
import org.truffleruby.RubyContext;
1614
import org.truffleruby.core.rope.Rope;
1715
import org.truffleruby.core.rope.RopeNodes;
18-
import org.truffleruby.core.rope.RopeOperations;
1916
import org.truffleruby.language.RubyBaseNode;
20-
import java.util.Arrays;
21-
import static org.truffleruby.core.rope.CodeRange.CR_7BIT;
22-
import static org.truffleruby.core.rope.CodeRange.CR_UNKNOWN;
2317

2418
public class ParserRopeOperations {
2519

2620
public Rope withEncoding(Rope rope, Encoding encoding) {
27-
if (isBuildingNativeImage()) {
28-
if (rope.isAsciiOnly() && encoding.isAsciiCompatible()) {
29-
return rope.withEncoding(encoding, CR_7BIT);
30-
}
31-
32-
return RopeOperations.create(rope.getBytes(), encoding, CR_UNKNOWN);
33-
} else {
34-
return ropeNode.getWithEncodingNode().executeWithEncoding(rope, encoding);
35-
}
21+
return ropeNode.getWithEncodingNode().executeWithEncoding(rope, encoding);
3622
}
3723

3824
public Rope makeShared(Rope rope, int sharedStart, int sharedLength) {
39-
if (isBuildingNativeImage()) {
40-
if (sharedLength == rope.byteLength()) {
41-
return rope;
42-
}
43-
44-
return RopeOperations.create(Arrays.copyOfRange(rope.getBytes(), sharedStart, sharedStart + sharedLength), rope.getEncoding(), rope.isAsciiOnly() ? CR_7BIT : CR_UNKNOWN);
45-
} else {
46-
return ropeNode.getSubstringNode().executeSubstring(rope, sharedStart, sharedLength);
47-
}
48-
}
49-
50-
private static boolean isBuildingNativeImage() {
51-
// We can't use a detached RopeNode during image construction because it trips up the static analysis, but
52-
// we can use it at runtime. We check if a context has been created as a proxy for whether we're in the native
53-
// image builder or running at runtime.
54-
return TruffleOptions.AOT && RubyContext.FIRST_INSTANCE == null;
25+
return ropeNode.getSubstringNode().executeSubstring(rope, sharedStart, sharedLength);
5526
}
5627

5728
private static class RopeNode extends RubyBaseNode {
@@ -79,6 +50,6 @@ public RopeNodes.WithEncodingNode getWithEncodingNode() {
7950

8051
}
8152

82-
private final RopeNode ropeNode = isBuildingNativeImage() ? null : new RopeNode();
53+
private final RopeNode ropeNode = new RopeNode();
8354

8455
}

0 commit comments

Comments
 (0)