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/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/js-typed-lowering.h" | 8 #include "src/compiler/js-typed-lowering.h" |
9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
10 #include "src/compiler/node-matchers.h" | 10 #include "src/compiler/node-matchers.h" |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 graph()->NewNode(common()->Merge(2), check_true, check_false); | 973 graph()->NewNode(common()->Merge(2), check_true, check_false); |
974 Node* new_effect = | 974 Node* new_effect = |
975 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); | 975 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); |
976 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, | 976 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, |
977 slow, new_control); | 977 slow, new_control); |
978 ReplaceWithValue(node, new_value, new_effect, new_control); | 978 ReplaceWithValue(node, new_value, new_effect, new_control); |
979 return Changed(new_value); | 979 return Changed(new_value); |
980 } | 980 } |
981 | 981 |
982 | 982 |
983 Reduction JSTypedLowering::ReduceJSLoadDynamicContext(Node* node) { | |
984 DCHECK_EQ(IrOpcode::kJSLoadDynamicContext, node->opcode()); | |
985 DynamicContextAccess const& access = DynamicContextAccessOf(node->op()); | |
986 ContextAccess const& context_access = access.context_access(); | |
987 Node* const context = NodeProperties::GetContextInput(node); | |
988 Node* const state = NodeProperties::GetFrameStateInput(node, 0); | |
989 Node* const effect = NodeProperties::GetEffectInput(node); | |
990 Node* const control = NodeProperties::GetControlInput(node); | |
991 if (access.RequiresFullCheck()) return NoChange(); | |
992 | |
993 // Perform checks whether the fast mode applies, by looking for any extension | |
994 // object which might shadow the optimistic declaration. | |
995 uint32_t bitset = access.check_bitset(); | |
996 Node* check_true = control; | |
997 Node* check_false = graph()->NewNode(common()->Merge(0)); | |
998 for (int depth = 0; bitset != 0; bitset >>= 1, depth++) { | |
999 if ((bitset & 1) == 0) continue; | |
1000 Node* load = graph()->NewNode( | |
1001 javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false), | |
1002 context, context, effect); | |
1003 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), load); | |
Benedikt Meurer
2015/06/03 03:46:52
We can use ReferenceEqual to zero here, see https:
Michael Starzinger
2015/06/03 08:45:00
Done.
| |
1004 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), check, | |
1005 check_true); | |
1006 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | |
1007 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | |
1008 check_false->set_op(common()->Merge(check_false->InputCount() + 1)); | |
1009 check_false->AppendInput(graph()->zone(), if_false); | |
1010 check_true = if_true; | |
1011 } | |
1012 | |
1013 // Fast case, because variable is not shadowed. Perform context slot load. | |
1014 Node* fast = | |
1015 graph()->NewNode(javascript()->LoadContext(context_access.depth(), | |
1016 context_access.index(), false), | |
1017 context, context, effect); | |
1018 | |
1019 // Slow case, because variable potentially shadowed. Perform dynamic lookup. | |
1020 uint32_t check_bitset = DynamicContextAccess::kFullCheckRequired; | |
1021 Node* slow = | |
1022 graph()->NewNode(javascript()->LoadDynamicContext( | |
1023 access.name(), check_bitset, context_access.depth(), | |
1024 context_access.index()), | |
1025 context, context, state, effect, check_false); | |
1026 | |
1027 // Replace value, effect and control uses accordingly. | |
1028 Node* new_control = | |
1029 graph()->NewNode(common()->Merge(2), check_true, check_false); | |
1030 Node* new_effect = | |
1031 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control); | |
1032 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast, | |
1033 slow, new_control); | |
1034 ReplaceWithValue(node, new_value, new_effect, new_control); | |
1035 return Changed(new_value); | |
1036 } | |
1037 | |
1038 | |
983 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { | 1039 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { |
984 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); | 1040 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); |
985 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); | 1041 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); |
986 Handle<SharedFunctionInfo> shared = p.shared_info(); | 1042 Handle<SharedFunctionInfo> shared = p.shared_info(); |
987 | 1043 |
988 // Use the FastNewClosureStub that allocates in new space only for nested | 1044 // Use the FastNewClosureStub that allocates in new space only for nested |
989 // functions that don't need literals cloning. | 1045 // functions that don't need literals cloning. |
990 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { | 1046 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { |
991 Isolate* isolate = jsgraph()->isolate(); | 1047 Isolate* isolate = jsgraph()->isolate(); |
992 Callable callable = CodeFactory::FastNewClosure( | 1048 Callable callable = CodeFactory::FastNewClosure( |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1482 case IrOpcode::kJSLoadProperty: | 1538 case IrOpcode::kJSLoadProperty: |
1483 return ReduceJSLoadProperty(node); | 1539 return ReduceJSLoadProperty(node); |
1484 case IrOpcode::kJSStoreProperty: | 1540 case IrOpcode::kJSStoreProperty: |
1485 return ReduceJSStoreProperty(node); | 1541 return ReduceJSStoreProperty(node); |
1486 case IrOpcode::kJSLoadContext: | 1542 case IrOpcode::kJSLoadContext: |
1487 return ReduceJSLoadContext(node); | 1543 return ReduceJSLoadContext(node); |
1488 case IrOpcode::kJSStoreContext: | 1544 case IrOpcode::kJSStoreContext: |
1489 return ReduceJSStoreContext(node); | 1545 return ReduceJSStoreContext(node); |
1490 case IrOpcode::kJSLoadDynamicGlobal: | 1546 case IrOpcode::kJSLoadDynamicGlobal: |
1491 return ReduceJSLoadDynamicGlobal(node); | 1547 return ReduceJSLoadDynamicGlobal(node); |
1548 case IrOpcode::kJSLoadDynamicContext: | |
1549 return ReduceJSLoadDynamicContext(node); | |
1492 case IrOpcode::kJSCreateClosure: | 1550 case IrOpcode::kJSCreateClosure: |
1493 return ReduceJSCreateClosure(node); | 1551 return ReduceJSCreateClosure(node); |
1494 case IrOpcode::kJSCreateLiteralArray: | 1552 case IrOpcode::kJSCreateLiteralArray: |
1495 return ReduceJSCreateLiteralArray(node); | 1553 return ReduceJSCreateLiteralArray(node); |
1496 case IrOpcode::kJSCreateLiteralObject: | 1554 case IrOpcode::kJSCreateLiteralObject: |
1497 return ReduceJSCreateLiteralObject(node); | 1555 return ReduceJSCreateLiteralObject(node); |
1498 case IrOpcode::kJSCreateWithContext: | 1556 case IrOpcode::kJSCreateWithContext: |
1499 return ReduceJSCreateWithContext(node); | 1557 return ReduceJSCreateWithContext(node); |
1500 case IrOpcode::kJSCreateBlockContext: | 1558 case IrOpcode::kJSCreateBlockContext: |
1501 return ReduceJSCreateBlockContext(node); | 1559 return ReduceJSCreateBlockContext(node); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1540 } | 1598 } |
1541 | 1599 |
1542 | 1600 |
1543 MachineOperatorBuilder* JSTypedLowering::machine() const { | 1601 MachineOperatorBuilder* JSTypedLowering::machine() const { |
1544 return jsgraph()->machine(); | 1602 return jsgraph()->machine(); |
1545 } | 1603 } |
1546 | 1604 |
1547 } // namespace compiler | 1605 } // namespace compiler |
1548 } // namespace internal | 1606 } // namespace internal |
1549 } // namespace v8 | 1607 } // namespace v8 |
OLD | NEW |