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

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

Issue 975001: Use untagged int32 values in evaluation of side-effect free expressions. (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
« no previous file with comments | « src/ia32/virtual-frame-ia32.cc ('k') | src/rewriter.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 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 info = NumberInfo::Unknown()); 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::Uninitialized().ToInt()) 73 | NumberInfoField::encode(NumberInfo::Uninitialized().ToInt())
74 | IsUntaggedInt32Field::encode(false)
74 | DataField::encode(ConstantList()->length()); 75 | DataField::encode(ConstantList()->length());
75 ConstantList()->Add(value); 76 ConstantList()->Add(value);
76 } 77 }
77 78
78 // The copy constructor and assignment operators could each create a new 79 // The copy constructor and assignment operators could each create a new
79 // register reference. 80 // register reference.
80 inline Result(const Result& other); 81 inline Result(const Result& other);
81 82
82 inline Result& operator=(const Result& other); 83 inline Result& operator=(const Result& other);
83 84
(...skipping 21 matching lines...) Expand all
105 inline void set_number_info(NumberInfo info); 106 inline void set_number_info(NumberInfo info);
106 inline bool is_number() const; 107 inline bool is_number() const;
107 inline bool is_smi() const; 108 inline bool is_smi() const;
108 inline bool is_integer32() const; 109 inline bool is_integer32() const;
109 inline bool is_heap_number() const; 110 inline bool is_heap_number() const;
110 111
111 bool is_valid() const { return type() != INVALID; } 112 bool is_valid() const { return type() != INVALID; }
112 bool is_register() const { return type() == REGISTER; } 113 bool is_register() const { return type() == REGISTER; }
113 bool is_constant() const { return type() == CONSTANT; } 114 bool is_constant() const { return type() == CONSTANT; }
114 115
116 // An untagged int32 Result contains a signed int32 in a register
117 // or as a constant. These are only allowed in a side-effect-free
118 // int32 calculation, and if a non-int32 input shows up or an overflow
119 // occurs, we bail out and drop all the int32 values. Constants are
120 // not converted to int32 until they are loaded into a register.
121 bool is_untagged_int32() const {
122 return IsUntaggedInt32Field::decode(value_);
123 }
124 void set_untagged_int32(bool value) {
125 value_ &= ~IsUntaggedInt32Field::mask();
126 value_ |= IsUntaggedInt32Field::encode(value);
127 }
128
115 Register reg() const { 129 Register reg() const {
116 ASSERT(is_register()); 130 ASSERT(is_register());
117 uint32_t reg = DataField::decode(value_); 131 uint32_t reg = DataField::decode(value_);
118 Register result; 132 Register result;
119 result.code_ = reg; 133 result.code_ = reg;
120 return result; 134 return result;
121 } 135 }
122 136
123 Handle<Object> handle() const { 137 Handle<Object> handle() const {
124 ASSERT(type() == CONSTANT); 138 ASSERT(type() == CONSTANT);
125 return ConstantList()->at(DataField::decode(value_)); 139 return ConstantList()->at(DataField::decode(value_));
126 } 140 }
127 141
128 // Move this result to an arbitrary register. The register is not 142 // Move this result to an arbitrary register. The register is not
129 // necessarily spilled from the frame or even singly-referenced outside 143 // necessarily spilled from the frame or even singly-referenced outside
130 // it. 144 // it.
131 void ToRegister(); 145 void ToRegister();
132 146
133 // Move this result to a specified register. The register is spilled from 147 // Move this result to a specified register. The register is spilled from
134 // the frame, and the register is singly-referenced (by this result) 148 // the frame, and the register is singly-referenced (by this result)
135 // outside the frame. 149 // outside the frame.
136 void ToRegister(Register reg); 150 void ToRegister(Register reg);
137 151
138 private: 152 private:
139 uint32_t value_; 153 uint32_t value_;
140 154
141 class TypeField: public BitField<Type, 0, 2> {}; 155 class TypeField: public BitField<Type, 0, 2> {};
142 class NumberInfoField : public BitField<int, 2, 4> {}; 156 class NumberInfoField : public BitField<int, 2, 4> {};
143 class DataField: public BitField<uint32_t, 6, 32 - 6> {}; 157 class IsUntaggedInt32Field : public BitField<bool, 6, 1> {};
158 class DataField: public BitField<uint32_t, 7, 32 - 7> {};
144 159
145 inline void CopyTo(Result* destination) const; 160 inline void CopyTo(Result* destination) const;
146 161
147 friend class CodeGeneratorScope; 162 friend class CodeGeneratorScope;
148 }; 163 };
149 164
150 165
151 // ------------------------------------------------------------------------- 166 // -------------------------------------------------------------------------
152 // Register file 167 // Register file
153 // 168 //
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 305 }
291 306
292 private: 307 private:
293 CodeGenerator* cgen_; 308 CodeGenerator* cgen_;
294 RegisterFile registers_; 309 RegisterFile registers_;
295 }; 310 };
296 311
297 } } // namespace v8::internal 312 } } // namespace v8::internal
298 313
299 #endif // V8_REGISTER_ALLOCATOR_H_ 314 #endif // V8_REGISTER_ALLOCATOR_H_
OLDNEW
« no previous file with comments | « src/ia32/virtual-frame-ia32.cc ('k') | src/rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698