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 : #include "src/objects/embedder-data-array-inl.h"
7 :
8 : namespace v8 {
9 : namespace internal {
10 :
11 : // static
12 59074 : Handle<EmbedderDataArray> EmbedderDataArray::EnsureCapacity(
13 : Isolate* isolate, Handle<EmbedderDataArray> array, int index) {
14 118148 : if (index < array->length()) return array;
15 : DCHECK_LT(index, kMaxLength);
16 : Handle<EmbedderDataArray> new_array =
17 59074 : isolate->factory()->NewEmbedderDataArray(index + 1);
18 : DisallowHeapAllocation no_gc;
19 : // Last new space allocation does not require any write barriers.
20 118148 : size_t size = array->length() * kEmbedderDataSlotSize;
21 118148 : MemCopy(reinterpret_cast<void*>(new_array->slots_start()),
22 236296 : reinterpret_cast<void*>(array->slots_start()), size);
23 59074 : return new_array;
24 : }
25 :
26 : } // namespace internal
27 183867 : } // namespace v8
|