Comment cmnt(masm_, "[ DebuggerStatament");
CodeForStatementPosition(node);
#ifdef ENABLE_DEBUGGER_SUPPORT
- frame_->CallRuntime(Runtime::kDebugBreak, 0);
+ DebugerStatementStub ces;
+ frame_->CallStub(&ces, 0);
#endif
// Ignore the return value.
ASSERT(frame_->height() == original_height);
__ mov(r0, Operand(0)); // no arguments
__ mov(r1, Operand(ExternalReference::debug_break()));
- CEntryDebugBreakStub ceb;
+ CEntryStub ceb(1);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression
return;
}
- Runtime::FunctionId function_id =
- static_cast<Runtime::FunctionId>(f->stub_id);
- RuntimeStub stub(function_id, num_arguments);
+ // TODO(1236192): Most runtime routines don't need the number of
+ // arguments passed in because it is constant. At some point we
+ // should remove this need and make the runtime routine entry code
+ // smarter.
+ mov(r0, Operand(num_arguments));
+ mov(r1, Operand(ExternalReference(f)));
+ CEntryStub stub(1);
CallStub(&stub);
}
V(CounterOp) \
V(ArgumentsAccess) \
V(RegExpExec) \
- V(Runtime) \
V(CEntry) \
- V(JSEntry)
+ V(JSEntry) \
+ V(DebuggerStatement)
// List of code stubs only used on ARM platforms.
#ifdef V8_TARGET_ARCH_ARM
}
-const char* RuntimeStub::GetName() {
- return Runtime::FunctionForId(id_)->stub_name;
-}
-
-
const char* GenericUnaryOpStub::GetName() {
switch (op_) {
case Token::SUB:
}
-void RuntimeStub::Generate(MacroAssembler* masm) {
- Runtime::Function* f = Runtime::FunctionForId(id_);
- masm->TailCallRuntime(ExternalReference(f),
- num_arguments_,
- f->result_size);
-}
-
-
void ArgumentsAccessStub::Generate(MacroAssembler* masm) {
switch (type_) {
case READ_LENGTH: GenerateReadLength(masm); break;
}
+void DebugerStatementStub::Generate(MacroAssembler* masm) {
+ Runtime::Function* f = Runtime::FunctionForId(Runtime::kDebugBreak);
+ masm->TailCallRuntime(ExternalReference(f), 0, f->result_size);
+}
+
+
} } // namespace v8::internal
DISALLOW_COPY_AND_ASSIGN(DeferredCode);
};
-
-// RuntimeStub models code stubs calling entry points in the Runtime class.
-class RuntimeStub : public CodeStub {
- public:
- explicit RuntimeStub(Runtime::FunctionId id, int num_arguments)
- : id_(id), num_arguments_(num_arguments) { }
-
- void Generate(MacroAssembler* masm);
-
- // Disassembler support. It is useful to be able to print the name
- // of the runtime function called through this stub.
- static const char* GetNameFromMinorKey(int minor_key) {
- return Runtime::FunctionForId(IdField::decode(minor_key))->stub_name;
- }
-
- private:
- Runtime::FunctionId id_;
- int num_arguments_;
-
- class ArgumentField: public BitField<int, 0, 16> {};
- class IdField: public BitField<Runtime::FunctionId, 16, kMinorBits - 16> {};
-
- Major MajorKey() { return Runtime; }
- int MinorKey() {
- return IdField::encode(id_) | ArgumentField::encode(num_arguments_);
- }
-
- const char* GetName();
-
-#ifdef DEBUG
- void Print() {
- PrintF("RuntimeStub (id %s)\n", Runtime::FunctionForId(id_)->name);
- }
-#endif
-};
-
-
class StackCheckStub : public CodeStub {
public:
StackCheckStub() { }
};
-class CEntryDebugBreakStub : public CEntryStub {
+// Mark the debugger statemet to be recognized bu debugger (by the MajorKey)
+class DebugerStatementStub : public CodeStub {
public:
- CEntryDebugBreakStub() : CEntryStub(1) { }
+ DebugerStatementStub() { }
- void Generate(MacroAssembler* masm) { GenerateBody(masm, true); }
+ void Generate(MacroAssembler* masm);
private:
- int MinorKey() { return 1; }
+ Major MajorKey() { return DebuggerStatement; }
+ int MinorKey() { return 0; }
- const char* GetName() { return "CEntryDebugBreakStub"; }
+ const char* GetName() { return "DebugerStatementStub"; }
};
BreakLocatorType type) {
debug_info_ = debug_info;
type_ = type;
- // Get the stub early to avoid possible GC during iterations. We may need
- // this stub to detect debugger calls generated from debugger statements.
- debug_break_stub_ = RuntimeStub(Runtime::kDebugBreak, 0).GetCode();
reloc_iterator_ = NULL;
reloc_iterator_original_ = NULL;
Reset(); // Initialize the rest of the member variables.
Code* code = Code::GetCodeFromTargetAddress(target);
if (code->kind() == Code::STUB) {
CodeStub::Major major_key = code->major_key();
- if (major_key == CodeStub::Runtime) {
- return (*debug_break_stub_ == code);
- }
+ return (major_key == CodeStub::DebuggerStatement);
}
}
return false;
int position_;
int statement_position_;
Handle<DebugInfo> debug_info_;
- Handle<Code> debug_break_stub_;
RelocIterator* reloc_iterator_;
RelocIterator* reloc_iterator_original_;
case CodeStub::CallFunction:
out.AddFormatted("argc = %d", minor_key);
break;
- case CodeStub::Runtime: {
- const char* name =
- RuntimeStub::GetNameFromMinorKey(minor_key);
- out.AddFormatted("%s", name);
- break;
- }
- default:
+ default:
out.AddFormatted("minor: %d", minor_key);
}
}
#ifdef ENABLE_DEBUGGER_SUPPORT
Comment cmnt(masm_, "[ DebuggerStatement");
SetStatementPosition(stmt);
- __ CallRuntime(Runtime::kDebugBreak, 0);
+
+ DebugerStatementStub ces;
+ __ CallStub(&ces);
// Ignore the return value.
#endif
}
void Heap::CreateCEntryDebugBreakStub() {
- CEntryDebugBreakStub stub;
+ DebugerStatementStub stub;
set_c_entry_debug_break_code(*stub.GetCode());
}
// { CEntryStub stub;
// c_entry_code_ = *stub.GetCode();
// }
- // { CEntryDebugBreakStub stub;
+ // { DebugerStatementStub stub;
// c_entry_debug_break_code_ = *stub.GetCode();
// }
// To workaround the problem, make separate functions without inlining.
#ifdef ENABLE_DEBUGGER_SUPPORT
// Spill everything, even constants, to the frame.
frame_->SpillAll();
- frame_->CallRuntime(Runtime::kDebugBreak, 0);
+
+ DebugerStatementStub ces;
+ frame_->CallStub(&ces, 0);
// Ignore the return value.
#endif
}
__ Set(eax, Immediate(0)); // no arguments
__ mov(ebx, Immediate(ExternalReference::debug_break()));
- CEntryDebugBreakStub ceb;
+ CEntryStub ceb(1);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression
return;
}
- Runtime::FunctionId function_id =
- static_cast<Runtime::FunctionId>(f->stub_id);
- RuntimeStub stub(function_id, num_arguments);
- CallStub(&stub);
+ // TODO(1236192): Most runtime routines don't need the number of
+ // arguments passed in because it is constant. At some point we
+ // should remove this need and make the runtime routine entry code
+ // smarter.
+ Set(eax, Immediate(num_arguments));
+ mov(ebx, Immediate(ExternalReference(f)));
+ CEntryStub ces(1);
+ CallStub(&ces);
}
return Heap::undefined_value();
}
- Runtime::FunctionId function_id =
- static_cast<Runtime::FunctionId>(f->stub_id);
- RuntimeStub stub(function_id, num_arguments);
- return TryCallStub(&stub);
+ // TODO(1236192): Most runtime routines don't need the number of
+ // arguments passed in because it is constant. At some point we
+ // should remove this need and make the runtime routine entry code
+ // smarter.
+ Set(eax, Immediate(num_arguments));
+ mov(ebx, Immediate(ExternalReference(f)));
+ CEntryStub ces(1);
+ return TryCallStub(&ces);
}
// Eventually this should be used for all C calls.
void CallRuntime(Runtime::Function* f, int num_arguments);
- // Call a runtime function, returning the RuntimeStub object called.
+ // Call a runtime function, returning the CodeStub object called.
// Try to generate the stub code if necessary. Do not perform a GC
// but instead return a retry after GC failure.
Object* TryCallRuntime(Runtime::Function* f, int num_arguments);
// Implementation of Runtime
#define F(name, nargs, ressize) \
- { #name, "RuntimeStub_" #name, FUNCTION_ADDR(Runtime_##name), nargs, \
+ { #name, FUNCTION_ADDR(Runtime_##name), nargs, \
static_cast<int>(Runtime::k##name), ressize },
static Runtime::Function Runtime_functions[] = {
RUNTIME_FUNCTION_LIST(F)
- { NULL, NULL, NULL, 0, -1, 0 }
+ { NULL, NULL, 0, -1, 0 }
};
#undef F
// The JS name of the function.
const char* name;
- // The name of the stub that calls the runtime function.
- const char* stub_name;
-
// The C++ (native) entry point.
byte* entry;
#ifdef ENABLE_DEBUGGER_SUPPORT
// Spill everything, even constants, to the frame.
frame_->SpillAll();
- frame_->CallRuntime(Runtime::kDebugBreak, 0);
+
+ DebugerStatementStub ces;
+ frame_->CallStub(&ces, 0);
// Ignore the return value.
#endif
}
#ifdef _WIN64
// Simple results returned in rax (using default code).
// Complex results must be written to address passed as first argument.
- // Use even numbers for minor keys, reserving the odd numbers for
- // CEntryDebugBreakStub.
- return (result_size_ < 2) ? 0 : result_size_ * 2;
+ return (result_size_ < 2) ? 0 : 1;
#else
// Single results returned in rax (both AMD64 and Win64 calling conventions)
// and a struct of two pointers in rax+rdx (AMD64 calling convention only)
__ xor_(rax, rax); // No arguments (argc == 0).
__ movq(rbx, ExternalReference::debug_break());
- CEntryDebugBreakStub ceb;
+ CEntryStub ceb(1);
__ CallStub(&ceb);
// Restore the register values containing object pointers from the expression
return;
}
- Runtime::FunctionId function_id =
- static_cast<Runtime::FunctionId>(f->stub_id);
- RuntimeStub stub(function_id, num_arguments);
- CallStub(&stub);
+ // TODO(1236192): Most runtime routines don't need the number of
+ // arguments passed in because it is constant. At some point we
+ // should remove this need and make the runtime routine entry code
+ // smarter.
+ movq(rax, Immediate(num_arguments));
+ movq(rbx, ExternalReference(f));
+ CEntryStub ces(f->result_size);
+ CallStub(&ces);
}
}
+// Test setting a breakpoint on the debugger statement.
+TEST(DebuggerStatementBreakpoint) {
+ break_point_hit_count = 0;
+ v8::HandleScope scope;
+ DebugLocalContext env;
+ v8::Debug::SetDebugEventListener(DebugEventBreakPointHitCount,
+ v8::Undefined());
+ v8::Script::Compile(v8::String::New("function foo(){debugger;}"))->Run();
+ v8::Local<v8::Function> foo =
+ v8::Local<v8::Function>::Cast(env->Global()->Get(v8::String::New("foo")));
+
+ // The debugger statement triggers breakpint hit
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(1, break_point_hit_count);
+
+ int bp = SetBreakPoint(foo, 0);
+
+ // Set breakpoint does not duplicate hits
+ foo->Call(env->Global(), 0, NULL);
+ CHECK_EQ(2, break_point_hit_count);
+
+ ClearBreakPoint(bp);
+ v8::Debug::SetDebugEventListener(NULL);
+ CheckDebuggerUnloaded();
+}
+
+
// Thest that the evaluation of expressions when a break point is hit generates
// the correct results.
TEST(DebugEvaluate) {