Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(217)

Side by Side Diff: src/builtins/builtins-global.cc

Issue 2502293002: Reland of [refactoring] Split CodeAssemblerState out of CodeAssembler (Closed)
Patch Set: fix Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/builtins/builtins-generator.cc ('k') | src/builtins/builtins-handler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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(CodeStubAssembler* assembler) { 104 void Builtins::Generate_GlobalIsFinite(compiler::CodeAssemblerState* state) {
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);
108 109
109 Node* context = assembler->Parameter(4); 110 Node* context = assembler.Parameter(4);
110 111
111 Label return_true(assembler), return_false(assembler); 112 Label return_true(&assembler), return_false(&assembler);
112 113
113 // We might need to loop once for ToNumber conversion. 114 // We might need to loop once for ToNumber conversion.
114 Variable var_num(assembler, MachineRepresentation::kTagged); 115 Variable var_num(&assembler, MachineRepresentation::kTagged);
115 Label loop(assembler, &var_num); 116 Label loop(&assembler, &var_num);
116 var_num.Bind(assembler->Parameter(1)); 117 var_num.Bind(assembler.Parameter(1));
117 assembler->Goto(&loop); 118 assembler.Goto(&loop);
118 assembler->Bind(&loop); 119 assembler.Bind(&loop);
119 { 120 {
120 // Load the current {num} value. 121 // Load the current {num} value.
121 Node* num = var_num.value(); 122 Node* num = var_num.value();
122 123
123 // Check if {num} is a Smi or a HeapObject. 124 // Check if {num} is a Smi or a HeapObject.
124 assembler->GotoIf(assembler->TaggedIsSmi(num), &return_true); 125 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_true);
125 126
126 // Check if {num} is a HeapNumber. 127 // Check if {num} is a HeapNumber.
127 Label if_numisheapnumber(assembler), 128 Label if_numisheapnumber(&assembler),
128 if_numisnotheapnumber(assembler, Label::kDeferred); 129 if_numisnotheapnumber(&assembler, Label::kDeferred);
129 assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), 130 assembler.Branch(assembler.WordEqual(assembler.LoadMap(num),
130 assembler->HeapNumberMapConstant()), 131 assembler.HeapNumberMapConstant()),
131 &if_numisheapnumber, &if_numisnotheapnumber); 132 &if_numisheapnumber, &if_numisnotheapnumber);
132 133
133 assembler->Bind(&if_numisheapnumber); 134 assembler.Bind(&if_numisheapnumber);
134 { 135 {
135 // Check if {num} contains a finite, non-NaN value. 136 // Check if {num} contains a finite, non-NaN value.
136 Node* num_value = assembler->LoadHeapNumberValue(num); 137 Node* num_value = assembler.LoadHeapNumberValue(num);
137 assembler->BranchIfFloat64IsNaN( 138 assembler.BranchIfFloat64IsNaN(assembler.Float64Sub(num_value, num_value),
138 assembler->Float64Sub(num_value, num_value), &return_false, 139 &return_false, &return_true);
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(CodeStubAssembler* assembler) { 159 void Builtins::Generate_GlobalIsNaN(compiler::CodeAssemblerState* state) {
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);
163 164
164 Node* context = assembler->Parameter(4); 165 Node* context = assembler.Parameter(4);
165 166
166 Label return_true(assembler), return_false(assembler); 167 Label return_true(&assembler), return_false(&assembler);
167 168
168 // We might need to loop once for ToNumber conversion. 169 // We might need to loop once for ToNumber conversion.
169 Variable var_num(assembler, MachineRepresentation::kTagged); 170 Variable var_num(&assembler, MachineRepresentation::kTagged);
170 Label loop(assembler, &var_num); 171 Label loop(&assembler, &var_num);
171 var_num.Bind(assembler->Parameter(1)); 172 var_num.Bind(assembler.Parameter(1));
172 assembler->Goto(&loop); 173 assembler.Goto(&loop);
173 assembler->Bind(&loop); 174 assembler.Bind(&loop);
174 { 175 {
175 // Load the current {num} value. 176 // Load the current {num} value.
176 Node* num = var_num.value(); 177 Node* num = var_num.value();
177 178
178 // Check if {num} is a Smi or a HeapObject. 179 // Check if {num} is a Smi or a HeapObject.
179 assembler->GotoIf(assembler->TaggedIsSmi(num), &return_false); 180 assembler.GotoIf(assembler.TaggedIsSmi(num), &return_false);
180 181
181 // Check if {num} is a HeapNumber. 182 // Check if {num} is a HeapNumber.
182 Label if_numisheapnumber(assembler), 183 Label if_numisheapnumber(&assembler),
183 if_numisnotheapnumber(assembler, Label::kDeferred); 184 if_numisnotheapnumber(&assembler, Label::kDeferred);
184 assembler->Branch(assembler->WordEqual(assembler->LoadMap(num), 185 assembler.Branch(assembler.WordEqual(assembler.LoadMap(num),
185 assembler->HeapNumberMapConstant()), 186 assembler.HeapNumberMapConstant()),
186 &if_numisheapnumber, &if_numisnotheapnumber); 187 &if_numisheapnumber, &if_numisnotheapnumber);
187 188
188 assembler->Bind(&if_numisheapnumber); 189 assembler.Bind(&if_numisheapnumber);
189 { 190 {
190 // Check if {num} contains a NaN. 191 // Check if {num} contains a NaN.
191 Node* num_value = assembler->LoadHeapNumberValue(num); 192 Node* num_value = assembler.LoadHeapNumberValue(num);
192 assembler->BranchIfFloat64IsNaN(num_value, &return_true, &return_false); 193 assembler.BranchIfFloat64IsNaN(num_value, &return_true, &return_false);
193 } 194 }
194 195
195 assembler->Bind(&if_numisnotheapnumber); 196 assembler.Bind(&if_numisnotheapnumber);
196 { 197 {
197 // Need to convert {num} to a Number first. 198 // Need to convert {num} to a Number first.
198 Callable callable = CodeFactory::NonNumberToNumber(assembler->isolate()); 199 Callable callable = CodeFactory::NonNumberToNumber(assembler.isolate());
199 var_num.Bind(assembler->CallStub(callable, context, num)); 200 var_num.Bind(assembler.CallStub(callable, context, num));
200 assembler->Goto(&loop); 201 assembler.Goto(&loop);
201 } 202 }
202 } 203 }
203 204
204 assembler->Bind(&return_true); 205 assembler.Bind(&return_true);
205 assembler->Return(assembler->BooleanConstant(true)); 206 assembler.Return(assembler.BooleanConstant(true));
206 207
207 assembler->Bind(&return_false); 208 assembler.Bind(&return_false);
208 assembler->Return(assembler->BooleanConstant(false)); 209 assembler.Return(assembler.BooleanConstant(false));
209 } 210 }
210 211
211 } // namespace internal 212 } // namespace internal
212 } // namespace v8 213 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins-generator.cc ('k') | src/builtins/builtins-handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698