Chromium Code Reviews| 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) = 0; | |
|
srdjan
2012/05/17 22:59:22
const (and in all overriden methods)
Florian Schneider
2012/05/18 00:28:38
Done.
| |
| 90 | 96 |
| 91 // Mutate assigned_vars to add the local variable index for all | 97 // Mutate assigned_vars to add the local variable index for all |
| 92 // frame-allocated locals assigned to by the computation. | 98 // frame-allocated locals assigned to by the computation. |
| 93 virtual void RecordAssignedVars(BitVector* assigned_vars); | 99 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 94 | 100 |
| 101 virtual const char* DebugName() const = 0; | |
| 102 | |
| 103 // Printing support. These functions are sometimes overridden for custom | |
| 104 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | |
| 105 virtual void PrintTo(BufferFormatter* f); | |
| 106 virtual void PrintOperandsTo(BufferFormatter* f); | |
|
srdjan
2012/05/17 22:59:22
Can they both be const?
Florian Schneider
2012/05/18 00:28:38
Done.
| |
| 107 | |
| 95 private: | 108 private: |
| 96 friend class Instruction; | 109 friend class Instruction; |
| 97 static intptr_t GetNextCid(Isolate* isolate) { | 110 static intptr_t GetNextCid(Isolate* isolate) { |
| 98 intptr_t tmp = isolate->computation_id(); | 111 intptr_t tmp = isolate->computation_id(); |
| 99 isolate->set_computation_id(tmp + 1); | 112 isolate->set_computation_id(tmp + 1); |
| 100 return tmp; | 113 return tmp; |
| 101 } | 114 } |
| 102 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { | 115 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { |
| 103 if (isolate->ic_data_array() == Array::null()) { | 116 if (isolate->ic_data_array() == Array::null()) { |
| 104 return NULL; | 117 return NULL; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 142 public: | 155 public: |
| 143 int length() { return 0; } | 156 int length() { return 0; } |
| 144 T& operator[](intptr_t i) { | 157 T& operator[](intptr_t i) { |
| 145 UNREACHABLE(); | 158 UNREACHABLE(); |
| 146 static T sentinel = 0; | 159 static T sentinel = 0; |
| 147 return sentinel; | 160 return sentinel; |
| 148 } | 161 } |
| 149 }; | 162 }; |
| 150 | 163 |
| 151 | 164 |
| 152 class Value; | |
| 153 | |
| 154 template<intptr_t N> | 165 template<intptr_t N> |
| 155 class TemplateComputation : public Computation { | 166 class TemplateComputation : public Computation { |
| 156 public: | 167 public: |
| 157 virtual intptr_t InputCount() const { return N; } | 168 virtual intptr_t InputCount() const { return N; } |
| 169 virtual Value* InputAt(intptr_t i) { return inputs_[i]; } | |
| 158 | 170 |
| 159 protected: | 171 protected: |
| 160 EmbeddedArray<Value*, N> inputs_; | 172 EmbeddedArray<Value*, N> inputs_; |
| 161 }; | 173 }; |
| 162 | 174 |
| 163 | 175 |
| 164 class Value : public TemplateComputation<0> { | 176 class Value : public TemplateComputation<0> { |
| 165 public: | 177 public: |
| 166 Value() { } | 178 Value() { } |
| 167 | 179 |
| 168 #define DEFINE_TESTERS(ShortName, ClassName) \ | 180 #define DEFINE_TESTERS(ShortName, ClassName) \ |
| 169 virtual ClassName* As##ShortName() { return NULL; } \ | 181 virtual ClassName* As##ShortName() { return NULL; } \ |
| 170 bool Is##ShortName() { return As##ShortName() != NULL; } | 182 bool Is##ShortName() { return As##ShortName() != NULL; } |
| 171 | 183 |
| 172 FOR_EACH_VALUE(DEFINE_TESTERS) | 184 FOR_EACH_VALUE(DEFINE_TESTERS) |
| 173 #undef DEFINE_TESTERS | 185 #undef DEFINE_TESTERS |
| 174 | 186 |
| 175 private: | 187 private: |
| 176 DISALLOW_COPY_AND_ASSIGN(Value); | 188 DISALLOW_COPY_AND_ASSIGN(Value); |
| 177 }; | 189 }; |
| 178 | 190 |
| 179 | 191 |
| 180 // Functions defined in all concrete computation classes. | 192 // Functions defined in all concrete computation classes. |
| 181 #define DECLARE_COMPUTATION(ShortName) \ | 193 #define DECLARE_COMPUTATION(ShortName) \ |
| 182 virtual void Accept(FlowGraphVisitor* visitor); \ | 194 virtual void Accept(FlowGraphVisitor* visitor); \ |
| 195 virtual const char* DebugName() const { return #ShortName; } \ | |
| 183 | 196 |
| 184 // Functions defined in all concrete value classes. | 197 // Functions defined in all concrete value classes. |
| 185 #define DECLARE_VALUE(ShortName) \ | 198 #define DECLARE_VALUE(ShortName) \ |
| 186 DECLARE_COMPUTATION(ShortName) \ | 199 DECLARE_COMPUTATION(ShortName) \ |
| 187 virtual ShortName##Val* As##ShortName() { return this; } | 200 virtual ShortName##Val* As##ShortName() { return this; } \ |
| 201 virtual void PrintTo(BufferFormatter* f); \ | |
| 188 | 202 |
| 189 | 203 |
| 190 // Definitions and uses are mutually recursive. | 204 // Definitions and uses are mutually recursive. |
| 191 class Definition; | 205 class Definition; |
| 192 | 206 |
| 193 class UseVal : public Value { | 207 class UseVal : public Value { |
| 194 public: | 208 public: |
| 195 explicit UseVal(Definition* definition) : definition_(definition) { } | 209 explicit UseVal(Definition* definition) : definition_(definition) { } |
| 196 | 210 |
| 197 DECLARE_VALUE(Use) | 211 DECLARE_VALUE(Use) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 intptr_t token_index() const { return token_index_; } | 262 intptr_t token_index() const { return token_index_; } |
| 249 intptr_t try_index() const { return try_index_; } | 263 intptr_t try_index() const { return try_index_; } |
| 250 Value* value() const { return value_; } | 264 Value* value() const { return value_; } |
| 251 Value* instantiator_type_arguments() const { | 265 Value* instantiator_type_arguments() const { |
| 252 return instantiator_type_arguments_; | 266 return instantiator_type_arguments_; |
| 253 } | 267 } |
| 254 const AbstractType& dst_type() const { return dst_type_; } | 268 const AbstractType& dst_type() const { return dst_type_; } |
| 255 const String& dst_name() const { return dst_name_; } | 269 const String& dst_name() const { return dst_name_; } |
| 256 | 270 |
| 257 virtual intptr_t InputCount() const; | 271 virtual intptr_t InputCount() const; |
| 272 virtual Value* InputAt(intptr_t i) { | |
| 273 if (i == 0) return value(); | |
| 274 if (i == 1) return instantiator_type_arguments(); | |
| 275 return NULL; | |
| 276 } | |
| 277 | |
| 278 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 258 | 279 |
| 259 private: | 280 private: |
| 260 const intptr_t token_index_; | 281 const intptr_t token_index_; |
| 261 const intptr_t try_index_; | 282 const intptr_t try_index_; |
| 262 Value* value_; | 283 Value* value_; |
| 263 Value* instantiator_type_arguments_; | 284 Value* instantiator_type_arguments_; |
| 264 const AbstractType& dst_type_; | 285 const AbstractType& dst_type_; |
| 265 const String& dst_name_; | 286 const String& dst_name_; |
| 266 | 287 |
| 267 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); | 288 DISALLOW_COPY_AND_ASSIGN(AssertAssignableComp); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 | 360 |
| 340 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 361 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 341 intptr_t token_index() const { return ast_node_.token_index(); } | 362 intptr_t token_index() const { return ast_node_.token_index(); } |
| 342 intptr_t try_index() const { return try_index_; } | 363 intptr_t try_index() const { return try_index_; } |
| 343 | 364 |
| 344 Value* context() const { return context_; } | 365 Value* context() const { return context_; } |
| 345 intptr_t ArgumentCount() const { return arguments_->length(); } | 366 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 346 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 367 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 347 | 368 |
| 348 virtual intptr_t InputCount() const; | 369 virtual intptr_t InputCount() const; |
| 370 virtual Value* InputAt(intptr_t i) { | |
| 371 return i == 0 ? context() : ArgumentAt(i - 1); | |
| 372 } | |
| 373 | |
| 374 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 349 | 375 |
| 350 private: | 376 private: |
| 351 const ClosureCallNode& ast_node_; | 377 const ClosureCallNode& ast_node_; |
| 352 const intptr_t try_index_; | 378 const intptr_t try_index_; |
| 353 Value* context_; | 379 Value* context_; |
| 354 ZoneGrowableArray<Value*>* arguments_; | 380 ZoneGrowableArray<Value*>* arguments_; |
| 355 | 381 |
| 356 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); | 382 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| 357 }; | 383 }; |
| 358 | 384 |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 380 | 406 |
| 381 intptr_t token_index() const { return token_index_; } | 407 intptr_t token_index() const { return token_index_; } |
| 382 intptr_t try_index() const { return try_index_; } | 408 intptr_t try_index() const { return try_index_; } |
| 383 const String& function_name() const { return function_name_; } | 409 const String& function_name() const { return function_name_; } |
| 384 intptr_t ArgumentCount() const { return arguments_->length(); } | 410 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 385 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 411 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 386 const Array& argument_names() const { return argument_names_; } | 412 const Array& argument_names() const { return argument_names_; } |
| 387 intptr_t checked_argument_count() const { return checked_argument_count_; } | 413 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 388 | 414 |
| 389 virtual intptr_t InputCount() const; | 415 virtual intptr_t InputCount() const; |
| 416 virtual Value* InputAt(intptr_t i) { return ArgumentAt(i); } | |
| 417 | |
| 418 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 390 | 419 |
| 391 private: | 420 private: |
| 392 const intptr_t token_index_; | 421 const intptr_t token_index_; |
| 393 const intptr_t try_index_; | 422 const intptr_t try_index_; |
| 394 const String& function_name_; | 423 const String& function_name_; |
| 395 ZoneGrowableArray<Value*>* const arguments_; | 424 ZoneGrowableArray<Value*>* const arguments_; |
| 396 const Array& argument_names_; | 425 const Array& argument_names_; |
| 397 const intptr_t checked_argument_count_; | 426 const intptr_t checked_argument_count_; |
| 398 | 427 |
| 399 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 428 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 400 }; | 429 }; |
| 401 | 430 |
| 402 | 431 |
| 403 class StrictCompareComp : public TemplateComputation<2> { | 432 class StrictCompareComp : public TemplateComputation<2> { |
| 404 public: | 433 public: |
| 405 StrictCompareComp(Token::Kind kind, Value* left, Value* right) | 434 StrictCompareComp(Token::Kind kind, Value* left, Value* right) |
| 406 : kind_(kind) { | 435 : kind_(kind) { |
| 407 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); | 436 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); |
| 408 inputs_[0] = left; | 437 inputs_[0] = left; |
| 409 inputs_[1] = right; | 438 inputs_[1] = right; |
| 410 } | 439 } |
| 411 | 440 |
| 412 DECLARE_COMPUTATION(StrictCompare) | 441 DECLARE_COMPUTATION(StrictCompare) |
| 413 | 442 |
| 414 Token::Kind kind() const { return kind_; } | 443 Token::Kind kind() const { return kind_; } |
| 415 Value* left() { return inputs_[0]; } | 444 Value* left() { return inputs_[0]; } |
| 416 Value* right() { return inputs_[1]; } | 445 Value* right() { return inputs_[1]; } |
| 417 | 446 |
| 447 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 448 | |
| 418 private: | 449 private: |
| 419 const Token::Kind kind_; | 450 const Token::Kind kind_; |
| 420 | 451 |
| 421 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); | 452 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
| 422 }; | 453 }; |
| 423 | 454 |
| 424 | 455 |
| 425 class EqualityCompareComp : public TemplateComputation<2> { | 456 class EqualityCompareComp : public TemplateComputation<2> { |
| 426 public: | 457 public: |
| 427 EqualityCompareComp(intptr_t token_index, | 458 EqualityCompareComp(intptr_t token_index, |
| 428 intptr_t try_index, | 459 intptr_t try_index, |
| 429 Value* left, | 460 Value* left, |
| 430 Value* right) | 461 Value* right) |
| 431 : token_index_(token_index), | 462 : token_index_(token_index), |
| 432 try_index_(try_index) { | 463 try_index_(try_index) { |
| 433 ASSERT(left != NULL); | 464 ASSERT(left != NULL); |
| 434 ASSERT(right != NULL); | 465 ASSERT(right != NULL); |
| 435 inputs_[0] = left; | 466 inputs_[0] = left; |
| 436 inputs_[1] = right; | 467 inputs_[1] = right; |
| 437 } | 468 } |
| 438 | 469 |
| 439 DECLARE_COMPUTATION(EqualityCompareComp) | 470 DECLARE_COMPUTATION(EqualityCompareComp) |
| 440 | 471 |
| 441 intptr_t token_index() const { return token_index_; } | 472 intptr_t token_index() const { return token_index_; } |
| 442 intptr_t try_index() const { return try_index_; } | 473 intptr_t try_index() const { return try_index_; } |
| 443 Value* left() { return inputs_[0]; } | 474 Value* left() { return inputs_[0]; } |
| 444 Value* right() { return inputs_[1]; } | 475 Value* right() { return inputs_[1]; } |
| 445 | 476 |
| 477 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 478 | |
| 446 private: | 479 private: |
| 447 const intptr_t token_index_; | 480 const intptr_t token_index_; |
| 448 const intptr_t try_index_; | 481 const intptr_t try_index_; |
| 449 | 482 |
| 450 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); | 483 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); |
| 451 }; | 484 }; |
| 452 | 485 |
| 453 | 486 |
| 454 class StaticCallComp : public Computation { | 487 class StaticCallComp : public Computation { |
| 455 public: | 488 public: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 472 // Accessors forwarded to the AST node. | 505 // Accessors forwarded to the AST node. |
| 473 const Function& function() const { return function_; } | 506 const Function& function() const { return function_; } |
| 474 const Array& argument_names() const { return argument_names_; } | 507 const Array& argument_names() const { return argument_names_; } |
| 475 intptr_t token_index() const { return token_index_; } | 508 intptr_t token_index() const { return token_index_; } |
| 476 intptr_t try_index() const { return try_index_; } | 509 intptr_t try_index() const { return try_index_; } |
| 477 | 510 |
| 478 intptr_t ArgumentCount() const { return arguments_->length(); } | 511 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 479 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 512 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 480 | 513 |
| 481 virtual intptr_t InputCount() const; | 514 virtual intptr_t InputCount() const; |
| 515 virtual Value* InputAt(intptr_t i) { return ArgumentAt(i); } | |
| 516 | |
| 517 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 482 | 518 |
| 483 private: | 519 private: |
| 484 const intptr_t token_index_; | 520 const intptr_t token_index_; |
| 485 const intptr_t try_index_; | 521 const intptr_t try_index_; |
| 486 const Function& function_; | 522 const Function& function_; |
| 487 const Array& argument_names_; | 523 const Array& argument_names_; |
| 488 ZoneGrowableArray<Value*>* arguments_; | 524 ZoneGrowableArray<Value*>* arguments_; |
| 489 | 525 |
| 490 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); | 526 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
| 491 }; | 527 }; |
| 492 | 528 |
| 493 | 529 |
| 494 class LoadLocalComp : public TemplateComputation<0> { | 530 class LoadLocalComp : public TemplateComputation<0> { |
| 495 public: | 531 public: |
| 496 LoadLocalComp(const LocalVariable& local, intptr_t context_level) | 532 LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
| 497 : local_(local), context_level_(context_level) { } | 533 : local_(local), context_level_(context_level) { } |
| 498 | 534 |
| 499 DECLARE_COMPUTATION(LoadLocal) | 535 DECLARE_COMPUTATION(LoadLocal) |
| 500 | 536 |
| 501 const LocalVariable& local() const { return local_; } | 537 const LocalVariable& local() const { return local_; } |
| 502 intptr_t context_level() const { return context_level_; } | 538 intptr_t context_level() const { return context_level_; } |
| 503 | 539 |
| 540 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 541 | |
| 504 private: | 542 private: |
| 505 const LocalVariable& local_; | 543 const LocalVariable& local_; |
| 506 const intptr_t context_level_; | 544 const intptr_t context_level_; |
| 507 | 545 |
| 508 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); | 546 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
| 509 }; | 547 }; |
| 510 | 548 |
| 511 | 549 |
| 512 class StoreLocalComp : public TemplateComputation<1> { | 550 class StoreLocalComp : public TemplateComputation<1> { |
| 513 public: | 551 public: |
| 514 StoreLocalComp(const LocalVariable& local, | 552 StoreLocalComp(const LocalVariable& local, |
| 515 Value* value, | 553 Value* value, |
| 516 intptr_t context_level) | 554 intptr_t context_level) |
| 517 : local_(local), context_level_(context_level) { | 555 : local_(local), context_level_(context_level) { |
| 518 inputs_[0] = value; | 556 inputs_[0] = value; |
| 519 } | 557 } |
| 520 | 558 |
| 521 DECLARE_COMPUTATION(StoreLocal) | 559 DECLARE_COMPUTATION(StoreLocal) |
| 522 | 560 |
| 523 const LocalVariable& local() const { return local_; } | 561 const LocalVariable& local() const { return local_; } |
| 524 Value* value() { return inputs_[0]; } | 562 Value* value() { return inputs_[0]; } |
| 525 intptr_t context_level() const { return context_level_; } | 563 intptr_t context_level() const { return context_level_; } |
| 526 | 564 |
| 527 virtual void RecordAssignedVars(BitVector* assigned_vars); | 565 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 528 | 566 |
| 567 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 568 | |
| 529 private: | 569 private: |
| 530 const LocalVariable& local_; | 570 const LocalVariable& local_; |
| 531 const intptr_t context_level_; | 571 const intptr_t context_level_; |
| 532 | 572 |
| 533 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 573 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 534 }; | 574 }; |
| 535 | 575 |
| 536 | 576 |
| 537 class NativeCallComp : public TemplateComputation<0> { | 577 class NativeCallComp : public TemplateComputation<0> { |
| 538 public: | 578 public: |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 551 NativeFunction native_c_function() const { | 591 NativeFunction native_c_function() const { |
| 552 return ast_node_.native_c_function(); | 592 return ast_node_.native_c_function(); |
| 553 } | 593 } |
| 554 | 594 |
| 555 intptr_t argument_count() const { return ast_node_.argument_count(); } | 595 intptr_t argument_count() const { return ast_node_.argument_count(); } |
| 556 | 596 |
| 557 bool has_optional_parameters() const { | 597 bool has_optional_parameters() const { |
| 558 return ast_node_.has_optional_parameters(); | 598 return ast_node_.has_optional_parameters(); |
| 559 } | 599 } |
| 560 | 600 |
| 601 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 602 | |
| 561 private: | 603 private: |
| 562 const NativeBodyNode& ast_node_; | 604 const NativeBodyNode& ast_node_; |
| 563 const intptr_t try_index_; | 605 const intptr_t try_index_; |
| 564 | 606 |
| 565 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); | 607 DISALLOW_COPY_AND_ASSIGN(NativeCallComp); |
| 566 }; | 608 }; |
| 567 | 609 |
| 568 | 610 |
| 569 class LoadInstanceFieldComp : public TemplateComputation<1> { | 611 class LoadInstanceFieldComp : public TemplateComputation<1> { |
| 570 public: | 612 public: |
| 571 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) | 613 LoadInstanceFieldComp(LoadInstanceFieldNode* ast_node, Value* instance) |
| 572 : ast_node_(*ast_node) { | 614 : ast_node_(*ast_node) { |
| 573 ASSERT(instance != NULL); | 615 ASSERT(instance != NULL); |
| 574 inputs_[0] = instance; | 616 inputs_[0] = instance; |
| 575 } | 617 } |
| 576 | 618 |
| 577 DECLARE_COMPUTATION(LoadInstanceField) | 619 DECLARE_COMPUTATION(LoadInstanceField) |
| 578 | 620 |
| 579 const Field& field() const { return ast_node_.field(); } | 621 const Field& field() const { return ast_node_.field(); } |
| 580 | 622 |
| 581 Value* instance() { return inputs_[0]; } | 623 Value* instance() { return inputs_[0]; } |
| 582 | 624 |
| 625 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 626 | |
| 583 private: | 627 private: |
| 584 const LoadInstanceFieldNode& ast_node_; | 628 const LoadInstanceFieldNode& ast_node_; |
| 585 | 629 |
| 586 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); | 630 DISALLOW_COPY_AND_ASSIGN(LoadInstanceFieldComp); |
| 587 }; | 631 }; |
| 588 | 632 |
| 589 | 633 |
| 590 class StoreInstanceFieldComp : public TemplateComputation<2> { | 634 class StoreInstanceFieldComp : public TemplateComputation<2> { |
| 591 public: | 635 public: |
| 592 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, | 636 StoreInstanceFieldComp(StoreInstanceFieldNode* ast_node, |
| 593 Value* instance, | 637 Value* instance, |
| 594 Value* value) | 638 Value* value) |
| 595 : ast_node_(*ast_node) { | 639 : ast_node_(*ast_node) { |
| 596 ASSERT(instance != NULL); | 640 ASSERT(instance != NULL); |
| 597 ASSERT(value != NULL); | 641 ASSERT(value != NULL); |
| 598 inputs_[0] = instance; | 642 inputs_[0] = instance; |
| 599 inputs_[1] = value; | 643 inputs_[1] = value; |
| 600 } | 644 } |
| 601 | 645 |
| 602 DECLARE_COMPUTATION(StoreInstanceField) | 646 DECLARE_COMPUTATION(StoreInstanceField) |
| 603 | 647 |
| 604 intptr_t token_index() const { return ast_node_.token_index(); } | 648 intptr_t token_index() const { return ast_node_.token_index(); } |
| 605 const Field& field() const { return ast_node_.field(); } | 649 const Field& field() const { return ast_node_.field(); } |
| 606 | 650 |
| 607 Value* instance() { return inputs_[0]; } | 651 Value* instance() { return inputs_[0]; } |
| 608 Value* value() { return inputs_[1]; } | 652 Value* value() { return inputs_[1]; } |
| 609 | 653 |
| 654 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 655 | |
| 610 private: | 656 private: |
| 611 const StoreInstanceFieldNode& ast_node_; | 657 const StoreInstanceFieldNode& ast_node_; |
| 612 | 658 |
| 613 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); | 659 DISALLOW_COPY_AND_ASSIGN(StoreInstanceFieldComp); |
| 614 }; | 660 }; |
| 615 | 661 |
| 616 | 662 |
| 617 class LoadStaticFieldComp : public TemplateComputation<0> { | 663 class LoadStaticFieldComp : public TemplateComputation<0> { |
| 618 public: | 664 public: |
| 619 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} | 665 explicit LoadStaticFieldComp(const Field& field) : field_(field) {} |
| 620 | 666 |
| 621 DECLARE_COMPUTATION(LoadStaticField); | 667 DECLARE_COMPUTATION(LoadStaticField); |
| 622 | 668 |
| 623 const Field& field() const { return field_; } | 669 const Field& field() const { return field_; } |
| 624 | 670 |
| 671 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 672 | |
| 625 private: | 673 private: |
| 626 const Field& field_; | 674 const Field& field_; |
| 627 | 675 |
| 628 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); | 676 DISALLOW_COPY_AND_ASSIGN(LoadStaticFieldComp); |
| 629 }; | 677 }; |
| 630 | 678 |
| 631 | 679 |
| 632 class StoreStaticFieldComp : public TemplateComputation<1> { | 680 class StoreStaticFieldComp : public TemplateComputation<1> { |
| 633 public: | 681 public: |
| 634 StoreStaticFieldComp(const Field& field, Value* value) | 682 StoreStaticFieldComp(const Field& field, Value* value) |
| 635 : field_(field) { | 683 : field_(field) { |
| 636 ASSERT(field.IsZoneHandle()); | 684 ASSERT(field.IsZoneHandle()); |
| 637 ASSERT(value != NULL); | 685 ASSERT(value != NULL); |
| 638 inputs_[0] = value; | 686 inputs_[0] = value; |
| 639 } | 687 } |
| 640 | 688 |
| 641 DECLARE_COMPUTATION(StoreStaticField); | 689 DECLARE_COMPUTATION(StoreStaticField); |
| 642 | 690 |
| 643 const Field& field() const { return field_; } | 691 const Field& field() const { return field_; } |
| 644 Value* value() { return inputs_[0]; } | 692 Value* value() { return inputs_[0]; } |
| 645 | 693 |
| 694 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 695 | |
| 646 private: | 696 private: |
| 647 const Field& field_; | 697 const Field& field_; |
| 648 | 698 |
| 649 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); | 699 DISALLOW_COPY_AND_ASSIGN(StoreStaticFieldComp); |
| 650 }; | 700 }; |
| 651 | 701 |
| 652 | 702 |
| 653 // Not simply an InstanceCall because it has somewhat more complicated | 703 // Not simply an InstanceCall because it has somewhat more complicated |
| 654 // semantics: the value operand is preserved before the call. | 704 // semantics: the value operand is preserved before the call. |
| 655 class StoreIndexedComp : public TemplateComputation<3> { | 705 class StoreIndexedComp : public TemplateComputation<3> { |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 DECLARE_COMPUTATION(InstanceOf) | 832 DECLARE_COMPUTATION(InstanceOf) |
| 783 | 833 |
| 784 Value* value() const { return value_; } | 834 Value* value() const { return value_; } |
| 785 Value* type_arguments() const { return type_arguments_; } | 835 Value* type_arguments() const { return type_arguments_; } |
| 786 bool negate_result() const { return negate_result_; } | 836 bool negate_result() const { return negate_result_; } |
| 787 const AbstractType& type() const { return type_; } | 837 const AbstractType& type() const { return type_; } |
| 788 intptr_t token_index() const { return token_index_; } | 838 intptr_t token_index() const { return token_index_; } |
| 789 intptr_t try_index() const { return try_index_; } | 839 intptr_t try_index() const { return try_index_; } |
| 790 | 840 |
| 791 virtual intptr_t InputCount() const; | 841 virtual intptr_t InputCount() const; |
| 842 virtual Value* InputAt(intptr_t i) { | |
| 843 if (i == 0) return value(); | |
| 844 if (i == 1) return type_arguments(); | |
| 845 return NULL; | |
| 846 } | |
| 847 | |
| 848 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 792 | 849 |
| 793 private: | 850 private: |
| 794 const intptr_t token_index_; | 851 const intptr_t token_index_; |
| 795 const intptr_t try_index_; | 852 const intptr_t try_index_; |
| 796 Value* value_; | 853 Value* value_; |
| 797 Value* type_arguments_; | 854 Value* type_arguments_; |
| 798 const AbstractType& type_; | 855 const AbstractType& type_; |
| 799 const bool negate_result_; | 856 const bool negate_result_; |
| 800 | 857 |
| 801 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); | 858 DISALLOW_COPY_AND_ASSIGN(InstanceOfComp); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 813 } | 870 } |
| 814 | 871 |
| 815 DECLARE_COMPUTATION(AllocateObject) | 872 DECLARE_COMPUTATION(AllocateObject) |
| 816 | 873 |
| 817 const Function& constructor() const { return ast_node_.constructor(); } | 874 const Function& constructor() const { return ast_node_.constructor(); } |
| 818 intptr_t token_index() const { return ast_node_.token_index(); } | 875 intptr_t token_index() const { return ast_node_.token_index(); } |
| 819 intptr_t try_index() const { return try_index_; } | 876 intptr_t try_index() const { return try_index_; } |
| 820 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 877 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 821 | 878 |
| 822 virtual intptr_t InputCount() const; | 879 virtual intptr_t InputCount() const; |
| 880 virtual Value* InputAt(intptr_t i) { return arguments()[i]; } | |
| 881 | |
| 882 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 823 | 883 |
| 824 private: | 884 private: |
| 825 const ConstructorCallNode& ast_node_; | 885 const ConstructorCallNode& ast_node_; |
| 826 const intptr_t try_index_; | 886 const intptr_t try_index_; |
| 827 ZoneGrowableArray<Value*>* const arguments_; | 887 ZoneGrowableArray<Value*>* const arguments_; |
| 828 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); | 888 DISALLOW_COPY_AND_ASSIGN(AllocateObjectComp); |
| 829 }; | 889 }; |
| 830 | 890 |
| 831 | 891 |
| 832 class AllocateObjectWithBoundsCheckComp : public Computation { | 892 class AllocateObjectWithBoundsCheckComp : public Computation { |
| 833 public: | 893 public: |
| 834 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node, | 894 AllocateObjectWithBoundsCheckComp(ConstructorCallNode* node, |
| 835 intptr_t try_index, | 895 intptr_t try_index, |
| 836 ZoneGrowableArray<Value*>* arguments) | 896 ZoneGrowableArray<Value*>* arguments) |
| 837 : ast_node_(*node), try_index_(try_index), arguments_(arguments) { | 897 : ast_node_(*node), try_index_(try_index), arguments_(arguments) { |
| 838 // One type-argument and one instantiator. | 898 // One type-argument and one instantiator. |
| 839 ASSERT(arguments->length() == 2); | 899 ASSERT(arguments->length() == 2); |
| 840 } | 900 } |
| 841 | 901 |
| 842 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) | 902 DECLARE_COMPUTATION(AllocateObjectWithBoundsCheck) |
| 843 | 903 |
| 844 const Function& constructor() const { return ast_node_.constructor(); } | 904 const Function& constructor() const { return ast_node_.constructor(); } |
| 845 intptr_t token_index() const { return ast_node_.token_index(); } | 905 intptr_t token_index() const { return ast_node_.token_index(); } |
| 846 intptr_t try_index() const { return try_index_; } | 906 intptr_t try_index() const { return try_index_; } |
| 847 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } | 907 const ZoneGrowableArray<Value*>& arguments() const { return *arguments_; } |
| 848 | 908 |
| 849 virtual intptr_t InputCount() const; | 909 virtual intptr_t InputCount() const; |
| 910 virtual Value* InputAt(intptr_t i) { return arguments()[i]; } | |
| 911 | |
| 912 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 850 | 913 |
| 851 private: | 914 private: |
| 852 const ConstructorCallNode& ast_node_; | 915 const ConstructorCallNode& ast_node_; |
| 853 const intptr_t try_index_; | 916 const intptr_t try_index_; |
| 854 ZoneGrowableArray<Value*>* const arguments_; | 917 ZoneGrowableArray<Value*>* const arguments_; |
| 855 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); | 918 DISALLOW_COPY_AND_ASSIGN(AllocateObjectWithBoundsCheckComp); |
| 856 }; | 919 }; |
| 857 | 920 |
| 858 | 921 |
| 859 class CreateArrayComp : public Computation { | 922 class CreateArrayComp : public Computation { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 876 | 939 |
| 877 DECLARE_COMPUTATION(CreateArray) | 940 DECLARE_COMPUTATION(CreateArray) |
| 878 | 941 |
| 879 intptr_t token_index() const { return token_index_; } | 942 intptr_t token_index() const { return token_index_; } |
| 880 intptr_t try_index() const { return try_index_; } | 943 intptr_t try_index() const { return try_index_; } |
| 881 intptr_t ElementCount() const { return elements_->length(); } | 944 intptr_t ElementCount() const { return elements_->length(); } |
| 882 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } | 945 Value* ElementAt(intptr_t i) const { return (*elements_)[i]; } |
| 883 Value* element_type() const { return element_type_; } | 946 Value* element_type() const { return element_type_; } |
| 884 | 947 |
| 885 virtual intptr_t InputCount() const; | 948 virtual intptr_t InputCount() const; |
| 949 virtual Value* InputAt(intptr_t i) { return ElementAt(i); } | |
| 950 | |
| 951 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 886 | 952 |
| 887 private: | 953 private: |
| 888 const intptr_t token_index_; | 954 const intptr_t token_index_; |
| 889 const intptr_t try_index_; | 955 const intptr_t try_index_; |
| 890 ZoneGrowableArray<Value*>* const elements_; | 956 ZoneGrowableArray<Value*>* const elements_; |
| 891 Value* element_type_; | 957 Value* element_type_; |
| 892 | 958 |
| 893 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); | 959 DISALLOW_COPY_AND_ASSIGN(CreateArrayComp); |
| 894 }; | 960 }; |
| 895 | 961 |
| 896 | 962 |
| 897 class CreateClosureComp : public Computation { | 963 class CreateClosureComp : public Computation { |
| 898 public: | 964 public: |
| 899 // 'type_arguments' is null if function() does not require type arguments. | 965 // 'type_arguments' is null if function() does not require type arguments. |
| 900 CreateClosureComp(ClosureNode* node, | 966 CreateClosureComp(ClosureNode* node, |
| 901 intptr_t try_index, | 967 intptr_t try_index, |
| 902 Value* type_arguments) | 968 Value* type_arguments) |
| 903 : ast_node_(*node), | 969 : ast_node_(*node), |
| 904 try_index_(try_index), | 970 try_index_(try_index), |
| 905 type_arguments_(type_arguments) {} | 971 type_arguments_(type_arguments) {} |
| 906 | 972 |
| 907 DECLARE_COMPUTATION(CreateClosure) | 973 DECLARE_COMPUTATION(CreateClosure) |
| 908 | 974 |
| 909 intptr_t token_index() const { return ast_node_.token_index(); } | 975 intptr_t token_index() const { return ast_node_.token_index(); } |
| 910 intptr_t try_index() const { return try_index_; } | 976 intptr_t try_index() const { return try_index_; } |
| 911 const Function& function() const { return ast_node_.function(); } | 977 const Function& function() const { return ast_node_.function(); } |
| 912 Value* type_arguments() const { return type_arguments_; } | 978 Value* type_arguments() const { return type_arguments_; } |
| 913 | 979 |
| 914 virtual intptr_t InputCount() const; | 980 virtual intptr_t InputCount() const; |
| 981 virtual Value* InputAt(intptr_t i) { | |
| 982 return i == 0 ? type_arguments() : NULL; | |
| 983 } | |
| 984 | |
| 985 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 915 | 986 |
| 916 private: | 987 private: |
| 917 const ClosureNode& ast_node_; | 988 const ClosureNode& ast_node_; |
| 918 const intptr_t try_index_; | 989 const intptr_t try_index_; |
| 919 Value* type_arguments_; | 990 Value* type_arguments_; |
| 920 | 991 |
| 921 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); | 992 DISALLOW_COPY_AND_ASSIGN(CreateClosureComp); |
| 922 }; | 993 }; |
| 923 | 994 |
| 924 | 995 |
| 925 class NativeLoadFieldComp : public TemplateComputation<1> { | 996 class NativeLoadFieldComp : public TemplateComputation<1> { |
| 926 public: | 997 public: |
| 927 NativeLoadFieldComp(Value* value, intptr_t offset_in_bytes) | 998 NativeLoadFieldComp(Value* value, intptr_t offset_in_bytes) |
| 928 : offset_in_bytes_(offset_in_bytes) { | 999 : offset_in_bytes_(offset_in_bytes) { |
| 929 ASSERT(value != NULL); | 1000 ASSERT(value != NULL); |
| 930 inputs_[0] = value; | 1001 inputs_[0] = value; |
| 931 } | 1002 } |
| 932 | 1003 |
| 933 DECLARE_COMPUTATION(NativeLoadField) | 1004 DECLARE_COMPUTATION(NativeLoadField) |
| 934 | 1005 |
| 935 Value* value() { return inputs_[0]; } | 1006 Value* value() { return inputs_[0]; } |
| 936 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 1007 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 937 | 1008 |
| 1009 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1010 | |
| 938 private: | 1011 private: |
| 939 const intptr_t offset_in_bytes_; | 1012 const intptr_t offset_in_bytes_; |
| 940 | 1013 |
| 941 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); | 1014 DISALLOW_COPY_AND_ASSIGN(NativeLoadFieldComp); |
| 942 }; | 1015 }; |
| 943 | 1016 |
| 944 | 1017 |
| 945 class NativeStoreFieldComp : public TemplateComputation<2> { | 1018 class NativeStoreFieldComp : public TemplateComputation<2> { |
| 946 public: | 1019 public: |
| 947 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value) | 1020 NativeStoreFieldComp(Value* dest, intptr_t offset_in_bytes, Value* value) |
| 948 : offset_in_bytes_(offset_in_bytes) { | 1021 : offset_in_bytes_(offset_in_bytes) { |
| 949 ASSERT(value != NULL); | 1022 ASSERT(value != NULL); |
| 950 inputs_[0] = dest; | 1023 inputs_[0] = dest; |
| 951 inputs_[1] = value; | 1024 inputs_[1] = value; |
| 952 } | 1025 } |
| 953 | 1026 |
| 954 DECLARE_COMPUTATION(NativeStoreField) | 1027 DECLARE_COMPUTATION(NativeStoreField) |
| 955 | 1028 |
| 956 Value* dest() { return inputs_[0]; } | 1029 Value* dest() { return inputs_[0]; } |
| 957 Value* value() { return inputs_[1]; } | 1030 Value* value() { return inputs_[1]; } |
| 958 intptr_t offset_in_bytes() const { return offset_in_bytes_; } | 1031 intptr_t offset_in_bytes() const { return offset_in_bytes_; } |
| 959 | 1032 |
| 1033 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1034 | |
| 960 private: | 1035 private: |
| 961 const intptr_t offset_in_bytes_; | 1036 const intptr_t offset_in_bytes_; |
| 962 | 1037 |
| 963 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); | 1038 DISALLOW_COPY_AND_ASSIGN(NativeStoreFieldComp); |
| 964 }; | 1039 }; |
| 965 | 1040 |
| 966 | 1041 |
| 967 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { | 1042 class InstantiateTypeArgumentsComp : public TemplateComputation<1> { |
| 968 public: | 1043 public: |
| 969 InstantiateTypeArgumentsComp(intptr_t token_index, | 1044 InstantiateTypeArgumentsComp(intptr_t token_index, |
| 970 intptr_t try_index, | 1045 intptr_t try_index, |
| 971 const AbstractTypeArguments& type_arguments, | 1046 const AbstractTypeArguments& type_arguments, |
| 972 Value* instantiator) | 1047 Value* instantiator) |
| 973 : token_index_(token_index), | 1048 : token_index_(token_index), |
| 974 try_index_(try_index), | 1049 try_index_(try_index), |
| 975 type_arguments_(type_arguments) { | 1050 type_arguments_(type_arguments) { |
| 976 ASSERT(instantiator != NULL); | 1051 ASSERT(instantiator != NULL); |
| 977 inputs_[0] = instantiator; | 1052 inputs_[0] = instantiator; |
| 978 } | 1053 } |
| 979 | 1054 |
| 980 DECLARE_COMPUTATION(InstantiateTypeArguments) | 1055 DECLARE_COMPUTATION(InstantiateTypeArguments) |
| 981 | 1056 |
| 982 Value* instantiator() { return inputs_[0]; } | 1057 Value* instantiator() { return inputs_[0]; } |
| 983 const AbstractTypeArguments& type_arguments() const { | 1058 const AbstractTypeArguments& type_arguments() const { |
| 984 return type_arguments_; | 1059 return type_arguments_; |
| 985 } | 1060 } |
| 986 intptr_t token_index() const { return token_index_; } | 1061 intptr_t token_index() const { return token_index_; } |
| 987 intptr_t try_index() const { return try_index_; } | 1062 intptr_t try_index() const { return try_index_; } |
| 988 | 1063 |
| 1064 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1065 | |
| 989 private: | 1066 private: |
| 990 const intptr_t token_index_; | 1067 const intptr_t token_index_; |
| 991 const intptr_t try_index_; | 1068 const intptr_t try_index_; |
| 992 const AbstractTypeArguments& type_arguments_; | 1069 const AbstractTypeArguments& type_arguments_; |
| 993 | 1070 |
| 994 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); | 1071 DISALLOW_COPY_AND_ASSIGN(InstantiateTypeArgumentsComp); |
| 995 }; | 1072 }; |
| 996 | 1073 |
| 997 | 1074 |
| 998 class ExtractConstructorTypeArgumentsComp : public TemplateComputation<1> { | 1075 class ExtractConstructorTypeArgumentsComp : public TemplateComputation<1> { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1011 | 1088 |
| 1012 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) | 1089 DECLARE_COMPUTATION(ExtractConstructorTypeArguments) |
| 1013 | 1090 |
| 1014 Value* instantiator() { return inputs_[0]; } | 1091 Value* instantiator() { return inputs_[0]; } |
| 1015 const AbstractTypeArguments& type_arguments() const { | 1092 const AbstractTypeArguments& type_arguments() const { |
| 1016 return type_arguments_; | 1093 return type_arguments_; |
| 1017 } | 1094 } |
| 1018 intptr_t token_index() const { return token_index_; } | 1095 intptr_t token_index() const { return token_index_; } |
| 1019 intptr_t try_index() const { return try_index_; } | 1096 intptr_t try_index() const { return try_index_; } |
| 1020 | 1097 |
| 1098 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1099 | |
| 1021 private: | 1100 private: |
| 1022 const intptr_t token_index_; | 1101 const intptr_t token_index_; |
| 1023 const intptr_t try_index_; | 1102 const intptr_t try_index_; |
| 1024 const AbstractTypeArguments& type_arguments_; | 1103 const AbstractTypeArguments& type_arguments_; |
| 1025 | 1104 |
| 1026 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); | 1105 DISALLOW_COPY_AND_ASSIGN(ExtractConstructorTypeArgumentsComp); |
| 1027 }; | 1106 }; |
| 1028 | 1107 |
| 1029 | 1108 |
| 1030 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { | 1109 class ExtractConstructorInstantiatorComp : public TemplateComputation<1> { |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 1060 : token_index_(token_index), | 1139 : token_index_(token_index), |
| 1061 try_index_(try_index), | 1140 try_index_(try_index), |
| 1062 num_context_variables_(num_context_variables) {} | 1141 num_context_variables_(num_context_variables) {} |
| 1063 | 1142 |
| 1064 DECLARE_COMPUTATION(AllocateContext); | 1143 DECLARE_COMPUTATION(AllocateContext); |
| 1065 | 1144 |
| 1066 intptr_t token_index() const { return token_index_; } | 1145 intptr_t token_index() const { return token_index_; } |
| 1067 intptr_t try_index() const { return try_index_; } | 1146 intptr_t try_index() const { return try_index_; } |
| 1068 intptr_t num_context_variables() const { return num_context_variables_; } | 1147 intptr_t num_context_variables() const { return num_context_variables_; } |
| 1069 | 1148 |
| 1149 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1150 | |
| 1070 private: | 1151 private: |
| 1071 const intptr_t token_index_; | 1152 const intptr_t token_index_; |
| 1072 const intptr_t try_index_; | 1153 const intptr_t try_index_; |
| 1073 const intptr_t num_context_variables_; | 1154 const intptr_t num_context_variables_; |
| 1074 | 1155 |
| 1075 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); | 1156 DISALLOW_COPY_AND_ASSIGN(AllocateContextComp); |
| 1076 }; | 1157 }; |
| 1077 | 1158 |
| 1078 | 1159 |
| 1079 class ChainContextComp : public TemplateComputation<1> { | 1160 class ChainContextComp : public TemplateComputation<1> { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1121 public: | 1202 public: |
| 1122 CatchEntryComp(const LocalVariable& exception_var, | 1203 CatchEntryComp(const LocalVariable& exception_var, |
| 1123 const LocalVariable& stacktrace_var) | 1204 const LocalVariable& stacktrace_var) |
| 1124 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} | 1205 : exception_var_(exception_var), stacktrace_var_(stacktrace_var) {} |
| 1125 | 1206 |
| 1126 const LocalVariable& exception_var() const { return exception_var_; } | 1207 const LocalVariable& exception_var() const { return exception_var_; } |
| 1127 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } | 1208 const LocalVariable& stacktrace_var() const { return stacktrace_var_; } |
| 1128 | 1209 |
| 1129 DECLARE_COMPUTATION(CatchEntry) | 1210 DECLARE_COMPUTATION(CatchEntry) |
| 1130 | 1211 |
| 1212 virtual void PrintOperandsTo(BufferFormatter* f); | |
| 1213 | |
| 1131 private: | 1214 private: |
| 1132 const LocalVariable& exception_var_; | 1215 const LocalVariable& exception_var_; |
| 1133 const LocalVariable& stacktrace_var_; | 1216 const LocalVariable& stacktrace_var_; |
| 1134 | 1217 |
| 1135 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); | 1218 DISALLOW_COPY_AND_ASSIGN(CatchEntryComp); |
| 1136 }; | 1219 }; |
| 1137 | 1220 |
| 1138 | 1221 |
| 1139 #undef DECLARE_COMPUTATION | 1222 #undef DECLARE_COMPUTATION |
| 1140 | 1223 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1158 M(Do) \ | 1241 M(Do) \ |
| 1159 M(Bind) \ | 1242 M(Bind) \ |
| 1160 M(Return) \ | 1243 M(Return) \ |
| 1161 M(Throw) \ | 1244 M(Throw) \ |
| 1162 M(ReThrow) \ | 1245 M(ReThrow) \ |
| 1163 M(Branch) \ | 1246 M(Branch) \ |
| 1164 | 1247 |
| 1165 | 1248 |
| 1166 // Forward declarations for Instruction classes. | 1249 // Forward declarations for Instruction classes. |
| 1167 class BlockEntryInstr; | 1250 class BlockEntryInstr; |
| 1251 class FlowGraphBuilder; | |
| 1252 | |
| 1168 #define FORWARD_DECLARATION(type) class type##Instr; | 1253 #define FORWARD_DECLARATION(type) class type##Instr; |
| 1169 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) | 1254 FOR_EACH_INSTRUCTION(FORWARD_DECLARATION) |
| 1170 #undef FORWARD_DECLARATION | 1255 #undef FORWARD_DECLARATION |
| 1171 | 1256 |
| 1172 | 1257 |
| 1173 // Functions required in all concrete instruction classes. | 1258 // Functions required in all concrete instruction classes. |
| 1174 #define DECLARE_INSTRUCTION(type) \ | 1259 #define DECLARE_INSTRUCTION(type) \ |
| 1175 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ | 1260 virtual Instruction* Accept(FlowGraphVisitor* visitor); \ |
| 1176 virtual bool Is##type() const { return true; } \ | 1261 virtual bool Is##type() const { return true; } \ |
| 1177 virtual type##Instr* As##type() { return this; } \ | 1262 virtual type##Instr* As##type() { return this; } \ |
| 1178 virtual intptr_t InputCount() const; \ | 1263 virtual intptr_t InputCount() const; \ |
| 1264 virtual const char* DebugName() const { return #type; } \ | |
| 1265 virtual void PrintTo(BufferFormatter* f); | |
| 1179 | 1266 |
| 1180 | 1267 |
| 1181 class Instruction : public ZoneAllocated { | 1268 class Instruction : public ZoneAllocated { |
| 1182 public: | 1269 public: |
| 1183 Instruction() : cid_(-1), ic_data_(NULL) { | 1270 Instruction() : cid_(-1), ic_data_(NULL) { |
| 1184 Isolate* isolate = Isolate::Current(); | 1271 Isolate* isolate = Isolate::Current(); |
| 1185 cid_ = Computation::GetNextCid(isolate); | 1272 cid_ = Computation::GetNextCid(isolate); |
| 1186 ic_data_ = Computation::GetICDataForCid(cid_, isolate); | 1273 ic_data_ = Computation::GetICDataForCid(cid_, isolate); |
| 1187 } | 1274 } |
| 1188 | 1275 |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1217 // and analogously for the array 'postorder'. The depth first spanning | 1304 // and analogously for the array 'postorder'. The depth first spanning |
| 1218 // tree is recorded in the array 'parent', which maps preorder block | 1305 // tree is recorded in the array 'parent', which maps preorder block |
| 1219 // numbers to the preorder number of the block's spanning-tree parent. | 1306 // numbers to the preorder number of the block's spanning-tree parent. |
| 1220 // The array 'assigned_vars' maps preorder block numbers to the set of | 1307 // The array 'assigned_vars' maps preorder block numbers to the set of |
| 1221 // assigned frame-allocated local variables in the block. As a side | 1308 // assigned frame-allocated local variables in the block. As a side |
| 1222 // effect of this function, the set of basic block predecessors (e.g., | 1309 // effect of this function, the set of basic block predecessors (e.g., |
| 1223 // block entry instructions of predecessor blocks) and also the last | 1310 // block entry instructions of predecessor blocks) and also the last |
| 1224 // instruction in the block is recorded in each entry instruction. | 1311 // instruction in the block is recorded in each entry instruction. |
| 1225 virtual void DiscoverBlocks( | 1312 virtual void DiscoverBlocks( |
| 1226 BlockEntryInstr* current_block, | 1313 BlockEntryInstr* current_block, |
| 1227 GrowableArray<BlockEntryInstr*>* preorder, | 1314 FlowGraphBuilder* builder, |
| 1228 GrowableArray<BlockEntryInstr*>* postorder, | |
| 1229 GrowableArray<intptr_t>* parent, | 1315 GrowableArray<intptr_t>* parent, |
| 1230 GrowableArray<BitVector*>* assigned_vars, | 1316 GrowableArray<BitVector*>* assigned_vars, |
| 1231 intptr_t variable_count) { | 1317 intptr_t variable_count) { |
| 1232 // Never called for instructions except block entries and branches. | 1318 // Never called for instructions except block entries and branches. |
| 1233 UNREACHABLE(); | 1319 UNREACHABLE(); |
| 1234 } | 1320 } |
| 1235 | 1321 |
| 1236 // Mutate assigned_vars to add the local variable index for all | 1322 // Mutate assigned_vars to add the local variable index for all |
| 1237 // frame-allocated locals assigned to by the instruction. | 1323 // frame-allocated locals assigned to by the instruction. |
| 1238 virtual void RecordAssignedVars(BitVector* assigned_vars); | 1324 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 1239 | 1325 |
| 1326 // Printing support. | |
| 1327 virtual void PrintTo(BufferFormatter* f) = 0; | |
| 1328 | |
| 1240 #define INSTRUCTION_TYPE_CHECK(type) \ | 1329 #define INSTRUCTION_TYPE_CHECK(type) \ |
| 1241 virtual bool Is##type() const { return false; } \ | 1330 virtual bool Is##type() const { return false; } \ |
| 1242 virtual type##Instr* As##type() { return NULL; } | 1331 virtual type##Instr* As##type() { return NULL; } |
| 1243 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) | 1332 FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CHECK) |
| 1244 #undef INSTRUCTION_TYPE_CHECK | 1333 #undef INSTRUCTION_TYPE_CHECK |
| 1245 | 1334 |
| 1246 private: | 1335 private: |
| 1247 intptr_t cid_; | 1336 intptr_t cid_; |
| 1248 ICData* ic_data_; | 1337 ICData* ic_data_; |
| 1249 DISALLOW_COPY_AND_ASSIGN(Instruction); | 1338 DISALLOW_COPY_AND_ASSIGN(Instruction); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1262 virtual intptr_t PredecessorCount() const = 0; | 1351 virtual intptr_t PredecessorCount() const = 0; |
| 1263 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; | 1352 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const = 0; |
| 1264 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; | 1353 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; |
| 1265 | 1354 |
| 1266 intptr_t preorder_number() const { return preorder_number_; } | 1355 intptr_t preorder_number() const { return preorder_number_; } |
| 1267 void set_preorder_number(intptr_t number) { preorder_number_ = number; } | 1356 void set_preorder_number(intptr_t number) { preorder_number_ = number; } |
| 1268 | 1357 |
| 1269 intptr_t postorder_number() const { return postorder_number_; } | 1358 intptr_t postorder_number() const { return postorder_number_; } |
| 1270 void set_postorder_number(intptr_t number) { postorder_number_ = number; } | 1359 void set_postorder_number(intptr_t number) { postorder_number_ = number; } |
| 1271 | 1360 |
| 1361 intptr_t block_id() const { return block_id_; } | |
| 1362 void set_block_id(intptr_t number) { block_id_ = number; } | |
|
srdjan
2012/05/17 22:59:22
intptr_t value
Florian Schneider
2012/05/18 00:28:38
Done.
| |
| 1363 | |
| 1272 BlockEntryInstr* dominator() const { return dominator_; } | 1364 BlockEntryInstr* dominator() const { return dominator_; } |
| 1273 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } | 1365 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } |
| 1274 | 1366 |
| 1275 Instruction* last_instruction() const { return last_instruction_; } | 1367 Instruction* last_instruction() const { return last_instruction_; } |
| 1276 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } | 1368 void set_last_instruction(Instruction* instr) { last_instruction_ = instr; } |
| 1277 | 1369 |
| 1278 virtual void DiscoverBlocks( | 1370 virtual void DiscoverBlocks( |
| 1279 BlockEntryInstr* current_block, | 1371 BlockEntryInstr* current_block, |
| 1280 GrowableArray<BlockEntryInstr*>* preorder, | 1372 FlowGraphBuilder* builder, |
|
srdjan
2012/05/17 22:59:22
It seems that you can revert this change and pass
Florian Schneider
2012/05/18 00:28:38
Done.
| |
| 1281 GrowableArray<BlockEntryInstr*>* postorder, | |
| 1282 GrowableArray<intptr_t>* parent, | 1373 GrowableArray<intptr_t>* parent, |
| 1283 GrowableArray<BitVector*>* assigned_vars, | 1374 GrowableArray<BitVector*>* assigned_vars, |
| 1284 intptr_t variable_count); | 1375 intptr_t variable_count); |
| 1285 | 1376 |
| 1286 protected: | 1377 protected: |
| 1287 BlockEntryInstr() | 1378 BlockEntryInstr() |
| 1288 : preorder_number_(-1), | 1379 : preorder_number_(-1), |
| 1289 postorder_number_(-1), | 1380 postorder_number_(-1), |
| 1381 block_id_(-1), | |
| 1290 dominator_(NULL), | 1382 dominator_(NULL), |
| 1291 last_instruction_(NULL) { } | 1383 last_instruction_(NULL) { } |
| 1292 | 1384 |
| 1293 private: | 1385 private: |
| 1294 intptr_t preorder_number_; | 1386 intptr_t preorder_number_; |
| 1295 intptr_t postorder_number_; | 1387 intptr_t postorder_number_; |
| 1388 intptr_t block_id_; | |
| 1296 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. | 1389 BlockEntryInstr* dominator_; // Immediate dominator, NULL for graph entry. |
| 1297 Instruction* last_instruction_; | 1390 Instruction* last_instruction_; |
| 1298 | 1391 |
| 1299 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); | 1392 DISALLOW_COPY_AND_ASSIGN(BlockEntryInstr); |
| 1300 }; | 1393 }; |
| 1301 | 1394 |
| 1302 | 1395 |
| 1303 class GraphEntryInstr : public BlockEntryInstr { | 1396 class GraphEntryInstr : public BlockEntryInstr { |
| 1304 public: | 1397 public: |
| 1305 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) | 1398 explicit GraphEntryInstr(TargetEntryInstr* normal_entry) |
| 1306 : BlockEntryInstr(), normal_entry_(normal_entry), catch_entries_() { } | 1399 : BlockEntryInstr(), normal_entry_(normal_entry), catch_entries_() { } |
| 1307 | 1400 |
| 1308 DECLARE_INSTRUCTION(GraphEntry) | 1401 DECLARE_INSTRUCTION(GraphEntry) |
| 1309 | 1402 |
| 1310 virtual intptr_t PredecessorCount() const { return 0; } | 1403 virtual intptr_t PredecessorCount() const { return 0; } |
| 1311 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { | 1404 virtual BlockEntryInstr* PredecessorAt(intptr_t index) const { |
| 1312 UNREACHABLE(); | 1405 UNREACHABLE(); |
| 1313 return NULL; | 1406 return NULL; |
| 1314 } | 1407 } |
| 1315 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } | 1408 virtual void AddPredecessor(BlockEntryInstr* predecessor) { UNREACHABLE(); } |
| 1316 | 1409 |
| 1317 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 1410 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 1318 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1411 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1319 | 1412 |
| 1320 virtual void DiscoverBlocks( | 1413 virtual void DiscoverBlocks( |
| 1321 BlockEntryInstr* current_block, | 1414 BlockEntryInstr* current_block, |
| 1322 GrowableArray<BlockEntryInstr*>* preorder, | 1415 FlowGraphBuilder* builder, |
| 1323 GrowableArray<BlockEntryInstr*>* postorder, | |
| 1324 GrowableArray<intptr_t>* parent, | 1416 GrowableArray<intptr_t>* parent, |
| 1325 GrowableArray<BitVector*>* assigned_vars, | 1417 GrowableArray<BitVector*>* assigned_vars, |
| 1326 intptr_t variable_count); | 1418 intptr_t variable_count); |
| 1327 | 1419 |
| 1328 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } | 1420 void AddCatchEntry(TargetEntryInstr* entry) { catch_entries_.Add(entry); } |
| 1329 | 1421 |
| 1330 private: | 1422 private: |
| 1331 TargetEntryInstr* normal_entry_; | 1423 TargetEntryInstr* normal_entry_; |
| 1332 GrowableArray<TargetEntryInstr*> catch_entries_; | 1424 GrowableArray<TargetEntryInstr*> catch_entries_; |
| 1333 | 1425 |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1607 TargetEntryInstr* false_successor() const { return false_successor_; } | 1699 TargetEntryInstr* false_successor() const { return false_successor_; } |
| 1608 | 1700 |
| 1609 TargetEntryInstr** true_successor_address() { return &true_successor_; } | 1701 TargetEntryInstr** true_successor_address() { return &true_successor_; } |
| 1610 TargetEntryInstr** false_successor_address() { return &false_successor_; } | 1702 TargetEntryInstr** false_successor_address() { return &false_successor_; } |
| 1611 | 1703 |
| 1612 virtual Instruction* StraightLineSuccessor() const { return NULL; } | 1704 virtual Instruction* StraightLineSuccessor() const { return NULL; } |
| 1613 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } | 1705 virtual void SetSuccessor(Instruction* instr) { UNREACHABLE(); } |
| 1614 | 1706 |
| 1615 virtual void DiscoverBlocks( | 1707 virtual void DiscoverBlocks( |
| 1616 BlockEntryInstr* current_block, | 1708 BlockEntryInstr* current_block, |
| 1617 GrowableArray<BlockEntryInstr*>* preorder, | 1709 FlowGraphBuilder* builder, |
| 1618 GrowableArray<BlockEntryInstr*>* postorder, | |
| 1619 GrowableArray<intptr_t>* parent, | 1710 GrowableArray<intptr_t>* parent, |
| 1620 GrowableArray<BitVector*>* assigned_vars, | 1711 GrowableArray<BitVector*>* assigned_vars, |
| 1621 intptr_t variable_count); | 1712 intptr_t variable_count); |
| 1622 | 1713 |
| 1623 private: | 1714 private: |
| 1624 Value* value_; | 1715 Value* value_; |
| 1625 TargetEntryInstr* true_successor_; | 1716 TargetEntryInstr* true_successor_; |
| 1626 TargetEntryInstr* false_successor_; | 1717 TargetEntryInstr* false_successor_; |
| 1627 | 1718 |
| 1628 DISALLOW_COPY_AND_ASSIGN(BranchInstr); | 1719 DISALLOW_COPY_AND_ASSIGN(BranchInstr); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1668 const GrowableArray<BlockEntryInstr*>& block_order_; | 1759 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1669 | 1760 |
| 1670 private: | 1761 private: |
| 1671 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1762 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1672 }; | 1763 }; |
| 1673 | 1764 |
| 1674 | 1765 |
| 1675 } // namespace dart | 1766 } // namespace dart |
| 1676 | 1767 |
| 1677 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1768 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |