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

Unified Diff: src/compiler/js-intrinsic-lowering.cc

Issue 1848243002: [turbofan] Introduce JSToInteger and JSToLength operators. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-intrinsic-lowering.cc
diff --git a/src/compiler/js-intrinsic-lowering.cc b/src/compiler/js-intrinsic-lowering.cc
index 95c1e22d595853e67bb49ca90ad8fb006cfac3b2..6bc1c46672307011aeba3bda367ce1fd4279fc6c 100644
--- a/src/compiler/js-intrinsic-lowering.cc
+++ b/src/compiler/js-intrinsic-lowering.cc
@@ -15,7 +15,6 @@
#include "src/compiler/operator-properties.h"
#include "src/counters.h"
#include "src/objects-inl.h"
-#include "src/type-cache.h"
namespace v8 {
namespace internal {
@@ -23,11 +22,7 @@ namespace compiler {
JSIntrinsicLowering::JSIntrinsicLowering(Editor* editor, JSGraph* jsgraph,
DeoptimizationMode mode)
- : AdvancedReducer(editor),
- jsgraph_(jsgraph),
- mode_(mode),
- type_cache_(TypeCache::Get()) {}
-
+ : AdvancedReducer(editor), jsgraph_(jsgraph), mode_(mode) {}
Reduction JSIntrinsicLowering::Reduce(Node* node) {
if (node->opcode() != IrOpcode::kJSCallRuntime) return NoChange();
@@ -351,16 +346,8 @@ Reduction JSIntrinsicLowering::ReduceSubString(Node* node) {
Reduction JSIntrinsicLowering::ReduceToInteger(Node* node) {
- Node* value = NodeProperties::GetValueInput(node, 0);
-
- // ToInteger is a no-op on integer values and -0.
- Type* value_type = NodeProperties::GetType(value);
- if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
- ReplaceWithValue(node, value);
- return Replace(value);
- }
-
- return Change(node, CodeFactory::ToInteger(isolate()), 0);
+ NodeProperties::ChangeOp(node, javascript()->ToInteger());
+ return Changed(node);
}
@@ -377,38 +364,8 @@ Reduction JSIntrinsicLowering::ReduceToNumber(Node* node) {
Reduction JSIntrinsicLowering::ReduceToLength(Node* node) {
- Node* value = NodeProperties::GetValueInput(node, 0);
- Type* value_type = NodeProperties::GetType(value);
- if (value_type->Is(type_cache().kIntegerOrMinusZero)) {
- if (value_type->Max() <= 0.0) {
- value = jsgraph()->ZeroConstant();
- } else if (value_type->Min() >= kMaxSafeInteger) {
- value = jsgraph()->Constant(kMaxSafeInteger);
- } else {
- if (value_type->Min() <= 0.0) {
- value = graph()->NewNode(
- common()->Select(MachineRepresentation::kTagged),
- graph()->NewNode(simplified()->NumberLessThanOrEqual(), value,
- jsgraph()->ZeroConstant()),
- jsgraph()->ZeroConstant(), value);
- value_type = Type::Range(0.0, value_type->Max(), graph()->zone());
- NodeProperties::SetType(value, value_type);
- }
- if (value_type->Max() > kMaxSafeInteger) {
- value = graph()->NewNode(
- common()->Select(MachineRepresentation::kTagged),
- graph()->NewNode(simplified()->NumberLessThanOrEqual(),
- jsgraph()->Constant(kMaxSafeInteger), value),
- jsgraph()->Constant(kMaxSafeInteger), value);
- value_type =
- Type::Range(value_type->Min(), kMaxSafeInteger, graph()->zone());
- NodeProperties::SetType(value, value_type);
- }
- }
- ReplaceWithValue(node, value);
- return Replace(value);
- }
- return Change(node, CodeFactory::ToLength(isolate()), 0);
+ NodeProperties::ChangeOp(node, javascript()->ToLength());
+ return Changed(node);
}
« no previous file with comments | « src/compiler/js-intrinsic-lowering.h ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698