| 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 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ | 5 #ifndef VM_INTERMEDIATE_LANGUAGE_H_ |
| 6 #define VM_INTERMEDIATE_LANGUAGE_H_ | 6 #define VM_INTERMEDIATE_LANGUAGE_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
| 10 #include "vm/growable_array.h" | 10 #include "vm/growable_array.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 M(AllocateContext, AllocateContextComp) \ | 61 M(AllocateContext, AllocateContextComp) \ |
| 62 M(ChainContext, ChainContextComp) \ | 62 M(ChainContext, ChainContextComp) \ |
| 63 M(CloneContext, CloneContextComp) \ | 63 M(CloneContext, CloneContextComp) \ |
| 64 M(CatchEntry, CatchEntryComp) \ | 64 M(CatchEntry, CatchEntryComp) \ |
| 65 | 65 |
| 66 | 66 |
| 67 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; | 67 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; |
| 68 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) | 68 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) |
| 69 #undef FORWARD_DECLARATION | 69 #undef FORWARD_DECLARATION |
| 70 | 70 |
| 71 // Forward declarations. |
| 72 class BufferFormatter; |
| 73 class Value; |
| 74 |
| 75 |
| 71 class Computation : public ZoneAllocated { | 76 class Computation : public ZoneAllocated { |
| 72 public: | 77 public: |
| 73 static const int kNoCid = -1; | 78 static const int kNoCid = -1; |
| 74 | 79 |
| 75 Computation() : cid_(-1), ic_data_(NULL) { | 80 Computation() : cid_(-1), ic_data_(NULL) { |
| 76 Isolate* isolate = Isolate::Current(); | 81 Isolate* isolate = Isolate::Current(); |
| 77 cid_ = GetNextCid(isolate); | 82 cid_ = GetNextCid(isolate); |
| 78 ic_data_ = GetICDataForCid(cid_, isolate); | 83 ic_data_ = GetICDataForCid(cid_, isolate); |
| 79 } | 84 } |
| 80 | 85 |
| 81 // Unique computation/instruction id, used for deoptimization. | 86 // Unique computation/instruction id, used for deoptimization. |
| 82 intptr_t cid() const { return cid_; } | 87 intptr_t cid() const { return cid_; } |
| 83 | 88 |
| 84 const ICData* ic_data() const { return ic_data_; } | 89 const ICData* ic_data() const { return ic_data_; } |
| 85 | 90 |
| 86 // Visiting support. | 91 // Visiting support. |
| 87 virtual void Accept(FlowGraphVisitor* visitor) = 0; | 92 virtual void Accept(FlowGraphVisitor* visitor) = 0; |
| 88 | 93 |
| 89 virtual intptr_t InputCount() const = 0; | 94 virtual intptr_t InputCount() const = 0; |
| 95 virtual Value* InputAt(intptr_t i) const = 0; |
| 90 | 96 |
| 91 // Static type of the computation. | 97 // Static type of the computation. |
| 92 virtual RawAbstractType* StaticType() const = 0; | 98 virtual RawAbstractType* StaticType() const = 0; |
| 93 | 99 |
| 94 // Mutate assigned_vars to add the local variable index for all | 100 // Mutate assigned_vars to add the local variable index for all |
| 95 // frame-allocated locals assigned to by the computation. | 101 // frame-allocated locals assigned to by the computation. |
| 96 virtual void RecordAssignedVars(BitVector* assigned_vars); | 102 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 97 | 103 |
| 104 virtual const char* DebugName() const = 0; |
| 105 |
| 106 // Printing support. These functions are sometimes overridden for custom |
| 107 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| 108 virtual void PrintTo(BufferFormatter* f) const; |
| 109 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 110 |
| 98 private: | 111 private: |
| 99 friend class Instruction; | 112 friend class Instruction; |
| 100 static intptr_t GetNextCid(Isolate* isolate) { | 113 static intptr_t GetNextCid(Isolate* isolate) { |
| 101 intptr_t tmp = isolate->computation_id(); | 114 intptr_t tmp = isolate->computation_id(); |
| 102 isolate->set_computation_id(tmp + 1); | 115 isolate->set_computation_id(tmp + 1); |
| 103 return tmp; | 116 return tmp; |
| 104 } | 117 } |
| 105 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { | 118 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { |
| 106 if (isolate->ic_data_array() == Array::null()) { | 119 if (isolate->ic_data_array() == Array::null()) { |
| 107 return NULL; | 120 return NULL; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 } | 153 } |
| 141 | 154 |
| 142 private: | 155 private: |
| 143 T elements_[N]; | 156 T elements_[N]; |
| 144 }; | 157 }; |
| 145 | 158 |
| 146 | 159 |
| 147 template<typename T> | 160 template<typename T> |
| 148 class EmbeddedArray<T, 0> { | 161 class EmbeddedArray<T, 0> { |
| 149 public: | 162 public: |
| 150 int length() const { return 0; } | 163 intptr_t length() const { return 0; } |
| 164 const T& operator[](intptr_t i) const { |
| 165 UNREACHABLE(); |
| 166 static T sentinel = 0; |
| 167 return sentinel; |
| 168 } |
| 169 T& operator[](intptr_t i) { |
| 170 UNREACHABLE(); |
| 171 static T sentinel = 0; |
| 172 return sentinel; |
| 173 } |
| 151 }; | 174 }; |
| 152 | 175 |
| 153 | 176 |
| 154 class Value; | |
| 155 | |
| 156 template<intptr_t N> | 177 template<intptr_t N> |
| 157 class TemplateComputation : public Computation { | 178 class TemplateComputation : public Computation { |
| 158 public: | 179 public: |
| 159 virtual intptr_t InputCount() const { return N; } | 180 virtual intptr_t InputCount() const { return N; } |
| 181 virtual Value* InputAt(intptr_t i) const { return inputs_[i]; } |
| 160 | 182 |
| 161 protected: | 183 protected: |
| 162 EmbeddedArray<Value*, N> inputs_; | 184 EmbeddedArray<Value*, N> inputs_; |
| 163 }; | 185 }; |
| 164 | 186 |
| 165 | 187 |
| 166 class Value : public TemplateComputation<0> { | 188 class Value : public TemplateComputation<0> { |
| 167 public: | 189 public: |
| 168 Value() { } | 190 Value() { } |
| 169 | 191 |
| 170 #define DEFINE_TESTERS(ShortName, ClassName) \ | 192 #define DEFINE_TESTERS(ShortName, ClassName) \ |
| 171 virtual ClassName* As##ShortName() { return NULL; } \ | 193 virtual ClassName* As##ShortName() { return NULL; } \ |
| 172 bool Is##ShortName() { return As##ShortName() != NULL; } | 194 bool Is##ShortName() { return As##ShortName() != NULL; } |
| 173 | 195 |
| 174 FOR_EACH_VALUE(DEFINE_TESTERS) | 196 FOR_EACH_VALUE(DEFINE_TESTERS) |
| 175 #undef DEFINE_TESTERS | 197 #undef DEFINE_TESTERS |
| 176 | 198 |
| 177 private: | 199 private: |
| 178 DISALLOW_COPY_AND_ASSIGN(Value); | 200 DISALLOW_COPY_AND_ASSIGN(Value); |
| 179 }; | 201 }; |
| 180 | 202 |
| 181 | 203 |
| 182 // Functions defined in all concrete computation classes. | 204 // Functions defined in all concrete computation classes. |
| 183 #define DECLARE_COMPUTATION(ShortName) \ | 205 #define DECLARE_COMPUTATION(ShortName) \ |
| 184 virtual void Accept(FlowGraphVisitor* visitor); \ | 206 virtual void Accept(FlowGraphVisitor* visitor); \ |
| 185 virtual RawAbstractType* StaticType() const; \ | 207 virtual const char* DebugName() const { return #ShortName; } \ |
| 208 virtual RawAbstractType* StaticType() const; |
| 186 | 209 |
| 187 // Functions defined in all concrete value classes. | 210 // Functions defined in all concrete value classes. |
| 188 #define DECLARE_VALUE(ShortName) \ | 211 #define DECLARE_VALUE(ShortName) \ |
| 189 DECLARE_COMPUTATION(ShortName) \ | 212 DECLARE_COMPUTATION(ShortName) \ |
| 190 virtual ShortName##Val* As##ShortName() { return this; } | 213 virtual ShortName##Val* As##ShortName() { return this; } \ |
| 214 virtual void PrintTo(BufferFormatter* f) const; |
| 191 | 215 |
| 192 | 216 |
| 193 // Definitions and uses are mutually recursive. | 217 // Definitions and uses are mutually recursive. |
| 194 class Definition; | 218 class Definition; |
| 195 | 219 |
| 196 class UseVal : public Value { | 220 class UseVal : public Value { |
| 197 public: | 221 public: |
| 198 explicit UseVal(Definition* definition) : definition_(definition) { } | 222 explicit UseVal(Definition* definition) : definition_(definition) { } |
| 199 | 223 |
| 200 DECLARE_VALUE(Use) | 224 DECLARE_VALUE(Use) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 intptr_t token_index() const { return token_index_; } | 275 intptr_t token_index() const { return token_index_; } |
| 252 intptr_t try_index() const { return try_index_; } | 276 intptr_t try_index() const { return try_index_; } |
| 253 Value* value() const { return value_; } | 277 Value* value() const { return value_; } |
| 254 Value* instantiator_type_arguments() const { | 278 Value* instantiator_type_arguments() const { |
| 255 return instantiator_type_arguments_; | 279 return instantiator_type_arguments_; |
| 256 } | 280 } |
| 257 const AbstractType& dst_type() const { return dst_type_; } | 281 const AbstractType& dst_type() const { return dst_type_; } |
| 258 const String& dst_name() const { return dst_name_; } | 282 const String& dst_name() const { return dst_name_; } |
| 259 | 283 |
| 260 virtual intptr_t InputCount() const; | 284 virtual intptr_t InputCount() const; |
| 285 virtual Value* InputAt(intptr_t i) const { |
| 286 if (i == 0) return value(); |
| 287 if (i == 1) return instantiator_type_arguments(); |
| 288 return NULL; |
| 289 } |
| 290 |
| 291 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 261 | 292 |
| 262 private: | 293 private: |
| 263 const intptr_t token_index_; | 294 const intptr_t token_index_; |
| 264 const intptr_t try_index_; | 295 const intptr_t try_index_; |
| 265 Value* value_; | 296 Value* value_; |
| 266 Value* instantiator_type_arguments_; | 297 Value* instantiator_type_arguments_; |
| 267 const AbstractType& dst_type_; | 298 const AbstractType& dst_type_; |
| 268 const String& dst_name_; | 299 const String& dst_name_; |
| 269 | 300 |
| 270 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); | 301 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 | 373 |
| 343 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 374 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 344 intptr_t token_index() const { return ast_node_.token_index(); } | 375 intptr_t token_index() const { return ast_node_.token_index(); } |
| 345 intptr_t try_index() const { return try_index_; } | 376 intptr_t try_index() const { return try_index_; } |
| 346 | 377 |
| 347 Value* context() const { return context_; } | 378 Value* context() const { return context_; } |
| 348 intptr_t ArgumentCount() const { return arguments_->length(); } | 379 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 349 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 380 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 350 | 381 |
| 351 virtual intptr_t InputCount() const; | 382 virtual intptr_t InputCount() const; |
| 383 virtual Value* InputAt(intptr_t i) const { |
| 384 return i == 0 ? context() : ArgumentAt(i - 1); |
| 385 } |
| 386 |
| 387 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 352 | 388 |
| 353 private: | 389 private: |
| 354 const ClosureCallNode& ast_node_; | 390 const ClosureCallNode& ast_node_; |
| 355 const intptr_t try_index_; | 391 const intptr_t try_index_; |
| 356 Value* context_; | 392 Value* context_; |
| 357 ZoneGrowableArray<Value*>* arguments_; | 393 ZoneGrowableArray<Value*>* arguments_; |
| 358 | 394 |
| 359 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); | 395 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| 360 }; | 396 }; |
| 361 | 397 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 383 | 419 |
| 384 intptr_t token_index() const { return token_index_; } | 420 intptr_t token_index() const { return token_index_; } |
| 385 intptr_t try_index() const { return try_index_; } | 421 intptr_t try_index() const { return try_index_; } |
| 386 const String& function_name() const { return function_name_; } | 422 const String& function_name() const { return function_name_; } |
| 387 intptr_t ArgumentCount() const { return arguments_->length(); } | 423 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 388 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 424 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 389 const Array& argument_names() const { return argument_names_; } | 425 const Array& argument_names() const { return argument_names_; } |
| 390 intptr_t checked_argument_count() const { return checked_argument_count_; } | 426 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 391 | 427 |
| 392 virtual intptr_t InputCount() const; | 428 virtual intptr_t InputCount() const; |
| 429 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 430 |
| 431 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 393 | 432 |
| 394 private: | 433 private: |
| 395 const intptr_t token_index_; | 434 const intptr_t token_index_; |
| 396 const intptr_t try_index_; | 435 const intptr_t try_index_; |
| 397 const String& function_name_; | 436 const String& function_name_; |
| 398 ZoneGrowableArray<Value*>* const arguments_; | 437 ZoneGrowableArray<Value*>* const arguments_; |
| 399 const Array& argument_names_; | 438 const Array& argument_names_; |
| 400 const intptr_t checked_argument_count_; | 439 const intptr_t checked_argument_count_; |
| 401 | 440 |
| 402 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 441 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 403 }; | 442 }; |
| 404 | 443 |
| 405 | 444 |
| 406 class StrictCompareComp : public TemplateComputation<2> { | 445 class StrictCompareComp : public TemplateComputation<2> { |
| 407 public: | 446 public: |
| 408 StrictCompareComp(Token::Kind kind, Value* left, Value* right) | 447 StrictCompareComp(Token::Kind kind, Value* left, Value* right) |
| 409 : kind_(kind) { | 448 : kind_(kind) { |
| 410 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); | 449 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); |
| 411 inputs_[0] = left; | 450 inputs_[0] = left; |
| 412 inputs_[1] = right; | 451 inputs_[1] = right; |
| 413 } | 452 } |
| 414 | 453 |
| 415 DECLARE_COMPUTATION(StrictCompare) | 454 DECLARE_COMPUTATION(StrictCompare) |
| 416 | 455 |
| 417 Token::Kind kind() const { return kind_; } | 456 Token::Kind kind() const { return kind_; } |
| 418 Value* left() const { return inputs_[0]; } | 457 Value* left() const { return inputs_[0]; } |
| 419 Value* right() const { return inputs_[1]; } | 458 Value* right() const { return inputs_[1]; } |
| 420 | 459 |
| 460 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 461 |
| 421 private: | 462 private: |
| 422 const Token::Kind kind_; | 463 const Token::Kind kind_; |
| 423 | 464 |
| 424 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); | 465 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
| 425 }; | 466 }; |
| 426 | 467 |
| 427 | 468 |
| 428 class EqualityCompareComp : public TemplateComputation<2> { | 469 class EqualityCompareComp : public TemplateComputation<2> { |
| 429 public: | 470 public: |
| 430 EqualityCompareComp(intptr_t token_index, | 471 EqualityCompareComp(intptr_t token_index, |
| 431 intptr_t try_index, | 472 intptr_t try_index, |
| 432 Value* left, | 473 Value* left, |
| 433 Value* right) | 474 Value* right) |
| 434 : token_index_(token_index), | 475 : token_index_(token_index), |
| 435 try_index_(try_index) { | 476 try_index_(try_index) { |
| 436 ASSERT(left != NULL); | 477 ASSERT(left != NULL); |
| 437 ASSERT(right != NULL); | 478 ASSERT(right != NULL); |
| 438 inputs_[0] = left; | 479 inputs_[0] = left; |
| 439 inputs_[1] = right; | 480 inputs_[1] = right; |
| 440 } | 481 } |
| 441 | 482 |
| 442 DECLARE_COMPUTATION(EqualityCompareComp) | 483 DECLARE_COMPUTATION(EqualityCompareComp) |
| 443 | 484 |
| 444 intptr_t token_index() const { return token_index_; } | 485 intptr_t token_index() const { return token_index_; } |
| 445 intptr_t try_index() const { return try_index_; } | 486 intptr_t try_index() const { return try_index_; } |
| 446 Value* left() const { return inputs_[0]; } | 487 Value* left() const { return inputs_[0]; } |
| 447 Value* right() const { return inputs_[1]; } | 488 Value* right() const { return inputs_[1]; } |
| 448 | 489 |
| 490 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 491 |
| 449 private: | 492 private: |
| 450 const intptr_t token_index_; | 493 const intptr_t token_index_; |
| 451 const intptr_t try_index_; | 494 const intptr_t try_index_; |
| 452 | 495 |
| 453 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 496 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
| 454 }; | 497 }; |
| 455 | 498 |
| 456 | 499 |
| 457 class StaticCallComp : public Computation { | 500 class StaticCallComp : public Computation { |
| 458 public: | 501 public: |
| (...skipping 16 matching lines...) Expand all Loading... |
| 475 // Accessors forwarded to the AST node. | 518 // Accessors forwarded to the AST node. |
| 476 const Function& function() const { return function_; } | 519 const Function& function() const { return function_; } |
| 477 const Array& argument_names() const { return argument_names_; } | 520 const Array& argument_names() const { return argument_names_; } |
| 478 intptr_t token_index() const { return token_index_; } | 521 intptr_t token_index() const { return token_index_; } |
| 479 intptr_t try_index() const { return try_index_; } | 522 intptr_t try_index() const { return try_index_; } |
| 480 | 523 |
| 481 intptr_t ArgumentCount() const { return arguments_->length(); } | 524 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 482 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 525 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 483 | 526 |
| 484 virtual intptr_t InputCount() const; | 527 virtual intptr_t InputCount() const; |
| 528 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 529 |
| 530 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 485 | 531 |
| 486 private: | 532 private: |
| 487 const intptr_t token_index_; | 533 const intptr_t token_index_; |
| 488 const intptr_t try_index_; | 534 const intptr_t try_index_; |
| 489 const Function& function_; | 535 const Function& function_; |
| 490 const Array& argument_names_; | 536 const Array& argument_names_; |
| 491 ZoneGrowableArray<Value*>* arguments_; | 537 ZoneGrowableArray<Value*>* arguments_; |
| 492 | 538 |
| 493 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); | 539 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
| 494 }; | 540 }; |
| 495 | 541 |
| 496 | 542 |
| 497 class LoadLocalComp : public TemplateComputation<0> { | 543 class LoadLocalComp : public TemplateComputation<0> { |
| 498 public: | 544 public: |
| 499 LoadLocalComp(const LocalVariable& local, intptr_t context_level) | 545 LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
| 500 : local_(local), context_level_(context_level) { } | 546 : local_(local), context_level_(context_level) { } |
| 501 | 547 |
| 502 DECLARE_COMPUTATION(LoadLocal) | 548 DECLARE_COMPUTATION(LoadLocal) |
| 503 | 549 |
| 504 const LocalVariable& local() const { return local_; } | 550 const LocalVariable& local() const { return local_; } |
| 505 intptr_t context_level() const { return context_level_; } | 551 intptr_t context_level() const { return context_level_; } |
| 506 | 552 |
| 553 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 554 |
| 507 private: | 555 private: |
| 508 const LocalVariable& local_; | 556 const LocalVariable& local_; |
| 509 const intptr_t context_level_; | 557 const intptr_t context_level_; |
| 510 | 558 |
| 511 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); | 559 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
| 512 }; | 560 }; |
| 513 | 561 |
| 514 | 562 |
| 515 class StoreLocalComp : public TemplateComputation<1> { | 563 class StoreLocalComp : public TemplateComputation<1> { |
| 516 public: | 564 public: |
| 517 StoreLocalComp(const LocalVariable& local, | 565 StoreLocalComp(const LocalVariable& local, |
| 518 Value* value, | 566 Value* value, |
| 519 intptr_t context_level) | 567 intptr_t context_level) |
| 520 : local_(local), context_level_(context_level) { | 568 : local_(local), context_level_(context_level) { |
| 521 inputs_[0] = value; | 569 inputs_[0] = value; |
| 522 } | 570 } |
| 523 | 571 |
| 524 DECLARE_COMPUTATION(StoreLocal) | 572 DECLARE_COMPUTATION(StoreLocal) |
| 525 | 573 |
| 526 const LocalVariable& local() const { return local_; } | 574 const LocalVariable& local() const { return local_; } |
| 527 Value* value() const { return inputs_[0]; } | 575 Value* value() const { return inputs_[0]; } |
| 528 intptr_t context_level() const { return context_level_; } | 576 intptr_t context_level() const { return context_level_; } |
| 529 | 577 |
| 530 virtual void RecordAssignedVars(BitVector* assigned_vars); | 578 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 531 | 579 |
| 580 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 581 |
| 532 private: | 582 private: |
| 533 const LocalVariable& local_; | 583 const LocalVariable& local_; |
| 534 const intptr_t context_level_; | 584 const intptr_t context_level_; |
| 535 | 585 |
| 536 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 586 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 537 }; | 587 }; |
| 538 | 588 |
| 539 | 589 |
| 540 class NativeCallComp : public TemplateComputation<0> { | 590 class NativeCallComp : public TemplateComputation<0> { |
| 541 public: | 591 public: |
| (...skipping 12 matching lines...) Expand all Loading... |
| 554 NativeFunction native_c_function() const { | 604 NativeFunction native_c_function() const { |
| 555 return ast_node_.native_c_function(); | 605 return ast_node_.native_c_function(); |
| 556 } | 606 } |
| 557 | 607 |
| 558 intptr_t argument_count() const { return ast_node_.argument_count(); } | 608 intptr_t argument_count() const { return ast_node_.argument_count(); } |
| 559 | 609 |
| 560 bool has_optional_parameters() const { | 610 bool has_optional_parameters() const { |
| 561 return ast_node_.has_optional_parameters(); | 611 return ast_node_.has_optional_parameters(); |
| 562 } | 612 } |
| 563 | 613 |
| 614 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 615 |
| 564 private: | 616 private: |
| 565 const NativeBodyNode& ast_node_; | 617 const NativeBodyNode& ast_node_; |
| 566 const intptr_t try_index_; | 618 const intptr_t try_index_; |
| 567 | 619 |
| 568 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); | 620 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); |
| 569 }; | 621 }; |
| 570 | 622 |
| 571 | 623 |
| 572 class LoadInstanceFieldComp : public TemplateComputation<1> { | 624 class LoadInstanceFieldComp : public TemplateComputation<1> { |
| 573 public: | 625 public: |
| 574 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) | 626 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) |
| 575 : ast_node_(*ast_node) { | 627 : ast_node_(*ast_node) { |
| 576 ASSERT(instance != NULL); | 628 ASSERT(instance != NULL); |
| 577 inputs_[0] = instance; | 629 inputs_[0] = instance; |
| 578 } | 630 } |
| 579 | 631 |
| 580 DECLARE_COMPUTATION(LoadInstanceField) | 632 DECLARE_COMPUTATION(LoadInstanceField) |
| 581 | 633 |
| 582 const Field& field() const { return ast_node_.field(); } | 634 const Field& field() const { return ast_node_.field(); } |
| 583 | 635 |
| 584 Value* instance() const { return inputs_[0]; } | 636 Value* instance() const { return inputs_[0]; } |
| 585 | 637 |
| 638 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 639 |
| 586 private: | 640 private: |
| 587 const LoadInstanceFieldNode& ast_node_; | 641 const LoadInstanceFieldNode& ast_node_; |
| 588 | 642 |
| 589 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 643 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 590 }; | 644 }; |
| 591 | 645 |
| 592 | 646 |
| 593 class StoreInstanceFieldComp : public TemplateComputation<2> { | 647 class StoreInstanceFieldComp : public TemplateComputation<2> { |
| 594 public: | 648 public: |
| 595 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, | 649 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, |
| 596 Value* instance, | 650 Value* instance, |
| 597 Value* value) | 651 Value* value) |
| 598 : ast_node_(*ast_node) { | 652 : ast_node_(*ast_node) { |
| 599 ASSERT(instance != NULL); | 653 ASSERT(instance != NULL); |
| 600 ASSERT(value != NULL); | 654 ASSERT(value != NULL); |
| 601 inputs_[0] = instance; | 655 inputs_[0] = instance; |
| 602 inputs_[1] = value; | 656 inputs_[1] = value; |
| 603 } | 657 } |
| 604 | 658 |
| 605 DECLARE_COMPUTATION(StoreInstanceField) | 659 DECLARE_COMPUTATION(StoreInstanceField) |
| 606 | 660 |
| 607 intptr_t token_index() const { return ast_node_.token_index(); } | 661 intptr_t token_index() const { return ast_node_.token_index(); } |
| 608 const Field& field() const { return ast_node_.field(); } | 662 const Field& field() const { return ast_node_.field(); } |
| 609 | 663 |
| 610 Value* instance() const { return inputs_[0]; } | 664 Value* instance() const { return inputs_[0]; } |
| 611 Value* value() const { return inputs_[1]; } | 665 Value* value() const { return inputs_[1]; } |
| 612 | 666 |
| 667 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 668 |
| 613 private: | 669 private: |
| 614 const StoreInstanceFieldNode& ast_node_; | 670 const StoreInstanceFieldNode& ast_node_; |
| 615 | 671 |
| 616 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 672 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 617 }; | 673 }; |
| 618 | 674 |
| 619 | 675 |
| 620 class LoadStaticFieldComp : public TemplateComputation<0> { | 676 class LoadStaticFieldComp : public TemplateComputation<0> { |
| 621 public: | 677 public: |
| 622 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} | 678 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
| 623 | 679 |
| 624 DECLARE_COMPUTATION(LoadStaticField); | 680 DECLARE_COMPUTATION(LoadStaticField); |
| 625 | 681 |
| 626 const Field& field() const { return field_; } | 682 const Field& field() const { return field_; } |
| 627 | 683 |
| 684 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 685 |
| 628 private: | 686 private: |
| 629 const Field& field_; | 687 const Field& field_; |
| 630 | 688 |
| 631 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); | 689 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); |
| 632 }; | 690 }; |
| 633 | 691 |
| 634 | 692 |
| 635 class StoreStaticFieldComp : public TemplateComputation<1> { | 693 class StoreStaticFieldComp : public TemplateComputation<1> { |
| 636 public: | 694 public: |
| 637 StoreStaticFieldComp(const Field& field, Value* value) | 695 StoreStaticFieldComp(const Field& field, Value* value) |
| 638 : field_(field) { | 696 : field_(field) { |
| 639 ASSERT(field.IsZoneHandle()); | 697 ASSERT(field.IsZoneHandle()); |
| 640 ASSERT(value != NULL); | 698 ASSERT(value != NULL); |
| 641 inputs_[0] = value; | 699 inputs_[0] = value; |
| 642 } | 700 } |
| 643 | 701 |
| 644 DECLARE_COMPUTATION(StoreStaticField); | 702 DECLARE_COMPUTATION(StoreStaticField); |
| 645 | 703 |
| 646 const Field& field() const { return field_; } | 704 const Field& field() const { return field_; } |
| 647 Value* value() const { return inputs_[0]; } | 705 Value* value() const { return inputs_[0]; } |
| 648 | 706 |
| 707 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 708 |
| 649 private: | 709 private: |
| 650 const Field& field_; | 710 const Field& field_; |
| 651 | 711 |
| 652 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); | 712 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
| 653 }; | 713 }; |
| 654 | 714 |
| 655 | 715 |
| 656 // Not simply an InstanceCall because it has somewhat more complicated | 716 // Not simply an InstanceCall because it has somewhat more complicated |
| 657 // semantics: the value operand is preserved before the call. | 717 // semantics: the value operand is preserved before the call. |
| 658 class StoreIndexedComp : public TemplateComputation<3> { | 718 class StoreIndexedComp : public TemplateComputation<3> { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 DECLARE_COMPUTATION(InstanceOf) | 845 DECLARE_COMPUTATION(InstanceOf) |
| 786 | 846 |
| 787 Value* value() const { return value_; } | 847 Value* value() const { return value_; } |
| 788 Value* type_arguments() const { return type_arguments_; } | 848 Value* type_arguments() const { return type_arguments_; } |
| 789 bool negate_result() const { return negate_result_; } | 849 bool negate_result() const { return negate_result_; } |
| 790 const AbstractType& type() const { return type_; } | 850 const AbstractType& type() const { return type_; } |
| 791 intptr_t token_index() const { return token_index_; } | 851 intptr_t token_index() const { return token_index_; } |
| 792 intptr_t try_index() const { return try_index_; } | 852 intptr_t try_index() const { return try_index_; } |
| 793 | 853 |
| 794 virtual intptr_t InputCount() const; | 854 virtual intptr_t InputCount() const; |
| 855 virtual Value* InputAt(intptr_t i) const { |
| 856 if (i == 0) return value(); |
| 857 if (i == 1) return type_arguments(); |
| 858 return NULL; |
| 859 } |
| 860 |
| 861 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 795 | 862 |
| 796 private: | 863 private: |
| 797 const intptr_t token_index_; | 864 const intptr_t token_index_; |
| 798 const intptr_t try_index_; | 865 const intptr_t try_index_; |
| 799 Value* value_; | 866 Value* value_; |
| 800 Value* type_arguments_; | 867 Value* type_arguments_; |
| 801 const AbstractType& type_; | 868 const AbstractType& type_; |
| 802 const bool negate_result_; | 869 const bool negate_result_; |
| 803 | 870 |
| 804 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); | 871 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 816 } | 883 } |
| 817 | 884 |
| 818 DECLARE_COMPUTATION(AllocateObject) | 885 DECLARE_COMPUTATION(AllocateObject) |
| 819 | 886 |
| 820 const Function& constructor() const { return ast_node_.constructor(); } | 887 const Function& constructor() const { return ast_node_.constructor(); } |
| 821 intptr_t token_index() const { return ast_node_.token_index(); } | 888 intptr_t token_index() const { return ast_node_.token_index(); } |
| 822 intptr_t try_index() const { return try_index_; } | 889 intptr_t try_index() const { return try_index_; } |
| 823 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 890 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 824 | 891 |
| 825 virtual intptr_t InputCount() const; | 892 virtual intptr_t InputCount() const; |
| 893 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } |
| 894 |
| 895 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 826 | 896 |
| 827 private: | 897 private: |
| 828 const ConstructorCallNode& ast_node_; | 898 const ConstructorCallNode& ast_node_; |
| 829 const intptr_t try_index_; | 899 const intptr_t try_index_; |
| 830 ZoneGrowableArray<Value*>* const arguments_; | 900 ZoneGrowableArray<Value*>* const arguments_; |
| 831 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); | 901 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); |
| 832 }; | 902 }; |
| 833 | 903 |
| 834 | 904 |
| 835 class AllocateObjectWithBoundsCheckComp : public Computation { | 905 class AllocateObjectWithBoundsCheckComp : public Computation { |
| 836 public: | 906 public: |
| 837 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node, | 907 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node, |
| 838 intptr_t try_index, | 908 intptr_t try_index, |
| 839 ZoneGrowableArray<Value*>* arguments) | 909 ZoneGrowableArray<Value*>* arguments) |
| 840 : ast_node_(*node), try_index_(try_index), arguments_(arguments) { | 910 : ast_node_(*node), try_index_(try_index), arguments_(arguments) { |
| 841 // One type-argument and one instantiator. | 911 // One type-argument and one instantiator. |
| 842 ASSERT(arguments->length() == 2); | 912 ASSERT(arguments->length() == 2); |
| 843 } | 913 } |
| 844 | 914 |
| 845 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) | 915 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) |
| 846 | 916 |
| 847 const Function& constructor() const { return ast_node_.constructor(); } | 917 const Function& constructor() const { return ast_node_.constructor(); } |
| 848 intptr_t token_index() const { return ast_node_.token_index(); } | 918 intptr_t token_index() const { return ast_node_.token_index(); } |
| 849 intptr_t try_index() const { return try_index_; } | 919 intptr_t try_index() const { return try_index_; } |
| 850 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 920 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 851 | 921 |
| 852 virtual intptr_t InputCount() const; | 922 virtual intptr_t InputCount() const; |
| 923 virtual Value* InputAt(intptr_t i) const { return arguments()[i]; } |
| 924 |
| 925 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 853 | 926 |
| 854 private: | 927 private: |
| 855 const ConstructorCallNode& ast_node_; | 928 const ConstructorCallNode& ast_node_; |
| 856 const intptr_t try_index_; | 929 const intptr_t try_index_; |
| 857 ZoneGrowableArray<Value*>* const arguments_; | 930 ZoneGrowableArray<Value*>* const arguments_; |
| 858 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); | 931 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); |
| 859 }; | 932 }; |
| 860 | 933 |
| 861 | 934 |
| 862 class CreateArrayComp : public Computation { | 935 class CreateArrayComp : public Computation { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 879 | 952 |
| 880 DECLARE_COMPUTATION(CreateArray) | 953 DECLARE_COMPUTATION(CreateArray) |
| 881 | 954 |
| 882 intptr_t token_index() const { return token_index_; } | 955 intptr_t token_index() const { return token_index_; } |
| 883 intptr_t try_index() const { return try_index_; } | 956 intptr_t try_index() const { return try_index_; } |
| 884 intptr_t ElementCount() const { return elements_->length(); } | 957 intptr_t ElementCount() const { return elements_->length(); } |
| 885 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } | 958 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } |
| 886 Value* element_type() const { return element_type_; } | 959 Value* element_type() const { return element_type_; } |
| 887 | 960 |
| 888 virtual intptr_t InputCount() const; | 961 virtual intptr_t InputCount() const; |
| 962 virtual Value* InputAt(intptr_t i) const { return ElementAt(i); } |
| 963 |
| 964 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 889 | 965 |
| 890 private: | 966 private: |
| 891 const intptr_t token_index_; | 967 const intptr_t token_index_; |
| 892 const intptr_t try_index_; | 968 const intptr_t try_index_; |
| 893 ZoneGrowableArray<Value*>* const elements_; | 969 ZoneGrowableArray<Value*>* const elements_; |
| 894 Value* element_type_; | 970 Value* element_type_; |
| 895 | 971 |
| 896 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); | 972 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
| 897 }; | 973 }; |
| 898 | 974 |
| 899 | 975 |
| 900 class CreateClosureComp : public Computation { | 976 class CreateClosureComp : public Computation { |
| 901 public: | 977 public: |
| 902 // 'type_arguments' is null if function() does not require type arguments. | 978 // 'type_arguments' is null if function() does not require type arguments. |
| 903 CreateClosureComp(ClosureNode* node, | 979 CreateClosureComp(ClosureNode* node, |
| 904 intptr_t try_index, | 980 intptr_t try_index, |
| 905 Value* type_arguments) | 981 Value* type_arguments) |
| 906 : ast_node_(*node), | 982 : ast_node_(*node), |
| 907 try_index_(try_index), | 983 try_index_(try_index), |
| 908 type_arguments_(type_arguments) {} | 984 type_arguments_(type_arguments) {} |
| 909 | 985 |
| 910 DECLARE_COMPUTATION(CreateClosure) | 986 DECLARE_COMPUTATION(CreateClosure) |
| 911 | 987 |
| 912 intptr_t token_index() const { return ast_node_.token_index(); } | 988 intptr_t token_index() const { return ast_node_.token_index(); } |
| 913 intptr_t try_index() const { return try_index_; } | 989 intptr_t try_index() const { return try_index_; } |
| 914 const Function& function() const { return ast_node_.function(); } | 990 const Function& function() const { return ast_node_.function(); } |
| 915 Value* type_arguments() const { return type_arguments_; } | 991 Value* type_arguments() const { return type_arguments_; } |
| 916 | 992 |
| 917 virtual intptr_t InputCount() const; | 993 virtual intptr_t InputCount() const; |
| 994 virtual Value* InputAt(intptr_t i) const { |
| 995 return i == 0 ? type_arguments() : NULL; |
| 996 } |
| 997 |
| 998 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 918 | 999 |
| 919 private: | 1000 private: |
| 920 const ClosureNode& ast_node_; | 1001 const ClosureNode& ast_node_; |
| 921 const intptr_t try_index_; | 1002 const intptr_t try_index_; |
| 922 Value* type_arguments_; | 1003 Value* type_arguments_; |
| 923 | 1004 |
| 924 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); | 1005 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); |
| 925 }; | 1006 }; |
| 926 | 1007 |
| 927 | 1008 |
| 928 class NativeLoadFieldComp : public TemplateComputation<1> { | 1009 class NativeLoadFieldComp : public TemplateComputation<1> { |
| 929 public: | 1010 public: |
| 930 NativeLoadFieldComp(Value* value, | 1011 NativeLoadFieldComp(Value* value, |
| 931 intptr_t offset_in_bytes, | 1012 intptr_t offset_in_bytes, |
| 932 const AbstractType& type) | 1013 const AbstractType& type) |
| 933 : offset_in_bytes_(offset_in_bytes), type_(type) { | 1014 : offset_in_bytes_(offset_in_bytes), type_(type) { |
| 934 ASSERT(value != NULL); | 1015 ASSERT(value != NULL); |
| 935 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 1016 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 936 inputs_[0] = value; | 1017 inputs_[0] = value; |
| 937 } | 1018 } |
| 938 | 1019 |
| 939 DECLARE_COMPUTATION(NativeLoadField) | 1020 DECLARE_COMPUTATION(NativeLoadField) |
| 940 | 1021 |
| 941 Value* value() const { return inputs_[0]; } | 1022 Value* value() const { return inputs_[0]; } |
| 942 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 1023 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 943 const AbstractType& type() const { return type_; } | 1024 const AbstractType& type() const { return type_; } |
| 944 | 1025 |
| 1026 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1027 |
| 945 private: | 1028 private: |
| 946 const intptr_t offset_in_bytes_; | 1029 const intptr_t offset_in_bytes_; |
| 947 const AbstractType& type_; | 1030 const AbstractType& type_; |
| 948 | 1031 |
| 949 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); | 1032 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); |
| 950 }; | 1033 }; |
| 951 | 1034 |
| 952 | 1035 |
| 953 class NativeStoreFieldComp : public TemplateComputation<2> { | 1036 class NativeStoreFieldComp : public TemplateComputation<2> { |
| 954 public: | 1037 public: |
| 955 NativeStoreFieldComp(Value* dest, | 1038 NativeStoreFieldComp(Value* dest, |
| 956 intptr_t offset_in_bytes, | 1039 intptr_t offset_in_bytes, |
| 957 Value* value, | 1040 Value* value, |
| 958 const AbstractType& type) | 1041 const AbstractType& type) |
| 959 : offset_in_bytes_(offset_in_bytes), type_(type) { | 1042 : offset_in_bytes_(offset_in_bytes), type_(type) { |
| 960 ASSERT(value != NULL); | 1043 ASSERT(value != NULL); |
| 961 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. | 1044 ASSERT(type.IsZoneHandle()); // May be null if field is not an instance. |
| 962 inputs_[0] = dest; | 1045 inputs_[0] = dest; |
| 963 inputs_[1] = value; | 1046 inputs_[1] = value; |
| 964 } | 1047 } |
| 965 | 1048 |
| 966 DECLARE_COMPUTATION(NativeStoreField) | 1049 DECLARE_COMPUTATION(NativeStoreField) |
| 967 | 1050 |
| 968 Value* dest() const { return inputs_[0]; } | 1051 Value* dest() const { return inputs_[0]; } |
| 969 Value* value() const { return inputs_[1]; } | 1052 Value* value() const { return inputs_[1]; } |
| 970 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 1053 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 971 const AbstractType& type() const { return type_; } | 1054 const AbstractType& type() const { return type_; } |
| 972 | 1055 |
| 1056 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1057 |
| 973 private: | 1058 private: |
| 974 const intptr_t offset_in_bytes_; | 1059 const intptr_t offset_in_bytes_; |
| 975 const AbstractType& type_; | 1060 const AbstractType& type_; |
| 976 | 1061 |
| 977 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); | 1062 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); |
| 978 }; | 1063 }; |
| 979 | 1064 |
| 980 | 1065 |
| 981 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { | 1066 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { |
| 982 public: | 1067 public: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 993 | 1078 |
| 994 DECLARE_COMPUTATION(InstantiateTypeArguments) | 1079 DECLARE_COMPUTATION(InstantiateTypeArguments) |
| 995 | 1080 |
| 996 Value* instantiator() const { return inputs_[0]; } | 1081 Value* instantiator() const { return inputs_[0]; } |
| 997 const AbstractTypeArguments& type_arguments() const { | 1082 const AbstractTypeArguments& type_arguments() const { |
| 998 return type_arguments_; | 1083 return type_arguments_; |
| 999 } | 1084 } |
| 1000 intptr_t token_index() const { return token_index_; } | 1085 intptr_t token_index() const { return token_index_; } |
| 1001 intptr_t try_index() const { return try_index_; } | 1086 intptr_t try_index() const { return try_index_; } |
| 1002 | 1087 |
| 1088 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1089 |
| 1003 private: | 1090 private: |
| 1004 const intptr_t token_index_; | 1091 const intptr_t token_index_; |
| 1005 const intptr_t try_index_; | 1092 const intptr_t try_index_; |
| 1006 const AbstractTypeArguments& type_arguments_; | 1093 const AbstractTypeArguments& type_arguments_; |
| 1007 | 1094 |
| 1008 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); | 1095 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); |
| 1009 }; | 1096 }; |
| 1010 | 1097 |
| 1011 | 1098 |
| 1012 class ExtractConstructorTypeArgumentsComp : public TemplateComputation<1> { | 1099 class ExtractConstructorTypeArgumentsComp : public TemplateComputation<1> { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1025 | 1112 |
| 1026 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) | 1113 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) |
| 1027 | 1114 |
| 1028 Value* instantiator() const { return inputs_[0]; } | 1115 Value* instantiator() const { return inputs_[0]; } |
| 1029 const AbstractTypeArguments& type_arguments() const { | 1116 const AbstractTypeArguments& type_arguments() const { |
| 1030 return type_arguments_; | 1117 return type_arguments_; |
| 1031 } | 1118 } |
| 1032 intptr_t token_index() const { return token_index_; } | 1119 intptr_t token_index() const { return token_index_; } |
| 1033 intptr_t try_index() const { return try_index_; } | 1120 intptr_t try_index() const { return try_index_; } |
| 1034 | 1121 |
| 1122 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1123 |
| 1035 private: | 1124 private: |
| 1036 const intptr_t token_index_; | 1125 const intptr_t token_index_; |
| 1037 const intptr_t try_index_; | 1126 const intptr_t try_index_; |
| 1038 const AbstractTypeArguments& type_arguments_; | 1127 const AbstractTypeArguments& type_arguments_; |
| 1039 | 1128 |
| 1040 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); | 1129 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); |
| 1041 }; | 1130 }; |
| 1042 | 1131 |
| 1043 | 1132 |
| 1044 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { | 1133 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1074 : token_index_(token_index), | 1163 : token_index_(token_index), |
| 1075 try_index_(try_index), | 1164 try_index_(try_index), |
| 1076 num_context_variables_(num_context_variables) {} | 1165 num_context_variables_(num_context_variables) {} |
| 1077 | 1166 |
| 1078 DECLARE_COMPUTATION(AllocateContext); | 1167 DECLARE_COMPUTATION(AllocateContext); |
| 1079 | 1168 |
| 1080 intptr_t token_index() const { return token_index_; } | 1169 intptr_t token_index() const { return token_index_; } |
| 1081 intptr_t try_index() const { return try_index_; } | 1170 intptr_t try_index() const { return try_index_; } |
| 1082 intptr_t num_context_variables() const { return num_context_variables_; } | 1171 intptr_t num_context_variables() const { return num_context_variables_; } |
| 1083 | 1172 |
| 1173 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1174 |
| 1084 private: | 1175 private: |
| 1085 const intptr_t token_index_; | 1176 const intptr_t token_index_; |
| 1086 const intptr_t try_index_; | 1177 const intptr_t try_index_; |
| 1087 const intptr_t num_context_variables_; | 1178 const intptr_t num_context_variables_; |
| 1088 | 1179 |
| 1089 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); | 1180 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); |
| 1090 }; | 1181 }; |
| 1091 | 1182 |
| 1092 | 1183 |
| 1093 class ChainContextComp : public TemplateComputation<1> { | 1184 class ChainContextComp : public TemplateComputation<1> { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1135 public: | 1226 public: |
| 1136 CatchEntryComp(const LocalVariable& exception_var, | 1227 CatchEntryComp(const LocalVariable& exception_var, |
| 1137 const LocalVariable& stacktrace_var) | 1228 const LocalVariable& stacktrace_var) |
| 1138 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} | 1229 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} |
| 1139 | 1230 |
| 1140 const LocalVariable& exception_var() const { return exception_var_; } | 1231 const LocalVariable& exception_var() const { return exception_var_; } |
| 1141 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } | 1232 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } |
| 1142 | 1233 |
| 1143 DECLARE_COMPUTATION(CatchEntry) | 1234 DECLARE_COMPUTATION(CatchEntry) |
| 1144 | 1235 |
| 1236 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 1237 |
| 1145 private: | 1238 private: |
| 1146 const LocalVariable& exception_var_; | 1239 const LocalVariable& exception_var_; |
| 1147 const LocalVariable& stacktrace_var_; | 1240 const LocalVariable& stacktrace_var_; |
| 1148 | 1241 |
| 1149 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); | 1242 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); |
| 1150 }; | 1243 }; |
| 1151 | 1244 |
| 1152 | 1245 |
| 1153 #undef DECLARE_COMPUTATION | 1246 #undef DECLARE_COMPUTATION |
| 1154 | 1247 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1172 M(Do) \ | 1265 M(Do) \ |
| 1173 M(Bind) \ | 1266 M(Bind) \ |
| 1174 M(Return) \ | 1267 M(Return) \ |
| 1175 M(Throw) \ | 1268 M(Throw) \ |
| 1176 M(ReThrow) \ | 1269 M(ReThrow) \ |
| 1177 M(Branch) \ | 1270 M(Branch) \ |
| 1178 | 1271 |
| 1179 | 1272 |
| 1180 // Forward declarations for Instruction classes. | 1273 // Forward declarations for Instruction classes. |
| 1181 class BlockEntryInstr; | 1274 class BlockEntryInstr; |
| 1275 class FlowGraphBuilder; |
| 1276 |
| 1182 #define FORWARD_DECLARATION(type) class type##Instr; | 1277 #define FORWARD_DECLARATION(type) class type##Instr; |
| 1183 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 1278 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 1184 #undef FORWARD_DECLARATION | 1279 #undef FORWARD_DECLARATION |
| 1185 | 1280 |
| 1186 | 1281 |
| 1187 // Functions required in all concrete instruction classes. | 1282 // Functions required in all concrete instruction classes. |
| 1188 #define DECLARE_INSTRUCTION(type) \ | 1283 #define DECLARE_INSTRUCTION(type) \ |
| 1189 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ | 1284 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ |
| 1190 virtual bool Is##type() const { return true; } \ | 1285 virtual bool Is##type() const { return true; } \ |
| 1191 virtual type##Instr* As##type() { return this; } \ | 1286 virtual type##Instr* As##type() { return this; } \ |
| 1192 virtual intptr_t InputCount() const; \ | 1287 virtual intptr_t InputCount() const; \ |
| 1288 virtual const char* DebugName() const { return #type; } \ |
| 1289 virtual void PrintTo(BufferFormatter* f) const; |
| 1193 | 1290 |
| 1194 | 1291 |
| 1195 class Instruction : public ZoneAllocated { | 1292 class Instruction : public ZoneAllocated { |
| 1196 public: | 1293 public: |
| 1197 Instruction() : cid_(-1), ic_data_(NULL) { | 1294 Instruction() : cid_(-1), ic_data_(NULL) { |
| 1198 Isolate* isolate = Isolate::Current(); | 1295 Isolate* isolate = Isolate::Current(); |
| 1199 cid_ = Computation::GetNextCid(isolate); | 1296 cid_ = Computation::GetNextCid(isolate); |
| 1200 ic_data_ = Computation::GetICDataForCid(cid_, isolate); | 1297 ic_data_ = Computation::GetICDataForCid(cid_, isolate); |
| 1201 } | 1298 } |
| 1202 | 1299 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 GrowableArray<BitVector*>* assigned_vars, | 1341 GrowableArray<BitVector*>* assigned_vars, |
| 1245 intptr_t variable_count) { | 1342 intptr_t variable_count) { |
| 1246 // Never called for instructions except block entries and branches. | 1343 // Never called for instructions except block entries and branches. |
| 1247 UNREACHABLE(); | 1344 UNREACHABLE(); |
| 1248 } | 1345 } |
| 1249 | 1346 |
| 1250 // Mutate assigned_vars to add the local variable index for all | 1347 // Mutate assigned_vars to add the local variable index for all |
| 1251 // frame-allocated locals assigned to by the instruction. | 1348 // frame-allocated locals assigned to by the instruction. |
| 1252 virtual void RecordAssignedVars(BitVector* assigned_vars); | 1349 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 1253 | 1350 |
| 1351 // Printing support. |
| 1352 virtual void PrintTo(BufferFormatter* f) const = 0; |
| 1353 |
| 1254 #define INSTRUCTION_TYPE_CHECK(type) \ | 1354 #define INSTRUCTION_TYPE_CHECK(type) \ |
| 1255 virtual bool Is##type() const { return false; } \ | 1355 virtual bool Is##type() const { return false; } \ |
| 1256 virtual type##Instr* As##type() { return NULL; } | 1356 virtual type##Instr* As##type() { return NULL; } |
| 1257 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) | 1357 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
| 1258 #undef INSTRUCTION_TYPE_CHECK | 1358 #undef INSTRUCTION_TYPE_CHECK |
| 1259 | 1359 |
| 1260 // Static type of the instruction. | 1360 // Static type of the instruction. |
| 1261 virtual RawAbstractType* StaticType() const { | 1361 virtual RawAbstractType* StaticType() const { |
| 1262 UNREACHABLE(); | 1362 UNREACHABLE(); |
| 1263 return AbstractType::null(); | 1363 return AbstractType::null(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1282 virtual intptr_t PredecessorCount() const = 0; | 1382 virtual intptr_t PredecessorCount() const = 0; |
| 1283 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; | 1383 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; |
| 1284 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; | 1384 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; |
| 1285 | 1385 |
| 1286 intptr_t preorder_number() const { return preorder_number_; } | 1386 intptr_t preorder_number() const { return preorder_number_; } |
| 1287 void set_preorder_number(intptr_t number) { preorder_number_ = number; } | 1387 void set_preorder_number(intptr_t number) { preorder_number_ = number; } |
| 1288 | 1388 |
| 1289 intptr_t postorder_number() const { return postorder_number_; } | 1389 intptr_t postorder_number() const { return postorder_number_; } |
| 1290 void set_postorder_number(intptr_t number) { postorder_number_ = number; } | 1390 void set_postorder_number(intptr_t number) { postorder_number_ = number; } |
| 1291 | 1391 |
| 1392 intptr_t block_id() const { return block_id_; } |
| 1393 void set_block_id(intptr_t value) { block_id_ = value; } |
| 1394 |
| 1292 BlockEntryInstr* dominator() const { return dominator_; } | 1395 BlockEntryInstr* dominator() const { return dominator_; } |
| 1293 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } | 1396 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| 1294 | 1397 |
| 1295 Instruction* last_instruction() const { return last_instruction_; } | 1398 Instruction* last_instruction() const { return last_instruction_; } |
| 1296 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } | 1399 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } |
| 1297 | 1400 |
| 1298 virtual void DiscoverBlocks( | 1401 virtual void DiscoverBlocks( |
| 1299 BlockEntryInstr* current_block, | 1402 BlockEntryInstr* current_block, |
| 1300 GrowableArray<BlockEntryInstr*>* preorder, | 1403 GrowableArray<BlockEntryInstr*>* preorder, |
| 1301 GrowableArray<BlockEntryInstr*>* postorder, | 1404 GrowableArray<BlockEntryInstr*>* postorder, |
| 1302 GrowableArray<intptr_t>* parent, | 1405 GrowableArray<intptr_t>* parent, |
| 1303 GrowableArray<BitVector*>* assigned_vars, | 1406 GrowableArray<BitVector*>* assigned_vars, |
| 1304 intptr_t variable_count); | 1407 intptr_t variable_count); |
| 1305 | 1408 |
| 1306 protected: | 1409 protected: |
| 1307 BlockEntryInstr() | 1410 BlockEntryInstr() |
| 1308 : preorder_number_(-1), | 1411 : preorder_number_(-1), |
| 1309 postorder_number_(-1), | 1412 postorder_number_(-1), |
| 1413 block_id_(-1), |
| 1310 dominator_(NULL), | 1414 dominator_(NULL), |
| 1311 last_instruction_(NULL) { } | 1415 last_instruction_(NULL) { } |
| 1312 | 1416 |
| 1313 private: | 1417 private: |
| 1314 intptr_t preorder_number_; | 1418 intptr_t preorder_number_; |
| 1315 intptr_t postorder_number_; | 1419 intptr_t postorder_number_; |
| 1420 intptr_t block_id_; |
| 1316 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. | 1421 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| 1317 Instruction* last_instruction_; | 1422 Instruction* last_instruction_; |
| 1318 | 1423 |
| 1319 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 1424 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 1320 }; | 1425 }; |
| 1321 | 1426 |
| 1322 | 1427 |
| 1323 class GraphEntryInstr : public BlockEntryInstr { | 1428 class GraphEntryInstr : public BlockEntryInstr { |
| 1324 public: | 1429 public: |
| 1325 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) | 1430 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 const GrowableArray<BlockEntryInstr*>& block_order_; | 1798 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1694 | 1799 |
| 1695 private: | 1800 private: |
| 1696 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1801 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1697 }; | 1802 }; |
| 1698 | 1803 |
| 1699 | 1804 |
| 1700 } // namespace dart | 1805 } // namespace dart |
| 1701 | 1806 |
| 1702 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1807 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |