summaryrefslogtreecommitdiff
path: root/deps/v8/src/codegen/source-position-table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/codegen/source-position-table.cc')
-rw-r--r--deps/v8/src/codegen/source-position-table.cc45
1 files changed, 21 insertions, 24 deletions
diff --git a/deps/v8/src/codegen/source-position-table.cc b/deps/v8/src/codegen/source-position-table.cc
index 870241eac6..ba8e5981f0 100644
--- a/deps/v8/src/codegen/source-position-table.cc
+++ b/deps/v8/src/codegen/source-position-table.cc
@@ -31,24 +31,23 @@ using MoreBit = BitField8<bool, 7, 1>;
using ValueBits = BitField8<unsigned, 0, 7>;
// Helper: Add the offsets from 'other' to 'value'. Also set is_statement.
-void AddAndSetEntry(PositionTableEntry& value, // NOLINT(runtime/references)
+void AddAndSetEntry(PositionTableEntry* value,
const PositionTableEntry& other) {
- value.code_offset += other.code_offset;
- value.source_position += other.source_position;
- value.is_statement = other.is_statement;
+ value->code_offset += other.code_offset;
+ value->source_position += other.source_position;
+ value->is_statement = other.is_statement;
}
// Helper: Subtract the offsets from 'other' from 'value'.
-void SubtractFromEntry(PositionTableEntry& value, // NOLINT(runtime/references)
+void SubtractFromEntry(PositionTableEntry* value,
const PositionTableEntry& other) {
- value.code_offset -= other.code_offset;
- value.source_position -= other.source_position;
+ value->code_offset -= other.code_offset;
+ value->source_position -= other.source_position;
}
// Helper: Encode an integer.
template <typename T>
-void EncodeInt(std::vector<byte>& bytes, // NOLINT(runtime/references)
- T value) {
+void EncodeInt(std::vector<byte>* bytes, T value) {
using unsigned_type = typename std::make_unsigned<T>::type;
// Zig-zag encoding.
static const int kShift = sizeof(T) * kBitsPerByte - 1;
@@ -60,14 +59,13 @@ void EncodeInt(std::vector<byte>& bytes, // NOLINT(runtime/references)
more = encoded > ValueBits::kMax;
byte current =
MoreBit::encode(more) | ValueBits::encode(encoded & ValueBits::kMask);
- bytes.push_back(current);
+ bytes->push_back(current);
encoded >>= ValueBits::kSize;
} while (more);
}
// Encode a PositionTableEntry.
-void EncodeEntry(std::vector<byte>& bytes, // NOLINT(runtime/references)
- const PositionTableEntry& entry) {
+void EncodeEntry(std::vector<byte>* bytes, const PositionTableEntry& entry) {
// We only accept ascending code offsets.
DCHECK_GE(entry.code_offset, 0);
// Since code_offset is not negative, we use sign to encode is_statement.
@@ -115,17 +113,16 @@ Vector<const byte> VectorFromByteArray(ByteArray byte_array) {
}
#ifdef ENABLE_SLOW_DCHECKS
-void CheckTableEquals(
- std::vector<PositionTableEntry>& raw_entries, // NOLINT(runtime/references)
- SourcePositionTableIterator& encoded) { // NOLINT(runtime/references)
+void CheckTableEquals(const std::vector<PositionTableEntry>& raw_entries,
+ SourcePositionTableIterator* encoded) {
// Brute force testing: Record all positions and decode
// the entire table to verify they are identical.
auto raw = raw_entries.begin();
- for (; !encoded.done(); encoded.Advance(), raw++) {
+ for (; !encoded->done(); encoded->Advance(), raw++) {
DCHECK(raw != raw_entries.end());
- DCHECK_EQ(encoded.code_offset(), raw->code_offset);
- DCHECK_EQ(encoded.source_position().raw(), raw->source_position);
- DCHECK_EQ(encoded.is_statement(), raw->is_statement);
+ DCHECK_EQ(encoded->code_offset(), raw->code_offset);
+ DCHECK_EQ(encoded->source_position().raw(), raw->source_position);
+ DCHECK_EQ(encoded->is_statement(), raw->is_statement);
}
DCHECK(raw == raw_entries.end());
}
@@ -148,8 +145,8 @@ void SourcePositionTableBuilder::AddPosition(size_t code_offset,
void SourcePositionTableBuilder::AddEntry(const PositionTableEntry& entry) {
PositionTableEntry tmp(entry);
- SubtractFromEntry(tmp, previous_);
- EncodeEntry(bytes_, tmp);
+ SubtractFromEntry(&tmp, previous_);
+ EncodeEntry(&bytes_, tmp);
previous_ = entry;
#ifdef ENABLE_SLOW_DCHECKS
raw_entries_.push_back(entry);
@@ -169,7 +166,7 @@ Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable(
// Brute force testing: Record all positions and decode
// the entire table to verify they are identical.
SourcePositionTableIterator it(*table, SourcePositionTableIterator::kAll);
- CheckTableEquals(raw_entries_, it);
+ CheckTableEquals(raw_entries_, &it);
// No additional source positions after creating the table.
mode_ = OMIT_SOURCE_POSITIONS;
#endif
@@ -187,7 +184,7 @@ OwnedVector<byte> SourcePositionTableBuilder::ToSourcePositionTableVector() {
// the entire table to verify they are identical.
SourcePositionTableIterator it(table.as_vector(),
SourcePositionTableIterator::kAll);
- CheckTableEquals(raw_entries_, it);
+ CheckTableEquals(raw_entries_, &it);
// No additional source positions after creating the table.
mode_ = OMIT_SOURCE_POSITIONS;
#endif
@@ -232,7 +229,7 @@ void SourcePositionTableIterator::Advance() {
} else {
PositionTableEntry tmp;
DecodeEntry(bytes, &index_, &tmp);
- AddAndSetEntry(current_, tmp);
+ AddAndSetEntry(&current_, tmp);
SourcePosition p = source_position();
filter_satisfied = (filter_ == kAll) ||
(filter_ == kJavaScriptOnly && p.IsJavaScript()) ||