Chromium Code Reviews| Index: src/virtual-frame-ia32.h |
| =================================================================== |
| --- src/virtual-frame-ia32.h (revision 787) |
| +++ src/virtual-frame-ia32.h (working copy) |
| @@ -39,11 +39,41 @@ |
| // only one kind, in-memory. Their actual location is given by their |
| // position in the virtual frame. |
| -class Element BASE_EMBEDDED { |
| +class FrameElement BASE_EMBEDDED { |
| public: |
| - Element() {} |
| + enum Type { MEMORY = 0, CONSTANT = 2}; |
| - bool matches(const Element& other) { return true; } |
| + FrameElement() : type_(MEMORY) {} |
| + |
| + explicit FrameElement(Handle<Object> value) : type_(CONSTANT | 0x1) { |
| + data_.handle_ = value.location(); |
| + } |
| + |
| + Type type() const { return static_cast<Type>(type_ & ~0x1); } |
|
William Hesse
2008/11/18 16:37:34
Name the dirty flag mask. Unless you are also sto
Kevin Millikin (Chromium)
2008/11/18 19:12:06
OK.
|
| + |
| + bool is_dirty() const { return type_ & 0x1; } |
| + |
| + void set_dirty() { |
| + ASSERT(type_ != MEMORY); |
| + type_ = type_ | 0x1; |
| + } |
| + |
| + void clear_dirty() { |
| + ASSERT(type_ != MEMORY); |
| + type_ = type_ & 0x1; |
| + } |
| + |
| + Handle<Object> handle() const { return Handle<Object>(data_.handle_); } |
|
William Hesse
2008/11/18 16:37:34
Put asserts here to assert it is a type that has h
Kevin Millikin (Chromium)
2008/11/18 19:12:06
OK.
|
| + |
| + private: |
| + // The element's type and a dirty bit in the low-order bit. The dirty bit |
| + // can be cleared for non-memory elements to indicate that the element |
| + // agrees with the value in memory in the actual frame. |
| + int type_; |
| + |
| + union { |
| + Object** handle_; |
| + } data_; |
|
William Hesse
2008/11/18 16:37:34
ASSERT( sizeof data_ == sizeof what? )
|
| }; |
| @@ -58,12 +88,10 @@ |
| class VirtualFrame : public Malloced { |
| public: |
| - // Construct a virtual frame with the given code generator used to |
| - // generate code. |
| + // Construct an initial virtual frame on entry to a JS function. |
| explicit VirtualFrame(CodeGenerator* cgen); |
| - // Construct a virtual frame that is a clone of an existing one, initially |
| - // with an identical state. |
| + // Construct a virtual frame as a clone of an existing one. |
| explicit VirtualFrame(VirtualFrame* original); |
| // The height of the virtual expression stack. |
| @@ -71,13 +99,22 @@ |
| return elements_.length() - expression_base_index(); |
| } |
| - // Add extra in-memory elements to the top of the frame without generating |
| - // code. |
| + // Add extra in-memory elements to the top of the frame to match an actual |
| + // frame (eg, the frame after an exception handler is pushed). No code is |
| + // emitted. |
| void Adjust(int count); |
| - // Forget frame elements without generating code. |
| + // Forget elements from the top of the frame to match an actual frame (eg, |
| + // the frame after a runtime call). No code is emitted. |
| void Forget(int count); |
| + // Spill all values from the frame to memory. |
| + void SpillAll(); |
| + |
| + // Ensure that this frame is in a state where an arbitrary frame of the |
| + // right size could be merged to it. May emit code. |
| + void EnsureMergable(); |
| + |
| // Make this virtual frame have a state identical to an expected virtual |
| // frame. As a side effect, code may be emitted to make this frame match |
| // the expected one. |
| @@ -158,10 +195,10 @@ |
| // Drop one element. |
| void Drop(); |
| - // Pop and save an element from the top of the expression stack. May emit |
| - // code. |
| - void Pop(Register reg); |
| - void Pop(Operand operand); |
| + // Pop and save an element from the top of the expression stack and emit a |
| + // corresponding pop instruction. |
| + void EmitPop(Register reg); |
| + void EmitPop(Operand operand); |
| // Push an element on top of the expression stack and emit a corresponding |
| // push instruction. |
| @@ -170,6 +207,9 @@ |
| void EmitPush(Immediate immediate); |
| private: |
| + // An illegal index into the virtual frame. |
| + static const int kIllegalIndex = -1; |
| + |
| static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset; |
| static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset; |
| static const int kContextOffset = StandardFrameConstants::kContextOffset; |
| @@ -178,11 +218,17 @@ |
| MacroAssembler* masm_; |
| - List<Element> elements_; |
| + List<FrameElement> elements_; |
| int parameter_count_; |
| int local_count_; |
| + // The index of the element that is at the processor's stack pointer |
| + // (the esp register). |
| + int stack_pointer_; |
| + |
| + // The index of the element that is at the processor's frame pointer |
| + // (the ebp register). |
| int frame_pointer_; |
| // The index of the first parameter. The receiver lies below the first |
| @@ -196,6 +242,16 @@ |
| // The index of the base of the expression stack. |
| int expression_base_index() const { return local0_index() + local_count_; } |
| + |
| + // Convert a frame index into a frame pointer relative offset into the |
| + // actual stack. |
| + int fp_relative(int index) const { |
| + return (frame_pointer_ - index) * kPointerSize; |
| + } |
| + |
| + // Spill the topmost elements of the frame to memory (eg, they are the |
| + // arguments to a call) and all registers. |
| + void PrepareCall(int count); |
|
William Hesse
2008/11/18 16:37:34
PrepareForCall?
Kevin Millikin (Chromium)
2008/11/18 19:12:06
OK.
|
| }; |