11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 61cb0ef41Sopenharmony_ci#define V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/objects/contexts.h" 91cb0ef41Sopenharmony_ci#include "src/objects/dictionary.h" 101cb0ef41Sopenharmony_ci#include "src/objects/js-array.h" 111cb0ef41Sopenharmony_ci#include "src/objects/objects.h" 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_cinamespace v8 { 141cb0ef41Sopenharmony_cinamespace internal { 151cb0ef41Sopenharmony_ci 161cb0ef41Sopenharmony_ciclass ConstructorBuiltins { 171cb0ef41Sopenharmony_ci public: 181cb0ef41Sopenharmony_ci static int MaximumFunctionContextSlots() { 191cb0ef41Sopenharmony_ci return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots 201cb0ef41Sopenharmony_ci : kMaximumSlots; 211cb0ef41Sopenharmony_ci } 221cb0ef41Sopenharmony_ci 231cb0ef41Sopenharmony_ci // Maximum number of elements in copied array (chosen so that even an array 241cb0ef41Sopenharmony_ci // backed by a double backing store will fit into new-space). 251cb0ef41Sopenharmony_ci static const int kMaximumClonedShallowArrayElements = 261cb0ef41Sopenharmony_ci JSArray::kInitialMaxFastElementArray; 271cb0ef41Sopenharmony_ci // Maximum number of properties in copied object so that the properties store 281cb0ef41Sopenharmony_ci // will fit into new-space. This constant is based on the assumption that 291cb0ef41Sopenharmony_ci // NameDictionaries are 50% over-allocated. 301cb0ef41Sopenharmony_ci static const int kMaximumClonedShallowObjectProperties = 311cb0ef41Sopenharmony_ci NameDictionary::kMaxRegularCapacity / 3 * 2; 321cb0ef41Sopenharmony_ci 331cb0ef41Sopenharmony_ci private: 341cb0ef41Sopenharmony_ci static const int kMaximumSlots = 351cb0ef41Sopenharmony_ci (kMaxRegularHeapObjectSize - Context::kTodoHeaderSize) / kTaggedSize - 1; 361cb0ef41Sopenharmony_ci static const int kSmallMaximumSlots = 10; 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_ci // FastNewFunctionContext can only allocate closures which fit in the 391cb0ef41Sopenharmony_ci // new space. 401cb0ef41Sopenharmony_ci STATIC_ASSERT(Context::SizeFor(kMaximumSlots + Context::MIN_CONTEXT_SLOTS) < 411cb0ef41Sopenharmony_ci kMaxRegularHeapObjectSize); 421cb0ef41Sopenharmony_ci}; 431cb0ef41Sopenharmony_ci 441cb0ef41Sopenharmony_ci} // namespace internal 451cb0ef41Sopenharmony_ci} // namespace v8 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ci#endif // V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 48