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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 | 72 |
| 73 // Forward declarations. | 73 // Forward declarations. |
| 74 class BufferFormatter; | 74 class BufferFormatter; |
| 75 class Value; | 75 class Value; |
| 76 | 76 |
| 77 | 77 |
| 78 class Computation : public ZoneAllocated { | 78 class Computation : public ZoneAllocated { |
| 79 public: | 79 public: |
| 80 static const int kNoCid = -1; | 80 static const int kNoCid = -1; |
| 81 | 81 |
| 82 Computation() : cid_(-1), ic_data_(NULL) { | 82 Computation() : cid_(-1), ic_data_(NULL), locs_(NULL) { |
| 83 Isolate* isolate = Isolate::Current(); | 83 Isolate* isolate = Isolate::Current(); |
| 84 cid_ = GetNextCid(isolate); | 84 cid_ = GetNextCid(isolate); |
| 85 ic_data_ = GetICDataForCid(cid_, isolate); | 85 ic_data_ = GetICDataForCid(cid_, isolate); |
| 86 } | 86 } |
| 87 | 87 |
| 88 // Unique computation/instruction id, used for deoptimization. | 88 // Unique computation/instruction id, used for deoptimization. |
| 89 intptr_t cid() const { return cid_; } | 89 intptr_t cid() const { return cid_; } |
| 90 | 90 |
| 91 const ICData* ic_data() const { return ic_data_; } | 91 const ICData* ic_data() const { return ic_data_; } |
| 92 | 92 |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 105 | 105 |
| 106 virtual const char* DebugName() const = 0; | 106 virtual const char* DebugName() const = 0; |
| 107 | 107 |
| 108 // Printing support. These functions are sometimes overridden for custom | 108 // Printing support. These functions are sometimes overridden for custom |
| 109 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". | 109 // formatting. Otherwise, it prints in the format "opcode(op1, op2, op3)". |
| 110 virtual void PrintTo(BufferFormatter* f) const; | 110 virtual void PrintTo(BufferFormatter* f) const; |
| 111 virtual void PrintOperandsTo(BufferFormatter* f) const; | 111 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 112 | 112 |
| 113 // Returns structure describing location constraints required | 113 // Returns structure describing location constraints required |
| 114 // to emit native code for this computation. | 114 // to emit native code for this computation. |
| 115 virtual LocationSummary* locs() const { | 115 LocationSummary* locs() { |
| 116 // TODO(vegorov): This should be pure virtual method. | 116 // TODO(vegorov): This should be pure virtual method. |
|
Ivan Posva
2012/05/22 22:19:49
This comment is out of date, as it should just be
Florian Schneider
2012/05/22 23:01:06
Done.
| |
| 117 // However we are temporary using NULL for instructions that | 117 // However we are temporary using NULL for instructions that |
| 118 // were not converted to the location based code generation yet. | 118 // were not converted to the location based code generation yet. |
| 119 if (locs_ == NULL) locs_ = MakeLocationSummary(); | |
| 120 return locs_; | |
| 121 } | |
| 122 | |
| 123 // Create a location summary for this computation. | |
| 124 // TODO(fschneider): Temporarily returns NULL for instructions | |
| 125 // that are not yet converted to the location based code generation. | |
| 126 virtual LocationSummary* MakeLocationSummary() const { | |
|
Ivan Posva
2012/05/22 22:19:49
This one here and the one below should be pure vir
Florian Schneider
2012/05/22 23:01:06
Done.
| |
| 119 return NULL; | 127 return NULL; |
| 120 } | 128 } |
| 121 | 129 |
| 122 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { | 130 virtual void EmitNativeCode(FlowGraphCompiler* compiler) { |
| 123 UNIMPLEMENTED(); | 131 UNIMPLEMENTED(); |
| 124 } | 132 } |
| 125 | 133 |
| 126 private: | 134 private: |
| 127 friend class Instruction; | 135 friend class Instruction; |
| 128 static intptr_t GetNextCid(Isolate* isolate) { | 136 static intptr_t GetNextCid(Isolate* isolate) { |
| 129 intptr_t tmp = isolate->computation_id(); | 137 intptr_t tmp = isolate->computation_id(); |
| 130 isolate->set_computation_id(tmp + 1); | 138 isolate->set_computation_id(tmp + 1); |
| 131 return tmp; | 139 return tmp; |
| 132 } | 140 } |
| 133 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { | 141 static ICData* GetICDataForCid(intptr_t cid, Isolate* isolate) { |
| 134 if (isolate->ic_data_array() == Array::null()) { | 142 if (isolate->ic_data_array() == Array::null()) { |
| 135 return NULL; | 143 return NULL; |
| 136 } else { | 144 } else { |
| 137 const Array& array_handle = Array::Handle(isolate->ic_data_array()); | 145 const Array& array_handle = Array::Handle(isolate->ic_data_array()); |
| 138 ICData& ic_data_handle = ICData::ZoneHandle(); | 146 ICData& ic_data_handle = ICData::ZoneHandle(); |
| 139 if (cid < array_handle.Length()) { | 147 if (cid < array_handle.Length()) { |
| 140 ic_data_handle ^= array_handle.At(cid); | 148 ic_data_handle ^= array_handle.At(cid); |
| 141 } | 149 } |
| 142 return &ic_data_handle; | 150 return &ic_data_handle; |
| 143 } | 151 } |
| 144 } | 152 } |
| 145 | 153 |
| 146 intptr_t cid_; | 154 intptr_t cid_; |
| 147 ICData* ic_data_; | 155 ICData* ic_data_; |
| 156 LocationSummary* locs_; | |
| 148 | 157 |
| 149 DISALLOW_COPY_AND_ASSIGN(Computation); | 158 DISALLOW_COPY_AND_ASSIGN(Computation); |
| 150 }; | 159 }; |
| 151 | 160 |
| 152 | 161 |
| 153 // An embedded container with N elements of type T. Used (with partial | 162 // An embedded container with N elements of type T. Used (with partial |
| 154 // specialization for N=0) because embedded arrays cannot have size 0. | 163 // specialization for N=0) because embedded arrays cannot have size 0. |
| 155 template<typename T, intptr_t N> | 164 template<typename T, intptr_t N> |
| 156 class EmbeddedArray { | 165 class EmbeddedArray { |
| 157 public: | 166 public: |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 234 virtual const char* DebugName() const { return #ShortName; } \ | 243 virtual const char* DebugName() const { return #ShortName; } \ |
| 235 virtual RawAbstractType* StaticType() const; | 244 virtual RawAbstractType* StaticType() const; |
| 236 | 245 |
| 237 // Functions defined in all concrete value classes. | 246 // Functions defined in all concrete value classes. |
| 238 #define DECLARE_VALUE(ShortName) \ | 247 #define DECLARE_VALUE(ShortName) \ |
| 239 DECLARE_COMPUTATION(ShortName) \ | 248 DECLARE_COMPUTATION(ShortName) \ |
| 240 virtual ShortName##Val* As##ShortName() { return this; } \ | 249 virtual ShortName##Val* As##ShortName() { return this; } \ |
| 241 virtual void PrintTo(BufferFormatter* f) const; | 250 virtual void PrintTo(BufferFormatter* f) const; |
| 242 | 251 |
| 243 | 252 |
| 253 // TODO(fschneider): Remove duplicate macro definitions once all instruction | |
| 254 // have a LocationSummary. | |
| 255 #define DECLARE_COMPUTATION_WITH_LOCATION(ShortName) \ | |
| 256 DECLARE_COMPUTATION(ShortName) \ | |
| 257 virtual LocationSummary* MakeLocationSummary() const; \ | |
|
Ivan Posva
2012/05/22 22:19:49
Then these two can just move into the general macr
| |
| 258 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 259 | |
| 260 // Functions defined in all concrete value classes. | |
| 261 #define DECLARE_VALUE_WITH_LOCATION(ShortName) \ | |
| 262 DECLARE_COMPUTATION_WITH_LOCATION(ShortName) \ | |
| 263 virtual ShortName##Val* As##ShortName() { return this; } \ | |
| 264 virtual void PrintTo(BufferFormatter* f) const; | |
| 265 | |
| 266 | |
| 244 // Definitions and uses are mutually recursive. | 267 // Definitions and uses are mutually recursive. |
| 245 class Definition; | 268 class Definition; |
| 246 | 269 |
| 247 class UseVal : public Value { | 270 class UseVal : public Value { |
| 248 public: | 271 public: |
| 249 explicit UseVal(Definition* definition) : definition_(definition) { } | 272 explicit UseVal(Definition* definition) : definition_(definition) { } |
| 250 | 273 |
| 251 DECLARE_VALUE(Use) | 274 DECLARE_VALUE(Use) |
| 252 | 275 |
| 253 Definition* definition() const { return definition_; } | 276 Definition* definition() const { return definition_; } |
| 254 | 277 |
| 255 private: | 278 private: |
| 256 Definition* const definition_; | 279 Definition* const definition_; |
| 257 | 280 |
| 258 DISALLOW_COPY_AND_ASSIGN(UseVal); | 281 DISALLOW_COPY_AND_ASSIGN(UseVal); |
| 259 }; | 282 }; |
| 260 | 283 |
| 261 | 284 |
| 262 class ConstantVal: public Value { | 285 class ConstantVal: public Value { |
| 263 public: | 286 public: |
| 264 explicit ConstantVal(const Object& value) | 287 explicit ConstantVal(const Object& value) |
| 265 : value_(value), | 288 : value_(value) { |
| 266 location_summary_(MakeLocationSummary()) { | |
| 267 ASSERT(value.IsZoneHandle()); | 289 ASSERT(value.IsZoneHandle()); |
| 268 } | 290 } |
| 269 | 291 |
| 270 DECLARE_VALUE(Constant) | 292 DECLARE_VALUE_WITH_LOCATION(Constant) |
| 271 | 293 |
| 272 const Object& value() const { return value_; } | 294 const Object& value() const { return value_; } |
| 273 | 295 |
| 274 virtual LocationSummary* locs() const { | |
| 275 return location_summary_; | |
| 276 } | |
| 277 | |
| 278 // Platform specific summary factory for this instruction. | |
| 279 LocationSummary* MakeLocationSummary(); | |
| 280 | |
| 281 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 282 | |
| 283 private: | 296 private: |
| 284 const Object& value_; | 297 const Object& value_; |
| 285 LocationSummary* location_summary_; | |
| 286 | 298 |
| 287 DISALLOW_COPY_AND_ASSIGN(ConstantVal); | 299 DISALLOW_COPY_AND_ASSIGN(ConstantVal); |
| 288 }; | 300 }; |
| 289 | 301 |
| 290 #undef DECLARE_VALUE | 302 #undef DECLARE_VALUE |
| 291 | 303 |
| 292 | 304 |
| 293 class AssertAssignableComp : public Computation { | 305 class AssertAssignableComp : public Computation { |
| 294 public: | 306 public: |
| 295 AssertAssignableComp(intptr_t token_index, | 307 AssertAssignableComp(intptr_t token_index, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 const intptr_t try_index_; | 379 const intptr_t try_index_; |
| 368 | 380 |
| 369 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); | 381 DISALLOW_COPY_AND_ASSIGN(AssertBooleanComp); |
| 370 }; | 382 }; |
| 371 | 383 |
| 372 | 384 |
| 373 // Denotes the current context, normally held in a register. This is | 385 // Denotes the current context, normally held in a register. This is |
| 374 // a computation, not a value, because it's mutable. | 386 // a computation, not a value, because it's mutable. |
| 375 class CurrentContextComp : public TemplateComputation<0> { | 387 class CurrentContextComp : public TemplateComputation<0> { |
| 376 public: | 388 public: |
| 377 CurrentContextComp() : location_summary_(MakeLocationSummary()) { } | 389 CurrentContextComp() { } |
| 378 | 390 |
| 379 DECLARE_COMPUTATION(CurrentContext) | 391 DECLARE_COMPUTATION_WITH_LOCATION(CurrentContext) |
| 380 | |
| 381 virtual LocationSummary* locs() const { | |
| 382 return location_summary_; | |
| 383 } | |
| 384 | |
| 385 static LocationSummary* MakeLocationSummary(); | |
| 386 | |
| 387 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 388 | 392 |
| 389 private: | 393 private: |
| 390 LocationSummary* location_summary_; | |
| 391 DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); | 394 DISALLOW_COPY_AND_ASSIGN(CurrentContextComp); |
| 392 }; | 395 }; |
| 393 | 396 |
| 394 | 397 |
| 395 class StoreContextComp : public TemplateComputation<1> { | 398 class StoreContextComp : public TemplateComputation<1> { |
| 396 public: | 399 public: |
| 397 explicit StoreContextComp(Value* value) | 400 explicit StoreContextComp(Value* value) { |
| 398 : location_summary_(MakeLocationSummary()) { | |
| 399 ASSERT(value != NULL); | 401 ASSERT(value != NULL); |
| 400 inputs_[0] = value; | 402 inputs_[0] = value; |
| 401 } | 403 } |
| 402 | 404 |
| 403 DECLARE_COMPUTATION(StoreContext); | 405 DECLARE_COMPUTATION_WITH_LOCATION(StoreContext); |
| 404 | |
| 405 virtual LocationSummary* locs() const { | |
| 406 return location_summary_; | |
| 407 } | |
| 408 | |
| 409 static LocationSummary* MakeLocationSummary(); | |
| 410 | |
| 411 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 412 | 406 |
| 413 Value* value() const { return inputs_[0]; } | 407 Value* value() const { return inputs_[0]; } |
| 414 | 408 |
| 415 private: | 409 private: |
| 416 LocationSummary* location_summary_; | |
| 417 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); | 410 DISALLOW_COPY_AND_ASSIGN(StoreContextComp); |
| 418 }; | 411 }; |
| 419 | 412 |
| 420 | 413 |
| 421 class ClosureCallComp : public Computation { | 414 class ClosureCallComp : public Computation { |
| 422 public: | 415 public: |
| 423 ClosureCallComp(ClosureCallNode* node, | 416 ClosureCallComp(ClosureCallNode* node, |
| 424 intptr_t try_index, | 417 intptr_t try_index, |
| 425 ZoneGrowableArray<Value*>* arguments) | 418 ZoneGrowableArray<Value*>* arguments) |
| 426 : ast_node_(*node), | 419 : ast_node_(*node), |
| 427 try_index_(try_index), | 420 try_index_(try_index), |
| 428 arguments_(arguments), | 421 arguments_(arguments) { } |
| 429 location_summary_(MakeLocationSummary()) { } | |
| 430 | 422 |
| 431 DECLARE_COMPUTATION(ClosureCall) | 423 DECLARE_COMPUTATION_WITH_LOCATION(ClosureCall) |
| 432 | 424 |
| 433 const Array& argument_names() const { return ast_node_.arguments()->names(); } | 425 const Array& argument_names() const { return ast_node_.arguments()->names(); } |
| 434 intptr_t token_index() const { return ast_node_.token_index(); } | 426 intptr_t token_index() const { return ast_node_.token_index(); } |
| 435 intptr_t try_index() const { return try_index_; } | 427 intptr_t try_index() const { return try_index_; } |
| 436 | 428 |
| 437 intptr_t ArgumentCount() const { return arguments_->length(); } | 429 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 438 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 430 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 439 | 431 |
| 440 virtual intptr_t InputCount() const; | 432 virtual intptr_t InputCount() const; |
| 441 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 433 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 442 | 434 |
| 443 virtual void PrintOperandsTo(BufferFormatter* f) const; | 435 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 444 | 436 |
| 445 virtual LocationSummary* locs() const { | |
| 446 return location_summary_; | |
| 447 } | |
| 448 | |
| 449 // Platform specific summary factory for this instruction. | |
| 450 LocationSummary* MakeLocationSummary(); | |
| 451 | |
| 452 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 453 | |
| 454 private: | 437 private: |
| 455 const ClosureCallNode& ast_node_; | 438 const ClosureCallNode& ast_node_; |
| 456 const intptr_t try_index_; | 439 const intptr_t try_index_; |
| 457 ZoneGrowableArray<Value*>* arguments_; | 440 ZoneGrowableArray<Value*>* arguments_; |
| 458 LocationSummary* location_summary_; | |
| 459 | 441 |
| 460 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); | 442 DISALLOW_COPY_AND_ASSIGN(ClosureCallComp); |
| 461 }; | 443 }; |
| 462 | 444 |
| 463 | 445 |
| 464 class InstanceCallComp : public Computation { | 446 class InstanceCallComp : public Computation { |
| 465 public: | 447 public: |
| 466 InstanceCallComp(intptr_t token_index, | 448 InstanceCallComp(intptr_t token_index, |
| 467 intptr_t try_index, | 449 intptr_t try_index, |
| 468 const String& function_name, | 450 const String& function_name, |
| 469 ZoneGrowableArray<Value*>* arguments, | 451 ZoneGrowableArray<Value*>* arguments, |
| 470 const Array& argument_names, | 452 const Array& argument_names, |
| 471 intptr_t checked_argument_count) | 453 intptr_t checked_argument_count) |
| 472 : token_index_(token_index), | 454 : token_index_(token_index), |
| 473 try_index_(try_index), | 455 try_index_(try_index), |
| 474 function_name_(function_name), | 456 function_name_(function_name), |
| 475 arguments_(arguments), | 457 arguments_(arguments), |
| 476 argument_names_(argument_names), | 458 argument_names_(argument_names), |
| 477 checked_argument_count_(checked_argument_count), | 459 checked_argument_count_(checked_argument_count) { |
| 478 location_summary_(MakeLocationSummary()) { | |
| 479 ASSERT(function_name.IsZoneHandle()); | 460 ASSERT(function_name.IsZoneHandle()); |
| 480 ASSERT(!arguments->is_empty()); | 461 ASSERT(!arguments->is_empty()); |
| 481 ASSERT(argument_names.IsZoneHandle()); | 462 ASSERT(argument_names.IsZoneHandle()); |
| 482 } | 463 } |
| 483 | 464 |
| 484 DECLARE_COMPUTATION(InstanceCall) | 465 DECLARE_COMPUTATION_WITH_LOCATION(InstanceCall) |
| 485 | 466 |
| 486 intptr_t token_index() const { return token_index_; } | 467 intptr_t token_index() const { return token_index_; } |
| 487 intptr_t try_index() const { return try_index_; } | 468 intptr_t try_index() const { return try_index_; } |
| 488 const String& function_name() const { return function_name_; } | 469 const String& function_name() const { return function_name_; } |
| 489 intptr_t ArgumentCount() const { return arguments_->length(); } | 470 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 490 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 471 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 491 const Array& argument_names() const { return argument_names_; } | 472 const Array& argument_names() const { return argument_names_; } |
| 492 intptr_t checked_argument_count() const { return checked_argument_count_; } | 473 intptr_t checked_argument_count() const { return checked_argument_count_; } |
| 493 | 474 |
| 494 virtual intptr_t InputCount() const; | 475 virtual intptr_t InputCount() const; |
| 495 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 476 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 496 | 477 |
| 497 virtual void PrintOperandsTo(BufferFormatter* f) const; | 478 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 498 | 479 |
| 499 virtual LocationSummary* locs() const { | |
| 500 return location_summary_; | |
| 501 } | |
| 502 | |
| 503 // Platform specific summary factory for this instruction. | |
| 504 LocationSummary* MakeLocationSummary(); | |
| 505 | |
| 506 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 507 | |
| 508 private: | 480 private: |
| 509 const intptr_t token_index_; | 481 const intptr_t token_index_; |
| 510 const intptr_t try_index_; | 482 const intptr_t try_index_; |
| 511 const String& function_name_; | 483 const String& function_name_; |
| 512 ZoneGrowableArray<Value*>* const arguments_; | 484 ZoneGrowableArray<Value*>* const arguments_; |
| 513 const Array& argument_names_; | 485 const Array& argument_names_; |
| 514 const intptr_t checked_argument_count_; | 486 const intptr_t checked_argument_count_; |
| 515 LocationSummary* location_summary_; | |
| 516 | 487 |
| 517 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); | 488 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); |
| 518 }; | 489 }; |
| 519 | 490 |
| 520 | 491 |
| 521 class StrictCompareComp : public TemplateComputation<2> { | 492 class StrictCompareComp : public TemplateComputation<2> { |
| 522 public: | 493 public: |
| 523 StrictCompareComp(Token::Kind kind, Value* left, Value* right) | 494 StrictCompareComp(Token::Kind kind, Value* left, Value* right) |
| 524 : kind_(kind) { | 495 : kind_(kind) { |
| 525 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); | 496 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); |
| 526 inputs_[0] = left; | 497 inputs_[0] = left; |
| 527 inputs_[1] = right; | 498 inputs_[1] = right; |
| 528 location_summary_ = MakeLocationSummary(); | |
| 529 } | 499 } |
| 530 | 500 |
| 531 DECLARE_COMPUTATION(StrictCompare) | 501 DECLARE_COMPUTATION_WITH_LOCATION(StrictCompare) |
| 532 | 502 |
| 533 Token::Kind kind() const { return kind_; } | 503 Token::Kind kind() const { return kind_; } |
| 534 Value* left() const { return inputs_[0]; } | 504 Value* left() const { return inputs_[0]; } |
| 535 Value* right() const { return inputs_[1]; } | 505 Value* right() const { return inputs_[1]; } |
| 536 | 506 |
| 537 virtual void PrintOperandsTo(BufferFormatter* f) const; | 507 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 538 | 508 |
| 539 virtual LocationSummary* locs() const { | |
| 540 return location_summary_; | |
| 541 } | |
| 542 | |
| 543 // Platform specific summary factory for this instruction. | |
| 544 LocationSummary* MakeLocationSummary(); | |
| 545 | |
| 546 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 547 | |
| 548 private: | 509 private: |
| 549 const Token::Kind kind_; | 510 const Token::Kind kind_; |
| 550 | 511 |
| 551 LocationSummary* location_summary_; | |
| 552 | |
| 553 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); | 512 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); |
| 554 }; | 513 }; |
| 555 | 514 |
| 556 | 515 |
| 557 class EqualityCompareComp : public TemplateComputation<2> { | 516 class EqualityCompareComp : public TemplateComputation<2> { |
| 558 public: | 517 public: |
| 559 EqualityCompareComp(intptr_t token_index, | 518 EqualityCompareComp(intptr_t token_index, |
| 560 intptr_t try_index, | 519 intptr_t try_index, |
| 561 Value* left, | 520 Value* left, |
| 562 Value* right) | 521 Value* right) |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 589 public: | 548 public: |
| 590 StaticCallComp(intptr_t token_index, | 549 StaticCallComp(intptr_t token_index, |
| 591 intptr_t try_index, | 550 intptr_t try_index, |
| 592 const Function& function, | 551 const Function& function, |
| 593 const Array& argument_names, | 552 const Array& argument_names, |
| 594 ZoneGrowableArray<Value*>* arguments) | 553 ZoneGrowableArray<Value*>* arguments) |
| 595 : token_index_(token_index), | 554 : token_index_(token_index), |
| 596 try_index_(try_index), | 555 try_index_(try_index), |
| 597 function_(function), | 556 function_(function), |
| 598 argument_names_(argument_names), | 557 argument_names_(argument_names), |
| 599 arguments_(arguments), | 558 arguments_(arguments) { |
| 600 location_summary_(MakeLocationSummary()) { | |
| 601 ASSERT(function.IsZoneHandle()); | 559 ASSERT(function.IsZoneHandle()); |
| 602 ASSERT(argument_names.IsZoneHandle()); | 560 ASSERT(argument_names.IsZoneHandle()); |
| 603 } | 561 } |
| 604 | 562 |
| 605 DECLARE_COMPUTATION(StaticCall) | 563 DECLARE_COMPUTATION_WITH_LOCATION(StaticCall) |
| 606 | 564 |
| 607 // Accessors forwarded to the AST node. | 565 // Accessors forwarded to the AST node. |
| 608 const Function& function() const { return function_; } | 566 const Function& function() const { return function_; } |
| 609 const Array& argument_names() const { return argument_names_; } | 567 const Array& argument_names() const { return argument_names_; } |
| 610 intptr_t token_index() const { return token_index_; } | 568 intptr_t token_index() const { return token_index_; } |
| 611 intptr_t try_index() const { return try_index_; } | 569 intptr_t try_index() const { return try_index_; } |
| 612 | 570 |
| 613 intptr_t ArgumentCount() const { return arguments_->length(); } | 571 intptr_t ArgumentCount() const { return arguments_->length(); } |
| 614 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } | 572 Value* ArgumentAt(intptr_t index) const { return (*arguments_)[index]; } |
| 615 | 573 |
| 616 virtual intptr_t InputCount() const; | 574 virtual intptr_t InputCount() const; |
| 617 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } | 575 virtual Value* InputAt(intptr_t i) const { return ArgumentAt(i); } |
| 618 | 576 |
| 619 virtual void PrintOperandsTo(BufferFormatter* f) const; | 577 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 620 | 578 |
| 621 virtual LocationSummary* locs() const { | |
| 622 return location_summary_; | |
| 623 } | |
| 624 | |
| 625 // Platform specific summary factory for this instruction. | |
| 626 LocationSummary* MakeLocationSummary(); | |
| 627 | |
| 628 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 629 | |
| 630 private: | 579 private: |
| 631 const intptr_t token_index_; | 580 const intptr_t token_index_; |
| 632 const intptr_t try_index_; | 581 const intptr_t try_index_; |
| 633 const Function& function_; | 582 const Function& function_; |
| 634 const Array& argument_names_; | 583 const Array& argument_names_; |
| 635 ZoneGrowableArray<Value*>* arguments_; | 584 ZoneGrowableArray<Value*>* arguments_; |
| 636 LocationSummary* location_summary_; | |
| 637 | 585 |
| 638 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); | 586 DISALLOW_COPY_AND_ASSIGN(StaticCallComp); |
| 639 }; | 587 }; |
| 640 | 588 |
| 641 | 589 |
| 642 class LoadLocalComp : public TemplateComputation<0> { | 590 class LoadLocalComp : public TemplateComputation<0> { |
| 643 public: | 591 public: |
| 644 LoadLocalComp(const LocalVariable& local, intptr_t context_level) | 592 LoadLocalComp(const LocalVariable& local, intptr_t context_level) |
| 645 : local_(local), | 593 : local_(local), |
| 646 context_level_(context_level), | 594 context_level_(context_level) { } |
| 647 location_summary_(MakeLocationSummary()) { } | |
| 648 | 595 |
| 649 DECLARE_COMPUTATION(LoadLocal) | 596 DECLARE_COMPUTATION_WITH_LOCATION(LoadLocal) |
| 650 | 597 |
| 651 const LocalVariable& local() const { return local_; } | 598 const LocalVariable& local() const { return local_; } |
| 652 intptr_t context_level() const { return context_level_; } | 599 intptr_t context_level() const { return context_level_; } |
| 653 | 600 |
| 654 virtual void PrintOperandsTo(BufferFormatter* f) const; | 601 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 655 | 602 |
| 656 virtual LocationSummary* locs() const { | |
| 657 return location_summary_; | |
| 658 } | |
| 659 | |
| 660 // Platform specific summary factory for this instruction. | |
| 661 LocationSummary* MakeLocationSummary(); | |
| 662 | |
| 663 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 664 | |
| 665 private: | 603 private: |
| 666 const LocalVariable& local_; | 604 const LocalVariable& local_; |
| 667 const intptr_t context_level_; | 605 const intptr_t context_level_; |
| 668 LocationSummary* location_summary_; | |
| 669 | 606 |
| 670 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); | 607 DISALLOW_COPY_AND_ASSIGN(LoadLocalComp); |
| 671 }; | 608 }; |
| 672 | 609 |
| 673 | 610 |
| 674 class StoreLocalComp : public TemplateComputation<1> { | 611 class StoreLocalComp : public TemplateComputation<1> { |
| 675 public: | 612 public: |
| 676 StoreLocalComp(const LocalVariable& local, | 613 StoreLocalComp(const LocalVariable& local, |
| 677 Value* value, | 614 Value* value, |
| 678 intptr_t context_level) | 615 intptr_t context_level) |
| 679 : local_(local), | 616 : local_(local), |
| 680 context_level_(context_level), | 617 context_level_(context_level) { |
| 681 location_summary_(MakeLocationSummary()) { | |
| 682 inputs_[0] = value; | 618 inputs_[0] = value; |
| 683 } | 619 } |
| 684 | 620 |
| 685 DECLARE_COMPUTATION(StoreLocal) | 621 DECLARE_COMPUTATION_WITH_LOCATION(StoreLocal) |
| 686 | 622 |
| 687 const LocalVariable& local() const { return local_; } | 623 const LocalVariable& local() const { return local_; } |
| 688 Value* value() const { return inputs_[0]; } | 624 Value* value() const { return inputs_[0]; } |
| 689 intptr_t context_level() const { return context_level_; } | 625 intptr_t context_level() const { return context_level_; } |
| 690 | 626 |
| 691 virtual void RecordAssignedVars(BitVector* assigned_vars); | 627 virtual void RecordAssignedVars(BitVector* assigned_vars); |
| 692 | 628 |
| 693 virtual void PrintOperandsTo(BufferFormatter* f) const; | 629 virtual void PrintOperandsTo(BufferFormatter* f) const; |
| 694 | 630 |
| 695 virtual LocationSummary* locs() const { | |
| 696 return location_summary_; | |
| 697 } | |
| 698 | |
| 699 // Platform specific summary factory for this instruction. | |
| 700 LocationSummary* MakeLocationSummary(); | |
| 701 | |
| 702 virtual void EmitNativeCode(FlowGraphCompiler* compiler); | |
| 703 | |
| 704 private: | 631 private: |
| 705 const LocalVariable& local_; | 632 const LocalVariable& local_; |
| 706 const intptr_t context_level_; | 633 const intptr_t context_level_; |
| 707 LocationSummary* location_summary_; | |
| 708 | 634 |
| 709 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); | 635 DISALLOW_COPY_AND_ASSIGN(StoreLocalComp); |
| 710 }; | 636 }; |
| 711 | 637 |
| 712 | 638 |
| 713 class NativeCallComp : public TemplateComputation<0> { | 639 class NativeCallComp : public TemplateComputation<0> { |
| 714 public: | 640 public: |
| 715 NativeCallComp(NativeBodyNode* node, intptr_t try_index) | 641 NativeCallComp(NativeBodyNode* node, intptr_t try_index) |
| 716 : ast_node_(*node), try_index_(try_index) {} | 642 : ast_node_(*node), try_index_(try_index) {} |
| 717 | 643 |
| (...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1954 const GrowableArray<BlockEntryInstr*>& block_order_; | 1880 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 1955 | 1881 |
| 1956 private: | 1882 private: |
| 1957 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); | 1883 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); |
| 1958 }; | 1884 }; |
| 1959 | 1885 |
| 1960 | 1886 |
| 1961 } // namespace dart | 1887 } // namespace dart |
| 1962 | 1888 |
| 1963 #endif // VM_INTERMEDIATE_LANGUAGE_H_ | 1889 #endif // VM_INTERMEDIATE_LANGUAGE_H_ |
| OLD | NEW |