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

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

Issue 10536086: Add stack check in loops so that loops can be stopped. Optimize relational operations. (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 23 matching lines...) Expand all
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(StaticCall, StaticCallComp) \ 39 M(StaticCall, StaticCallComp) \
40 M(LoadLocal, LoadLocalComp) \ 40 M(LoadLocal, LoadLocalComp) \
41 M(StoreLocal, StoreLocalComp) \ 41 M(StoreLocal, StoreLocalComp) \
42 M(StrictCompare, StrictCompareComp) \ 42 M(StrictCompare, StrictCompareComp) \
43 M(EqualityCompare, EqualityCompareComp) \ 43 M(EqualityCompare, EqualityCompareComp) \
44 M(RelationalOp, RelationalOpComp) \
44 M(NativeCall, NativeCallComp) \ 45 M(NativeCall, NativeCallComp) \
45 M(LoadIndexed, LoadIndexedComp) \ 46 M(LoadIndexed, LoadIndexedComp) \
46 M(StoreIndexed, StoreIndexedComp) \ 47 M(StoreIndexed, StoreIndexedComp) \
47 M(InstanceSetter, InstanceSetterComp) \ 48 M(InstanceSetter, InstanceSetterComp) \
48 M(StaticSetter, StaticSetterComp) \ 49 M(StaticSetter, StaticSetterComp) \
49 M(LoadInstanceField, LoadInstanceFieldComp) \ 50 M(LoadInstanceField, LoadInstanceFieldComp) \
50 M(StoreInstanceField, StoreInstanceFieldComp) \ 51 M(StoreInstanceField, StoreInstanceFieldComp) \
51 M(LoadStaticField, LoadStaticFieldComp) \ 52 M(LoadStaticField, LoadStaticFieldComp) \
52 M(StoreStaticField, StoreStaticFieldComp) \ 53 M(StoreStaticField, StoreStaticFieldComp) \
53 M(BooleanNegate, BooleanNegateComp) \ 54 M(BooleanNegate, BooleanNegateComp) \
54 M(InstanceOf, InstanceOfComp) \ 55 M(InstanceOf, InstanceOfComp) \
55 M(CreateArray, CreateArrayComp) \ 56 M(CreateArray, CreateArrayComp) \
56 M(CreateClosure, CreateClosureComp) \ 57 M(CreateClosure, CreateClosureComp) \
57 M(AllocateObject, AllocateObjectComp) \ 58 M(AllocateObject, AllocateObjectComp) \
58 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \ 59 M(AllocateObjectWithBoundsCheck, AllocateObjectWithBoundsCheckComp) \
59 M(LoadVMField, LoadVMFieldComp) \ 60 M(LoadVMField, LoadVMFieldComp) \
60 M(StoreVMField, StoreVMFieldComp) \ 61 M(StoreVMField, StoreVMFieldComp) \
61 M(InstantiateTypeArguments, InstantiateTypeArgumentsComp) \ 62 M(InstantiateTypeArguments, InstantiateTypeArgumentsComp) \
62 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \ 63 M(ExtractConstructorTypeArguments, ExtractConstructorTypeArgumentsComp) \
63 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \ 64 M(ExtractConstructorInstantiator, ExtractConstructorInstantiatorComp) \
64 M(AllocateContext, AllocateContextComp) \ 65 M(AllocateContext, AllocateContextComp) \
65 M(ChainContext, ChainContextComp) \ 66 M(ChainContext, ChainContextComp) \
66 M(CloneContext, CloneContextComp) \ 67 M(CloneContext, CloneContextComp) \
67 M(CatchEntry, CatchEntryComp) \ 68 M(CatchEntry, CatchEntryComp) \
68 M(BinaryOp, BinaryOpComp) \ 69 M(BinaryOp, BinaryOpComp) \
69 M(UnarySmiOp, UnarySmiOpComp) \ 70 M(UnarySmiOp, UnarySmiOpComp) \
70 M(NumberNegate, NumberNegateComp) \ 71 M(NumberNegate, NumberNegateComp) \
72 M(CheckStackOverflow, CheckStackOverflowComp) \
71 73
72 74
73 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName; 75 #define FORWARD_DECLARATION(ShortName, ClassName) class ClassName;
74 FOR_EACH_COMPUTATION(FORWARD_DECLARATION) 76 FOR_EACH_COMPUTATION(FORWARD_DECLARATION)
75 #undef FORWARD_DECLARATION 77 #undef FORWARD_DECLARATION
76 78
77 // Forward declarations. 79 // Forward declarations.
78 class BufferFormatter; 80 class BufferFormatter;
79 class Instruction; 81 class Instruction;
80 class Value; 82 class Value;
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp); 520 DISALLOW_COPY_AND_ASSIGN(StrictCompareComp);
519 }; 521 };
520 522
521 523
522 class EqualityCompareComp : public TemplateComputation<2> { 524 class EqualityCompareComp : public TemplateComputation<2> {
523 public: 525 public:
524 EqualityCompareComp(intptr_t token_index, 526 EqualityCompareComp(intptr_t token_index,
525 intptr_t try_index, 527 intptr_t try_index,
526 Value* left, 528 Value* left,
527 Value* right) 529 Value* right)
528 : token_index_(token_index), 530 : token_index_(token_index),
529 try_index_(try_index) { 531 try_index_(try_index) {
530 ASSERT(left != NULL); 532 ASSERT(left != NULL);
531 ASSERT(right != NULL); 533 ASSERT(right != NULL);
532 inputs_[0] = left; 534 inputs_[0] = left;
533 inputs_[1] = right; 535 inputs_[1] = right;
534 } 536 }
535 537
536 DECLARE_COMPUTATION(EqualityCompare) 538 DECLARE_COMPUTATION(EqualityCompare)
537 539
538 intptr_t token_index() const { return token_index_; } 540 intptr_t token_index() const { return token_index_; }
539 intptr_t try_index() const { return try_index_; } 541 intptr_t try_index() const { return try_index_; }
540 Value* left() const { return inputs_[0]; } 542 Value* left() const { return inputs_[0]; }
541 Value* right() const { return inputs_[1]; } 543 Value* right() const { return inputs_[1]; }
542 544
543 virtual void PrintOperandsTo(BufferFormatter* f) const; 545 virtual void PrintOperandsTo(BufferFormatter* f) const;
544 546
545 private: 547 private:
546 const intptr_t token_index_; 548 const intptr_t token_index_;
547 const intptr_t try_index_; 549 const intptr_t try_index_;
548 550
549 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp); 551 DISALLOW_COPY_AND_ASSIGN(EqualityCompareComp);
550 }; 552 };
551 553
552 554
555 class RelationalOpComp : public TemplateComputation<2> {
556 public:
557 RelationalOpComp(intptr_t token_index,
558 intptr_t try_index,
559 Token::Kind kind,
560 Value* left,
561 Value* right)
562 : token_index_(token_index),
563 try_index_(try_index),
564 kind_(kind),
565 operands_class_id_(kObject) {
566 ASSERT(Token::IsRelationalOperator(kind));
567 ASSERT(left != NULL);
568 ASSERT(right != NULL);
569 inputs_[0] = left;
570 inputs_[1] = right;
571 }
572
573 DECLARE_COMPUTATION(RelationalOp)
574
575 intptr_t token_index() const { return token_index_; }
576 intptr_t try_index() const { return try_index_; }
577 Token::Kind kind() const { return kind_; }
578 Value* left() const { return inputs_[0]; }
579 Value* right() const { return inputs_[1]; }
580
581 void set_operands_class_id(intptr_t value) {
582 operands_class_id_ = value;
583 }
584 intptr_t operands_class_id() const { return operands_class_id_; }
585
586 virtual void PrintOperandsTo(BufferFormatter* f) const;
587
588 private:
589 const intptr_t token_index_;
590 const intptr_t try_index_;
591 const Token::Kind kind_;
592 intptr_t operands_class_id_; // class id of both operands.
593
594 DISALLOW_COPY_AND_ASSIGN(RelationalOpComp);
595 };
596
597
553 class StaticCallComp : public Computation { 598 class StaticCallComp : public Computation {
554 public: 599 public:
555 StaticCallComp(intptr_t token_index, 600 StaticCallComp(intptr_t token_index,
556 intptr_t try_index, 601 intptr_t try_index,
557 const Function& function, 602 const Function& function,
558 const Array& argument_names, 603 const Array& argument_names,
559 ZoneGrowableArray<Value*>* arguments) 604 ZoneGrowableArray<Value*>* arguments)
560 : token_index_(token_index), 605 : token_index_(token_index),
561 try_index_(try_index), 606 try_index_(try_index),
562 function_(function), 607 function_(function),
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1434 InstanceCallComp* instance_call() const { return instance_call_; } 1479 InstanceCallComp* instance_call() const { return instance_call_; }
1435 1480
1436 DECLARE_COMPUTATION(NumberNegate) 1481 DECLARE_COMPUTATION(NumberNegate)
1437 1482
1438 private: 1483 private:
1439 InstanceCallComp* instance_call_; 1484 InstanceCallComp* instance_call_;
1440 1485
1441 DISALLOW_COPY_AND_ASSIGN(NumberNegateComp); 1486 DISALLOW_COPY_AND_ASSIGN(NumberNegateComp);
1442 }; 1487 };
1443 1488
1489
1490 class CheckStackOverflowComp : public TemplateComputation<0> {
1491 public:
1492 CheckStackOverflowComp(intptr_t token_index, intptr_t try_index)
1493 : token_index_(token_index),
1494 try_index_(try_index) {}
1495
1496 intptr_t token_index() const { return token_index_; }
1497 intptr_t try_index() const { return try_index_; }
1498
1499 DECLARE_COMPUTATION(CheckStackOverflow)
1500
1501 private:
1502 const intptr_t token_index_;
1503 const intptr_t try_index_;
1504
1505 DISALLOW_COPY_AND_ASSIGN(CheckStackOverflowComp);
1506 };
1507
1508
1444 #undef DECLARE_COMPUTATION 1509 #undef DECLARE_COMPUTATION
1445 1510
1446 1511
1447 // Implementation of type testers and cast functins. 1512 // Implementation of type testers and cast functins.
1448 #define DEFINE_PREDICATE(ShortName, ClassName) \ 1513 #define DEFINE_PREDICATE(ShortName, ClassName) \
1449 bool Computation::Is##ShortName() const { \ 1514 bool Computation::Is##ShortName() const { \
1450 return computation_type() == k##ShortName; \ 1515 return computation_type() == k##ShortName; \
1451 } \ 1516 } \
1452 ClassName* Computation::As##ShortName() { \ 1517 ClassName* Computation::As##ShortName() { \
1453 if (!Is##ShortName()) return NULL; \ 1518 if (!Is##ShortName()) return NULL; \
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2093 const GrowableArray<BlockEntryInstr*>& block_order_; 2158 const GrowableArray<BlockEntryInstr*>& block_order_;
2094 2159
2095 private: 2160 private:
2096 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor); 2161 DISALLOW_COPY_AND_ASSIGN(FlowGraphVisitor);
2097 }; 2162 };
2098 2163
2099 2164
2100 } // namespace dart 2165 } // namespace dart
2101 2166
2102 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 2167 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698