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

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

Issue 595673002: Reduce number of times a deopt-id is computed. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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
« no previous file with comments | « runtime/vm/code_descriptors.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 583 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 594
595 class Instruction : public ZoneAllocated { 595 class Instruction : public ZoneAllocated {
596 public: 596 public:
597 #define DECLARE_TAG(type) k##type, 597 #define DECLARE_TAG(type) k##type,
598 enum Tag { 598 enum Tag {
599 FOR_EACH_INSTRUCTION(DECLARE_TAG) 599 FOR_EACH_INSTRUCTION(DECLARE_TAG)
600 }; 600 };
601 #undef DECLARE_TAG 601 #undef DECLARE_TAG
602 602
603 Instruction() 603 Instruction()
604 : deopt_id_(Isolate::Current()->GetNextDeoptId()), 604 : deopt_id_(Isolate::kNoDeoptId),
605 lifetime_position_(-1), 605 lifetime_position_(-1),
606 previous_(NULL), 606 previous_(NULL),
607 next_(NULL), 607 next_(NULL),
608 env_(NULL), 608 env_(NULL),
609 locs_(NULL), 609 locs_(NULL),
610 place_id_(kNoPlaceId) { } 610 place_id_(kNoPlaceId) { }
611 611
612 virtual ~Instruction() { } 612 virtual ~Instruction() { }
613 613
614 virtual Tag tag() const = 0; 614 virtual Tag tag() const = 0;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 friend class EqualityCompareInstr; 917 friend class EqualityCompareInstr;
918 friend class TestCidsInstr; 918 friend class TestCidsInstr;
919 friend class UnboxIntNInstr; 919 friend class UnboxIntNInstr;
920 friend class UnboxInt32Instr; 920 friend class UnboxInt32Instr;
921 friend class UnboxUint32Instr; 921 friend class UnboxUint32Instr;
922 friend class UnboxedIntConverterInstr; 922 friend class UnboxedIntConverterInstr;
923 friend class UnaryIntegerOpInstr; 923 friend class UnaryIntegerOpInstr;
924 friend class BinaryIntegerOpInstr; 924 friend class BinaryIntegerOpInstr;
925 friend class DeoptimizeInstr; 925 friend class DeoptimizeInstr;
926 926
927 // deopt_id_ access.
928 friend class InstanceCallInstr;
929 friend class StaticCallInstr;
930 friend class GotoInstr;
931 friend class ReturnInstr;
932 friend class BranchInstr;
933 friend class AssertAssignableInstr;
934 friend class TestSmiInstr;
935 friend class IfThenElseInstr;
936 friend class StrictCompareInstr;
937 friend class ThrowInstr;
938 friend class ReThrowInstr;
939 friend class AssertBooleanInstr;
940 friend class CurrentContextInstr;
941 friend class ClosureCallInstr;
942 friend class StringInterpolateInstr;
943 friend class CreateArrayInstr;
944 friend class InstantiateTypeInstr;
945 friend class InstantiateTypeArgumentsInstr;
946 friend class InitStaticFieldInstr;
947 friend class CloneContextInstr;
948 friend class CheckStackOverflowInstr;
949
927 virtual void RawSetInputAt(intptr_t i, Value* value) = 0; 950 virtual void RawSetInputAt(intptr_t i, Value* value) = 0;
928 951
929 enum { 952 enum {
930 kNoPlaceId = -1 953 kNoPlaceId = -1
931 }; 954 };
932 955
933 intptr_t deopt_id_; 956 intptr_t deopt_id_;
934 intptr_t lifetime_position_; // Position used by register allocator. 957 intptr_t lifetime_position_; // Position used by register allocator.
935 Instruction* previous_; 958 Instruction* previous_;
936 Instruction* next_; 959 Instruction* next_;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 protected: 1219 protected:
1197 BlockEntryInstr(intptr_t block_id, intptr_t try_index) 1220 BlockEntryInstr(intptr_t block_id, intptr_t try_index)
1198 : block_id_(block_id), 1221 : block_id_(block_id),
1199 try_index_(try_index), 1222 try_index_(try_index),
1200 preorder_number_(-1), 1223 preorder_number_(-1),
1201 postorder_number_(-1), 1224 postorder_number_(-1),
1202 dominator_(NULL), 1225 dominator_(NULL),
1203 dominated_blocks_(1), 1226 dominated_blocks_(1),
1204 last_instruction_(NULL), 1227 last_instruction_(NULL),
1205 parallel_move_(NULL), 1228 parallel_move_(NULL),
1206 loop_info_(NULL) { } 1229 loop_info_(NULL) {
1230 deopt_id_ = Isolate::Current()->GetNextDeoptId();
1231 }
1207 1232
1208 private: 1233 private:
1209 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); } 1234 virtual void RawSetInputAt(intptr_t i, Value* value) { UNREACHABLE(); }
1210 1235
1211 virtual void ClearPredecessors() = 0; 1236 virtual void ClearPredecessors() = 0;
1212 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0; 1237 virtual void AddPredecessor(BlockEntryInstr* predecessor) = 0;
1213 1238
1214 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; } 1239 void set_dominator(BlockEntryInstr* instr) { dominator_ = instr; }
1215 1240
1216 intptr_t block_id_; 1241 intptr_t block_id_;
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1431 ZoneGrowableArray<PhiInstr*>* phis_; 1456 ZoneGrowableArray<PhiInstr*>* phis_;
1432 intptr_t index_; 1457 intptr_t index_;
1433 }; 1458 };
1434 1459
1435 1460
1436 class TargetEntryInstr : public BlockEntryInstr { 1461 class TargetEntryInstr : public BlockEntryInstr {
1437 public: 1462 public:
1438 TargetEntryInstr(intptr_t block_id, intptr_t try_index) 1463 TargetEntryInstr(intptr_t block_id, intptr_t try_index)
1439 : BlockEntryInstr(block_id, try_index), 1464 : BlockEntryInstr(block_id, try_index),
1440 predecessor_(NULL), 1465 predecessor_(NULL),
1441 edge_weight_(0.0) { 1466 edge_weight_(0.0) { }
1442 }
1443 1467
1444 DECLARE_INSTRUCTION(TargetEntry) 1468 DECLARE_INSTRUCTION(TargetEntry)
1445 1469
1446 double edge_weight() const { return edge_weight_; } 1470 double edge_weight() const { return edge_weight_; }
1447 void set_edge_weight(double weight) { edge_weight_ = weight; } 1471 void set_edge_weight(double weight) { edge_weight_ = weight; }
1448 void adjust_edge_weight(double scale_factor) { edge_weight_ *= scale_factor; } 1472 void adjust_edge_weight(double scale_factor) { edge_weight_ *= scale_factor; }
1449 1473
1450 virtual intptr_t PredecessorCount() const { 1474 virtual intptr_t PredecessorCount() const {
1451 return (predecessor_ == NULL) ? 0 : 1; 1475 return (predecessor_ == NULL) ? 0 : 1;
1452 } 1476 }
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1994 2018
1995 inline Definition* Instruction::ArgumentAt(intptr_t index) const { 2019 inline Definition* Instruction::ArgumentAt(intptr_t index) const {
1996 return PushArgumentAt(index)->value()->definition(); 2020 return PushArgumentAt(index)->value()->definition();
1997 } 2021 }
1998 2022
1999 2023
2000 class ReturnInstr : public TemplateInstruction<1> { 2024 class ReturnInstr : public TemplateInstruction<1> {
2001 public: 2025 public:
2002 ReturnInstr(intptr_t token_pos, Value* value) 2026 ReturnInstr(intptr_t token_pos, Value* value)
2003 : token_pos_(token_pos) { 2027 : token_pos_(token_pos) {
2028 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2004 SetInputAt(0, value); 2029 SetInputAt(0, value);
2005 } 2030 }
2006 2031
2007 DECLARE_INSTRUCTION(Return) 2032 DECLARE_INSTRUCTION(Return)
2008 2033
2009 virtual intptr_t ArgumentCount() const { return 0; } 2034 virtual intptr_t ArgumentCount() const { return 0; }
2010 2035
2011 virtual intptr_t token_pos() const { return token_pos_; } 2036 virtual intptr_t token_pos() const { return token_pos_; }
2012 Value* value() const { return inputs_[0]; } 2037 Value* value() const { return inputs_[0]; }
2013 2038
(...skipping 11 matching lines...) Expand all
2025 2050
2026 private: 2051 private:
2027 const intptr_t token_pos_; 2052 const intptr_t token_pos_;
2028 2053
2029 DISALLOW_COPY_AND_ASSIGN(ReturnInstr); 2054 DISALLOW_COPY_AND_ASSIGN(ReturnInstr);
2030 }; 2055 };
2031 2056
2032 2057
2033 class ThrowInstr : public TemplateInstruction<0> { 2058 class ThrowInstr : public TemplateInstruction<0> {
2034 public: 2059 public:
2035 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) { } 2060 explicit ThrowInstr(intptr_t token_pos) : token_pos_(token_pos) {
2061 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2062 }
2036 2063
2037 DECLARE_INSTRUCTION(Throw) 2064 DECLARE_INSTRUCTION(Throw)
2038 2065
2039 virtual intptr_t ArgumentCount() const { return 1; } 2066 virtual intptr_t ArgumentCount() const { return 1; }
2040 2067
2041 virtual intptr_t token_pos() const { return token_pos_; } 2068 virtual intptr_t token_pos() const { return token_pos_; }
2042 2069
2043 virtual bool CanDeoptimize() const { return true; } 2070 virtual bool CanDeoptimize() const { return true; }
2044 2071
2045 virtual EffectSet Effects() const { return EffectSet::None(); } 2072 virtual EffectSet Effects() const { return EffectSet::None(); }
2046 2073
2047 virtual bool MayThrow() const { return true; } 2074 virtual bool MayThrow() const { return true; }
2048 2075
2049 private: 2076 private:
2050 const intptr_t token_pos_; 2077 const intptr_t token_pos_;
2051 2078
2052 DISALLOW_COPY_AND_ASSIGN(ThrowInstr); 2079 DISALLOW_COPY_AND_ASSIGN(ThrowInstr);
2053 }; 2080 };
2054 2081
2055 2082
2056 class ReThrowInstr : public TemplateInstruction<0> { 2083 class ReThrowInstr : public TemplateInstruction<0> {
2057 public: 2084 public:
2058 // 'catch_try_index' can be CatchClauseNode::kInvalidTryIndex if the 2085 // 'catch_try_index' can be CatchClauseNode::kInvalidTryIndex if the
2059 // rethrow has been artifically generated by the parser. 2086 // rethrow has been artifically generated by the parser.
2060 ReThrowInstr(intptr_t token_pos, intptr_t catch_try_index) 2087 ReThrowInstr(intptr_t token_pos, intptr_t catch_try_index)
2061 : token_pos_(token_pos), catch_try_index_(catch_try_index) {} 2088 : token_pos_(token_pos), catch_try_index_(catch_try_index) {
2089 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2090 }
2062 2091
2063 DECLARE_INSTRUCTION(ReThrow) 2092 DECLARE_INSTRUCTION(ReThrow)
2064 2093
2065 virtual intptr_t ArgumentCount() const { return 2; } 2094 virtual intptr_t ArgumentCount() const { return 2; }
2066 2095
2067 virtual intptr_t token_pos() const { return token_pos_; } 2096 virtual intptr_t token_pos() const { return token_pos_; }
2068 intptr_t catch_try_index() const { return catch_try_index_; } 2097 intptr_t catch_try_index() const { return catch_try_index_; }
2069 2098
2070 virtual bool CanDeoptimize() const { return true; } 2099 virtual bool CanDeoptimize() const { return true; }
2071 2100
2072 virtual EffectSet Effects() const { return EffectSet::None(); } 2101 virtual EffectSet Effects() const { return EffectSet::None(); }
2073 2102
2074 virtual bool MayThrow() const { return true; } 2103 virtual bool MayThrow() const { return true; }
2075 2104
2076 private: 2105 private:
2077 const intptr_t token_pos_; 2106 const intptr_t token_pos_;
2078 const intptr_t catch_try_index_; 2107 const intptr_t catch_try_index_;
2079 2108
2080 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr); 2109 DISALLOW_COPY_AND_ASSIGN(ReThrowInstr);
2081 }; 2110 };
2082 2111
2083 2112
2084 class GotoInstr : public TemplateInstruction<0> { 2113 class GotoInstr : public TemplateInstruction<0> {
2085 public: 2114 public:
2086 explicit GotoInstr(JoinEntryInstr* entry) 2115 explicit GotoInstr(JoinEntryInstr* entry)
2087 : successor_(entry), 2116 : successor_(entry),
2088 edge_weight_(0.0), 2117 edge_weight_(0.0),
2089 parallel_move_(NULL) { 2118 parallel_move_(NULL) {
2119 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2090 } 2120 }
2091 2121
2092 DECLARE_INSTRUCTION(Goto) 2122 DECLARE_INSTRUCTION(Goto)
2093 2123
2094 virtual intptr_t ArgumentCount() const { return 0; } 2124 virtual intptr_t ArgumentCount() const { return 0; }
2095 2125
2096 JoinEntryInstr* successor() const { return successor_; } 2126 JoinEntryInstr* successor() const { return successor_; }
2097 void set_successor(JoinEntryInstr* successor) { successor_ = successor; } 2127 void set_successor(JoinEntryInstr* successor) { successor_ = successor; }
2098 virtual intptr_t SuccessorCount() const; 2128 virtual intptr_t SuccessorCount() const;
2099 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const; 2129 virtual BlockEntryInstr* SuccessorAt(intptr_t index) const;
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
2192 }; 2222 };
2193 2223
2194 2224
2195 class BranchInstr : public Instruction { 2225 class BranchInstr : public Instruction {
2196 public: 2226 public:
2197 explicit BranchInstr(ComparisonInstr* comparison) 2227 explicit BranchInstr(ComparisonInstr* comparison)
2198 : comparison_(comparison), 2228 : comparison_(comparison),
2199 is_checked_(false), 2229 is_checked_(false),
2200 constrained_type_(NULL), 2230 constrained_type_(NULL),
2201 constant_target_(NULL) { 2231 constant_target_(NULL) {
2232 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2202 ASSERT(comparison->env() == NULL); 2233 ASSERT(comparison->env() == NULL);
2203 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) { 2234 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) {
2204 comparison->InputAt(i)->set_instruction(this); 2235 comparison->InputAt(i)->set_instruction(this);
2205 } 2236 }
2206 } 2237 }
2207 2238
2208 DECLARE_INSTRUCTION(Branch) 2239 DECLARE_INSTRUCTION(Branch)
2209 2240
2210 virtual intptr_t ArgumentCount() const { 2241 virtual intptr_t ArgumentCount() const {
2211 return comparison()->ArgumentCount(); 2242 return comparison()->ArgumentCount();
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
2502 public: 2533 public:
2503 AssertAssignableInstr(intptr_t token_pos, 2534 AssertAssignableInstr(intptr_t token_pos,
2504 Value* value, 2535 Value* value,
2505 Value* instantiator, 2536 Value* instantiator,
2506 Value* instantiator_type_arguments, 2537 Value* instantiator_type_arguments,
2507 const AbstractType& dst_type, 2538 const AbstractType& dst_type,
2508 const String& dst_name) 2539 const String& dst_name)
2509 : token_pos_(token_pos), 2540 : token_pos_(token_pos),
2510 dst_type_(AbstractType::ZoneHandle(dst_type.raw())), 2541 dst_type_(AbstractType::ZoneHandle(dst_type.raw())),
2511 dst_name_(dst_name) { 2542 dst_name_(dst_name) {
2543 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2512 ASSERT(!dst_type.IsNull()); 2544 ASSERT(!dst_type.IsNull());
2513 ASSERT(!dst_name.IsNull()); 2545 ASSERT(!dst_name.IsNull());
2514 SetInputAt(0, value); 2546 SetInputAt(0, value);
2515 SetInputAt(1, instantiator); 2547 SetInputAt(1, instantiator);
2516 SetInputAt(2, instantiator_type_arguments); 2548 SetInputAt(2, instantiator_type_arguments);
2517 } 2549 }
2518 2550
2519 DECLARE_INSTRUCTION(AssertAssignable) 2551 DECLARE_INSTRUCTION(AssertAssignable)
2520 virtual CompileType* ComputeInitialType() const; 2552 virtual CompileType* ComputeInitialType() const;
2521 virtual bool RecomputeType(); 2553 virtual bool RecomputeType();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
2556 const String& dst_name_; 2588 const String& dst_name_;
2557 2589
2558 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr); 2590 DISALLOW_COPY_AND_ASSIGN(AssertAssignableInstr);
2559 }; 2591 };
2560 2592
2561 2593
2562 class AssertBooleanInstr : public TemplateDefinition<1> { 2594 class AssertBooleanInstr : public TemplateDefinition<1> {
2563 public: 2595 public:
2564 AssertBooleanInstr(intptr_t token_pos, Value* value) 2596 AssertBooleanInstr(intptr_t token_pos, Value* value)
2565 : token_pos_(token_pos) { 2597 : token_pos_(token_pos) {
2598 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2566 SetInputAt(0, value); 2599 SetInputAt(0, value);
2567 } 2600 }
2568 2601
2569 DECLARE_INSTRUCTION(AssertBoolean) 2602 DECLARE_INSTRUCTION(AssertBoolean)
2570 virtual CompileType ComputeType() const; 2603 virtual CompileType ComputeType() const;
2571 2604
2572 virtual intptr_t token_pos() const { return token_pos_; } 2605 virtual intptr_t token_pos() const { return token_pos_; }
2573 Value* value() const { return inputs_[0]; } 2606 Value* value() const { return inputs_[0]; }
2574 2607
2575 virtual void PrintOperandsTo(BufferFormatter* f) const; 2608 virtual void PrintOperandsTo(BufferFormatter* f) const;
(...skipping 13 matching lines...) Expand all
2589 const intptr_t token_pos_; 2622 const intptr_t token_pos_;
2590 2623
2591 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr); 2624 DISALLOW_COPY_AND_ASSIGN(AssertBooleanInstr);
2592 }; 2625 };
2593 2626
2594 2627
2595 // Denotes the current context, normally held in a register. This is 2628 // Denotes the current context, normally held in a register. This is
2596 // a computation, not a value, because it's mutable. 2629 // a computation, not a value, because it's mutable.
2597 class CurrentContextInstr : public TemplateDefinition<0> { 2630 class CurrentContextInstr : public TemplateDefinition<0> {
2598 public: 2631 public:
2599 CurrentContextInstr() { } 2632 CurrentContextInstr() {
2633 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2634 }
2600 2635
2601 DECLARE_INSTRUCTION(CurrentContext) 2636 DECLARE_INSTRUCTION(CurrentContext)
2602 virtual CompileType ComputeType() const; 2637 virtual CompileType ComputeType() const;
2603 2638
2604 virtual bool CanDeoptimize() const { return false; } 2639 virtual bool CanDeoptimize() const { return false; }
2605 2640
2606 virtual EffectSet Effects() const { return EffectSet::None(); } 2641 virtual EffectSet Effects() const { return EffectSet::None(); }
2607 virtual EffectSet Dependencies() const { return EffectSet::None(); } 2642 virtual EffectSet Dependencies() const { return EffectSet::None(); }
2608 virtual bool AttributesEqual(Instruction* other) const { return true; } 2643 virtual bool AttributesEqual(Instruction* other) const { return true; }
2609 2644
2610 virtual bool MayThrow() const { return false; } 2645 virtual bool MayThrow() const { return false; }
2611 2646
2612 private: 2647 private:
2613 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr); 2648 DISALLOW_COPY_AND_ASSIGN(CurrentContextInstr);
2614 }; 2649 };
2615 2650
2616 2651
2617 class ClosureCallInstr : public TemplateDefinition<1> { 2652 class ClosureCallInstr : public TemplateDefinition<1> {
2618 public: 2653 public:
2619 ClosureCallInstr(Value* function, 2654 ClosureCallInstr(Value* function,
2620 ClosureCallNode* node, 2655 ClosureCallNode* node,
2621 ZoneGrowableArray<PushArgumentInstr*>* arguments) 2656 ZoneGrowableArray<PushArgumentInstr*>* arguments)
2622 : ast_node_(*node), 2657 : ast_node_(*node),
2623 arguments_(arguments) { 2658 arguments_(arguments) {
2659 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2624 SetInputAt(0, function); 2660 SetInputAt(0, function);
2625 } 2661 }
2626 2662
2627 DECLARE_INSTRUCTION(ClosureCall) 2663 DECLARE_INSTRUCTION(ClosureCall)
2628 2664
2629 const Array& argument_names() const { return ast_node_.arguments()->names(); } 2665 const Array& argument_names() const { return ast_node_.arguments()->names(); }
2630 virtual intptr_t token_pos() const { return ast_node_.token_pos(); } 2666 virtual intptr_t token_pos() const { return ast_node_.token_pos(); }
2631 2667
2632 virtual intptr_t ArgumentCount() const { return arguments_->length(); } 2668 virtual intptr_t ArgumentCount() const { return arguments_->length(); }
2633 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const { 2669 virtual PushArgumentInstr* PushArgumentAt(intptr_t index) const {
(...skipping 21 matching lines...) Expand all
2655 2691
2656 class InstanceCallInstr : public TemplateDefinition<0> { 2692 class InstanceCallInstr : public TemplateDefinition<0> {
2657 public: 2693 public:
2658 InstanceCallInstr(intptr_t token_pos, 2694 InstanceCallInstr(intptr_t token_pos,
2659 const String& function_name, 2695 const String& function_name,
2660 Token::Kind token_kind, 2696 Token::Kind token_kind,
2661 ZoneGrowableArray<PushArgumentInstr*>* arguments, 2697 ZoneGrowableArray<PushArgumentInstr*>* arguments,
2662 const Array& argument_names, 2698 const Array& argument_names,
2663 intptr_t checked_argument_count, 2699 intptr_t checked_argument_count,
2664 const ZoneGrowableArray<const ICData*>& ic_data_array) 2700 const ZoneGrowableArray<const ICData*>& ic_data_array)
2665 : ic_data_(GetICData(ic_data_array)), 2701 : ic_data_(NULL),
2666 token_pos_(token_pos), 2702 token_pos_(token_pos),
2667 function_name_(function_name), 2703 function_name_(function_name),
2668 token_kind_(token_kind), 2704 token_kind_(token_kind),
2669 arguments_(arguments), 2705 arguments_(arguments),
2670 argument_names_(argument_names), 2706 argument_names_(argument_names),
2671 checked_argument_count_(checked_argument_count) { 2707 checked_argument_count_(checked_argument_count) {
2708 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2709 ic_data_ = GetICData(ic_data_array);
2672 ASSERT(function_name.IsNotTemporaryScopedHandle()); 2710 ASSERT(function_name.IsNotTemporaryScopedHandle());
2673 ASSERT(!arguments->is_empty()); 2711 ASSERT(!arguments->is_empty());
2674 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); 2712 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap());
2675 ASSERT(Token::IsBinaryOperator(token_kind) || 2713 ASSERT(Token::IsBinaryOperator(token_kind) ||
2676 Token::IsEqualityOperator(token_kind) || 2714 Token::IsEqualityOperator(token_kind) ||
2677 Token::IsRelationalOperator(token_kind) || 2715 Token::IsRelationalOperator(token_kind) ||
2678 Token::IsPrefixOperator(token_kind) || 2716 Token::IsPrefixOperator(token_kind) ||
2679 Token::IsIndexOperator(token_kind) || 2717 Token::IsIndexOperator(token_kind) ||
2680 Token::IsTypeTestOperator(token_kind) || 2718 Token::IsTypeTestOperator(token_kind) ||
2681 Token::IsTypeCastOperator(token_kind) || 2719 Token::IsTypeCastOperator(token_kind) ||
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr); 2873 DISALLOW_COPY_AND_ASSIGN(StrictCompareInstr);
2836 }; 2874 };
2837 2875
2838 2876
2839 // Comparison instruction that is equivalent to the (left & right) == 0 2877 // Comparison instruction that is equivalent to the (left & right) == 0
2840 // comparison pattern. 2878 // comparison pattern.
2841 class TestSmiInstr : public ComparisonInstr { 2879 class TestSmiInstr : public ComparisonInstr {
2842 public: 2880 public:
2843 TestSmiInstr(intptr_t token_pos, Token::Kind kind, Value* left, Value* right) 2881 TestSmiInstr(intptr_t token_pos, Token::Kind kind, Value* left, Value* right)
2844 : ComparisonInstr(token_pos, kind, left, right) { 2882 : ComparisonInstr(token_pos, kind, left, right) {
2883 deopt_id_ = Isolate::Current()->GetNextDeoptId();
2845 ASSERT(kind == Token::kEQ || kind == Token::kNE); 2884 ASSERT(kind == Token::kEQ || kind == Token::kNE);
2846 } 2885 }
2847 2886
2848 DECLARE_INSTRUCTION(TestSmi); 2887 DECLARE_INSTRUCTION(TestSmi);
2849 2888
2850 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right); 2889 virtual ComparisonInstr* CopyWithNewOperands(Value* left, Value* right);
2851 2890
2852 virtual CompileType ComputeType() const; 2891 virtual CompileType ComputeType() const;
2853 2892
2854 virtual bool CanDeoptimize() const { return false; } 2893 virtual bool CanDeoptimize() const { return false; }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for 3104 // TODO(vegorov): ComparisonInstr should be switched to use IfTheElseInstr for
3066 // materialization of true and false constants. 3105 // materialization of true and false constants.
3067 class IfThenElseInstr : public Definition { 3106 class IfThenElseInstr : public Definition {
3068 public: 3107 public:
3069 IfThenElseInstr(ComparisonInstr* comparison, 3108 IfThenElseInstr(ComparisonInstr* comparison,
3070 Value* if_true, 3109 Value* if_true,
3071 Value* if_false) 3110 Value* if_false)
3072 : comparison_(comparison), 3111 : comparison_(comparison),
3073 if_true_(Smi::Cast(if_true->BoundConstant()).Value()), 3112 if_true_(Smi::Cast(if_true->BoundConstant()).Value()),
3074 if_false_(Smi::Cast(if_false->BoundConstant()).Value()) { 3113 if_false_(Smi::Cast(if_false->BoundConstant()).Value()) {
3114 deopt_id_ = Isolate::Current()->GetNextDeoptId();
3075 // Adjust uses at the comparison. 3115 // Adjust uses at the comparison.
3076 ASSERT(comparison->env() == NULL); 3116 ASSERT(comparison->env() == NULL);
3077 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) { 3117 for (intptr_t i = comparison->InputCount() - 1; i >= 0; --i) {
3078 comparison->InputAt(i)->set_instruction(this); 3118 comparison->InputAt(i)->set_instruction(this);
3079 } 3119 }
3080 } 3120 }
3081 3121
3082 // Returns true if this combination of comparison and values flowing on 3122 // Returns true if this combination of comparison and values flowing on
3083 // the true and false paths is supported on the current platform. 3123 // the true and false paths is supported on the current platform.
3084 static bool Supports(ComparisonInstr* comparison, Value* v1, Value* v2); 3124 static bool Supports(ComparisonInstr* comparison, Value* v1, Value* v2);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3142 }; 3182 };
3143 3183
3144 3184
3145 class StaticCallInstr : public TemplateDefinition<0> { 3185 class StaticCallInstr : public TemplateDefinition<0> {
3146 public: 3186 public:
3147 StaticCallInstr(intptr_t token_pos, 3187 StaticCallInstr(intptr_t token_pos,
3148 const Function& function, 3188 const Function& function,
3149 const Array& argument_names, 3189 const Array& argument_names,
3150 ZoneGrowableArray<PushArgumentInstr*>* arguments, 3190 ZoneGrowableArray<PushArgumentInstr*>* arguments,
3151 const ZoneGrowableArray<const ICData*>& ic_data_array) 3191 const ZoneGrowableArray<const ICData*>& ic_data_array)
3152 : ic_data_(GetICData(ic_data_array)), 3192 : ic_data_(NULL),
3153 token_pos_(token_pos), 3193 token_pos_(token_pos),
3154 function_(function), 3194 function_(function),
3155 argument_names_(argument_names), 3195 argument_names_(argument_names),
3156 arguments_(arguments), 3196 arguments_(arguments),
3157 result_cid_(kDynamicCid), 3197 result_cid_(kDynamicCid),
3158 is_known_list_constructor_(false), 3198 is_known_list_constructor_(false),
3159 is_native_list_factory_(false), 3199 is_native_list_factory_(false),
3160 identity_(AliasIdentity::Unknown()) { 3200 identity_(AliasIdentity::Unknown()) {
3201 deopt_id_ = Isolate::Current()->GetNextDeoptId();
3202 ic_data_ = GetICData(ic_data_array);
3161 ASSERT(function.IsZoneHandle()); 3203 ASSERT(function.IsZoneHandle());
3162 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap()); 3204 ASSERT(argument_names.IsZoneHandle() || argument_names.InVMHeap());
3163 } 3205 }
3164 3206
3165 // ICData for static calls carries call count. 3207 // ICData for static calls carries call count.
3166 const ICData* ic_data() const { return ic_data_; } 3208 const ICData* ic_data() const { return ic_data_; }
3167 bool HasICData() const { 3209 bool HasICData() const {
3168 return (ic_data() != NULL) && !ic_data()->IsNull(); 3210 return (ic_data() != NULL) && !ic_data()->IsNull();
3169 } 3211 }
3170 3212
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
3827 const intptr_t cid_; 3869 const intptr_t cid_;
3828 3870
3829 DISALLOW_COPY_AND_ASSIGN(StringToCharCodeInstr); 3871 DISALLOW_COPY_AND_ASSIGN(StringToCharCodeInstr);
3830 }; 3872 };
3831 3873
3832 3874
3833 class StringInterpolateInstr : public TemplateDefinition<1> { 3875 class StringInterpolateInstr : public TemplateDefinition<1> {
3834 public: 3876 public:
3835 StringInterpolateInstr(Value* value, intptr_t token_pos) 3877 StringInterpolateInstr(Value* value, intptr_t token_pos)
3836 : token_pos_(token_pos), function_(Function::Handle()) { 3878 : token_pos_(token_pos), function_(Function::Handle()) {
3879 deopt_id_ = Isolate::Current()->GetNextDeoptId();
3837 SetInputAt(0, value); 3880 SetInputAt(0, value);
3838 } 3881 }
3839 3882
3840 Value* value() const { return inputs_[0]; } 3883 Value* value() const { return inputs_[0]; }
3841 virtual intptr_t token_pos() const { return token_pos_; } 3884 virtual intptr_t token_pos() const { return token_pos_; }
3842 3885
3843 virtual CompileType ComputeType() const; 3886 virtual CompileType ComputeType() const;
3844 // Issues a static call to Dart code which calls toString on objects. 3887 // Issues a static call to Dart code which calls toString on objects.
3845 virtual EffectSet Effects() const { return EffectSet::All(); } 3888 virtual EffectSet Effects() const { return EffectSet::All(); }
3846 virtual bool CanDeoptimize() const { return true; } 3889 virtual bool CanDeoptimize() const { return true; }
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
4143 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr); 4186 DISALLOW_COPY_AND_ASSIGN(MaterializeObjectInstr);
4144 }; 4187 };
4145 4188
4146 4189
4147 class CreateArrayInstr : public TemplateDefinition<2> { 4190 class CreateArrayInstr : public TemplateDefinition<2> {
4148 public: 4191 public:
4149 CreateArrayInstr(intptr_t token_pos, 4192 CreateArrayInstr(intptr_t token_pos,
4150 Value* element_type, 4193 Value* element_type,
4151 Value* num_elements) 4194 Value* num_elements)
4152 : token_pos_(token_pos), identity_(AliasIdentity::Unknown()) { 4195 : token_pos_(token_pos), identity_(AliasIdentity::Unknown()) {
4196 deopt_id_ = Isolate::Current()->GetNextDeoptId();
4153 SetInputAt(kElementTypePos, element_type); 4197 SetInputAt(kElementTypePos, element_type);
4154 SetInputAt(kLengthPos, num_elements); 4198 SetInputAt(kLengthPos, num_elements);
4155 } 4199 }
4156 4200
4157 enum { 4201 enum {
4158 kElementTypePos = 0, 4202 kElementTypePos = 0,
4159 kLengthPos = 1 4203 kLengthPos = 1
4160 }; 4204 };
4161 4205
4162 DECLARE_INSTRUCTION(CreateArray) 4206 DECLARE_INSTRUCTION(CreateArray)
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
4349 4393
4350 class InstantiateTypeInstr : public TemplateDefinition<1> { 4394 class InstantiateTypeInstr : public TemplateDefinition<1> {
4351 public: 4395 public:
4352 InstantiateTypeInstr(intptr_t token_pos, 4396 InstantiateTypeInstr(intptr_t token_pos,
4353 const AbstractType& type, 4397 const AbstractType& type,
4354 const Class& instantiator_class, 4398 const Class& instantiator_class,
4355 Value* instantiator) 4399 Value* instantiator)
4356 : token_pos_(token_pos), 4400 : token_pos_(token_pos),
4357 type_(type), 4401 type_(type),
4358 instantiator_class_(instantiator_class) { 4402 instantiator_class_(instantiator_class) {
4403 deopt_id_ = Isolate::Current()->GetNextDeoptId();
4359 ASSERT(type.IsZoneHandle()); 4404 ASSERT(type.IsZoneHandle());
4360 SetInputAt(0, instantiator); 4405 SetInputAt(0, instantiator);
4361 } 4406 }
4362 4407
4363 DECLARE_INSTRUCTION(InstantiateType) 4408 DECLARE_INSTRUCTION(InstantiateType)
4364 4409
4365 Value* instantiator() const { return inputs_[0]; } 4410 Value* instantiator() const { return inputs_[0]; }
4366 const AbstractType& type() const { return type_; 4411 const AbstractType& type() const { return type_;
4367 } 4412 }
4368 const Class& instantiator_class() const { return instantiator_class_; } 4413 const Class& instantiator_class() const { return instantiator_class_; }
(...skipping 18 matching lines...) Expand all
4387 4432
4388 class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> { 4433 class InstantiateTypeArgumentsInstr : public TemplateDefinition<1> {
4389 public: 4434 public:
4390 InstantiateTypeArgumentsInstr(intptr_t token_pos, 4435 InstantiateTypeArgumentsInstr(intptr_t token_pos,
4391 const TypeArguments& type_arguments, 4436 const TypeArguments& type_arguments,
4392 const Class& instantiator_class, 4437 const Class& instantiator_class,
4393 Value* instantiator) 4438 Value* instantiator)
4394 : token_pos_(token_pos), 4439 : token_pos_(token_pos),
4395 type_arguments_(type_arguments), 4440 type_arguments_(type_arguments),
4396 instantiator_class_(instantiator_class) { 4441 instantiator_class_(instantiator_class) {
4442 deopt_id_ = Isolate::Current()->GetNextDeoptId();
4397 ASSERT(type_arguments.IsZoneHandle()); 4443 ASSERT(type_arguments.IsZoneHandle());
4398 SetInputAt(0, instantiator); 4444 SetInputAt(0, instantiator);
4399 } 4445 }
4400 4446
4401 DECLARE_INSTRUCTION(InstantiateTypeArguments) 4447 DECLARE_INSTRUCTION(InstantiateTypeArguments)
4402 4448
4403 Value* instantiator() const { return inputs_[0]; } 4449 Value* instantiator() const { return inputs_[0]; }
4404 const TypeArguments& type_arguments() const { 4450 const TypeArguments& type_arguments() const {
4405 return type_arguments_; 4451 return type_arguments_;
4406 } 4452 }
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
4452 const intptr_t num_context_variables_; 4498 const intptr_t num_context_variables_;
4453 4499
4454 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr); 4500 DISALLOW_COPY_AND_ASSIGN(AllocateContextInstr);
4455 }; 4501 };
4456 4502
4457 4503
4458 class InitStaticFieldInstr : public TemplateInstruction<1> { 4504 class InitStaticFieldInstr : public TemplateInstruction<1> {
4459 public: 4505 public:
4460 InitStaticFieldInstr(Value* input, const Field& field) 4506 InitStaticFieldInstr(Value* input, const Field& field)
4461 : field_(field) { 4507 : field_(field) {
4508 deopt_id_ = Isolate::Current()->GetNextDeoptId();
4462 SetInputAt(0, input); 4509 SetInputAt(0, input);
4463 } 4510 }
4464 4511
4465 virtual intptr_t token_pos() const { return field_.token_pos(); } 4512 virtual intptr_t token_pos() const { return field_.token_pos(); }
4466 const Field& field() const { return field_; } 4513 const Field& field() const { return field_; }
4467 4514
4468 DECLARE_INSTRUCTION(InitStaticField) 4515 DECLARE_INSTRUCTION(InitStaticField)
4469 4516
4470 virtual intptr_t ArgumentCount() const { return 0; } 4517 virtual intptr_t ArgumentCount() const { return 0; }
4471 virtual bool CanDeoptimize() const { return true; } 4518 virtual bool CanDeoptimize() const { return true; }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
4506 const intptr_t num_context_variables_; 4553 const intptr_t num_context_variables_;
4507 4554
4508 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr); 4555 DISALLOW_COPY_AND_ASSIGN(AllocateUninitializedContextInstr);
4509 }; 4556 };
4510 4557
4511 4558
4512 class CloneContextInstr : public TemplateDefinition<1> { 4559 class CloneContextInstr : public TemplateDefinition<1> {
4513 public: 4560 public:
4514 CloneContextInstr(intptr_t token_pos, Value* context_value) 4561 CloneContextInstr(intptr_t token_pos, Value* context_value)
4515 : token_pos_(token_pos) { 4562 : token_pos_(token_pos) {
4563 deopt_id_ = Isolate::Current()->GetNextDeoptId();
4516 SetInputAt(0, context_value); 4564 SetInputAt(0, context_value);
4517 } 4565 }
4518 4566
4519 virtual intptr_t token_pos() const { return token_pos_; } 4567 virtual intptr_t token_pos() const { return token_pos_; }
4520 Value* context_value() const { return inputs_[0]; } 4568 Value* context_value() const { return inputs_[0]; }
4521 4569
4522 DECLARE_INSTRUCTION(CloneContext) 4570 DECLARE_INSTRUCTION(CloneContext)
4523 virtual CompileType ComputeType() const; 4571 virtual CompileType ComputeType() const;
4524 4572
4525 virtual bool CanDeoptimize() const { return true; } 4573 virtual bool CanDeoptimize() const { return true; }
(...skipping 2237 matching lines...) Expand 10 before | Expand all | Expand 10 after
6763 const Token::Kind op_kind_; 6811 const Token::Kind op_kind_;
6764 }; 6812 };
6765 6813
6766 6814
6767 // Handles both Smi operations: BIT_OR and NEGATE. 6815 // Handles both Smi operations: BIT_OR and NEGATE.
6768 class UnarySmiOpInstr : public UnaryIntegerOpInstr { 6816 class UnarySmiOpInstr : public UnaryIntegerOpInstr {
6769 public: 6817 public:
6770 UnarySmiOpInstr(Token::Kind op_kind, 6818 UnarySmiOpInstr(Token::Kind op_kind,
6771 Value* value, 6819 Value* value,
6772 intptr_t deopt_id) 6820 intptr_t deopt_id)
6773 : UnaryIntegerOpInstr(op_kind, value, deopt_id) { 6821 : UnaryIntegerOpInstr(op_kind, value, deopt_id) {}
6774 }
6775 6822
6776 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; } 6823 virtual bool CanDeoptimize() const { return op_kind() == Token::kNEGATE; }
6777 6824
6778 virtual CompileType ComputeType() const; 6825 virtual CompileType ComputeType() const;
6779 6826
6780 DECLARE_INSTRUCTION(UnarySmiOp) 6827 DECLARE_INSTRUCTION(UnarySmiOp)
6781 6828
6782 private: 6829 private:
6783 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr); 6830 DISALLOW_COPY_AND_ASSIGN(UnarySmiOpInstr);
6784 }; 6831 };
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
7174 private: 7221 private:
7175 const Token::Kind op_kind_; 7222 const Token::Kind op_kind_;
7176 7223
7177 DISALLOW_COPY_AND_ASSIGN(UnaryDoubleOpInstr); 7224 DISALLOW_COPY_AND_ASSIGN(UnaryDoubleOpInstr);
7178 }; 7225 };
7179 7226
7180 7227
7181 class CheckStackOverflowInstr : public TemplateInstruction<0> { 7228 class CheckStackOverflowInstr : public TemplateInstruction<0> {
7182 public: 7229 public:
7183 CheckStackOverflowInstr(intptr_t token_pos, intptr_t loop_depth) 7230 CheckStackOverflowInstr(intptr_t token_pos, intptr_t loop_depth)
7184 : token_pos_(token_pos), loop_depth_(loop_depth) {} 7231 : token_pos_(token_pos), loop_depth_(loop_depth) {
7232 deopt_id_ = Isolate::Current()->GetNextDeoptId();
7233 }
7185 7234
7186 virtual intptr_t token_pos() const { return token_pos_; } 7235 virtual intptr_t token_pos() const { return token_pos_; }
7187 bool in_loop() const { return loop_depth_ > 0; } 7236 bool in_loop() const { return loop_depth_ > 0; }
7188 intptr_t loop_depth() const { return loop_depth_; } 7237 intptr_t loop_depth() const { return loop_depth_; }
7189 7238
7190 DECLARE_INSTRUCTION(CheckStackOverflow) 7239 DECLARE_INSTRUCTION(CheckStackOverflow)
7191 7240
7192 virtual intptr_t ArgumentCount() const { return 0; } 7241 virtual intptr_t ArgumentCount() const { return 0; }
7193 7242
7194 virtual bool CanDeoptimize() const { return true; } 7243 virtual bool CanDeoptimize() const { return true; }
(...skipping 1167 matching lines...) Expand 10 before | Expand all | Expand 10 after
8362 Isolate* isolate, bool opt) const { \ 8411 Isolate* isolate, bool opt) const { \
8363 UNIMPLEMENTED(); \ 8412 UNIMPLEMENTED(); \
8364 return NULL; \ 8413 return NULL; \
8365 } \ 8414 } \
8366 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); } 8415 void Name::EmitNativeCode(FlowGraphCompiler* compiler) { UNIMPLEMENTED(); }
8367 8416
8368 8417
8369 } // namespace dart 8418 } // namespace dart
8370 8419
8371 #endif // VM_INTERMEDIATE_LANGUAGE_H_ 8420 #endif // VM_INTERMEDIATE_LANGUAGE_H_
OLDNEW
« no previous file with comments | « runtime/vm/code_descriptors.cc ('k') | runtime/vm/intermediate_language.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698