| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 class VirtualFrame : public Malloced { | 59 class VirtualFrame : public Malloced { |
| 60 public: | 60 public: |
| 61 // Construct a virtual frame with the given code generator used to | 61 // Construct a virtual frame with the given code generator used to |
| 62 // generate code. | 62 // generate code. |
| 63 explicit VirtualFrame(CodeGenerator* cgen); | 63 explicit VirtualFrame(CodeGenerator* cgen); |
| 64 | 64 |
| 65 // Construct a virtual frame that is a clone of an existing one, initially | 65 // Construct a virtual frame that is a clone of an existing one, initially |
| 66 // with an identical state. | 66 // with an identical state. |
| 67 explicit VirtualFrame(VirtualFrame* original); | 67 explicit VirtualFrame(VirtualFrame* original); |
| 68 | 68 |
| 69 // The height of the virtual expression stack. Always non-negative. | 69 // The height of the virtual expression stack. |
| 70 int height() const { | 70 int height() const { |
| 71 return virtual_stack_pointer_ - expression_base_index() + 1; | 71 return virtual_stack_pointer_ - expression_base_index() + 1; |
| 72 } | 72 } |
| 73 | 73 |
| 74 // Add extra in-memory elements to the top of the frame without generating | 74 // Add extra in-memory elements to the top of the frame without generating |
| 75 // code. | 75 // code. |
| 76 void Adjust(int count); | 76 void Adjust(int count); |
| 77 | 77 |
| 78 // Forget frame elements without generating code. | 78 // Forget frame elements without generating code. |
| 79 void Forget(int count); | 79 void Forget(int count); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 97 | 97 |
| 98 // The current top of the expression stack as an assembly operand. | 98 // The current top of the expression stack as an assembly operand. |
| 99 Operand Top() const { return Operand(esp, 0); } | 99 Operand Top() const { return Operand(esp, 0); } |
| 100 | 100 |
| 101 // An element of the expression stack as an assembly operand. | 101 // An element of the expression stack as an assembly operand. |
| 102 Operand ElementAt(int index) const { | 102 Operand ElementAt(int index) const { |
| 103 return Operand(esp, index * kPointerSize); | 103 return Operand(esp, index * kPointerSize); |
| 104 } | 104 } |
| 105 | 105 |
| 106 // A frame-allocated local as an assembly operand. | 106 // A frame-allocated local as an assembly operand. |
| 107 Operand Local(int index) const { | 107 Operand LocalAt(int index) const { |
| 108 ASSERT(0 <= index); | 108 ASSERT(0 <= index); |
| 109 ASSERT(index < local_count_); | 109 ASSERT(index < local_count_); |
| 110 return Operand(ebp, kLocal0Offset - index * kPointerSize); | 110 return Operand(ebp, kLocal0Offset - index * kPointerSize); |
| 111 } | 111 } |
| 112 | 112 |
| 113 // The function frame slot. | 113 // The function frame slot. |
| 114 Operand Function() const { return Operand(ebp, kFunctionOffset); } | 114 Operand Function() const { return Operand(ebp, kFunctionOffset); } |
| 115 | 115 |
| 116 // The context frame slot. | 116 // The context frame slot. |
| 117 Operand Context() const { return Operand(ebp, kContextOffset); } | 117 Operand Context() const { return Operand(ebp, kContextOffset); } |
| 118 | 118 |
| 119 // A parameter as an assembly operand. | 119 // A parameter as an assembly operand. |
| 120 Operand Parameter(int index) const { | 120 Operand ParameterAt(int index) const { |
| 121 ASSERT(-1 <= index); | 121 ASSERT(-1 <= index); // -1 is the receiver. |
| 122 ASSERT(index < parameter_count_); | 122 ASSERT(index < parameter_count_); |
| 123 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); | 123 return Operand(ebp, (1 + parameter_count_ - index) * kPointerSize); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // The receiver frame slot. | 126 // The receiver frame slot. |
| 127 Operand Receiver() const { return Parameter(-1); } | 127 Operand Receiver() const { return ParameterAt(-1); } |
| 128 | 128 |
| 129 // Push a try-catch or try-finally handler on top of the virtual frame. | 129 // Push a try-catch or try-finally handler on top of the virtual frame. |
| 130 void PushTryHandler(HandlerType type); | 130 void PushTryHandler(HandlerType type); |
| 131 | 131 |
| 132 // Call a code stub, given the number of arguments it expects on (and | 132 // Call a code stub, given the number of arguments it expects on (and |
| 133 // removes from) the top of the physical frame. | 133 // removes from) the top of the physical frame. |
| 134 void CallStub(CodeStub* stub, int frame_arg_count); | 134 void CallStub(CodeStub* stub, int frame_arg_count); |
| 135 | 135 |
| 136 // Call the runtime, given the number of arguments expected on (and | 136 // Call the runtime, given the number of arguments expected on (and |
| 137 // removed from) the top of the physical frame. | 137 // removed from) the top of the physical frame. |
| 138 void CallRuntime(Runtime::Function* f, int frame_arg_count); | 138 void CallRuntime(Runtime::Function* f, int frame_arg_count); |
| 139 void CallRuntime(Runtime::FunctionId id, int frame_arg_count); | 139 void CallRuntime(Runtime::FunctionId id, int frame_arg_count); |
| 140 | 140 |
| 141 // Invoke a builtin, given the number of arguments it expects on (and | 141 // Invoke a builtin, given the number of arguments it expects on (and |
| 142 // removes from) the top of the physical frame. | 142 // removes from) the top of the physical frame. |
| 143 void InvokeBuiltin(Builtins::JavaScript id, | 143 void InvokeBuiltin(Builtins::JavaScript id, |
| 144 InvokeFlag flag, | 144 InvokeFlag flag, |
| 145 int frame_arg_count); | 145 int frame_arg_count); |
| 146 | 146 |
| 147 // Call into a JS code object, given the number of arguments it expects on | 147 // Call into a JS code object, given the number of arguments it expects on |
| 148 // (and removes from) the top of the physical frame. | 148 // (and removes from) the top of the physical frame. |
| 149 void CallCode(Handle<Code> ic, RelocInfo::Mode rmode, int frame_arg_count); | 149 void CallCodeObject(Handle<Code> ic, |
| 150 RelocInfo::Mode rmode, |
| 151 int frame_arg_count); |
| 150 | 152 |
| 151 // Drop a number of elements from the top of the expression stack. May | 153 // Drop a number of elements from the top of the expression stack. May |
| 152 // emit code to affect the physical frame. Does not clobber any registers | 154 // emit code to affect the physical frame. Does not clobber any registers |
| 153 // excepting possibly the stack pointer. | 155 // excepting possibly the stack pointer. |
| 154 void Drop(int count); | 156 void Drop(int count); |
| 155 | 157 |
| 156 // Drop one element. | 158 // Drop one element. |
| 157 void Drop(); | 159 void Drop(); |
| 158 | 160 |
| 159 // Pop and save an element from the top of the expression stack. May emit | 161 // Pop and save an element from the top of the expression stack. May emit |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 | 201 |
| 200 void AddElement(const Element& element) { | 202 void AddElement(const Element& element) { |
| 201 virtual_stack_pointer_++; | 203 virtual_stack_pointer_++; |
| 202 elements_.Add(element); | 204 elements_.Add(element); |
| 203 } | 205 } |
| 204 | 206 |
| 205 Element RemoveElement() { | 207 Element RemoveElement() { |
| 206 virtual_stack_pointer_--; | 208 virtual_stack_pointer_--; |
| 207 return elements_.RemoveLast(); | 209 return elements_.RemoveLast(); |
| 208 } | 210 } |
| 209 | |
| 210 // The JumpTarget class explicitly sets the height_ field of the expected | |
| 211 // frame at the actual return target. | |
| 212 friend class JumpTarget; | |
| 213 }; | 211 }; |
| 214 | 212 |
| 215 | 213 |
| 216 } } // namespace v8::internal | 214 } } // namespace v8::internal |
| 217 | 215 |
| 218 #endif // V8_VIRTUAL_FRAME_IA32_H_ | 216 #endif // V8_VIRTUAL_FRAME_IA32_H_ |
| OLD | NEW |