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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 2494753003: [turbofan] Introduce an ExternalPointer type. (Closed)
Patch Set: Stronger ducktape. Created 4 years, 1 month 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/opcodes.h ('k') | src/compiler/typer.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/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "src/address-map.h" 9 #include "src/address-map.h"
10 #include "src/base/bits.h" 10 #include "src/base/bits.h"
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after
851 return MachineRepresentation::kFloat64; 851 return MachineRepresentation::kFloat64;
852 } else if (type->Is( 852 } else if (type->Is(
853 Type::Union(Type::SignedSmall(), Type::NaN(), zone()))) { 853 Type::Union(Type::SignedSmall(), Type::NaN(), zone()))) {
854 // TODO(turbofan): For Phis that return either NaN or some Smi, it's 854 // TODO(turbofan): For Phis that return either NaN or some Smi, it's
855 // beneficial to not go all the way to double, unless the uses are 855 // beneficial to not go all the way to double, unless the uses are
856 // double uses. For tagging that just means some potentially expensive 856 // double uses. For tagging that just means some potentially expensive
857 // allocation code; we might want to do the same for -0 as well? 857 // allocation code; we might want to do the same for -0 as well?
858 return MachineRepresentation::kTagged; 858 return MachineRepresentation::kTagged;
859 } else if (type->Is(Type::Number())) { 859 } else if (type->Is(Type::Number())) {
860 return MachineRepresentation::kFloat64; 860 return MachineRepresentation::kFloat64;
861 } else if (type->Is(Type::Internal())) { 861 } else if (type->Is(Type::ExternalPointer())) {
862 // We mark (u)int64 as Type::Internal. 862 return MachineType::PointerRepresentation();
863 // TODO(jarin) This is a workaround for our lack of (u)int64
864 // types. This can be removed once we can represent (u)int64
865 // unambiguously. (At the moment internal objects, such as the hole,
866 // are also Type::Internal()).
867 bool is_word64 = GetInfo(node->InputAt(0))->representation() ==
868 MachineRepresentation::kWord64;
869 #ifdef DEBUG
870 if (node->opcode() != IrOpcode::kTypeGuard) {
871 // Check that all the inputs agree on being Word64.
872 DCHECK_EQ(IrOpcode::kPhi, node->opcode()); // This only works for phis.
873 for (int i = 1; i < node->op()->ValueInputCount(); i++) {
874 DCHECK_EQ(is_word64, GetInfo(node->InputAt(i))->representation() ==
875 MachineRepresentation::kWord64);
876 }
877 }
878 #endif
879 return is_word64 ? MachineRepresentation::kWord64
880 : MachineRepresentation::kTagged;
881 } 863 }
882 return MachineRepresentation::kTagged; 864 return MachineRepresentation::kTagged;
883 } 865 }
884 866
885 // Helper for handling selects. 867 // Helper for handling selects.
886 void VisitSelect(Node* node, Truncation truncation, 868 void VisitSelect(Node* node, Truncation truncation,
887 SimplifiedLowering* lowering) { 869 SimplifiedLowering* lowering) {
888 ProcessInput(node, 0, UseInfo::Bool()); 870 ProcessInput(node, 0, UseInfo::Bool());
889 871
890 MachineRepresentation output = 872 MachineRepresentation output =
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 } 990 }
1009 NodeProperties::ChangeOp(node, 991 NodeProperties::ChangeOp(node,
1010 jsgraph_->common()->TypedStateValues(types)); 992 jsgraph_->common()->TypedStateValues(types));
1011 } 993 }
1012 SetOutput(node, MachineRepresentation::kTagged); 994 SetOutput(node, MachineRepresentation::kTagged);
1013 } 995 }
1014 996
1015 void VisitObjectState(Node* node) { 997 void VisitObjectState(Node* node) {
1016 if (propagate()) { 998 if (propagate()) {
1017 for (int i = 0; i < node->InputCount(); i++) { 999 for (int i = 0; i < node->InputCount(); i++) {
1018 EnqueueInput(node, i, UseInfo::Any()); 1000 Node* input = node->InputAt(i);
1001 Type* input_type = TypeOf(input);
1002 // TODO(turbofan): Special treatment for ExternalPointer here,
1003 // to avoid incompatible truncations. We really need a story
1004 // for the JSFunction::entry field.
1005 UseInfo use_info = input_type->Is(Type::ExternalPointer())
1006 ? UseInfo::PointerInt()
1007 : UseInfo::Any();
1008 EnqueueInput(node, i, use_info);
1019 } 1009 }
1020 } else if (lower()) { 1010 } else if (lower()) {
1021 Zone* zone = jsgraph_->zone(); 1011 Zone* zone = jsgraph_->zone();
1022 ZoneVector<MachineType>* types = 1012 ZoneVector<MachineType>* types =
1023 new (zone->New(sizeof(ZoneVector<MachineType>))) 1013 new (zone->New(sizeof(ZoneVector<MachineType>)))
1024 ZoneVector<MachineType>(node->InputCount(), zone); 1014 ZoneVector<MachineType>(node->InputCount(), zone);
1025 for (int i = 0; i < node->InputCount(); i++) { 1015 for (int i = 0; i < node->InputCount(); i++) {
1026 Node* input = node->InputAt(i); 1016 Node* input = node->InputAt(i);
1027 NodeInfo* input_info = GetInfo(input); 1017 NodeInfo* input_info = GetInfo(input);
1028 Type* input_type = TypeOf(input); 1018 Type* input_type = TypeOf(input);
1029 MachineRepresentation rep = input_type->IsInhabited() 1019 // TODO(turbofan): Special treatment for ExternalPointer here,
1030 ? input_info->representation() 1020 // to avoid incompatible truncations. We really need a story
1031 : MachineRepresentation::kNone; 1021 // for the JSFunction::entry field.
1032 MachineType machine_type(rep, DeoptValueSemanticOf(input_type)); 1022 if (input_type->Is(Type::ExternalPointer())) {
1033 DCHECK(machine_type.representation() != 1023 (*types)[i] = MachineType::Pointer();
1034 MachineRepresentation::kWord32 || 1024 } else {
1035 machine_type.semantic() == MachineSemantic::kInt32 || 1025 MachineRepresentation rep = input_type->IsInhabited()
1036 machine_type.semantic() == MachineSemantic::kUint32); 1026 ? input_info->representation()
1037 (*types)[i] = machine_type; 1027 : MachineRepresentation::kNone;
1028 MachineType machine_type(rep, DeoptValueSemanticOf(input_type));
1029 DCHECK(machine_type.representation() !=
1030 MachineRepresentation::kWord32 ||
1031 machine_type.semantic() == MachineSemantic::kInt32 ||
1032 machine_type.semantic() == MachineSemantic::kUint32);
1033 (*types)[i] = machine_type;
1034 }
1038 } 1035 }
1039 NodeProperties::ChangeOp(node, 1036 NodeProperties::ChangeOp(node,
1040 jsgraph_->common()->TypedObjectState(types)); 1037 jsgraph_->common()->TypedObjectState(types));
1041 } 1038 }
1042 SetOutput(node, MachineRepresentation::kTagged); 1039 SetOutput(node, MachineRepresentation::kTagged);
1043 } 1040 }
1044 1041
1045 const Operator* Int32Op(Node* node) { 1042 const Operator* Int32Op(Node* node) {
1046 return changer_->Int32OperatorFor(node->opcode()); 1043 return changer_->Int32OperatorFor(node->opcode());
1047 } 1044 }
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 case IrOpcode::kInt32Constant: 1374 case IrOpcode::kInt32Constant:
1378 return VisitLeaf(node, MachineRepresentation::kWord32); 1375 return VisitLeaf(node, MachineRepresentation::kWord32);
1379 case IrOpcode::kInt64Constant: 1376 case IrOpcode::kInt64Constant:
1380 return VisitLeaf(node, MachineRepresentation::kWord64); 1377 return VisitLeaf(node, MachineRepresentation::kWord64);
1381 case IrOpcode::kExternalConstant: 1378 case IrOpcode::kExternalConstant:
1382 return VisitLeaf(node, MachineType::PointerRepresentation()); 1379 return VisitLeaf(node, MachineType::PointerRepresentation());
1383 case IrOpcode::kNumberConstant: 1380 case IrOpcode::kNumberConstant:
1384 return VisitLeaf(node, MachineRepresentation::kTagged); 1381 return VisitLeaf(node, MachineRepresentation::kTagged);
1385 case IrOpcode::kHeapConstant: 1382 case IrOpcode::kHeapConstant:
1386 return VisitLeaf(node, MachineRepresentation::kTaggedPointer); 1383 return VisitLeaf(node, MachineRepresentation::kTaggedPointer);
1384 case IrOpcode::kPointerConstant: {
1385 VisitLeaf(node, MachineType::PointerRepresentation());
1386 if (lower()) {
1387 intptr_t const value = OpParameter<intptr_t>(node);
1388 DeferReplacement(node, lowering->jsgraph()->IntPtrConstant(value));
1389 }
1390 return;
1391 }
1387 1392
1388 case IrOpcode::kBranch: 1393 case IrOpcode::kBranch:
1389 ProcessInput(node, 0, UseInfo::Bool()); 1394 ProcessInput(node, 0, UseInfo::Bool());
1390 EnqueueInput(node, NodeProperties::FirstControlIndex(node)); 1395 EnqueueInput(node, NodeProperties::FirstControlIndex(node));
1391 return; 1396 return;
1392 case IrOpcode::kSwitch: 1397 case IrOpcode::kSwitch:
1393 ProcessInput(node, 0, UseInfo::TruncatingWord32()); 1398 ProcessInput(node, 0, UseInfo::TruncatingWord32());
1394 EnqueueInput(node, NodeProperties::FirstControlIndex(node)); 1399 EnqueueInput(node, NodeProperties::FirstControlIndex(node));
1395 return; 1400 return;
1396 case IrOpcode::kSelect: 1401 case IrOpcode::kSelect:
(...skipping 2003 matching lines...) Expand 10 before | Expand all | Expand 10 after
3400 isolate(), graph()->zone(), callable.descriptor(), 0, flags, 3405 isolate(), graph()->zone(), callable.descriptor(), 0, flags,
3401 Operator::kNoProperties); 3406 Operator::kNoProperties);
3402 to_number_operator_.set(common()->Call(desc)); 3407 to_number_operator_.set(common()->Call(desc));
3403 } 3408 }
3404 return to_number_operator_.get(); 3409 return to_number_operator_.get();
3405 } 3410 }
3406 3411
3407 } // namespace compiler 3412 } // namespace compiler
3408 } // namespace internal 3413 } // namespace internal
3409 } // namespace v8 3414 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/opcodes.h ('k') | src/compiler/typer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698