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

Side by Side Diff: src/compiler/instruction.h

Issue 803493002: revert r25736 (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/instruction.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COMPILER_INSTRUCTION_H_ 5 #ifndef V8_COMPILER_INSTRUCTION_H_
6 #define V8_COMPILER_INSTRUCTION_H_ 6 #define V8_COMPILER_INSTRUCTION_H_
7 7
8 #include <deque> 8 #include <deque>
9 #include <iosfwd> 9 #include <iosfwd>
10 #include <map> 10 #include <map>
(...skipping 21 matching lines...) Expand all
32 V(Constant, CONSTANT, 0) \ 32 V(Constant, CONSTANT, 0) \
33 V(Immediate, IMMEDIATE, 0) \ 33 V(Immediate, IMMEDIATE, 0) \
34 V(StackSlot, STACK_SLOT, 128) \ 34 V(StackSlot, STACK_SLOT, 128) \
35 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \ 35 V(DoubleStackSlot, DOUBLE_STACK_SLOT, 128) \
36 V(Register, REGISTER, RegisterConfiguration::kMaxGeneralRegisters) \ 36 V(Register, REGISTER, RegisterConfiguration::kMaxGeneralRegisters) \
37 V(DoubleRegister, DOUBLE_REGISTER, RegisterConfiguration::kMaxDoubleRegisters) 37 V(DoubleRegister, DOUBLE_REGISTER, RegisterConfiguration::kMaxDoubleRegisters)
38 38
39 class InstructionOperand : public ZoneObject { 39 class InstructionOperand : public ZoneObject {
40 public: 40 public:
41 enum Kind { 41 enum Kind {
42 INVALID,
42 UNALLOCATED, 43 UNALLOCATED,
43 CONSTANT, 44 CONSTANT,
44 IMMEDIATE, 45 IMMEDIATE,
45 STACK_SLOT, 46 STACK_SLOT,
46 DOUBLE_STACK_SLOT, 47 DOUBLE_STACK_SLOT,
47 REGISTER, 48 REGISTER,
48 DOUBLE_REGISTER 49 DOUBLE_REGISTER
49 }; 50 };
50 51
52 InstructionOperand() : value_(KindField::encode(INVALID)) {}
51 InstructionOperand(Kind kind, int index) { ConvertTo(kind, index); } 53 InstructionOperand(Kind kind, int index) { ConvertTo(kind, index); }
52 54
53 Kind kind() const { return KindField::decode(value_); } 55 Kind kind() const { return KindField::decode(value_); }
54 int index() const { return static_cast<int>(value_) >> KindField::kSize; } 56 int index() const { return static_cast<int>(value_) >> KindField::kSize; }
55 #define INSTRUCTION_OPERAND_PREDICATE(name, type, number) \ 57 #define INSTRUCTION_OPERAND_PREDICATE(name, type, number) \
56 bool Is##name() const { return kind() == type; } 58 bool Is##name() const { return kind() == type; }
57 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_PREDICATE) 59 INSTRUCTION_OPERAND_LIST(INSTRUCTION_OPERAND_PREDICATE)
58 INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED, 0) 60 INSTRUCTION_OPERAND_PREDICATE(Unallocated, UNALLOCATED, 0)
61 INSTRUCTION_OPERAND_PREDICATE(Ignored, INVALID, 0)
59 #undef INSTRUCTION_OPERAND_PREDICATE 62 #undef INSTRUCTION_OPERAND_PREDICATE
60 bool Equals(const InstructionOperand* other) const { 63 bool Equals(const InstructionOperand* other) const {
61 return value_ == other->value_; 64 return value_ == other->value_;
62 } 65 }
63 66
64 void ConvertTo(Kind kind, int index) { 67 void ConvertTo(Kind kind, int index) {
65 if (kind == REGISTER || kind == DOUBLE_REGISTER) DCHECK(index >= 0); 68 if (kind == REGISTER || kind == DOUBLE_REGISTER) DCHECK(index >= 0);
66 value_ = KindField::encode(kind); 69 value_ = KindField::encode(kind);
67 value_ |= index << KindField::kSize; 70 value_ |= index << KindField::kSize;
68 DCHECK(this->index() == index); 71 DCHECK(this->index() == index);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 // The gap resolver marks moves as "in-progress" by clearing the 284 // The gap resolver marks moves as "in-progress" by clearing the
282 // destination (but not the source). 285 // destination (but not the source).
283 bool IsPending() const { return destination_ == NULL && source_ != NULL; } 286 bool IsPending() const { return destination_ == NULL && source_ != NULL; }
284 287
285 // True if this move a move into the given destination operand. 288 // True if this move a move into the given destination operand.
286 bool Blocks(InstructionOperand* operand) const { 289 bool Blocks(InstructionOperand* operand) const {
287 return !IsEliminated() && source()->Equals(operand); 290 return !IsEliminated() && source()->Equals(operand);
288 } 291 }
289 292
290 // A move is redundant if it's been eliminated, if its source and 293 // A move is redundant if it's been eliminated, if its source and
291 // destination are the same, or if its destination is constant. 294 // destination are the same, or if its destination is unneeded or constant.
292 bool IsRedundant() const { 295 bool IsRedundant() const {
293 return IsEliminated() || source_->Equals(destination_) || 296 return IsEliminated() || source_->Equals(destination_) || IsIgnored() ||
294 (destination_ != NULL && destination_->IsConstant()); 297 (destination_ != NULL && destination_->IsConstant());
295 } 298 }
296 299
300 bool IsIgnored() const {
301 return destination_ != NULL && destination_->IsIgnored();
302 }
303
297 // We clear both operands to indicate move that's been eliminated. 304 // We clear both operands to indicate move that's been eliminated.
298 void Eliminate() { source_ = destination_ = NULL; } 305 void Eliminate() { source_ = destination_ = NULL; }
299 bool IsEliminated() const { 306 bool IsEliminated() const {
300 DCHECK(source_ != NULL || destination_ == NULL); 307 DCHECK(source_ != NULL || destination_ == NULL);
301 return source_ == NULL; 308 return source_ == NULL;
302 } 309 }
303 310
304 private: 311 private:
305 InstructionOperand* source_; 312 InstructionOperand* source_;
306 InstructionOperand* destination_; 313 InstructionOperand* destination_;
(...skipping 27 matching lines...) Expand all
334 DCHECK(op->kind() == kOperandKind); 341 DCHECK(op->kind() == kOperandKind);
335 return reinterpret_cast<const SubKindOperand*>(op); 342 return reinterpret_cast<const SubKindOperand*>(op);
336 } 343 }
337 344
338 static void SetUpCache(); 345 static void SetUpCache();
339 static void TearDownCache(); 346 static void TearDownCache();
340 347
341 private: 348 private:
342 static SubKindOperand* cache; 349 static SubKindOperand* cache;
343 350
344 SubKindOperand() : InstructionOperand(kOperandKind, 0) {} // For the caches. 351 SubKindOperand() : InstructionOperand() {}
345 explicit SubKindOperand(int index) 352 explicit SubKindOperand(int index)
346 : InstructionOperand(kOperandKind, index) {} 353 : InstructionOperand(kOperandKind, index) {}
347 }; 354 };
348 355
349 356
350 #define INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number) \ 357 #define INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number) \
351 typedef SubKindOperand<InstructionOperand::type, number> name##Operand; 358 typedef SubKindOperand<InstructionOperand::type, number> name##Operand;
352 INSTRUCTION_OPERAND_LIST(INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS) 359 INSTRUCTION_OPERAND_LIST(INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS)
353 #undef INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS 360 #undef INSTRUCTION_TYPEDEF_SUBKIND_OPERAND_CLASS
354 361
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 1092
1086 1093
1087 std::ostream& operator<<(std::ostream& os, 1094 std::ostream& operator<<(std::ostream& os,
1088 const PrintableInstructionSequence& code); 1095 const PrintableInstructionSequence& code);
1089 1096
1090 } // namespace compiler 1097 } // namespace compiler
1091 } // namespace internal 1098 } // namespace internal
1092 } // namespace v8 1099 } // namespace v8
1093 1100
1094 #endif // V8_COMPILER_INSTRUCTION_H_ 1101 #endif // V8_COMPILER_INSTRUCTION_H_
OLDNEW
« no previous file with comments | « src/compiler/graph-visualizer.cc ('k') | src/compiler/instruction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698