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 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
10 #include "src/uri.h" | 10 #include "src/uri.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 94 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
95 isolate, function, Compiler::GetFunctionFromString( | 95 isolate, function, Compiler::GetFunctionFromString( |
96 handle(target->native_context(), isolate), | 96 handle(target->native_context(), isolate), |
97 Handle<String>::cast(x), NO_PARSE_RESTRICTION)); | 97 Handle<String>::cast(x), NO_PARSE_RESTRICTION)); |
98 RETURN_RESULT_OR_FAILURE( | 98 RETURN_RESULT_OR_FAILURE( |
99 isolate, | 99 isolate, |
100 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); | 100 Execution::Call(isolate, function, target_global_proxy, 0, nullptr)); |
101 } | 101 } |
102 | 102 |
103 // ES6 section 18.2.2 isFinite ( number ) | 103 // ES6 section 18.2.2 isFinite ( number ) |
104 void Builtins::Generate_GlobalIsFinite(compiler::CodeAssemblerState* state) { | 104 void Builtins::Generate_GlobalIsFinite(CodeStubAssembler* assembler) { |
105 typedef CodeStubAssembler::Label Label; | 105 typedef CodeStubAssembler::Label Label; |
106 typedef compiler::Node Node; | 106 typedef compiler::Node Node; |
107 typedef CodeStubAssembler::Variable Variable; | 107 typedef CodeStubAssembler::Variable Variable; |
108 CodeStubAssembler assembler(state); | |
109 | 108 |
110 Node* context = assembler.Parameter(4); | 109 Node* context = assembler->Parameter(4); |
111 | 110 |
112 Label return_true(&assembler), return_false(&assembler); | 111 Label return_true(assembler), return_false(assembler); |
113 | 112 |
114 // We might need to loop once for ToNumber conversion. | 113 // We might need to loop once for ToNumber conversion. |
115 Variable var_num(&assembler, MachineRepresentation::kTagged); | 114 Variable var_num(assembler, MachineRepresentation::kTagged); |
116 Label loop(&assembler, &var_num); | 115 Label loop(assembler, &var_num); |
117 var_num.Bind(assembler.Parameter(1)); | 116 var_num.Bind(assembler->Parameter(1)); |
118 assembler.Goto(&loop); | 117 assembler->Goto(&loop); |
119 assembler.Bind(&loop); | 118 assembler->Bind(&loop); |
120 { | 119 { |
121 // Load the current {num} value. | 120 // Load the current {num} value. |
122 Node* num = var_num.value(); | 121 Node* num = var_num.value(); |
123 | 122 |
124 // Check if {num} is a Smi or a HeapObject. | 123 // Check if {num} is a Smi or a HeapObject. |
125 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_true); | 124 assembler->GotoIf(assembler->TaggedIsSmi(num), &return_true); |
126 | 125 |
127 // Check if {num} is a HeapNumber. | 126 // Check if {num} is a HeapNumber. |
128 Label if_numisheapnumber(&assembler), | 127 Label if_numisheapnumber(assembler), |
129 if_numisnotheapnumber(&assembler, Label::kDeferred); | 128 if_numisnotheapnumber(assembler, Label::kDeferred); |
130 assembler.Branch(assembler.WordEqual(assembler.LoadMap(num), | 129 assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), |
131 assembler.HeapNumberMapConstant()), | 130 assembler->HeapNumberMapConstant()), |
132 &if_numisheapnumber, &if_numisnotheapnumber); | 131 &if_numisheapnumber, &if_numisnotheapnumber); |
133 | 132 |
134 assembler.Bind(&if_numisheapnumber); | 133 assembler->Bind(&if_numisheapnumber); |
135 { | 134 { |
136 // Check if {num} contains a finite, non-NaN value. | 135 // Check if {num} contains a finite, non-NaN value. |
137 Node* num_value = assembler.LoadHeapNumberValue(num); | 136 Node* num_value = assembler->LoadHeapNumberValue(num); |
138 assembler.BranchIfFloat64IsNaN(assembler.Float64Sub(num_value, num_value), | 137 assembler->BranchIfFloat64IsNaN( |
139 &return_false, &return_true); | 138 assembler->Float64Sub(num_value, num_value), &return_false, |
| 139 &return_true); |
140 } | 140 } |
141 | 141 |
142 assembler.Bind(&if_numisnotheapnumber); | 142 assembler->Bind(&if_numisnotheapnumber); |
143 { | 143 { |
144 // Need to convert {num} to a Number first. | 144 // Need to convert {num} to a Number first. |
145 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate()); | 145 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); |
146 var_num.Bind(assembler.CallStub(callable, context, num)); | 146 var_num.Bind(assembler->CallStub(callable, context, num)); |
147 assembler.Goto(&loop); | 147 assembler->Goto(&loop); |
148 } | 148 } |
149 } | 149 } |
150 | 150 |
151 assembler.Bind(&return_true); | 151 assembler->Bind(&return_true); |
152 assembler.Return(assembler.BooleanConstant(true)); | 152 assembler->Return(assembler->BooleanConstant(true)); |
153 | 153 |
154 assembler.Bind(&return_false); | 154 assembler->Bind(&return_false); |
155 assembler.Return(assembler.BooleanConstant(false)); | 155 assembler->Return(assembler->BooleanConstant(false)); |
156 } | 156 } |
157 | 157 |
158 // ES6 section 18.2.3 isNaN ( number ) | 158 // ES6 section 18.2.3 isNaN ( number ) |
159 void Builtins::Generate_GlobalIsNaN(compiler::CodeAssemblerState* state) { | 159 void Builtins::Generate_GlobalIsNaN(CodeStubAssembler* assembler) { |
160 typedef CodeStubAssembler::Label Label; | 160 typedef CodeStubAssembler::Label Label; |
161 typedef compiler::Node Node; | 161 typedef compiler::Node Node; |
162 typedef CodeStubAssembler::Variable Variable; | 162 typedef CodeStubAssembler::Variable Variable; |
163 CodeStubAssembler assembler(state); | |
164 | 163 |
165 Node* context = assembler.Parameter(4); | 164 Node* context = assembler->Parameter(4); |
166 | 165 |
167 Label return_true(&assembler), return_false(&assembler); | 166 Label return_true(assembler), return_false(assembler); |
168 | 167 |
169 // We might need to loop once for ToNumber conversion. | 168 // We might need to loop once for ToNumber conversion. |
170 Variable var_num(&assembler, MachineRepresentation::kTagged); | 169 Variable var_num(assembler, MachineRepresentation::kTagged); |
171 Label loop(&assembler, &var_num); | 170 Label loop(assembler, &var_num); |
172 var_num.Bind(assembler.Parameter(1)); | 171 var_num.Bind(assembler->Parameter(1)); |
173 assembler.Goto(&loop); | 172 assembler->Goto(&loop); |
174 assembler.Bind(&loop); | 173 assembler->Bind(&loop); |
175 { | 174 { |
176 // Load the current {num} value. | 175 // Load the current {num} value. |
177 Node* num = var_num.value(); | 176 Node* num = var_num.value(); |
178 | 177 |
179 // Check if {num} is a Smi or a HeapObject. | 178 // Check if {num} is a Smi or a HeapObject. |
180 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_false); | 179 assembler->GotoIf(assembler->TaggedIsSmi(num), &return_false); |
181 | 180 |
182 // Check if {num} is a HeapNumber. | 181 // Check if {num} is a HeapNumber. |
183 Label if_numisheapnumber(&assembler), | 182 Label if_numisheapnumber(assembler), |
184 if_numisnotheapnumber(&assembler, Label::kDeferred); | 183 if_numisnotheapnumber(assembler, Label::kDeferred); |
185 assembler.Branch(assembler.WordEqual(assembler.LoadMap(num), | 184 assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), |
186 assembler.HeapNumberMapConstant()), | 185 assembler->HeapNumberMapConstant()), |
187 &if_numisheapnumber, &if_numisnotheapnumber); | 186 &if_numisheapnumber, &if_numisnotheapnumber); |
188 | 187 |
189 assembler.Bind(&if_numisheapnumber); | 188 assembler->Bind(&if_numisheapnumber); |
190 { | 189 { |
191 // Check if {num} contains a NaN. | 190 // Check if {num} contains a NaN. |
192 Node* num_value = assembler.LoadHeapNumberValue(num); | 191 Node* num_value = assembler->LoadHeapNumberValue(num); |
193 assembler.BranchIfFloat64IsNaN(num_value, &return_true, &return_false); | 192 assembler->BranchIfFloat64IsNaN(num_value, &return_true, &return_false); |
194 } | 193 } |
195 | 194 |
196 assembler.Bind(&if_numisnotheapnumber); | 195 assembler->Bind(&if_numisnotheapnumber); |
197 { | 196 { |
198 // Need to convert {num} to a Number first. | 197 // Need to convert {num} to a Number first. |
199 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate()); | 198 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); |
200 var_num.Bind(assembler.CallStub(callable, context, num)); | 199 var_num.Bind(assembler->CallStub(callable, context, num)); |
201 assembler.Goto(&loop); | 200 assembler->Goto(&loop); |
202 } | 201 } |
203 } | 202 } |
204 | 203 |
205 assembler.Bind(&return_true); | 204 assembler->Bind(&return_true); |
206 assembler.Return(assembler.BooleanConstant(true)); | 205 assembler->Return(assembler->BooleanConstant(true)); |
207 | 206 |
208 assembler.Bind(&return_false); | 207 assembler->Bind(&return_false); |
209 assembler.Return(assembler.BooleanConstant(false)); | 208 assembler->Return(assembler->BooleanConstant(false)); |
210 } | 209 } |
211 | 210 |
212 } // namespace internal | 211 } // namespace internal |
213 } // namespace v8 | 212 } // namespace v8 |
OLD | NEW |