Skip to content

Commit e26c54f

Browse files
committed
Merge remote-tracking branch 'origin/master' into truffle-head
2 parents e13ed00 + 6ab4b4a commit e26c54f

File tree

18 files changed

+319
-41
lines changed

18 files changed

+319
-41
lines changed

lib/pom.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ def to_pathname
8686
end
8787
end
8888

89-
gem 'ruby-maven', '3.3.0', :scope => :provided
90-
gem 'ruby-maven-libs', '3.3.3', :scope => :provided
89+
gem 'ruby-maven', '3.3.2', :scope => :provided
9190

9291
default_gemnames = default_gems.collect { |g| g.name }
9392

lib/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -157,14 +157,7 @@
157157
<dependency>
158158
<groupId>rubygems</groupId>
159159
<artifactId>ruby-maven</artifactId>
160-
<version>3.3.0</version>
161-
<type>gem</type>
162-
<scope>provided</scope>
163-
</dependency>
164-
<dependency>
165-
<groupId>rubygems</groupId>
166-
<artifactId>ruby-maven-libs</artifactId>
167-
<version>3.3.3</version>
160+
<version>3.3.2</version>
168161
<type>gem</type>
169162
<scope>provided</scope>
170163
</dependency>

maven/jruby-dist/pom.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
'jruby.plugins.version' => '1.0.9', # Not sure why but wo this pom.xml get 1.0.8
1313
'main.basedir' => '${project.parent.parent.basedir}' )
1414

15-
# pre-installed gems - not default gems !
16-
gem 'ruby-maven', '3.1.1.0.11', :scope => 'provided'
15+
# pre-installed gems - not yet default gems !
16+
gem 'ruby-maven', '3.3.2', :scope => 'provided'
1717

1818
# HACK: add torquebox repo only when building from filesystem
1919
# not when using the pom as "dependency" in some other projects

spec/truffle/tags/core/process/egid_tags.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1 @@
1-
fails:Process.euid also goes by Process::UID.eid
2-
fails:Process.euid also goes by Process::Sys.geteuid
3-
fails:Process.euid= raises TypeError if not passed an Integer
4-
fails:Process.euid= raises Errno::ERPERM if run by a non superuser trying to set the superuser id
51
fails:Process.euid= raises Errno::ERPERM if run by a non superuser trying to set the superuser id from username
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
1-
fails:Process.uid also goes by Process::UID.rid
2-
fails:Process.uid also goes by Process::Sys.getuid
3-
fails:Process.uid= raises TypeError if not passed an Integer
41
fails:Process.uid= raises Errno::ERPERM if run by a non privileged user trying to set the superuser id
52
fails:Process.uid= raises Errno::ERPERM if run by a non privileged user trying to set the superuser id from username

tool/jt.rb

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,16 @@ def print(*args)
256256

257257
def test_mri(*args)
258258
env_vars = {
259-
"EXCLUDES" => "test/mri/excludes_truffle"
259+
"EXCLUDES" => "test/mri/excludes_truffle"
260260
}
261261
jruby_args = %w[-J-Xmx2G -X+T -Xtruffle.exceptions.print_java]
262262

263263
if args.empty?
264264
args = File.readlines("#{JRUBY_DIR}/test/mri_truffle.index").grep(/^[^#]\w+/).map(&:chomp)
265265
end
266266

267-
command = %w[test/mri/runner.rb -v --color=never --tty=no -q --]
268-
args.unshift(*command)
269-
raw_sh(env_vars, "#{JRUBY_DIR}/bin/jruby", *jruby_args, *args)
267+
command = %w[test/mri/runner.rb -v --color=never --tty=no -q]
268+
raw_sh(env_vars, "#{JRUBY_DIR}/bin/jruby", *jruby_args, *command, *args)
270269
end
271270
private :test_mri
272271

truffle/pom.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
execute_goals( 'compile',
2828
:id => 'default-compile',
2929
:phase => 'compile',
30-
'annotationProcessors' => [ 'com.oracle.truffle.dsl.processor.TruffleProcessor' ],
3130
'generatedSourcesDirectory' => 'target/generated-sources',
3231
'compilerArgs' => [ '-XDignore.symbol.file=true',
3332
'-J-Duser.language=en',

truffle/pom.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
<goal>compile</goal>
5555
</goals>
5656
<configuration>
57-
<annotationProcessors>
58-
<annotationProcessor>com.oracle.truffle.dsl.processor.TruffleProcessor</annotationProcessor>
59-
</annotationProcessors>
6057
<generatedSourcesDirectory>target/generated-sources</generatedSourcesDirectory>
6158
<compilerArgs>
6259
<compilerArg>-XDignore.symbol.file=true</compilerArg>

truffle/src/main/java/org/jruby/truffle/nodes/core/array/ArrayNodes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public Object setOtherArray(VirtualFrame frame, RubyArray array, int start, int
595595
CompilerDirectives.transferToInterpreter();
596596
writeNode = insert(ArrayWriteDenormalizedNodeGen.create(getContext(), getSourceSection(), null, null, null));
597597
}
598-
Object[] values = ArrayUtils.box(value.getStore());
598+
Object[] values = value.slowToArray();
599599
if (value.getSize() == length || (begin + length + 1) > array.getSize()) {
600600
int i = begin;
601601
for (Object obj : values) {

truffle/src/main/java/org/jruby/truffle/nodes/rubinius/ExceptionPrimitiveNodes.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public abstract class ExceptionPrimitiveNodes {
2929
public static abstract class ExceptionErrnoErrorPrimitiveNode extends RubiniusPrimitiveNode {
3030

3131
// If you add a constant here, add it below in isExceptionSupported() too.
32+
protected final static int EPERM = Errno.EPERM.intValue();
3233
protected final static int ENOENT = Errno.ENOENT.intValue();
3334
protected final static int EBADF = Errno.EBADF.intValue();
3435
protected final static int EEXIST = Errno.EEXIST.intValue();
@@ -37,13 +38,23 @@ public static abstract class ExceptionErrnoErrorPrimitiveNode extends RubiniusPr
3738
protected final static int ENOTDIR = Errno.ENOTDIR.intValue();
3839

3940
public static boolean isExceptionSupported(int errno) {
40-
return errno == ENOENT || errno == EBADF || errno == EEXIST || errno == EACCES || errno == EFAULT || errno == ENOTDIR;
41+
return errno == EPERM || errno == ENOENT || errno == EBADF || errno == EEXIST || errno == EACCES || errno == EFAULT || errno == ENOTDIR;
4142
}
4243

4344
public ExceptionErrnoErrorPrimitiveNode(RubyContext context, SourceSection sourceSection) {
4445
super(context, sourceSection);
4546
}
4647

48+
@Specialization(guards = "errno == EPERM")
49+
public RubyException eperm(RubyString message, int errno) {
50+
return getContext().getCoreLibrary().operationNotPermittedError(message.toString(), this);
51+
}
52+
53+
@Specialization(guards = {"errno == EPERM", "isNil(message)"})
54+
public RubyException eperm(Object message, int errno) {
55+
return getContext().getCoreLibrary().operationNotPermittedError("nil", this);
56+
}
57+
4758
@Specialization(guards = "errno == ENOENT")
4859
public RubyException enoent(RubyString message, int errno) {
4960
return getContext().getCoreLibrary().fileNotFoundError(message.toString(), this);

truffle/src/main/java/org/jruby/truffle/nodes/rubinius/PosixNodes.java

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,20 @@ public int getpriority(int kind, int id) {
351351

352352
}
353353

354+
@CoreMethod(names = "setgid", isModuleFunction = true, required = 1, lowerFixnumParameters = 0)
355+
public abstract static class SetgidNode extends CoreMethodArrayArgumentsNode {
356+
357+
public SetgidNode(RubyContext context, SourceSection sourceSection) {
358+
super(context, sourceSection);
359+
}
360+
361+
@Specialization
362+
public int setgid(int gid) {
363+
return posix().setgid(gid);
364+
}
365+
366+
}
367+
354368
@CoreMethod(names = "setpriority", isModuleFunction = true, required = 3, lowerFixnumParameters = {0, 1, 2})
355369
public abstract static class SetPriorityNode extends CoreMethodArrayArgumentsNode {
356370

@@ -365,6 +379,90 @@ public int setpriority(int kind, int id, int priority) {
365379

366380
}
367381

382+
@CoreMethod(names = "setresuid", isModuleFunction = true, required = 3, lowerFixnumParameters = {0, 1, 2})
383+
public abstract static class SetResuidNode extends CoreMethodArrayArgumentsNode {
384+
385+
public SetResuidNode(RubyContext context, SourceSection sourceSection) {
386+
super(context, sourceSection);
387+
}
388+
389+
@Specialization
390+
public int setresuid(int uid, int id, int priority) {
391+
throw new RaiseException(getContext().getCoreLibrary().notImplementedError("setresuid", this));
392+
}
393+
394+
}
395+
396+
@CoreMethod(names = "seteuid", isModuleFunction = true, required = 1, lowerFixnumParameters = 0)
397+
public abstract static class SetEuidNode extends CoreMethodArrayArgumentsNode {
398+
399+
public SetEuidNode(RubyContext context, SourceSection sourceSection) {
400+
super(context, sourceSection);
401+
}
402+
403+
@Specialization
404+
public int seteuid(int uid) {
405+
return posix().seteuid(uid);
406+
}
407+
408+
}
409+
410+
@CoreMethod(names = "setreuid", isModuleFunction = true, required = 2, lowerFixnumParameters = {0, 1})
411+
public abstract static class SetReuidNode extends CoreMethodArrayArgumentsNode {
412+
413+
public SetReuidNode(RubyContext context, SourceSection sourceSection) {
414+
super(context, sourceSection);
415+
}
416+
417+
@Specialization
418+
public int setreuid(int uid, int id) {
419+
throw new RaiseException(getContext().getCoreLibrary().notImplementedError("setreuid", this));
420+
}
421+
422+
}
423+
424+
@CoreMethod(names = "setruid", isModuleFunction = true, required = 1, lowerFixnumParameters = 0)
425+
public abstract static class SetRuidNode extends CoreMethodArrayArgumentsNode {
426+
427+
public SetRuidNode(RubyContext context, SourceSection sourceSection) {
428+
super(context, sourceSection);
429+
}
430+
431+
@Specialization
432+
public int setruid(int uid) {
433+
throw new RaiseException(getContext().getCoreLibrary().notImplementedError("setruid", this));
434+
}
435+
436+
}
437+
438+
@CoreMethod(names = "setuid", isModuleFunction = true, required = 1, lowerFixnumParameters = 0)
439+
public abstract static class SetUidNode extends CoreMethodArrayArgumentsNode {
440+
441+
public SetUidNode(RubyContext context, SourceSection sourceSection) {
442+
super(context, sourceSection);
443+
}
444+
445+
@Specialization
446+
public int setuid(int uid) {
447+
return posix().setuid(uid);
448+
}
449+
450+
}
451+
452+
@CoreMethod(names = "setsid", isModuleFunction = true)
453+
public abstract static class SetSidNode extends CoreMethodArrayArgumentsNode {
454+
455+
public SetSidNode(RubyContext context, SourceSection sourceSection) {
456+
super(context, sourceSection);
457+
}
458+
459+
@Specialization
460+
public int setsid() {
461+
return posix().setsid();
462+
}
463+
464+
}
465+
368466
@CoreMethod(names = "flock", isModuleFunction = true, required = 2, lowerFixnumParameters = {0, 1})
369467
public abstract static class FlockNode extends CoreMethodArrayArgumentsNode {
370468

@@ -545,6 +643,20 @@ public int isATTY(int fd) {
545643

546644
}
547645

646+
@CoreMethod(names = "getppid", isModuleFunction = true)
647+
public abstract static class GetppidNode extends CoreMethodArrayArgumentsNode {
648+
649+
public GetppidNode(RubyContext context, SourceSection sourceSection) {
650+
super(context, sourceSection);
651+
}
652+
653+
@Specialization
654+
public int getppid() {
655+
return posix().getppid();
656+
}
657+
658+
}
659+
548660
@CoreMethod(names = "symlink", isModuleFunction = true, required = 2)
549661
public abstract static class SymlinkNode extends CoreMethodArrayArgumentsNode {
550662

truffle/src/main/java/org/jruby/truffle/runtime/RubyContext.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,12 @@ public Object instanceEval(ByteList code, Object self, Node currentNode) {
319319
}
320320

321321
public Object eval(Source source) {
322-
return execute(source, UTF8Encoding.INSTANCE, TranslatorDriver.ParserContext.EVAL, getCoreLibrary().getMainObject(), null, null, NodeWrapper.IDENTITY);
322+
return execute(source, UTF8Encoding.INSTANCE, TranslatorDriver.ParserContext.EVAL, getCoreLibrary().getMainObject(), null, null, new NodeWrapper() {
323+
@Override
324+
public RubyNode wrap(RubyNode node) {
325+
return new SetMethodDeclarationContext(node.getContext(), node.getSourceSection(), Visibility.PRIVATE, "simple eval", node);
326+
}
327+
});
323328
}
324329

325330
@TruffleBoundary

truffle/src/main/java/org/jruby/truffle/runtime/array/ArrayUtils.java

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,25 @@ public static Object[] boxExtra(double[] unboxed, int extra) {
196196
return boxed;
197197
}
198198

199+
public static Object[] boxExtra(Object array, int extra) {
200+
CompilerAsserts.neverPartOfCompilation();
201+
202+
if (array == null) {
203+
return new Object[extra];
204+
} else if (array instanceof int[]) {
205+
return boxExtra((int[]) array, extra);
206+
} else if (array instanceof long[]) {
207+
return boxExtra((long[]) array, extra);
208+
} else if (array instanceof double[]) {
209+
return boxExtra((double[]) array, extra);
210+
} else if (array instanceof Object[]) {
211+
final Object[] objectArray = (Object[]) array;
212+
return Arrays.copyOf(objectArray, objectArray.length + extra);
213+
} else {
214+
throw new UnsupportedOperationException();
215+
}
216+
}
217+
199218
public static Object[] boxUntil(int[] unboxed, int length) {
200219
final Object[] boxed = new Object[length];
201220

@@ -226,20 +245,20 @@ public static Object[] boxUntil(double[] unboxed, int length) {
226245
return boxed;
227246
}
228247

229-
public static Object[] boxExtra(Object array, int extra) {
248+
public static Object[] boxUntil(Object array, int length) {
230249
CompilerAsserts.neverPartOfCompilation();
231250

232251
if (array == null) {
233-
return new Object[extra];
234-
} if (array instanceof int[]) {
235-
return boxExtra((int[]) array, extra);
252+
return new Object[0];
253+
} else if (array instanceof int[]) {
254+
return boxUntil((int[]) array, length);
236255
} else if (array instanceof long[]) {
237-
return boxExtra((long[]) array, extra);
256+
return boxUntil((long[]) array, length);
238257
} else if (array instanceof double[]) {
239-
return boxExtra((double[]) array, extra);
258+
return boxUntil((double[]) array, length);
240259
} else if (array instanceof Object[]) {
241260
final Object[] objectArray = (Object[]) array;
242-
return Arrays.copyOf(objectArray, objectArray.length + extra);
261+
return Arrays.copyOf(objectArray, length);
243262
} else {
244263
throw new UnsupportedOperationException();
245264
}

truffle/src/main/java/org/jruby/truffle/runtime/core/CoreLibrary.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ public class CoreLibrary {
9494
private final RubyClass nameErrorClass;
9595
private final RubyClass nilClass;
9696
private final RubyClass noMethodErrorClass;
97+
private final RubyClass notImplementedErrorClass;
9798
private final RubyClass numericClass;
9899
private final RubyClass objectClass;
99100
private final RubyClass procClass;
@@ -270,7 +271,7 @@ public CoreLibrary(RubyContext context) {
270271
// ScriptError
271272
RubyClass scriptErrorClass = defineClass(exceptionClass, "ScriptError");
272273
loadErrorClass = defineClass(scriptErrorClass, "LoadError");
273-
defineClass(scriptErrorClass, "NotImplementedError");
274+
notImplementedErrorClass = defineClass(scriptErrorClass, "NotImplementedError");
274275
syntaxErrorClass = defineClass(scriptErrorClass, "SyntaxError");
275276

276277
// SecurityError
@@ -1014,6 +1015,11 @@ public RubyException zeroDivisionError(Node currentNode) {
10141015
return new RubyException(context.getCoreLibrary().getZeroDivisionErrorClass(), context.makeString("divided by 0"), RubyCallStack.getBacktrace(currentNode));
10151016
}
10161017

1018+
public RubyException notImplementedError(String message, Node currentNode) {
1019+
CompilerAsserts.neverPartOfCompilation();
1020+
return new RubyException(notImplementedErrorClass, context.makeString(String.format("Method %s not implemented", message)), RubyCallStack.getBacktrace(currentNode));
1021+
}
1022+
10171023
public RubyException syntaxError(String message, Node currentNode) {
10181024
CompilerAsserts.neverPartOfCompilation();
10191025
return new RubyException(syntaxErrorClass, context.makeString(message), RubyCallStack.getBacktrace(currentNode));
@@ -1065,6 +1071,11 @@ public RubyException dirNotEmptyError(String path, Node currentNode) {
10651071
return new RubyException(getErrnoClass(Errno.ENOTEMPTY), context.makeString(String.format("Directory not empty - %s", path)), RubyCallStack.getBacktrace(currentNode));
10661072
}
10671073

1074+
public RubyException operationNotPermittedError(String path, Node currentNode) {
1075+
CompilerAsserts.neverPartOfCompilation();
1076+
return new RubyException(getErrnoClass(Errno.EPERM), context.makeString(String.format("Operation not permitted - %s", path)), RubyCallStack.getBacktrace(currentNode));
1077+
}
1078+
10681079
public RubyException permissionDeniedError(String path, Node currentNode) {
10691080
CompilerAsserts.neverPartOfCompilation();
10701081
return new RubyException(getErrnoClass(Errno.EACCES), context.makeString(String.format("Permission denied - %s", path)), RubyCallStack.getBacktrace(currentNode));

truffle/src/main/java/org/jruby/truffle/runtime/core/RubyArray.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private static Object storeFromObjects(RubyContext context, Object... objects) {
135135
}
136136

137137
public Object[] slowToArray() {
138-
return Arrays.copyOf(ArrayUtils.box(store), size);
138+
return ArrayUtils.boxUntil(store, size);
139139
}
140140

141141
public Object slowShift() {

0 commit comments

Comments
 (0)