OLD | NEW |
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 // r1: preserved | 267 // r1: preserved |
268 // r2: preserved | 268 // r2: preserved |
269 | 269 |
270 // Drop the execution stack down to the frame pointer and restore | 270 // Drop the execution stack down to the frame pointer and restore |
271 // the caller frame pointer and return address. | 271 // the caller frame pointer and return address. |
272 mov(sp, fp); | 272 mov(sp, fp); |
273 ldm(ia_w, sp, fp.bit() | lr.bit()); | 273 ldm(ia_w, sp, fp.bit() | lr.bit()); |
274 } | 274 } |
275 | 275 |
276 | 276 |
277 void MacroAssembler::EnterExitFrame(ExitFrame::Mode mode) { | 277 void MacroAssembler::EnterExitFrame(StackFrame::Type type) { |
| 278 ASSERT(type == StackFrame::EXIT || type == StackFrame::EXIT_DEBUG); |
| 279 |
278 // Compute the argv pointer and keep it in a callee-saved register. | 280 // Compute the argv pointer and keep it in a callee-saved register. |
279 // r0 is argc. | 281 // r0 is argc. |
280 add(r6, sp, Operand(r0, LSL, kPointerSizeLog2)); | 282 add(r6, sp, Operand(r0, LSL, kPointerSizeLog2)); |
281 sub(r6, r6, Operand(kPointerSize)); | 283 sub(r6, r6, Operand(kPointerSize)); |
282 | 284 |
283 // Compute callee's stack pointer before making changes and save it as | 285 // Compute callee's stack pointer before making changes and save it as |
284 // ip register so that it is restored as sp register on exit, thereby | 286 // ip register so that it is restored as sp register on exit, thereby |
285 // popping the args. | 287 // popping the args. |
286 | 288 |
287 // ip = sp + kPointerSize * #args; | 289 // ip = sp + kPointerSize * #args; |
288 add(ip, sp, Operand(r0, LSL, kPointerSizeLog2)); | 290 add(ip, sp, Operand(r0, LSL, kPointerSizeLog2)); |
289 | 291 |
290 // Align the stack at this point. After this point we have 5 pushes, | 292 // Align the stack at this point. After this point we have 5 pushes, |
291 // so in fact we have to unalign here! See also the assert on the | 293 // so in fact we have to unalign here! See also the assert on the |
292 // alignment in AlignStack. | 294 // alignment in AlignStack. |
293 AlignStack(1); | 295 AlignStack(1); |
294 | 296 |
295 // Push in reverse order: caller_fp, sp_on_exit, and caller_pc. | 297 // Push in reverse order: caller_fp, sp_on_exit, and caller_pc. |
296 stm(db_w, sp, fp.bit() | ip.bit() | lr.bit()); | 298 stm(db_w, sp, fp.bit() | ip.bit() | lr.bit()); |
297 mov(fp, Operand(sp)); // setup new frame pointer | 299 mov(fp, Operand(sp)); // setup new frame pointer |
298 | 300 |
299 if (mode == ExitFrame::MODE_DEBUG) { | 301 // Push debug marker. |
300 mov(ip, Operand(0)); | 302 mov(ip, Operand(type == StackFrame::EXIT_DEBUG ? 1 : 0)); |
301 } else { | |
302 mov(ip, Operand(CodeObject())); | |
303 } | |
304 push(ip); | 303 push(ip); |
305 | 304 |
306 // Save the frame pointer and the context in top. | 305 // Save the frame pointer and the context in top. |
307 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); | 306 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); |
308 str(fp, MemOperand(ip)); | 307 str(fp, MemOperand(ip)); |
309 mov(ip, Operand(ExternalReference(Top::k_context_address))); | 308 mov(ip, Operand(ExternalReference(Top::k_context_address))); |
310 str(cp, MemOperand(ip)); | 309 str(cp, MemOperand(ip)); |
311 | 310 |
312 // Setup argc and the builtin function in callee-saved registers. | 311 // Setup argc and the builtin function in callee-saved registers. |
313 mov(r4, Operand(r0)); | 312 mov(r4, Operand(r0)); |
314 mov(r5, Operand(r1)); | 313 mov(r5, Operand(r1)); |
315 | 314 |
316 | 315 |
317 #ifdef ENABLE_DEBUGGER_SUPPORT | 316 #ifdef ENABLE_DEBUGGER_SUPPORT |
318 // Save the state of all registers to the stack from the memory | 317 // Save the state of all registers to the stack from the memory |
319 // location. This is needed to allow nested break points. | 318 // location. This is needed to allow nested break points. |
320 if (mode == ExitFrame::MODE_DEBUG) { | 319 if (type == StackFrame::EXIT_DEBUG) { |
321 // Use sp as base to push. | 320 // Use sp as base to push. |
322 CopyRegistersFromMemoryToStack(sp, kJSCallerSaved); | 321 CopyRegistersFromMemoryToStack(sp, kJSCallerSaved); |
323 } | 322 } |
324 #endif | 323 #endif |
325 } | 324 } |
326 | 325 |
327 | 326 |
328 void MacroAssembler::AlignStack(int offset) { | 327 void MacroAssembler::AlignStack(int offset) { |
329 #if defined(V8_HOST_ARCH_ARM) | 328 #if defined(V8_HOST_ARCH_ARM) |
330 // Running on the real platform. Use the alignment as mandated by the local | 329 // Running on the real platform. Use the alignment as mandated by the local |
(...skipping 11 matching lines...) Expand all Loading... |
342 if (activation_frame_alignment != kPointerSize) { | 341 if (activation_frame_alignment != kPointerSize) { |
343 // This code needs to be made more general if this assert doesn't hold. | 342 // This code needs to be made more general if this assert doesn't hold. |
344 ASSERT(activation_frame_alignment == 2 * kPointerSize); | 343 ASSERT(activation_frame_alignment == 2 * kPointerSize); |
345 mov(r7, Operand(Smi::FromInt(0))); | 344 mov(r7, Operand(Smi::FromInt(0))); |
346 tst(sp, Operand(activation_frame_alignment - offset)); | 345 tst(sp, Operand(activation_frame_alignment - offset)); |
347 push(r7, eq); // Conditional push instruction. | 346 push(r7, eq); // Conditional push instruction. |
348 } | 347 } |
349 } | 348 } |
350 | 349 |
351 | 350 |
352 void MacroAssembler::LeaveExitFrame(ExitFrame::Mode mode) { | 351 void MacroAssembler::LeaveExitFrame(StackFrame::Type type) { |
353 #ifdef ENABLE_DEBUGGER_SUPPORT | 352 #ifdef ENABLE_DEBUGGER_SUPPORT |
354 // Restore the memory copy of the registers by digging them out from | 353 // Restore the memory copy of the registers by digging them out from |
355 // the stack. This is needed to allow nested break points. | 354 // the stack. This is needed to allow nested break points. |
356 if (mode == ExitFrame::MODE_DEBUG) { | 355 if (type == StackFrame::EXIT_DEBUG) { |
357 // This code intentionally clobbers r2 and r3. | 356 // This code intentionally clobbers r2 and r3. |
358 const int kCallerSavedSize = kNumJSCallerSaved * kPointerSize; | 357 const int kCallerSavedSize = kNumJSCallerSaved * kPointerSize; |
359 const int kOffset = ExitFrameConstants::kCodeOffset - kCallerSavedSize; | 358 const int kOffset = ExitFrameConstants::kDebugMarkOffset - kCallerSavedSize; |
360 add(r3, fp, Operand(kOffset)); | 359 add(r3, fp, Operand(kOffset)); |
361 CopyRegistersFromStackToMemory(r3, r2, kJSCallerSaved); | 360 CopyRegistersFromStackToMemory(r3, r2, kJSCallerSaved); |
362 } | 361 } |
363 #endif | 362 #endif |
364 | 363 |
365 // Clear top frame. | 364 // Clear top frame. |
366 mov(r3, Operand(0)); | 365 mov(r3, Operand(0)); |
367 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); | 366 mov(ip, Operand(ExternalReference(Top::k_c_entry_fp_address))); |
368 str(r3, MemOperand(ip)); | 367 str(r3, MemOperand(ip)); |
369 | 368 |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1179 } | 1178 } |
1180 | 1179 |
1181 | 1180 |
1182 void CodePatcher::Emit(Address addr) { | 1181 void CodePatcher::Emit(Address addr) { |
1183 masm()->emit(reinterpret_cast<Instr>(addr)); | 1182 masm()->emit(reinterpret_cast<Instr>(addr)); |
1184 } | 1183 } |
1185 #endif // ENABLE_DEBUGGER_SUPPORT | 1184 #endif // ENABLE_DEBUGGER_SUPPORT |
1186 | 1185 |
1187 | 1186 |
1188 } } // namespace v8::internal | 1187 } } // namespace v8::internal |
OLD | NEW |