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

Side by Side Diff: runtime/vm/datastream.h

Issue 2723213002: DWARF and unwind support for AOT assembly output. (Closed)
Patch Set: . Created 3 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dwarf.h » ('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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_DATASTREAM_H_ 5 #ifndef RUNTIME_VM_DATASTREAM_H_
6 #define RUNTIME_VM_DATASTREAM_H_ 6 #define RUNTIME_VM_DATASTREAM_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "platform/utils.h" 9 #include "platform/utils.h"
10 #include "vm/allocation.h" 10 #include "vm/allocation.h"
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 } 381 }
382 ASSERT((end_ - current_) >= len); 382 ASSERT((end_ - current_) >= len);
383 *reinterpret_cast<uword*>(current_) = value; 383 *reinterpret_cast<uword*>(current_) = value;
384 current_ += len; 384 current_ += len;
385 } 385 }
386 386
387 void Print(const char* format, ...) { 387 void Print(const char* format, ...) {
388 va_list args; 388 va_list args;
389 va_start(args, format); 389 va_start(args, format);
390 VPrint(format, args); 390 VPrint(format, args);
391 va_end(args);
392 }
393
394 void VPrint(const char* format, va_list args) {
395 // Measure.
396 va_list measure_args;
397 va_copy(measure_args, args);
398 intptr_t len = OS::VSNPrint(NULL, 0, format, measure_args);
399 va_end(measure_args);
400
401 // Alloc.
402 if ((end_ - current_) < (len + 1)) {
403 Resize(len + 1);
404 }
405 ASSERT((end_ - current_) >= (len + 1));
406
407 // Print.
408 va_list print_args;
409 va_copy(print_args, args);
410 OS::VSNPrint(reinterpret_cast<char*>(current_), len + 1, format,
411 print_args);
412 va_end(print_args);
413 current_ += len; // Not len + 1 to swallow the terminating NUL.
391 } 414 }
392 415
393 template <typename T> 416 template <typename T>
394 void Write(T value) { 417 void Write(T value) {
395 T v = value; 418 T v = value;
396 while (v < kMinDataPerByte || v > kMaxDataPerByte) { 419 while (v < kMinDataPerByte || v > kMaxDataPerByte) {
397 WriteByte(static_cast<uint8_t>(v & kByteMask)); 420 WriteByte(static_cast<uint8_t>(v & kByteMask));
398 v = v >> kDataBitsPerByte; 421 v = v >> kDataBitsPerByte;
399 } 422 }
400 WriteByte(static_cast<uint8_t>(v + kEndByteMarker)); 423 WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
(...skipping 20 matching lines...) Expand all
421 reinterpret_cast<uint8_t*>(alloc_(*buffer_, current_size_, new_size)); 444 reinterpret_cast<uint8_t*>(alloc_(*buffer_, current_size_, new_size));
422 if (*buffer_ == NULL) { 445 if (*buffer_ == NULL) {
423 Exceptions::ThrowOOM(); 446 Exceptions::ThrowOOM();
424 } 447 }
425 current_ = *buffer_ + position; 448 current_ = *buffer_ + position;
426 current_size_ = new_size; 449 current_size_ = new_size;
427 end_ = *buffer_ + new_size; 450 end_ = *buffer_ + new_size;
428 ASSERT(end_ > *buffer_); 451 ASSERT(end_ > *buffer_);
429 } 452 }
430 453
431 void VPrint(const char* format, va_list args) {
432 // Measure.
433 va_list measure_args;
434 va_copy(measure_args, args);
435 intptr_t len = OS::VSNPrint(NULL, 0, format, measure_args);
436 va_end(measure_args);
437
438 // Alloc.
439 if ((end_ - current_) < (len + 1)) {
440 Resize(len + 1);
441 }
442 ASSERT((end_ - current_) >= (len + 1));
443
444 // Print.
445 va_list print_args;
446 va_copy(print_args, args);
447 OS::VSNPrint(reinterpret_cast<char*>(current_), len + 1, format,
448 print_args);
449 va_end(print_args);
450 current_ += len; // Not len + 1 to swallow the terminating NUL.
451 }
452
453 private: 454 private:
454 uint8_t** const buffer_; 455 uint8_t** const buffer_;
455 uint8_t* end_; 456 uint8_t* end_;
456 uint8_t* current_; 457 uint8_t* current_;
457 intptr_t current_size_; 458 intptr_t current_size_;
458 ReAlloc alloc_; 459 ReAlloc alloc_;
459 intptr_t initial_size_; 460 intptr_t initial_size_;
460 461
461 DISALLOW_COPY_AND_ASSIGN(WriteStream); 462 DISALLOW_COPY_AND_ASSIGN(WriteStream);
462 }; 463 };
463 464
464 } // namespace dart 465 } // namespace dart
465 466
466 #endif // RUNTIME_VM_DATASTREAM_H_ 467 #endif // RUNTIME_VM_DATASTREAM_H_
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dwarf.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698