OLD | NEW |
---|---|
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 14264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14275 if (target->is_inline_cache_stub()) { | 14275 if (target->is_inline_cache_stub()) { |
14276 if (kind == NULL || *kind == target->kind()) { | 14276 if (kind == NULL || *kind == target->kind()) { |
14277 IC::Clear(this->GetIsolate(), info->pc(), | 14277 IC::Clear(this->GetIsolate(), info->pc(), |
14278 info->host()->constant_pool()); | 14278 info->host()->constant_pool()); |
14279 } | 14279 } |
14280 } | 14280 } |
14281 } | 14281 } |
14282 } | 14282 } |
14283 | 14283 |
14284 | 14284 |
14285 int AbstractCode::SourcePosition(int offset) { | |
14286 if (IsBytecodeArray()) return GetBytecodeArray()->SourcePosition(offset); | |
14287 DCHECK(IsCode()); | |
14288 Code* code = GetCode(); | |
14289 Address pc = code->instruction_start() + offset; | |
14290 return code->SourcePosition(pc); | |
rmcilroy
2016/01/22 19:16:34
Nit, could you make SourcePosition take the offset
Yang
2016/01/28 09:09:53
Done.
| |
14291 } | |
14292 | |
14293 | |
14285 void SharedFunctionInfo::ClearTypeFeedbackInfo() { | 14294 void SharedFunctionInfo::ClearTypeFeedbackInfo() { |
14286 feedback_vector()->ClearSlots(this); | 14295 feedback_vector()->ClearSlots(this); |
14287 } | 14296 } |
14288 | 14297 |
14289 | 14298 |
14290 void SharedFunctionInfo::ClearTypeFeedbackInfoAtGCTime() { | 14299 void SharedFunctionInfo::ClearTypeFeedbackInfoAtGCTime() { |
14291 feedback_vector()->ClearSlotsAtGCTime(this); | 14300 feedback_vector()->ClearSlotsAtGCTime(this); |
14292 } | 14301 } |
14293 | 14302 |
14294 | 14303 |
(...skipping 672 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
14967 | 14976 |
14968 os << "RelocInfo (size = " << relocation_size() << ")\n"; | 14977 os << "RelocInfo (size = " << relocation_size() << ")\n"; |
14969 for (RelocIterator it(this); !it.done(); it.next()) { | 14978 for (RelocIterator it(this); !it.done(); it.next()) { |
14970 it.rinfo()->Print(GetIsolate(), os); | 14979 it.rinfo()->Print(GetIsolate(), os); |
14971 } | 14980 } |
14972 os << "\n"; | 14981 os << "\n"; |
14973 } | 14982 } |
14974 #endif // ENABLE_DISASSEMBLER | 14983 #endif // ENABLE_DISASSEMBLER |
14975 | 14984 |
14976 | 14985 |
14986 int BytecodeArray::SourcePosition(int offset) { | |
14987 // TODO(yangguo): implement this. | |
14988 return 0; | |
14989 } | |
14990 | |
14991 | |
14977 void BytecodeArray::Disassemble(std::ostream& os) { | 14992 void BytecodeArray::Disassemble(std::ostream& os) { |
14978 os << "Parameter count " << parameter_count() << "\n"; | 14993 os << "Parameter count " << parameter_count() << "\n"; |
14979 os << "Frame size " << frame_size() << "\n"; | 14994 os << "Frame size " << frame_size() << "\n"; |
14980 Vector<char> buf = Vector<char>::New(50); | 14995 Vector<char> buf = Vector<char>::New(50); |
14981 | 14996 |
14982 const uint8_t* first_bytecode_address = GetFirstBytecodeAddress(); | 14997 const uint8_t* first_bytecode_address = GetFirstBytecodeAddress(); |
14983 int bytecode_size = 0; | 14998 int bytecode_size = 0; |
14984 for (int i = 0; i < this->length(); i += bytecode_size) { | 14999 for (int i = 0; i < this->length(); i += bytecode_size) { |
14985 const uint8_t* bytecode_start = &first_bytecode_address[i]; | 15000 const uint8_t* bytecode_start = &first_bytecode_address[i]; |
14986 interpreter::Bytecode bytecode = | 15001 interpreter::Bytecode bytecode = |
(...skipping 4032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19019 ObjectHashTable::Remove(table, key, &was_present, hash); | 19034 ObjectHashTable::Remove(table, key, &was_present, hash); |
19020 weak_collection->set_table(*new_table); | 19035 weak_collection->set_table(*new_table); |
19021 if (*table != *new_table) { | 19036 if (*table != *new_table) { |
19022 // Zap the old table since we didn't record slots for its elements. | 19037 // Zap the old table since we didn't record slots for its elements. |
19023 table->FillWithHoles(0, table->length()); | 19038 table->FillWithHoles(0, table->length()); |
19024 } | 19039 } |
19025 return was_present; | 19040 return was_present; |
19026 } | 19041 } |
19027 | 19042 |
19028 | 19043 |
19029 // Check if there is a break point at this code position. | 19044 // Check if there is a break point at this code offset. |
19030 bool DebugInfo::HasBreakPoint(int code_position) { | 19045 bool DebugInfo::HasBreakPoint(int code_offset) { |
19031 // Get the break point info object for this code position. | 19046 // Get the break point info object for this code offset. |
19032 Object* break_point_info = GetBreakPointInfo(code_position); | 19047 Object* break_point_info = GetBreakPointInfo(code_offset); |
19033 | 19048 |
19034 // If there is no break point info object or no break points in the break | 19049 // If there is no break point info object or no break points in the break |
19035 // point info object there is no break point at this code position. | 19050 // point info object there is no break point at this code offset. |
19036 if (break_point_info->IsUndefined()) return false; | 19051 if (break_point_info->IsUndefined()) return false; |
19037 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; | 19052 return BreakPointInfo::cast(break_point_info)->GetBreakPointCount() > 0; |
19038 } | 19053 } |
19039 | 19054 |
19040 | 19055 |
19041 // Get the break point info object for this code position. | 19056 // Get the break point info object for this code offset. |
19042 Object* DebugInfo::GetBreakPointInfo(int code_position) { | 19057 Object* DebugInfo::GetBreakPointInfo(int code_offset) { |
19043 // Find the index of the break point info object for this code position. | 19058 // Find the index of the break point info object for this code offset. |
19044 int index = GetBreakPointInfoIndex(code_position); | 19059 int index = GetBreakPointInfoIndex(code_offset); |
19045 | 19060 |
19046 // Return the break point info object if any. | 19061 // Return the break point info object if any. |
19047 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); | 19062 if (index == kNoBreakPointInfo) return GetHeap()->undefined_value(); |
19048 return BreakPointInfo::cast(break_points()->get(index)); | 19063 return BreakPointInfo::cast(break_points()->get(index)); |
19049 } | 19064 } |
19050 | 19065 |
19051 | 19066 |
19052 // Clear a break point at the specified code position. | 19067 // Clear a break point at the specified code offset. |
19053 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, | 19068 void DebugInfo::ClearBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
19054 int code_position, | |
19055 Handle<Object> break_point_object) { | 19069 Handle<Object> break_point_object) { |
19056 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position), | 19070 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), |
19057 debug_info->GetIsolate()); | 19071 debug_info->GetIsolate()); |
19058 if (break_point_info->IsUndefined()) return; | 19072 if (break_point_info->IsUndefined()) return; |
19059 BreakPointInfo::ClearBreakPoint( | 19073 BreakPointInfo::ClearBreakPoint( |
19060 Handle<BreakPointInfo>::cast(break_point_info), | 19074 Handle<BreakPointInfo>::cast(break_point_info), |
19061 break_point_object); | 19075 break_point_object); |
19062 } | 19076 } |
19063 | 19077 |
19064 | 19078 |
19065 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, | 19079 void DebugInfo::SetBreakPoint(Handle<DebugInfo> debug_info, int code_offset, |
19066 int code_position, | 19080 int source_position, int statement_position, |
19067 int source_position, | |
19068 int statement_position, | |
19069 Handle<Object> break_point_object) { | 19081 Handle<Object> break_point_object) { |
19070 Isolate* isolate = debug_info->GetIsolate(); | 19082 Isolate* isolate = debug_info->GetIsolate(); |
19071 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_position), | 19083 Handle<Object> break_point_info(debug_info->GetBreakPointInfo(code_offset), |
19072 isolate); | 19084 isolate); |
19073 if (!break_point_info->IsUndefined()) { | 19085 if (!break_point_info->IsUndefined()) { |
19074 BreakPointInfo::SetBreakPoint( | 19086 BreakPointInfo::SetBreakPoint( |
19075 Handle<BreakPointInfo>::cast(break_point_info), | 19087 Handle<BreakPointInfo>::cast(break_point_info), |
19076 break_point_object); | 19088 break_point_object); |
19077 return; | 19089 return; |
19078 } | 19090 } |
19079 | 19091 |
19080 // Adding a new break point for a code position which did not have any | 19092 // Adding a new break point for a code offset which did not have any |
19081 // break points before. Try to find a free slot. | 19093 // break points before. Try to find a free slot. |
19082 int index = kNoBreakPointInfo; | 19094 int index = kNoBreakPointInfo; |
19083 for (int i = 0; i < debug_info->break_points()->length(); i++) { | 19095 for (int i = 0; i < debug_info->break_points()->length(); i++) { |
19084 if (debug_info->break_points()->get(i)->IsUndefined()) { | 19096 if (debug_info->break_points()->get(i)->IsUndefined()) { |
19085 index = i; | 19097 index = i; |
19086 break; | 19098 break; |
19087 } | 19099 } |
19088 } | 19100 } |
19089 if (index == kNoBreakPointInfo) { | 19101 if (index == kNoBreakPointInfo) { |
19090 // No free slot - extend break point info array. | 19102 // No free slot - extend break point info array. |
19091 Handle<FixedArray> old_break_points = | 19103 Handle<FixedArray> old_break_points = |
19092 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); | 19104 Handle<FixedArray>(FixedArray::cast(debug_info->break_points())); |
19093 Handle<FixedArray> new_break_points = | 19105 Handle<FixedArray> new_break_points = |
19094 isolate->factory()->NewFixedArray( | 19106 isolate->factory()->NewFixedArray( |
19095 old_break_points->length() + | 19107 old_break_points->length() + |
19096 DebugInfo::kEstimatedNofBreakPointsInFunction); | 19108 DebugInfo::kEstimatedNofBreakPointsInFunction); |
19097 | 19109 |
19098 debug_info->set_break_points(*new_break_points); | 19110 debug_info->set_break_points(*new_break_points); |
19099 for (int i = 0; i < old_break_points->length(); i++) { | 19111 for (int i = 0; i < old_break_points->length(); i++) { |
19100 new_break_points->set(i, old_break_points->get(i)); | 19112 new_break_points->set(i, old_break_points->get(i)); |
19101 } | 19113 } |
19102 index = old_break_points->length(); | 19114 index = old_break_points->length(); |
19103 } | 19115 } |
19104 DCHECK(index != kNoBreakPointInfo); | 19116 DCHECK(index != kNoBreakPointInfo); |
19105 | 19117 |
19106 // Allocate new BreakPointInfo object and set the break point. | 19118 // Allocate new BreakPointInfo object and set the break point. |
19107 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( | 19119 Handle<BreakPointInfo> new_break_point_info = Handle<BreakPointInfo>::cast( |
19108 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); | 19120 isolate->factory()->NewStruct(BREAK_POINT_INFO_TYPE)); |
19109 new_break_point_info->set_code_position(code_position); | 19121 new_break_point_info->set_code_offset(code_offset); |
19110 new_break_point_info->set_source_position(source_position); | 19122 new_break_point_info->set_source_position(source_position); |
19111 new_break_point_info->set_statement_position(statement_position); | 19123 new_break_point_info->set_statement_position(statement_position); |
19112 new_break_point_info->set_break_point_objects( | 19124 new_break_point_info->set_break_point_objects( |
19113 isolate->heap()->undefined_value()); | 19125 isolate->heap()->undefined_value()); |
19114 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); | 19126 BreakPointInfo::SetBreakPoint(new_break_point_info, break_point_object); |
19115 debug_info->break_points()->set(index, *new_break_point_info); | 19127 debug_info->break_points()->set(index, *new_break_point_info); |
19116 } | 19128 } |
19117 | 19129 |
19118 | 19130 |
19119 // Get the break point objects for a code position. | 19131 // Get the break point objects for a code offset. |
19120 Handle<Object> DebugInfo::GetBreakPointObjects(int code_position) { | 19132 Handle<Object> DebugInfo::GetBreakPointObjects(int code_offset) { |
19121 Object* break_point_info = GetBreakPointInfo(code_position); | 19133 Object* break_point_info = GetBreakPointInfo(code_offset); |
19122 if (break_point_info->IsUndefined()) { | 19134 if (break_point_info->IsUndefined()) { |
19123 return GetIsolate()->factory()->undefined_value(); | 19135 return GetIsolate()->factory()->undefined_value(); |
19124 } | 19136 } |
19125 return Handle<Object>( | 19137 return Handle<Object>( |
19126 BreakPointInfo::cast(break_point_info)->break_point_objects(), | 19138 BreakPointInfo::cast(break_point_info)->break_point_objects(), |
19127 GetIsolate()); | 19139 GetIsolate()); |
19128 } | 19140 } |
19129 | 19141 |
19130 | 19142 |
19131 // Get the total number of break points. | 19143 // Get the total number of break points. |
(...skipping 25 matching lines...) Expand all Loading... | |
19157 } | 19169 } |
19158 } | 19170 } |
19159 } | 19171 } |
19160 } | 19172 } |
19161 return isolate->factory()->undefined_value(); | 19173 return isolate->factory()->undefined_value(); |
19162 } | 19174 } |
19163 | 19175 |
19164 | 19176 |
19165 // Find the index of the break point info object for the specified code | 19177 // Find the index of the break point info object for the specified code |
19166 // position. | 19178 // position. |
19167 int DebugInfo::GetBreakPointInfoIndex(int code_position) { | 19179 int DebugInfo::GetBreakPointInfoIndex(int code_offset) { |
19168 if (break_points()->IsUndefined()) return kNoBreakPointInfo; | 19180 if (break_points()->IsUndefined()) return kNoBreakPointInfo; |
19169 for (int i = 0; i < break_points()->length(); i++) { | 19181 for (int i = 0; i < break_points()->length(); i++) { |
19170 if (!break_points()->get(i)->IsUndefined()) { | 19182 if (!break_points()->get(i)->IsUndefined()) { |
19171 BreakPointInfo* break_point_info = | 19183 BreakPointInfo* break_point_info = |
19172 BreakPointInfo::cast(break_points()->get(i)); | 19184 BreakPointInfo::cast(break_points()->get(i)); |
19173 if (break_point_info->code_position() == code_position) { | 19185 if (break_point_info->code_offset() == code_offset) { |
19174 return i; | 19186 return i; |
19175 } | 19187 } |
19176 } | 19188 } |
19177 } | 19189 } |
19178 return kNoBreakPointInfo; | 19190 return kNoBreakPointInfo; |
19179 } | 19191 } |
19180 | 19192 |
19181 | 19193 |
19182 // Remove the specified break point object. | 19194 // Remove the specified break point object. |
19183 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, | 19195 void BreakPointInfo::ClearBreakPoint(Handle<BreakPointInfo> break_point_info, |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
19724 if (cell->value() != *new_value) { | 19736 if (cell->value() != *new_value) { |
19725 cell->set_value(*new_value); | 19737 cell->set_value(*new_value); |
19726 Isolate* isolate = cell->GetIsolate(); | 19738 Isolate* isolate = cell->GetIsolate(); |
19727 cell->dependent_code()->DeoptimizeDependentCodeGroup( | 19739 cell->dependent_code()->DeoptimizeDependentCodeGroup( |
19728 isolate, DependentCode::kPropertyCellChangedGroup); | 19740 isolate, DependentCode::kPropertyCellChangedGroup); |
19729 } | 19741 } |
19730 } | 19742 } |
19731 | 19743 |
19732 } // namespace internal | 19744 } // namespace internal |
19733 } // namespace v8 | 19745 } // namespace v8 |
OLD | NEW |