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