Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/builtins/growable-fixed-array.tq')
-rw-r--r--deps/v8/src/builtins/growable-fixed-array.tq76
1 files changed, 40 insertions, 36 deletions
diff --git a/deps/v8/src/builtins/growable-fixed-array.tq b/deps/v8/src/builtins/growable-fixed-array.tq
index 0666c39fd75..094e051a65a 100644
--- a/deps/v8/src/builtins/growable-fixed-array.tq
+++ b/deps/v8/src/builtins/growable-fixed-array.tq
@@ -3,44 +3,48 @@
// found in the LICENSE file.
namespace growable_fixed_array {
- // TODO(pwong): Support FixedTypedArrays.
- struct GrowableFixedArray {
- macro Push(obj: Object) {
- this.EnsureCapacity();
- this.array.objects[this.length++] = obj;
- }
- macro ResizeFixedArray(newCapacity: intptr): FixedArray {
- assert(this.length >= 0);
- assert(newCapacity >= 0);
- assert(newCapacity >= this.length);
- const first: intptr = 0;
- return ExtractFixedArray(this.array, first, this.length, newCapacity);
- }
- macro EnsureCapacity() {
- assert(this.length <= this.capacity);
- if (this.capacity == this.length) {
- // Growth rate is analog to JSObject::NewElementsCapacity:
- // new_capacity = (current_capacity + (current_capacity >> 1)) + 16.
- this.capacity = this.capacity + (this.capacity >> 1) + 16;
- this.array = this.ResizeFixedArray(this.capacity);
- }
- }
- macro ToJSArray(implicit context: Context)(): JSArray {
- const nativeContext: NativeContext = LoadNativeContext(context);
- const map: Map =
- LoadJSArrayElementsMap(ElementsKind::PACKED_ELEMENTS, nativeContext);
- const fixedArray: FixedArray = this.ResizeFixedArray(this.length);
- const lengthSmi = Convert<Smi>(this.length);
- return AllocateJSArray(map, fixedArray, lengthSmi);
+// TODO(pwong): Support FixedTypedArrays.
+struct GrowableFixedArray {
+ macro Push(obj: Object) {
+ this.EnsureCapacity();
+ this.array.objects[this.length++] = obj;
+ }
+ macro ResizeFixedArray(newCapacity: intptr): FixedArray {
+ assert(this.length >= 0);
+ assert(newCapacity >= 0);
+ assert(newCapacity >= this.length);
+ const first: intptr = 0;
+ return ExtractFixedArray(this.array, first, this.length, newCapacity);
+ }
+ macro EnsureCapacity() {
+ assert(this.length <= this.capacity);
+ if (this.capacity == this.length) {
+ // Growth rate is analog to JSObject::NewElementsCapacity:
+ // new_capacity = (current_capacity + (current_capacity >> 1)) + 16.
+ this.capacity = this.capacity + (this.capacity >> 1) + 16;
+ this.array = this.ResizeFixedArray(this.capacity);
}
-
- array: FixedArray;
- // TODO(v8:4153): make capacity and length uintptr
- capacity: intptr;
- length: intptr;
+ }
+ macro ToFixedArray(): FixedArray {
+ return this.ResizeFixedArray(this.length);
}
- macro NewGrowableFixedArray(): GrowableFixedArray {
- return GrowableFixedArray{array: kEmptyFixedArray, capacity: 0, length: 0};
+ macro ToJSArray(implicit context: Context)(): JSArray {
+ const nativeContext: NativeContext = LoadNativeContext(context);
+ const map: Map =
+ LoadJSArrayElementsMap(ElementsKind::PACKED_ELEMENTS, nativeContext);
+ const fixedArray: FixedArray = this.ResizeFixedArray(this.length);
+ const lengthSmi = Convert<Smi>(this.length);
+ return AllocateJSArray(map, fixedArray, lengthSmi);
}
+
+ array: FixedArray;
+ // TODO(v8:4153): make capacity and length uintptr
+ capacity: intptr;
+ length: intptr;
+}
+
+macro NewGrowableFixedArray(): GrowableFixedArray {
+ return GrowableFixedArray{array: kEmptyFixedArray, capacity: 0, length: 0};
+}
}