| 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_ARM | 7 #if V8_TARGET_ARCH_ARM |
| 8 | 8 |
| 9 #include "code-stubs.h" | 9 #include "code-stubs.h" |
| 10 #include "codegen.h" | 10 #include "codegen.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 } | 205 } |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool function_in_register = true; | 208 bool function_in_register = true; |
| 209 | 209 |
| 210 // Possibly allocate a local context. | 210 // Possibly allocate a local context. |
| 211 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; | 211 int heap_slots = info->scope()->num_heap_slots() - Context::MIN_CONTEXT_SLOTS; |
| 212 if (heap_slots > 0) { | 212 if (heap_slots > 0) { |
| 213 // Argument to NewContext is the function, which is still in r1. | 213 // Argument to NewContext is the function, which is still in r1. |
| 214 Comment cmnt(masm_, "[ Allocate context"); | 214 Comment cmnt(masm_, "[ Allocate context"); |
| 215 bool need_write_barrier = true; |
| 215 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { | 216 if (FLAG_harmony_scoping && info->scope()->is_global_scope()) { |
| 216 __ push(r1); | 217 __ push(r1); |
| 217 __ Push(info->scope()->GetScopeInfo()); | 218 __ Push(info->scope()->GetScopeInfo()); |
| 218 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2); | 219 __ CallRuntime(Runtime::kHiddenNewGlobalContext, 2); |
| 219 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { | 220 } else if (heap_slots <= FastNewContextStub::kMaximumSlots) { |
| 220 FastNewContextStub stub(isolate(), heap_slots); | 221 FastNewContextStub stub(isolate(), heap_slots); |
| 221 __ CallStub(&stub); | 222 __ CallStub(&stub); |
| 223 // Result of FastNewContextStub is always in new space. |
| 224 need_write_barrier = false; |
| 222 } else { | 225 } else { |
| 223 __ push(r1); | 226 __ push(r1); |
| 224 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); | 227 __ CallRuntime(Runtime::kHiddenNewFunctionContext, 1); |
| 225 } | 228 } |
| 226 function_in_register = false; | 229 function_in_register = false; |
| 227 // Context is returned in r0. It replaces the context passed to us. | 230 // Context is returned in r0. It replaces the context passed to us. |
| 228 // It's saved in the stack and kept live in cp. | 231 // It's saved in the stack and kept live in cp. |
| 229 __ mov(cp, r0); | 232 __ mov(cp, r0); |
| 230 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 233 __ str(r0, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 231 // Copy any necessary parameters into the context. | 234 // Copy any necessary parameters into the context. |
| 232 int num_parameters = info->scope()->num_parameters(); | 235 int num_parameters = info->scope()->num_parameters(); |
| 233 for (int i = 0; i < num_parameters; i++) { | 236 for (int i = 0; i < num_parameters; i++) { |
| 234 Variable* var = scope()->parameter(i); | 237 Variable* var = scope()->parameter(i); |
| 235 if (var->IsContextSlot()) { | 238 if (var->IsContextSlot()) { |
| 236 int parameter_offset = StandardFrameConstants::kCallerSPOffset + | 239 int parameter_offset = StandardFrameConstants::kCallerSPOffset + |
| 237 (num_parameters - 1 - i) * kPointerSize; | 240 (num_parameters - 1 - i) * kPointerSize; |
| 238 // Load parameter from stack. | 241 // Load parameter from stack. |
| 239 __ ldr(r0, MemOperand(fp, parameter_offset)); | 242 __ ldr(r0, MemOperand(fp, parameter_offset)); |
| 240 // Store it in the context. | 243 // Store it in the context. |
| 241 MemOperand target = ContextOperand(cp, var->index()); | 244 MemOperand target = ContextOperand(cp, var->index()); |
| 242 __ str(r0, target); | 245 __ str(r0, target); |
| 243 | 246 |
| 244 // Update the write barrier. | 247 // Update the write barrier. |
| 245 __ RecordWriteContextSlot( | 248 if (need_write_barrier) { |
| 246 cp, target.offset(), r0, r3, kLRHasBeenSaved, kDontSaveFPRegs); | 249 __ RecordWriteContextSlot( |
| 250 cp, target.offset(), r0, r3, kLRHasBeenSaved, kDontSaveFPRegs); |
| 251 } else if (FLAG_debug_code) { |
| 252 Label done; |
| 253 __ JumpIfInNewSpace(cp, r0, &done); |
| 254 __ Abort(kExpectedNewSpaceObject); |
| 255 __ bind(&done); |
| 256 } |
| 247 } | 257 } |
| 248 } | 258 } |
| 249 } | 259 } |
| 250 | 260 |
| 251 Variable* arguments = scope()->arguments(); | 261 Variable* arguments = scope()->arguments(); |
| 252 if (arguments != NULL) { | 262 if (arguments != NULL) { |
| 253 // Function uses arguments object. | 263 // Function uses arguments object. |
| 254 Comment cmnt(masm_, "[ Allocate arguments object"); | 264 Comment cmnt(masm_, "[ Allocate arguments object"); |
| 255 if (!function_in_register) { | 265 if (!function_in_register) { |
| 256 // Load this again, if it's used by the local context below. | 266 // Load this again, if it's used by the local context below. |
| (...skipping 4564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4821 | 4831 |
| 4822 ASSERT(interrupt_address == | 4832 ASSERT(interrupt_address == |
| 4823 isolate->builtins()->OsrAfterStackCheck()->entry()); | 4833 isolate->builtins()->OsrAfterStackCheck()->entry()); |
| 4824 return OSR_AFTER_STACK_CHECK; | 4834 return OSR_AFTER_STACK_CHECK; |
| 4825 } | 4835 } |
| 4826 | 4836 |
| 4827 | 4837 |
| 4828 } } // namespace v8::internal | 4838 } } // namespace v8::internal |
| 4829 | 4839 |
| 4830 #endif // V8_TARGET_ARCH_ARM | 4840 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |