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

Side by Side Diff: src/x64/lithium-x64.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
« src/arm/lithium-arm.h ('K') | « src/ia32/lithium-ia32.h ('k') | no next file » | 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; } \
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 191
202 virtual ~LInstruction() { } 192 virtual ~LInstruction() { }
203 193
204 virtual void CompileToNative(LCodeGen* generator) = 0; 194 virtual void CompileToNative(LCodeGen* generator) = 0;
205 virtual const char* Mnemonic() const = 0; 195 virtual const char* Mnemonic() const = 0;
206 virtual void PrintTo(StringStream* stream); 196 virtual void PrintTo(StringStream* stream);
207 virtual void PrintDataTo(StringStream* stream) = 0; 197 virtual void PrintDataTo(StringStream* stream) = 0;
208 virtual void PrintOutputOperandTo(StringStream* stream) = 0; 198 virtual void PrintOutputOperandTo(StringStream* stream) = 0;
209 199
200 enum Opcode {
201 // Declare a unique enum value for each instruction.
202 #define DECLARE_OPCODE(type) k##type,
203 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE)
204 kNumberOfInstructions
205 #undef DECLARE_OPCODE
206 };
207
208 virtual Opcode opcode() const = 0;
209
210 // Declare virtual type testers. 210 // Declare virtual type testers.
211 #define DECLARE_DO(type) virtual bool Is##type() const { return false; } 211 #define DECLARE_PREDICATE(type) \
212 LITHIUM_ALL_INSTRUCTION_LIST(DECLARE_DO) 212 bool Is##type() const { return opcode() == k##type; }
213 #undef DECLARE_DO 213 LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE)
214 #undef DECLARE_PREDICATE
214 215
215 virtual bool IsControl() const { return false; } 216 virtual bool IsControl() const { return false; }
216 virtual void SetBranchTargets(int true_block_id, int false_block_id) { } 217 virtual void SetBranchTargets(int true_block_id, int false_block_id) { }
217 218
218 void set_environment(LEnvironment* env) { environment_ = env; } 219 void set_environment(LEnvironment* env) { environment_ = env; }
219 LEnvironment* environment() const { return environment_; } 220 LEnvironment* environment() const { return environment_; }
220 bool HasEnvironment() const { return environment_ != NULL; } 221 bool HasEnvironment() const { return environment_ != NULL; }
221 222
222 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } 223 void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); }
223 LPointerMap* pointer_map() const { return pointer_map_.get(); } 224 LPointerMap* pointer_map() const { return pointer_map_.get(); }
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 450
450 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { 451 class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> {
451 public: 452 public:
452 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") 453 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value")
453 }; 454 };
454 455
455 456
456 template<int I, int T> 457 template<int I, int T>
457 class LControlInstruction: public LTemplateInstruction<0, I, T> { 458 class LControlInstruction: public LTemplateInstruction<0, I, T> {
458 public: 459 public:
459 DECLARE_INSTRUCTION(ControlInstruction)
460 virtual bool IsControl() const { return true; } 460 virtual bool IsControl() const { return true; }
461 461
462 int true_block_id() const { return true_block_id_; } 462 int true_block_id() const { return true_block_id_; }
463 int false_block_id() const { return false_block_id_; } 463 int false_block_id() const { return false_block_id_; }
464 void SetBranchTargets(int true_block_id, int false_block_id) { 464 void SetBranchTargets(int true_block_id, int false_block_id) {
465 true_block_id_ = true_block_id; 465 true_block_id_ = true_block_id;
466 false_block_id_ = false_block_id; 466 false_block_id_ = false_block_id;
467 } 467 }
468 468
469 private: 469 private:
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 class LArithmeticD: public LTemplateInstruction<1, 2, 0> { 1085 class LArithmeticD: public LTemplateInstruction<1, 2, 0> {
1086 public: 1086 public:
1087 LArithmeticD(Token::Value op, LOperand* left, LOperand* right) 1087 LArithmeticD(Token::Value op, LOperand* left, LOperand* right)
1088 : op_(op) { 1088 : op_(op) {
1089 inputs_[0] = left; 1089 inputs_[0] = left;
1090 inputs_[1] = right; 1090 inputs_[1] = right;
1091 } 1091 }
1092 1092
1093 Token::Value op() const { return op_; } 1093 Token::Value op() const { return op_; }
1094 1094
1095 virtual Opcode opcode() const { return LInstruction::kArithmeticD; }
1095 virtual void CompileToNative(LCodeGen* generator); 1096 virtual void CompileToNative(LCodeGen* generator);
1096 virtual const char* Mnemonic() const; 1097 virtual const char* Mnemonic() const;
1097 1098
1098 private: 1099 private:
1099 Token::Value op_; 1100 Token::Value op_;
1100 }; 1101 };
1101 1102
1102 1103
1103 class LArithmeticT: public LTemplateInstruction<1, 2, 0> { 1104 class LArithmeticT: public LTemplateInstruction<1, 2, 0> {
1104 public: 1105 public:
1105 LArithmeticT(Token::Value op, LOperand* left, LOperand* right) 1106 LArithmeticT(Token::Value op, LOperand* left, LOperand* right)
1106 : op_(op) { 1107 : op_(op) {
1107 inputs_[0] = left; 1108 inputs_[0] = left;
1108 inputs_[1] = right; 1109 inputs_[1] = right;
1109 } 1110 }
1110 1111
1112 virtual Opcode opcode() const { return LInstruction::kArithmeticT; }
1111 virtual void CompileToNative(LCodeGen* generator); 1113 virtual void CompileToNative(LCodeGen* generator);
1112 virtual const char* Mnemonic() const; 1114 virtual const char* Mnemonic() const;
1113 1115
1114 Token::Value op() const { return op_; } 1116 Token::Value op() const { return op_; }
1115 1117
1116 private: 1118 private:
1117 Token::Value op_; 1119 Token::Value op_;
1118 }; 1120 };
1119 1121
1120 1122
(...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after
2184 int argument_count_; 2186 int argument_count_;
2185 LAllocator* allocator_; 2187 LAllocator* allocator_;
2186 int position_; 2188 int position_;
2187 LInstruction* instruction_pending_deoptimization_environment_; 2189 LInstruction* instruction_pending_deoptimization_environment_;
2188 int pending_deoptimization_ast_id_; 2190 int pending_deoptimization_ast_id_;
2189 2191
2190 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); 2192 DISALLOW_COPY_AND_ASSIGN(LChunkBuilder);
2191 }; 2193 };
2192 2194
2193 #undef DECLARE_HYDROGEN_ACCESSOR 2195 #undef DECLARE_HYDROGEN_ACCESSOR
2194 #undef DECLARE_INSTRUCTION
2195 #undef DECLARE_CONCRETE_INSTRUCTION 2196 #undef DECLARE_CONCRETE_INSTRUCTION
2196 2197
2197 } } // namespace v8::int 2198 } } // namespace v8::int
2198 2199
2199 #endif // V8_X64_LITHIUM_X64_H_ 2200 #endif // V8_X64_LITHIUM_X64_H_
OLDNEW
« src/arm/lithium-arm.h ('K') | « src/ia32/lithium-ia32.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698