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

Unified Diff: src/compiler/simplified-operator-reducer.cc

Issue 638853004: [turbofan] Eliminate typed array bounds checks if both key and length are constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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/simplified-operator-reducer.h ('k') | test/mjsunit/asm/int32array-constant-key.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/simplified-operator-reducer.cc
diff --git a/src/compiler/simplified-operator-reducer.cc b/src/compiler/simplified-operator-reducer.cc
index f6181ea988ffca2e432ce7afd0847578ace1e8e2..49b87b22a1aa036f15ccaee3028d6b90131f910c 100644
--- a/src/compiler/simplified-operator-reducer.cc
+++ b/src/compiler/simplified-operator-reducer.cc
@@ -12,6 +12,10 @@ namespace v8 {
namespace internal {
namespace compiler {
+SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph)
+ : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
+
+
SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
@@ -95,6 +99,38 @@ Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value()));
break;
}
+ case IrOpcode::kLoadElement: {
+ ElementAccess access = ElementAccessOf(node->op());
+ if (access.bounds_check == kTypedArrayBoundsCheck) {
+ NumericValueMatcher mkey(node->InputAt(1));
+ NumericValueMatcher mlength(node->InputAt(2));
+ if (mkey.HasValue() && mlength.HasValue()) {
+ // Skip the typed array bounds check if key and length are constant.
+ if (mkey.Value() < mlength.Value()) {
+ access.bounds_check = kNoBoundsCheck;
+ node->set_op(simplified()->LoadElement(access));
+ return Changed(node);
+ }
+ }
+ }
+ break;
+ }
+ case IrOpcode::kStoreElement: {
+ ElementAccess access = ElementAccessOf(node->op());
+ if (access.bounds_check == kTypedArrayBoundsCheck) {
+ NumericValueMatcher mkey(node->InputAt(1));
+ NumericValueMatcher mlength(node->InputAt(2));
+ if (mkey.HasValue() && mlength.HasValue()) {
+ // Skip the typed array bounds check if key and length are constant.
+ if (mkey.Value() < mlength.Value()) {
+ access.bounds_check = kNoBoundsCheck;
+ node->set_op(simplified()->StoreElement(access));
+ return Changed(node);
+ }
+ }
+ }
+ break;
+ }
default:
break;
}
« no previous file with comments | « src/compiler/simplified-operator-reducer.h ('k') | test/mjsunit/asm/int32array-constant-key.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698