OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2017 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
| 5 #ifndef V8_BUILTINS_BUILTINS_CONSTRUCTOR_GEN_H_ |
| 6 #define V8_BUILTINS_BUILTINS_CONSTRUCTOR_GEN_H_ |
| 7 |
5 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
6 | 9 |
7 namespace v8 { | 10 namespace v8 { |
8 namespace internal { | 11 namespace internal { |
9 | 12 |
10 class ConstructorBuiltinsAssembler : public CodeStubAssembler { | 13 class ConstructorBuiltinsAssembler : public CodeStubAssembler { |
11 public: | 14 public: |
12 explicit ConstructorBuiltinsAssembler(compiler::CodeAssemblerState* state) | 15 explicit ConstructorBuiltinsAssembler(compiler::CodeAssemblerState* state) |
13 : CodeStubAssembler(state) {} | 16 : CodeStubAssembler(state) {} |
14 | 17 |
15 Node* EmitFastNewClosure(Node* shared_info, Node* feedback_vector, Node* slot, | 18 Node* EmitFastNewClosure(Node* shared_info, Node* feedback_vector, Node* slot, |
16 Node* context); | 19 Node* context); |
17 Node* EmitFastNewFunctionContext(Node* closure, Node* slots, Node* context, | 20 Node* EmitFastNewFunctionContext(Node* closure, Node* slots, Node* context, |
18 ScopeType scope_type); | 21 ScopeType scope_type); |
19 static int MaximumFunctionContextSlots(); | |
20 | 22 |
21 Node* EmitFastCloneRegExp(Node* closure, Node* literal_index, Node* pattern, | 23 Node* EmitFastCloneRegExp(Node* closure, Node* literal_index, Node* pattern, |
22 Node* flags, Node* context); | 24 Node* flags, Node* context); |
23 Node* EmitFastCloneShallowArray(Node* closure, Node* literal_index, | 25 Node* EmitFastCloneShallowArray(Node* closure, Node* literal_index, |
24 Node* context, Label* call_runtime, | 26 Node* context, Label* call_runtime, |
25 AllocationSiteMode allocation_site_mode); | 27 AllocationSiteMode allocation_site_mode); |
26 | 28 |
27 // Maximum number of elements in copied array (chosen so that even an array | |
28 // backed by a double backing store will fit into new-space). | |
29 static const int kMaximumClonedShallowArrayElements = | |
30 JSArray::kInitialMaxFastElementArray * kPointerSize / kDoubleSize; | |
31 | |
32 void CreateFastCloneShallowArrayBuiltin( | 29 void CreateFastCloneShallowArrayBuiltin( |
33 AllocationSiteMode allocation_site_mode); | 30 AllocationSiteMode allocation_site_mode); |
34 | 31 |
35 // Maximum number of properties in copied objects. | |
36 static const int kMaximumClonedShallowObjectProperties = 6; | |
37 static int FastCloneShallowObjectPropertiesCount(int literal_length); | |
38 Node* EmitFastCloneShallowObject(Label* call_runtime, Node* closure, | 32 Node* EmitFastCloneShallowObject(Label* call_runtime, Node* closure, |
39 Node* literals_index, | 33 Node* literals_index, |
40 Node* properties_count); | 34 Node* properties_count); |
41 void CreateFastCloneShallowObjectBuiltin(int properties_count); | 35 void CreateFastCloneShallowObjectBuiltin(int properties_count); |
42 | 36 |
43 Node* EmitFastNewObject(Node* context, Node* target, Node* new_target); | 37 Node* EmitFastNewObject(Node* context, Node* target, Node* new_target); |
44 | 38 |
45 Node* EmitFastNewObject(Node* context, Node* target, Node* new_target, | 39 Node* EmitFastNewObject(Node* context, Node* target, Node* new_target, |
46 Label* call_runtime); | 40 Label* call_runtime); |
47 | 41 |
48 private: | 42 private: |
49 static const int kMaximumSlots = 0x8000; | |
50 static const int kSmallMaximumSlots = 10; | |
51 | |
52 Node* NonEmptyShallowClone(Node* boilerplate, Node* boilerplate_map, | 43 Node* NonEmptyShallowClone(Node* boilerplate, Node* boilerplate_map, |
53 Node* boilerplate_elements, Node* allocation_site, | 44 Node* boilerplate_elements, Node* allocation_site, |
54 Node* capacity, ElementsKind kind); | 45 Node* capacity, ElementsKind kind); |
55 | |
56 // FastNewFunctionContext can only allocate closures which fit in the | |
57 // new space. | |
58 STATIC_ASSERT(((kMaximumSlots + Context::MIN_CONTEXT_SLOTS) * kPointerSize + | |
59 FixedArray::kHeaderSize) < kMaxRegularHeapObjectSize); | |
60 }; | 46 }; |
61 | 47 |
62 } // namespace internal | 48 } // namespace internal |
63 } // namespace v8 | 49 } // namespace v8 |
| 50 |
| 51 #endif // V8_BUILTINS_BUILTINS_CONSTRUCTOR_GEN_H_ |
OLD | NEW |