OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 __ movq(args.GetReceiverOperand(), kScratchRegister); | 145 __ movq(args.GetReceiverOperand(), kScratchRegister); |
146 __ bind(&ok); | 146 __ bind(&ok); |
147 } | 147 } |
148 | 148 |
149 // Open a frame scope to indicate that there is a frame on the stack. The | 149 // Open a frame scope to indicate that there is a frame on the stack. The |
150 // MANUAL indicates that the scope shouldn't actually generate code to set up | 150 // MANUAL indicates that the scope shouldn't actually generate code to set up |
151 // the frame (that is done below). | 151 // the frame (that is done below). |
152 FrameScope frame_scope(masm_, StackFrame::MANUAL); | 152 FrameScope frame_scope(masm_, StackFrame::MANUAL); |
153 | 153 |
154 info->set_prologue_offset(masm_->pc_offset()); | 154 info->set_prologue_offset(masm_->pc_offset()); |
155 __ push(rbp); // Caller's frame pointer. | 155 { |
156 __ movq(rbp, rsp); | 156 PredictableCodeSizeScope predictible_code_size_scope( |
157 __ push(rsi); // Callee's context. | 157 masm_, kNoCodeAgeSequenceLength); |
158 __ push(rdi); // Callee's JS Function. | 158 if (FLAG_optimize_for_size && FLAG_age_code) { |
| 159 // Pre-age the code. |
| 160 __ Call(isolate()->builtins()->MarkCodeAsExecutedOnce(), |
| 161 RelocInfo::CODE_AGE_SEQUENCE); |
| 162 __ Nop(kNoCodeAgeSequenceLength - Assembler::kShortCallInstructionLength); |
| 163 } else { |
| 164 __ push(rbp); // Caller's frame pointer. |
| 165 __ movq(rbp, rsp); |
| 166 __ push(rsi); // Callee's context. |
| 167 __ push(rdi); // Callee's JS Function. |
| 168 } |
| 169 } |
159 info->AddNoFrameRange(0, masm_->pc_offset()); | 170 info->AddNoFrameRange(0, masm_->pc_offset()); |
160 | 171 |
161 { Comment cmnt(masm_, "[ Allocate locals"); | 172 { Comment cmnt(masm_, "[ Allocate locals"); |
162 int locals_count = info->scope()->num_stack_slots(); | 173 int locals_count = info->scope()->num_stack_slots(); |
163 // Generators allocate locals, if any, in context slots. | 174 // Generators allocate locals, if any, in context slots. |
164 ASSERT(!info->function()->is_generator() || locals_count == 0); | 175 ASSERT(!info->function()->is_generator() || locals_count == 0); |
165 if (locals_count == 1) { | 176 if (locals_count == 1) { |
166 __ PushRoot(Heap::kUndefinedValueRootIndex); | 177 __ PushRoot(Heap::kUndefinedValueRootIndex); |
167 } else if (locals_count > 1) { | 178 } else if (locals_count > 1) { |
168 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); | 179 __ LoadRoot(rdx, Heap::kUndefinedValueRootIndex); |
169 for (int i = 0; i < locals_count; i++) { | 180 for (int i = 0; i < locals_count; i++) { |
170 __ push(rdx); | 181 __ push(rdx); |
171 } | 182 } |
172 } | 183 } |
173 } | 184 } |
174 | |
175 bool function_in_register = true; | 185 bool function_in_register = true; |
176 | 186 |
177 // Possibly allocate a local context. | 187 // Possibly allocate a local context. |
178 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 188 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
179 if (heap_slots > 0) { | 189 if (heap_slots > 0) { |
180 Comment cmnt(masm_, "[ Allocate context"); | 190 Comment cmnt(masm_, "[ Allocate context"); |
181 // Argument to NewContext is the function, which is still in rdi. | 191 // Argument to NewContext is the function, which is still in rdi. |
182 __ push(rdi); | 192 __ push(rdi); |
183 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 193 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
184 __ Push(info->scope()->GetScopeInfo()); | 194 __ Push(info->scope()->GetScopeInfo()); |
185 __ CallRuntime(Runtime::kNewGlobalContext, 2); | 195 __ CallRuntime(Runtime::kNewGlobalContext, 2); |
186 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 196 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
187 FastNewContextStub stub(heap_slots); | 197 FastNewContextStub stub(heap_slots); |
188 __ CallStub(&stub); | 198 __ CallStub(&stub); |
189 } else { | 199 } else { |
190 __ CallRuntime(Runtime::kNewFunctionContext, 1); | 200 __ CallRuntime(Runtime::kNewFunctionContext, 1); |
191 } | 201 } |
192 function_in_register = false; | 202 function_in_register = false; |
| 203 |
193 // Context is returned in both rax and rsi. It replaces the context | 204 // Context is returned in both rax and rsi. It replaces the context |
194 // passed to us. It's saved in the stack and kept live in rsi. | 205 // passed to us. It's saved in the stack and kept live in rsi. |
195 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); | 206 __ movq(Operand(rbp, StandardFrameConstants::kContextOffset), rsi); |
196 | 207 |
197 // Copy any necessary parameters into the context. | 208 // Copy any necessary parameters into the context. |
198 int num_parameters = info->scope()->num_parameters(); | 209 int num_parameters = info->scope()->num_parameters(); |
199 for (int i = 0; i < num_parameters; i++) { | 210 for (int i = 0; i < num_parameters; i++) { |
200 Variable* var = scope()->parameter(i); | 211 Variable* var = scope()->parameter(i); |
201 if (var->IsContextSlot()) { | 212 if (var->IsContextSlot()) { |
202 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 213 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
(...skipping 4744 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4947 | 4958 |
4948 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4959 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4949 Assembler::target_address_at(call_target_address)); | 4960 Assembler::target_address_at(call_target_address)); |
4950 return OSR_AFTER_STACK_CHECK; | 4961 return OSR_AFTER_STACK_CHECK; |
4951 } | 4962 } |
4952 | 4963 |
4953 | 4964 |
4954 } } // namespace v8::internal | 4965 } } // namespace v8::internal |
4955 | 4966 |
4956 #endif // V8_TARGET_ARCH_X64 | 4967 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |