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

Side by Side Diff: src/register-allocator.h

Issue 668151: Make more use of the NumberInfo data.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 years, 9 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 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 enum Type { 58 enum Type {
59 INVALID, 59 INVALID,
60 REGISTER, 60 REGISTER,
61 CONSTANT 61 CONSTANT
62 }; 62 };
63 63
64 // Construct an invalid result. 64 // Construct an invalid result.
65 Result() { invalidate(); } 65 Result() { invalidate(); }
66 66
67 // Construct a register Result. 67 // Construct a register Result.
68 explicit Result(Register reg, NumberInfo::Type info = NumberInfo::kUnknown); 68 explicit Result(Register reg, NumberInfo info = NumberInfo::Unknown());
69 69
70 // Construct a Result whose value is a compile-time constant. 70 // Construct a Result whose value is a compile-time constant.
71 explicit Result(Handle<Object> value) { 71 explicit Result(Handle<Object> value) {
72 value_ = TypeField::encode(CONSTANT) 72 value_ = TypeField::encode(CONSTANT)
73 | NumberInfoField::encode(NumberInfo::kUninitialized) 73 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt())
74 | DataField::encode(ConstantList()->length()); 74 | DataField::encode(ConstantList()->length());
75 ConstantList()->Add(value); 75 ConstantList()->Add(value);
76 } 76 }
77 77
78 // The copy constructor and assignment operators could each create a new 78 // The copy constructor and assignment operators could each create a new
79 // register reference. 79 // register reference.
80 inline Result(const Result& other); 80 inline Result(const Result& other);
81 81
82 inline Result& operator=(const Result& other); 82 inline Result& operator=(const Result& other);
83 83
(...skipping 10 matching lines...) Expand all
94 static void ClearConstantList() { 94 static void ClearConstantList() {
95 ConstantList()->Clear(); 95 ConstantList()->Clear();
96 } 96 }
97 97
98 inline void Unuse(); 98 inline void Unuse();
99 99
100 Type type() const { return TypeField::decode(value_); } 100 Type type() const { return TypeField::decode(value_); }
101 101
102 void invalidate() { value_ = TypeField::encode(INVALID); } 102 void invalidate() { value_ = TypeField::encode(INVALID); }
103 103
104 NumberInfo::Type number_info(); 104 NumberInfo number_info() const;
fschneider 2010/03/05 15:01:07 Maybe make this an inline function?
105 void set_number_info(NumberInfo::Type info); 105 void set_number_info(NumberInfo info);
fschneider 2010/03/05 15:01:07 Maybe make this an inline function?
106 bool is_number() { 106 bool is_number() const { return number_info().IsNumber(); }
107 return (number_info() & NumberInfo::kNumber) != 0; 107 bool is_smi() const { return number_info().IsSmi(); }
108 } 108 bool is_integer32() const { return number_info().IsInteger32(); }
109 bool is_smi() { return number_info() == NumberInfo::kSmi; } 109 bool is_heap_number() const { return number_info().IsHeapNumber(); }
110 bool is_heap_number() { return number_info() == NumberInfo::kHeapNumber; }
111 110
112 bool is_valid() const { return type() != INVALID; } 111 bool is_valid() const { return type() != INVALID; }
113 bool is_register() const { return type() == REGISTER; } 112 bool is_register() const { return type() == REGISTER; }
114 bool is_constant() const { return type() == CONSTANT; } 113 bool is_constant() const { return type() == CONSTANT; }
115 114
116 Register reg() const { 115 Register reg() const {
117 ASSERT(is_register()); 116 ASSERT(is_register());
118 uint32_t reg = DataField::decode(value_); 117 uint32_t reg = DataField::decode(value_);
119 Register result; 118 Register result;
120 result.code_ = reg; 119 result.code_ = reg;
(...skipping 12 matching lines...) Expand all
133 132
134 // Move this result to a specified register. The register is spilled from 133 // Move this result to a specified register. The register is spilled from
135 // the frame, and the register is singly-referenced (by this result) 134 // the frame, and the register is singly-referenced (by this result)
136 // outside the frame. 135 // outside the frame.
137 void ToRegister(Register reg); 136 void ToRegister(Register reg);
138 137
139 private: 138 private:
140 uint32_t value_; 139 uint32_t value_;
141 140
142 class TypeField: public BitField<Type, 0, 2> {}; 141 class TypeField: public BitField<Type, 0, 2> {};
143 class NumberInfoField : public BitField<NumberInfo::Type, 2, 3> {}; 142 class NumberInfoField : public BitField<int, 2, 4> {};
144 class DataField: public BitField<uint32_t, 5, 32 - 5> {}; 143 class DataField: public BitField<uint32_t, 6, 32 - 6> {};
145 144
146 inline void CopyTo(Result* destination) const; 145 inline void CopyTo(Result* destination) const;
147 146
148 friend class CodeGeneratorScope; 147 friend class CodeGeneratorScope;
149 }; 148 };
150 149
151 150
152 // ------------------------------------------------------------------------- 151 // -------------------------------------------------------------------------
153 // Register file 152 // Register file
154 // 153 //
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } 290 }
292 291
293 private: 292 private:
294 CodeGenerator* cgen_; 293 CodeGenerator* cgen_;
295 RegisterFile registers_; 294 RegisterFile registers_;
296 }; 295 };
297 296
298 } } // namespace v8::internal 297 } } // namespace v8::internal
299 298
300 #endif // V8_REGISTER_ALLOCATOR_H_ 299 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698