@@ -136,7 +136,7 @@ void SegmentedArrayDeserialize(Deserializer &d, CellKind kind) {
136136}
137137#endif
138138
139- CallResult<HermesValue > SegmentedArray::create (
139+ CallResult<PseudoHandle<SegmentedArray> > SegmentedArray::create (
140140 Runtime *runtime,
141141 size_type capacity) {
142142 if (LLVM_UNLIKELY (capacity > maxElements ())) {
@@ -148,34 +148,33 @@ CallResult<HermesValue> SegmentedArray::create(
148148 // if it is larger than the inline storage space. That is in order to avoid
149149 // having an extra field to track, and the upper bound of "size" can be used
150150 // instead.
151- return HermesValue::encodeObjectValue (new (
152- runtime->alloc <false /* fixedSize*/ >(allocationSizeForCapacity (capacity)))
153- SegmentedArray (runtime, capacity));
151+ return createPseudoHandle (new (runtime->alloc <false /* fixedSize*/ >(
152+ allocationSizeForCapacity (capacity))) SegmentedArray (runtime, capacity));
154153}
155154
156- CallResult<HermesValue > SegmentedArray::createLongLived (
155+ CallResult<PseudoHandle<SegmentedArray> > SegmentedArray::createLongLived (
157156 Runtime *runtime,
158157 size_type capacity) {
159158 if (LLVM_UNLIKELY (capacity > maxElements ())) {
160159 return throwExcessiveCapacityError (runtime, capacity);
161160 }
162161 // Leave the segments as null. Whenever the size is changed, the segments will
163162 // be allocated.
164- return HermesValue::encodeObjectValue (new (runtime->allocLongLived (
163+ return createPseudoHandle (new (runtime->allocLongLived (
165164 allocationSizeForCapacity (capacity))) SegmentedArray (runtime, capacity));
166165}
167166
168- CallResult<HermesValue >
167+ CallResult<PseudoHandle<SegmentedArray> >
169168SegmentedArray::create (Runtime *runtime, size_type capacity, size_type size) {
170169 auto arrRes = create (runtime, capacity);
171170 if (LLVM_UNLIKELY (arrRes == ExecutionStatus::EXCEPTION )) {
172171 return ExecutionStatus::EXCEPTION ;
173172 }
174- auto self = createPseudoHandle (vmcast<SegmentedArray>( *arrRes) );
173+ PseudoHandle<SegmentedArray> self = std::move ( *arrRes);
175174 // TODO T25663446: This is potentially optimizable to iterate over the inline
176175 // storage and the segments separately.
177176 self = increaseSize</* Fill*/ true >(runtime, std::move (self), size);
178- return self. getHermesValue () ;
177+ return self;
179178}
180179
181180SegmentedArray::size_type SegmentedArray::capacity () const {
@@ -291,7 +290,7 @@ ExecutionStatus SegmentedArray::growRight(
291290 if (arrRes == ExecutionStatus::EXCEPTION ) {
292291 return ExecutionStatus::EXCEPTION ;
293292 }
294- auto newSegmentedArray = createPseudoHandle (vmcast<SegmentedArray>( *arrRes) );
293+ PseudoHandle<SegmentedArray> newSegmentedArray = std::move ( *arrRes);
295294 // Copy inline storage and segments over.
296295 // Do this with raw pointers so that the range write barrier occurs.
297296 GCHermesValue::copy (
@@ -321,7 +320,7 @@ ExecutionStatus SegmentedArray::growLeft(
321320 if (arrRes == ExecutionStatus::EXCEPTION ) {
322321 return ExecutionStatus::EXCEPTION ;
323322 }
324- auto newSegmentedArray = createPseudoHandle (vmcast<SegmentedArray>( *arrRes) );
323+ PseudoHandle<SegmentedArray> newSegmentedArray = std::move ( *arrRes);
325324 // Don't fill with empty values, most will be copied in.
326325 newSegmentedArray = increaseSize</* Fill*/ false >(
327326 runtime, std::move (newSegmentedArray), newSize);
0 commit comments