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

Unified Diff: src/compiler/js-typed-lowering.cc

Issue 2839623003: [modules] Factor out cell load into helper function. (Closed)
Patch Set: Assign cell in unreachable path. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/objects.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/js-typed-lowering.cc
diff --git a/src/compiler/js-typed-lowering.cc b/src/compiler/js-typed-lowering.cc
index 50a33c355f7aae634024d0a58a8ccd73ca933b5b..b3f6af87b502cf0d60e530be4fe06d004c9682ba 100644
--- a/src/compiler/js-typed-lowering.cc
+++ b/src/compiler/js-typed-lowering.cc
@@ -1391,35 +1391,41 @@ Reduction JSTypedLowering::ReduceJSStoreContext(Node* node) {
return Changed(node);
}
-Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) {
- DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode());
+Node* JSTypedLowering::BuildGetModuleCell(Node* node) {
+ DCHECK(node->opcode() == IrOpcode::kJSLoadModule ||
+ node->opcode() == IrOpcode::kJSStoreModule);
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
int32_t cell_index = OpParameter<int32_t>(node);
Node* module = NodeProperties::GetValueInput(node, 0);
- Node* array;
+ FieldAccess field_access;
int index;
if (ModuleDescriptor::GetCellIndexKind(cell_index) ==
ModuleDescriptor::kExport) {
- array = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForModuleRegularExports()),
- module, effect, control);
+ field_access = AccessBuilder::ForModuleRegularExports();
index = cell_index - 1;
} else {
DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index),
ModuleDescriptor::kImport);
- array = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForModuleRegularImports()),
- module, effect, control);
+ field_access = AccessBuilder::ForModuleRegularImports();
index = -cell_index - 1;
}
-
- Node* cell = effect = graph()->NewNode(
+ Node* array = effect = graph()->NewNode(simplified()->LoadField(field_access),
+ module, effect, control);
+ return graph()->NewNode(
simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array,
effect, control);
+}
+Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) {
+ DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode());
+ Node* effect = NodeProperties::GetEffectInput(node);
+ Node* control = NodeProperties::GetControlInput(node);
+
+ Node* cell = BuildGetModuleCell(node);
+ if (cell->op()->EffectOutputCount() > 0) effect = cell;
Node* value = effect =
graph()->NewNode(simplified()->LoadField(AccessBuilder::ForCellValue()),
cell, effect, control);
@@ -1432,32 +1438,12 @@ Reduction JSTypedLowering::ReduceJSStoreModule(Node* node) {
DCHECK_EQ(IrOpcode::kJSStoreModule, node->opcode());
Node* effect = NodeProperties::GetEffectInput(node);
Node* control = NodeProperties::GetControlInput(node);
-
- int32_t cell_index = OpParameter<int32_t>(node);
- Node* module = NodeProperties::GetValueInput(node, 0);
Node* value = NodeProperties::GetValueInput(node, 1);
+ DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(OpParameter<int32_t>(node)),
+ ModuleDescriptor::kExport);
- Node* array;
- int index;
- if (ModuleDescriptor::GetCellIndexKind(cell_index) ==
- ModuleDescriptor::kExport) {
- array = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForModuleRegularExports()),
- module, effect, control);
- index = cell_index - 1;
- } else {
- DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index),
- ModuleDescriptor::kImport);
- array = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForModuleRegularImports()),
- module, effect, control);
- index = -cell_index - 1;
- }
-
- Node* cell = effect = graph()->NewNode(
- simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array,
- effect, control);
-
+ Node* cell = BuildGetModuleCell(node);
+ if (cell->op()->EffectOutputCount() > 0) effect = cell;
effect =
graph()->NewNode(simplified()->StoreField(AccessBuilder::ForCellValue()),
cell, value, effect, control);
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698