| 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 <deque> | 7 #include <deque> |
| 8 #include <queue> | 8 #include <queue> |
| 9 | 9 |
| 10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 // representation changes between uses that demand a particular | 47 // representation changes between uses that demand a particular |
| 48 // representation and nodes that produce a different representation. | 48 // representation and nodes that produce a different representation. |
| 49 LOWER | 49 LOWER |
| 50 }; | 50 }; |
| 51 | 51 |
| 52 | 52 |
| 53 class RepresentationSelector { | 53 class RepresentationSelector { |
| 54 public: | 54 public: |
| 55 // Information for each node tracked during the fixpoint. | 55 // Information for each node tracked during the fixpoint. |
| 56 struct NodeInfo { | 56 struct NodeInfo { |
| 57 RepTypeUnion use : 14; // Union of all usages for the node. | 57 MachineTypeUnion use : 14; // Union of all usages for the node. |
| 58 bool queued : 1; // Bookkeeping for the traversal. | 58 bool queued : 1; // Bookkeeping for the traversal. |
| 59 bool visited : 1; // Bookkeeping for the traversal. | 59 bool visited : 1; // Bookkeeping for the traversal. |
| 60 RepTypeUnion output : 14; // Output type of the node. | 60 MachineTypeUnion output : 14; // Output type of the node. |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 RepresentationSelector(JSGraph* jsgraph, Zone* zone, | 63 RepresentationSelector(JSGraph* jsgraph, Zone* zone, |
| 64 RepresentationChanger* changer) | 64 RepresentationChanger* changer) |
| 65 : jsgraph_(jsgraph), | 65 : jsgraph_(jsgraph), |
| 66 count_(jsgraph->graph()->NodeCount()), | 66 count_(jsgraph->graph()->NodeCount()), |
| 67 info_(zone->NewArray<NodeInfo>(count_)), | 67 info_(zone->NewArray<NodeInfo>(count_)), |
| 68 nodes_(NodeVector::allocator_type(zone)), | 68 nodes_(NodeVector::allocator_type(zone)), |
| 69 replacements_(NodeVector::allocator_type(zone)), | 69 replacements_(NodeVector::allocator_type(zone)), |
| 70 contains_js_nodes_(false), | 70 contains_js_nodes_(false), |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 for (NodeVector::iterator i = replacements_.begin(); | 108 for (NodeVector::iterator i = replacements_.begin(); |
| 109 i != replacements_.end(); ++i) { | 109 i != replacements_.end(); ++i) { |
| 110 Node* node = *i; | 110 Node* node = *i; |
| 111 Node* replacement = *(++i); | 111 Node* replacement = *(++i); |
| 112 node->ReplaceUses(replacement); | 112 node->ReplaceUses(replacement); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Enqueue {node} if the {use} contains new information for that node. | 116 // Enqueue {node} if the {use} contains new information for that node. |
| 117 // Add {node} to {nodes_} if this is the first time it's been visited. | 117 // Add {node} to {nodes_} if this is the first time it's been visited. |
| 118 void Enqueue(Node* node, RepTypeUnion use = 0) { | 118 void Enqueue(Node* node, MachineTypeUnion use = 0) { |
| 119 if (phase_ != PROPAGATE) return; | 119 if (phase_ != PROPAGATE) return; |
| 120 NodeInfo* info = GetInfo(node); | 120 NodeInfo* info = GetInfo(node); |
| 121 if (!info->visited) { | 121 if (!info->visited) { |
| 122 // First visit of this node. | 122 // First visit of this node. |
| 123 info->visited = true; | 123 info->visited = true; |
| 124 info->queued = true; | 124 info->queued = true; |
| 125 nodes_.push_back(node); | 125 nodes_.push_back(node); |
| 126 queue_.push(node); | 126 queue_.push(node); |
| 127 TRACE((" initial: ")); | 127 TRACE((" initial: ")); |
| 128 info->use |= use; | 128 info->use |= use; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 140 } else { | 140 } else { |
| 141 TRACE((" inqueue: ")); | 141 TRACE((" inqueue: ")); |
| 142 } | 142 } |
| 143 info->use |= use; | 143 info->use |= use; |
| 144 PrintUseInfo(node); | 144 PrintUseInfo(node); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 bool lower() { return phase_ == LOWER; } | 148 bool lower() { return phase_ == LOWER; } |
| 149 | 149 |
| 150 void Enqueue(Node* node, RepType use) { | 150 void Enqueue(Node* node, MachineType use) { |
| 151 Enqueue(node, static_cast<RepTypeUnion>(use)); | 151 Enqueue(node, static_cast<MachineTypeUnion>(use)); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void SetOutput(Node* node, RepTypeUnion output) { | 154 void SetOutput(Node* node, MachineTypeUnion output) { |
| 155 // Every node should have at most one output representation. Note that | 155 // Every node should have at most one output representation. Note that |
| 156 // phis can have 0, if they have not been used in a representation-inducing | 156 // phis can have 0, if they have not been used in a representation-inducing |
| 157 // instruction. | 157 // instruction. |
| 158 DCHECK((output & rMask) == 0 || IsPowerOf2(output & rMask)); | 158 DCHECK((output & rMask) == 0 || IsPowerOf2(output & rMask)); |
| 159 GetInfo(node)->output = output; | 159 GetInfo(node)->output = output; |
| 160 } | 160 } |
| 161 | 161 |
| 162 bool BothInputsAre(Node* node, Type* type) { | 162 bool BothInputsAre(Node* node, Type* type) { |
| 163 DCHECK_EQ(2, node->InputCount()); | 163 DCHECK_EQ(2, node->InputCount()); |
| 164 return NodeProperties::GetBounds(node->InputAt(0)).upper->Is(type) && | 164 return NodeProperties::GetBounds(node->InputAt(0)).upper->Is(type) && |
| 165 NodeProperties::GetBounds(node->InputAt(1)).upper->Is(type); | 165 NodeProperties::GetBounds(node->InputAt(1)).upper->Is(type); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void ProcessInput(Node* node, int index, RepTypeUnion use) { | 168 void ProcessInput(Node* node, int index, MachineTypeUnion use) { |
| 169 Node* input = node->InputAt(index); | 169 Node* input = node->InputAt(index); |
| 170 if (phase_ == PROPAGATE) { | 170 if (phase_ == PROPAGATE) { |
| 171 // In the propagate phase, propagate the usage information backward. | 171 // In the propagate phase, propagate the usage information backward. |
| 172 Enqueue(input, use); | 172 Enqueue(input, use); |
| 173 } else { | 173 } else { |
| 174 // In the change phase, insert a change before the use if necessary. | 174 // In the change phase, insert a change before the use if necessary. |
| 175 if ((use & rMask) == 0) return; // No input requirement on the use. | 175 if ((use & rMask) == 0) return; // No input requirement on the use. |
| 176 RepTypeUnion output = GetInfo(input)->output; | 176 MachineTypeUnion output = GetInfo(input)->output; |
| 177 if ((output & rMask & use) == 0) { | 177 if ((output & rMask & use) == 0) { |
| 178 // Output representation doesn't match usage. | 178 // Output representation doesn't match usage. |
| 179 TRACE((" change: #%d:%s(@%d #%d:%s) ", node->id(), | 179 TRACE((" change: #%d:%s(@%d #%d:%s) ", node->id(), |
| 180 node->op()->mnemonic(), index, input->id(), | 180 node->op()->mnemonic(), index, input->id(), |
| 181 input->op()->mnemonic())); | 181 input->op()->mnemonic())); |
| 182 TRACE((" from ")); | 182 TRACE((" from ")); |
| 183 PrintInfo(output); | 183 PrintInfo(output); |
| 184 TRACE((" to ")); | 184 TRACE((" to ")); |
| 185 PrintInfo(use); | 185 PrintInfo(use); |
| 186 TRACE(("\n")); | 186 TRACE(("\n")); |
| 187 Node* n = changer_->GetRepresentationFor(input, output, use); | 187 Node* n = changer_->GetRepresentationFor(input, output, use); |
| 188 node->ReplaceInput(index, n); | 188 node->ReplaceInput(index, n); |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 } | 191 } |
| 192 | 192 |
| 193 static const RepTypeUnion kFloat64 = rFloat64 | tNumber; | |
| 194 static const RepTypeUnion kInt32 = rWord32 | tInt32; | |
| 195 static const RepTypeUnion kUint32 = rWord32 | tUint32; | |
| 196 static const RepTypeUnion kInt64 = rWord64 | tInt64; | |
| 197 static const RepTypeUnion kUint64 = rWord64 | tUint64; | |
| 198 static const RepTypeUnion kAnyTagged = rTagged | tAny; | |
| 199 | |
| 200 // The default, most general visitation case. For {node}, process all value, | 193 // The default, most general visitation case. For {node}, process all value, |
| 201 // context, effect, and control inputs, assuming that value inputs should have | 194 // context, effect, and control inputs, assuming that value inputs should have |
| 202 // {rTagged} representation and can observe all output values {tAny}. | 195 // {rTagged} representation and can observe all output values {tAny}. |
| 203 void VisitInputs(Node* node) { | 196 void VisitInputs(Node* node) { |
| 204 InputIter i = node->inputs().begin(); | 197 InputIter i = node->inputs().begin(); |
| 205 for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0; | 198 for (int j = OperatorProperties::GetValueInputCount(node->op()); j > 0; |
| 206 ++i, j--) { | 199 ++i, j--) { |
| 207 ProcessInput(node, i.index(), kAnyTagged); // Value inputs | 200 ProcessInput(node, i.index(), mAnyTagged); // Value inputs |
| 208 } | 201 } |
| 209 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; | 202 for (int j = OperatorProperties::GetContextInputCount(node->op()); j > 0; |
| 210 ++i, j--) { | 203 ++i, j--) { |
| 211 ProcessInput(node, i.index(), kAnyTagged); // Context inputs | 204 ProcessInput(node, i.index(), mAnyTagged); // Context inputs |
| 212 } | 205 } |
| 213 for (int j = OperatorProperties::GetEffectInputCount(node->op()); j > 0; | 206 for (int j = OperatorProperties::GetEffectInputCount(node->op()); j > 0; |
| 214 ++i, j--) { | 207 ++i, j--) { |
| 215 Enqueue(*i); // Effect inputs: just visit | 208 Enqueue(*i); // Effect inputs: just visit |
| 216 } | 209 } |
| 217 for (int j = OperatorProperties::GetControlInputCount(node->op()); j > 0; | 210 for (int j = OperatorProperties::GetControlInputCount(node->op()); j > 0; |
| 218 ++i, j--) { | 211 ++i, j--) { |
| 219 Enqueue(*i); // Control inputs: just visit | 212 Enqueue(*i); // Control inputs: just visit |
| 220 } | 213 } |
| 221 SetOutput(node, kAnyTagged); | 214 SetOutput(node, mAnyTagged); |
| 222 } | 215 } |
| 223 | 216 |
| 224 // Helper for binops of the I x I -> O variety. | 217 // Helper for binops of the I x I -> O variety. |
| 225 void VisitBinop(Node* node, RepTypeUnion input_use, RepTypeUnion output) { | 218 void VisitBinop(Node* node, MachineTypeUnion input_use, |
| 219 MachineTypeUnion output) { |
| 226 DCHECK_EQ(2, node->InputCount()); | 220 DCHECK_EQ(2, node->InputCount()); |
| 227 ProcessInput(node, 0, input_use); | 221 ProcessInput(node, 0, input_use); |
| 228 ProcessInput(node, 1, input_use); | 222 ProcessInput(node, 1, input_use); |
| 229 SetOutput(node, output); | 223 SetOutput(node, output); |
| 230 } | 224 } |
| 231 | 225 |
| 232 // Helper for unops of the I -> O variety. | 226 // Helper for unops of the I -> O variety. |
| 233 void VisitUnop(Node* node, RepTypeUnion input_use, RepTypeUnion output) { | 227 void VisitUnop(Node* node, MachineTypeUnion input_use, |
| 228 MachineTypeUnion output) { |
| 234 DCHECK_EQ(1, node->InputCount()); | 229 DCHECK_EQ(1, node->InputCount()); |
| 235 ProcessInput(node, 0, input_use); | 230 ProcessInput(node, 0, input_use); |
| 236 SetOutput(node, output); | 231 SetOutput(node, output); |
| 237 } | 232 } |
| 238 | 233 |
| 239 // Helper for leaf nodes. | 234 // Helper for leaf nodes. |
| 240 void VisitLeaf(Node* node, RepTypeUnion output) { | 235 void VisitLeaf(Node* node, MachineTypeUnion output) { |
| 241 DCHECK_EQ(0, node->InputCount()); | 236 DCHECK_EQ(0, node->InputCount()); |
| 242 SetOutput(node, output); | 237 SetOutput(node, output); |
| 243 } | 238 } |
| 244 | 239 |
| 245 // Helpers for specific types of binops. | 240 // Helpers for specific types of binops. |
| 246 void VisitFloat64Binop(Node* node) { VisitBinop(node, kFloat64, kFloat64); } | 241 void VisitFloat64Binop(Node* node) { VisitBinop(node, mFloat64, mFloat64); } |
| 247 void VisitInt32Binop(Node* node) { VisitBinop(node, kInt32, kInt32); } | 242 void VisitInt32Binop(Node* node) { VisitBinop(node, mInt32, mInt32); } |
| 248 void VisitUint32Binop(Node* node) { VisitBinop(node, kUint32, kUint32); } | 243 void VisitUint32Binop(Node* node) { VisitBinop(node, mUint32, mUint32); } |
| 249 void VisitInt64Binop(Node* node) { VisitBinop(node, kInt64, kInt64); } | 244 void VisitInt64Binop(Node* node) { VisitBinop(node, mInt64, mInt64); } |
| 250 void VisitUint64Binop(Node* node) { VisitBinop(node, kUint64, kUint64); } | 245 void VisitUint64Binop(Node* node) { VisitBinop(node, mUint64, mUint64); } |
| 251 void VisitFloat64Cmp(Node* node) { VisitBinop(node, kFloat64, rBit); } | 246 void VisitFloat64Cmp(Node* node) { VisitBinop(node, mFloat64, rBit); } |
| 252 void VisitInt32Cmp(Node* node) { VisitBinop(node, kInt32, rBit); } | 247 void VisitInt32Cmp(Node* node) { VisitBinop(node, mInt32, rBit); } |
| 253 void VisitUint32Cmp(Node* node) { VisitBinop(node, kUint32, rBit); } | 248 void VisitUint32Cmp(Node* node) { VisitBinop(node, mUint32, rBit); } |
| 254 void VisitInt64Cmp(Node* node) { VisitBinop(node, kInt64, rBit); } | 249 void VisitInt64Cmp(Node* node) { VisitBinop(node, mInt64, rBit); } |
| 255 void VisitUint64Cmp(Node* node) { VisitBinop(node, kUint64, rBit); } | 250 void VisitUint64Cmp(Node* node) { VisitBinop(node, mUint64, rBit); } |
| 256 | 251 |
| 257 // Helper for handling phis. | 252 // Helper for handling phis. |
| 258 void VisitPhi(Node* node, RepTypeUnion use) { | 253 void VisitPhi(Node* node, MachineTypeUnion use) { |
| 259 // First, propagate the usage information to inputs of the phi. | 254 // First, propagate the usage information to inputs of the phi. |
| 260 int values = OperatorProperties::GetValueInputCount(node->op()); | 255 int values = OperatorProperties::GetValueInputCount(node->op()); |
| 261 Node::Inputs inputs = node->inputs(); | 256 Node::Inputs inputs = node->inputs(); |
| 262 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); | 257 for (Node::Inputs::iterator iter(inputs.begin()); iter != inputs.end(); |
| 263 ++iter, --values) { | 258 ++iter, --values) { |
| 264 // Propagate {use} of the phi to value inputs, and 0 to control. | 259 // Propagate {use} of the phi to value inputs, and 0 to control. |
| 265 // TODO(titzer): it'd be nice to have distinguished edge kinds here. | 260 // TODO(titzer): it'd be nice to have distinguished edge kinds here. |
| 266 ProcessInput(node, iter.index(), values > 0 ? use : 0); | 261 ProcessInput(node, iter.index(), values > 0 ? use : 0); |
| 267 } | 262 } |
| 268 // Phis adapt to whatever output representation their uses demand, | 263 // Phis adapt to whatever output representation their uses demand, |
| 269 // pushing representation changes to their inputs. | 264 // pushing representation changes to their inputs. |
| 270 RepTypeUnion use_rep = GetUseInfo(node) & rMask; | 265 MachineTypeUnion use_rep = GetUseInfo(node) & rMask; |
| 271 RepTypeUnion use_type = GetUseInfo(node) & tMask; | 266 MachineTypeUnion use_type = GetUseInfo(node) & tMask; |
| 272 RepTypeUnion rep = 0; | 267 MachineTypeUnion rep = 0; |
| 273 if (use_rep & rTagged) { | 268 if (use_rep & rTagged) { |
| 274 rep = rTagged; // Tagged overrides everything. | 269 rep = rTagged; // Tagged overrides everything. |
| 275 } else if (use_rep & rFloat64) { | 270 } else if (use_rep & rFloat64) { |
| 276 rep = rFloat64; | 271 rep = rFloat64; |
| 277 } else if (use_rep & rWord64) { | 272 } else if (use_rep & rWord64) { |
| 278 rep = rWord64; | 273 rep = rWord64; |
| 279 } else if (use_rep & rWord32) { | 274 } else if (use_rep & rWord32) { |
| 280 rep = rWord32; | 275 rep = rWord32; |
| 281 } else if (use_rep & rBit) { | 276 } else if (use_rep & rBit) { |
| 282 rep = rBit; | 277 rep = rBit; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 309 Operator* Uint32Op(Node* node) { | 304 Operator* Uint32Op(Node* node) { |
| 310 return changer_->Uint32OperatorFor(node->opcode()); | 305 return changer_->Uint32OperatorFor(node->opcode()); |
| 311 } | 306 } |
| 312 | 307 |
| 313 Operator* Float64Op(Node* node) { | 308 Operator* Float64Op(Node* node) { |
| 314 return changer_->Float64OperatorFor(node->opcode()); | 309 return changer_->Float64OperatorFor(node->opcode()); |
| 315 } | 310 } |
| 316 | 311 |
| 317 // Dispatching routine for visiting the node {node} with the usage {use}. | 312 // Dispatching routine for visiting the node {node} with the usage {use}. |
| 318 // Depending on the operator, propagate new usage info to the inputs. | 313 // Depending on the operator, propagate new usage info to the inputs. |
| 319 void VisitNode(Node* node, RepTypeUnion use, SimplifiedLowering* lowering) { | 314 void VisitNode(Node* node, MachineTypeUnion use, |
| 315 SimplifiedLowering* lowering) { |
| 320 switch (node->opcode()) { | 316 switch (node->opcode()) { |
| 321 //------------------------------------------------------------------ | 317 //------------------------------------------------------------------ |
| 322 // Common operators. | 318 // Common operators. |
| 323 //------------------------------------------------------------------ | 319 //------------------------------------------------------------------ |
| 324 case IrOpcode::kStart: | 320 case IrOpcode::kStart: |
| 325 case IrOpcode::kDead: | 321 case IrOpcode::kDead: |
| 326 return VisitLeaf(node, 0); | 322 return VisitLeaf(node, 0); |
| 327 case IrOpcode::kParameter: { | 323 case IrOpcode::kParameter: { |
| 328 // TODO(titzer): use representation from linkage. | 324 // TODO(titzer): use representation from linkage. |
| 329 Type* upper = NodeProperties::GetBounds(node).upper; | 325 Type* upper = NodeProperties::GetBounds(node).upper; |
| 330 ProcessInput(node, 0, 0); | 326 ProcessInput(node, 0, 0); |
| 331 SetOutput(node, rTagged | changer_->TypeFromUpperBound(upper)); | 327 SetOutput(node, rTagged | changer_->TypeFromUpperBound(upper)); |
| 332 return; | 328 return; |
| 333 } | 329 } |
| 334 case IrOpcode::kInt32Constant: | 330 case IrOpcode::kInt32Constant: |
| 335 return VisitLeaf(node, rWord32); | 331 return VisitLeaf(node, rWord32); |
| 336 case IrOpcode::kInt64Constant: | 332 case IrOpcode::kInt64Constant: |
| 337 return VisitLeaf(node, rWord64); | 333 return VisitLeaf(node, rWord64); |
| 338 case IrOpcode::kFloat64Constant: | 334 case IrOpcode::kFloat64Constant: |
| 339 return VisitLeaf(node, rFloat64); | 335 return VisitLeaf(node, rFloat64); |
| 340 case IrOpcode::kExternalConstant: | 336 case IrOpcode::kExternalConstant: |
| 341 return VisitLeaf(node, rPtr); | 337 return VisitLeaf(node, mPtr); |
| 342 case IrOpcode::kNumberConstant: | 338 case IrOpcode::kNumberConstant: |
| 343 return VisitLeaf(node, rTagged); | 339 return VisitLeaf(node, rTagged); |
| 344 case IrOpcode::kHeapConstant: | 340 case IrOpcode::kHeapConstant: |
| 345 return VisitLeaf(node, rTagged); | 341 return VisitLeaf(node, rTagged); |
| 346 | 342 |
| 347 case IrOpcode::kEnd: | 343 case IrOpcode::kEnd: |
| 348 case IrOpcode::kIfTrue: | 344 case IrOpcode::kIfTrue: |
| 349 case IrOpcode::kIfFalse: | 345 case IrOpcode::kIfFalse: |
| 350 case IrOpcode::kReturn: | 346 case IrOpcode::kReturn: |
| 351 case IrOpcode::kMerge: | 347 case IrOpcode::kMerge: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 372 #undef DEFINE_JS_CASE | 368 #undef DEFINE_JS_CASE |
| 373 contains_js_nodes_ = true; | 369 contains_js_nodes_ = true; |
| 374 VisitInputs(node); | 370 VisitInputs(node); |
| 375 return SetOutput(node, rTagged); | 371 return SetOutput(node, rTagged); |
| 376 | 372 |
| 377 //------------------------------------------------------------------ | 373 //------------------------------------------------------------------ |
| 378 // Simplified operators. | 374 // Simplified operators. |
| 379 //------------------------------------------------------------------ | 375 //------------------------------------------------------------------ |
| 380 case IrOpcode::kBooleanNot: { | 376 case IrOpcode::kBooleanNot: { |
| 381 if (lower()) { | 377 if (lower()) { |
| 382 RepTypeUnion input = GetInfo(node->InputAt(0))->output; | 378 MachineTypeUnion input = GetInfo(node->InputAt(0))->output; |
| 383 if (input & rBit) { | 379 if (input & rBit) { |
| 384 // BooleanNot(x: rBit) => WordEqual(x, #0) | 380 // BooleanNot(x: rBit) => WordEqual(x, #0) |
| 385 node->set_op(lowering->machine()->WordEqual()); | 381 node->set_op(lowering->machine()->WordEqual()); |
| 386 node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(0)); | 382 node->AppendInput(jsgraph_->zone(), jsgraph_->Int32Constant(0)); |
| 387 } else { | 383 } else { |
| 388 // BooleanNot(x: rTagged) => WordEqual(x, #false) | 384 // BooleanNot(x: rTagged) => WordEqual(x, #false) |
| 389 node->set_op(lowering->machine()->WordEqual()); | 385 node->set_op(lowering->machine()->WordEqual()); |
| 390 node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant()); | 386 node->AppendInput(jsgraph_->zone(), jsgraph_->FalseConstant()); |
| 391 } | 387 } |
| 392 } else { | 388 } else { |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 } | 434 } |
| 439 case IrOpcode::kNumberMultiply: | 435 case IrOpcode::kNumberMultiply: |
| 440 case IrOpcode::kNumberDivide: | 436 case IrOpcode::kNumberDivide: |
| 441 case IrOpcode::kNumberModulus: { | 437 case IrOpcode::kNumberModulus: { |
| 442 // Float64Mul/Div/Mod | 438 // Float64Mul/Div/Mod |
| 443 VisitFloat64Binop(node); | 439 VisitFloat64Binop(node); |
| 444 if (lower()) node->set_op(Float64Op(node)); | 440 if (lower()) node->set_op(Float64Op(node)); |
| 445 break; | 441 break; |
| 446 } | 442 } |
| 447 case IrOpcode::kNumberToInt32: { | 443 case IrOpcode::kNumberToInt32: { |
| 448 RepTypeUnion use_rep = use & rMask; | 444 MachineTypeUnion use_rep = use & rMask; |
| 449 if (lower()) { | 445 if (lower()) { |
| 450 RepTypeUnion in = GetInfo(node->InputAt(0))->output; | 446 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; |
| 451 if ((in & tMask) == tInt32 || (in & rMask) == rWord32) { | 447 if ((in & tMask) == tInt32 || (in & rMask) == rWord32) { |
| 452 // If the input has type int32, or is already a word32, just change | 448 // If the input has type int32, or is already a word32, just change |
| 453 // representation if necessary. | 449 // representation if necessary. |
| 454 VisitUnop(node, tInt32 | use_rep, tInt32 | use_rep); | 450 VisitUnop(node, tInt32 | use_rep, tInt32 | use_rep); |
| 455 DeferReplacement(node, node->InputAt(0)); | 451 DeferReplacement(node, node->InputAt(0)); |
| 456 } else { | 452 } else { |
| 457 // Require the input in float64 format and perform truncation. | 453 // Require the input in float64 format and perform truncation. |
| 458 // TODO(turbofan): could also avoid the truncation with a tag check. | 454 // TODO(turbofan): could also avoid the truncation with a tag check. |
| 459 VisitUnop(node, tInt32 | rFloat64, tInt32 | rWord32); | 455 VisitUnop(node, tInt32 | rFloat64, tInt32 | rWord32); |
| 460 // TODO(titzer): should be a truncation. | 456 // TODO(titzer): should be a truncation. |
| 461 node->set_op(lowering->machine()->ChangeFloat64ToInt32()); | 457 node->set_op(lowering->machine()->ChangeFloat64ToInt32()); |
| 462 } | 458 } |
| 463 } else { | 459 } else { |
| 464 // Propagate a type to the input, but pass through representation. | 460 // Propagate a type to the input, but pass through representation. |
| 465 VisitUnop(node, tInt32, tInt32 | use_rep); | 461 VisitUnop(node, tInt32, tInt32 | use_rep); |
| 466 } | 462 } |
| 467 break; | 463 break; |
| 468 } | 464 } |
| 469 case IrOpcode::kNumberToUint32: { | 465 case IrOpcode::kNumberToUint32: { |
| 470 RepTypeUnion use_rep = use & rMask; | 466 MachineTypeUnion use_rep = use & rMask; |
| 471 if (lower()) { | 467 if (lower()) { |
| 472 RepTypeUnion in = GetInfo(node->InputAt(0))->output; | 468 MachineTypeUnion in = GetInfo(node->InputAt(0))->output; |
| 473 if ((in & tMask) == tUint32 || (in & rMask) == rWord32) { | 469 if ((in & tMask) == tUint32 || (in & rMask) == rWord32) { |
| 474 // The input has type int32, just change representation. | 470 // The input has type int32, just change representation. |
| 475 VisitUnop(node, tUint32 | use_rep, tUint32 | use_rep); | 471 VisitUnop(node, tUint32 | use_rep, tUint32 | use_rep); |
| 476 DeferReplacement(node, node->InputAt(0)); | 472 DeferReplacement(node, node->InputAt(0)); |
| 477 } else { | 473 } else { |
| 478 // Require the input in float64 format to perform truncation. | 474 // Require the input in float64 format to perform truncation. |
| 479 // TODO(turbofan): could also avoid the truncation with a tag check. | 475 // TODO(turbofan): could also avoid the truncation with a tag check. |
| 480 VisitUnop(node, tUint32 | rFloat64, tUint32 | rWord32); | 476 VisitUnop(node, tUint32 | rFloat64, tUint32 | rWord32); |
| 481 // TODO(titzer): should be a truncation. | 477 // TODO(titzer): should be a truncation. |
| 482 node->set_op(lowering->machine()->ChangeFloat64ToUint32()); | 478 node->set_op(lowering->machine()->ChangeFloat64ToUint32()); |
| 483 } | 479 } |
| 484 } else { | 480 } else { |
| 485 // Propagate a type to the input, but pass through representation. | 481 // Propagate a type to the input, but pass through representation. |
| 486 VisitUnop(node, tUint32, tUint32 | use_rep); | 482 VisitUnop(node, tUint32, tUint32 | use_rep); |
| 487 } | 483 } |
| 488 break; | 484 break; |
| 489 } | 485 } |
| 490 case IrOpcode::kReferenceEqual: { | 486 case IrOpcode::kReferenceEqual: { |
| 491 VisitBinop(node, kAnyTagged, rBit); | 487 VisitBinop(node, mAnyTagged, rBit); |
| 492 if (lower()) node->set_op(lowering->machine()->WordEqual()); | 488 if (lower()) node->set_op(lowering->machine()->WordEqual()); |
| 493 break; | 489 break; |
| 494 } | 490 } |
| 495 case IrOpcode::kStringEqual: { | 491 case IrOpcode::kStringEqual: { |
| 496 VisitBinop(node, kAnyTagged, rBit); | 492 VisitBinop(node, mAnyTagged, rBit); |
| 497 // TODO(titzer): lower StringEqual to stub/runtime call. | 493 // TODO(titzer): lower StringEqual to stub/runtime call. |
| 498 break; | 494 break; |
| 499 } | 495 } |
| 500 case IrOpcode::kStringLessThan: { | 496 case IrOpcode::kStringLessThan: { |
| 501 VisitBinop(node, kAnyTagged, rBit); | 497 VisitBinop(node, mAnyTagged, rBit); |
| 502 // TODO(titzer): lower StringLessThan to stub/runtime call. | 498 // TODO(titzer): lower StringLessThan to stub/runtime call. |
| 503 break; | 499 break; |
| 504 } | 500 } |
| 505 case IrOpcode::kStringLessThanOrEqual: { | 501 case IrOpcode::kStringLessThanOrEqual: { |
| 506 VisitBinop(node, kAnyTagged, rBit); | 502 VisitBinop(node, mAnyTagged, rBit); |
| 507 // TODO(titzer): lower StringLessThanOrEqual to stub/runtime call. | 503 // TODO(titzer): lower StringLessThanOrEqual to stub/runtime call. |
| 508 break; | 504 break; |
| 509 } | 505 } |
| 510 case IrOpcode::kStringAdd: { | 506 case IrOpcode::kStringAdd: { |
| 511 VisitBinop(node, kAnyTagged, kAnyTagged); | 507 VisitBinop(node, mAnyTagged, mAnyTagged); |
| 512 // TODO(titzer): lower StringAdd to stub/runtime call. | 508 // TODO(titzer): lower StringAdd to stub/runtime call. |
| 513 break; | 509 break; |
| 514 } | 510 } |
| 515 case IrOpcode::kLoadField: { | 511 case IrOpcode::kLoadField: { |
| 516 FieldAccess access = FieldAccessOf(node->op()); | 512 FieldAccess access = FieldAccessOf(node->op()); |
| 517 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 513 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 518 SetOutput(node, changer_->TypeForField(access)); | 514 SetOutput(node, access.machine_type); |
| 519 if (lower()) lowering->DoLoadField(node); | 515 if (lower()) lowering->DoLoadField(node); |
| 520 break; | 516 break; |
| 521 } | 517 } |
| 522 case IrOpcode::kStoreField: { | 518 case IrOpcode::kStoreField: { |
| 523 FieldAccess access = FieldAccessOf(node->op()); | 519 FieldAccess access = FieldAccessOf(node->op()); |
| 524 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 520 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 525 ProcessInput(node, 1, changer_->TypeForField(access)); | 521 ProcessInput(node, 1, access.machine_type); |
| 526 SetOutput(node, 0); | 522 SetOutput(node, 0); |
| 527 if (lower()) lowering->DoStoreField(node); | 523 if (lower()) lowering->DoStoreField(node); |
| 528 break; | 524 break; |
| 529 } | 525 } |
| 530 case IrOpcode::kLoadElement: { | 526 case IrOpcode::kLoadElement: { |
| 531 ElementAccess access = ElementAccessOf(node->op()); | 527 ElementAccess access = ElementAccessOf(node->op()); |
| 532 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 528 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 533 ProcessInput(node, 1, kInt32); // element index | 529 ProcessInput(node, 1, mInt32); // element index |
| 534 SetOutput(node, changer_->TypeForElement(access)); | 530 SetOutput(node, access.machine_type); |
| 535 if (lower()) lowering->DoLoadElement(node); | 531 if (lower()) lowering->DoLoadElement(node); |
| 536 break; | 532 break; |
| 537 } | 533 } |
| 538 case IrOpcode::kStoreElement: { | 534 case IrOpcode::kStoreElement: { |
| 539 ElementAccess access = ElementAccessOf(node->op()); | 535 ElementAccess access = ElementAccessOf(node->op()); |
| 540 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); | 536 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); |
| 541 ProcessInput(node, 1, kInt32); // element index | 537 ProcessInput(node, 1, mInt32); // element index |
| 542 ProcessInput(node, 2, changer_->TypeForElement(access)); | 538 ProcessInput(node, 2, access.machine_type); |
| 543 SetOutput(node, 0); | 539 SetOutput(node, 0); |
| 544 if (lower()) lowering->DoStoreElement(node); | 540 if (lower()) lowering->DoStoreElement(node); |
| 545 break; | 541 break; |
| 546 } | 542 } |
| 547 | 543 |
| 548 //------------------------------------------------------------------ | 544 //------------------------------------------------------------------ |
| 549 // Machine-level operators. | 545 // Machine-level operators. |
| 550 //------------------------------------------------------------------ | 546 //------------------------------------------------------------------ |
| 551 case IrOpcode::kLoad: { | 547 case IrOpcode::kLoad: { |
| 552 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? | 548 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? |
| 553 RepType tBase = rTagged; | 549 MachineType tBase = rTagged; |
| 554 MachineType rep = OpParameter<MachineType>(node); | 550 MachineType machine_type = OpParameter<MachineType>(node); |
| 555 ProcessInput(node, 0, tBase); // pointer or object | 551 ProcessInput(node, 0, tBase); // pointer or object |
| 556 ProcessInput(node, 1, kInt32); // index | 552 ProcessInput(node, 1, mInt32); // index |
| 557 SetOutput(node, changer_->TypeForMachineType(rep)); | 553 SetOutput(node, machine_type); |
| 558 break; | 554 break; |
| 559 } | 555 } |
| 560 case IrOpcode::kStore: { | 556 case IrOpcode::kStore: { |
| 561 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? | 557 // TODO(titzer): machine loads/stores need to know BaseTaggedness!? |
| 562 RepType tBase = rTagged; | 558 MachineType tBase = rTagged; |
| 563 StoreRepresentation rep = OpParameter<StoreRepresentation>(node); | 559 StoreRepresentation rep = OpParameter<StoreRepresentation>(node); |
| 564 ProcessInput(node, 0, tBase); // pointer or object | 560 ProcessInput(node, 0, tBase); // pointer or object |
| 565 ProcessInput(node, 1, kInt32); // index | 561 ProcessInput(node, 1, mInt32); // index |
| 566 ProcessInput(node, 2, changer_->TypeForMachineType(rep.rep)); | 562 ProcessInput(node, 2, rep.machine_type); |
| 567 SetOutput(node, 0); | 563 SetOutput(node, 0); |
| 568 break; | 564 break; |
| 569 } | 565 } |
| 570 case IrOpcode::kWord32Shr: | 566 case IrOpcode::kWord32Shr: |
| 571 // We output unsigned int32 for shift right because JavaScript. | 567 // We output unsigned int32 for shift right because JavaScript. |
| 572 return VisitBinop(node, rWord32, rWord32 | tUint32); | 568 return VisitBinop(node, rWord32, rWord32 | tUint32); |
| 573 case IrOpcode::kWord32And: | 569 case IrOpcode::kWord32And: |
| 574 case IrOpcode::kWord32Or: | 570 case IrOpcode::kWord32Or: |
| 575 case IrOpcode::kWord32Xor: | 571 case IrOpcode::kWord32Xor: |
| 576 case IrOpcode::kWord32Shl: | 572 case IrOpcode::kWord32Shl: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 } | 663 } |
| 668 // TODO(titzer) node->RemoveAllInputs(); // Node is now dead. | 664 // TODO(titzer) node->RemoveAllInputs(); // Node is now dead. |
| 669 } | 665 } |
| 670 | 666 |
| 671 void PrintUseInfo(Node* node) { | 667 void PrintUseInfo(Node* node) { |
| 672 TRACE(("#%d:%-20s ", node->id(), node->op()->mnemonic())); | 668 TRACE(("#%d:%-20s ", node->id(), node->op()->mnemonic())); |
| 673 PrintInfo(GetUseInfo(node)); | 669 PrintInfo(GetUseInfo(node)); |
| 674 TRACE(("\n")); | 670 TRACE(("\n")); |
| 675 } | 671 } |
| 676 | 672 |
| 677 void PrintInfo(RepTypeUnion info) { | 673 void PrintInfo(MachineTypeUnion info) { |
| 678 if (FLAG_trace_representation) { | 674 if (FLAG_trace_representation) { |
| 679 char buf[REP_TYPE_STRLEN]; | 675 OFStream os(stdout); |
| 680 RenderRepTypeUnion(buf, info); | 676 PrintMachineTypeUnionTo(os, info); |
| 681 TRACE(("%s", buf)); | |
| 682 } | 677 } |
| 683 } | 678 } |
| 684 | 679 |
| 685 private: | 680 private: |
| 686 JSGraph* jsgraph_; | 681 JSGraph* jsgraph_; |
| 687 int count_; // number of nodes in the graph | 682 int count_; // number of nodes in the graph |
| 688 NodeInfo* info_; // node id -> usage information | 683 NodeInfo* info_; // node id -> usage information |
| 689 NodeVector nodes_; // collected nodes | 684 NodeVector nodes_; // collected nodes |
| 690 NodeVector replacements_; // replacements to be done after lowering | 685 NodeVector replacements_; // replacements to be done after lowering |
| 691 bool contains_js_nodes_; // {true} if a JS operator was seen | 686 bool contains_js_nodes_; // {true} if a JS operator was seen |
| 692 Phase phase_; // current phase of algorithm | 687 Phase phase_; // current phase of algorithm |
| 693 RepresentationChanger* changer_; // for inserting representation changes | 688 RepresentationChanger* changer_; // for inserting representation changes |
| 694 | 689 |
| 695 std::queue<Node*, std::deque<Node*, NodePtrZoneAllocator> > queue_; | 690 std::queue<Node*, std::deque<Node*, NodePtrZoneAllocator> > queue_; |
| 696 | 691 |
| 697 NodeInfo* GetInfo(Node* node) { | 692 NodeInfo* GetInfo(Node* node) { |
| 698 DCHECK(node->id() >= 0); | 693 DCHECK(node->id() >= 0); |
| 699 DCHECK(node->id() < count_); | 694 DCHECK(node->id() < count_); |
| 700 return &info_[node->id()]; | 695 return &info_[node->id()]; |
| 701 } | 696 } |
| 702 | 697 |
| 703 RepTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; } | 698 MachineTypeUnion GetUseInfo(Node* node) { return GetInfo(node)->use; } |
| 704 }; | 699 }; |
| 705 | 700 |
| 706 | 701 |
| 707 Node* SimplifiedLowering::IsTagged(Node* node) { | 702 Node* SimplifiedLowering::IsTagged(Node* node) { |
| 708 // TODO(titzer): factor this out to a TaggingScheme abstraction. | 703 // TODO(titzer): factor this out to a TaggingScheme abstraction. |
| 709 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. | 704 STATIC_ASSERT(kSmiTagMask == 1); // Only works if tag is the low bit. |
| 710 return graph()->NewNode(machine()->WordAnd(), node, | 705 return graph()->NewNode(machine()->WordAnd(), node, |
| 711 jsgraph()->Int32Constant(kSmiTagMask)); | 706 jsgraph()->Int32Constant(kSmiTagMask)); |
| 712 } | 707 } |
| 713 | 708 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 continue; | 747 continue; |
| 753 } | 748 } |
| 754 ++iter; | 749 ++iter; |
| 755 } | 750 } |
| 756 } | 751 } |
| 757 | 752 |
| 758 | 753 |
| 759 void SimplifiedLowering::DoChangeTaggedToUI32(Node* node, Node* effect, | 754 void SimplifiedLowering::DoChangeTaggedToUI32(Node* node, Node* effect, |
| 760 Node* control, bool is_signed) { | 755 Node* control, bool is_signed) { |
| 761 // if (IsTagged(val)) | 756 // if (IsTagged(val)) |
| 762 // ConvertFloat64To(Int32|Uint32)(Load[kMachineFloat64](input, #value_offset)) | 757 // ConvertFloat64To(Int32|Uint32)(Load[mFloat64](input, #value_offset)) |
| 763 // else Untag(val) | 758 // else Untag(val) |
| 764 Node* val = node->InputAt(0); | 759 Node* val = node->InputAt(0); |
| 765 Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control); | 760 Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control); |
| 766 | 761 |
| 767 // true branch. | 762 // true branch. |
| 768 Node* tbranch = graph()->NewNode(common()->IfTrue(), branch); | 763 Node* tbranch = graph()->NewNode(common()->IfTrue(), branch); |
| 769 Node* loaded = graph()->NewNode( | 764 Node* loaded = graph()->NewNode( |
| 770 machine()->Load(kMachineFloat64), val, | 765 machine()->Load(mFloat64), val, |
| 771 OffsetMinusTagConstant(HeapNumber::kValueOffset), effect); | 766 OffsetMinusTagConstant(HeapNumber::kValueOffset), effect); |
| 772 Operator* op = is_signed ? machine()->ChangeFloat64ToInt32() | 767 Operator* op = is_signed ? machine()->ChangeFloat64ToInt32() |
| 773 : machine()->ChangeFloat64ToUint32(); | 768 : machine()->ChangeFloat64ToUint32(); |
| 774 Node* converted = graph()->NewNode(op, loaded); | 769 Node* converted = graph()->NewNode(op, loaded); |
| 775 | 770 |
| 776 // false branch. | 771 // false branch. |
| 777 Node* fbranch = graph()->NewNode(common()->IfFalse(), branch); | 772 Node* fbranch = graph()->NewNode(common()->IfFalse(), branch); |
| 778 Node* untagged = Untag(val); | 773 Node* untagged = Untag(val); |
| 779 | 774 |
| 780 // merge. | 775 // merge. |
| 781 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch); | 776 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch); |
| 782 Node* phi = graph()->NewNode(common()->Phi(2), converted, untagged, merge); | 777 Node* phi = graph()->NewNode(common()->Phi(2), converted, untagged, merge); |
| 783 UpdateControlSuccessors(control, merge); | 778 UpdateControlSuccessors(control, merge); |
| 784 branch->ReplaceInput(1, control); | 779 branch->ReplaceInput(1, control); |
| 785 node->ReplaceUses(phi); | 780 node->ReplaceUses(phi); |
| 786 } | 781 } |
| 787 | 782 |
| 788 | 783 |
| 789 void SimplifiedLowering::DoChangeTaggedToFloat64(Node* node, Node* effect, | 784 void SimplifiedLowering::DoChangeTaggedToFloat64(Node* node, Node* effect, |
| 790 Node* control) { | 785 Node* control) { |
| 791 // if (IsTagged(input)) Load[kMachineFloat64](input, #value_offset) | 786 // if (IsTagged(input)) Load[mFloat64](input, #value_offset) |
| 792 // else ConvertFloat64(Untag(input)) | 787 // else ConvertFloat64(Untag(input)) |
| 793 Node* val = node->InputAt(0); | 788 Node* val = node->InputAt(0); |
| 794 Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control); | 789 Node* branch = graph()->NewNode(common()->Branch(), IsTagged(val), control); |
| 795 | 790 |
| 796 // true branch. | 791 // true branch. |
| 797 Node* tbranch = graph()->NewNode(common()->IfTrue(), branch); | 792 Node* tbranch = graph()->NewNode(common()->IfTrue(), branch); |
| 798 Node* loaded = graph()->NewNode( | 793 Node* loaded = graph()->NewNode( |
| 799 machine()->Load(kMachineFloat64), val, | 794 machine()->Load(mFloat64), val, |
| 800 OffsetMinusTagConstant(HeapNumber::kValueOffset), effect); | 795 OffsetMinusTagConstant(HeapNumber::kValueOffset), effect); |
| 801 | 796 |
| 802 // false branch. | 797 // false branch. |
| 803 Node* fbranch = graph()->NewNode(common()->IfFalse(), branch); | 798 Node* fbranch = graph()->NewNode(common()->IfFalse(), branch); |
| 804 Node* untagged = Untag(val); | 799 Node* untagged = Untag(val); |
| 805 Node* converted = | 800 Node* converted = |
| 806 graph()->NewNode(machine()->ChangeInt32ToFloat64(), untagged); | 801 graph()->NewNode(machine()->ChangeInt32ToFloat64(), untagged); |
| 807 | 802 |
| 808 // merge. | 803 // merge. |
| 809 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch); | 804 Node* merge = graph()->NewNode(common()->Merge(2), tbranch, fbranch); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 UpdateControlSuccessors(control, merge); | 885 UpdateControlSuccessors(control, merge); |
| 891 branch->ReplaceInput(1, control); | 886 branch->ReplaceInput(1, control); |
| 892 node->ReplaceUses(phi); | 887 node->ReplaceUses(phi); |
| 893 } | 888 } |
| 894 | 889 |
| 895 | 890 |
| 896 static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, | 891 static WriteBarrierKind ComputeWriteBarrierKind(BaseTaggedness base_is_tagged, |
| 897 MachineType representation, | 892 MachineType representation, |
| 898 Type* type) { | 893 Type* type) { |
| 899 // TODO(turbofan): skip write barriers for Smis, etc. | 894 // TODO(turbofan): skip write barriers for Smis, etc. |
| 900 if (base_is_tagged == kTaggedBase && representation == kMachineTagged) { | 895 if (base_is_tagged == kTaggedBase && |
| 896 RepresentationOf(representation) == rTagged) { |
| 901 // Write barriers are only for writes into heap objects (i.e. tagged base). | 897 // Write barriers are only for writes into heap objects (i.e. tagged base). |
| 902 return kFullWriteBarrier; | 898 return kFullWriteBarrier; |
| 903 } | 899 } |
| 904 return kNoWriteBarrier; | 900 return kNoWriteBarrier; |
| 905 } | 901 } |
| 906 | 902 |
| 907 | 903 |
| 908 void SimplifiedLowering::DoLoadField(Node* node) { | 904 void SimplifiedLowering::DoLoadField(Node* node) { |
| 909 const FieldAccess& access = FieldAccessOf(node->op()); | 905 const FieldAccess& access = FieldAccessOf(node->op()); |
| 910 node->set_op(machine_.Load(access.representation)); | 906 node->set_op(machine_.Load(access.machine_type)); |
| 911 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 907 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
| 912 node->InsertInput(zone(), 1, offset); | 908 node->InsertInput(zone(), 1, offset); |
| 913 } | 909 } |
| 914 | 910 |
| 915 | 911 |
| 916 void SimplifiedLowering::DoStoreField(Node* node) { | 912 void SimplifiedLowering::DoStoreField(Node* node) { |
| 917 const FieldAccess& access = FieldAccessOf(node->op()); | 913 const FieldAccess& access = FieldAccessOf(node->op()); |
| 918 WriteBarrierKind kind = ComputeWriteBarrierKind( | 914 WriteBarrierKind kind = ComputeWriteBarrierKind( |
| 919 access.base_is_tagged, access.representation, access.type); | 915 access.base_is_tagged, access.machine_type, access.type); |
| 920 node->set_op(machine_.Store(access.representation, kind)); | 916 node->set_op(machine_.Store(access.machine_type, kind)); |
| 921 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); | 917 Node* offset = jsgraph()->Int32Constant(access.offset - access.tag()); |
| 922 node->InsertInput(zone(), 1, offset); | 918 node->InsertInput(zone(), 1, offset); |
| 923 } | 919 } |
| 924 | 920 |
| 925 | 921 |
| 926 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, | 922 Node* SimplifiedLowering::ComputeIndex(const ElementAccess& access, |
| 927 Node* index) { | 923 Node* index) { |
| 928 int element_size = 0; | 924 int element_size = ElementSizeOf(access.machine_type); |
| 929 switch (access.representation) { | |
| 930 case kMachineTagged: | |
| 931 element_size = kPointerSize; | |
| 932 break; | |
| 933 case kMachineWord8: | |
| 934 element_size = 1; | |
| 935 break; | |
| 936 case kMachineWord16: | |
| 937 element_size = 2; | |
| 938 break; | |
| 939 case kMachineWord32: | |
| 940 element_size = 4; | |
| 941 break; | |
| 942 case kMachineWord64: | |
| 943 case kMachineFloat64: | |
| 944 element_size = 8; | |
| 945 break; | |
| 946 case kMachineLast: | |
| 947 UNREACHABLE(); | |
| 948 break; | |
| 949 } | |
| 950 if (element_size != 1) { | 925 if (element_size != 1) { |
| 951 index = graph()->NewNode(machine()->Int32Mul(), | 926 index = graph()->NewNode(machine()->Int32Mul(), |
| 952 jsgraph()->Int32Constant(element_size), index); | 927 jsgraph()->Int32Constant(element_size), index); |
| 953 } | 928 } |
| 954 int fixed_offset = access.header_size - access.tag(); | 929 int fixed_offset = access.header_size - access.tag(); |
| 955 if (fixed_offset == 0) return index; | 930 if (fixed_offset == 0) return index; |
| 956 return graph()->NewNode(machine()->Int32Add(), index, | 931 return graph()->NewNode(machine()->Int32Add(), index, |
| 957 jsgraph()->Int32Constant(fixed_offset)); | 932 jsgraph()->Int32Constant(fixed_offset)); |
| 958 } | 933 } |
| 959 | 934 |
| 960 | 935 |
| 961 void SimplifiedLowering::DoLoadElement(Node* node) { | 936 void SimplifiedLowering::DoLoadElement(Node* node) { |
| 962 const ElementAccess& access = ElementAccessOf(node->op()); | 937 const ElementAccess& access = ElementAccessOf(node->op()); |
| 963 node->set_op(machine_.Load(access.representation)); | 938 node->set_op(machine_.Load(access.machine_type)); |
| 964 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 939 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 965 } | 940 } |
| 966 | 941 |
| 967 | 942 |
| 968 void SimplifiedLowering::DoStoreElement(Node* node) { | 943 void SimplifiedLowering::DoStoreElement(Node* node) { |
| 969 const ElementAccess& access = ElementAccessOf(node->op()); | 944 const ElementAccess& access = ElementAccessOf(node->op()); |
| 970 WriteBarrierKind kind = ComputeWriteBarrierKind( | 945 WriteBarrierKind kind = ComputeWriteBarrierKind( |
| 971 access.base_is_tagged, access.representation, access.type); | 946 access.base_is_tagged, access.machine_type, access.type); |
| 972 node->set_op(machine_.Store(access.representation, kind)); | 947 node->set_op(machine_.Store(access.machine_type, kind)); |
| 973 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); | 948 node->ReplaceInput(1, ComputeIndex(access, node->InputAt(1))); |
| 974 } | 949 } |
| 975 | 950 |
| 976 | 951 |
| 977 void SimplifiedLowering::Lower(Node* node) {} | 952 void SimplifiedLowering::Lower(Node* node) {} |
| 978 | 953 |
| 979 | 954 |
| 980 void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) { | 955 void SimplifiedLowering::LowerChange(Node* node, Node* effect, Node* control) { |
| 981 switch (node->opcode()) { | 956 switch (node->opcode()) { |
| 982 case IrOpcode::kChangeTaggedToInt32: | 957 case IrOpcode::kChangeTaggedToInt32: |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1005 break; | 980 break; |
| 1006 default: | 981 default: |
| 1007 UNREACHABLE(); | 982 UNREACHABLE(); |
| 1008 break; | 983 break; |
| 1009 } | 984 } |
| 1010 } | 985 } |
| 1011 | 986 |
| 1012 } // namespace compiler | 987 } // namespace compiler |
| 1013 } // namespace internal | 988 } // namespace internal |
| 1014 } // namespace v8 | 989 } // namespace v8 |
| OLD | NEW |