18b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch// Copyright 2011 the V8 project authors. All rights reserved. 2a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Redistribution and use in source and binary forms, with or without 3a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// modification, are permitted provided that the following conditions are 4a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// met: 5a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 6a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions of source code must retain the above copyright 7a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// notice, this list of conditions and the following disclaimer. 8a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Redistributions in binary form must reproduce the above 9a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// copyright notice, this list of conditions and the following 10a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// disclaimer in the documentation and/or other materials provided 11a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// with the distribution. 12a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// * Neither the name of Google Inc. nor the names of its 13a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// contributors may be used to endorse or promote products derived 14a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// from this software without specific prior written permission. 15a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// 16a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 28a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "v8.h" 29a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 30f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke#if defined(V8_TARGET_ARCH_ARM) 31f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 328b112d2025046f85ef7f6be087c6129c872ebad2Ben Murdoch#include "codegen.h" 33a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#include "debug.h" 34a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 35a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace v8 { 36a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blocknamespace internal { 37a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 38a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef ENABLE_DEBUGGER_SUPPORT 39a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockbool BreakLocationIterator::IsDebugBreakAtReturn() { 40a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block return Debug::IsDebugBreakAtReturn(rinfo()); 41a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 42a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 43a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 44a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid BreakLocationIterator::SetDebugBreakAtReturn() { 45a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Patch the code changing the return from JS function sequence from 46a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // mov sp, fp 47a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ldmia sp!, {fp, lr} 48a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // add sp, sp, #4 49a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // bx lr 50a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // to a call to the debug break return code. 516ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // #if USE_BLX 526ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // ldr ip, [pc, #0] 536ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // blx ip 546ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // #else 55a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // mov lr, pc 56a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ldr pc, [pc, #-4] 576ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // #endif 58a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // <debug break return code entry point address> 59a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // bktp 0 607f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions); 616ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#ifdef USE_BLX 626ded16be15dd865a9b21ea304d5273c8be299c87Steve Block patcher.masm()->ldr(v8::internal::ip, MemOperand(v8::internal::pc, 0)); 636ded16be15dd865a9b21ea304d5273c8be299c87Steve Block patcher.masm()->blx(v8::internal::ip); 646ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#else 65a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block patcher.masm()->mov(v8::internal::lr, v8::internal::pc); 66a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block patcher.masm()->ldr(v8::internal::pc, MemOperand(v8::internal::pc, -4)); 676ded16be15dd865a9b21ea304d5273c8be299c87Steve Block#endif 6844f0eee88ff00398ff7f715fab053374d808c90dSteve Block patcher.Emit(Isolate::Current()->debug()->debug_break_return()->entry()); 69a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block patcher.masm()->bkpt(0); 70a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 71a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 72a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 73a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block// Restore the JS frame exit code. 74a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid BreakLocationIterator::ClearDebugBreakAtReturn() { 75a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block rinfo()->PatchCode(original_rinfo()->pc(), 767f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch Assembler::kJSReturnSequenceInstructions); 77a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 78a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 79a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 807f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch// A debug break in the frame exit code is identified by the JS frame exit code 817f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch// having been patched with a call instruction. 82a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockbool Debug::IsDebugBreakAtReturn(RelocInfo* rinfo) { 83a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block ASSERT(RelocInfo::IsJSReturn(rinfo->rmode())); 843ce2e2076e8e3e60cf1810eec160ea2d8557e9e7Steve Block return rinfo->IsPatchedReturnSequence(); 85a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 86a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 87a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 887f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdochbool BreakLocationIterator::IsDebugBreakAtSlot() { 897f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch ASSERT(IsDebugBreakSlot()); 907f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // Check whether the debug break slot instructions have been patched. 917f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch return rinfo()->IsPatchedDebugBreakSlotSequence(); 927f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch} 937f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 947f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 957f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdochvoid BreakLocationIterator::SetDebugBreakAtSlot() { 967f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch ASSERT(IsDebugBreakSlot()); 977f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // Patch the code changing the debug break slot code from 987f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // mov r2, r2 997f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // mov r2, r2 1007f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // mov r2, r2 1017f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // to a call to the debug break slot code. 1027f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // #if USE_BLX 1037f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // ldr ip, [pc, #0] 1047f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // blx ip 1057f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // #else 1067f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // mov lr, pc 1077f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // ldr pc, [pc, #-4] 1087f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // #endif 1097f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // <debug break slot code entry point address> 1107f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions); 1117f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch#ifdef USE_BLX 1127f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch patcher.masm()->ldr(v8::internal::ip, MemOperand(v8::internal::pc, 0)); 1137f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch patcher.masm()->blx(v8::internal::ip); 1147f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch#else 1157f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch patcher.masm()->mov(v8::internal::lr, v8::internal::pc); 1167f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch patcher.masm()->ldr(v8::internal::pc, MemOperand(v8::internal::pc, -4)); 1177f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch#endif 11844f0eee88ff00398ff7f715fab053374d808c90dSteve Block patcher.Emit(Isolate::Current()->debug()->debug_break_slot()->entry()); 1197f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch} 1207f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 1217f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 1227f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdochvoid BreakLocationIterator::ClearDebugBreakAtSlot() { 1237f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch ASSERT(IsDebugBreakSlot()); 1247f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch rinfo()->PatchCode(original_rinfo()->pc(), 1257f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch Assembler::kDebugBreakSlotInstructions); 1267f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch} 1277f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 1287f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 129a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#define __ ACCESS_MASM(masm) 130a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 131a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 132a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockstatic void Generate_DebugBreakCallHelper(MacroAssembler* masm, 13380d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen RegList object_regs, 13480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen RegList non_object_regs) { 1353ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch { 1363ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch FrameScope scope(masm, StackFrame::INTERNAL); 1373ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1383ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Store the registers containing live values on the expression stack to 1393ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // make sure that these are correctly updated during GC. Non object values 1403ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // are stored as a smi causing it to be untouched by GC. 1413ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch ASSERT((object_regs & ~kJSCallerSaved) == 0); 1423ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch ASSERT((non_object_regs & ~kJSCallerSaved) == 0); 1433ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch ASSERT((object_regs & non_object_regs) == 0); 1443ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if ((object_regs | non_object_regs) != 0) { 1453ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch for (int i = 0; i < kNumJSCallerSaved; i++) { 1463ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch int r = JSCallerSavedCode(i); 1473ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Register reg = { r }; 1483ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if ((non_object_regs & (1 << r)) != 0) { 1493ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if (FLAG_debug_code) { 1503ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ tst(reg, Operand(0xc0000000)); 1513ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ Assert(eq, "Unable to encode value as smi"); 1523ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1533ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ mov(reg, Operand(reg, LSL, kSmiTagSize)); 15480d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen } 15580d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen } 1563ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ stm(db_w, sp, object_regs | non_object_regs); 15780d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen } 158a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 159a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#ifdef DEBUG 1603ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ RecordComment("// Calling from debug break to runtime - come in - over"); 161a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif 1623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ mov(r0, Operand(0, RelocInfo::NONE)); // no arguments 1633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ mov(r1, Operand(ExternalReference::debug_break(masm->isolate()))); 1643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch CEntryStub ceb(1); 1663ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ CallStub(&ceb); 1673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 1683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Restore the register values from the expression stack. 1693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if ((object_regs | non_object_regs) != 0) { 1703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ ldm(ia_w, sp, object_regs | non_object_regs); 1713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch for (int i = 0; i < kNumJSCallerSaved; i++) { 1723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch int r = JSCallerSavedCode(i); 1733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Register reg = { r }; 1743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if ((non_object_regs & (1 << r)) != 0) { 1753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ mov(reg, Operand(reg, LSR, kSmiTagSize)); 1763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 1773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch if (FLAG_debug_code && 1783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch (((object_regs |non_object_regs) & (1 << r)) == 0)) { 1793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch __ mov(reg, Operand(kDebugZapValue)); 1803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 18180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen } 18280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen } 183a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 1843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Leave the internal frame. 1853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch } 18685b71799222b55eb5dd74ea26efe0c64ab655c8cBen Murdoch 187a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Now that the break point has been handled, resume normal execution by 188a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // jumping to the target address intended by the caller and that was 189a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // overwritten by the address of DebugBreakXXX. 19044f0eee88ff00398ff7f715fab053374d808c90dSteve Block ExternalReference after_break_target = 19144f0eee88ff00398ff7f715fab053374d808c90dSteve Block ExternalReference(Debug_Address::AfterBreakTarget(), masm->isolate()); 19244f0eee88ff00398ff7f715fab053374d808c90dSteve Block __ mov(ip, Operand(after_break_target)); 193a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block __ ldr(ip, MemOperand(ip)); 194a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block __ Jump(ip); 195a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 196a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 197a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 198a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateLoadICDebugBreak(MacroAssembler* masm) { 199a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Calling convention for IC load (from ic-arm.cc). 200a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------- S t a t e ------------- 201a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- r2 : name 202a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- lr : return address 2036ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // -- r0 : receiver 204a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- [sp] : receiver 205a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------------------------------- 206402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu // Registers r0 and r2 contain objects that need to be pushed on the 207a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // expression stack of the fake JS frame. 20880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r0.bit() | r2.bit(), 0); 209a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 210a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 211a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 212a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateStoreICDebugBreak(MacroAssembler* masm) { 213a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Calling convention for IC store (from ic-arm.cc). 214a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------- S t a t e ------------- 215402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu // -- r0 : value 216402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu // -- r1 : receiver 217a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- r2 : name 218a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- lr : return address 219a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------------------------------- 220402d937239b0e2fd11bf2f4fe972ad78aa9fd481Andrei Popescu // Registers r0, r1, and r2 contain objects that need to be pushed on the 221a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // expression stack of the fake JS frame. 22280d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r0.bit() | r1.bit() | r2.bit(), 0); 223a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 224a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 225a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 226a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateKeyedLoadICDebugBreak(MacroAssembler* masm) { 227a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ---------- S t a t e -------------- 228a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- lr : return address 2296ded16be15dd865a9b21ea304d5273c8be299c87Steve Block // -- r0 : key 23080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen // -- r1 : receiver 23180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r0.bit() | r1.bit(), 0); 232a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 233a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 234a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 235a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateKeyedStoreICDebugBreak(MacroAssembler* masm) { 236a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ---------- S t a t e -------------- 237f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke // -- r0 : value 238f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke // -- r1 : key 239f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke // -- r2 : receiver 240a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // -- lr : return address 24180d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r0.bit() | r1.bit() | r2.bit(), 0); 242a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 243a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 244a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 245a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateCallICDebugBreak(MacroAssembler* masm) { 246a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // Calling convention for IC call (from ic-arm.cc) 247a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------- S t a t e ------------- 24880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen // -- r2 : name 249a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // ----------------------------------- 25080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r2.bit(), 0); 251a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 252a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 253a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 254a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Blockvoid Debug::GenerateReturnDebugBreak(MacroAssembler* masm) { 255a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // In places other than IC call sites it is expected that r0 is TOS which 256a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // is an object - this is not generally the case so this should be used with 257a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block // care. 25880d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, r0.bit(), 0); 259a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} 260a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 261a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 2623ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid Debug::GenerateCallFunctionStubDebugBreak(MacroAssembler* masm) { 2633ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Register state for CallFunctionStub (from code-stubs-arm.cc). 2643ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------- S t a t e ------------- 2653ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r1 : function 2663ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------------------------------- 2673ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Generate_DebugBreakCallHelper(masm, r1.bit(), 0); 2683ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 2693ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2703ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2713ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid Debug::GenerateCallFunctionStubRecordDebugBreak(MacroAssembler* masm) { 2723ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Register state for CallFunctionStub (from code-stubs-arm.cc). 2733ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------- S t a t e ------------- 2743ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r1 : function 2753ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r2 : cache cell for call target 2763ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------------------------------- 2773ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Generate_DebugBreakCallHelper(masm, r1.bit() | r2.bit(), 0); 2783ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 2793ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2803ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2813ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid Debug::GenerateCallConstructStubDebugBreak(MacroAssembler* masm) { 2823ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Calling convention for CallConstructStub (from code-stubs-arm.cc) 2833ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------- S t a t e ------------- 2843ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r0 : number of arguments (not smi) 2853ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r1 : constructor function 2863ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // ----------------------------------- 2873ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Generate_DebugBreakCallHelper(masm, r1.bit(), r0.bit()); 2883ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch} 2893ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2903ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch 2913ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdochvoid Debug::GenerateCallConstructStubRecordDebugBreak(MacroAssembler* masm) { 2923ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // Calling convention for CallConstructStub (from code-stubs-arm.cc) 2935d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch // ----------- S t a t e ------------- 2943ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r0 : number of arguments (not smi) 2953ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r1 : constructor function 2963ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch // -- r2 : cache cell for call target 2975d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch // ----------------------------------- 2983ef787dbeca8a5fb1086949cda830dccee07bfbdBen Murdoch Generate_DebugBreakCallHelper(masm, r1.bit() | r2.bit(), r0.bit()); 2995d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch} 3005d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 3015d4cdbf7a67d3662fa0bee4efdb7edd8daec9b0bBen Murdoch 3027f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdochvoid Debug::GenerateSlot(MacroAssembler* masm) { 3037f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // Generate enough nop's to make space for a call instruction. Avoid emitting 3047f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // the constant pool in the debug break slot code. 3057f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch Assembler::BlockConstPoolScope block_const_pool(masm); 3067f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch Label check_codesize; 3077f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch __ bind(&check_codesize); 3087f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch __ RecordDebugBreakSlot(); 3097f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch for (int i = 0; i < Assembler::kDebugBreakSlotInstructions; i++) { 3108a31eba00023874d4a1dcdc5f411cc4336776874Shimeng (Simon) Wang __ nop(MacroAssembler::DEBUG_BREAK_NOP); 3117f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch } 3127f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch ASSERT_EQ(Assembler::kDebugBreakSlotInstructions, 3137f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch masm->InstructionsGeneratedSince(&check_codesize)); 3147f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch} 3157f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 3167f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 3177f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdochvoid Debug::GenerateSlotDebugBreak(MacroAssembler* masm) { 3187f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // In the places where a debug break slot is inserted no registers can contain 3197f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch // object pointers. 32080d68eab642096c1a48b6474d6ec33064b0ad1f5Kristian Monsen Generate_DebugBreakCallHelper(masm, 0, 0); 3217f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch} 3227f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 3237f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 3246ded16be15dd865a9b21ea304d5273c8be299c87Steve Blockvoid Debug::GeneratePlainReturnLiveEdit(MacroAssembler* masm) { 3256ded16be15dd865a9b21ea304d5273c8be299c87Steve Block masm->Abort("LiveEdit frame dropping is not supported on arm"); 3266ded16be15dd865a9b21ea304d5273c8be299c87Steve Block} 3276ded16be15dd865a9b21ea304d5273c8be299c87Steve Block 3287f4d5bd8c03935e2c0cd412e561b8fc5a6a880aeBen Murdoch 3296ded16be15dd865a9b21ea304d5273c8be299c87Steve Blockvoid Debug::GenerateFrameDropperLiveEdit(MacroAssembler* masm) { 3306ded16be15dd865a9b21ea304d5273c8be299c87Steve Block masm->Abort("LiveEdit frame dropping is not supported on arm"); 3316ded16be15dd865a9b21ea304d5273c8be299c87Steve Block} 3326ded16be15dd865a9b21ea304d5273c8be299c87Steve Block 333756813857a4c2a4d8ad2e805969d5768d3cf43a0Iain Merrickconst bool Debug::kFrameDropperSupported = false; 334756813857a4c2a4d8ad2e805969d5768d3cf43a0Iain Merrick 335a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#undef __ 336a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 3376ded16be15dd865a9b21ea304d5273c8be299c87Steve Block 3386ded16be15dd865a9b21ea304d5273c8be299c87Steve Block 339a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block#endif // ENABLE_DEBUGGER_SUPPORT 340a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block 341a7e24c173cf37484693b9abb38e494fa7bd7baebSteve Block} } // namespace v8::internal 342f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke 343f7060e27768c550ace7ec48ad8c093466db52dfaLeon Clarke#endif // V8_TARGET_ARCH_ARM 344