Line data Source code
1 : // Copyright 2018 the V8 project authors. All rights reserved.
2 : // Use of this source code is governed by a BSD-style license that can be
3 : // found in the LICENSE file.
4 :
5 : #include "src/objects/embedder-data-array.h"
6 :
7 : #include "src/isolate.h"
8 : #include "src/objects/embedder-data-array-inl.h"
9 :
10 : namespace v8 {
11 : namespace internal {
12 :
13 : // static
14 60565 : Handle<EmbedderDataArray> EmbedderDataArray::EnsureCapacity(
15 : Isolate* isolate, Handle<EmbedderDataArray> array, int index) {
16 60565 : if (index < array->length()) return array;
17 : DCHECK_LT(index, kMaxLength);
18 : Handle<EmbedderDataArray> new_array =
19 60565 : isolate->factory()->NewEmbedderDataArray(index + 1);
20 : DisallowHeapAllocation no_gc;
21 : // Last new space allocation does not require any write barriers.
22 60565 : size_t size = array->length() * kEmbedderDataSlotSize;
23 121130 : MemCopy(reinterpret_cast<void*>(new_array->slots_start()),
24 : reinterpret_cast<void*>(array->slots_start()), size);
25 60565 : return new_array;
26 : }
27 :
28 : } // namespace internal
29 120216 : } // namespace v8
|