Changeset 249586 in webkit for trunk/Source/JavaScriptCore/interpreter/ShadowChicken.cpp
- Timestamp:
- Sep 6, 2019, 12:11:20 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/ShadowChicken.cpp
r249577 r249586 46 46 47 47 if (isPrologue()) { 48 String name = "?"_s; 49 if (auto* function = jsDynamicCast<JSFunction*>(callee->vm(), callee)) { 50 name = function->name(callee->vm()); 51 if (name.isEmpty()) 52 name = "?"_s; 53 } 54 48 55 out.print( 49 56 "{callee = ", RawPointer(callee), ", frame = ", RawPointer(frame), ", callerFrame = ", 50 RawPointer(callerFrame), " }");57 RawPointer(callerFrame), ", name = ", name, "}"); 51 58 return; 52 59 } … … 63 70 void ShadowChicken::Frame::dump(PrintStream& out) const 64 71 { 72 String name = "?"_s; 73 if (auto* function = jsDynamicCast<JSFunction*>(callee->vm(), callee)) { 74 name = function->name(callee->vm()); 75 if (name.isEmpty()) 76 name = "?"_s; 77 } 78 65 79 out.print( 66 "{callee = ", RawPointer(callee), ", frame = ", RawPointer(frame), ", isTailDeleted = ",67 isTailDeleted, " }");80 "{callee = ", *callee, ", frame = ", RawPointer(frame), ", isTailDeleted = ", 81 isTailDeleted, ", name = ", name, "}"); 68 82 } 69 83 … … 71 85 : m_logSize(Options::shadowChickenLogSize()) 72 86 { 73 m_log = static_cast<Packet*>(fastZeroedMalloc(sizeof(Packet) * m_logSize)); 87 // Allow one additional packet beyond m_logEnd. This is useful for the moment we 88 // log a packet when the log is full and force an update. At that moment the packet 89 // that is being logged should be included in the update because it may be 90 // a critical prologue needed to rationalize the current machine stack with the 91 // shadow stack. 92 m_log = static_cast<Packet*>(fastZeroedMalloc(sizeof(Packet) * (m_logSize + 1))); 74 93 m_logCursor = m_log; 75 94 m_logEnd = m_log + m_logSize; … … 83 102 void ShadowChicken::log(VM& vm, ExecState* exec, const Packet& packet) 84 103 { 104 // This write is allowed because we construct the log with space for 1 additional packet. 105 *m_logCursor++ = packet; 85 106 update(vm, exec); 86 *m_logCursor++ = packet;87 107 } 88 108 … … 143 163 } 144 164 145 146 165 if (ShadowChickenInternal::verbose) 147 166 dataLog(" Revised stack: ", listDump(m_stack), "\n"); … … 289 308 290 309 CallFrame* callFrame = visitor->callFrame(); 291 if (ShadowChickenInternal::verbose) 292 dataLog(" Examining ", RawPointer(callFrame), "\n"); 310 if (ShadowChickenInternal::verbose) { 311 dataLog(" Examining callFrame:", RawPointer(callFrame), ", callee:", RawPointer(callFrame->jsCallee()), ", callerFrame:", RawPointer(callFrame->callerFrame()), "\n"); 312 JSObject* callee = callFrame->jsCallee(); 313 if (auto* function = jsDynamicCast<JSFunction*>(callee->vm(), callee)) 314 dataLog(" Function = ", function->name(callee->vm()), "\n"); 315 } 316 293 317 if (callFrame == highestPointSinceLastTime) { 294 318 if (ShadowChickenInternal::verbose) 295 dataLog(" Bailing at ", RawPointer(callFrame), " because it's the highest point since last time.\n"); 319 dataLog(" Bailing at ", RawPointer(callFrame), " because it's the highest point since last time\n"); 320 321 // FIXME: At this point the shadow stack may still have tail deleted frames 322 // that do not run into the current call frame but are left in the shadow stack. 323 // Those tail deleted frames should be validated somehow. 324 296 325 return StackVisitor::Done; 297 326 } … … 319 348 && m_log[indexInLog].frame == toPush.last().frame) { 320 349 if (ShadowChickenInternal::verbose) 321 dataLog(" Going to loop through to find tail deleted frames with indexInLog = ", indexInLog, " and push-stack top = ", toPush.last(), "\n");350 dataLog(" Going to loop through to find tail deleted frames using ", RawPointer(callFrame), " with indexInLog = ", indexInLog, " and push-stack top = ", toPush.last(), "\n"); 322 351 for (;;) { 323 352 ASSERT(m_log[indexInLog].frame == toPush.last().frame); … … 341 370 } 342 371 indexInLog--; // Skip over the tail packet. 372 373 // FIXME: After a few iterations the tail packet referenced frame may not be the 374 // same as the original callFrame for the real stack frame we started with. 375 // It is unclear when we should break. 343 376 344 377 if (!advanceIndexInLogTo(tailPacket.frame, nullptr, nullptr)) { … … 380 413 381 414 if (ShadowChickenInternal::verbose) 382 dataLog(" After pushing: ", *this, "\n");415 dataLog(" After pushing: ", listDump(m_stack), "\n"); 383 416 384 417 // Remove tail frames until the number of tail deleted frames is small enough. … … 448 481 out.print("\n"); 449 482 for (unsigned i = 0; i < limit; ++i) 450 out.print("\t", comma, m_log[i], "\n");483 out.print("\t", comma, "[", i, "] ", m_log[i], "\n"); 451 484 out.print("]}"); 452 485 }
Note:
See TracChangeset
for help on using the changeset viewer.