V8 API Reference, 7.2.502.16 (for Deno 0.2.4)
embedder-data-array.cc
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 Handle<EmbedderDataArray> EmbedderDataArray::EnsureCapacity(
13  Isolate* isolate, Handle<EmbedderDataArray> array, int index) {
14  if (index < array->length()) return array;
15  DCHECK_LT(index, kMaxLength);
16  Handle<EmbedderDataArray> new_array =
17  isolate->factory()->NewEmbedderDataArray(index + 1);
18  DisallowHeapAllocation no_gc;
19  // Last new space allocation does not require any write barriers.
20  size_t size = array->length() * kEmbedderDataSlotSize;
21  MemCopy(reinterpret_cast<void*>(new_array->slots_start()),
22  reinterpret_cast<void*>(array->slots_start()), size);
23  return new_array;
24 }
25 
26 } // namespace internal
27 } // namespace v8
Definition: libplatform.h:13