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

Side by Side Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1657863004: [turbofan] Introduce proper ObjectIsReceiver operator. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 10 months 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 | « no previous file | src/compiler/js-native-context-specialization.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/compiler/js-intrinsic-lowering.h" 5 #include "src/compiler/js-intrinsic-lowering.h"
6 6
7 #include <stack> 7 #include <stack>
8 8
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge); 221 Node* ephi = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, merge);
222 ReplaceWithValue(node, node, ephi); 222 ReplaceWithValue(node, node, ephi);
223 223
224 // Turn the {node} into a Phi. 224 // Turn the {node} into a Phi.
225 return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue, 225 return Change(node, common()->Phi(MachineRepresentation::kTagged, 2), vtrue,
226 vfalse, merge); 226 vfalse, merge);
227 } 227 }
228 228
229 229
230 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) { 230 Reduction JSIntrinsicLowering::ReduceIsJSReceiver(Node* node) {
231 Node* value = NodeProperties::GetValueInput(node, 0); 231 return Change(node, simplified()->ObjectIsReceiver());
232 Type* value_type = NodeProperties::GetType(value);
233 Node* effect = NodeProperties::GetEffectInput(node);
234 Node* control = NodeProperties::GetControlInput(node);
235 if (value_type->Is(Type::Receiver())) {
236 value = jsgraph()->TrueConstant();
237 } else if (!value_type->Maybe(Type::Receiver())) {
238 value = jsgraph()->FalseConstant();
239 } else {
240 // if (%_IsSmi(value)) {
241 // return false;
242 // } else {
243 // return FIRST_JS_RECEIVER_TYPE <= %_GetInstanceType(%_GetMap(value))
244 // }
245 STATIC_ASSERT(LAST_TYPE == LAST_JS_RECEIVER_TYPE);
246
247 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value);
248 Node* branch = graph()->NewNode(common()->Branch(), check, control);
249
250 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
251 Node* etrue = effect;
252 Node* vtrue = jsgraph()->FalseConstant();
253
254 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
255 Node* efalse = graph()->NewNode(
256 simplified()->LoadField(AccessBuilder::ForMapInstanceType()),
257 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForMap()),
258 value, effect, if_false),
259 effect, if_false);
260 Node* vfalse = graph()->NewNode(
261 machine()->Uint32LessThanOrEqual(),
262 jsgraph()->Int32Constant(FIRST_JS_RECEIVER_TYPE), efalse);
263
264 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
265 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
266 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
267 vtrue, vfalse, control);
268 }
269 ReplaceWithValue(node, node, effect, control);
270 return Replace(value);
271 } 232 }
272 233
273 234
274 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) { 235 Reduction JSIntrinsicLowering::ReduceIsSmi(Node* node) {
275 return Change(node, simplified()->ObjectIsSmi()); 236 return Change(node, simplified()->ObjectIsSmi());
276 } 237 }
277 238
278 239
279 Reduction JSIntrinsicLowering::ReduceJSValueGetValue(Node* node) { 240 Reduction JSIntrinsicLowering::ReduceJSValueGetValue(Node* node) {
280 Node* value = NodeProperties::GetValueInput(node, 0); 241 Node* value = NodeProperties::GetValueInput(node, 0);
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 641 }
681 642
682 643
683 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 644 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
684 return jsgraph()->simplified(); 645 return jsgraph()->simplified();
685 } 646 }
686 647
687 } // namespace compiler 648 } // namespace compiler
688 } // namespace internal 649 } // namespace internal
689 } // namespace v8 650 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/js-native-context-specialization.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698