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/contexts.h" 9 #include "src/objects.h" 10 #include "src/objects/dictionary.h" 11 #include "src/objects/js-array.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 = 0x8000; 35 static const int kSmallMaximumSlots = 10; 36 37 // FastNewFunctionContext can only allocate closures which fit in the 38 // new space. 39 STATIC_ASSERT(((kMaximumSlots + Context::MIN_CONTEXT_SLOTS) * kPointerSize + 40 FixedArray::kHeaderSize) < kMaxRegularHeapObjectSize); 41 }; 42 43 } // namespace internal 44 } // namespace v8 45 46 #endif // V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_ 47