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

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

Issue 1846683006: [stubs] Introduce ToIntegerStub and unify the handling of %_ToInteger. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 8 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 | « src/code-stubs.cc ('k') | src/crankshaft/hydrogen.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 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 } 345 }
346 346
347 347
348 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) { 348 Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
349 return Change(node, CodeFactory::SubString(isolate()), 3); 349 return Change(node, CodeFactory::SubString(isolate()), 3);
350 } 350 }
351 351
352 352
353 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) { 353 Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
354 Node* value = NodeProperties::GetValueInput(node, 0); 354 Node* value = NodeProperties::GetValueInput(node, 0);
355 Node* context = NodeProperties::GetContextInput(node);
356 Node* frame_state = NodeProperties::GetFrameStateInput(node, 0);
357 Node* effect = NodeProperties::GetEffectInput(node);
358 Node* control = NodeProperties::GetControlInput(node);
359 355
360 // ToInteger is a no-op on integer values and -0. 356 // ToInteger is a no-op on integer values and -0.
361 Type* value_type = NodeProperties::GetType(value); 357 Type* value_type = NodeProperties::GetType(value);
362 if (value_type->Is(type_cache().kIntegerOrMinusZero)) { 358 if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
363 ReplaceWithValue(node, value); 359 ReplaceWithValue(node, value);
364 return Replace(value); 360 return Replace(value);
365 } 361 }
366 362
367 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), value); 363 return Change(node, CodeFactory::ToInteger(isolate()), 0);
368 Node* branch =
369 graph()->NewNode(common()->Branch(BranchHint::kTrue), check, control);
370
371 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
372 Node* etrue = effect;
373 Node* vtrue =
374 graph()->NewNode(common()->Guard(type_cache_.kSmi), value, if_true);
375
376 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
377 Node* efalse = effect;
378 Node* vfalse;
379 {
380 vfalse = efalse =
381 graph()->NewNode(javascript()->CallRuntime(Runtime::kToInteger), value,
382 context, frame_state, efalse, if_false);
383 // TODO(jarin) Intersect the type with integers?
384 NodeProperties::SetType(vfalse, NodeProperties::GetType(node));
385
386 if_false = graph()->NewNode(common()->IfSuccess(), vfalse);
387 }
388
389 control = graph()->NewNode(common()->Merge(2), if_true, if_false);
390 effect = graph()->NewNode(common()->EffectPhi(2), etrue, efalse, control);
391 value = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2),
392 vtrue, vfalse, control);
393
394 // TODO(bmeurer, mstarzinger): Rewire IfException inputs to {vfalse}.
395 ReplaceWithValue(node, value, effect, control);
396 return Changed(value);
397 } 364 }
398 365
399 366
400 Reduction JSIntrinsicLowering::ReduceToName(Node* node) { 367 Reduction JSIntrinsicLowering::ReduceToName(Node* node) {
401 NodeProperties::ChangeOp(node, javascript()->ToName()); 368 NodeProperties::ChangeOp(node, javascript()->ToName());
402 return Changed(node); 369 return Changed(node);
403 } 370 }
404 371
405 372
406 Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) { 373 Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
574 } 541 }
575 542
576 543
577 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const { 544 SimplifiedOperatorBuilder* JSIntrinsicLowering::simplified() const {
578 return jsgraph()->simplified(); 545 return jsgraph()->simplified();
579 } 546 }
580 547
581 } // namespace compiler 548 } // namespace compiler
582 } // namespace internal 549 } // namespace internal
583 } // namespace v8 550 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/crankshaft/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698