OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/objects.h" | 5 #include "src/objects.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <iomanip> | 8 #include <iomanip> |
9 #include <sstream> | 9 #include <sstream> |
10 | 10 |
(...skipping 10892 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10903 DCHECK(script->line_ends()->IsFixedArray()); | 10903 DCHECK(script->line_ends()->IsFixedArray()); |
10904 } | 10904 } |
10905 | 10905 |
10906 | 10906 |
10907 int Script::GetColumnNumber(Handle<Script> script, int code_pos) { | 10907 int Script::GetColumnNumber(Handle<Script> script, int code_pos) { |
10908 int line_number = GetLineNumber(script, code_pos); | 10908 int line_number = GetLineNumber(script, code_pos); |
10909 if (line_number == -1) return -1; | 10909 if (line_number == -1) return -1; |
10910 | 10910 |
10911 DisallowHeapAllocation no_allocation; | 10911 DisallowHeapAllocation no_allocation; |
10912 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); | 10912 FixedArray* line_ends_array = FixedArray::cast(script->line_ends()); |
10913 line_number = line_number - script->line_offset()->value(); | 10913 line_number = line_number - script->line_offset(); |
10914 if (line_number == 0) return code_pos + script->column_offset()->value(); | 10914 if (line_number == 0) return code_pos + script->column_offset(); |
10915 int prev_line_end_pos = | 10915 int prev_line_end_pos = |
10916 Smi::cast(line_ends_array->get(line_number - 1))->value(); | 10916 Smi::cast(line_ends_array->get(line_number - 1))->value(); |
10917 return code_pos - (prev_line_end_pos + 1); | 10917 return code_pos - (prev_line_end_pos + 1); |
10918 } | 10918 } |
10919 | 10919 |
10920 | 10920 |
10921 int Script::GetLineNumberWithArray(int code_pos) { | 10921 int Script::GetLineNumberWithArray(int code_pos) { |
10922 DisallowHeapAllocation no_allocation; | 10922 DisallowHeapAllocation no_allocation; |
10923 DCHECK(line_ends()->IsFixedArray()); | 10923 DCHECK(line_ends()->IsFixedArray()); |
10924 FixedArray* line_ends_array = FixedArray::cast(line_ends()); | 10924 FixedArray* line_ends_array = FixedArray::cast(line_ends()); |
10925 int line_ends_len = line_ends_array->length(); | 10925 int line_ends_len = line_ends_array->length(); |
10926 if (line_ends_len == 0) return -1; | 10926 if (line_ends_len == 0) return -1; |
10927 | 10927 |
10928 if ((Smi::cast(line_ends_array->get(0)))->value() >= code_pos) { | 10928 if ((Smi::cast(line_ends_array->get(0)))->value() >= code_pos) { |
10929 return line_offset()->value(); | 10929 return line_offset(); |
10930 } | 10930 } |
10931 | 10931 |
10932 int left = 0; | 10932 int left = 0; |
10933 int right = line_ends_len; | 10933 int right = line_ends_len; |
10934 while (int half = (right - left) / 2) { | 10934 while (int half = (right - left) / 2) { |
10935 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { | 10935 if ((Smi::cast(line_ends_array->get(left + half)))->value() > code_pos) { |
10936 right -= half; | 10936 right -= half; |
10937 } else { | 10937 } else { |
10938 left += half; | 10938 left += half; |
10939 } | 10939 } |
10940 } | 10940 } |
10941 return right + line_offset()->value(); | 10941 return right + line_offset(); |
10942 } | 10942 } |
10943 | 10943 |
10944 | 10944 |
10945 int Script::GetLineNumber(Handle<Script> script, int code_pos) { | 10945 int Script::GetLineNumber(Handle<Script> script, int code_pos) { |
10946 InitLineEnds(script); | 10946 InitLineEnds(script); |
10947 return script->GetLineNumberWithArray(code_pos); | 10947 return script->GetLineNumberWithArray(code_pos); |
10948 } | 10948 } |
10949 | 10949 |
10950 | 10950 |
10951 int Script::GetLineNumber(int code_pos) { | 10951 int Script::GetLineNumber(int code_pos) { |
(...skipping 5210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16162 for (int i = 0; i < old_break_points->length(); i++) { | 16162 for (int i = 0; i < old_break_points->length(); i++) { |
16163 new_break_points->set(i, old_break_points->get(i)); | 16163 new_break_points->set(i, old_break_points->get(i)); |
16164 } | 16164 } |
16165 index = old_break_points->length(); | 16165 index = old_break_points->length(); |
16166 } | 16166 } |
16167 DCHECK(index != kNoBreakPointInfo); | 16167 DCHECK(index != kNoBreakPointInfo); |
16168 | 16168 |
16169 // Allocate new BreakPointInfo object and set the break point. | 16169 // Allocate new BreakPointInfo object and set the break point. |
16170 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( | 16170 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( |
16171 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); | 16171 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); |
16172 new_break_point_info->set_code_position(Smi::FromInt(code_position)); | 16172 new_break_point_info->set_code_position(code_position); |
16173 new_break_point_info->set_source_position(Smi::FromInt(source_position)); | 16173 new_break_point_info->set_source_position(source_position); |
16174 new_break_point_info-> | 16174 new_break_point_info->set_statement_position(statement_position); |
16175 set_statement_position(Smi::FromInt(statement_position)); | |
16176 new_break_point_info->set_break_point_objects( | 16175 new_break_point_info->set_break_point_objects( |
16177 isolate->heap()->undefined_value()); | 16176 isolate->heap()->undefined_value()); |
16178 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); | 16177 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); |
16179 debug_info->break_points()->set(index, *new_break_point_info); | 16178 debug_info->break_points()->set(index, *new_break_point_info); |
16180 } | 16179 } |
16181 | 16180 |
16182 | 16181 |
16183 // Get the break point objects for a code position. | 16182 // Get the break point objects for a code position. |
16184 Handle<Object> DebugInfo::GetBreakPointObjects(int code_position) { | 16183 Handle<Object> DebugInfo::GetBreakPointObjects(int code_position) { |
16185 Object* break_point_info = GetBreakPointInfo(code_position); | 16184 Object* break_point_info = GetBreakPointInfo(code_position); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16227 | 16226 |
16228 | 16227 |
16229 // Find the index of the break point info object for the specified code | 16228 // Find the index of the break point info object for the specified code |
16230 // position. | 16229 // position. |
16231 int DebugInfo::GetBreakPointInfoIndex(int code_position) { | 16230 int DebugInfo::GetBreakPointInfoIndex(int code_position) { |
16232 if (break_points()->IsUndefined()) return kNoBreakPointInfo; | 16231 if (break_points()->IsUndefined()) return kNoBreakPointInfo; |
16233 for (int i = 0; i < break_points()->length(); i++) { | 16232 for (int i = 0; i < break_points()->length(); i++) { |
16234 if (!break_points()->get(i)->IsUndefined()) { | 16233 if (!break_points()->get(i)->IsUndefined()) { |
16235 BreakPointInfo* break_point_info = | 16234 BreakPointInfo* break_point_info = |
16236 BreakPointInfo::cast(break_points()->get(i)); | 16235 BreakPointInfo::cast(break_points()->get(i)); |
16237 if (break_point_info->code_position()->value() == code_position) { | 16236 if (break_point_info->code_position() == code_position) { |
16238 return i; | 16237 return i; |
16239 } | 16238 } |
16240 } | 16239 } |
16241 } | 16240 } |
16242 return kNoBreakPointInfo; | 16241 return kNoBreakPointInfo; |
16243 } | 16242 } |
16244 | 16243 |
16245 | 16244 |
16246 // Remove the specified break point object. | 16245 // Remove the specified break point object. |
16247 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, | 16246 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16745 if (cell->value() != *new_value) { | 16744 if (cell->value() != *new_value) { |
16746 cell->set_value(*new_value); | 16745 cell->set_value(*new_value); |
16747 Isolate* isolate = cell->GetIsolate(); | 16746 Isolate* isolate = cell->GetIsolate(); |
16748 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 16747 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
16749 isolate, DependentCode::kPropertyCellChangedGroup); | 16748 isolate, DependentCode::kPropertyCellChangedGroup); |
16750 } | 16749 } |
16751 } | 16750 } |
16752 | 16751 |
16753 } // namespace internal | 16752 } // namespace internal |
16754 } // namespace v8 | 16753 } // namespace v8 |
OLD | NEW |