js-array-buffer.tq 1.53 KB
Newer Older
Tobias Tebbi's avatar
Tobias Tebbi committed
1 2 3 4
// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8 9 10 11 12
bitfield struct JSArrayBufferFlags extends uint32 {
  is_external: bool: 1 bit;
  is_detachable: bool: 1 bit;
  was_detached: bool: 1 bit;
  is_asm_js_memory: bool: 1 bit;
  is_shared: bool: 1 bit;
}

13
@generateCppClass
Tobias Tebbi's avatar
Tobias Tebbi committed
14 15
extern class JSArrayBuffer extends JSObject {
  byte_length: uintptr;
16
  backing_store: ExternalPointer;
17 18 19 20 21 22 23 24
  @if(V8_ARRAY_BUFFER_EXTENSION_BOOL) extension: RawPtr;
  @ifnot(V8_ARRAY_BUFFER_EXTENSION_BOOL) extension: void;
  bit_field: JSArrayBufferFlags;
  // Pads header size to be a multiple of kTaggedSize.
  @if(TAGGED_SIZE_8_BYTES) optional_padding: uint32;
  @ifnot(TAGGED_SIZE_8_BYTES) optional_padding: void;
}

25 26 27
extern operator '.backing_store_ptr' macro LoadJSArrayBufferBackingStorePtr(
    JSArrayBuffer): RawPtr;

28 29 30 31 32 33 34
@export
macro IsDetachedBuffer(buffer: JSArrayBuffer): bool {
  return buffer.bit_field.was_detached;
}

macro IsSharedArrayBuffer(buffer: JSArrayBuffer): bool {
  return buffer.bit_field.is_shared;
Tobias Tebbi's avatar
Tobias Tebbi committed
35 36 37
}

@abstract
38
@generateCppClass
Tobias Tebbi's avatar
Tobias Tebbi committed
39 40 41 42 43 44
extern class JSArrayBufferView extends JSObject {
  buffer: JSArrayBuffer;
  byte_offset: uintptr;
  byte_length: uintptr;
}

45
@generateCppClass
Tobias Tebbi's avatar
Tobias Tebbi committed
46 47
extern class JSTypedArray extends JSArrayBufferView {
  length: uintptr;
48
  external_pointer: ExternalPointer;
49
  // [base_pointer]: TODO(v8:4153)
Tobias Tebbi's avatar
Tobias Tebbi committed
50 51 52
  base_pointer: ByteArray|Smi;
}

53
@generateCppClass
54 55 56
extern class JSDataView extends JSArrayBufferView {
  data_pointer: ExternalPointer;
}