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

Side by Side Diff: src/frame-element.h

Issue 660095: Merge revision 3813 to 3930 from bleeding_edge to partial snapshots branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/partial_snapshots/
Patch Set: '' Created 10 years, 10 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/fast-codegen.cc ('k') | src/frame-element.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_FRAME_ELEMENT_H_ 28 #ifndef V8_FRAME_ELEMENT_H_
29 #define V8_FRAME_ELEMENT_H_ 29 #define V8_FRAME_ELEMENT_H_
30 30
31 #include "register-allocator-inl.h" 31 #include "number-info.h"
32 #include "macro-assembler.h"
32 33
33 namespace v8 { 34 namespace v8 {
34 namespace internal { 35 namespace internal {
35 36
36 // ------------------------------------------------------------------------- 37 // -------------------------------------------------------------------------
37 // Virtual frame elements 38 // Virtual frame elements
38 // 39 //
39 // The internal elements of the virtual frames. There are several kinds of 40 // The internal elements of the virtual frames. There are several kinds of
40 // elements: 41 // elements:
41 // * Invalid: elements that are uninitialized or not actually part 42 // * Invalid: elements that are uninitialized or not actually part
42 // of the virtual frame. They should not be read. 43 // of the virtual frame. They should not be read.
43 // * Memory: an element that resides in the actual frame. Its address is 44 // * Memory: an element that resides in the actual frame. Its address is
44 // given by its position in the virtual frame. 45 // given by its position in the virtual frame.
45 // * Register: an element that resides in a register. 46 // * Register: an element that resides in a register.
46 // * Constant: an element whose value is known at compile time. 47 // * Constant: an element whose value is known at compile time.
47 48
48 class FrameElement BASE_EMBEDDED { 49 class FrameElement BASE_EMBEDDED {
49 public: 50 public:
50 enum SyncFlag { 51 enum SyncFlag {
51 NOT_SYNCED, 52 NOT_SYNCED,
52 SYNCED 53 SYNCED
53 }; 54 };
54 55
56 inline NumberInfo::Type number_info() {
57 // Copied elements do not have number info. Instead
58 // we have to inspect their backing element in the frame.
59 ASSERT(!is_copy());
60 if (!is_constant()) return NumberInfoField::decode(value_);
61 Handle<Object> value = handle();
62 if (value->IsSmi()) return NumberInfo::kSmi;
63 if (value->IsHeapNumber()) return NumberInfo::kHeapNumber;
64 return NumberInfo::kUnknown;
65 }
66
67 inline void set_number_info(NumberInfo::Type info) {
68 // Copied elements do not have number info. Instead
69 // we have to inspect their backing element in the frame.
70 ASSERT(!is_copy());
71 value_ = value_ & ~NumberInfoField::mask();
72 value_ = value_ | NumberInfoField::encode(info);
73 }
74
55 // The default constructor creates an invalid frame element. 75 // The default constructor creates an invalid frame element.
56 FrameElement() { 76 FrameElement() {
57 value_ = TypeField::encode(INVALID) 77 value_ = TypeField::encode(INVALID)
58 | CopiedField::encode(false) 78 | CopiedField::encode(false)
59 | SyncedField::encode(false) 79 | SyncedField::encode(false)
80 | NumberInfoField::encode(NumberInfo::kUninitialized)
60 | DataField::encode(0); 81 | DataField::encode(0);
61 } 82 }
62 83
63 // Factory function to construct an invalid frame element. 84 // Factory function to construct an invalid frame element.
64 static FrameElement InvalidElement() { 85 static FrameElement InvalidElement() {
65 FrameElement result; 86 FrameElement result;
66 return result; 87 return result;
67 } 88 }
68 89
69 // Factory function to construct an in-memory frame element. 90 // Factory function to construct an in-memory frame element.
70 static FrameElement MemoryElement() { 91 static FrameElement MemoryElement(NumberInfo::Type info) {
71 FrameElement result(MEMORY, no_reg, SYNCED); 92 FrameElement result(MEMORY, no_reg, SYNCED, info);
72 return result; 93 return result;
73 } 94 }
74 95
75 // Factory function to construct an in-register frame element. 96 // Factory function to construct an in-register frame element.
76 static FrameElement RegisterElement(Register reg, 97 static FrameElement RegisterElement(Register reg,
77 SyncFlag is_synced) { 98 SyncFlag is_synced,
78 return FrameElement(REGISTER, reg, is_synced); 99 NumberInfo::Type info) {
100 return FrameElement(REGISTER, reg, is_synced, info);
79 } 101 }
80 102
81 // Factory function to construct a frame element whose value is known at 103 // Factory function to construct a frame element whose value is known at
82 // compile time. 104 // compile time.
83 static FrameElement ConstantElement(Handle<Object> value, 105 static FrameElement ConstantElement(Handle<Object> value,
84 SyncFlag is_synced) { 106 SyncFlag is_synced) {
85 FrameElement result(value, is_synced); 107 FrameElement result(value, is_synced);
86 return result; 108 return result;
87 } 109 }
88 110
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 private: 200 private:
179 enum Type { 201 enum Type {
180 INVALID, 202 INVALID,
181 MEMORY, 203 MEMORY,
182 REGISTER, 204 REGISTER,
183 CONSTANT, 205 CONSTANT,
184 COPY 206 COPY
185 }; 207 };
186 208
187 // Used to construct memory and register elements. 209 // Used to construct memory and register elements.
188 FrameElement(Type type, Register reg, SyncFlag is_synced) { 210 FrameElement(Type type,
211 Register reg,
212 SyncFlag is_synced,
213 NumberInfo::Type info) {
189 value_ = TypeField::encode(type) 214 value_ = TypeField::encode(type)
190 | CopiedField::encode(false) 215 | CopiedField::encode(false)
191 | SyncedField::encode(is_synced != NOT_SYNCED) 216 | SyncedField::encode(is_synced != NOT_SYNCED)
217 | NumberInfoField::encode(info)
192 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0); 218 | DataField::encode(reg.code_ > 0 ? reg.code_ : 0);
193 } 219 }
194 220
195 // Used to construct constant elements. 221 // Used to construct constant elements.
196 FrameElement(Handle<Object> value, SyncFlag is_synced) { 222 FrameElement(Handle<Object> value, SyncFlag is_synced) {
197 value_ = TypeField::encode(CONSTANT) 223 value_ = TypeField::encode(CONSTANT)
198 | CopiedField::encode(false) 224 | CopiedField::encode(false)
199 | SyncedField::encode(is_synced != NOT_SYNCED) 225 | SyncedField::encode(is_synced != NOT_SYNCED)
226 | NumberInfoField::encode(NumberInfo::kUninitialized)
200 | DataField::encode(ConstantList()->length()); 227 | DataField::encode(ConstantList()->length());
201 ConstantList()->Add(value); 228 ConstantList()->Add(value);
202 } 229 }
203 230
204 Type type() const { return TypeField::decode(value_); } 231 Type type() const { return TypeField::decode(value_); }
205 void set_type(Type type) { 232 void set_type(Type type) {
206 value_ = value_ & ~TypeField::mask(); 233 value_ = value_ & ~TypeField::mask();
207 value_ = value_ | TypeField::encode(type); 234 value_ = value_ | TypeField::encode(type);
208 } 235 }
209 236
210 void set_index(int new_index) { 237 void set_index(int new_index) {
211 ASSERT(is_copy()); 238 ASSERT(is_copy());
212 value_ = value_ & ~DataField::mask(); 239 value_ = value_ & ~DataField::mask();
213 value_ = value_ | DataField::encode(new_index); 240 value_ = value_ | DataField::encode(new_index);
214 } 241 }
215 242
216 void set_reg(Register new_reg) { 243 void set_reg(Register new_reg) {
217 ASSERT(is_register()); 244 ASSERT(is_register());
218 value_ = value_ & ~DataField::mask(); 245 value_ = value_ & ~DataField::mask();
219 value_ = value_ | DataField::encode(new_reg.code_); 246 value_ = value_ | DataField::encode(new_reg.code_);
220 } 247 }
221 248
222 // Encode type, copied, synced and data in one 32 bit integer. 249 // Encode type, copied, synced and data in one 32 bit integer.
223 uint32_t value_; 250 uint32_t value_;
224 251
225 class TypeField: public BitField<Type, 0, 3> {}; 252 class TypeField: public BitField<Type, 0, 3> {};
226 class CopiedField: public BitField<uint32_t, 3, 1> {}; 253 class CopiedField: public BitField<bool, 3, 1> {};
227 class SyncedField: public BitField<uint32_t, 4, 1> {}; 254 class SyncedField: public BitField<bool, 4, 1> {};
228 class DataField: public BitField<uint32_t, 5, 32 - 6> {}; 255 class NumberInfoField: public BitField<NumberInfo::Type, 5, 3> {};
256 class DataField: public BitField<uint32_t, 8, 32 - 8> {};
229 257
230 friend class VirtualFrame; 258 friend class VirtualFrame;
231 }; 259 };
232 260
233 } } // namespace v8::internal 261 } } // namespace v8::internal
234 262
235 #endif // V8_FRAME_ELEMENT_H_ 263 #endif // V8_FRAME_ELEMENT_H_
OLDNEW
« no previous file with comments | « src/fast-codegen.cc ('k') | src/frame-element.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698