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

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

Issue 1657213002: [turbofan] Constant-fold ToNumber conversions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Preserve identity of ToNumber w/ number nodes. 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/compilation-dependencies.h" 6 #include "src/compilation-dependencies.h"
7 #include "src/compiler/access-builder.h" 7 #include "src/compiler/access-builder.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-typed-lowering.h" 9 #include "src/compiler/js-typed-lowering.h"
10 #include "src/compiler/linkage.h" 10 #include "src/compiler/linkage.h"
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 Node* vfalse = NodeProperties::GetValueInput(input, 2); 773 Node* vfalse = NodeProperties::GetValueInput(input, 2);
774 Type* vfalse_type = NodeProperties::GetType(vfalse); 774 Type* vfalse_type = NodeProperties::GetType(vfalse);
775 if (vtrue_type->Is(Type::Undefined()) && vfalse_type->Is(Type::Number())) { 775 if (vtrue_type->Is(Type::Undefined()) && vfalse_type->Is(Type::Number())) {
776 if (check->opcode() == IrOpcode::kNumberIsHoleNaN && 776 if (check->opcode() == IrOpcode::kNumberIsHoleNaN &&
777 check->InputAt(0) == vfalse) { 777 check->InputAt(0) == vfalse) {
778 // JSToNumber(Select(NumberIsHoleNaN(x), y:undefined, x:number)) => x 778 // JSToNumber(Select(NumberIsHoleNaN(x), y:undefined, x:number)) => x
779 return Replace(vfalse); 779 return Replace(vfalse);
780 } 780 }
781 } 781 }
782 } 782 }
783 // Check if we have a cached conversion. 783 // Try constant-folding of JSToNumber with constant inputs.
784 Type* input_type = NodeProperties::GetType(input); 784 Type* input_type = NodeProperties::GetType(input);
785 if (input_type->IsConstant()) {
786 Handle<Object> input_value = input_type->AsConstant()->Value();
787 if (input_value->IsString()) {
788 return Replace(jsgraph()->Constant(
789 String::ToNumber(Handle<String>::cast(input_value))));
790 } else if (input_value->IsOddball()) {
791 return Replace(jsgraph()->Constant(
792 Oddball::ToNumber(Handle<Oddball>::cast(input_value))));
793 }
794 }
785 if (input_type->Is(Type::Number())) { 795 if (input_type->Is(Type::Number())) {
786 // JSToNumber(x:number) => x 796 // JSToNumber(x:number) => x
787 return Changed(input); 797 return Changed(input);
788 } 798 }
789 if (input_type->Is(Type::Undefined())) { 799 if (input_type->Is(Type::Undefined())) {
790 // JSToNumber(undefined) => #NaN 800 // JSToNumber(undefined) => #NaN
791 return Replace(jsgraph()->NaNConstant()); 801 return Replace(jsgraph()->NaNConstant());
792 } 802 }
793 if (input_type->Is(Type::Null())) { 803 if (input_type->Is(Type::Null())) {
794 // JSToNumber(null) => #0 804 // JSToNumber(null) => #0
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after
2671 } 2681 }
2672 2682
2673 2683
2674 CompilationDependencies* JSTypedLowering::dependencies() const { 2684 CompilationDependencies* JSTypedLowering::dependencies() const {
2675 return dependencies_; 2685 return dependencies_;
2676 } 2686 }
2677 2687
2678 } // namespace compiler 2688 } // namespace compiler
2679 } // namespace internal 2689 } // namespace internal
2680 } // namespace v8 2690 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698