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

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

Issue 1595103006: [Interpreter] Preparation for wide registers. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase. Created 4 years, 11 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/bytecode-graph-builder.h ('k') | src/compiler/interpreter-assembler.cc » ('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/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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 } 623 }
624 624
625 625
626 void BytecodeGraphBuilder::VisitMov( 626 void BytecodeGraphBuilder::VisitMov(
627 const interpreter::BytecodeArrayIterator& iterator) { 627 const interpreter::BytecodeArrayIterator& iterator) {
628 Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0)); 628 Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0));
629 environment()->BindRegister(iterator.GetRegisterOperand(1), value); 629 environment()->BindRegister(iterator.GetRegisterOperand(1), value);
630 } 630 }
631 631
632 632
633 void BytecodeGraphBuilder::VisitExchange( 633 void BytecodeGraphBuilder::VisitMovWide(
634 const interpreter::BytecodeArrayIterator& iterator) { 634 const interpreter::BytecodeArrayIterator& iterator) {
635 environment()->ExchangeRegisters(iterator.GetRegisterOperand(0), 635 VisitMov(iterator);
636 iterator.GetRegisterOperand(1));
637 } 636 }
638 637
639 638
640 void BytecodeGraphBuilder::VisitExchangeWide(
641 const interpreter::BytecodeArrayIterator& iterator) {
642 environment()->ExchangeRegisters(iterator.GetRegisterOperand(0),
643 iterator.GetRegisterOperand(1));
644 }
645
646
647 void BytecodeGraphBuilder::BuildLoadGlobal( 639 void BytecodeGraphBuilder::BuildLoadGlobal(
648 const interpreter::BytecodeArrayIterator& iterator, 640 const interpreter::BytecodeArrayIterator& iterator,
649 TypeofMode typeof_mode) { 641 TypeofMode typeof_mode) {
650 FrameStateBeforeAndAfter states(this, iterator); 642 FrameStateBeforeAndAfter states(this, iterator);
651 Handle<Name> name = 643 Handle<Name> name =
652 Handle<Name>::cast(iterator.GetConstantForIndexOperand(0)); 644 Handle<Name>::cast(iterator.GetConstantForIndexOperand(0));
653 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); 645 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1));
654 646
655 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); 647 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode);
656 Node* node = NewNode(op, BuildLoadFeedbackVector()); 648 Node* node = NewNode(op, BuildLoadFeedbackVector());
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 BuildCall(iterator); 1208 BuildCall(iterator);
1217 } 1209 }
1218 1210
1219 1211
1220 void BytecodeGraphBuilder::VisitCallWide( 1212 void BytecodeGraphBuilder::VisitCallWide(
1221 const interpreter::BytecodeArrayIterator& iterator) { 1213 const interpreter::BytecodeArrayIterator& iterator) {
1222 BuildCall(iterator); 1214 BuildCall(iterator);
1223 } 1215 }
1224 1216
1225 1217
1226 void BytecodeGraphBuilder::VisitCallJSRuntime( 1218 void BytecodeGraphBuilder::BuildCallJSRuntime(
1227 const interpreter::BytecodeArrayIterator& iterator) { 1219 const interpreter::BytecodeArrayIterator& iterator) {
1228 FrameStateBeforeAndAfter states(this, iterator); 1220 FrameStateBeforeAndAfter states(this, iterator);
1229 Node* callee = BuildLoadNativeContextField(iterator.GetIndexOperand(0)); 1221 Node* callee = BuildLoadNativeContextField(iterator.GetIndexOperand(0));
1230 interpreter::Register receiver = iterator.GetRegisterOperand(1); 1222 interpreter::Register receiver = iterator.GetRegisterOperand(1);
1231 size_t arg_count = iterator.GetCountOperand(2); 1223 size_t arg_count = iterator.GetCountOperand(2);
1232 1224
1233 // Create node to perform the JS runtime call. 1225 // Create node to perform the JS runtime call.
1234 const Operator* call = 1226 const Operator* call =
1235 javascript()->CallFunction(arg_count + 2, language_mode()); 1227 javascript()->CallFunction(arg_count + 2, language_mode());
1236 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2); 1228 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2);
1237 environment()->BindAccumulator(value, &states); 1229 environment()->BindAccumulator(value, &states);
1238 } 1230 }
1239 1231
1240 1232
1233 void BytecodeGraphBuilder::VisitCallJSRuntime(
1234 const interpreter::BytecodeArrayIterator& iterator) {
1235 BuildCallJSRuntime(iterator);
1236 }
1237
1238
1239 void BytecodeGraphBuilder::VisitCallJSRuntimeWide(
1240 const interpreter::BytecodeArrayIterator& iterator) {
1241 BuildCallJSRuntime(iterator);
1242 }
1243
1244
1241 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( 1245 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments(
1242 const Operator* call_runtime_op, interpreter::Register first_arg, 1246 const Operator* call_runtime_op, interpreter::Register first_arg,
1243 size_t arity) { 1247 size_t arity) {
1244 Node** all = info()->zone()->NewArray<Node*>(arity); 1248 Node** all = info()->zone()->NewArray<Node*>(arity);
1245 int first_arg_index = first_arg.index(); 1249 int first_arg_index = first_arg.index();
1246 for (int i = 0; i < static_cast<int>(arity); ++i) { 1250 for (int i = 0; i < static_cast<int>(arity); ++i) {
1247 all[i] = environment()->LookupRegister( 1251 all[i] = environment()->LookupRegister(
1248 interpreter::Register(first_arg_index + i)); 1252 interpreter::Register(first_arg_index + i));
1249 } 1253 }
1250 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); 1254 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false);
1251 return value; 1255 return value;
1252 } 1256 }
1253 1257
1254 1258
1255 void BytecodeGraphBuilder::VisitCallRuntime( 1259 void BytecodeGraphBuilder::BuildCallRuntime(
1256 const interpreter::BytecodeArrayIterator& iterator) { 1260 const interpreter::BytecodeArrayIterator& iterator) {
1257 FrameStateBeforeAndAfter states(this, iterator); 1261 FrameStateBeforeAndAfter states(this, iterator);
1258 Runtime::FunctionId functionId = 1262 Runtime::FunctionId functionId =
1259 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); 1263 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0));
1260 interpreter::Register first_arg = iterator.GetRegisterOperand(1); 1264 interpreter::Register first_arg = iterator.GetRegisterOperand(1);
1261 size_t arg_count = iterator.GetCountOperand(2); 1265 size_t arg_count = iterator.GetCountOperand(2);
1262 1266
1263 // Create node to perform the runtime call. 1267 // Create node to perform the runtime call.
1264 const Operator* call = javascript()->CallRuntime(functionId, arg_count); 1268 const Operator* call = javascript()->CallRuntime(functionId, arg_count);
1265 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); 1269 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count);
1266 environment()->BindAccumulator(value, &states); 1270 environment()->BindAccumulator(value, &states);
1267 } 1271 }
1268 1272
1269 1273
1270 void BytecodeGraphBuilder::VisitCallRuntimeForPair( 1274 void BytecodeGraphBuilder::VisitCallRuntime(
1275 const interpreter::BytecodeArrayIterator& iterator) {
1276 BuildCallRuntime(iterator);
1277 }
1278
1279
1280 void BytecodeGraphBuilder::VisitCallRuntimeWide(
1281 const interpreter::BytecodeArrayIterator& iterator) {
1282 BuildCallRuntime(iterator);
1283 }
1284
1285
1286 void BytecodeGraphBuilder::BuildCallRuntimeForPair(
1271 const interpreter::BytecodeArrayIterator& iterator) { 1287 const interpreter::BytecodeArrayIterator& iterator) {
1272 FrameStateBeforeAndAfter states(this, iterator); 1288 FrameStateBeforeAndAfter states(this, iterator);
1273 Runtime::FunctionId functionId = 1289 Runtime::FunctionId functionId =
1274 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); 1290 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0));
1275 interpreter::Register first_arg = iterator.GetRegisterOperand(1); 1291 interpreter::Register first_arg = iterator.GetRegisterOperand(1);
1276 size_t arg_count = iterator.GetCountOperand(2); 1292 size_t arg_count = iterator.GetCountOperand(2);
1277 interpreter::Register first_return = iterator.GetRegisterOperand(3); 1293 interpreter::Register first_return = iterator.GetRegisterOperand(3);
1278 1294
1279 // Create node to perform the runtime call. 1295 // Create node to perform the runtime call.
1280 const Operator* call = javascript()->CallRuntime(functionId, arg_count); 1296 const Operator* call = javascript()->CallRuntime(functionId, arg_count);
1281 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); 1297 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count);
1282 environment()->BindRegistersToProjections(first_return, return_pair, &states); 1298 environment()->BindRegistersToProjections(first_return, return_pair, &states);
1283 } 1299 }
1284 1300
1285 1301
1302 void BytecodeGraphBuilder::VisitCallRuntimeForPair(
1303 const interpreter::BytecodeArrayIterator& iterator) {
1304 BuildCallRuntimeForPair(iterator);
1305 }
1306
1307
1308 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide(
1309 const interpreter::BytecodeArrayIterator& iterator) {
1310 BuildCallRuntimeForPair(iterator);
1311 }
1312
1313
1286 Node* BytecodeGraphBuilder::ProcessCallNewArguments( 1314 Node* BytecodeGraphBuilder::ProcessCallNewArguments(
1287 const Operator* call_new_op, interpreter::Register callee, 1315 const Operator* call_new_op, interpreter::Register callee,
1288 interpreter::Register first_arg, size_t arity) { 1316 interpreter::Register first_arg, size_t arity) {
1289 Node** all = info()->zone()->NewArray<Node*>(arity); 1317 Node** all = info()->zone()->NewArray<Node*>(arity);
1290 all[0] = environment()->LookupRegister(callee); 1318 all[0] = environment()->LookupRegister(callee);
1291 int first_arg_index = first_arg.index(); 1319 int first_arg_index = first_arg.index();
1292 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { 1320 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) {
1293 all[i] = environment()->LookupRegister( 1321 all[i] = environment()->LookupRegister(
1294 interpreter::Register(first_arg_index + i - 1)); 1322 interpreter::Register(first_arg_index + i - 1));
1295 } 1323 }
1296 // Original constructor is the same as the callee. 1324 // Original constructor is the same as the callee.
1297 all[arity - 1] = environment()->LookupRegister(callee); 1325 all[arity - 1] = environment()->LookupRegister(callee);
1298 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); 1326 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false);
1299 return value; 1327 return value;
1300 } 1328 }
1301 1329
1302 1330
1303 void BytecodeGraphBuilder::VisitNew( 1331 void BytecodeGraphBuilder::BuildCallConstruct(
1304 const interpreter::BytecodeArrayIterator& iterator) { 1332 const interpreter::BytecodeArrayIterator& iterator) {
1305 FrameStateBeforeAndAfter states(this, iterator); 1333 FrameStateBeforeAndAfter states(this, iterator);
1306 interpreter::Register callee = iterator.GetRegisterOperand(0); 1334 interpreter::Register callee = iterator.GetRegisterOperand(0);
1307 interpreter::Register first_arg = iterator.GetRegisterOperand(1); 1335 interpreter::Register first_arg = iterator.GetRegisterOperand(1);
1308 size_t arg_count = iterator.GetCountOperand(2); 1336 size_t arg_count = iterator.GetCountOperand(2);
1309 1337
1310 // TODO(turbofan): Pass the feedback here. 1338 // TODO(turbofan): Pass the feedback here.
1311 const Operator* call = javascript()->CallConstruct( 1339 const Operator* call = javascript()->CallConstruct(
1312 static_cast<int>(arg_count) + 2, VectorSlotPair()); 1340 static_cast<int>(arg_count) + 2, VectorSlotPair());
1313 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); 1341 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2);
1314 environment()->BindAccumulator(value, &states); 1342 environment()->BindAccumulator(value, &states);
1315 } 1343 }
1316 1344
1317 1345
1346 void BytecodeGraphBuilder::VisitNew(
1347 const interpreter::BytecodeArrayIterator& iterator) {
1348 BuildCallConstruct(iterator);
1349 }
1350
1351
1352 void BytecodeGraphBuilder::VisitNewWide(
1353 const interpreter::BytecodeArrayIterator& iterator) {
1354 BuildCallConstruct(iterator);
1355 }
1356
1357
1318 void BytecodeGraphBuilder::VisitThrow( 1358 void BytecodeGraphBuilder::VisitThrow(
1319 const interpreter::BytecodeArrayIterator& iterator) { 1359 const interpreter::BytecodeArrayIterator& iterator) {
1320 FrameStateBeforeAndAfter states(this, iterator); 1360 FrameStateBeforeAndAfter states(this, iterator);
1321 Node* value = environment()->LookupAccumulator(); 1361 Node* value = environment()->LookupAccumulator();
1322 // TODO(mythria): Change to Runtime::kThrow when we have deoptimization 1362 // TODO(mythria): Change to Runtime::kThrow when we have deoptimization
1323 // information support in the interpreter. 1363 // information support in the interpreter.
1324 NewNode(javascript()->CallRuntime(Runtime::kReThrow), value); 1364 NewNode(javascript()->CallRuntime(Runtime::kReThrow), value);
1325 Node* control = NewNode(common()->Throw(), value); 1365 Node* control = NewNode(common()->Throw(), value);
1326 environment()->RecordAfterState(control, &states); 1366 environment()->RecordAfterState(control, &states);
1327 UpdateControlDependencyToLeaveFunction(control); 1367 UpdateControlDependencyToLeaveFunction(control);
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 1755
1716 void BytecodeGraphBuilder::VisitReturn( 1756 void BytecodeGraphBuilder::VisitReturn(
1717 const interpreter::BytecodeArrayIterator& iterator) { 1757 const interpreter::BytecodeArrayIterator& iterator) {
1718 Node* control = 1758 Node* control =
1719 NewNode(common()->Return(), environment()->LookupAccumulator()); 1759 NewNode(common()->Return(), environment()->LookupAccumulator());
1720 UpdateControlDependencyToLeaveFunction(control); 1760 UpdateControlDependencyToLeaveFunction(control);
1721 set_environment(nullptr); 1761 set_environment(nullptr);
1722 } 1762 }
1723 1763
1724 1764
1725 void BytecodeGraphBuilder::VisitForInPrepare( 1765 void BytecodeGraphBuilder::BuildForInPrepare(
1726 const interpreter::BytecodeArrayIterator& iterator) { 1766 const interpreter::BytecodeArrayIterator& iterator) {
1727 FrameStateBeforeAndAfter states(this, iterator); 1767 FrameStateBeforeAndAfter states(this, iterator);
1728 Node* receiver = environment()->LookupAccumulator(); 1768 Node* receiver = environment()->LookupAccumulator();
1729 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); 1769 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver);
1730 environment()->BindRegistersToProjections(iterator.GetRegisterOperand(0), 1770 environment()->BindRegistersToProjections(iterator.GetRegisterOperand(0),
1731 prepare, &states); 1771 prepare, &states);
1732 } 1772 }
1733 1773
1734 1774
1775 void BytecodeGraphBuilder::VisitForInPrepare(
1776 const interpreter::BytecodeArrayIterator& iterator) {
1777 BuildForInPrepare(iterator);
1778 }
1779
1780
1781 void BytecodeGraphBuilder::VisitForInPrepareWide(
1782 const interpreter::BytecodeArrayIterator& iterator) {
1783 BuildForInPrepare(iterator);
1784 }
1785
1786
1735 void BytecodeGraphBuilder::VisitForInDone( 1787 void BytecodeGraphBuilder::VisitForInDone(
1736 const interpreter::BytecodeArrayIterator& iterator) { 1788 const interpreter::BytecodeArrayIterator& iterator) {
1737 FrameStateBeforeAndAfter states(this, iterator); 1789 FrameStateBeforeAndAfter states(this, iterator);
1738 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); 1790 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1739 Node* cache_length = 1791 Node* cache_length =
1740 environment()->LookupRegister(iterator.GetRegisterOperand(1)); 1792 environment()->LookupRegister(iterator.GetRegisterOperand(1));
1741 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); 1793 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length);
1742 environment()->BindAccumulator(exit_cond, &states); 1794 environment()->BindAccumulator(exit_cond, &states);
1743 } 1795 }
1744 1796
1745 1797
1746 void BytecodeGraphBuilder::VisitForInNext( 1798 void BytecodeGraphBuilder::BuildForInNext(
1747 const interpreter::BytecodeArrayIterator& iterator) { 1799 const interpreter::BytecodeArrayIterator& iterator) {
1748 FrameStateBeforeAndAfter states(this, iterator); 1800 FrameStateBeforeAndAfter states(this, iterator);
1749 Node* receiver = 1801 Node* receiver =
1750 environment()->LookupRegister(iterator.GetRegisterOperand(0)); 1802 environment()->LookupRegister(iterator.GetRegisterOperand(0));
1751 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(1)); 1803 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(1));
1752 int catch_reg_pair_index = iterator.GetRegisterOperand(2).index(); 1804 int catch_reg_pair_index = iterator.GetRegisterOperand(2).index();
1753 Node* cache_type = environment()->LookupRegister( 1805 Node* cache_type = environment()->LookupRegister(
1754 interpreter::Register(catch_reg_pair_index)); 1806 interpreter::Register(catch_reg_pair_index));
1755 Node* cache_array = environment()->LookupRegister( 1807 Node* cache_array = environment()->LookupRegister(
1756 interpreter::Register(catch_reg_pair_index + 1)); 1808 interpreter::Register(catch_reg_pair_index + 1));
1757 1809
1758 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, 1810 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array,
1759 cache_type, index); 1811 cache_type, index);
1760 environment()->BindAccumulator(value, &states); 1812 environment()->BindAccumulator(value, &states);
1761 } 1813 }
1762 1814
1763 1815
1816 void BytecodeGraphBuilder::VisitForInNext(
1817 const interpreter::BytecodeArrayIterator& iterator) {
1818 BuildForInNext(iterator);
1819 }
1820
1821
1822 void BytecodeGraphBuilder::VisitForInNextWide(
1823 const interpreter::BytecodeArrayIterator& iterator) {
1824 BuildForInNext(iterator);
1825 }
1826
1827
1764 void BytecodeGraphBuilder::VisitForInStep( 1828 void BytecodeGraphBuilder::VisitForInStep(
1765 const interpreter::BytecodeArrayIterator& iterator) { 1829 const interpreter::BytecodeArrayIterator& iterator) {
1766 FrameStateBeforeAndAfter states(this, iterator); 1830 FrameStateBeforeAndAfter states(this, iterator);
1767 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); 1831 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0));
1768 index = NewNode(javascript()->ForInStep(), index); 1832 index = NewNode(javascript()->ForInStep(), index);
1769 environment()->BindAccumulator(index, &states); 1833 environment()->BindAccumulator(index, &states);
1770 } 1834 }
1771 1835
1772 1836
1773 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( 1837 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches(
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
2025 2089
2026 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { 2090 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) {
2027 if (environment()->IsMarkedAsUnreachable()) return; 2091 if (environment()->IsMarkedAsUnreachable()) return;
2028 environment()->MarkAsUnreachable(); 2092 environment()->MarkAsUnreachable();
2029 exit_controls_.push_back(exit); 2093 exit_controls_.push_back(exit);
2030 } 2094 }
2031 2095
2032 } // namespace compiler 2096 } // namespace compiler
2033 } // namespace internal 2097 } // namespace internal
2034 } // namespace v8 2098 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.h ('k') | src/compiler/interpreter-assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698