MCPcopy Index your code
hub / github.com/apache/tvm / allocRawBytes

Method allocRawBytes

web/src/memory.ts:357–378  ·  view source on GitHub ↗

* Allocate space by number of bytes * @param nbytes Number of bytes. * Note: This function always allocate space that aligns to 64bit.

(nbytes: number)

Source from the content-addressed store, hash-verified

355 * Note: This function always allocate space that aligns to 64bit.
356 */
357 allocRawBytes(nbytes: number): PtrOffset {
358 // always aligns to 64bit
359 nbytes = ((nbytes + 7) >> 3) << 3;
360
361 if (this.stackTop + nbytes > this.buffer.byteLength) {
362 const newSize = Math.max(
363 this.buffer.byteLength * 2,
364 this.stackTop + nbytes
365 );
366 const oldU8 = this.viewU8;
367 this.buffer = new ArrayBuffer(newSize);
368 this.updateViews();
369 this.viewU8.set(oldU8);
370 if (this.basePtr != 0) {
371 this.cFreeSpace(this.basePtr);
372 }
373 this.basePtr = this.cAllocSpace(newSize);
374 }
375 const retOffset = this.stackTop;
376 this.stackTop += nbytes;
377 return retOffset;
378 }
379
380 /**
381 * Allocate space for pointers.

Callers 6

allocPtrArrayMethod · 0.95
allocThenSetArgStringMethod · 0.95
allocThenSetArgBytesMethod · 0.95
packedFuncMethod · 0.80

Calls 2

updateViewsMethod · 0.95
maxMethod · 0.80

Tested by

no test coverage detected