| 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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 masm_->int3(); | 96 masm_->int3(); |
| 97 } | 97 } |
| 98 #endif | 98 #endif |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 | 101 |
| 102 | 102 |
| 103 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { | 103 void FastCodeGenerator::VisitExpressionStatement(ExpressionStatement* stmt) { |
| 104 Comment cmnt(masm_, "[ ExpressionStatement"); | 104 Comment cmnt(masm_, "[ ExpressionStatement"); |
| 105 Visit(stmt->expression()); | 105 Visit(stmt->expression()); |
| 106 __ pop(rax); | |
| 107 } | 106 } |
| 108 | 107 |
| 109 | 108 |
| 110 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { | 109 void FastCodeGenerator::VisitReturnStatement(ReturnStatement* stmt) { |
| 111 Comment cmnt(masm_, "[ ReturnStatement"); | 110 Comment cmnt(masm_, "[ ReturnStatement"); |
| 112 Visit(stmt->expression()); | 111 Visit(stmt->expression()); |
| 113 __ pop(rax); | 112 __ pop(rax); |
| 114 __ RecordJSReturn(); | 113 __ RecordJSReturn(); |
| 115 // Do not use the leave instruction here because it is too short to | 114 // Do not use the leave instruction here because it is too short to |
| 116 // patch with the code required by the debugger. | 115 // patch with the code required by the debugger. |
| 117 __ movq(rsp, rbp); | 116 __ movq(rsp, rbp); |
| 118 __ pop(rbp); | 117 __ pop(rbp); |
| 119 __ ret((function_->scope()->num_parameters() + 1) * kPointerSize); | 118 __ ret((function_->scope()->num_parameters() + 1) * kPointerSize); |
| 120 #ifdef ENABLE_DEBUGGER_SUPPORT | 119 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 121 // Add padding that will be overwritten by a debugger breakpoint. We | 120 // Add padding that will be overwritten by a debugger breakpoint. We |
| 122 // have just generated "movq rsp, rbp; pop rbp; ret k" with length 7 | 121 // have just generated "movq rsp, rbp; pop rbp; ret k" with length 7 |
| 123 // (3 + 1 + 3). | 122 // (3 + 1 + 3). |
| 124 const int kPadding = Debug::kX64JSReturnSequenceLength - 7; | 123 const int kPadding = Debug::kX64JSReturnSequenceLength - 7; |
| 125 for (int i = 0; i < kPadding; ++i) { | 124 for (int i = 0; i < kPadding; ++i) { |
| 126 masm_->int3(); | 125 masm_->int3(); |
| 127 } | 126 } |
| 128 #endif | 127 #endif |
| 129 } | 128 } |
| 130 | 129 |
| 131 | 130 |
| 132 void FastCodeGenerator::VisitSlot(Slot* expr) { | 131 void FastCodeGenerator::VisitSlot(Slot* expr) { |
| 133 Comment cmnt(masm_, "[ Slot"); | 132 Comment cmnt(masm_, "[ Slot"); |
| 134 __ push(Operand(rbp, SlotOffset(expr))); | 133 if (expr->location().is_temporary()) { |
| 134 __ push(Operand(rbp, SlotOffset(expr))); |
| 135 } else { |
| 136 ASSERT(expr->location().is_nowhere()); |
| 137 } |
| 135 } | 138 } |
| 136 | 139 |
| 137 | 140 |
| 138 void FastCodeGenerator::VisitLiteral(Literal* expr) { | 141 void FastCodeGenerator::VisitLiteral(Literal* expr) { |
| 139 Comment cmnt(masm_, "[ Literal"); | 142 Comment cmnt(masm_, "[ Literal"); |
| 140 __ Push(expr->handle()); | 143 if (expr->location().is_temporary()) { |
| 144 __ Push(expr->handle()); |
| 145 } else { |
| 146 ASSERT(expr->location().is_nowhere()); |
| 147 } |
| 141 } | 148 } |
| 142 | 149 |
| 143 | 150 |
| 144 void FastCodeGenerator::VisitAssignment(Assignment* expr) { | 151 void FastCodeGenerator::VisitAssignment(Assignment* expr) { |
| 145 Comment cmnt(masm_, "[ Assignment"); | 152 Comment cmnt(masm_, "[ Assignment"); |
| 146 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); | 153 ASSERT(expr->op() == Token::ASSIGN || expr->op() == Token::INIT_VAR); |
| 147 | 154 |
| 148 Visit(expr->value()); | 155 Visit(expr->value()); |
| 149 | 156 |
| 150 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 157 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 151 ASSERT(var != NULL && var->slot() != NULL); | 158 ASSERT(var != NULL && var->slot() != NULL); |
| 152 __ movq(rax, Operand(rsp, 0)); | 159 |
| 153 __ movq(Operand(rbp, SlotOffset(var->slot())), rax); | 160 if (expr->location().is_temporary()) { |
| 161 __ movq(rax, Operand(rsp, 0)); |
| 162 __ movq(Operand(rbp, SlotOffset(var->slot())), rax); |
| 163 } else { |
| 164 ASSERT(expr->location().is_nowhere()); |
| 165 __ pop(Operand(rbp, SlotOffset(var->slot()))); |
| 166 } |
| 154 } | 167 } |
| 155 | 168 |
| 156 | 169 |
| 157 } } // namespace v8::internal | 170 } } // namespace v8::internal |
| OLD | NEW |