builtins-constructor.h 1.65 KB
Newer Older
1 2 3 4
// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6 7 8 9
#ifndef V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_
#define V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_

#include "src/contexts.h"
#include "src/objects.h"
10
#include "src/objects/dictionary.h"
11
#include "src/objects/js-array.h"
12 13 14 15

namespace v8 {
namespace internal {

16
class ConstructorBuiltins {
17
 public:
18 19 20 21
  static int MaximumFunctionContextSlots() {
    return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots
                                                          : kMaximumSlots;
  }
22 23 24 25

  // Maximum number of elements in copied array (chosen so that even an array
  // backed by a double backing store will fit into new-space).
  static const int kMaximumClonedShallowArrayElements =
26
      JSArray::kInitialMaxFastElementArray;
27 28 29 30 31
  // Maximum number of properties in copied object so that the properties store
  // will fit into new-space. This constant is based on the assumption that
  // NameDictionaries are 50% over-allocated.
  static const int kMaximumClonedShallowObjectProperties =
      NameDictionary::kMaxRegularCapacity / 3 * 2;
32

33
 private:
34
  static const int kMaximumSlots =
35
      (kMaxRegularHeapObjectSize - Context::kTodoHeaderSize) / kTaggedSize - 1;
36 37 38 39
  static const int kSmallMaximumSlots = 10;

  // FastNewFunctionContext can only allocate closures which fit in the
  // new space.
40 41
  STATIC_ASSERT(Context::SizeFor(kMaximumSlots + Context::MIN_CONTEXT_SLOTS) <
                kMaxRegularHeapObjectSize);
42 43 44 45
};

}  // namespace internal
}  // namespace v8
46 47

#endif  // V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_