| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/interpreter/source-position-table.h" | 5 #include "src/interpreter/source-position-table.h" |
| 6 | 6 |
| 7 #include "src/objects-inl.h" | 7 #include "src/objects-inl.h" |
| 8 #include "src/objects.h" | 8 #include "src/objects.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 SubtractFromEntry(tmp, previous_); | 144 SubtractFromEntry(tmp, previous_); |
| 145 EncodeEntry(bytes_, tmp); | 145 EncodeEntry(bytes_, tmp); |
| 146 previous_ = entry; | 146 previous_ = entry; |
| 147 | 147 |
| 148 #ifdef ENABLE_SLOW_DCHECKS | 148 #ifdef ENABLE_SLOW_DCHECKS |
| 149 raw_entries_.push_back(entry); | 149 raw_entries_.push_back(entry); |
| 150 #endif | 150 #endif |
| 151 } | 151 } |
| 152 | 152 |
| 153 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { | 153 Handle<ByteArray> SourcePositionTableBuilder::ToSourcePositionTable() { |
| 154 if (bytes_.empty()) return isolate_->factory()->empty_byte_array(); |
| 155 |
| 154 Handle<ByteArray> table = isolate_->factory()->NewByteArray( | 156 Handle<ByteArray> table = isolate_->factory()->NewByteArray( |
| 155 static_cast<int>(bytes_.size()), TENURED); | 157 static_cast<int>(bytes_.size()), TENURED); |
| 156 if (bytes_.empty()) return table; | |
| 157 | 158 |
| 158 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size()); | 159 MemCopy(table->GetDataStartAddress(), &*bytes_.begin(), bytes_.size()); |
| 159 | 160 |
| 160 #ifdef ENABLE_SLOW_DCHECKS | 161 #ifdef ENABLE_SLOW_DCHECKS |
| 161 // Brute force testing: Record all positions and decode | 162 // Brute force testing: Record all positions and decode |
| 162 // the entire table to verify they are identical. | 163 // the entire table to verify they are identical. |
| 163 auto raw = raw_entries_.begin(); | 164 auto raw = raw_entries_.begin(); |
| 164 for (SourcePositionTableIterator encoded(*table); !encoded.done(); | 165 for (SourcePositionTableIterator encoded(*table); !encoded.done(); |
| 165 encoded.Advance(), raw++) { | 166 encoded.Advance(), raw++) { |
| 166 DCHECK(raw != raw_entries_.end()); | 167 DCHECK(raw != raw_entries_.end()); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 187 } else { | 188 } else { |
| 188 PositionTableEntry tmp; | 189 PositionTableEntry tmp; |
| 189 DecodeEntry(table_, &index_, &tmp); | 190 DecodeEntry(table_, &index_, &tmp); |
| 190 AddAndSetEntry(current_, tmp); | 191 AddAndSetEntry(current_, tmp); |
| 191 } | 192 } |
| 192 } | 193 } |
| 193 | 194 |
| 194 } // namespace interpreter | 195 } // namespace interpreter |
| 195 } // namespace internal | 196 } // namespace internal |
| 196 } // namespace v8 | 197 } // namespace v8 |
| OLD | NEW |