Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 23 matching lines...) Expand all Loading... | |
| 34 | 34 |
| 35 // ------------------------------------------------------------------------- | 35 // ------------------------------------------------------------------------- |
| 36 // Virtual frame elements | 36 // Virtual frame elements |
| 37 // | 37 // |
| 38 // The internal elements of the virtual frames. Elements are (currently) of | 38 // The internal elements of the virtual frames. Elements are (currently) of |
| 39 // only one kind, in-memory. Their actual location is given by their | 39 // only one kind, in-memory. Their actual location is given by their |
| 40 // position in the virtual frame. | 40 // position in the virtual frame. |
| 41 | 41 |
| 42 class FrameElement BASE_EMBEDDED { | 42 class FrameElement BASE_EMBEDDED { |
| 43 public: | 43 public: |
| 44 enum Type { MEMORY, CONSTANT, LAST_TYPE = CONSTANT }; | 44 enum Type { MEMORY, REGISTER, CONSTANT, LAST_TYPE = CONSTANT }; |
| 45 | 45 |
| 46 FrameElement() : type_(MEMORY) {} | 46 FrameElement() : type_(MEMORY) {} |
| 47 | 47 |
| 48 explicit FrameElement(Register reg) : type_(REGISTER | kDirtyBit) { | |
| 49 data_.reg_ = reg; | |
| 50 } | |
| 51 | |
| 48 explicit FrameElement(Handle<Object> value) : type_(CONSTANT | kDirtyBit) { | 52 explicit FrameElement(Handle<Object> value) : type_(CONSTANT | kDirtyBit) { |
| 49 data_.handle_ = value.location(); | 53 data_.handle_ = value.location(); |
| 50 } | 54 } |
| 51 | 55 |
| 52 Type type() const { return static_cast<Type>(type_ & kTypeMask); } | |
| 53 | |
| 54 bool is_dirty() const { | 56 bool is_dirty() const { |
| 55 return (type_ & kDirtyBit) != 0; | 57 return (type_ & kDirtyBit) != 0; |
| 56 } | 58 } |
| 57 | 59 |
| 58 void set_dirty() { | 60 void set_dirty() { |
| 59 ASSERT(type() != MEMORY); | 61 ASSERT(type() != MEMORY); |
| 60 type_ = type_ | kDirtyBit; | 62 type_ = type_ | kDirtyBit; |
| 61 } | 63 } |
| 62 | 64 |
| 63 void clear_dirty() { | 65 void clear_dirty() { |
| 64 ASSERT(type() != MEMORY); | 66 ASSERT(type() != MEMORY); |
| 65 type_ = type_ & ~kDirtyBit; | 67 type_ = type_ & ~kDirtyBit; |
| 66 } | 68 } |
| 67 | 69 |
| 70 bool is_spilled() const { return type() == MEMORY; } | |
| 71 bool is_register() const { return type() == REGISTER; } | |
| 72 bool is_constant() const { return type() == CONSTANT; } | |
|
William Hesse
2008/11/19 15:05:36
If is_spilled() is only true when type is MEMORY,
iposva
2008/11/20 05:49:35
Should there be an is_synched() accessor to make t
Kevin Millikin (Chromium)
2008/11/20 08:28:03
Maybe it's best to rename is_spilled to something
| |
| 73 | |
| 74 Register reg() const { | |
| 75 ASSERT(type() == REGISTER); | |
| 76 return data_.reg_; | |
| 77 } | |
| 78 | |
| 68 Handle<Object> handle() const { | 79 Handle<Object> handle() const { |
| 69 ASSERT(type() == CONSTANT); | 80 ASSERT(type() == CONSTANT); |
| 70 return Handle<Object>(data_.handle_); | 81 return Handle<Object>(data_.handle_); |
| 71 } | 82 } |
| 72 | 83 |
| 73 private: | 84 private: |
|
iposva
2008/11/20 05:49:35
C++ style guide suggests this order:
- Typedefs an
Kevin Millikin (Chromium)
2008/11/20 08:28:03
It seems like we often have data members first in
| |
| 74 static const int kDirtyBit = 1 << 8; | 85 static const int kDirtyBit = 1 << 8; |
|
iposva
2008/11/20 05:49:35
As I said in my other comments. You probably reall
| |
| 75 static const int kTypeMask = kDirtyBit - 1; | 86 static const int kTypeMask = kDirtyBit - 1; |
| 76 | 87 |
| 77 STATIC_ASSERT((kDirtyBit > LAST_TYPE)); | 88 STATIC_ASSERT(kDirtyBit > LAST_TYPE); |
| 78 | 89 |
| 79 // The element's type and a dirty bit. The dirty bit can be cleared | 90 // The element's type and a dirty bit. The dirty bit can be cleared |
| 80 // for non-memory elements to indicate that the element agrees with | 91 // for non-memory elements to indicate that the element agrees with |
| 81 // the value in memory in the actual frame. | 92 // the value in memory in the actual frame. |
| 82 int type_; | 93 int type_; |
| 83 | 94 |
| 84 union { | 95 union { |
| 96 Register reg_; | |
| 85 Object** handle_; | 97 Object** handle_; |
| 86 } data_; | 98 } data_; |
| 99 | |
| 100 Type type() const { return static_cast<Type>(type_ & kTypeMask); } | |
|
William Hesse
2008/11/19 15:05:36
Will code constructors only be able to access the
Kevin Millikin (Chromium)
2008/11/20 08:28:03
I decided not to expose the type (in fact, the enu
| |
| 87 }; | 101 }; |
| 88 | 102 |
| 89 | 103 |
| 90 // ------------------------------------------------------------------------- | 104 // ------------------------------------------------------------------------- |
| 91 // Virtual frames | 105 // Virtual frames |
| 92 // | 106 // |
| 93 // The virtual frame is an abstraction of the physical stack frame. It | 107 // The virtual frame is an abstraction of the physical stack frame. It |
| 94 // encapsulates the parameters, frame-allocated locals, and the expression | 108 // encapsulates the parameters, frame-allocated locals, and the expression |
| 95 // stack. It supports push/pop operations on the expression stack, as well | 109 // stack. It supports push/pop operations on the expression stack, as well |
| 96 // as random access to the expression stack elements, locals, and | 110 // as random access to the expression stack elements, locals, and |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 | 266 |
| 253 // The index of the base of the expression stack. | 267 // The index of the base of the expression stack. |
| 254 int expression_base_index() const { return local0_index() + local_count_; } | 268 int expression_base_index() const { return local0_index() + local_count_; } |
| 255 | 269 |
| 256 // Convert a frame index into a frame pointer relative offset into the | 270 // Convert a frame index into a frame pointer relative offset into the |
| 257 // actual stack. | 271 // actual stack. |
| 258 int fp_relative(int index) const { | 272 int fp_relative(int index) const { |
| 259 return (frame_pointer_ - index) * kPointerSize; | 273 return (frame_pointer_ - index) * kPointerSize; |
| 260 } | 274 } |
| 261 | 275 |
| 276 // Sync the element at a particular index---write it to memory if | |
| 277 // necessary, but do not free any associated register or forget its value | |
| 278 // if constant. Space should have already been allocated in the actual | |
| 279 // frame for all the elements below this one (at least). | |
|
iposva
2008/11/20 05:49:35
Not just the space should be allocated, but all th
Kevin Millikin (Chromium)
2008/11/20 08:28:03
I agree that "sync" vs. "spill" is fuzzy. The poi
| |
| 280 void SyncElementAt(int index); | |
| 281 | |
| 282 // Spill the element at a particular index---write it to memory if | |
| 283 // necessary, free any associated register, and forget its value if | |
| 284 // constant. Space should have already been allocated in the actual frame | |
| 285 // for all the elements below this one (at least). | |
| 286 void SpillElementAt(int index); | |
|
William Hesse
2008/11/19 15:05:36
OK, this answers my question about different terms
| |
| 287 | |
| 262 // Spill the topmost elements of the frame to memory (eg, they are the | 288 // Spill the topmost elements of the frame to memory (eg, they are the |
| 263 // arguments to a call) and all registers. | 289 // arguments to a call) and all registers. |
| 264 void PrepareForCall(int count); | 290 void PrepareForCall(int count); |
| 265 }; | 291 }; |
| 266 | 292 |
| 267 | 293 |
| 268 } } // namespace v8::internal | 294 } } // namespace v8::internal |
| 269 | 295 |
| 270 #endif // V8_VIRTUAL_FRAME_IA32_H_ | 296 #endif // V8_VIRTUAL_FRAME_IA32_H_ |
| OLD | NEW |