| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
| 6 | 6 |
| 7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/flow_graph_builder.h" | 9 #include "vm/flow_graph_builder.h" |
| 10 #include "vm/flow_graph_compiler.h" | 10 #include "vm/flow_graph_compiler.h" |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 intptr_t AllocateObjectComp::InputCount() const { | 181 intptr_t AllocateObjectComp::InputCount() const { |
| 182 return arguments().length(); | 182 return arguments().length(); |
| 183 } | 183 } |
| 184 | 184 |
| 185 | 185 |
| 186 intptr_t AllocateObjectWithBoundsCheckComp::InputCount() const { | 186 intptr_t AllocateObjectWithBoundsCheckComp::InputCount() const { |
| 187 return arguments().length(); | 187 return arguments().length(); |
| 188 } | 188 } |
| 189 | 189 |
| 190 | 190 |
| 191 intptr_t BranchInstr::InputCount() const { | |
| 192 return 2; | |
| 193 } | |
| 194 | |
| 195 | |
| 196 Value* BranchInstr::InputAt(intptr_t i) const { | |
| 197 if (i == 0) return left(); | |
| 198 if (i == 1) return right(); | |
| 199 UNREACHABLE(); | |
| 200 return NULL; | |
| 201 } | |
| 202 | |
| 203 | |
| 204 void BranchInstr::SetInputAt(intptr_t i, Value* value) { | |
| 205 if (i == 0) { | |
| 206 left_ = value; | |
| 207 } else if (i == 1) { | |
| 208 right_ = value; | |
| 209 } else { | |
| 210 UNREACHABLE(); | |
| 211 } | |
| 212 } | |
| 213 | |
| 214 | |
| 215 intptr_t ParallelMoveInstr::InputCount() const { | |
| 216 UNREACHABLE(); | |
| 217 return 0; | |
| 218 } | |
| 219 | |
| 220 | |
| 221 Value* ParallelMoveInstr::InputAt(intptr_t i) const { | |
| 222 UNREACHABLE(); | |
| 223 return NULL; | |
| 224 } | |
| 225 | |
| 226 | |
| 227 void ParallelMoveInstr::SetInputAt(intptr_t i, Value* value) { | |
| 228 UNREACHABLE(); | |
| 229 } | |
| 230 | |
| 231 | |
| 232 intptr_t GotoInstr::InputCount() const { | |
| 233 return 0; | |
| 234 } | |
| 235 | |
| 236 | |
| 237 Value* GotoInstr::InputAt(intptr_t i) const { | |
| 238 UNREACHABLE(); | |
| 239 return NULL; | |
| 240 } | |
| 241 | |
| 242 | |
| 243 void GotoInstr::SetInputAt(intptr_t i, Value* value) { | |
| 244 UNREACHABLE(); | |
| 245 } | |
| 246 | |
| 247 | |
| 248 intptr_t PushArgumentInstr::InputCount() const { | |
| 249 return 1; | |
| 250 } | |
| 251 | |
| 252 | |
| 253 Value* PushArgumentInstr::InputAt(intptr_t i) const { | |
| 254 if (i == 0) return value(); | |
| 255 UNREACHABLE(); | |
| 256 return NULL; | |
| 257 } | |
| 258 | |
| 259 | |
| 260 void PushArgumentInstr::SetInputAt(intptr_t i, Value* value) { | |
| 261 if (i == 0) { | |
| 262 value_ = value; | |
| 263 return; | |
| 264 } | |
| 265 UNREACHABLE(); | |
| 266 } | |
| 267 | |
| 268 | |
| 269 intptr_t ReturnInstr::InputCount() const { | |
| 270 return 1; | |
| 271 } | |
| 272 | |
| 273 | |
| 274 Value* ReturnInstr::InputAt(intptr_t i) const { | |
| 275 if (i == 0) return value(); | |
| 276 UNREACHABLE(); | |
| 277 return NULL; | |
| 278 } | |
| 279 | |
| 280 | |
| 281 void ReturnInstr::SetInputAt(intptr_t i, Value* value) { | |
| 282 if (i == 0) { | |
| 283 value_ = value; | |
| 284 return; | |
| 285 } | |
| 286 UNREACHABLE(); | |
| 287 } | |
| 288 | |
| 289 | |
| 290 intptr_t BindInstr::InputCount() const { | |
| 291 return computation()->InputCount(); | |
| 292 } | |
| 293 | |
| 294 | |
| 295 Value* BindInstr::InputAt(intptr_t i) const { | |
| 296 return computation()->InputAt(i); | |
| 297 } | |
| 298 | |
| 299 | |
| 300 void BindInstr::SetInputAt(intptr_t i, Value* value) { | |
| 301 computation()->SetInputAt(i, value); | |
| 302 } | |
| 303 | |
| 304 | |
| 305 intptr_t PhiInstr::InputCount() const { | |
| 306 return inputs_.length(); | |
| 307 } | |
| 308 | |
| 309 | |
| 310 Value* PhiInstr::InputAt(intptr_t i) const { | |
| 311 return inputs_[i]; | |
| 312 } | |
| 313 | |
| 314 | |
| 315 void PhiInstr::SetInputAt(intptr_t i, Value* value) { | |
| 316 inputs_[i] = value; | |
| 317 } | |
| 318 | |
| 319 | |
| 320 RawAbstractType* PhiInstr::StaticType() const { | 191 RawAbstractType* PhiInstr::StaticType() const { |
| 321 // TODO(regis): Return the least upper bound of the input static types. | 192 // TODO(regis): Return the least upper bound of the input static types. |
| 322 // It is much simpler to compute the least specific of the input static types, | 193 // It is much simpler to compute the least specific of the input static types, |
| 323 // and it may be good enough in practice. | 194 // and it may be good enough in practice. |
| 324 // Even better: we could keep the set of the input static types intact. | 195 // Even better: we could keep the set of the input static types intact. |
| 325 AbstractType& least_specific_type = | 196 AbstractType& least_specific_type = |
| 326 AbstractType::Handle(InputAt(0)->StaticType()); | 197 AbstractType::Handle(InputAt(0)->StaticType()); |
| 327 AbstractType& input_type = AbstractType::Handle(); | 198 AbstractType& input_type = AbstractType::Handle(); |
| 328 for (intptr_t i = 1; i < InputCount(); i++) { | 199 for (intptr_t i = 1; i < InputCount(); i++) { |
| 329 input_type = InputAt(i)->StaticType(); | 200 input_type = InputAt(i)->StaticType(); |
| 330 if (input_type.IsMoreSpecificThan(least_specific_type, NULL)) { | 201 if (input_type.IsMoreSpecificThan(least_specific_type, NULL)) { |
| 331 // Type least_specific_type is less specific than input_type. No change. | 202 // Type least_specific_type is less specific than input_type. No change. |
| 332 } else if (least_specific_type.IsMoreSpecificThan(input_type, NULL)) { | 203 } else if (least_specific_type.IsMoreSpecificThan(input_type, NULL)) { |
| 333 // Type input_type is less specific than the current least_specific_type. | 204 // Type input_type is less specific than the current least_specific_type. |
| 334 least_specific_type = input_type.raw(); | 205 least_specific_type = input_type.raw(); |
| 335 } else { | 206 } else { |
| 336 // The types are unrelated. No need to continue. | 207 // The types are unrelated. No need to continue. |
| 337 least_specific_type = Type::ObjectType(); | 208 least_specific_type = Type::ObjectType(); |
| 338 break; | 209 break; |
| 339 } | 210 } |
| 340 } | 211 } |
| 341 return least_specific_type.raw(); | 212 return least_specific_type.raw(); |
| 342 } | 213 } |
| 343 | 214 |
| 344 | 215 |
| 345 intptr_t ParameterInstr::InputCount() const { | |
| 346 return 0; | |
| 347 } | |
| 348 | |
| 349 | |
| 350 Value* ParameterInstr::InputAt(intptr_t i) const { | |
| 351 UNREACHABLE(); | |
| 352 return NULL; | |
| 353 } | |
| 354 | |
| 355 | |
| 356 void ParameterInstr::SetInputAt(intptr_t i, Value* value) { | |
| 357 UNREACHABLE(); | |
| 358 } | |
| 359 | |
| 360 | |
| 361 RawAbstractType* ParameterInstr::StaticType() const { | 216 RawAbstractType* ParameterInstr::StaticType() const { |
| 362 // TODO(regis): Can type feedback provide information about the static type | 217 // TODO(regis): Can type feedback provide information about the static type |
| 363 // of a passed-in parameter? | 218 // of a passed-in parameter? |
| 364 // Note that in checked mode, we could return the static type of the formal | 219 // Note that in checked mode, we could return the static type of the formal |
| 365 // parameter. However, this would be wrong if ParameterInstr is used to type | 220 // parameter. However, this would be wrong if ParameterInstr is used to type |
| 366 // check the passed-in parameter, since the type check would then always be | 221 // check the passed-in parameter, since the type check would then always be |
| 367 // wrongly eliminated. | 222 // wrongly eliminated. |
| 368 return Type::DynamicType(); | 223 return Type::DynamicType(); |
| 369 } | 224 } |
| 370 | 225 |
| 371 | 226 |
| 372 intptr_t GraphEntryInstr::InputCount() const { | |
| 373 return 0; | |
| 374 } | |
| 375 | |
| 376 | |
| 377 Value* GraphEntryInstr::InputAt(intptr_t i) const { | |
| 378 UNREACHABLE(); | |
| 379 return NULL; | |
| 380 } | |
| 381 | |
| 382 | |
| 383 void GraphEntryInstr::SetInputAt(intptr_t i, Value* value) { | |
| 384 UNREACHABLE(); | |
| 385 } | |
| 386 | |
| 387 | |
| 388 intptr_t TargetEntryInstr::InputCount() const { | |
| 389 return 0; | |
| 390 } | |
| 391 | |
| 392 | |
| 393 Value* TargetEntryInstr::InputAt(intptr_t i) const { | |
| 394 UNREACHABLE(); | |
| 395 return NULL; | |
| 396 } | |
| 397 | |
| 398 | |
| 399 void TargetEntryInstr::SetInputAt(intptr_t i, Value* value) { | |
| 400 UNREACHABLE(); | |
| 401 } | |
| 402 | |
| 403 | |
| 404 intptr_t JoinEntryInstr::InputCount() const { | |
| 405 return 0; | |
| 406 } | |
| 407 | |
| 408 | |
| 409 Value* JoinEntryInstr::InputAt(intptr_t i) const { | |
| 410 UNREACHABLE(); | |
| 411 return NULL; | |
| 412 } | |
| 413 | |
| 414 | |
| 415 void JoinEntryInstr::SetInputAt(intptr_t i, Value* value) { | |
| 416 UNREACHABLE(); | |
| 417 } | |
| 418 | |
| 419 | |
| 420 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const { | 227 intptr_t JoinEntryInstr::IndexOfPredecessor(BlockEntryInstr* pred) const { |
| 421 for (intptr_t i = 0; i < predecessors_.length(); ++i) { | 228 for (intptr_t i = 0; i < predecessors_.length(); ++i) { |
| 422 if (predecessors_[i] == pred) return i; | 229 if (predecessors_[i] == pred) return i; |
| 423 } | 230 } |
| 424 return -1; | 231 return -1; |
| 425 } | 232 } |
| 426 | 233 |
| 427 | 234 |
| 428 // ==== Recording assigned variables. | 235 // ==== Recording assigned variables. |
| 429 void Computation::RecordAssignedVars(BitVector* assigned_vars, | 236 void Computation::RecordAssignedVars(BitVector* assigned_vars, |
| (...skipping 925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1355 if (compiler->is_ssa()) { | 1162 if (compiler->is_ssa()) { |
| 1356 ASSERT(locs()->in(0).IsRegister()); | 1163 ASSERT(locs()->in(0).IsRegister()); |
| 1357 __ PushRegister(locs()->in(0).reg()); | 1164 __ PushRegister(locs()->in(0).reg()); |
| 1358 } | 1165 } |
| 1359 } | 1166 } |
| 1360 | 1167 |
| 1361 | 1168 |
| 1362 #undef __ | 1169 #undef __ |
| 1363 | 1170 |
| 1364 } // namespace dart | 1171 } // namespace dart |
| OLD | NEW |