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