OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "code-stubs.h" | 9 #include "code-stubs.h" |
10 #include "codegen.h" | 10 #include "codegen.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 } | 191 } |
192 } | 192 } |
193 } | 193 } |
194 | 194 |
195 bool function_in_register = true; | 195 bool function_in_register = true; |
196 | 196 |
197 // Possibly allocate a local context. | 197 // Possibly allocate a local context. |
198 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 198 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
199 if (heap_slots > 0) { | 199 if (heap_slots > 0) { |
200 Comment cmnt(masm_, "[ Allocate context"); | 200 Comment cmnt(masm_, "[ Allocate context"); |
| 201 bool need_write_barrier = true; |
201 // Argument to NewContext is the function, which is still in edi. | 202 // Argument to NewContext is the function, which is still in edi. |
202 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 203 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
203 __ push(edi); | 204 __ push(edi); |
204 __ Push(info->scope()->GetScopeInfo()); | 205 __ Push(info->scope()->GetScopeInfo()); |
205 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2); | 206 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2); |
206 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 207 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
207 FastNewContextStub stub(isolate(), heap_slots); | 208 FastNewContextStub stub(isolate(), heap_slots); |
208 __ CallStub(&stub); | 209 __ CallStub(&stub); |
| 210 // Result of FastNewContextStub is always in new space. |
| 211 need_write_barrier = false; |
209 } else { | 212 } else { |
210 __ push(edi); | 213 __ push(edi); |
211 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); | 214 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); |
212 } | 215 } |
213 function_in_register = false; | 216 function_in_register = false; |
214 // Context is returned in eax. It replaces the context passed to us. | 217 // Context is returned in eax. It replaces the context passed to us. |
215 // It's saved in the stack and kept live in esi. | 218 // It's saved in the stack and kept live in esi. |
216 __ mov(esi, eax); | 219 __ mov(esi, eax); |
217 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); | 220 __ mov(Operand(ebp, StandardFrameConstants::kContextOffset), eax); |
218 | 221 |
219 // Copy parameters into context if necessary. | 222 // Copy parameters into context if necessary. |
220 int num_parameters = info->scope()->num_parameters(); | 223 int num_parameters = info->scope()->num_parameters(); |
221 for (int i = 0; i < num_parameters; i++) { | 224 for (int i = 0; i < num_parameters; i++) { |
222 Variable* var = scope()->parameter(i); | 225 Variable* var = scope()->parameter(i); |
223 if (var->IsContextSlot()) { | 226 if (var->IsContextSlot()) { |
224 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 227 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
225 (num_parameters - 1 - i) * kPointerSize; | 228 (num_parameters - 1 - i) * kPointerSize; |
226 // Load parameter from stack. | 229 // Load parameter from stack. |
227 __ mov(eax, Operand(ebp, parameter_offset)); | 230 __ mov(eax, Operand(ebp, parameter_offset)); |
228 // Store it in the context. | 231 // Store it in the context. |
229 int context_offset = Context::SlotOffset(var->index()); | 232 int context_offset = Context::SlotOffset(var->index()); |
230 __ mov(Operand(esi, context_offset), eax); | 233 __ mov(Operand(esi, context_offset), eax); |
231 // Update the write barrier. This clobbers eax and ebx. | 234 // Update the write barrier. This clobbers eax and ebx. |
232 __ RecordWriteContextSlot(esi, | 235 if (need_write_barrier) { |
233 context_offset, | 236 __ RecordWriteContextSlot(esi, |
234 eax, | 237 context_offset, |
235 ebx); | 238 eax, |
| 239 ebx); |
| 240 } else if (FLAG_debug_code) { |
| 241 Label done; |
| 242 __ JumpIfInNewSpace(esi, eax, &done, Label::kNear); |
| 243 __ Abort(kExpectedNewSpaceObject); |
| 244 __ bind(&done); |
| 245 } |
236 } | 246 } |
237 } | 247 } |
238 } | 248 } |
239 | 249 |
240 Variable* arguments = scope()->arguments(); | 250 Variable* arguments = scope()->arguments(); |
241 if (arguments != NULL) { | 251 if (arguments != NULL) { |
242 // Function uses arguments object. | 252 // Function uses arguments object. |
243 Comment cmnt(masm_, "[ Allocate arguments object"); | 253 Comment cmnt(masm_, "[ Allocate arguments object"); |
244 if (function_in_register) { | 254 if (function_in_register) { |
245 __ push(edi); | 255 __ push(edi); |
(...skipping 4540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4786 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), | 4796 ASSERT_EQ(isolate->builtins()->OsrAfterStackCheck()->entry(), |
4787 Assembler::target_address_at(call_target_address, | 4797 Assembler::target_address_at(call_target_address, |
4788 unoptimized_code)); | 4798 unoptimized_code)); |
4789 return OSR_AFTER_STACK_CHECK; | 4799 return OSR_AFTER_STACK_CHECK; |
4790 } | 4800 } |
4791 | 4801 |
4792 | 4802 |
4793 } } // namespace v8::internal | 4803 } } // namespace v8::internal |
4794 | 4804 |
4795 #endif // V8_TARGET_ARCH_X87 | 4805 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |