OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 } | 454 } |
455 | 455 |
456 void AppendString(String* str) { | 456 void AppendString(String* str) { |
457 if (str == NULL) return; | 457 if (str == NULL) return; |
458 if (str->HasOnlyAsciiChars()) { | 458 if (str->HasOnlyAsciiChars()) { |
459 int utf8_length = Min(str->length(), kUtf8BufferSize - utf8_pos_); | 459 int utf8_length = Min(str->length(), kUtf8BufferSize - utf8_pos_); |
460 String::WriteToFlat(str, utf8_buffer_ + utf8_pos_, 0, utf8_length); | 460 String::WriteToFlat(str, utf8_buffer_ + utf8_pos_, 0, utf8_length); |
461 utf8_pos_ += utf8_length; | 461 utf8_pos_ += utf8_length; |
462 return; | 462 return; |
463 } | 463 } |
464 int uc16_length = Min(str->length(), kUc16BufferSize); | 464 int uc16_length = Min(str->length(), kUtf16BufferSize); |
465 String::WriteToFlat(str, uc16_buffer_, 0, uc16_length); | 465 String::WriteToFlat(str, utf16_buffer, 0, uc16_length); |
| 466 int previous = unibrow::Utf16::kNoPreviousCharacter; |
466 for (int i = 0; i < uc16_length && utf8_pos_ < kUtf8BufferSize; ++i) { | 467 for (int i = 0; i < uc16_length && utf8_pos_ < kUtf8BufferSize; ++i) { |
467 uc16 c = uc16_buffer_[i]; | 468 uc16 c = utf16_buffer[i]; |
468 if (c <= String::kMaxAsciiCharCodeU) { | 469 if (c <= String::kMaxAsciiCharCodeU) { |
469 utf8_buffer_[utf8_pos_++] = static_cast<char>(c); | 470 utf8_buffer_[utf8_pos_++] = static_cast<char>(c); |
470 } else { | 471 } else { |
471 int char_length = unibrow::Utf8::Length(c); | 472 int char_length = unibrow::Utf8::Length(c, previous); |
472 if (utf8_pos_ + char_length > kUtf8BufferSize) break; | 473 if (utf8_pos_ + char_length > kUtf8BufferSize) break; |
473 unibrow::Utf8::Encode(utf8_buffer_ + utf8_pos_, c); | 474 unibrow::Utf8::Encode(utf8_buffer_ + utf8_pos_, c, previous); |
474 utf8_pos_ += char_length; | 475 utf8_pos_ += char_length; |
475 } | 476 } |
| 477 previous = c; |
476 } | 478 } |
477 } | 479 } |
478 | 480 |
479 void AppendBytes(const char* bytes, int size) { | 481 void AppendBytes(const char* bytes, int size) { |
480 size = Min(size, kUtf8BufferSize - utf8_pos_); | 482 size = Min(size, kUtf8BufferSize - utf8_pos_); |
481 memcpy(utf8_buffer_ + utf8_pos_, bytes, size); | 483 memcpy(utf8_buffer_ + utf8_pos_, bytes, size); |
482 utf8_pos_ += size; | 484 utf8_pos_ += size; |
483 } | 485 } |
484 | 486 |
485 void AppendBytes(const char* bytes) { | 487 void AppendBytes(const char* bytes) { |
(...skipping 11 matching lines...) Expand all Loading... |
497 if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { | 499 if (size > 0 && utf8_pos_ + size <= kUtf8BufferSize) { |
498 utf8_pos_ += size; | 500 utf8_pos_ += size; |
499 } | 501 } |
500 } | 502 } |
501 | 503 |
502 const char* get() { return utf8_buffer_; } | 504 const char* get() { return utf8_buffer_; } |
503 int size() const { return utf8_pos_; } | 505 int size() const { return utf8_pos_; } |
504 | 506 |
505 private: | 507 private: |
506 static const int kUtf8BufferSize = 512; | 508 static const int kUtf8BufferSize = 512; |
507 static const int kUc16BufferSize = 128; | 509 static const int kUtf16BufferSize = 128; |
508 | 510 |
509 int utf8_pos_; | 511 int utf8_pos_; |
510 char utf8_buffer_[kUtf8BufferSize]; | 512 char utf8_buffer_[kUtf8BufferSize]; |
511 uc16 uc16_buffer_[kUc16BufferSize]; | 513 uc16 utf16_buffer[kUtf16BufferSize]; |
512 }; | 514 }; |
513 | 515 |
514 | 516 |
515 Logger::Logger() | 517 Logger::Logger() |
516 : ticker_(NULL), | 518 : ticker_(NULL), |
517 profiler_(NULL), | 519 profiler_(NULL), |
518 sliding_state_window_(NULL), | 520 sliding_state_window_(NULL), |
519 log_events_(NULL), | 521 log_events_(NULL), |
520 logging_nesting_(0), | 522 logging_nesting_(0), |
521 cpu_profiler_nesting_(0), | 523 cpu_profiler_nesting_(0), |
(...skipping 1250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1772 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { | 1774 void SamplerRegistry::RemoveActiveSampler(Sampler* sampler) { |
1773 ASSERT(sampler->IsActive()); | 1775 ASSERT(sampler->IsActive()); |
1774 ScopedLock lock(mutex_); | 1776 ScopedLock lock(mutex_); |
1775 ASSERT(active_samplers_ != NULL); | 1777 ASSERT(active_samplers_ != NULL); |
1776 bool removed = active_samplers_->RemoveElement(sampler); | 1778 bool removed = active_samplers_->RemoveElement(sampler); |
1777 ASSERT(removed); | 1779 ASSERT(removed); |
1778 USE(removed); | 1780 USE(removed); |
1779 } | 1781 } |
1780 | 1782 |
1781 } } // namespace v8::internal | 1783 } } // namespace v8::internal |
OLD | NEW |