Commit 7c797360 authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

Revert of [debugger] remove debugger statement support from FCG/CS. (patchset...

Revert of [debugger] remove debugger statement support from FCG/CS. (patchset #5 id:80001 of https://codereview.chromium.org/2650193002/ )

Reason for revert:
Fails on chromium leak bot:
https://uberchromegw.corp.google.com/i/chromium.webkit/builders/WebKit%20Linux%20Trusty%20Leak/builds/2007

Original issue's description:
> [debugger] remove debugger statement support from FCG/CS.
>
>
> R=mstarzinger@chromium.org
>
> Review-Url: https://codereview.chromium.org/2650193002
> Cr-Commit-Position: refs/heads/master@{#42892}
> Committed: https://chromium.googlesource.com/v8/v8/+/eef855a1dc956e9db03ec09abca1d732d379861b

TBR=mstarzinger@chromium.org,yangguo@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.

Review-Url: https://codereview.chromium.org/2672823007
Cr-Commit-Position: refs/heads/master@{#42942}
parent 29e8d49f
......@@ -1919,6 +1919,16 @@ void MacroAssembler::IsObjectNameType(Register object,
b(hi, fail);
}
void MacroAssembler::DebugBreak() {
mov(r0, Operand::Zero());
mov(r1,
Operand(ExternalReference(Runtime::kHandleDebuggerStatement, isolate())));
CEntryStub ces(isolate(), 1);
DCHECK(AllowThisStubCall(&ces));
Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -714,9 +714,13 @@ class MacroAssembler: public Assembler {
Register scratch,
Label* fail);
// Frame restart support
// ---------------------------------------------------------------------------
// Debugger Support
void DebugBreak();
void MaybeDropFrames();
// ---------------------------------------------------------------------------
// Exception handling
// Push a new stack handler and link into stack handler chain.
......
......@@ -2888,6 +2888,15 @@ void MacroAssembler::LoadContext(Register dst, int context_chain_length) {
}
}
void MacroAssembler::DebugBreak() {
Mov(x0, 0);
Mov(x1, ExternalReference(Runtime::kHandleDebuggerStatement, isolate()));
CEntryStub ces(isolate(), 1);
DCHECK(AllowThisStubCall(&ces));
Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -1300,9 +1300,13 @@ class MacroAssembler : public Assembler {
MacroAssembler* masm_;
};
// Frame restart support
// ---------------------------------------------------------------------------
// Debugger Support
void DebugBreak();
void MaybeDropFrames();
// ---------------------------------------------------------------------------
// Exception handling
// Push a new stack handler and link into stack handler chain.
......
......@@ -725,6 +725,8 @@ const char* RelocInfo::RelocModeName(RelocInfo::Mode rmode) {
return "no reloc 64";
case EMBEDDED_OBJECT:
return "embedded object";
case DEBUGGER_STATEMENT:
return "debugger statement";
case CODE_TARGET:
return "code target";
case CODE_TARGET_WITH_ID:
......@@ -832,6 +834,7 @@ void RelocInfo::Verify(Isolate* isolate) {
case CELL:
Object::VerifyPointer(target_cell());
break;
case DEBUGGER_STATEMENT:
case CODE_TARGET_WITH_ID:
case CODE_TARGET: {
// convert inline target address to code object
......
......@@ -317,6 +317,7 @@ class RelocInfo {
// Please note the order is important (see IsCodeTarget, IsGCRelocMode).
CODE_TARGET, // Code target which is not any of the above.
CODE_TARGET_WITH_ID,
DEBUGGER_STATEMENT, // Code target for the debugger statement.
EMBEDDED_OBJECT,
// To relocate pointers into the wasm memory embedded in wasm code
WASM_MEMORY_REFERENCE,
......@@ -365,7 +366,7 @@ class RelocInfo {
FIRST_REAL_RELOC_MODE = CODE_TARGET,
LAST_REAL_RELOC_MODE = VENEER_POOL,
LAST_CODE_ENUM = CODE_TARGET_WITH_ID,
LAST_CODE_ENUM = DEBUGGER_STATEMENT,
LAST_GCED_ENUM = WASM_FUNCTION_TABLE_SIZE_REFERENCE,
FIRST_SHAREABLE_RELOC_MODE = CELL,
};
......@@ -441,6 +442,9 @@ class RelocInfo {
static inline bool IsDebugBreakSlotAtTailCall(Mode mode) {
return mode == DEBUG_BREAK_SLOT_AT_TAIL_CALL;
}
static inline bool IsDebuggerStatement(Mode mode) {
return mode == DEBUGGER_STATEMENT;
}
static inline bool IsNone(Mode mode) {
return mode == NONE32 || mode == NONE64;
}
......
......@@ -119,7 +119,8 @@ void AstNumberingVisitor::VisitBreakStatement(BreakStatement* node) {
void AstNumberingVisitor::VisitDebuggerStatement(DebuggerStatement* node) {
IncrementNodeCount();
DisableFullCodegenAndCrankshaft(kDebuggerStatement);
DisableOptimization(kDebuggerStatement);
node->set_base_id(ReserveIdRange(DebuggerStatement::num_ids()));
}
......
......@@ -1146,10 +1146,26 @@ class TryFinallyStatement final : public TryStatement {
class DebuggerStatement final : public Statement {
public:
void set_base_id(int id) { base_id_ = id; }
static int num_ids() { return parent_num_ids() + 1; }
BailoutId DebugBreakId() const { return BailoutId(local_id(0)); }
private:
friend class AstNodeFactory;
explicit DebuggerStatement(int pos) : Statement(pos, kDebuggerStatement) {}
explicit DebuggerStatement(int pos)
: Statement(pos, kDebuggerStatement),
base_id_(BailoutId::None().ToInt()) {}
static int parent_num_ids() { return 0; }
int base_id() const {
DCHECK(!BailoutId(base_id_).IsNone());
return base_id_;
}
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
int base_id_;
};
......
......@@ -1286,8 +1286,9 @@ void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
void AstGraphBuilder::VisitDebuggerStatement(DebuggerStatement* stmt) {
// Debugger statement is supported only by going through Ignition first.
UNREACHABLE();
Node* node = NewNode(javascript()->Debugger());
PrepareFrameState(node, stmt->DebugBreakId());
environment()->MarkAllLocalsLive();
}
......
......@@ -186,6 +186,7 @@ int CodeBreakIterator::GetModeMask() {
mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_CALL);
mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_TAIL_CALL);
mask |= RelocInfo::ModeMask(RelocInfo::DEBUG_BREAK_SLOT_AT_POSITION);
mask |= RelocInfo::ModeMask(RelocInfo::DEBUGGER_STATEMENT);
return mask;
}
......@@ -210,7 +211,8 @@ void CodeBreakIterator::Next() {
source_position_iterator_.Advance();
}
DCHECK(RelocInfo::IsDebugBreakSlot(rmode()));
DCHECK(RelocInfo::IsDebugBreakSlot(rmode()) ||
RelocInfo::IsDebuggerStatement(rmode()));
break_index_++;
}
......@@ -223,6 +225,8 @@ DebugBreakType CodeBreakIterator::GetDebugBreakType() {
return isolate()->is_tail_call_elimination_enabled()
? DEBUG_BREAK_SLOT_AT_TAIL_CALL
: DEBUG_BREAK_SLOT_AT_CALL;
} else if (RelocInfo::IsDebuggerStatement(rmode())) {
return DEBUGGER_STATEMENT;
} else if (RelocInfo::IsDebugBreakSlot(rmode())) {
return DEBUG_BREAK_SLOT;
} else {
......@@ -238,6 +242,7 @@ void CodeBreakIterator::SkipToPosition(int position,
void CodeBreakIterator::SetDebugBreak() {
DebugBreakType debug_break_type = GetDebugBreakType();
if (debug_break_type == DEBUGGER_STATEMENT) return;
DCHECK(debug_break_type >= DEBUG_BREAK_SLOT);
Builtins* builtins = isolate()->builtins();
Handle<Code> target = debug_break_type == DEBUG_BREAK_SLOT_AT_RETURN
......@@ -247,12 +252,16 @@ void CodeBreakIterator::SetDebugBreak() {
}
void CodeBreakIterator::ClearDebugBreak() {
DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT);
DebugBreakType debug_break_type = GetDebugBreakType();
if (debug_break_type == DEBUGGER_STATEMENT) return;
DCHECK(debug_break_type >= DEBUG_BREAK_SLOT);
DebugCodegen::ClearDebugBreakSlot(isolate(), rinfo()->pc());
}
bool CodeBreakIterator::IsDebugBreak() {
DCHECK(GetDebugBreakType() >= DEBUG_BREAK_SLOT);
DebugBreakType debug_break_type = GetDebugBreakType();
if (debug_break_type == DEBUGGER_STATEMENT) return false;
DCHECK(debug_break_type >= DEBUG_BREAK_SLOT);
return DebugCodegen::DebugBreakSlotIsPatched(rinfo()->pc());
}
......
......@@ -1228,8 +1228,13 @@ void FullCodeGenerator::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
void FullCodeGenerator::VisitDebuggerStatement(DebuggerStatement* stmt) {
// Debugger statement is not supported.
UNREACHABLE();
Comment cmnt(masm_, "[ DebuggerStatement");
SetStatementPosition(stmt);
__ DebugBreak();
__ MaybeDropFrames();
PrepareForBailoutForId(stmt->DebugBreakId(), BailoutState::NO_REGISTERS);
}
......
......@@ -673,6 +673,14 @@ void MacroAssembler::RecordWriteCodeEntryField(Register js_function,
bind(&done);
}
void MacroAssembler::DebugBreak() {
Move(eax, Immediate(0));
mov(ebx, Immediate(ExternalReference(Runtime::kHandleDebuggerStatement,
isolate())));
CEntryStub ces(isolate(), 1);
call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -228,7 +228,10 @@ class MacroAssembler: public Assembler {
void RecordWriteForMap(Register object, Handle<Map> map, Register scratch1,
Register scratch2, SaveFPRegsMode save_fp);
// Frame restart support
// ---------------------------------------------------------------------------
// Debugger Support
void DebugBreak();
void MaybeDropFrames();
// Generates function and stub prologue code.
......
......@@ -3885,6 +3885,16 @@ void MacroAssembler::Push(Handle<Object> handle) {
push(at);
}
void MacroAssembler::DebugBreak() {
PrepareCEntryArgs(0);
PrepareCEntryFunction(
ExternalReference(Runtime::kHandleDebuggerStatement, isolate()));
CEntryStub ces(isolate(), 1);
DCHECK(AllowThisStubCall(&ces));
Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -1080,9 +1080,13 @@ class MacroAssembler: public Assembler {
Register scratch,
Label* fail);
// Frame restart support.
// -------------------------------------------------------------------------
// Debugger Support.
void DebugBreak();
void MaybeDropFrames();
// -------------------------------------------------------------------------
// Exception handling.
// Push a new stack handler and link into stack handler chain.
......
......@@ -4040,6 +4040,16 @@ void MacroAssembler::PopRegisterAsTwoSmis(Register dst, Register scratch) {
or_(dst, dst, scratch);
}
void MacroAssembler::DebugBreak() {
PrepareCEntryArgs(0);
PrepareCEntryFunction(
ExternalReference(Runtime::kHandleDebuggerStatement, isolate()));
CEntryStub ces(isolate(), 1);
DCHECK(AllowThisStubCall(&ces));
Call(ces.GetCode(), RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -1134,9 +1134,13 @@ class MacroAssembler: public Assembler {
Register scratch,
Label* fail);
// Frame restart support.
// -------------------------------------------------------------------------
// Debugger Support.
void DebugBreak();
void MaybeDropFrames();
// -------------------------------------------------------------------------
// Exception handling.
// Push a new stack handler and link into stack handler chain.
......
......@@ -4088,6 +4088,11 @@ void MacroAssembler::DecrementCounter(StatsCounter* counter, int value) {
}
}
void MacroAssembler::DebugBreak() {
Call(isolate()->builtins()->HandleDebuggerStatement(),
RelocInfo::DEBUGGER_STATEMENT);
}
void MacroAssembler::MaybeDropFrames() {
// Check whether we need to drop frames to restart a function on the stack.
ExternalReference restart_fp =
......
......@@ -323,7 +323,10 @@ class MacroAssembler: public Assembler {
PointersToHereCheck pointers_to_here_check_for_value =
kPointersToHereMaybeInteresting);
// Frame restart support.
// ---------------------------------------------------------------------------
// Debugger Support
void DebugBreak();
void MaybeDropFrames();
// Generates function and stub prologue code.
......
......@@ -697,8 +697,6 @@ TEST(LineNumber) {
}
TEST(BailoutReason) {
i::FLAG_allow_natives_syntax = true;
i::FLAG_always_opt = false;
v8::HandleScope scope(CcTest::isolate());
v8::Local<v8::Context> env = CcTest::NewContext(PROFILER_EXTENSION);
v8::Context::Scope context_scope(env);
......@@ -706,21 +704,14 @@ TEST(BailoutReason) {
i::ProfilerExtension::set_profiler(iprofiler.get());
CHECK_EQ(0, iprofiler->GetProfilesCount());
v8::Local<v8::Function> function = CompileRun(
"function Debugger() {\n"
" startProfiling();\n"
"}"
"Debugger")
.As<v8::Function>();
i::Handle<i::JSFunction> i_function =
i::Handle<i::JSFunction>::cast(v8::Utils::OpenHandle(*function));
// Set a high opt count to trigger bail out.
i_function->shared()->set_opt_count(10000);
CompileRun(
"%OptimizeFunctionOnNextCall(Debugger);"
"Debugger();"
"stopProfiling()");
v8::Local<v8::Script> script =
v8_compile(v8_str("function Debugger() {\n"
" debugger;\n"
" startProfiling();\n"
"}\n"
"Debugger();\n"
"stopProfiling();"));
script->Run(v8::Isolate::GetCurrent()->GetCurrentContext()).ToLocalChecked();
CHECK_EQ(1, iprofiler->GetProfilesCount());
const v8::CpuProfile* profile = i::ProfilerExtension::last_profile;
CHECK(profile);
......@@ -730,11 +721,11 @@ TEST(BailoutReason) {
// The tree should look like this:
// (root)
// ""
// kFunctionBeingDebugged
// kDebuggerStatement
current = PickChild(current, "");
CHECK(const_cast<v8::CpuProfileNode*>(current));
current = PickChild(current, "Debugger");
CHECK(const_cast<v8::CpuProfileNode*>(current));
CHECK(!strcmp("Deoptimized too many times", current->GetBailoutReason()));
CHECK(!strcmp("DebuggerStatement", current->GetBailoutReason()));
}
......@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --no-always-opt
Debug = debug.Debug;
var listened = false;
......
......@@ -25,7 +25,6 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// Flags: --no-always-opt
var Debug = debug.Debug;
......
......@@ -29,8 +29,6 @@
// Test debug evaluation for functions without local context, but with
// nested catch contexts.
// Flags: --no-always-opt
"use strict";
var x;
......
......@@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --no-always-opt
Debug = debug.Debug;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment