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

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

Issue 2596843002: [turbofan] Optimize store to typed arrays only if the value is plain primitive. (Closed)
Patch Set: Remove dead variable Created 3 years, 12 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 | test/mjsunit/compiler/regress-v8-5756.js » ('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 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/compiler/js-typed-lowering.h" 5 #include "src/compiler/js-typed-lowering.h"
6 6
7 #include "src/ast/modules.h" 7 #include "src/ast/modules.h"
8 #include "src/builtins/builtins-utils.h" 8 #include "src/builtins/builtins-utils.h"
9 #include "src/code-factory.h" 9 #include "src/code-factory.h"
10 #include "src/compilation-dependencies.h" 10 #include "src/compilation-dependencies.h"
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 } 1247 }
1248 return NoChange(); 1248 return NoChange();
1249 } 1249 }
1250 1250
1251 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) { 1251 Reduction JSTypedLowering::ReduceJSStoreProperty(Node* node) {
1252 Node* key = NodeProperties::GetValueInput(node, 1); 1252 Node* key = NodeProperties::GetValueInput(node, 1);
1253 Node* base = NodeProperties::GetValueInput(node, 0); 1253 Node* base = NodeProperties::GetValueInput(node, 0);
1254 Node* value = NodeProperties::GetValueInput(node, 2); 1254 Node* value = NodeProperties::GetValueInput(node, 2);
1255 Type* key_type = NodeProperties::GetType(key); 1255 Type* key_type = NodeProperties::GetType(key);
1256 Type* value_type = NodeProperties::GetType(value); 1256 Type* value_type = NodeProperties::GetType(value);
1257
1258 if (!value_type->Is(Type::PlainPrimitive())) return NoChange();
1259
1257 HeapObjectMatcher mbase(base); 1260 HeapObjectMatcher mbase(base);
1258 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) { 1261 if (mbase.HasValue() && mbase.Value()->IsJSTypedArray()) {
1259 Handle<JSTypedArray> const array = 1262 Handle<JSTypedArray> const array =
1260 Handle<JSTypedArray>::cast(mbase.Value()); 1263 Handle<JSTypedArray>::cast(mbase.Value());
1261 if (!array->GetBuffer()->was_neutered()) { 1264 if (!array->GetBuffer()->was_neutered()) {
1262 array->GetBuffer()->set_is_neuterable(false); 1265 array->GetBuffer()->set_is_neuterable(false);
1263 BufferAccess const access(array->type()); 1266 BufferAccess const access(array->type());
1264 size_t const k = 1267 size_t const k =
1265 ElementSizeLog2Of(access.machine_type().representation()); 1268 ElementSizeLog2Of(access.machine_type().representation());
1266 double const byte_length = array->byte_length()->Number(); 1269 double const byte_length = array->byte_length()->Number();
1267 CHECK_LT(k, arraysize(shifted_int32_ranges_)); 1270 CHECK_LT(k, arraysize(shifted_int32_ranges_));
1268 if (access.external_array_type() != kExternalUint8ClampedArray && 1271 if (access.external_array_type() != kExternalUint8ClampedArray &&
1269 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) { 1272 key_type->Is(shifted_int32_ranges_[k]) && byte_length <= kMaxInt) {
1270 // JSLoadProperty(typed-array, int32) 1273 // JSLoadProperty(typed-array, int32)
1271 Handle<FixedTypedArrayBase> elements = 1274 Handle<FixedTypedArrayBase> elements =
1272 Handle<FixedTypedArrayBase>::cast(handle(array->elements())); 1275 Handle<FixedTypedArrayBase>::cast(handle(array->elements()));
1273 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer()); 1276 Node* buffer = jsgraph()->PointerConstant(elements->external_pointer());
1274 Node* length = jsgraph()->Constant(byte_length); 1277 Node* length = jsgraph()->Constant(byte_length);
1275 Node* context = NodeProperties::GetContextInput(node);
1276 Node* effect = NodeProperties::GetEffectInput(node); 1278 Node* effect = NodeProperties::GetEffectInput(node);
1277 Node* control = NodeProperties::GetControlInput(node); 1279 Node* control = NodeProperties::GetControlInput(node);
1278 // Convert to a number first. 1280 // Convert to a number first.
1279 if (!value_type->Is(Type::Number())) { 1281 if (!value_type->Is(Type::Number())) {
1280 Reduction number_reduction = ReduceJSToNumberInput(value); 1282 Reduction number_reduction = ReduceJSToNumberInput(value);
1281 if (number_reduction.Changed()) { 1283 if (number_reduction.Changed()) {
1282 value = number_reduction.replacement(); 1284 value = number_reduction.replacement();
1283 } else { 1285 } else {
1284 Node* frame_state_for_to_number = 1286 value =
1285 NodeProperties::FindFrameStateBefore(node); 1287 graph()->NewNode(simplified()->PlainPrimitiveToNumber(), value);
1286 value = effect =
1287 graph()->NewNode(javascript()->ToNumber(), value, context,
1288 frame_state_for_to_number, effect, control);
1289 control = graph()->NewNode(common()->IfSuccess(), value);
1290 } 1288 }
1291 } 1289 }
1292 // Check if we can avoid the bounds check. 1290 // Check if we can avoid the bounds check.
1293 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) { 1291 if (key_type->Min() >= 0 && key_type->Max() < array->length_value()) {
1294 RelaxControls(node); 1292 RelaxControls(node);
1295 node->ReplaceInput(0, buffer); 1293 node->ReplaceInput(0, buffer);
1296 DCHECK_EQ(key, node->InputAt(1)); 1294 DCHECK_EQ(key, node->InputAt(1));
1297 node->ReplaceInput(2, value); 1295 node->ReplaceInput(2, value);
1298 node->ReplaceInput(3, effect); 1296 node->ReplaceInput(3, effect);
1299 node->ReplaceInput(4, control); 1297 node->ReplaceInput(4, control);
(...skipping 1017 matching lines...) Expand 10 before | Expand all | Expand 10 after
2317 } 2315 }
2318 2316
2319 2317
2320 CompilationDependencies* JSTypedLowering::dependencies() const { 2318 CompilationDependencies* JSTypedLowering::dependencies() const {
2321 return dependencies_; 2319 return dependencies_;
2322 } 2320 }
2323 2321
2324 } // namespace compiler 2322 } // namespace compiler
2325 } // namespace internal 2323 } // namespace internal
2326 } // namespace v8 2324 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/compiler/regress-v8-5756.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698