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

Side by Side Diff: src/compiler/bytecode-graph-builder.cc

Issue 1531693002: [Interpreter] Implement ForIn in bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@oth-0009-phi
Patch Set: Re-work ForInPrepare. Created 5 years 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 | src/interpreter/bytecode-array-builder.h » ('j') | src/interpreter/interpreter.cc » ('J')
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/bytecode-graph-builder.h" 5 #include "src/compiler/bytecode-graph-builder.h"
6 6
7 #include "src/compiler/bytecode-branch-analysis.h" 7 #include "src/compiler/bytecode-branch-analysis.h"
8 #include "src/compiler/linkage.h" 8 #include "src/compiler/linkage.h"
9 #include "src/compiler/operator-properties.h" 9 #include "src/compiler/operator-properties.h"
10 #include "src/interpreter/bytecodes.h" 10 #include "src/interpreter/bytecodes.h"
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 UpdateControlDependencyToLeaveFunction(control); 1011 UpdateControlDependencyToLeaveFunction(control);
1012 environment()->BindAccumulator(value); 1012 environment()->BindAccumulator(value);
1013 } 1013 }
1014 1014
1015 1015
1016 void BytecodeGraphBuilder::BuildBinaryOp( 1016 void BytecodeGraphBuilder::BuildBinaryOp(
1017 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { 1017 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) {
1018 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); 1018 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1019 Node* right = environment()->LookupAccumulator(); 1019 Node* right = environment()->LookupAccumulator();
1020 Node* node = NewNode(js_op, left, right); 1020 Node* node = NewNode(js_op, left, right);
1021
1022 AddEmptyFrameStateInputs(node); 1021 AddEmptyFrameStateInputs(node);
1023 environment()->BindAccumulator(node); 1022 environment()->BindAccumulator(node);
1024 } 1023 }
1025 1024
1026 1025
1027 void BytecodeGraphBuilder::VisitAdd( 1026 void BytecodeGraphBuilder::VisitAdd(
1028 const interpreter::BytecodeArrayIterator& iterator) { 1027 const interpreter::BytecodeArrayIterator& iterator) {
1029 BinaryOperationHints hints = BinaryOperationHints::Any(); 1028 BinaryOperationHints hints = BinaryOperationHints::Any();
1030 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); 1029 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator);
1031 } 1030 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1254 BuildCastOperator(javascript()->ToName(), iterator); 1253 BuildCastOperator(javascript()->ToName(), iterator);
1255 } 1254 }
1256 1255
1257 1256
1258 void BytecodeGraphBuilder::VisitToNumber( 1257 void BytecodeGraphBuilder::VisitToNumber(
1259 const interpreter::BytecodeArrayIterator& iterator) { 1258 const interpreter::BytecodeArrayIterator& iterator) {
1260 BuildCastOperator(javascript()->ToNumber(), iterator); 1259 BuildCastOperator(javascript()->ToNumber(), iterator);
1261 } 1260 }
1262 1261
1263 1262
1264 void BytecodeGraphBuilder::VisitToObject(
1265 const interpreter::BytecodeArrayIterator& iterator) {
1266 BuildCastOperator(javascript()->ToObject(), iterator);
1267 }
1268
1269
1270 void BytecodeGraphBuilder::VisitJump( 1263 void BytecodeGraphBuilder::VisitJump(
1271 const interpreter::BytecodeArrayIterator& iterator) { 1264 const interpreter::BytecodeArrayIterator& iterator) {
1272 BuildJump(); 1265 BuildJump();
1273 } 1266 }
1274 1267
1275 1268
1276 void BytecodeGraphBuilder::VisitJumpConstant( 1269 void BytecodeGraphBuilder::VisitJumpConstant(
1277 const interpreter::BytecodeArrayIterator& iterator) { 1270 const interpreter::BytecodeArrayIterator& iterator) {
1278 BuildJump(); 1271 BuildJump();
1279 } 1272 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1367 const interpreter::BytecodeArrayIterator& iterator) { 1360 const interpreter::BytecodeArrayIterator& iterator) {
1368 Node* control = 1361 Node* control =
1369 NewNode(common()->Return(), environment()->LookupAccumulator()); 1362 NewNode(common()->Return(), environment()->LookupAccumulator());
1370 UpdateControlDependencyToLeaveFunction(control); 1363 UpdateControlDependencyToLeaveFunction(control);
1371 set_environment(nullptr); 1364 set_environment(nullptr);
1372 } 1365 }
1373 1366
1374 1367
1375 void BytecodeGraphBuilder::VisitForInPrepare( 1368 void BytecodeGraphBuilder::VisitForInPrepare(
1376 const interpreter::BytecodeArrayIterator& iterator) { 1369 const interpreter::BytecodeArrayIterator& iterator) {
1377 UNIMPLEMENTED(); 1370 // Bytecode generator only reaches here if the object is not null or
1371 // undefined, whereas ast-graph-builder has to check.
1372 Node* object = environment()->LookupAccumulator();
1373 Node* receiver = NewNode(javascript()->ToObject(), object);
1374 AddEmptyFrameStateInputs(receiver);
1375 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver);
1376 AddEmptyFrameStateInputs(prepare);
rmcilroy 2015/12/17 15:43:26 Hmm, this is a bit troubling for deopt - you have
oth 2015/12/17 19:28:23 NP. Will re-spin shortly. The interpreter needs a
1377 Node* cache_type = NewNode(common()->Projection(0), prepare);
1378 Node* cache_array = NewNode(common()->Projection(1), prepare);
1379 Node* cache_length = NewNode(common()->Projection(2), prepare);
1380 environment()->BindRegister(iterator.GetRegisterOperand(0), receiver);
1381 environment()->BindRegister(iterator.GetRegisterOperand(1), cache_type);
1382 environment()->BindRegister(iterator.GetRegisterOperand(2), cache_array);
1383 environment()->BindRegister(iterator.GetRegisterOperand(3), cache_length);
1384 }
1385
1386
1387 void BytecodeGraphBuilder::VisitForInDone(
1388 const interpreter::BytecodeArrayIterator& iterator) {
1389 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1390 Node* cache_length =
1391 environment()->LookupRegister(iterator.GetRegisterOperand(1));
1392 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length);
1393 AddEmptyFrameStateInputs(exit_cond);
1394 environment()->BindAccumulator(exit_cond);
1378 } 1395 }
1379 1396
1380 1397
1381 void BytecodeGraphBuilder::VisitForInNext( 1398 void BytecodeGraphBuilder::VisitForInNext(
1382 const interpreter::BytecodeArrayIterator& iterator) { 1399 const interpreter::BytecodeArrayIterator& iterator) {
1383 UNIMPLEMENTED(); 1400 Node* receiver =
1401 environment()->LookupRegister(iterator.GetRegisterOperand(0));
1402 Node* cache_type =
1403 environment()->LookupRegister(iterator.GetRegisterOperand(1));
1404 Node* cache_array =
1405 environment()->LookupRegister(iterator.GetRegisterOperand(2));
1406 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(3));
1407 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array,
1408 cache_type, index);
1409 AddEmptyFrameStateInputs(value);
1410 environment()->BindAccumulator(value);
1384 } 1411 }
1385 1412
1386 1413
1387 void BytecodeGraphBuilder::VisitForInDone( 1414 void BytecodeGraphBuilder::VisitForInStep(
1388 const interpreter::BytecodeArrayIterator& iterator) { 1415 const interpreter::BytecodeArrayIterator& iterator) {
1389 UNIMPLEMENTED(); 1416 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1417 index = NewNode(javascript()->ForInStep(), index);
1418 AddEmptyFrameStateInputs(index);
1419 environment()->BindRegister(iterator.GetRegisterOperand(0), index);
1390 } 1420 }
1391 1421
1392 1422
1393 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( 1423 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches(
1394 int source_offset, int target_offset) { 1424 int source_offset, int target_offset) {
1395 DCHECK_GE(source_offset, target_offset); 1425 DCHECK_GE(source_offset, target_offset);
1396 const ZoneVector<int>* branch_sites = 1426 const ZoneVector<int>* branch_sites =
1397 branch_analysis()->BackwardBranchesTargetting(target_offset); 1427 branch_analysis()->BackwardBranchesTargetting(target_offset);
1398 if (branch_sites->back() == source_offset) { 1428 if (branch_sites->back() == source_offset) {
1399 // The set of back branches is complete, merge them. 1429 // The set of back branches is complete, merge them.
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
1632 1662
1633 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { 1663 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) {
1634 if (environment()->IsMarkedAsUnreachable()) return; 1664 if (environment()->IsMarkedAsUnreachable()) return;
1635 environment()->MarkAsUnreachable(); 1665 environment()->MarkAsUnreachable();
1636 exit_controls_.push_back(exit); 1666 exit_controls_.push_back(exit);
1637 } 1667 }
1638 1668
1639 } // namespace compiler 1669 } // namespace compiler
1640 } // namespace internal 1670 } // namespace internal
1641 } // namespace v8 1671 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-builder.h » ('j') | src/interpreter/interpreter.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698