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 61130 : Handle<EmbedderDataArray> EmbedderDataArray::EnsureCapacity(
15 : Isolate* isolate, Handle<EmbedderDataArray> array, int index) {
16 61130 : if (index < array->length()) return array;
17 : DCHECK_LT(index, kMaxLength);
18 : Handle<EmbedderDataArray> new_array =
19 61130 : isolate->factory()->NewEmbedderDataArray(index + 1);
20 : DisallowHeapAllocation no_gc;
21 : // Last new space allocation does not require any write barriers.
22 61130 : size_t size = array->length() * kEmbedderDataSlotSize;
23 122260 : MemCopy(reinterpret_cast<void*>(new_array->slots_start()),
24 : reinterpret_cast<void*>(array->slots_start()), size);
25 61130 : return new_array;
26 : }
27 :
28 : } // namespace internal
29 122036 : } // namespace v8
|