Changeset 15307


Ignore:
Timestamp:
06/04/20 08:25:15 (6 months ago)
Author:
Mark Evenson
Message:

Gently add arguments to the CL:MAKE-ARRAY we want

Look ma, no new symbols!

Well, if keywords aren't symbols. We augement CL:MAKE-ARRAY to add
the keyword arguments :NIO-BUFFER and :NIO-DIRECT.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/arrays.lisp

    r11391 r15307  
    3939                              (initial-element nil initial-element-p)
    4040                              initial-contents adjustable fill-pointer
    41                               displaced-to displaced-index-offset)
     41                              displaced-to displaced-index-offset
     42                              (nio-direct nil nio-direct-p)
     43                              (nio-buffer nil nio-buffer-p))
    4244  (setf element-type (normalize-type element-type))
    4345  (%make-array dimensions element-type initial-element initial-element-p
    4446               initial-contents adjustable fill-pointer displaced-to
    45                displaced-index-offset))
     47               displaced-index-offset
     48               nio-direct nio-direct-p
     49               nio-buffer nio-buffer-p))
    4650
    4751(defun adjust-array (array new-dimensions
     
    8387(defun (setf sbit) (new-value array &rest subscripts)
    8488  (aset array (%array-row-major-index array subscripts) new-value))
     89
     90(push :nio *features*)
  • trunk/abcl/src/org/armedbear/lisp/make_array.java

    r15306 r15307  
    5050  public LispObject execute(LispObject[] args)
    5151  {
    52     if (args.length != 9)
    53       return error(new WrongNumberOfArgumentsException(this, 9));
     52    // What a mess without keywords, but it still works

     53    if (args.length != 13)
     54      return error(new WrongNumberOfArgumentsException(this, 13));
    5455    LispObject dimensions = args[0];
    5556    LispObject elementType = args[1];
     
    6162    LispObject displacedTo = args[7];
    6263    LispObject displacedIndexOffset = args[8];
     64    LispObject direct = args[9]; // boolean whether to do a direct allocation for nio capable vectors
     65    //    LispObject directProvided = args[10]; // UNUSED but included for consistency
     66    boolean directAllocation = direct.equals(NIL) ? false : true;
     67    LispObject nioBuffer = args[11];
     68    LispObject nioBufferProvided = args[12];
     69   
    6370    if (initialElementProvided != NIL && initialContents != NIL)
    6471      {
     
    103110            } else if (arrayElementType.equal(UNSIGNED_BYTE_8)) {
    104111              if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    105                 v = new ComplexVector_ByteBuffer(dimv[0], array, displacement);
     112                // an abstract array doesn't have a directAllocation  ???
     113                v = new ComplexVector_ByteBuffer(dimv[0], array, displacement, directAllocation);
    106114              } else if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    107115                v = new ComplexVector_UnsignedByte8(dimv[0], array, displacement);
     
    170178            if (fillPointer != NIL || adjustable != NIL) {
    171179              if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    172                 v = new ComplexVector_ByteBuffer(size);
     180                v = new ComplexVector_ByteBuffer(size, directAllocation);
    173181              } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    174182                v = new ComplexVector_UnsignedByte8(size);
     
    176184            } else {
    177185              if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    178                 v = new BasicVector_ByteBuffer(size);
     186                if (!nioBuffer.equals(NIL)) {
     187                  v = new BasicVector_ByteBuffer((java.nio.ByteBuffer)(((JavaObject)nioBuffer).getObject()),
     188                                                 directAllocation);
     189                } else {
     190                  v = new BasicVector_ByteBuffer(size, directAllocation);
     191                }
    179192              } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    180193                v = new BasicVector_UnsignedByte8(size);
     
    188201          {
    189202            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    190               v = new BasicVector_CharBuffer(size);
     203              v = new BasicVector_CharBuffer(size, directAllocation);
    191204            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    192205              v = new BasicVector_UnsignedByte16(size);
     
    201214            else {
    202215              if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    203                 v = new BasicVector_IntBuffer(size);
     216                v = new BasicVector_IntBuffer(size, directAllocation);
    204217              } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    205218                v = new BasicVector_UnsignedByte32(size);
     
    263276              {
    264277                if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    265                   array = new SimpleArray_ByteBuffer(dimv, initialContents);
     278                  array = new SimpleArray_ByteBuffer(dimv, initialContents, directAllocation);
    266279                } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    267280                  array = new SimpleArray_UnsignedByte8(dimv, initialContents);
     
    271284              {
    272285                if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    273                   array = new SimpleArray_ByteBuffer(dimv);
     286                  array = new SimpleArray_ByteBuffer(dimv, directAllocation);
    274287                } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    275288                  array = new SimpleArray_UnsignedByte8(dimv);
     
    285298          if (initialContents != NIL) {
    286299            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    287               array = new SimpleArray_CharBuffer(dimv, initialContents);
     300              array = new SimpleArray_CharBuffer(dimv, initialContents, directAllocation);
    288301            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    289302              array = new SimpleArray_UnsignedByte16(dimv, initialContents);
     
    291304          } else {
    292305            if (Java.Buffers.active.equals(AllocationPolicy.NIO)) {
    293               array = new SimpleArray_CharBuffer(dimv);
     306              array = new SimpleArray_CharBuffer(dimv, directAllocation);
    294307            } else { //if (Java.Buffers.active.equals(AllocationPolicy.PRIMITIVE_ARRAY)) {
    295308              array = new SimpleArray_UnsignedByte16(dimv);
     
    302315          }
    303316        }
     317        // N.b. There is no implementation of SimpleArray with
     318        // contents (unsigned-byte 32) using either a
     319        // primitive array or an nio.Buffer
    304320        else if (upgradedType.equal(UNSIGNED_BYTE_32))
    305321          {
Note: See TracChangeset for help on using the changeset viewer.