Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(529)

Side by Side Diff: runtime/vm/intermediate_language.h

Issue 10541135: Some cleanups, started implementing checked instance calls, better equality operation. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 18 matching lines...) Expand all
29 // M is a two argument macro. It is applied to each concrete instruction's 29 // M is a two argument macro. It is applied to each concrete instruction's
30 // (including the values) typename and classname. 30 // (including the values) typename and classname.
31 #define FOR_EACH_COMPUTATION(M) \ 31 #define FOR_EACH_COMPUTATION(M) \
32 FOR_EACH_VALUE(M) \ 32 FOR_EACH_VALUE(M) \
33 M(AssertAssignable, AssertAssignableComp) \ 33 M(AssertAssignable, AssertAssignableComp) \
34 M(AssertBoolean, AssertBooleanComp) \ 34 M(AssertBoolean, AssertBooleanComp) \
35 M(CurrentContext, CurrentContextComp) \ 35 M(CurrentContext, CurrentContextComp) \
36 M(StoreContext, StoreContextComp) \ 36 M(StoreContext, StoreContextComp) \
37 M(ClosureCall, ClosureCallComp) \ 37 M(ClosureCall, ClosureCallComp) \
38 M(InstanceCall, InstanceCallComp) \ 38 M(InstanceCall, InstanceCallComp) \
39 M(CheckedInstanceCall, CheckedInstanceCallComp) \
39 M(StaticCall, StaticCallComp) \ 40 M(StaticCall, StaticCallComp) \
40 M(LoadLocal, LoadLocalComp) \ 41 M(LoadLocal, LoadLocalComp) \
41 M(StoreLocal, StoreLocalComp) \ 42 M(StoreLocal, StoreLocalComp) \
42 M(StrictCompare, StrictCompareComp) \ 43 M(StrictCompare, StrictCompareComp) \
43 M(EqualityCompare, EqualityCompareComp) \ 44 M(EqualityCompare, EqualityCompareComp) \
44 M(RelationalOp, RelationalOpComp) \ 45 M(RelationalOp, RelationalOpComp) \
45 M(NativeCall, NativeCallComp) \ 46 M(NativeCall, NativeCallComp) \
46 M(LoadIndexed, LoadIndexedComp) \ 47 M(LoadIndexed, LoadIndexedComp) \
47 M(StoreIndexed, StoreIndexedComp) \ 48 M(StoreIndexed, StoreIndexedComp) \
48 M(InstanceSetter, InstanceSetterComp) \ 49 M(InstanceSetter, InstanceSetterComp) \
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // Create a location summary for this computation. 139 // Create a location summary for this computation.
139 // TODO(fschneider): Temporarily returns NULL for instructions 140 // TODO(fschneider): Temporarily returns NULL for instructions
140 // that are not yet converted to the location based code generation. 141 // that are not yet converted to the location based code generation.
141 virtual LocationSummary* MakeLocationSummary() const = 0; 142 virtual LocationSummary* MakeLocationSummary() const = 0;
142 143
143 // TODO(fschneider): Make EmitNativeCode and locs const. 144 // TODO(fschneider): Make EmitNativeCode and locs const.
144 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0; 145 virtual void EmitNativeCode(FlowGraphCompiler* compiler) = 0;
145 146
146 static LocationSummary* MakeCallSummary(); 147 static LocationSummary* MakeCallSummary();
147 148
149 void ReplaceWith(Computation* other);
150
148 // Declare an enum value used to define type-test predicates. 151 // Declare an enum value used to define type-test predicates.
149 enum ComputationType { 152 enum ComputationType {
150 #define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName, 153 #define DECLARE_COMPUTATION_TYPE(ShortName, ClassName) k##ShortName,
151 154
152 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE) 155 FOR_EACH_COMPUTATION(DECLARE_COMPUTATION_TYPE)
153 156
154 #undef DECLARE_COMPUTATION_TYPE 157 #undef DECLARE_COMPUTATION_TYPE
155 }; 158 };
156 159
157 virtual ComputationType computation_type() const = 0; 160 virtual ComputationType computation_type() const = 0;
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 const intptr_t try_index_; 493 const intptr_t try_index_;
491 const String& function_name_; 494 const String& function_name_;
492 ZoneGrowableArray<Value*>* const arguments_; 495 ZoneGrowableArray<Value*>* const arguments_;
493 const Array& argument_names_; 496 const Array& argument_names_;
494 const intptr_t checked_argument_count_; 497 const intptr_t checked_argument_count_;
495 498
496 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp); 499 DISALLOW_COPY_AND_ASSIGN(InstanceCallComp);
497 }; 500 };
498 501
499 502
503 class CheckedInstanceCallComp : public Computation {
Vyacheslav Egorov (Google) 2012/06/13 09:02:27 Should not this be PolymorphicInstanceCall or some
srdjan 2012/06/13 18:34:24 Renaming to PolymorphicInstanceCall.
504 public:
505 CheckedInstanceCallComp(InstanceCallComp* comp,
506 const ZoneGrowableArray<intptr_t>& class_ids,
507 const ZoneGrowableArray<Function*>& targets)
508 : instance_call_(comp),
509 class_ids_(class_ids),
510 targets_(targets) {
511 ASSERT(instance_call_ != NULL);
512 }
513
514 InstanceCallComp* instance_call() const { return instance_call_; }
515 const ZoneGrowableArray<intptr_t>& class_ids() const { return class_ids_; }
516 const ZoneGrowableArray<Function*>& targets() const { return targets_; }
517
518 virtual intptr_t InputCount() const { return instance_call()->InputCount(); }
519 virtual Value* InputAt(intptr_t i) const {
520 return instance_call()->ArgumentAt(i);
521 }
522
523 virtual void PrintOperandsTo(BufferFormatter* f) const {
524 instance_call()->PrintOperandsTo(f);
525 }
526
527 DECLARE_COMPUTATION(CheckedInstanceCall)
528
529 private:
530 InstanceCallComp* instance_call_;
531 const ZoneGrowableArray<intptr_t>& class_ids_;
532 const ZoneGrowableArray<Function*>& targets_;
533
534 DISALLOW_COPY_AND_ASSIGN(CheckedInstanceCallComp);
535 };
536
537
500 class StrictCompareComp : public TemplateComputation<2> { 538 class StrictCompareComp : public TemplateComputation<2> {
501 public: 539 public:
502 StrictCompareComp(Token::Kind kind, Value* left, Value* right) 540 StrictCompareComp(Token::Kind kind, Value* left, Value* right)
503 : kind_(kind) { 541 : kind_(kind) {
504 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT)); 542 ASSERT((kind_ == Token::kEQ_STRICT) || (kind_ == Token::kNE_STRICT));
505 inputs_[0] = left; 543 inputs_[0] = left;
506 inputs_[1] = right; 544 inputs_[1] = right;
507 } 545 }
508 546
509 DECLARE_COMPUTATION(StrictCompare) 547 DECLARE_COMPUTATION(StrictCompare)
(...skipping 11 matching lines...) Expand all
521 }; 559 };
522 560
523 561
524 class EqualityCompareComp : public TemplateComputation<2> { 562 class EqualityCompareComp : public TemplateComputation<2> {
525 public: 563 public:
526 EqualityCompareComp(intptr_t token_index, 564 EqualityCompareComp(intptr_t token_index,
527 intptr_t try_index, 565 intptr_t try_index,
528 Value* left, 566 Value* left,
529 Value* right) 567 Value* right)
530 : token_index_(token_index), 568 : token_index_(token_index),
531 try_index_(try_index) { 569 try_index_(try_index),
570 operands_class_id_(kObject) {
532 ASSERT(left != NULL); 571 ASSERT(left != NULL);
533 ASSERT(right != NULL); 572 ASSERT(right != NULL);
534 inputs_[0] = left; 573 inputs_[0] = left;
535 inputs_[1] = right; 574 inputs_[1] = right;
536 } 575 }
537 576
538 DECLARE_COMPUTATION(EqualityCompare) 577 DECLARE_COMPUTATION(EqualityCompare)
539 578
540 intptr_t token_index() const { return token_index_; } 579 intptr_t token_index() const { return token_index_; }
541 intptr_t try_index() const { return try_index_; } 580 intptr_t try_index() const { return try_index_; }
542 Value* left() const { return inputs_[0]; } 581 Value* left() const { return inputs_[0]; }
543 Value* right() const { return inputs_[1]; } 582 Value* right() const { return inputs_[1]; }
583 void set_operands_class_id(intptr_t value) {
584 operands_class_id_ = value;
585 }
586 intptr_t operands_class_id() const { return operands_class_id_; }
544 587
545 virtual void PrintOperandsTo(BufferFormatter* f) const; 588 virtual void PrintOperandsTo(BufferFormatter* f) const;
546 589
547 private: 590 private:
548 const intptr_t token_index_; 591 const intptr_t token_index_;
549 const intptr_t try_index_; 592 const intptr_t try_index_;
593 intptr_t operands_class_id_; // class id of both operands.
550 594
551 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); 595 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp);
552 }; 596 };
553 597
554 598
555 class RelationalOpComp : public TemplateComputation<2> { 599 class RelationalOpComp : public TemplateComputation<2> {
556 public: 600 public:
557 RelationalOpComp(intptr_t token_index, 601 RelationalOpComp(intptr_t token_index,
558 intptr_t try_index, 602 intptr_t try_index,
559 Token::Kind kind, 603 Token::Kind kind,
(...skipping 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 const GrowableArray<BlockEntryInstr*>& block_order_; 2228 const GrowableArray<BlockEntryInstr*>& block_order_;
2185 2229
2186 private: 2230 private:
2187 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2231 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2188 }; 2232 };
2189 2233
2190 2234
2191 } // namespace dart 2235 } // namespace dart
2192 2236
2193 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2237 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698