Commit f6bc2088 authored by Alexey Kozyatinskiy's avatar Alexey Kozyatinskiy Committed by Commit Bot

[debugger] removed BreakPositionAlignment.STATEMENT_ALIGNED

Inspector uses only BREAK_POSITION_ALIGNED, no tests pass STATEMENT_ALIGNED. It's exposed only with debugger API but I'm pretty sure that nobody actually uses it and as far as mirrors API is deprecated - it's time to remove it.

R=jgruber@chromium.org

Bug: none
Change-Id: I28d62e145811d3eb6f4d64007c47c51b2ecbaf0f
Reviewed-on: https://chromium-review.googlesource.com/536934
Commit-Queue: Aleksey Kozyatinskiy <kozyatinskiy@chromium.org>
Reviewed-by: 's avatarJakob Gruber <jgruber@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46056}
parent 932fd3ba
...@@ -116,12 +116,12 @@ bool BreakLocation::HasBreakPoint(Handle<DebugInfo> debug_info) const { ...@@ -116,12 +116,12 @@ bool BreakLocation::HasBreakPoint(Handle<DebugInfo> debug_info) const {
if (abstract_code_->IsCode()) { if (abstract_code_->IsCode()) {
DCHECK_EQ(debug_info->DebugCode(), abstract_code_->GetCode()); DCHECK_EQ(debug_info->DebugCode(), abstract_code_->GetCode());
CodeBreakIterator it(debug_info); CodeBreakIterator it(debug_info);
it.SkipToPosition(position_, BREAK_POSITION_ALIGNED); it.SkipToPosition(position_);
return it.code_offset() == code_offset_; return it.code_offset() == code_offset_;
} else { } else {
DCHECK(abstract_code_->IsBytecodeArray()); DCHECK(abstract_code_->IsBytecodeArray());
BytecodeArrayBreakIterator it(debug_info); BytecodeArrayBreakIterator it(debug_info);
it.SkipToPosition(position_, BREAK_POSITION_ALIGNED); it.SkipToPosition(position_);
return it.code_offset() == code_offset_; return it.code_offset() == code_offset_;
} }
} }
...@@ -159,18 +159,11 @@ BreakIterator::BreakIterator(Handle<DebugInfo> debug_info) ...@@ -159,18 +159,11 @@ BreakIterator::BreakIterator(Handle<DebugInfo> debug_info)
statement_position_ = position_; statement_position_ = position_;
} }
int BreakIterator::BreakIndexFromPosition(int source_position, int BreakIterator::BreakIndexFromPosition(int source_position) {
BreakPositionAlignment alignment) {
int distance = kMaxInt; int distance = kMaxInt;
int closest_break = break_index(); int closest_break = break_index();
while (!Done()) { while (!Done()) {
int next_position; int next_position = position();
if (alignment == STATEMENT_ALIGNED) {
next_position = statement_position();
} else {
DCHECK(alignment == BREAK_POSITION_ALIGNED);
next_position = position();
}
if (source_position <= next_position && if (source_position <= next_position &&
next_position - source_position < distance) { next_position - source_position < distance) {
closest_break = break_index(); closest_break = break_index();
...@@ -243,10 +236,9 @@ DebugBreakType CodeBreakIterator::GetDebugBreakType() { ...@@ -243,10 +236,9 @@ DebugBreakType CodeBreakIterator::GetDebugBreakType() {
} }
} }
void CodeBreakIterator::SkipToPosition(int position, void CodeBreakIterator::SkipToPosition(int position) {
BreakPositionAlignment alignment) {
CodeBreakIterator it(debug_info_); CodeBreakIterator it(debug_info_);
SkipTo(it.BreakIndexFromPosition(position, alignment)); SkipTo(it.BreakIndexFromPosition(position));
} }
int CodeBreakIterator::code_offset() { int CodeBreakIterator::code_offset() {
...@@ -332,10 +324,9 @@ DebugBreakType BytecodeArrayBreakIterator::GetDebugBreakType() { ...@@ -332,10 +324,9 @@ DebugBreakType BytecodeArrayBreakIterator::GetDebugBreakType() {
} }
} }
void BytecodeArrayBreakIterator::SkipToPosition( void BytecodeArrayBreakIterator::SkipToPosition(int position) {
int position, BreakPositionAlignment alignment) {
BytecodeArrayBreakIterator it(debug_info_); BytecodeArrayBreakIterator it(debug_info_);
SkipTo(it.BreakIndexFromPosition(position, alignment)); SkipTo(it.BreakIndexFromPosition(position));
} }
void BytecodeArrayBreakIterator::SetDebugBreak() { void BytecodeArrayBreakIterator::SetDebugBreak() {
...@@ -687,8 +678,7 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function, ...@@ -687,8 +678,7 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
DCHECK(*source_position >= 0); DCHECK(*source_position >= 0);
// Find the break point and change it. // Find the break point and change it.
*source_position = *source_position = FindBreakablePosition(debug_info, *source_position);
FindBreakablePosition(debug_info, *source_position, STATEMENT_ALIGNED);
DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object); DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object);
// At least one active break point now. // At least one active break point now.
DCHECK(debug_info->GetBreakPointCount() > 0); DCHECK(debug_info->GetBreakPointCount() > 0);
...@@ -700,11 +690,9 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function, ...@@ -700,11 +690,9 @@ bool Debug::SetBreakPoint(Handle<JSFunction> function,
return true; return true;
} }
bool Debug::SetBreakPointForScript(Handle<Script> script, bool Debug::SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object, Handle<Object> break_point_object,
int* source_position, int* source_position) {
BreakPositionAlignment alignment) {
if (script->type() == Script::TYPE_WASM) { if (script->type() == Script::TYPE_WASM) {
Handle<WasmCompiledModule> compiled_module( Handle<WasmCompiledModule> compiled_module(
WasmCompiledModule::cast(script->wasm_compiled_module()), isolate_); WasmCompiledModule::cast(script->wasm_compiled_module()), isolate_);
...@@ -732,8 +720,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, ...@@ -732,8 +720,7 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
Handle<DebugInfo> debug_info(shared->GetDebugInfo()); Handle<DebugInfo> debug_info(shared->GetDebugInfo());
// Find the break point and change it. // Find the break point and change it.
*source_position = *source_position = FindBreakablePosition(debug_info, *source_position);
FindBreakablePosition(debug_info, *source_position, alignment);
DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object); DebugInfo::SetBreakPoint(debug_info, *source_position, break_point_object);
// At least one active break point now. // At least one active break point now.
DCHECK(debug_info->GetBreakPointCount() > 0); DCHECK(debug_info->GetBreakPointCount() > 0);
...@@ -746,23 +733,19 @@ bool Debug::SetBreakPointForScript(Handle<Script> script, ...@@ -746,23 +733,19 @@ bool Debug::SetBreakPointForScript(Handle<Script> script,
} }
int Debug::FindBreakablePosition(Handle<DebugInfo> debug_info, int Debug::FindBreakablePosition(Handle<DebugInfo> debug_info,
int source_position, int source_position) {
BreakPositionAlignment alignment) {
int statement_position;
int position; int position;
if (debug_info->HasDebugCode()) { if (debug_info->HasDebugCode()) {
CodeBreakIterator it(debug_info); CodeBreakIterator it(debug_info);
it.SkipToPosition(source_position, alignment); it.SkipToPosition(source_position);
statement_position = it.statement_position();
position = it.position(); position = it.position();
} else { } else {
DCHECK(debug_info->HasDebugBytecodeArray()); DCHECK(debug_info->HasDebugBytecodeArray());
BytecodeArrayBreakIterator it(debug_info); BytecodeArrayBreakIterator it(debug_info);
it.SkipToPosition(source_position, alignment); it.SkipToPosition(source_position);
statement_position = it.statement_position();
position = it.position(); position = it.position();
} }
return alignment == STATEMENT_ALIGNED ? statement_position : position; return position;
} }
void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) { void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
...@@ -775,12 +758,12 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) { ...@@ -775,12 +758,12 @@ void Debug::ApplyBreakPoints(Handle<DebugInfo> debug_info) {
if (info->GetBreakPointCount() == 0) continue; if (info->GetBreakPointCount() == 0) continue;
if (debug_info->HasDebugCode()) { if (debug_info->HasDebugCode()) {
CodeBreakIterator it(debug_info); CodeBreakIterator it(debug_info);
it.SkipToPosition(info->source_position(), BREAK_POSITION_ALIGNED); it.SkipToPosition(info->source_position());
it.SetDebugBreak(); it.SetDebugBreak();
} }
if (debug_info->HasDebugBytecodeArray()) { if (debug_info->HasDebugBytecodeArray()) {
BytecodeArrayBreakIterator it(debug_info); BytecodeArrayBreakIterator it(debug_info);
it.SkipToPosition(info->source_position(), BREAK_POSITION_ALIGNED); it.SkipToPosition(info->source_position());
it.SetDebugBreak(); it.SetDebugBreak();
} }
} }
...@@ -1115,8 +1098,7 @@ void Debug::PrepareStep(StepAction step_action) { ...@@ -1115,8 +1098,7 @@ void Debug::PrepareStep(StepAction step_action) {
// Simple function for returning the source positions for active break points. // Simple function for returning the source positions for active break points.
Handle<Object> Debug::GetSourceBreakLocations( Handle<Object> Debug::GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared) {
BreakPositionAlignment position_alignment) {
Isolate* isolate = shared->GetIsolate(); Isolate* isolate = shared->GetIsolate();
if (!shared->HasBreakInfo()) { if (!shared->HasBreakInfo()) {
return isolate->factory()->undefined_value(); return isolate->factory()->undefined_value();
...@@ -1134,25 +1116,10 @@ Handle<Object> Debug::GetSourceBreakLocations( ...@@ -1134,25 +1116,10 @@ Handle<Object> Debug::GetSourceBreakLocations(
BreakPointInfo::cast(debug_info->break_points()->get(i)); BreakPointInfo::cast(debug_info->break_points()->get(i));
int break_points = break_point_info->GetBreakPointCount(); int break_points = break_point_info->GetBreakPointCount();
if (break_points == 0) continue; if (break_points == 0) continue;
Smi* position = NULL; for (int j = 0; j < break_points; ++j) {
if (position_alignment == STATEMENT_ALIGNED) { locations->set(count++,
if (debug_info->HasDebugCode()) { Smi::FromInt(break_point_info->source_position()));
CodeBreakIterator it(debug_info);
it.SkipToPosition(break_point_info->source_position(),
BREAK_POSITION_ALIGNED);
position = Smi::FromInt(it.statement_position());
} else {
DCHECK(debug_info->HasDebugBytecodeArray());
BytecodeArrayBreakIterator it(debug_info);
it.SkipToPosition(break_point_info->source_position(),
BREAK_POSITION_ALIGNED);
position = Smi::FromInt(it.statement_position());
}
} else {
DCHECK_EQ(BREAK_POSITION_ALIGNED, position_alignment);
position = Smi::FromInt(break_point_info->source_position());
} }
for (int j = 0; j < break_points; ++j) locations->set(count++, position);
} }
} }
return locations; return locations;
......
...@@ -50,13 +50,6 @@ enum ExceptionBreakType { ...@@ -50,13 +50,6 @@ enum ExceptionBreakType {
}; };
// The different types of breakpoint position alignments.
// Must match Debug.BreakPositionAlignment in debug.js
enum BreakPositionAlignment {
STATEMENT_ALIGNED = 0,
BREAK_POSITION_ALIGNED = 1
};
enum DebugBreakType { enum DebugBreakType {
NOT_DEBUG_BREAK, NOT_DEBUG_BREAK,
DEBUGGER_STATEMENT, DEBUGGER_STATEMENT,
...@@ -149,7 +142,7 @@ class BreakIterator { ...@@ -149,7 +142,7 @@ class BreakIterator {
protected: protected:
explicit BreakIterator(Handle<DebugInfo> debug_info); explicit BreakIterator(Handle<DebugInfo> debug_info);
int BreakIndexFromPosition(int position, BreakPositionAlignment alignment); int BreakIndexFromPosition(int position);
Isolate* isolate() { return debug_info_->GetIsolate(); } Isolate* isolate() { return debug_info_->GetIsolate(); }
...@@ -176,7 +169,7 @@ class CodeBreakIterator : public BreakIterator { ...@@ -176,7 +169,7 @@ class CodeBreakIterator : public BreakIterator {
void ClearDebugBreak() override; void ClearDebugBreak() override;
void SetDebugBreak() override; void SetDebugBreak() override;
void SkipToPosition(int position, BreakPositionAlignment alignment); void SkipToPosition(int position);
int code_offset() override; int code_offset() override;
...@@ -205,7 +198,7 @@ class BytecodeArrayBreakIterator : public BreakIterator { ...@@ -205,7 +198,7 @@ class BytecodeArrayBreakIterator : public BreakIterator {
void ClearDebugBreak() override; void ClearDebugBreak() override;
void SetDebugBreak() override; void SetDebugBreak() override;
void SkipToPosition(int position, BreakPositionAlignment alignment); void SkipToPosition(int position);
int code_offset() override { return source_position_iterator_.code_offset(); } int code_offset() override { return source_position_iterator_.code_offset(); }
...@@ -294,8 +287,7 @@ class Debug { ...@@ -294,8 +287,7 @@ class Debug {
int* source_position); int* source_position);
bool SetBreakPointForScript(Handle<Script> script, bool SetBreakPointForScript(Handle<Script> script,
Handle<Object> break_point_object, Handle<Object> break_point_object,
int* source_position, int* source_position);
BreakPositionAlignment alignment);
void ClearBreakPoint(Handle<Object> break_point_object); void ClearBreakPoint(Handle<Object> break_point_object);
void ChangeBreakOnException(ExceptionBreakType type, bool enable); void ChangeBreakOnException(ExceptionBreakType type, bool enable);
bool IsBreakOnException(ExceptionBreakType type); bool IsBreakOnException(ExceptionBreakType type);
...@@ -348,8 +340,7 @@ class Debug { ...@@ -348,8 +340,7 @@ class Debug {
int position); int position);
static Handle<Object> GetSourceBreakLocations( static Handle<Object> GetSourceBreakLocations(
Handle<SharedFunctionInfo> shared, Handle<SharedFunctionInfo> shared);
BreakPositionAlignment position_aligment);
// Check whether a global object is the debug global object. // Check whether a global object is the debug global object.
bool IsDebugGlobal(JSGlobalObject* global); bool IsDebugGlobal(JSGlobalObject* global);
...@@ -483,8 +474,7 @@ class Debug { ...@@ -483,8 +474,7 @@ class Debug {
void ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data); void ProcessDebugEvent(v8::DebugEvent event, Handle<JSObject> event_data);
// Find the closest source position for a break point for a given position. // Find the closest source position for a break point for a given position.
int FindBreakablePosition(Handle<DebugInfo> debug_info, int source_position, int FindBreakablePosition(Handle<DebugInfo> debug_info, int source_position);
BreakPositionAlignment alignment);
// Instrument code to break at break points. // Instrument code to break at break points.
void ApplyBreakPoints(Handle<DebugInfo> debug_info); void ApplyBreakPoints(Handle<DebugInfo> debug_info);
// Clear code from instrumentation. // Clear code from instrumentation.
......
...@@ -63,13 +63,6 @@ Debug.ScriptBreakPointType = { ScriptId: 0, ...@@ -63,13 +63,6 @@ Debug.ScriptBreakPointType = { ScriptId: 0,
ScriptName: 1, ScriptName: 1,
ScriptRegExp: 2 }; ScriptRegExp: 2 };
// The different types of breakpoint position alignments.
// Must match BreakPositionAlignment in debug.h.
Debug.BreakPositionAlignment = {
Statement: 0,
BreakPosition: 1
};
function ScriptTypeFlag(type) { function ScriptTypeFlag(type) {
return (1 << type); return (1 << type);
} }
...@@ -221,7 +214,7 @@ function IsBreakPointTriggered(break_id, break_point) { ...@@ -221,7 +214,7 @@ function IsBreakPointTriggered(break_id, break_point) {
// script name or script id and the break point is represented as line and // script name or script id and the break point is represented as line and
// column. // column.
function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
opt_groupId, opt_position_alignment) { opt_groupId) {
this.type_ = type; this.type_ = type;
if (type == Debug.ScriptBreakPointType.ScriptId) { if (type == Debug.ScriptBreakPointType.ScriptId) {
this.script_id_ = script_id_or_name; this.script_id_ = script_id_or_name;
...@@ -235,8 +228,6 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, ...@@ -235,8 +228,6 @@ function ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
this.line_ = opt_line || 0; this.line_ = opt_line || 0;
this.column_ = opt_column; this.column_ = opt_column;
this.groupId_ = opt_groupId; this.groupId_ = opt_groupId;
this.position_alignment_ = IS_UNDEFINED(opt_position_alignment)
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
this.active_ = true; this.active_ = true;
this.condition_ = null; this.condition_ = null;
this.break_points_ = []; this.break_points_ = [];
...@@ -378,7 +369,6 @@ ScriptBreakPoint.prototype.set = function (script) { ...@@ -378,7 +369,6 @@ ScriptBreakPoint.prototype.set = function (script) {
// Create a break point object and set the break point. // Create a break point object and set the break point.
var break_point = MakeBreakPoint(position, this); var break_point = MakeBreakPoint(position, this);
var actual_position = %SetScriptBreakPoint(script, position, var actual_position = %SetScriptBreakPoint(script, position,
this.position_alignment_,
break_point); break_point);
if (IS_UNDEFINED(actual_position)) { if (IS_UNDEFINED(actual_position)) {
actual_position = position; actual_position = position;
...@@ -559,8 +549,7 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) { ...@@ -559,8 +549,7 @@ Debug.setBreakPoint = function(func, opt_line, opt_column, opt_condition) {
Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, Debug.setBreakPointByScriptIdAndPosition = function(script_id, position,
condition, enabled, condition, enabled)
opt_position_alignment)
{ {
var break_point = MakeBreakPoint(position); var break_point = MakeBreakPoint(position);
break_point.setCondition(condition); break_point.setCondition(condition);
...@@ -569,10 +558,7 @@ Debug.setBreakPointByScriptIdAndPosition = function(script_id, position, ...@@ -569,10 +558,7 @@ Debug.setBreakPointByScriptIdAndPosition = function(script_id, position,
} }
var script = scriptById(script_id); var script = scriptById(script_id);
if (script) { if (script) {
var position_alignment = IS_UNDEFINED(opt_position_alignment) break_point.actual_position = %SetScriptBreakPoint(script, position, break_point);
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
break_point.actual_position = %SetScriptBreakPoint(script, position,
position_alignment, break_point);
} }
return break_point; return break_point;
}; };
...@@ -654,11 +640,11 @@ Debug.findScriptBreakPoint = function(break_point_number, remove) { ...@@ -654,11 +640,11 @@ Debug.findScriptBreakPoint = function(break_point_number, remove) {
// specified source line and column within that line. // specified source line and column within that line.
Debug.setScriptBreakPoint = function(type, script_id_or_name, Debug.setScriptBreakPoint = function(type, script_id_or_name,
opt_line, opt_column, opt_condition, opt_line, opt_column, opt_condition,
opt_groupId, opt_position_alignment) { opt_groupId) {
// Create script break point object. // Create script break point object.
var script_break_point = var script_break_point =
new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column, new ScriptBreakPoint(type, script_id_or_name, opt_line, opt_column,
opt_groupId, opt_position_alignment); opt_groupId);
// Assign number to the new script break point and add it. // Assign number to the new script break point and add it.
script_break_point.number_ = next_break_point_number++; script_break_point.number_ = next_break_point_number++;
...@@ -680,12 +666,10 @@ Debug.setScriptBreakPoint = function(type, script_id_or_name, ...@@ -680,12 +666,10 @@ Debug.setScriptBreakPoint = function(type, script_id_or_name,
Debug.setScriptBreakPointById = function(script_id, Debug.setScriptBreakPointById = function(script_id,
opt_line, opt_column, opt_line, opt_column,
opt_condition, opt_groupId, opt_condition, opt_groupId) {
opt_position_alignment) {
return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId, return this.setScriptBreakPoint(Debug.ScriptBreakPointType.ScriptId,
script_id, opt_line, opt_column, script_id, opt_line, opt_column,
opt_condition, opt_groupId, opt_condition, opt_groupId);
opt_position_alignment);
}; };
...@@ -759,13 +743,11 @@ Debug.isBreakOnUncaughtException = function() { ...@@ -759,13 +743,11 @@ Debug.isBreakOnUncaughtException = function() {
return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught); return !!%IsBreakOnException(Debug.ExceptionBreak.Uncaught);
}; };
Debug.showBreakPoints = function(f, full, opt_position_alignment) { Debug.showBreakPoints = function(f, full) {
if (!IS_FUNCTION(f)) throw %make_error(kDebuggerType); if (!IS_FUNCTION(f)) throw %make_error(kDebuggerType);
var source = full ? this.scriptSource(f) : this.source(f); var source = full ? this.scriptSource(f) : this.source(f);
var offset = full ? 0 : this.sourcePosition(f); var offset = full ? 0 : this.sourcePosition(f);
var position_alignment = IS_UNDEFINED(opt_position_alignment) var locations = %GetBreakLocations(f);
? Debug.BreakPositionAlignment.Statement : opt_position_alignment;
var locations = %GetBreakLocations(f, position_alignment);
if (!locations) return source; if (!locations) return source;
locations.sort(function(x, y) { return x - y; }); locations.sort(function(x, y) { return x - y; });
var result = ""; var result = "";
......
...@@ -108,7 +108,7 @@ DebuggerScript.getGeneratorScopes = function(gen) ...@@ -108,7 +108,7 @@ DebuggerScript.getGeneratorScopes = function(gen)
*/ */
DebuggerScript.setBreakpoint = function(execState, info) DebuggerScript.setBreakpoint = function(execState, info)
{ {
var breakId = Debug.setScriptBreakPointById(info.sourceID, info.lineNumber, info.columnNumber, info.condition, undefined, Debug.BreakPositionAlignment.BreakPosition); var breakId = Debug.setScriptBreakPointById(info.sourceID, info.lineNumber, info.columnNumber, info.condition, undefined);
var locations = Debug.findBreakPointActualLocations(breakId); var locations = Debug.findBreakPointActualLocations(breakId);
if (!locations.length) if (!locations.length)
return undefined; return undefined;
......
...@@ -55,9 +55,8 @@ Debug.scripts = function() {} ...@@ -55,9 +55,8 @@ Debug.scripts = function() {}
* @param {number=} column * @param {number=} column
* @param {string=} condition * @param {string=} condition
* @param {string=} groupId * @param {string=} groupId
* @param {Debug.BreakPositionAlignment=} positionAlignment
*/ */
Debug.setScriptBreakPointById = function(scriptId, line, column, condition, groupId, positionAlignment) {} Debug.setScriptBreakPointById = function(scriptId, line, column, condition, groupId) {}
/** /**
* @param {number} breakId * @param {number} breakId
...@@ -72,13 +71,6 @@ Debug.findBreakPointActualLocations = function(breakId) {} ...@@ -72,13 +71,6 @@ Debug.findBreakPointActualLocations = function(breakId) {}
*/ */
Debug.findBreakPoint = function(breakId, remove) {} Debug.findBreakPoint = function(breakId, remove) {}
/** @enum */
const BreakPositionAlignment = {
Statement: 0,
BreakPosition: 1
};
Debug.BreakPositionAlignment = BreakPositionAlignment;
/** @const */ /** @const */
var LiveEdit = {} var LiveEdit = {}
......
...@@ -1057,28 +1057,15 @@ RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) { ...@@ -1057,28 +1057,15 @@ RUNTIME_FUNCTION(Runtime_SetBreakPointsActive) {
} }
static bool IsPositionAlignmentCodeCorrect(int alignment) {
return alignment == STATEMENT_ALIGNED || alignment == BREAK_POSITION_ALIGNED;
}
RUNTIME_FUNCTION(Runtime_GetBreakLocations) { RUNTIME_FUNCTION(Runtime_GetBreakLocations) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(2, args.length()); DCHECK_EQ(1, args.length());
CHECK(isolate->debug()->is_active()); CHECK(isolate->debug()->is_active());
CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0);
CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[1]);
if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
return isolate->ThrowIllegalOperation();
}
BreakPositionAlignment alignment =
static_cast<BreakPositionAlignment>(statement_aligned_code);
Handle<SharedFunctionInfo> shared(fun->shared()); Handle<SharedFunctionInfo> shared(fun->shared());
// Find the number of break points // Find the number of break points
Handle<Object> break_locations = Handle<Object> break_locations = Debug::GetSourceBreakLocations(shared);
Debug::GetSourceBreakLocations(shared, alignment);
if (break_locations->IsUndefined(isolate)) { if (break_locations->IsUndefined(isolate)) {
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
} }
...@@ -1109,29 +1096,20 @@ RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) { ...@@ -1109,29 +1096,20 @@ RUNTIME_FUNCTION(Runtime_SetFunctionBreakPoint) {
return Smi::FromInt(source_position); return Smi::FromInt(source_position);
} }
// Changes the state of a break point in a script and returns source position // Changes the state of a break point in a script and returns source position
// where break point was set. NOTE: Regarding performance see the NOTE for // where break point was set. NOTE: Regarding performance see the NOTE for
// GetScriptFromScriptData. // GetScriptFromScriptData.
// args[0]: script to set break point in // args[0]: script to set break point in
// args[1]: number: break source position (within the script source) // args[1]: number: break source position (within the script source)
// args[2]: number, breakpoint position alignment // args[2]: number: break point object
// args[3]: number: break point object
RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK_EQ(4, args.length()); DCHECK_EQ(3, args.length());
CHECK(isolate->debug()->is_active()); CHECK(isolate->debug()->is_active());
CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0); CONVERT_ARG_HANDLE_CHECKED(JSValue, wrapper, 0);
CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]); CONVERT_NUMBER_CHECKED(int32_t, source_position, Int32, args[1]);
CHECK(source_position >= 0); CHECK(source_position >= 0);
CONVERT_NUMBER_CHECKED(int32_t, statement_aligned_code, Int32, args[2]); CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 2);
CONVERT_ARG_HANDLE_CHECKED(Object, break_point_object_arg, 3);
if (!IsPositionAlignmentCodeCorrect(statement_aligned_code)) {
return isolate->ThrowIllegalOperation();
}
BreakPositionAlignment alignment =
static_cast<BreakPositionAlignment>(statement_aligned_code);
// Get the script from the script wrapper. // Get the script from the script wrapper.
CHECK(wrapper->value()->IsScript()); CHECK(wrapper->value()->IsScript());
...@@ -1139,7 +1117,7 @@ RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) { ...@@ -1139,7 +1117,7 @@ RUNTIME_FUNCTION(Runtime_SetScriptBreakPoint) {
// Set break point. // Set break point.
if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg, if (!isolate->debug()->SetBreakPointForScript(script, break_point_object_arg,
&source_position, alignment)) { &source_position)) {
return isolate->heap()->undefined_value(); return isolate->heap()->undefined_value();
} }
......
...@@ -166,9 +166,9 @@ namespace internal { ...@@ -166,9 +166,9 @@ namespace internal {
F(SetScopeVariableValue, 6, 1) \ F(SetScopeVariableValue, 6, 1) \
F(DebugPrintScopes, 0, 1) \ F(DebugPrintScopes, 0, 1) \
F(SetBreakPointsActive, 1, 1) \ F(SetBreakPointsActive, 1, 1) \
F(GetBreakLocations, 2, 1) \ F(GetBreakLocations, 1, 1) \
F(SetFunctionBreakPoint, 3, 1) \ F(SetFunctionBreakPoint, 3, 1) \
F(SetScriptBreakPoint, 4, 1) \ F(SetScriptBreakPoint, 3, 1) \
F(ClearBreakPoint, 1, 1) \ F(ClearBreakPoint, 1, 1) \
F(ChangeBreakOnException, 2, 1) \ F(ChangeBreakOnException, 2, 1) \
F(IsBreakOnException, 1, 1) \ F(IsBreakOnException, 1, 1) \
......
...@@ -67,13 +67,6 @@ class DebugWrapper { ...@@ -67,13 +67,6 @@ class DebugWrapper {
this.ExceptionBreak = { Caught : 0, this.ExceptionBreak = { Caught : 0,
Uncaught: 1 }; Uncaught: 1 };
// The different types of breakpoint position alignments.
// Must match BreakPositionAlignment in debug.h.
this.BreakPositionAlignment = {
Statement: 0,
BreakPosition: 1
};
// The different script break point types. // The different script break point types.
this.ScriptBreakPointType = { ScriptId: 0, this.ScriptBreakPointType = { ScriptId: 0,
ScriptName: 1, ScriptName: 1,
...@@ -180,14 +173,12 @@ class DebugWrapper { ...@@ -180,14 +173,12 @@ class DebugWrapper {
this.breakpoints.clear(); this.breakpoints.clear();
} }
showBreakPoints(f, opt_position_alignment) { showBreakPoints(f) {
if (!%IsFunction(f)) throw new Error("Not passed a Function"); if (!%IsFunction(f)) throw new Error("Not passed a Function");
const source = %FunctionGetSourceCode(f); const source = %FunctionGetSourceCode(f);
const offset = %FunctionGetScriptSourcePosition(f); const offset = %FunctionGetScriptSourcePosition(f);
const position_alignment = opt_position_alignment === undefined const locations = %GetBreakLocations(f);
? this.BreakPositionAlignment.Statement : opt_position_alignment;
const locations = %GetBreakLocations(f, position_alignment);
if (!locations) return source; if (!locations) return source;
......
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