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/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 #include "src/interface-descriptors.h" | 7 #include "src/interface-descriptors.h" |
8 #include "src/macro-assembler.h" | 8 #include "src/macro-assembler.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 | 48 |
49 void Builtins::Generate_StackCheck(MacroAssembler* masm) { | 49 void Builtins::Generate_StackCheck(MacroAssembler* masm) { |
50 masm->TailCallRuntime(Runtime::kStackGuard); | 50 masm->TailCallRuntime(Runtime::kStackGuard); |
51 } | 51 } |
52 | 52 |
53 // ----------------------------------------------------------------------------- | 53 // ----------------------------------------------------------------------------- |
54 // TurboFan support builtins. | 54 // TurboFan support builtins. |
55 | 55 |
56 void Builtins::Generate_CopyFastSmiOrObjectElements( | 56 void Builtins::Generate_CopyFastSmiOrObjectElements( |
57 compiler::CodeAssemblerState* state) { | 57 CodeStubAssembler* assembler) { |
58 typedef CodeStubAssembler::Label Label; | 58 typedef CodeStubAssembler::Label Label; |
59 typedef compiler::Node Node; | 59 typedef compiler::Node Node; |
60 typedef CopyFastSmiOrObjectElementsDescriptor Descriptor; | 60 typedef CopyFastSmiOrObjectElementsDescriptor Descriptor; |
61 CodeStubAssembler assembler(state); | |
62 | 61 |
63 Node* object = assembler.Parameter(Descriptor::kObject); | 62 Node* object = assembler->Parameter(Descriptor::kObject); |
64 | 63 |
65 // Load the {object}s elements. | 64 // Load the {object}s elements. |
66 Node* source = assembler.LoadObjectField(object, JSObject::kElementsOffset); | 65 Node* source = assembler->LoadObjectField(object, JSObject::kElementsOffset); |
67 | 66 |
68 CodeStubAssembler::ParameterMode mode = assembler.OptimalParameterMode(); | 67 CodeStubAssembler::ParameterMode mode = assembler->OptimalParameterMode(); |
69 Node* length = assembler.UntagParameter( | 68 Node* length = assembler->UntagParameter( |
70 assembler.LoadFixedArrayBaseLength(source), mode); | 69 assembler->LoadFixedArrayBaseLength(source), mode); |
71 | 70 |
72 // Check if we can allocate in new space. | 71 // Check if we can allocate in new space. |
73 ElementsKind kind = FAST_ELEMENTS; | 72 ElementsKind kind = FAST_ELEMENTS; |
74 int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); | 73 int max_elements = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(kind); |
75 Label if_newspace(&assembler), if_oldspace(&assembler); | 74 Label if_newspace(assembler), if_oldspace(assembler); |
76 assembler.Branch( | 75 assembler->Branch( |
77 assembler.UintPtrLessThan( | 76 assembler->UintPtrLessThan( |
78 length, assembler.IntPtrOrSmiConstant(max_elements, mode)), | 77 length, assembler->IntPtrOrSmiConstant(max_elements, mode)), |
79 &if_newspace, &if_oldspace); | 78 &if_newspace, &if_oldspace); |
80 | 79 |
81 assembler.Bind(&if_newspace); | 80 assembler->Bind(&if_newspace); |
82 { | 81 { |
83 Node* target = assembler.AllocateFixedArray(kind, length, mode); | 82 Node* target = assembler->AllocateFixedArray(kind, length, mode); |
84 assembler.CopyFixedArrayElements(kind, source, target, length, | 83 assembler->CopyFixedArrayElements(kind, source, target, length, |
85 SKIP_WRITE_BARRIER, mode); | 84 SKIP_WRITE_BARRIER, mode); |
86 assembler.StoreObjectField(object, JSObject::kElementsOffset, target); | 85 assembler->StoreObjectField(object, JSObject::kElementsOffset, target); |
87 assembler.Return(target); | 86 assembler->Return(target); |
88 } | 87 } |
89 | 88 |
90 assembler.Bind(&if_oldspace); | 89 assembler->Bind(&if_oldspace); |
91 { | 90 { |
92 Node* target = assembler.AllocateFixedArray(kind, length, mode, | 91 Node* target = assembler->AllocateFixedArray( |
93 CodeStubAssembler::kPretenured); | 92 kind, length, mode, CodeStubAssembler::kPretenured); |
94 assembler.CopyFixedArrayElements(kind, source, target, length, | 93 assembler->CopyFixedArrayElements(kind, source, target, length, |
95 UPDATE_WRITE_BARRIER, mode); | 94 UPDATE_WRITE_BARRIER, mode); |
96 assembler.StoreObjectField(object, JSObject::kElementsOffset, target); | 95 assembler->StoreObjectField(object, JSObject::kElementsOffset, target); |
97 assembler.Return(target); | 96 assembler->Return(target); |
98 } | 97 } |
99 } | 98 } |
100 | 99 |
101 void Builtins::Generate_GrowFastDoubleElements( | 100 void Builtins::Generate_GrowFastDoubleElements(CodeStubAssembler* assembler) { |
102 compiler::CodeAssemblerState* state) { | |
103 typedef CodeStubAssembler::Label Label; | 101 typedef CodeStubAssembler::Label Label; |
104 typedef compiler::Node Node; | 102 typedef compiler::Node Node; |
105 typedef GrowArrayElementsDescriptor Descriptor; | 103 typedef GrowArrayElementsDescriptor Descriptor; |
106 CodeStubAssembler assembler(state); | |
107 | 104 |
108 Node* object = assembler.Parameter(Descriptor::kObject); | 105 Node* object = assembler->Parameter(Descriptor::kObject); |
109 Node* key = assembler.Parameter(Descriptor::kKey); | 106 Node* key = assembler->Parameter(Descriptor::kKey); |
110 Node* context = assembler.Parameter(Descriptor::kContext); | 107 Node* context = assembler->Parameter(Descriptor::kContext); |
111 | 108 |
112 Label runtime(&assembler, CodeStubAssembler::Label::kDeferred); | 109 Label runtime(assembler, CodeStubAssembler::Label::kDeferred); |
113 Node* elements = assembler.LoadElements(object); | 110 Node* elements = assembler->LoadElements(object); |
114 elements = assembler.TryGrowElementsCapacity( | 111 elements = assembler->TryGrowElementsCapacity( |
115 object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime); | 112 object, elements, FAST_DOUBLE_ELEMENTS, key, &runtime); |
116 assembler.Return(elements); | 113 assembler->Return(elements); |
117 | 114 |
118 assembler.Bind(&runtime); | 115 assembler->Bind(&runtime); |
119 assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); | 116 assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); |
120 } | 117 } |
121 | 118 |
122 void Builtins::Generate_GrowFastSmiOrObjectElements( | 119 void Builtins::Generate_GrowFastSmiOrObjectElements( |
123 compiler::CodeAssemblerState* state) { | 120 CodeStubAssembler* assembler) { |
124 typedef CodeStubAssembler::Label Label; | 121 typedef CodeStubAssembler::Label Label; |
125 typedef compiler::Node Node; | 122 typedef compiler::Node Node; |
126 typedef GrowArrayElementsDescriptor Descriptor; | 123 typedef GrowArrayElementsDescriptor Descriptor; |
127 CodeStubAssembler assembler(state); | |
128 | 124 |
129 Node* object = assembler.Parameter(Descriptor::kObject); | 125 Node* object = assembler->Parameter(Descriptor::kObject); |
130 Node* key = assembler.Parameter(Descriptor::kKey); | 126 Node* key = assembler->Parameter(Descriptor::kKey); |
131 Node* context = assembler.Parameter(Descriptor::kContext); | 127 Node* context = assembler->Parameter(Descriptor::kContext); |
132 | 128 |
133 Label runtime(&assembler, CodeStubAssembler::Label::kDeferred); | 129 Label runtime(assembler, CodeStubAssembler::Label::kDeferred); |
134 Node* elements = assembler.LoadElements(object); | 130 Node* elements = assembler->LoadElements(object); |
135 elements = assembler.TryGrowElementsCapacity(object, elements, FAST_ELEMENTS, | 131 elements = assembler->TryGrowElementsCapacity(object, elements, FAST_ELEMENTS, |
136 key, &runtime); | 132 key, &runtime); |
137 assembler.Return(elements); | 133 assembler->Return(elements); |
138 | 134 |
139 assembler.Bind(&runtime); | 135 assembler->Bind(&runtime); |
140 assembler.TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); | 136 assembler->TailCallRuntime(Runtime::kGrowArrayElements, context, object, key); |
141 } | 137 } |
142 | 138 |
143 } // namespace internal | 139 } // namespace internal |
144 } // namespace v8 | 140 } // namespace v8 |
OLD | NEW |