Always initialize the debugger eagerly.

There is no point doing it lazily, since compiling and executing the tiniest piece of code triggers lazy init.
Also removed some dead code.

R=ulan@chromium.org

Review URL: https://codereview.chromium.org/265593004

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@21135 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yangguo@chromium.org 2014-05-05 07:10:38 +00:00
parent 929b99ed8d
commit db904a20da
13 changed files with 19 additions and 106 deletions

View File

@ -32,7 +32,7 @@ void BreakLocationIterator::SetDebugBreakAtReturn() {
patcher.masm()->ldr(v8::internal::ip, MemOperand(v8::internal::pc, 0));
patcher.masm()->blx(v8::internal::ip);
patcher.Emit(
debug_info_->GetIsolate()->debug()->debug_break_return()->entry());
debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry());
patcher.masm()->bkpt(0);
}
@ -73,7 +73,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() {
patcher.masm()->ldr(v8::internal::ip, MemOperand(v8::internal::pc, 0));
patcher.masm()->blx(v8::internal::ip);
patcher.Emit(
debug_info_->GetIsolate()->debug()->debug_break_slot()->entry());
debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry());
}

View File

@ -42,7 +42,7 @@ void BreakLocationIterator::SetDebugBreakAtReturn() {
STATIC_ASSERT(Assembler::kJSRetSequenceInstructions >= 5);
PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 5);
byte* entry =
debug_info_->GetIsolate()->debug()->debug_break_return()->entry();
debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry();
// The first instruction of a patched return sequence must be a load literal
// loading the address of the debug break return code.
@ -101,7 +101,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() {
STATIC_ASSERT(Assembler::kDebugBreakSlotInstructions >= 4);
PatchingAssembler patcher(reinterpret_cast<Instruction*>(rinfo()->pc()), 4);
byte* entry =
debug_info_->GetIsolate()->debug()->debug_break_slot()->entry();
debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry();
// The first instruction of a patched debug break slot must be a load literal
// loading the address of the debug break slot code.

View File

@ -39,10 +39,9 @@ Debug::Debug(Isolate* isolate)
break_on_uncaught_exception_(false),
promise_catch_handlers_(0),
promise_getters_(0),
debug_break_return_(NULL),
debug_break_slot_(NULL),
isolate_(isolate) {
memset(registers_, 0, sizeof(JSCallerSavedBuffer));
ThreadInit();
}
@ -665,21 +664,6 @@ void ScriptCache::HandleWeakScript(
}
void Debug::SetUp(bool create_heap_objects) {
ThreadInit();
if (create_heap_objects) {
// Get code to handle debug break on return.
debug_break_return_ =
isolate_->builtins()->builtin(Builtins::kReturn_DebugBreak);
ASSERT(debug_break_return_->IsCode());
// Get code to handle debug break in debug break slots.
debug_break_slot_ =
isolate_->builtins()->builtin(Builtins::kSlot_DebugBreak);
ASSERT(debug_break_slot_->IsCode());
}
}
void Debug::HandleWeakDebugInfo(
const v8::WeakCallbackData<v8::Value, void>& data) {
Debug* debug = reinterpret_cast<Isolate*>(data.GetIsolate())->debug();
@ -883,12 +867,6 @@ void Debug::PreemptionWhileInDebugger() {
}
void Debug::Iterate(ObjectVisitor* v) {
v->VisitPointer(BitCast<Object**>(&(debug_break_return_)));
v->VisitPointer(BitCast<Object**>(&(debug_break_slot_)));
}
Object* Debug::Break(Arguments args) {
Heap* heap = isolate_->heap();
HandleScope scope(isolate_);

View File

@ -212,13 +212,11 @@ class DebugInfoListNode {
// DebugInfo.
class Debug {
public:
void SetUp(bool create_heap_objects);
bool Load();
void Unload();
bool IsLoaded() { return !debug_context_.is_null(); }
bool InDebugger() { return thread_local_.debugger_entry_ != NULL; }
void PreemptionWhileInDebugger();
void Iterate(ObjectVisitor* v);
Object* Break(Arguments args);
void SetBreakPoint(Handle<JSFunction> function,
@ -347,8 +345,6 @@ class Debug {
enum AddressId {
k_after_break_target_address,
k_debug_break_return_address,
k_debug_break_slot_address,
k_restarter_frame_function_pointer
};
@ -366,18 +362,6 @@ class Debug {
return &registers_[r];
}
// Access to the debug break on return code.
Code* debug_break_return() { return debug_break_return_; }
Code** debug_break_return_address() {
return &debug_break_return_;
}
// Access to the debug break in debug break slot code.
Code* debug_break_slot() { return debug_break_slot_; }
Code** debug_break_slot_address() {
return &debug_break_slot_;
}
static const int kEstimatedNofDebugInfoEntries = 16;
static const int kEstimatedNofBreakPointsInFunction = 16;
@ -610,12 +594,6 @@ class Debug {
ThreadLocal thread_local_;
void ThreadInit();
// Code to call for handling debug break on return.
Code* debug_break_return_;
// Code to call for handling debug break in debug break slots.
Code* debug_break_slot_;
Isolate* isolate_;
friend class Isolate;
@ -996,10 +974,6 @@ class Debug_Address {
return Debug_Address(Debug::k_after_break_target_address);
}
static Debug_Address DebugBreakReturn() {
return Debug_Address(Debug::k_debug_break_return_address);
}
static Debug_Address RestarterFrameFunctionPointer() {
return Debug_Address(Debug::k_restarter_frame_function_pointer);
}
@ -1009,10 +983,6 @@ class Debug_Address {
switch (id_) {
case Debug::k_after_break_target_address:
return reinterpret_cast<Address>(debug->after_break_target_address());
case Debug::k_debug_break_return_address:
return reinterpret_cast<Address>(debug->debug_break_return_address());
case Debug::k_debug_break_slot_address:
return reinterpret_cast<Address>(debug->debug_break_slot_address());
case Debug::k_restarter_frame_function_pointer:
return reinterpret_cast<Address>(
debug->restarter_frame_function_pointer_address());

View File

@ -4913,7 +4913,6 @@ void Heap::IterateStrongRoots(ObjectVisitor* v, VisitMode mode) {
Relocatable::Iterate(isolate_, v);
v->Synchronize(VisitorSynchronization::kRelocatable);
isolate_->debug()->Iterate(v);
if (isolate_->deoptimizer_data() != NULL) {
isolate_->deoptimizer_data()->Iterate(v);
}

View File

@ -25,7 +25,7 @@ void BreakLocationIterator::SetDebugBreakAtReturn() {
ASSERT(Assembler::kJSReturnSequenceLength >=
Assembler::kCallInstructionLength);
rinfo()->PatchCodeWithCall(
debug_info_->GetIsolate()->debug()->debug_break_return()->entry(),
debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(),
Assembler::kJSReturnSequenceLength - Assembler::kCallInstructionLength);
}
@ -56,7 +56,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() {
ASSERT(IsDebugBreakSlot());
Isolate* isolate = debug_info_->GetIsolate();
rinfo()->PatchCodeWithCall(
isolate->debug()->debug_break_slot()->entry(),
isolate->builtins()->Slot_DebugBreak()->entry(),
Assembler::kDebugBreakSlotLength - Assembler::kCallInstructionLength);
}

View File

@ -31,7 +31,6 @@ bool Isolate::IsCodePreAgingActive() {
bool Isolate::IsDebuggerActive() {
if (!NoBarrier_Load(&debugger_initialized_)) return false;
return debugger()->IsDebuggerActive();
}

View File

@ -1422,7 +1422,6 @@ Isolate::Isolate()
compilation_cache_(NULL),
counters_(NULL),
code_range_(NULL),
debugger_initialized_(false),
logger_(NULL),
stats_table_(NULL),
stub_cache_(NULL),
@ -1483,9 +1482,6 @@ Isolate::Isolate()
memset(&js_spill_information_, 0, sizeof(js_spill_information_));
#endif
debug_ = NULL;
debugger_ = NULL;
handle_scope_data_.Initialize();
#define ISOLATE_INIT_EXECUTE(type, name, initial_value) \
@ -1497,6 +1493,10 @@ Isolate::Isolate()
memset(name##_, 0, sizeof(type) * length);
ISOLATE_INIT_ARRAY_LIST(ISOLATE_INIT_ARRAY_EXECUTE)
#undef ISOLATE_INIT_ARRAY_EXECUTE
InitializeLoggingAndCounters();
debug_ = new Debug(this);
debugger_ = new Debugger(this);
}
@ -1764,16 +1764,6 @@ void Isolate::InitializeLoggingAndCounters() {
}
void Isolate::InitializeDebugger() {
LockGuard<RecursiveMutex> lock_guard(debugger_access());
if (NoBarrier_Load(&debugger_initialized_)) return;
InitializeLoggingAndCounters();
debug_ = new Debug(this);
debugger_ = new Debugger(this);
Release_Store(&debugger_initialized_, true);
}
bool Isolate::Init(Deserializer* des) {
ASSERT(state_ != INITIALIZED);
TRACE_ISOLATE(init);
@ -1797,10 +1787,6 @@ bool Isolate::Init(Deserializer* des) {
// The initialization process does not handle memory exhaustion.
DisallowAllocationFailure disallow_allocation_failure(this);
InitializeLoggingAndCounters();
InitializeDebugger();
memory_allocator_ = new MemoryAllocator(this);
code_range_ = new CodeRange(this);
@ -1915,8 +1901,6 @@ bool Isolate::Init(Deserializer* des) {
}
}
debug_->SetUp(create_heap_objects);
// If we are deserializing, read the state into the now-empty heap.
if (!create_heap_objects) {
des->Deserialize(this);

View File

@ -928,14 +928,8 @@ class Isolate {
inline bool IsCodePreAgingActive();
Debugger* debugger() {
if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
return debugger_;
}
Debug* debug() {
if (!NoBarrier_Load(&debugger_initialized_)) InitializeDebugger();
return debug_;
}
Debugger* debugger() { return debugger_; }
Debug* debug() { return debug_; }
inline bool IsDebuggerActive();
inline bool DebuggerHasBreakPoints();
@ -1182,8 +1176,6 @@ class Isolate {
void PropagatePendingExceptionToExternalTryCatch();
void InitializeDebugger();
// Traverse prototype chain to find out whether the object is derived from
// the Error object.
bool IsErrorObject(Handle<Object> obj);

View File

@ -1569,7 +1569,7 @@ static const char* DropFrames(Vector<StackFrame*> frames,
*mode = Debug::FRAME_DROPPED_IN_IC_CALL;
frame_has_padding = Debug::FramePaddingLayout::kIsSupported;
} else if (pre_top_frame_code ==
isolate->debug()->debug_break_slot()) {
isolate->builtins()->builtin(Builtins::kSlot_DebugBreak)) {
// OK, we can drop debug break slot.
*mode = Debug::FRAME_DROPPED_IN_DEBUG_SLOT_CALL;
frame_has_padding = Debug::FramePaddingLayout::kIsSupported;

View File

@ -33,9 +33,8 @@ void BreakLocationIterator::SetDebugBreakAtReturn() {
ASSERT(Assembler::kJSReturnSequenceInstructions == 7);
CodePatcher patcher(rinfo()->pc(), Assembler::kJSReturnSequenceInstructions);
// li and Call pseudo-instructions emit two instructions each.
patcher.masm()->li(v8::internal::t9,
Operand(reinterpret_cast<int32_t>(
debug_info_->GetIsolate()->debug()->debug_break_return()->entry())));
patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>(
debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry())));
patcher.masm()->Call(v8::internal::t9);
patcher.masm()->nop();
patcher.masm()->nop();
@ -80,7 +79,7 @@ void BreakLocationIterator::SetDebugBreakAtSlot() {
// call t9 (jalr t9 / nop instruction pair)
CodePatcher patcher(rinfo()->pc(), Assembler::kDebugBreakSlotInstructions);
patcher.masm()->li(v8::internal::t9, Operand(reinterpret_cast<int32_t>(
debug_info_->GetIsolate()->debug()->debug_break_slot()->entry())));
debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry())));
patcher.masm()->Call(v8::internal::t9);
}

View File

@ -190,14 +190,6 @@ void ExternalReferenceTable::PopulateTable(Isolate* isolate) {
DEBUG_ADDRESS,
Debug::k_after_break_target_address << kDebugIdShift,
"Debug::after_break_target_address()");
Add(Debug_Address(Debug::k_debug_break_slot_address).address(isolate),
DEBUG_ADDRESS,
Debug::k_debug_break_slot_address << kDebugIdShift,
"Debug::debug_break_slot_address()");
Add(Debug_Address(Debug::k_debug_break_return_address).address(isolate),
DEBUG_ADDRESS,
Debug::k_debug_break_return_address << kDebugIdShift,
"Debug::debug_break_return_address()");
Add(Debug_Address(Debug::k_restarter_frame_function_pointer).address(isolate),
DEBUG_ADDRESS,
Debug::k_restarter_frame_function_pointer << kDebugIdShift,

View File

@ -25,7 +25,7 @@ bool BreakLocationIterator::IsDebugBreakAtReturn() {
void BreakLocationIterator::SetDebugBreakAtReturn() {
ASSERT(Assembler::kJSReturnSequenceLength >= Assembler::kCallSequenceLength);
rinfo()->PatchCodeWithCall(
debug_info_->GetIsolate()->debug()->debug_break_return()->entry(),
debug_info_->GetIsolate()->builtins()->Return_DebugBreak()->entry(),
Assembler::kJSReturnSequenceLength - Assembler::kCallSequenceLength);
}
@ -55,7 +55,7 @@ bool BreakLocationIterator::IsDebugBreakAtSlot() {
void BreakLocationIterator::SetDebugBreakAtSlot() {
ASSERT(IsDebugBreakSlot());
rinfo()->PatchCodeWithCall(
debug_info_->GetIsolate()->debug()->debug_break_slot()->entry(),
debug_info_->GetIsolate()->builtins()->Slot_DebugBreak()->entry(),
Assembler::kDebugBreakSlotLength - Assembler::kCallSequenceLength);
}