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

Unified Diff: src/virtual-frame-ia32.h

Issue 9328: Initial (stub) port of jump targets to the ARM platform.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/toiger/
Patch Set: '' Created 12 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: src/virtual-frame-ia32.h
===================================================================
--- src/virtual-frame-ia32.h (revision 0)
+++ src/virtual-frame-ia32.h (revision 0)
@@ -0,0 +1,176 @@
+// Copyright 2008 the V8 project authors. All rights reserved.
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// * Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// * Redistributions in binary form must reproduce the above
+// copyright notice, this list of conditions and the following
+// disclaimer in the documentation and/or other materials provided
+// with the distribution.
+// * Neither the name of Google Inc. nor the names of its
+// contributors may be used to endorse or promote products derived
+// from this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+#ifndef V8_VIRTUAL_FRAME_IA32_H_
+#define V8_VIRTUAL_FRAME_IA32_H_
+
+#include "macro-assembler.h"
+
+namespace v8 { namespace internal {
+
+// -------------------------------------------------------------------------
+// Virtual frames
+//
+// The virtual frame is an abstraction of the physical stack frame. It
+// encapsulates the parameters, frame-allocated locals, and the expression
+// stack. It supports push/pop operations on the expression stack, as well
+// as random access to the expression stack elements, locals, and
+// parameters.
+
+class VirtualFrame : public Malloced {
+ public:
+ // Construct a virtual frame with the given code generator used to
+ // generate code.
+ explicit VirtualFrame(CodeGenerator* cgen);
+
+ // Construct a virtual frame that is a clone of an existing one, initially
+ // with an identical state.
+ explicit VirtualFrame(VirtualFrame* original);
+
+ // The height of the virtual expression stack. Always non-negative.
+ int height() const { return height_; }
+
+ // Forget elements from the top of the expression stack. This is
+ // used when the stack pointer is manually lowered to pop values
+ // left by statements (eg, for...in, try...finally) that have been
+ // escaped from.
+ 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.
+ void MergeTo(VirtualFrame* expected);
+
+ // Emit code for the physical JS entry and exit frame sequences. After
+ // calling Enter, the virtual frame is ready for use; and after calling
+ // Exit it should not be used. Note that Enter does not allocate space in
+ // the physical frame for storing frame-allocated locals.
+ void Enter();
+ void Exit();
+
+ // 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();
+
+ // The current top of the expression stack as an assembly operand.
+ Operand Top() const { return Operand(esp, 0); }
+
+ // An element of the expression stack as an assembly operand.
+ Operand Element(int index) const {
+ return Operand(esp, index * kPointerSize);
+ }
+
+ // A frame-allocated local as an assembly operand.
+ Operand Local(int index) const {
+ ASSERT(0 <= index && index < frame_local_count_);
+ return Operand(ebp, kLocal0Offset - index * kPointerSize);
+ }
+
+ // The function frame slot.
+ Operand Function() const { return Operand(ebp, kFunctionOffset); }
+
+ // The context frame slot.
+ Operand Context() const { return Operand(ebp, kContextOffset); }
+
+ // A parameter as an assembly operand.
+ Operand Parameter(int index) const {
+ ASSERT(-1 <= index && index < parameter_count_);
+ return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize);
+ }
+
+ // The receiver frame slot.
+ Operand Receiver() const { return Parameter(-1); }
+
+ // Push a try-catch or try-finally handler on top of the virtual frame.
+ inline 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.
+ inline 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.
+ inline void CallRuntime(Runtime::Function* f, int frame_arg_count);
+ inline 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.
+ inline void InvokeBuiltin(Builtins::JavaScript id,
+ InvokeFlag flag,
+ 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.
+ inline void CallCode(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);
+
+ // 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();
+
+ // Pop and save an element from the top of the expression stack. May emit
+ // code.
+ inline void Pop(Register reg);
+ inline void Pop(Operand operand);
+
+ // Push an element on top of the expression stack. May emit code.
+ inline void Push(Register reg);
+ inline void Push(Operand operand);
+ inline void Push(Immediate immediate);
+
+ 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_;
+
+ // The number of frame-allocated locals and parameters respectively.
+ int frame_local_count_;
+ int parameter_count_;
+
+ // The height of the expression stack.
+ int height_;
+
+ // The JumpTarget class explicitly sets the height_ field of the expected
+ // frame at the actual return target.
+ friend class JumpTarget;
+};
+
+
+} } // namespace v8::internal
+
+#endif // V8_VIRTUAL_FRAME_IA32_H_

Powered by Google App Engine
This is Rietveld 408576698