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

Side by Side Diff: src/arm/lithium-arm.h

Issue 6877036: Make predicates on lithium instruction classes non-virtual. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Fix lintos Created 9 years, 8 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 | « no previous file | src/ia32/lithium-ia32.h » ('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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 21 matching lines...) Expand all
32 #include "lithium-allocator.h" 32 #include "lithium-allocator.h"
33 #include "lithium.h" 33 #include "lithium.h"
34 #include "safepoint-table.h" 34 #include "safepoint-table.h"
35 35
36 namespace v8 { 36 namespace v8 {
37 namespace internal { 37 namespace internal {
38 38
39 // Forward declarations. 39 // Forward declarations.
40 class LCodeGen; 40 class LCodeGen;
41 41
42 #define LITHIUM_ALL_INSTRUCTION_LIST(V) \
43 V(ControlInstruction) \
44 V(Call) \
45 LITHIUM_CONCRETE_INSTRUCTION_LIST(V)
46
47
48 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ 42 #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \
49 V(AccessArgumentsAt) \ 43 V(AccessArgumentsAt) \
50 V(AddI) \ 44 V(AddI) \
51 V(ApplyArguments) \ 45 V(ApplyArguments) \
52 V(ArgumentsElements) \ 46 V(ArgumentsElements) \
53 V(ArgumentsLength) \ 47 V(ArgumentsLength) \
54 V(ArithmeticD) \ 48 V(ArithmeticD) \
55 V(ArithmeticT) \ 49 V(ArithmeticT) \
56 V(ArrayLiteral) \ 50 V(ArrayLiteral) \
57 V(BitI) \ 51 V(BitI) \
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 V(Typeof) \ 158 V(Typeof) \
165 V(TypeofIs) \ 159 V(TypeofIs) \
166 V(TypeofIsAndBranch) \ 160 V(TypeofIsAndBranch) \
167 V(IsConstructCall) \ 161 V(IsConstructCall) \
168 V(IsConstructCallAndBranch) \ 162 V(IsConstructCallAndBranch) \
169 V(UnaryMathOperation) \ 163 V(UnaryMathOperation) \
170 V(UnknownOSRValue) \ 164 V(UnknownOSRValue) \
171 V(ValueOf) 165 V(ValueOf)
172 166
173 167
174 #define DECLARE_INSTRUCTION(type) \ 168 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
175 virtual bool Is##type() const { return true; } \ 169 virtual Opcode opcode() const { return LInstruction::k##type; } \
Kevin Millikin (Chromium) 2011/04/19 12:20:30 Thank you.
176 static L##type* cast(LInstruction* instr) { \ 170 virtual void CompileToNative(LCodeGen* generator); \
177 ASSERT(instr->Is##type()); \ 171 virtual const char* Mnemonic() const { return mnemonic; } \
178 return reinterpret_cast<L##type*>(instr); \ 172 static L##type* cast(LInstruction* instr) { \
173 ASSERT(instr->Is##type()); \
174 return reinterpret_cast<L##type*>(instr); \
179 } 175 }
180 176
181 177
182 #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \
183 virtual void CompileToNative(LCodeGen* generator); \
184 virtual const char* Mnemonic() const { return mnemonic; } \
185 DECLARE_INSTRUCTION(type)
186
187
188 #define DECLARE_HYDROGEN_ACCESSOR(type) \ 178 #define DECLARE_HYDROGEN_ACCESSOR(type) \
189 H##type* hydrogen() const { \ 179 H##type* hydrogen() const { \
190 return H##type::cast(hydrogen_value()); \ 180 return H##type::cast(hydrogen_value()); \
191 } 181 }
192 182
193 183
194 class LInstruction: public ZoneObject { 184 class LInstruction: public ZoneObject {
195 public: 185 public:
196 LInstruction() 186 LInstruction()
197 : environment_(NULL), 187 : environment_(NULL),
198 hydrogen_value_(NULL), 188 hydrogen_value_(NULL),
199 is_call_(false), 189 is_call_(false),
200 is_save_doubles_(false) { } 190 is_save_doubles_(false) { }
201 virtual ~LInstruction() { } 191 virtual ~LInstruction() { }
202 192
203 virtual void CompileToNative(LCodeGen* generator) = 0; 193 virtual void CompileToNative(LCodeGen* generator) = 0;
204 virtual const char* Mnemonic() const = 0; 194 virtual const char* Mnemonic() const = 0;
205 virtual void PrintTo(StringStream* stream); 195 virtual void PrintTo(StringStream* stream);
206 virtual void PrintDataTo(StringStream* stream) = 0; 196 virtual void PrintDataTo(StringStream* stream) = 0;
207 virtual void PrintOutputOperandTo(StringStream* stream) = 0; 197 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
208 198
199 enum Opcode {
200 // Declare a unique enum value for each instruction.
201 #define DECLARE_OPCODE(type) k##type,
202 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
203 kNumberOfInstructions
204 #undef DECLARE_OPCODE
205 };
206
207 virtual Opcode opcode() const = 0;
208
209 // Declare virtual type testers. 209 // Declare virtual type testers.
210 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } 210 #define DECLARE_PREDICATE(type) \
211 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) 211 bool Is##type() const { return opcode() == k##type; }
212 #undef DECLARE_DO 212 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
213 #undef DECLARE_PREDICATE
213 214
214 virtual bool IsControl() const { return false; } 215 virtual bool IsControl() const { return false; }
215 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } 216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { }
216 217
217 void set_environment(LEnvironment* env) { environment_ = env; } 218 void set_environment(LEnvironment* env) { environment_ = env; }
218 LEnvironment* environment() const { return environment_; } 219 LEnvironment* environment() const { return environment_; }
219 bool HasEnvironment() const { return environment_ != NULL; } 220 bool HasEnvironment() const { return environment_ != NULL; }
220 221
221 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } 222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
222 LPointerMap* pointer_map() const { return pointer_map_.get(); } 223 LPointerMap* pointer_map() const { return pointer_map_.get(); }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 449
449 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { 450 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
450 public: 451 public:
451 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") 452 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
452 }; 453 };
453 454
454 455
455 template<int I, int T> 456 template<int I, int T>
456 class LControlInstruction: public LTemplateInstruction<0, I, T> { 457 class LControlInstruction: public LTemplateInstruction<0, I, T> {
457 public: 458 public:
458 DECLARE_INSTRUCTION(ControlInstruction)
459 virtual bool IsControl() const { return true; } 459 virtual bool IsControl() const { return true; }
460 460
461 int true_block_id() const { return true_block_id_; } 461 int true_block_id() const { return true_block_id_; }
462 int false_block_id() const { return false_block_id_; } 462 int false_block_id() const { return false_block_id_; }
463 void SetBranchTargets(int true_block_id, int false_block_id) { 463 void SetBranchTargets(int true_block_id, int false_block_id) {
464 true_block_id_ = true_block_id; 464 true_block_id_ = true_block_id;
465 false_block_id_ = false_block_id; 465 false_block_id_ = false_block_id;
466 } 466 }
467 467
468 private: 468 private:
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { 1099 class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1100 public: 1100 public:
1101 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) 1101 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1102 : op_(op) { 1102 : op_(op) {
1103 inputs_[0] = left; 1103 inputs_[0] = left;
1104 inputs_[1] = right; 1104 inputs_[1] = right;
1105 } 1105 }
1106 1106
1107 Token::Value op() const { return op_; } 1107 Token::Value op() const { return op_; }
1108 1108
1109 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
Kevin Millikin (Chromium) 2011/04/19 12:20:30 Maybe add a comment here and below that DECLARE_CO
1109 virtual void CompileToNative(LCodeGen* generator); 1110 virtual void CompileToNative(LCodeGen* generator);
1110 virtual const char* Mnemonic() const; 1111 virtual const char* Mnemonic() const;
1111 1112
1112 private: 1113 private:
1113 Token::Value op_; 1114 Token::Value op_;
1114 }; 1115 };
1115 1116
1116 1117
1117 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { 1118 class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1118 public: 1119 public:
1119 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) 1120 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1120 : op_(op) { 1121 : op_(op) {
1121 inputs_[0] = left; 1122 inputs_[0] = left;
1122 inputs_[1] = right; 1123 inputs_[1] = right;
1123 } 1124 }
1124 1125
1126 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1125 virtual void CompileToNative(LCodeGen* generator); 1127 virtual void CompileToNative(LCodeGen* generator);
1126 virtual const char* Mnemonic() const; 1128 virtual const char* Mnemonic() const;
1127 1129
1128 Token::Value op() const { return op_; } 1130 Token::Value op() const { return op_; }
1129 1131
1130 private: 1132 private:
1131 Token::Value op_; 1133 Token::Value op_;
1132 }; 1134 };
1133 1135
1134 1136
(...skipping 1067 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 int argument_count_; 2204 int argument_count_;
2203 LAllocator* allocator_; 2205 LAllocator* allocator_;
2204 int position_; 2206 int position_;
2205 LInstruction* instruction_pending_deoptimization_environment_; 2207 LInstruction* instruction_pending_deoptimization_environment_;
2206 int pending_deoptimization_ast_id_; 2208 int pending_deoptimization_ast_id_;
2207 2209
2208 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); 2210 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2209 }; 2211 };
2210 2212
2211 #undef DECLARE_HYDROGEN_ACCESSOR 2213 #undef DECLARE_HYDROGEN_ACCESSOR
2212 #undef DECLARE_INSTRUCTION
2213 #undef DECLARE_CONCRETE_INSTRUCTION 2214 #undef DECLARE_CONCRETE_INSTRUCTION
2214 2215
2215 } } // namespace v8::internal 2216 } } // namespace v8::internal
2216 2217
2217 #endif // V8_ARM_LITHIUM_ARM_H_ 2218 #endif // V8_ARM_LITHIUM_ARM_H_
OLDNEW
« no previous file with comments | « no previous file | src/ia32/lithium-ia32.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698