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

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

Issue 2754233002: Revert "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.
414 } 391 }
415 392
416 template <typename T> 393 template <typename T>
417 void Write(T value) { 394 void Write(T value) {
418 T v = value; 395 T v = value;
419 while (v < kMinDataPerByte || v > kMaxDataPerByte) { 396 while (v < kMinDataPerByte || v > kMaxDataPerByte) {
420 WriteByte(static_cast<uint8_t>(v & kByteMask)); 397 WriteByte(static_cast<uint8_t>(v & kByteMask));
421 v = v >> kDataBitsPerByte; 398 v = v >> kDataBitsPerByte;
422 } 399 }
423 WriteByte(static_cast<uint8_t>(v + kEndByteMarker)); 400 WriteByte(static_cast<uint8_t>(v + kEndByteMarker));
(...skipping 20 matching lines...) Expand all
444 reinterpret_cast<uint8_t*>(alloc_(*buffer_, current_size_, new_size)); 421 reinterpret_cast<uint8_t*>(alloc_(*buffer_, current_size_, new_size));
445 if (*buffer_ == NULL) { 422 if (*buffer_ == NULL) {
446 Exceptions::ThrowOOM(); 423 Exceptions::ThrowOOM();
447 } 424 }
448 current_ = *buffer_ + position; 425 current_ = *buffer_ + position;
449 current_size_ = new_size; 426 current_size_ = new_size;
450 end_ = *buffer_ + new_size; 427 end_ = *buffer_ + new_size;
451 ASSERT(end_ > *buffer_); 428 ASSERT(end_ > *buffer_);
452 } 429 }
453 430
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
454 private: 453 private:
455 uint8_t** const buffer_; 454 uint8_t** const buffer_;
456 uint8_t* end_; 455 uint8_t* end_;
457 uint8_t* current_; 456 uint8_t* current_;
458 intptr_t current_size_; 457 intptr_t current_size_;
459 ReAlloc alloc_; 458 ReAlloc alloc_;
460 intptr_t initial_size_; 459 intptr_t initial_size_;
461 460
462 DISALLOW_COPY_AND_ASSIGN(WriteStream); 461 DISALLOW_COPY_AND_ASSIGN(WriteStream);
463 }; 462 };
464 463
465 } // namespace dart 464 } // namespace dart
466 465
467 #endif // RUNTIME_VM_DATASTREAM_H_ 466 #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