Hi, I’m interested to know whether Avail’s (L3?) compiler will be capable of inlining higher order functions that traverse tuples in a tight loop. Especially I wonder whether map and fold (*the* 'big data’ operators) can be efficiently compiled and implemented with the current set of primitives.
Currently, indexing a tuple is a VM primitive that has the following
(interpreter) implementation:
(P_131_TupleAt.java)
public Result attempt (
final List<AvailObject> args,
final Interpreter interpreter,
final boolean skipReturnCheck)
{
assert args.size() == 2;
final A_Tuple tuple = args.get(0);
final A_Number indexObject = args.get(1);
if (!indexObject.isInt())
{
return
interpreter.primitiveFailure(E_SUBSCRIPT_OUT_OF_BOUNDS);
}
final int index = indexObject.extractInt();
if (index > tuple.tupleSize())
{
return
interpreter.primitiveFailure(E_SUBSCRIPT_OUT_OF_BOUNDS);
}
return interpreter.primitiveSuccess(
tuple.tupleAt(index));
}
(TreeTupleDescriptor.java)
AvailObject o_TupleAt (final AvailObject object, final int index)
{
final int childSubscript = childSubscriptForIndex(object,
index);
final int offset = offsetForChildSubscript(object,
childSubscript);
final A_Tuple child = object.slot(SUBTUPLE_AT_, childSubscript);
return child.tupleAt(index - offset);
}
How would all this code be translated to L3 and aggressively inlined at the L3
level, so that traversing and indexing tuples in a tight loop gets maximally
inlined?
cheers,
Robbert.
signature.asc
Description: Message signed with OpenPGP using GPGMail
