1 // Copyright 2016 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 #ifndef V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 6 #define V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 7 8 #include "src/objects/contexts.h" 9 #include "src/objects/dictionary.h" 10 #include "src/objects/js-array.h" 11 #include "src/objects/objects.h" 12 13 namespace v8 { 14 namespace internal { 15 16 class ConstructorBuiltins { 17 public: MaximumFunctionContextSlots()18 static int MaximumFunctionContextSlots() { 19 return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots 20 : kMaximumSlots; 21 } 22 23 // Maximum number of elements in copied array (chosen so that even an array 24 // backed by a double backing store will fit into new-space). 25 static const int kMaximumClonedShallowArrayElements = 26 JSArray::kInitialMaxFastElementArray; 27 // Maximum number of properties in copied object so that the properties store 28 // will fit into new-space. This constant is based on the assumption that 29 // NameDictionaries are 50% over-allocated. 30 static const int kMaximumClonedShallowObjectProperties = 31 NameDictionary::kMaxRegularCapacity / 3 * 2; 32 33 private: 34 static const int kMaximumSlots = 35 (kMaxRegularHeapObjectSize - Context::kTodoHeaderSize) / kTaggedSize - 1; 36 static const int kSmallMaximumSlots = 10; 37 38 // FastNewFunctionContext can only allocate closures which fit in the 39 // new space. 40 STATIC_ASSERT(Context::SizeFor(kMaximumSlots + Context::MIN_CONTEXT_SLOTS) < 41 kMaxRegularHeapObjectSize); 42 }; 43 44 } // namespace internal 45 } // namespace v8 46 47 #endif // V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 48