| 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 13574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13585 // Locate the source position which is closest to the code offset. This is | 13585 // Locate the source position which is closest to the code offset. This is |
| 13586 // using the source position information embedded in the relocation info. | 13586 // using the source position information embedded in the relocation info. |
| 13587 // The position returned is relative to the beginning of the script where the | 13587 // The position returned is relative to the beginning of the script where the |
| 13588 // source for this function is found. | 13588 // source for this function is found. |
| 13589 int Code::SourcePosition(int code_offset) { | 13589 int Code::SourcePosition(int code_offset) { |
| 13590 int position = RelocInfo::kNoPosition; // Initially no position found. | 13590 int position = RelocInfo::kNoPosition; // Initially no position found. |
| 13591 // Subtract one because the current PC is one instruction after the call site. | 13591 // Subtract one because the current PC is one instruction after the call site. |
| 13592 code_offset--; | 13592 code_offset--; |
| 13593 // Find the closest position attached to a pc lower or equal to the current. | 13593 // Find the closest position attached to a pc lower or equal to the current. |
| 13594 // Note that the pc of reloc infos grow monotonically. | 13594 // Note that the pc of reloc infos grow monotonically. |
| 13595 if (kind() == FUNCTION) { | 13595 if (kind() == FUNCTION || (is_optimized_code() && !is_turbofanned())) { |
| 13596 for (SourcePositionTableIterator it(source_position_table()); | 13596 for (SourcePositionTableIterator it(source_position_table()); |
| 13597 !it.done() && it.code_offset() <= code_offset; it.Advance()) { | 13597 !it.done() && it.code_offset() <= code_offset; it.Advance()) { |
| 13598 position = it.source_position(); | 13598 position = it.source_position(); |
| 13599 } | 13599 } |
| 13600 } else { | 13600 } else { |
| 13601 Address pc = instruction_start() + code_offset; | 13601 Address pc = instruction_start() + code_offset; |
| 13602 for (RelocIterator it(this, RelocInfo::kPositionMask); | 13602 for (RelocIterator it(this, RelocInfo::kPositionMask); |
| 13603 !it.done() && it.rinfo()->pc() <= pc; it.next()) { | 13603 !it.done() && it.rinfo()->pc() <= pc; it.next()) { |
| 13604 position = static_cast<int>(it.rinfo()->data()); | 13604 position = static_cast<int>(it.rinfo()->data()); |
| 13605 } | 13605 } |
| 13606 } | 13606 } |
| 13607 DCHECK(kind() == FUNCTION || (is_optimized_code() && is_turbofanned()) || | 13607 DCHECK(kind() == FUNCTION || (is_optimized_code() && is_turbofanned()) || |
| 13608 is_wasm_code() || position == RelocInfo::kNoPosition); | 13608 is_wasm_code() || position == RelocInfo::kNoPosition); |
| 13609 return position; | 13609 return position; |
| 13610 } | 13610 } |
| 13611 | 13611 |
| 13612 | 13612 |
| 13613 // Same as Code::SourcePosition above except it only looks for statement | 13613 // Same as Code::SourcePosition above except it only looks for statement |
| 13614 // positions. | 13614 // positions. |
| 13615 int Code::SourceStatementPosition(int code_offset) { | 13615 int Code::SourceStatementPosition(int code_offset) { |
| 13616 // First find the closest position. | 13616 // First find the closest position. |
| 13617 int position = SourcePosition(code_offset); | 13617 int position = SourcePosition(code_offset); |
| 13618 // Now find the closest statement position before the position. | 13618 // Now find the closest statement position before the position. |
| 13619 int statement_position = 0; | 13619 int statement_position = 0; |
| 13620 if (kind() == FUNCTION) { | 13620 if (kind() == FUNCTION || (is_optimized_code() && !is_turbofanned())) { |
| 13621 for (SourcePositionTableIterator it(source_position_table()); !it.done(); | 13621 for (SourcePositionTableIterator it(source_position_table()); !it.done(); |
| 13622 it.Advance()) { | 13622 it.Advance()) { |
| 13623 if (it.is_statement()) { | 13623 if (it.is_statement()) { |
| 13624 int p = it.source_position(); | 13624 int p = it.source_position(); |
| 13625 if (statement_position < p && p <= position) { | 13625 if (statement_position < p && p <= position) { |
| 13626 statement_position = p; | 13626 statement_position = p; |
| 13627 } | 13627 } |
| 13628 } | 13628 } |
| 13629 } | 13629 } |
| 13630 } else { | 13630 } else { |
| (...skipping 5319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 18950 | 18950 |
| 18951 Object* data_obj = | 18951 Object* data_obj = |
| 18952 constructor->shared()->get_api_func_data()->access_check_info(); | 18952 constructor->shared()->get_api_func_data()->access_check_info(); |
| 18953 if (data_obj->IsUndefined(isolate)) return nullptr; | 18953 if (data_obj->IsUndefined(isolate)) return nullptr; |
| 18954 | 18954 |
| 18955 return AccessCheckInfo::cast(data_obj); | 18955 return AccessCheckInfo::cast(data_obj); |
| 18956 } | 18956 } |
| 18957 | 18957 |
| 18958 } // namespace internal | 18958 } // namespace internal |
| 18959 } // namespace v8 | 18959 } // namespace v8 |
| OLD | NEW |