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/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/base/bits.h" | 10 #include "src/base/bits.h" |
10 #include "src/code-factory.h" | 11 #include "src/code-factory.h" |
11 #include "src/compiler/common-operator.h" | 12 #include "src/compiler/common-operator.h" |
12 #include "src/compiler/diamond.h" | 13 #include "src/compiler/diamond.h" |
13 #include "src/compiler/linkage.h" | 14 #include "src/compiler/linkage.h" |
14 #include "src/compiler/node-matchers.h" | 15 #include "src/compiler/node-matchers.h" |
15 #include "src/compiler/node-properties.h" | 16 #include "src/compiler/node-properties.h" |
16 #include "src/compiler/operator-properties.h" | 17 #include "src/compiler/operator-properties.h" |
17 #include "src/compiler/representation-change.h" | 18 #include "src/compiler/representation-change.h" |
18 #include "src/compiler/simplified-operator.h" | 19 #include "src/compiler/simplified-operator.h" |
(...skipping 1125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1144 namespace { | 1145 namespace { |
1145 | 1146 |
1146 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, | 1147 WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, |
1147 MachineType representation, | 1148 MachineType representation, |
1148 Type* field_type, Type* input_type) { | 1149 Type* field_type, Type* input_type) { |
1149 if (field_type->Is(Type::TaggedSigned()) || | 1150 if (field_type->Is(Type::TaggedSigned()) || |
1150 input_type->Is(Type::TaggedSigned())) { | 1151 input_type->Is(Type::TaggedSigned())) { |
1151 // Write barriers are only for writes of heap objects. | 1152 // Write barriers are only for writes of heap objects. |
1152 return kNoWriteBarrier; | 1153 return kNoWriteBarrier; |
1153 } | 1154 } |
| 1155 if (input_type->Is(Type::BooleanOrNullOrUndefined())) { |
| 1156 // Write barriers are not necessary when storing true, false, null or |
| 1157 // undefined, because these special oddballs are always in the root set. |
| 1158 return kNoWriteBarrier; |
| 1159 } |
1154 if (base_is_tagged == kTaggedBase && | 1160 if (base_is_tagged == kTaggedBase && |
1155 RepresentationOf(representation) == kRepTagged) { | 1161 RepresentationOf(representation) == kRepTagged) { |
| 1162 if (input_type->IsConstant() && |
| 1163 input_type->AsConstant()->Value()->IsHeapObject()) { |
| 1164 Handle<HeapObject> input = |
| 1165 Handle<HeapObject>::cast(input_type->AsConstant()->Value()); |
| 1166 if (input->IsMap()) { |
| 1167 // Write barriers for storing maps are cheaper. |
| 1168 return kMapWriteBarrier; |
| 1169 } |
| 1170 Isolate* const isolate = input->GetIsolate(); |
| 1171 RootIndexMap root_index_map(isolate); |
| 1172 int root_index = root_index_map.Lookup(*input); |
| 1173 if (root_index != RootIndexMap::kInvalidRootIndex && |
| 1174 isolate->heap()->RootIsImmortalImmovable(root_index)) { |
| 1175 // Write barriers are unnecessary for immortal immovable roots. |
| 1176 return kNoWriteBarrier; |
| 1177 } |
| 1178 } |
| 1179 if (field_type->Is(Type::TaggedPointer()) || |
| 1180 input_type->Is(Type::TaggedPointer())) { |
| 1181 // Write barriers for heap objects don't need a Smi check. |
| 1182 return kPointerWriteBarrier; |
| 1183 } |
1156 // Write barriers are only for writes into heap objects (i.e. tagged base). | 1184 // Write barriers are only for writes into heap objects (i.e. tagged base). |
1157 return kFullWriteBarrier; | 1185 return kFullWriteBarrier; |
1158 } | 1186 } |
1159 return kNoWriteBarrier; | 1187 return kNoWriteBarrier; |
1160 } | 1188 } |
1161 | 1189 |
1162 } // namespace | 1190 } // namespace |
1163 | 1191 |
1164 | 1192 |
1165 void SimplifiedLowering::DoAllocate(Node* node) { | 1193 void SimplifiedLowering::DoAllocate(Node* node) { |
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1674 ReplaceEffectUses(node, comparison); | 1702 ReplaceEffectUses(node, comparison); |
1675 node->ReplaceInput(0, comparison); | 1703 node->ReplaceInput(0, comparison); |
1676 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); | 1704 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); |
1677 node->TrimInputCount(2); | 1705 node->TrimInputCount(2); |
1678 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); | 1706 NodeProperties::ChangeOp(node, machine()->IntLessThanOrEqual()); |
1679 } | 1707 } |
1680 | 1708 |
1681 } // namespace compiler | 1709 } // namespace compiler |
1682 } // namespace internal | 1710 } // namespace internal |
1683 } // namespace v8 | 1711 } // namespace v8 |
OLD | NEW |