Line data Source code
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 :
11 : namespace v8 {
12 : namespace internal {
13 :
14 : class ConstructorBuiltins {
15 : public:
16 : static int MaximumFunctionContextSlots() {
17 : return FLAG_test_small_max_function_context_stub_size ? kSmallMaximumSlots
18 : : kMaximumSlots;
19 : }
20 :
21 : // Maximum number of elements in copied array (chosen so that even an array
22 : // backed by a double backing store will fit into new-space).
23 : static const int kMaximumClonedShallowArrayElements =
24 : JSArray::kInitialMaxFastElementArray * kPointerSize / kDoubleSize;
25 :
26 : // Maximum number of properties in copied objects.
27 : static const int kMaximumClonedShallowObjectProperties = 6;
28 : static int FastCloneShallowObjectPropertiesCount(int literal_length) {
29 : // This heuristic of setting empty literals to have
30 : // kInitialGlobalObjectUnusedPropertiesCount must remain in-sync with the
31 : // runtime.
32 : // TODO(verwaest): Unify this with the heuristic in the runtime.
33 : return literal_length == 0
34 : ? JSObject::kInitialGlobalObjectUnusedPropertiesCount
35 347263 : : literal_length;
36 : }
37 :
38 : private:
39 : static const int kMaximumSlots = 0x8000;
40 : static const int kSmallMaximumSlots = 10;
41 :
42 : // FastNewFunctionContext can only allocate closures which fit in the
43 : // new space.
44 : STATIC_ASSERT(((kMaximumSlots + Context::MIN_CONTEXT_SLOTS) * kPointerSize +
45 : FixedArray::kHeaderSize) < kMaxRegularHeapObjectSize);
46 : };
47 :
48 : } // namespace internal
49 : } // namespace v8
50 :
51 : #endif // V8_BUILTINS_BUILTINS_CONSTRUCTOR_H_
|