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

Side by Side Diff: src/compiler/js-typed-lowering.cc

Issue 1150723005: [turbofan] Optimized lowering of DYNAMIC_GLOBAL lookup slot loads. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 6 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/js-typed-lowering.h ('k') | src/compiler/operator-properties.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 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 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 NodeProperties::GetValueInput(node, 0), effect, control)); 917 NodeProperties::GetValueInput(node, 0), effect, control));
918 } 918 }
919 node->set_op( 919 node->set_op(
920 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index()))); 920 simplified()->StoreField(AccessBuilder::ForContextSlot(access.index())));
921 node->RemoveInput(2); 921 node->RemoveInput(2);
922 DCHECK_EQ(4, node->InputCount()); 922 DCHECK_EQ(4, node->InputCount());
923 return Changed(node); 923 return Changed(node);
924 } 924 }
925 925
926 926
927 Reduction JSTypedLowering::ReduceJSLoadDynamicGlobal(Node* node) {
928 DCHECK_EQ(IrOpcode::kJSLoadDynamicGlobal, node->opcode());
929 DynamicGlobalAccess const& access = DynamicGlobalAccessOf(node->op());
930 Node* const context = NodeProperties::GetContextInput(node);
931 Node* const state1 = NodeProperties::GetFrameStateInput(node, 0);
932 Node* const state2 = NodeProperties::GetFrameStateInput(node, 1);
933 Node* const effect = NodeProperties::GetEffectInput(node);
934 Node* const control = NodeProperties::GetControlInput(node);
935 if (access.RequiresFullCheck()) return NoChange();
936
937 // Perform checks whether the fast mode applies, by looking for any extension
938 // object which might shadow the optimistic declaration.
939 uint32_t bitset = access.check_bitset();
940 Node* check_true = control;
941 Node* check_false = graph()->NewNode(common()->Merge(0));
942 for (int depth = 0; bitset != 0; bitset >>= 1, depth++) {
943 if ((bitset & 1) == 0) continue;
944 Node* load = graph()->NewNode(
945 javascript()->LoadContext(depth, Context::EXTENSION_INDEX, false),
946 context, context, effect);
947 Node* check = graph()->NewNode(simplified()->ObjectIsSmi(), load);
948 Node* branch = graph()->NewNode(common()->Branch(BranchHint::kTrue), check,
949 check_true);
950 Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
951 Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
952 check_false->set_op(common()->Merge(check_false->InputCount() + 1));
953 check_false->AppendInput(graph()->zone(), if_false);
954 check_true = if_true;
955 }
956
957 // Fast case, because variable is not shadowed. Perform global object load.
958 Unique<Name> name = Unique<Name>::CreateUninitialized(access.name());
959 Node* global = graph()->NewNode(
960 javascript()->LoadContext(0, Context::GLOBAL_OBJECT_INDEX, true), context,
961 context, effect);
962 Node* fast = graph()->NewNode(
963 javascript()->LoadNamed(name, access.feedback(), access.mode()), global,
964 context, state1, state2, global, check_true);
965
966 // Slow case, because variable potentially shadowed. Perform dynamic lookup.
967 uint32_t check_bitset = DynamicGlobalAccess::kFullCheckRequired;
968 Node* slow = graph()->NewNode(
969 javascript()->LoadDynamicGlobal(access.name(), check_bitset,
970 access.feedback(), access.mode()),
971 context, context, state1, state2, effect, check_false);
972
973 // Replace value, effect and control uses accordingly.
974 Node* new_control =
975 graph()->NewNode(common()->Merge(2), check_true, check_false);
976 Node* new_effect =
977 graph()->NewNode(common()->EffectPhi(2), fast, slow, new_control);
978 Node* new_value = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fast,
979 slow, new_control);
980 ReplaceWithValue(node, new_value, new_effect, new_control);
981 return Changed(new_value);
982 }
983
984
927 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) { 985 Reduction JSTypedLowering::ReduceJSCreateClosure(Node* node) {
928 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode()); 986 DCHECK_EQ(IrOpcode::kJSCreateClosure, node->opcode());
929 CreateClosureParameters const& p = CreateClosureParametersOf(node->op()); 987 CreateClosureParameters const& p = CreateClosureParametersOf(node->op());
930 Handle<SharedFunctionInfo> shared = p.shared_info(); 988 Handle<SharedFunctionInfo> shared = p.shared_info();
931 989
932 // Use the FastNewClosureStub that allocates in new space only for nested 990 // Use the FastNewClosureStub that allocates in new space only for nested
933 // functions that don't need literals cloning. 991 // functions that don't need literals cloning.
934 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) { 992 if (p.pretenure() == NOT_TENURED && shared->num_literals() == 0) {
935 Isolate* isolate = jsgraph()->isolate(); 993 Isolate* isolate = jsgraph()->isolate();
936 Callable callable = CodeFactory::FastNewClosure( 994 Callable callable = CodeFactory::FastNewClosure(
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 case IrOpcode::kJSLoadNamed: 1480 case IrOpcode::kJSLoadNamed:
1423 return ReduceJSLoadNamed(node); 1481 return ReduceJSLoadNamed(node);
1424 case IrOpcode::kJSLoadProperty: 1482 case IrOpcode::kJSLoadProperty:
1425 return ReduceJSLoadProperty(node); 1483 return ReduceJSLoadProperty(node);
1426 case IrOpcode::kJSStoreProperty: 1484 case IrOpcode::kJSStoreProperty:
1427 return ReduceJSStoreProperty(node); 1485 return ReduceJSStoreProperty(node);
1428 case IrOpcode::kJSLoadContext: 1486 case IrOpcode::kJSLoadContext:
1429 return ReduceJSLoadContext(node); 1487 return ReduceJSLoadContext(node);
1430 case IrOpcode::kJSStoreContext: 1488 case IrOpcode::kJSStoreContext:
1431 return ReduceJSStoreContext(node); 1489 return ReduceJSStoreContext(node);
1490 case IrOpcode::kJSLoadDynamicGlobal:
1491 return ReduceJSLoadDynamicGlobal(node);
1432 case IrOpcode::kJSCreateClosure: 1492 case IrOpcode::kJSCreateClosure:
1433 return ReduceJSCreateClosure(node); 1493 return ReduceJSCreateClosure(node);
1434 case IrOpcode::kJSCreateLiteralArray: 1494 case IrOpcode::kJSCreateLiteralArray:
1435 return ReduceJSCreateLiteralArray(node); 1495 return ReduceJSCreateLiteralArray(node);
1436 case IrOpcode::kJSCreateLiteralObject: 1496 case IrOpcode::kJSCreateLiteralObject:
1437 return ReduceJSCreateLiteralObject(node); 1497 return ReduceJSCreateLiteralObject(node);
1438 case IrOpcode::kJSCreateWithContext: 1498 case IrOpcode::kJSCreateWithContext:
1439 return ReduceJSCreateWithContext(node); 1499 return ReduceJSCreateWithContext(node);
1440 case IrOpcode::kJSCreateBlockContext: 1500 case IrOpcode::kJSCreateBlockContext:
1441 return ReduceJSCreateBlockContext(node); 1501 return ReduceJSCreateBlockContext(node);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1480 } 1540 }
1481 1541
1482 1542
1483 MachineOperatorBuilder* JSTypedLowering::machine() const { 1543 MachineOperatorBuilder* JSTypedLowering::machine() const {
1484 return jsgraph()->machine(); 1544 return jsgraph()->machine();
1485 } 1545 }
1486 1546
1487 } // namespace compiler 1547 } // namespace compiler
1488 } // namespace internal 1548 } // namespace internal
1489 } // namespace v8 1549 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/js-typed-lowering.h ('k') | src/compiler/operator-properties.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698