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 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1392 } | 1392 } |
1393 | 1393 |
1394 Node* JSTypedLowering::BuildGetModuleCell(Node* node) { | 1394 Node* JSTypedLowering::BuildGetModuleCell(Node* node) { |
1395 DCHECK(node->opcode() == IrOpcode::kJSLoadModule || | 1395 DCHECK(node->opcode() == IrOpcode::kJSLoadModule || |
1396 node->opcode() == IrOpcode::kJSStoreModule); | 1396 node->opcode() == IrOpcode::kJSStoreModule); |
1397 Node* effect = NodeProperties::GetEffectInput(node); | 1397 Node* effect = NodeProperties::GetEffectInput(node); |
1398 Node* control = NodeProperties::GetControlInput(node); | 1398 Node* control = NodeProperties::GetControlInput(node); |
1399 | 1399 |
1400 int32_t cell_index = OpParameter<int32_t>(node); | 1400 int32_t cell_index = OpParameter<int32_t>(node); |
1401 Node* module = NodeProperties::GetValueInput(node, 0); | 1401 Node* module = NodeProperties::GetValueInput(node, 0); |
1402 Type* module_type = NodeProperties::GetType(module); | |
1403 | |
1404 if (module_type->IsHeapConstant()) { | |
1405 Handle<Module> module_constant = | |
1406 Handle<Module>::cast(module_type->AsHeapConstant()->Value()); | |
1407 Cell* cell_constant = module_constant->GetCell(cell_index); | |
Michael Starzinger
2017/05/03 17:28:16
nit: Let's just make the local variable handlified
neis
2017/05/04 10:36:21
Done.
| |
1408 return jsgraph()->HeapConstant(handle(cell_constant, isolate())); | |
1409 } | |
1402 | 1410 |
1403 FieldAccess field_access; | 1411 FieldAccess field_access; |
1404 int index; | 1412 int index; |
1405 if (ModuleDescriptor::GetCellIndexKind(cell_index) == | 1413 if (ModuleDescriptor::GetCellIndexKind(cell_index) == |
1406 ModuleDescriptor::kExport) { | 1414 ModuleDescriptor::kExport) { |
1407 field_access = AccessBuilder::ForModuleRegularExports(); | 1415 field_access = AccessBuilder::ForModuleRegularExports(); |
1408 index = cell_index - 1; | 1416 index = cell_index - 1; |
1409 } else { | 1417 } else { |
1410 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), | 1418 DCHECK_EQ(ModuleDescriptor::GetCellIndexKind(cell_index), |
1411 ModuleDescriptor::kImport); | 1419 ModuleDescriptor::kImport); |
1412 field_access = AccessBuilder::ForModuleRegularImports(); | 1420 field_access = AccessBuilder::ForModuleRegularImports(); |
1413 index = -cell_index - 1; | 1421 index = -cell_index - 1; |
1414 } | 1422 } |
1423 | |
1415 Node* array = effect = graph()->NewNode(simplified()->LoadField(field_access), | 1424 Node* array = effect = graph()->NewNode(simplified()->LoadField(field_access), |
1416 module, effect, control); | 1425 module, effect, control); |
1417 return graph()->NewNode( | 1426 return graph()->NewNode( |
1418 simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array, | 1427 simplified()->LoadField(AccessBuilder::ForFixedArraySlot(index)), array, |
1419 effect, control); | 1428 effect, control); |
1420 } | 1429 } |
1421 | 1430 |
1422 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { | 1431 Reduction JSTypedLowering::ReduceJSLoadModule(Node* node) { |
1423 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); | 1432 DCHECK_EQ(IrOpcode::kJSLoadModule, node->opcode()); |
1424 Node* effect = NodeProperties::GetEffectInput(node); | 1433 Node* effect = NodeProperties::GetEffectInput(node); |
(...skipping 802 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2227 } | 2236 } |
2228 | 2237 |
2229 | 2238 |
2230 CompilationDependencies* JSTypedLowering::dependencies() const { | 2239 CompilationDependencies* JSTypedLowering::dependencies() const { |
2231 return dependencies_; | 2240 return dependencies_; |
2232 } | 2241 } |
2233 | 2242 |
2234 } // namespace compiler | 2243 } // namespace compiler |
2235 } // namespace internal | 2244 } // namespace internal |
2236 } // namespace v8 | 2245 } // namespace v8 |
OLD | NEW |