| Index: src/virtual-frame-arm.h
|
| ===================================================================
|
| --- src/virtual-frame-arm.h (revision 737)
|
| +++ src/virtual-frame-arm.h (working copy)
|
| @@ -33,6 +33,21 @@
|
| namespace v8 { namespace internal {
|
|
|
| // -------------------------------------------------------------------------
|
| +// Virtual frame elements
|
| +//
|
| +// The internal elements of the virtual frames. Elements are (currently) of
|
| +// only one kind, in-memory. Their actual location is given by their
|
| +// position in the virtual frame.
|
| +
|
| +class Element BASE_EMBEDDED {
|
| + public:
|
| + Element() {}
|
| +
|
| + bool matches(const Element& other) { return true; }
|
| +};
|
| +
|
| +
|
| +// -------------------------------------------------------------------------
|
| // Virtual frames
|
| //
|
| // The virtual frame is an abstraction of the physical stack frame. It
|
| @@ -41,7 +56,7 @@
|
| // as random access to the expression stack elements, locals, and
|
| // parameters.
|
|
|
| -class VirtualFrame {
|
| +class VirtualFrame : public Malloced{
|
| public:
|
| // Construct a virtual frame with the given code generator used to
|
| // generate code.
|
| @@ -51,6 +66,17 @@
|
| // with an identical state.
|
| explicit VirtualFrame(VirtualFrame* original);
|
|
|
| + int height() const {
|
| + return virtual_stack_pointer_ - expression_base_index() + 1;
|
| + }
|
| +
|
| + // Add extra in-memory elements to the top of the frame without generating
|
| + // code.
|
| + void Adjust(int count);
|
| +
|
| + // Forget frame elements without generating code.
|
| + void Forget(int count);
|
| +
|
| // 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.
|
| @@ -66,19 +92,20 @@
|
| // Allocate and initialize the frame-allocated locals. The number of
|
| // locals is known from the frame's code generator's state (specifically
|
| // its scope). As a side effect, code may be emitted.
|
| - void AllocateLocals();
|
| + void AllocateStackSlots(int count);
|
|
|
| // The current top of the expression stack as an assembly operand.
|
| MemOperand Top() const { return MemOperand(sp, 0); }
|
|
|
| // An element of the expression stack as an assembly operand.
|
| - MemOperand Element(int index) const {
|
| + MemOperand ElementAt(int index) const {
|
| return MemOperand(sp, index * kPointerSize);
|
| }
|
|
|
| // A frame-allocated local as an assembly operand.
|
| - MemOperand Local(int index) const {
|
| - ASSERT(0 <= index && index < frame_local_count_);
|
| + MemOperand LocalAt(int index) const {
|
| + ASSERT(0 <= index);
|
| + ASSERT(index < local_count_);
|
| return MemOperand(fp, kLocal0Offset - index * kPointerSize);
|
| }
|
|
|
| @@ -89,38 +116,92 @@
|
| MemOperand Context() const { return MemOperand(fp, kContextOffset); }
|
|
|
| // A parameter as an assembly operand.
|
| - MemOperand Parameter(int index) const {
|
| + MemOperand ParameterAt(int index) const {
|
| // Index -1 corresponds to the receiver.
|
| ASSERT(-1 <= index && index <= parameter_count_);
|
| return MemOperand(fp, (1 + parameter_count_ - index) * kPointerSize);
|
| }
|
|
|
| + // Push a try-catch or try-finally handler on top of the virtual frame.
|
| + void PushTryHandler(HandlerType type);
|
| +
|
| + // Call a code stub, given the number of arguments it expects on (and
|
| + // removes from) the top of the physical frame.
|
| + void CallStub(CodeStub* stub, int frame_arg_count);
|
| +
|
| + // Call the runtime, given the number of arguments expected on (and
|
| + // removed from) the top of the physical frame.
|
| + void CallRuntime(Runtime::Function* f, int frame_arg_count);
|
| + void CallRuntime(Runtime::FunctionId id, int frame_arg_count);
|
| +
|
| + // Invoke a builtin, given the number of arguments it expects on (and
|
| + // removes from) the top of the physical frame.
|
| + void InvokeBuiltin(Builtins::JavaScript id,
|
| + InvokeJSFlags flags,
|
| + int frame_arg_count);
|
| +
|
| + // Call into a JS code object, given the number of arguments it expects on
|
| + // (and removes from) the top of the physical frame.
|
| + void CallCodeObject(Handle<Code> ic,
|
| + RelocInfo::Mode rmode,
|
| + int frame_arg_count);
|
| +
|
| // Drop a number of elements from the top of the expression stack. May
|
| - // emit code to effect the physical frame.
|
| - inline void Drop(int count);
|
| + // emit code to affect the physical frame. Does not clobber any registers
|
| + // excepting possibly the stack pointer.
|
| + void Drop(int count);
|
|
|
| - // Pop and discard an element from the top of the expression stack.
|
| - // Specifically does not clobber any registers excepting possibly the
|
| - // stack pointer.
|
| - inline void Pop();
|
| + // Drop one element.
|
| + void Drop();
|
|
|
| // Pop and save an element from the top of the expression stack. May emit
|
| // code.
|
| - inline void Pop(Register reg);
|
| + void Pop(Register reg);
|
|
|
| // Push an element on top of the expression stack. May emit code.
|
| - inline void Push(Register reg);
|
| + void Push(Register reg);
|
|
|
| private:
|
| static const int kLocal0Offset = JavaScriptFrameConstants::kLocal0Offset;
|
| static const int kFunctionOffset = JavaScriptFrameConstants::kFunctionOffset;
|
| static const int kContextOffset = StandardFrameConstants::kContextOffset;
|
|
|
| + static const int kHandlerSize = StackHandlerConstants::kSize / kPointerSize;
|
| +
|
| MacroAssembler* masm_;
|
|
|
| + List<Element> elements_;
|
| +
|
| + // The virtual stack pointer is the index of the top element of the stack.
|
| + int virtual_stack_pointer_;
|
| +
|
| + int virtual_frame_pointer_;
|
| +
|
| // The number of frame-allocated locals and parameters respectively.
|
| - int frame_local_count_;
|
| int parameter_count_;
|
| + int local_count_;
|
| +
|
| + // The index of the first parameter. The receiver lies below the first
|
| + // parameter.
|
| + int param0_index() const { return 1; }
|
| +
|
| + // The index of the first local. Between the parameters and the locals
|
| + // lie the return address, the saved frame pointer, the context, and the
|
| + // function.
|
| + int local0_index() const { return param0_index() + parameter_count_ + 4; }
|
| +
|
| + // The index of the base of the expression stack.
|
| + int expression_base_index() const { return local0_index() + local_count_; }
|
| +
|
| + void AddElement(const Element& element) {
|
| + virtual_stack_pointer_++;
|
| + elements_.Add(element);
|
| + }
|
| +
|
| + Element RemoveElement() {
|
| + virtual_stack_pointer_--;
|
| + return elements_.RemoveLast();
|
| + }
|
| };
|
|
|
|
|
|
|