| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 11 matching lines...) Expand all Loading... |
| 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include "v8.h" | 28 #include "v8.h" |
| 29 | 29 |
| 30 #include "codegen-inl.h" | 30 #include "codegen-inl.h" |
| 31 #include "fast-codegen.h" | 31 #include "fast-codegen.h" |
| 32 // #include "scopes.h" | |
| 33 | 32 |
| 34 namespace v8 { | 33 namespace v8 { |
| 35 namespace internal { | 34 namespace internal { |
| 36 | 35 |
| 37 #define __ ACCESS_MASM(masm_) | 36 #define __ ACCESS_MASM(masm_) |
| 38 | 37 |
| 39 // Generate code for a JS function. On entry to the function the receiver | 38 // Generate code for a JS function. On entry to the function the receiver |
| 40 // and arguments have been pushed on the stack left to right, with the | 39 // and arguments have been pushed on the stack left to right, with the |
| 41 // return address on top of them. The actual argument count matches the | 40 // return address on top of them. The actual argument count matches the |
| 42 // formal parameter count expected by the function. | 41 // formal parameter count expected by the function. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 __ ret((function_->scope()->num_parameters() + 1) * kPointerSize); | 110 __ ret((function_->scope()->num_parameters() + 1) * kPointerSize); |
| 112 } | 111 } |
| 113 | 112 |
| 114 | 113 |
| 115 void FastCodeGenerator::VisitSlot(Slot* expr) { | 114 void FastCodeGenerator::VisitSlot(Slot* expr) { |
| 116 Comment cmnt(masm_, "[ Slot"); | 115 Comment cmnt(masm_, "[ Slot"); |
| 117 __ push(Operand(ebp, SlotOffset(expr))); | 116 __ push(Operand(ebp, SlotOffset(expr))); |
| 118 } | 117 } |
| 119 | 118 |
| 120 | 119 |
| 121 void FastCodeGenerator::VisitVariableProxy(VariableProxy* expr) { | |
| 122 Comment cmnt(masm_, "[ VariableProxy"); | |
| 123 Expression* rewrite = expr->var()->rewrite(); | |
| 124 ASSERT(rewrite != NULL); | |
| 125 Visit(rewrite); | |
| 126 } | |
| 127 | |
| 128 | |
| 129 void FastCodeGenerator::VisitLiteral(Literal* expr) { | 120 void FastCodeGenerator::VisitLiteral(Literal* expr) { |
| 130 Comment cmnt(masm_, "[ Literal"); | 121 Comment cmnt(masm_, "[ Literal"); |
| 131 __ push(Immediate(expr->handle())); | 122 __ push(Immediate(expr->handle())); |
| 132 } | 123 } |
| 133 | 124 |
| 134 | 125 |
| 135 void FastCodeGenerator::VisitAssignment(Assignment* expr) { | 126 void FastCodeGenerator::VisitAssignment(Assignment* expr) { |
| 136 Comment cmnt(masm_, "[ Assignment"); | 127 Comment cmnt(masm_, "[ Assignment"); |
| 137 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); | 128 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); |
| 138 | 129 |
| 139 Visit(expr->value()); | 130 Visit(expr->value()); |
| 140 | 131 |
| 141 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 132 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 142 ASSERT(var != NULL && var->slot() != NULL); | 133 ASSERT(var != NULL && var->slot() != NULL); |
| 143 __ mov(eax, Operand(esp, 0)); | 134 __ mov(eax, Operand(esp, 0)); |
| 144 __ mov(Operand(ebp, SlotOffset(var->slot())), eax); | 135 __ mov(Operand(ebp, SlotOffset(var->slot())), eax); |
| 145 } | 136 } |
| 146 | 137 |
| 147 | 138 |
| 148 } } // namespace v8::internal | 139 } } // namespace v8::internal |
| OLD | NEW |