| 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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 __ PushRoot(Heap::kUndefinedValueRootIndex); | 67 __ PushRoot(Heap::kUndefinedValueRootIndex); |
| 68 } | 68 } |
| 69 } else { | 69 } else { |
| 70 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); | 70 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); |
| 71 for (int i = 0; i < locals_count; i++) { | 71 for (int i = 0; i < locals_count; i++) { |
| 72 __ push(rdx); | 72 __ push(rdx); |
| 73 } | 73 } |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 // The current stack contains the context, function, and locals. |
| 78 // Keep track of the current height above the frame pointer, excluding |
| 79 // the expression stack. |
| 80 scope_stack_height_ = 2 + fun->scope()->num_stack_slots(); |
| 81 return_stack_height_ = scope_stack_height_; |
| 82 |
| 77 bool function_in_register = true; | 83 bool function_in_register = true; |
| 78 | 84 |
| 79 Variable* arguments = fun->scope()->arguments()->AsVariable(); | 85 Variable* arguments = fun->scope()->arguments()->AsVariable(); |
| 80 if (arguments != NULL) { | 86 if (arguments != NULL) { |
| 81 // Function uses arguments object. | 87 // Function uses arguments object. |
| 82 Comment cmnt(masm_, "[ Allocate arguments object"); | 88 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 83 __ push(rdi); | 89 __ push(rdi); |
| 84 // The receiver is just before the parameters on the caller's stack. | 90 // The receiver is just before the parameters on the caller's stack. |
| 85 __ lea(rdx, Operand(rbp, StandardFrameConstants::kCallerSPOffset + | 91 __ lea(rdx, Operand(rbp, StandardFrameConstants::kCallerSPOffset + |
| 86 fun->num_parameters() * kPointerSize)); | 92 fun->num_parameters() * kPointerSize)); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 { Comment cmnt(masm_, "[ return <undefined>;"); | 155 { Comment cmnt(masm_, "[ return <undefined>;"); |
| 150 // Emit a 'return undefined' in case control fell off the end of the body. | 156 // Emit a 'return undefined' in case control fell off the end of the body. |
| 151 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); | 157 __ LoadRoot(rax, Heap::kUndefinedValueRootIndex); |
| 152 EmitReturnSequence(function_->end_position()); | 158 EmitReturnSequence(function_->end_position()); |
| 153 } | 159 } |
| 154 } | 160 } |
| 155 | 161 |
| 156 | 162 |
| 157 void FastCodeGenerator::EmitReturnSequence(int position) { | 163 void FastCodeGenerator::EmitReturnSequence(int position) { |
| 158 Comment cmnt(masm_, "[ Return sequence"); | 164 Comment cmnt(masm_, "[ Return sequence"); |
| 159 if (return_label_.is_bound()) { | 165 if (return_label_ != &function_return_) { // Shadowed return |
| 160 __ jmp(&return_label_); | 166 if (scope_stack_height_ > return_stack_height_) { |
| 161 } else { | 167 __ addq(rsp, Immediate( |
| 162 __ bind(&return_label_); | 168 (scope_stack_height_ - return_stack_height_) * kPointerSize));} |
| 169 else { |
| 170 ASSERT(scope_stack_height_ == return_stack_height_); |
| 171 } |
| 172 __ jmp(return_label_); |
| 173 } else if (return_label_->is_bound()) { // Don't adjust stack for real return
. |
| 174 __ jmp(return_label_); |
| 175 } else { // Emit actual return sequence |
| 176 __ bind(return_label_); |
| 163 if (FLAG_trace) { | 177 if (FLAG_trace) { |
| 164 __ push(rax); | 178 __ push(rax); |
| 165 __ CallRuntime(Runtime::kTraceExit, 1); | 179 __ CallRuntime(Runtime::kTraceExit, 1); |
| 166 } | 180 } |
| 167 #ifdef DEBUG | 181 #ifdef DEBUG |
| 168 // Add a label for checking the size of the code used for returning. | 182 // Add a label for checking the size of the code used for returning. |
| 169 Label check_exit_codesize; | 183 Label check_exit_codesize; |
| 170 masm_->bind(&check_exit_codesize); | 184 masm_->bind(&check_exit_codesize); |
| 171 #endif | 185 #endif |
| 172 CodeGenerator::RecordPositions(masm_, position); | 186 CodeGenerator::RecordPositions(masm_, position); |
| (...skipping 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1548 true_label_ = saved_true; | 1562 true_label_ = saved_true; |
| 1549 false_label_ = saved_false; | 1563 false_label_ = saved_false; |
| 1550 // Convert current context to test context: End post-test code. | 1564 // Convert current context to test context: End post-test code. |
| 1551 } | 1565 } |
| 1552 | 1566 |
| 1553 | 1567 |
| 1554 #undef __ | 1568 #undef __ |
| 1555 | 1569 |
| 1556 | 1570 |
| 1557 } } // namespace v8::internal | 1571 } } // namespace v8::internal |
| OLD | NEW |