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

Side by Side Diff: src/compiler/js-native-context-specialization.cc

Issue 2763533002: [WIP] JSForInLowering and JSForInHasOwnProperty.
Patch Set: Hack around the issue with indices not being available always. Created 3 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 unified diff | Download patch
« no previous file with comments | « src/compiler/js-generic-lowering.cc ('k') | src/compiler/js-operator.h » ('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-native-context-specialization.h" 5 #include "src/compiler/js-native-context-specialization.h"
6 6
7 #include "src/accessors.h" 7 #include "src/accessors.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compilation-dependencies.h" 9 #include "src/compilation-dependencies.h"
10 #include "src/compiler/access-builder.h" 10 #include "src/compiler/access-builder.h"
(...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1267 Revisit(graph()->end()); 1267 Revisit(graph()->end());
1268 node->TrimInputCount(0); 1268 node->TrimInputCount(0);
1269 NodeProperties::ChangeOp(node, common()->Dead()); 1269 NodeProperties::ChangeOp(node, common()->Dead());
1270 return Changed(node); 1270 return Changed(node);
1271 } 1271 }
1272 1272
1273 1273
1274 Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) { 1274 Reduction JSNativeContextSpecialization::ReduceJSLoadProperty(Node* node) {
1275 DCHECK_EQ(IrOpcode::kJSLoadProperty, node->opcode()); 1275 DCHECK_EQ(IrOpcode::kJSLoadProperty, node->opcode());
1276 PropertyAccess const& p = PropertyAccessOf(node->op()); 1276 PropertyAccess const& p = PropertyAccessOf(node->op());
1277 Node* const index = NodeProperties::GetValueInput(node, 1); 1277 Node* const receiver = NodeProperties::GetValueInput(node, 0);
1278 Node* const name = NodeProperties::GetValueInput(node, 1);
1278 Node* const value = jsgraph()->Dead(); 1279 Node* const value = jsgraph()->Dead();
1279 1280
1281 // We can optimize a property load if it's being used inside a for..in, so
1282 // for code like this:
1283 //
1284 // for (name in receiver) {
1285 // value = receiver[name];
1286 // ...
1287 // }
1288 if (name->opcode() == IrOpcode::kJSForInNext) {
1289 Node* object = NodeProperties::GetValueInput(name, 0);
1290 Node* enumerator = NodeProperties::GetValueInput(name, 2);
1291 Node* index = NodeProperties::GetValueInput(name, 3);
1292 if (object == receiver || (object->opcode() == IrOpcode::kJSToObject &&
1293 object->InputAt(0) == receiver)) {
1294 node->ReplaceInput(0, object);
1295 node->InsertInput(graph()->zone(), 2, enumerator);
1296 node->InsertInput(graph()->zone(), 3, index);
1297 NodeProperties::ChangeOp(node, javascript()->ForInLoadProperty());
1298 return Changed(node);
1299 }
1300 }
1301
1280 // Extract receiver maps from the KEYED_LOAD_IC using the KeyedLoadICNexus. 1302 // Extract receiver maps from the KEYED_LOAD_IC using the KeyedLoadICNexus.
1281 if (!p.feedback().IsValid()) return NoChange(); 1303 if (!p.feedback().IsValid()) return NoChange();
1282 KeyedLoadICNexus nexus(p.feedback().vector(), p.feedback().slot()); 1304 KeyedLoadICNexus nexus(p.feedback().vector(), p.feedback().slot());
1283 1305
1284 // Try to lower the keyed access based on the {nexus}. 1306 // Try to lower the keyed access based on the {nexus}.
1285 return ReduceKeyedAccess(node, index, value, nexus, AccessMode::kLoad, 1307 return ReduceKeyedAccess(node, name, value, nexus, AccessMode::kLoad,
1286 p.language_mode(), STANDARD_STORE); 1308 p.language_mode(), STANDARD_STORE);
1287 } 1309 }
1288 1310
1289 1311
1290 Reduction JSNativeContextSpecialization::ReduceJSStoreProperty(Node* node) { 1312 Reduction JSNativeContextSpecialization::ReduceJSStoreProperty(Node* node) {
1291 DCHECK_EQ(IrOpcode::kJSStoreProperty, node->opcode()); 1313 DCHECK_EQ(IrOpcode::kJSStoreProperty, node->opcode());
1292 PropertyAccess const& p = PropertyAccessOf(node->op()); 1314 PropertyAccess const& p = PropertyAccessOf(node->op());
1293 Node* const index = NodeProperties::GetValueInput(node, 1); 1315 Node* const index = NodeProperties::GetValueInput(node, 1);
1294 Node* const value = NodeProperties::GetValueInput(node, 2); 1316 Node* const value = NodeProperties::GetValueInput(node, 2);
1295 1317
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 return jsgraph()->javascript(); 2337 return jsgraph()->javascript();
2316 } 2338 }
2317 2339
2318 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const { 2340 SimplifiedOperatorBuilder* JSNativeContextSpecialization::simplified() const {
2319 return jsgraph()->simplified(); 2341 return jsgraph()->simplified();
2320 } 2342 }
2321 2343
2322 } // namespace compiler 2344 } // namespace compiler
2323 } // namespace internal 2345 } // namespace internal
2324 } // namespace v8 2346 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-generic-lowering.cc ('k') | src/compiler/js-operator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698