Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 1373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1384 } | 1384 } |
| 1385 node->ReplaceInput(0, context); | 1385 node->ReplaceInput(0, context); |
| 1386 node->ReplaceInput(1, value); | 1386 node->ReplaceInput(1, value); |
| 1387 node->ReplaceInput(2, effect); | 1387 node->ReplaceInput(2, effect); |
| 1388 NodeProperties::ChangeOp( | 1388 NodeProperties::ChangeOp( |
| 1389 node, | 1389 node, |
| 1390 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); | 1390 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); |
| 1391 return Changed(node); | 1391 return Changed(node); |
| 1392 } | 1392 } |
| 1393 | 1393 |
| 1394 Node* JSTypedLowering::BuildGetModuleCell(Node* node) { | |
| 1395 DCHECK(node->opcode() == IrOpcode::kJSLoadModule || | |
| 1396 node->opcode() == IrOpcode::kJSStoreModule); | |
| 1397 Node* effect = NodeProperties::GetEffectInput(node); | |
| 1398 Node* control = NodeProperties::GetControlInput(node); | |
| 1399 | |
| 1400 int32_t cell_index = OpParameter<int32_t>(node); | |
| 1401 Node* module = NodeProperties::GetValueInput(node, 0); | |
| 1402 | |
| 1403 FieldAccess field_access; | |
| 1404 int index; | |
| 1405 if (ModuleDescriptor::GetCellIndexKind(cell_index) == | |
| 1406 ModuleDescriptor::kExport) { | |
| 1407 field_access = AccessBuilder::ForModuleRegularExports(); | |
| 1408 index = cell_index - 1; | |
| 1409 } else { | |
| 1410 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), | |
| 1411 ModuleDescriptor::kImport); | |
| 1412 field_access = AccessBuilder::ForModuleRegularImports(); | |
| 1413 index = -cell_index - 1; | |
| 1414 } | |
| 1415 Node* array = effect = graph()->NewNode(simplified()->LoadField(field_access), | |
| 1416 module, effect, control); | |
| 1417 return graph()->NewNode( | |
| 1418 simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array, | |
| 1419 effect, control); | |
| 1420 } | |
| 1421 | |
| 1394 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { | 1422 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { |
| 1395 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); | 1423 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); |
| 1396 Node* effect = NodeProperties::GetEffectInput(node); | 1424 Node* effect = NodeProperties::GetEffectInput(node); |
| 1397 Node* control = NodeProperties::GetControlInput(node); | 1425 Node* control = NodeProperties::GetControlInput(node); |
| 1398 | 1426 |
| 1399 int32_t cell_index = OpParameter<int32_t>(node); | 1427 Node* cell = BuildGetModuleCell(node); |
| 1400 Node* module = NodeProperties::GetValueInput(node, 0); | 1428 if (cell->op()->EffectOutputCount() > 0) effect = cell; |
|
Michael Starzinger
2017/04/27 09:51:02
The returned {LoadField} node will always have an
| |
| 1401 | |
| 1402 Node* array; | |
| 1403 int index; | |
| 1404 if (ModuleDescriptor::GetCellIndexKind(cell_index) == | |
| 1405 ModuleDescriptor::kExport) { | |
| 1406 array = effect = graph()->NewNode( | |
| 1407 simplified()->LoadField(AccessBuilder::ForModuleRegularExports()), | |
| 1408 module, effect, control); | |
| 1409 index = cell_index - 1; | |
| 1410 } else { | |
| 1411 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), | |
| 1412 ModuleDescriptor::kImport); | |
| 1413 array = effect = graph()->NewNode( | |
| 1414 simplified()->LoadField(AccessBuilder::ForModuleRegularImports()), | |
| 1415 module, effect, control); | |
| 1416 index = -cell_index - 1; | |
| 1417 } | |
| 1418 | |
| 1419 Node* cell = effect = graph()->NewNode( | |
| 1420 simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array, | |
| 1421 effect, control); | |
| 1422 | |
| 1423 Node* value = effect = | 1429 Node* value = effect = |
| 1424 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForCellValue()), | 1430 graph()->NewNode(simplified()->LoadField(AccessBuilder::ForCellValue()), |
| 1425 cell, effect, control); | 1431 cell, effect, control); |
| 1426 | 1432 |
| 1427 ReplaceWithValue(node, value, effect, control); | 1433 ReplaceWithValue(node, value, effect, control); |
| 1428 return Changed(value); | 1434 return Changed(value); |
| 1429 } | 1435 } |
| 1430 | 1436 |
| 1431 Reduction JSTypedLowering::ReduceJSStoreModule(Node* node) { | 1437 Reduction JSTypedLowering::ReduceJSStoreModule(Node* node) { |
| 1432 DCHECK_EQ(IrOpcode::kJSStoreModule, node->opcode()); | 1438 DCHECK_EQ(IrOpcode::kJSStoreModule, node->opcode()); |
| 1433 Node* effect = NodeProperties::GetEffectInput(node); | 1439 Node* effect = NodeProperties::GetEffectInput(node); |
| 1434 Node* control = NodeProperties::GetControlInput(node); | 1440 Node* control = NodeProperties::GetControlInput(node); |
| 1441 Node* value = NodeProperties::GetValueInput(node, 1); | |
| 1442 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(OpParameter<int32_t>(node)), | |
| 1443 ModuleDescriptor::kExport); | |
| 1435 | 1444 |
| 1436 int32_t cell_index = OpParameter<int32_t>(node); | 1445 Node* cell = BuildGetModuleCell(node); |
| 1437 Node* module = NodeProperties::GetValueInput(node, 0); | 1446 if (cell->op()->EffectOutputCount() > 0) effect = cell; |
|
Michael Starzinger
2017/04/27 09:51:02
Likewise.
| |
| 1438 Node* value = NodeProperties::GetValueInput(node, 1); | |
| 1439 | |
| 1440 Node* array; | |
| 1441 int index; | |
| 1442 if (ModuleDescriptor::GetCellIndexKind(cell_index) == | |
| 1443 ModuleDescriptor::kExport) { | |
| 1444 array = effect = graph()->NewNode( | |
| 1445 simplified()->LoadField(AccessBuilder::ForModuleRegularExports()), | |
| 1446 module, effect, control); | |
| 1447 index = cell_index - 1; | |
| 1448 } else { | |
| 1449 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), | |
| 1450 ModuleDescriptor::kImport); | |
| 1451 array = effect = graph()->NewNode( | |
| 1452 simplified()->LoadField(AccessBuilder::ForModuleRegularImports()), | |
| 1453 module, effect, control); | |
| 1454 index = -cell_index - 1; | |
| 1455 } | |
| 1456 | |
| 1457 Node* cell = effect = graph()->NewNode( | |
| 1458 simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array, | |
| 1459 effect, control); | |
| 1460 | |
| 1461 effect = | 1447 effect = |
| 1462 graph()->NewNode(simplified()->StoreField(AccessBuilder::ForCellValue()), | 1448 graph()->NewNode(simplified()->StoreField(AccessBuilder::ForCellValue()), |
| 1463 cell, value, effect, control); | 1449 cell, value, effect, control); |
| 1464 | 1450 |
| 1465 ReplaceWithValue(node, effect, effect, control); | 1451 ReplaceWithValue(node, effect, effect, control); |
| 1466 return Changed(value); | 1452 return Changed(value); |
| 1467 } | 1453 } |
| 1468 | 1454 |
| 1469 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { | 1455 Reduction JSTypedLowering::ReduceJSConvertReceiver(Node* node) { |
| 1470 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); | 1456 DCHECK_EQ(IrOpcode::kJSConvertReceiver, node->opcode()); |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2241 } | 2227 } |
| 2242 | 2228 |
| 2243 | 2229 |
| 2244 CompilationDependencies* JSTypedLowering::dependencies() const { | 2230 CompilationDependencies* JSTypedLowering::dependencies() const { |
| 2245 return dependencies_; | 2231 return dependencies_; |
| 2246 } | 2232 } |
| 2247 | 2233 |
| 2248 } // namespace compiler | 2234 } // namespace compiler |
| 2249 } // namespace internal | 2235 } // namespace internal |
| 2250 } // namespace v8 | 2236 } // namespace v8 |
| OLD | NEW |