Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: src/log.cc

Issue 1751963003: Fix crash when --ll_prof is enabled after cb29f9c (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_profile_sourcepos
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/log.h ('k') | src/snapshot/deserializer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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/log.h" 5 #include "src/log.h"
6 6
7 #include <cstdarg> 7 #include <cstdarg>
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call; 291 #define LL_LOG(Call) if (ll_logger_) ll_logger_->Call;
292 292
293 class LowLevelLogger : public CodeEventLogger { 293 class LowLevelLogger : public CodeEventLogger {
294 public: 294 public:
295 explicit LowLevelLogger(const char* file_name); 295 explicit LowLevelLogger(const char* file_name);
296 ~LowLevelLogger() override; 296 ~LowLevelLogger() override;
297 297
298 void CodeMoveEvent(AbstractCode* from, Address to) override; 298 void CodeMoveEvent(AbstractCode* from, Address to) override;
299 void CodeDisableOptEvent(AbstractCode* code, 299 void CodeDisableOptEvent(AbstractCode* code,
300 SharedFunctionInfo* shared) override {} 300 SharedFunctionInfo* shared) override {}
301 void SnapshotPositionEvent(Address addr, int pos); 301 void SnapshotPositionEvent(HeapObject* obj, int pos);
302 void CodeMovingGCEvent() override; 302 void CodeMovingGCEvent() override;
303 303
304 private: 304 private:
305 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared, 305 void LogRecordedBuffer(AbstractCode* code, SharedFunctionInfo* shared,
306 const char* name, int length) override; 306 const char* name, int length) override;
307 307
308 // Low-level profiling event structures. 308 // Low-level profiling event structures.
309 struct CodeCreateStruct { 309 struct CodeCreateStruct {
310 static const char kTag = 'C'; 310 static const char kTag = 'C';
311 311
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 } 414 }
415 415
416 void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) { 416 void LowLevelLogger::CodeMoveEvent(AbstractCode* from, Address to) {
417 CodeMoveStruct event; 417 CodeMoveStruct event;
418 event.from_address = from->instruction_start(); 418 event.from_address = from->instruction_start();
419 size_t header_size = from->instruction_start() - from->address(); 419 size_t header_size = from->instruction_start() - from->address();
420 event.to_address = to + header_size; 420 event.to_address = to + header_size;
421 LogWriteStruct(event); 421 LogWriteStruct(event);
422 } 422 }
423 423
424 void LowLevelLogger::SnapshotPositionEvent(Address addr, int pos) { 424 void LowLevelLogger::SnapshotPositionEvent(HeapObject* obj, int pos) {
425 HeapObject* obj = HeapObject::FromAddress(addr);
426 if (obj->IsAbstractCode()) { 425 if (obj->IsAbstractCode()) {
427 SnapshotPositionStruct event; 426 SnapshotPositionStruct event;
428 event.address = 427 event.address =
429 addr + (obj->IsCode() ? Code::kHeaderSize : BytecodeArray::kHeaderSize); 428 obj->address() +
429 (obj->IsCode() ? Code::kHeaderSize : BytecodeArray::kHeaderSize);
430 event.position = pos; 430 event.position = pos;
431 LogWriteStruct(event); 431 LogWriteStruct(event);
432 } 432 }
433 } 433 }
434 434
435 435
436 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) { 436 void LowLevelLogger::LogWriteBytes(const char* bytes, int size) {
437 size_t rv = fwrite(bytes, 1, size, ll_output_handle_); 437 size_t rv = fwrite(bytes, 1, size, ll_output_handle_);
438 DCHECK(static_cast<size_t>(size) == rv); 438 DCHECK(static_cast<size_t>(size) == rv);
439 USE(rv); 439 USE(rv);
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 1287
1288 1288
1289 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) { 1289 void Logger::CodeNameEvent(Address addr, int pos, const char* code_name) {
1290 if (code_name == NULL) return; // Not a code object. 1290 if (code_name == NULL) return; // Not a code object.
1291 Log::MessageBuilder msg(log_); 1291 Log::MessageBuilder msg(log_);
1292 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos); 1292 msg.Append("%s,%d,", kLogEventsNames[SNAPSHOT_CODE_NAME_EVENT], pos);
1293 msg.AppendDoubleQuotedString(code_name); 1293 msg.AppendDoubleQuotedString(code_name);
1294 msg.WriteToLogFile(); 1294 msg.WriteToLogFile();
1295 } 1295 }
1296 1296
1297 1297 void Logger::SnapshotPositionEvent(HeapObject* obj, int pos) {
1298 void Logger::SnapshotPositionEvent(Address addr, int pos) {
1299 if (!log_->IsEnabled()) return; 1298 if (!log_->IsEnabled()) return;
1300 LL_LOG(SnapshotPositionEvent(addr, pos)); 1299 LL_LOG(SnapshotPositionEvent(obj, pos));
1301 if (!FLAG_log_snapshot_positions) return; 1300 if (!FLAG_log_snapshot_positions) return;
1302 Log::MessageBuilder msg(log_); 1301 Log::MessageBuilder msg(log_);
1303 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]); 1302 msg.Append("%s,", kLogEventsNames[SNAPSHOT_POSITION_EVENT]);
1304 msg.AppendAddress(addr); 1303 msg.AppendAddress(obj->address());
1305 msg.Append(",%d", pos); 1304 msg.Append(",%d", pos);
1306 msg.WriteToLogFile(); 1305 msg.WriteToLogFile();
1307 } 1306 }
1308 1307
1309 1308
1310 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) { 1309 void Logger::SharedFunctionInfoMoveEvent(Address from, Address to) {
1311 if (!is_logging_code_events()) return; 1310 if (!is_logging_code_events()) return;
1312 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to); 1311 MoveEventInternal(SHARED_FUNC_MOVE_EVENT, from, to);
1313 } 1312 }
1314 1313
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 removeCodeEventListener(jit_logger_); 1835 removeCodeEventListener(jit_logger_);
1837 delete jit_logger_; 1836 delete jit_logger_;
1838 jit_logger_ = NULL; 1837 jit_logger_ = NULL;
1839 } 1838 }
1840 1839
1841 return log_->Close(); 1840 return log_->Close();
1842 } 1841 }
1843 1842
1844 } // namespace internal 1843 } // namespace internal
1845 } // namespace v8 1844 } // namespace v8
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/snapshot/deserializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698