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

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: Fix 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
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 995 matching lines...) Expand 10 before | Expand all | Expand 10 after
1006 UpdateControlDependencyToLeaveFunction(control); 1006 UpdateControlDependencyToLeaveFunction(control);
1007 environment()->BindAccumulator(value); 1007 environment()->BindAccumulator(value);
1008 } 1008 }
1009 1009
1010 1010
1011 void BytecodeGraphBuilder::BuildBinaryOp( 1011 void BytecodeGraphBuilder::BuildBinaryOp(
1012 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { 1012 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) {
1013 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); 1013 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1014 Node* right = environment()->LookupAccumulator(); 1014 Node* right = environment()->LookupAccumulator();
1015 Node* node = NewNode(js_op, left, right); 1015 Node* node = NewNode(js_op, left, right);
1016
1017 AddEmptyFrameStateInputs(node); 1016 AddEmptyFrameStateInputs(node);
1018 environment()->BindAccumulator(node); 1017 environment()->BindAccumulator(node);
1019 } 1018 }
1020 1019
1021 1020
1022 void BytecodeGraphBuilder::VisitAdd( 1021 void BytecodeGraphBuilder::VisitAdd(
1023 const interpreter::BytecodeArrayIterator& iterator) { 1022 const interpreter::BytecodeArrayIterator& iterator) {
1024 BinaryOperationHints hints = BinaryOperationHints::Any(); 1023 BinaryOperationHints hints = BinaryOperationHints::Any();
1025 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); 1024 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator);
1026 } 1025 }
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1362 const interpreter::BytecodeArrayIterator& iterator) { 1361 const interpreter::BytecodeArrayIterator& iterator) {
1363 Node* control = 1362 Node* control =
1364 NewNode(common()->Return(), environment()->LookupAccumulator()); 1363 NewNode(common()->Return(), environment()->LookupAccumulator());
1365 UpdateControlDependencyToLeaveFunction(control); 1364 UpdateControlDependencyToLeaveFunction(control);
1366 set_environment(nullptr); 1365 set_environment(nullptr);
1367 } 1366 }
1368 1367
1369 1368
1370 void BytecodeGraphBuilder::VisitForInPrepare( 1369 void BytecodeGraphBuilder::VisitForInPrepare(
1371 const interpreter::BytecodeArrayIterator& iterator) { 1370 const interpreter::BytecodeArrayIterator& iterator) {
1372 UNIMPLEMENTED(); 1371 Node* receiver =
1372 environment()->LookupRegister(iterator.GetRegisterOperand(0));
1373 // Prepare for-in cache.
1374 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver);
1375 AddEmptyFrameStateInputs(prepare);
1376
1377 // Move cache info from ForInPrepare into interpreter frame for de-opt.
1378 Node* cache_type = NewNode(common()->Projection(0), prepare);
1379 Node* cache_array = NewNode(common()->Projection(1), prepare);
1380 Node* cache_length = NewNode(common()->Projection(2), prepare);
1381 interpreter::Register cache_type_register = iterator.GetRegisterOperand(1);
1382 interpreter::Register cache_array_register = iterator.GetRegisterOperand(2);
1383 interpreter::Register cache_length_register = iterator.GetRegisterOperand(3);
1384 environment()->BindRegister(cache_type_register, cache_type);
1385 environment()->BindRegister(cache_array_register, cache_array);
1386 environment()->BindRegister(cache_length_register, cache_length);
1387 }
1388
1389
1390 void BytecodeGraphBuilder::VisitForInDone(
1391 const interpreter::BytecodeArrayIterator& iterator) {
1392 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1393 Node* cache_length =
1394 environment()->LookupRegister(iterator.GetRegisterOperand(1));
1395 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length);
1396 AddEmptyFrameStateInputs(exit_cond);
1397 environment()->BindAccumulator(exit_cond);
1373 } 1398 }
1374 1399
1375 1400
1376 void BytecodeGraphBuilder::VisitForInNext( 1401 void BytecodeGraphBuilder::VisitForInNext(
1377 const interpreter::BytecodeArrayIterator& iterator) { 1402 const interpreter::BytecodeArrayIterator& iterator) {
1378 UNIMPLEMENTED(); 1403 Node* receiver =
1404 environment()->LookupRegister(iterator.GetRegisterOperand(0));
1405 Node* cache_type =
1406 environment()->LookupRegister(iterator.GetRegisterOperand(1));
1407 Node* cache_array =
1408 environment()->LookupRegister(iterator.GetRegisterOperand(2));
1409 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(3));
1410 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array,
1411 cache_type, index);
1412 AddEmptyFrameStateInputs(value);
1413 environment()->BindAccumulator(value);
1379 } 1414 }
1380 1415
1381 1416
1382 void BytecodeGraphBuilder::VisitForInDone( 1417 void BytecodeGraphBuilder::VisitForInStep(
1383 const interpreter::BytecodeArrayIterator& iterator) { 1418 const interpreter::BytecodeArrayIterator& iterator) {
1384 UNIMPLEMENTED(); 1419 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1420 index = NewNode(javascript()->ForInStep(), index);
1421 AddEmptyFrameStateInputs(index);
1422 environment()->BindRegister(iterator.GetRegisterOperand(0), index);
1385 } 1423 }
1386 1424
1387 1425
1388 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( 1426 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches(
1389 int source_offset, int target_offset) { 1427 int source_offset, int target_offset) {
1390 DCHECK_GE(source_offset, target_offset); 1428 DCHECK_GE(source_offset, target_offset);
1391 const ZoneVector<int>* back_branches = 1429 const ZoneVector<int>* back_branches =
1392 branch_analysis()->BackwardBranchesTargetting(target_offset); 1430 branch_analysis()->BackwardBranchesTargetting(target_offset);
1393 if (back_branches->back() == source_offset) { 1431 if (back_branches->back() == source_offset) {
1394 // The set of back branches is complete, merge them. 1432 // The set of back branches is complete, merge them.
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1626 1664
1627 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { 1665 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) {
1628 if (environment()->IsMarkedAsUnreachable()) return; 1666 if (environment()->IsMarkedAsUnreachable()) return;
1629 environment()->MarkAsUnreachable(); 1667 environment()->MarkAsUnreachable();
1630 exit_controls_.push_back(exit); 1668 exit_controls_.push_back(exit);
1631 } 1669 }
1632 1670
1633 } // namespace compiler 1671 } // namespace compiler
1634 } // namespace internal 1672 } // namespace internal
1635 } // namespace v8 1673 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/interpreter/bytecode-array-builder.h » ('j') | src/interpreter/bytecode-generator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698