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

Side by Side Diff: src/api.cc

Issue 11746015: Fix Win64 build. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 3994 matching lines...) Expand 10 before | Expand all | Expand 10 after
4005 // Copy state to stack. 4005 // Copy state to stack.
4006 char* buffer = buffer_; 4006 char* buffer = buffer_;
4007 int last_character = last_character_; 4007 int last_character = last_character_;
4008 int i = 0; 4008 int i = 0;
4009 // Do a fast loop where there is no exit capacity check. 4009 // Do a fast loop where there is no exit capacity check.
4010 while (true) { 4010 while (true) {
4011 int fast_length; 4011 int fast_length;
4012 if (capacity_ == -1) { 4012 if (capacity_ == -1) {
4013 fast_length = length; 4013 fast_length = length;
4014 } else { 4014 } else {
4015 int remaining_capacity = capacity_ - (buffer - start_); 4015 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4016 // Need enough space to write everything but one character. 4016 // Need enough space to write everything but one character.
4017 STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3); 4017 STATIC_ASSERT(Utf16::kMaxExtraUtf8BytesForOneUtf16CodeUnit == 3);
4018 int writable_length = (remaining_capacity - 3)/3; 4018 int writable_length = (remaining_capacity - 3)/3;
4019 // Need to drop into slow loop. 4019 // Need to drop into slow loop.
4020 if (writable_length <= 0) break; 4020 if (writable_length <= 0) break;
4021 fast_length = i + writable_length; 4021 fast_length = i + writable_length;
4022 if (fast_length > length) fast_length = length; 4022 if (fast_length > length) fast_length = length;
4023 } 4023 }
4024 // Write the characters to the stream. 4024 // Write the characters to the stream.
4025 for (; i < fast_length; i++) { 4025 for (; i < fast_length; i++) {
4026 uint16_t character = *chars++; 4026 uint16_t character = *chars++;
4027 buffer += Utf8::Encode(buffer, character, last_character); 4027 buffer += Utf8::Encode(buffer, character, last_character);
4028 last_character = character; 4028 last_character = character;
4029 ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_); 4029 ASSERT(capacity_ == -1 || (buffer - start_) <= capacity_);
4030 } 4030 }
4031 // Array is fully written. Exit. 4031 // Array is fully written. Exit.
4032 if (fast_length == length) { 4032 if (fast_length == length) {
4033 // Write state back out to object. 4033 // Write state back out to object.
4034 last_character_ = last_character; 4034 last_character_ = last_character;
4035 buffer_ = buffer; 4035 buffer_ = buffer;
4036 utf16_chars_read_ += i; 4036 utf16_chars_read_ += i;
4037 return; 4037 return;
4038 } 4038 }
4039 } 4039 }
4040 ASSERT(capacity_ != -1); 4040 ASSERT(capacity_ != -1);
4041 // Slow loop. Must check capacity on each iteration. 4041 // Slow loop. Must check capacity on each iteration.
4042 int remaining_capacity = capacity_ - (buffer - start_); 4042 int remaining_capacity = capacity_ - static_cast<int>(buffer - start_);
4043 ASSERT(remaining_capacity >= 0); 4043 ASSERT(remaining_capacity >= 0);
4044 for (; i < length && remaining_capacity > 0; i++) { 4044 for (; i < length && remaining_capacity > 0; i++) {
4045 uint16_t character = *chars++; 4045 uint16_t character = *chars++;
4046 int written = WriteEndCharacter(character, 4046 int written = WriteEndCharacter(character,
4047 last_character, 4047 last_character,
4048 remaining_capacity, 4048 remaining_capacity,
4049 buffer); 4049 buffer);
4050 if (written == 0) { 4050 if (written == 0) {
4051 early_termination_ = true; 4051 early_termination_ = true;
4052 break; 4052 break;
(...skipping 24 matching lines...) Expand all
4077 // Write out number of utf16 characters written to the stream. 4077 // Write out number of utf16 characters written to the stream.
4078 if (utf16_chars_read_out != NULL) { 4078 if (utf16_chars_read_out != NULL) {
4079 *utf16_chars_read_out = utf16_chars_read_; 4079 *utf16_chars_read_out = utf16_chars_read_;
4080 } 4080 }
4081 // Only null terminate if all of the string was written and there's space. 4081 // Only null terminate if all of the string was written and there's space.
4082 if (write_null && 4082 if (write_null &&
4083 !early_termination_ && 4083 !early_termination_ &&
4084 (capacity_ == -1 || (buffer_ - start_) < capacity_)) { 4084 (capacity_ == -1 || (buffer_ - start_) < capacity_)) {
4085 *buffer_++ = '\0'; 4085 *buffer_++ = '\0';
4086 } 4086 }
4087 return buffer_ - start_; 4087 return static_cast<int>(buffer_ - start_);
4088 } 4088 }
4089 4089
4090 private: 4090 private:
4091 bool early_termination_; 4091 bool early_termination_;
4092 int last_character_; 4092 int last_character_;
4093 char* buffer_; 4093 char* buffer_;
4094 char* const start_; 4094 char* const start_;
4095 int capacity_; 4095 int capacity_;
4096 int utf16_chars_read_; 4096 int utf16_chars_read_;
4097 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor); 4097 DISALLOW_IMPLICIT_CONSTRUCTORS(Utf8WriterVisitor);
(...skipping 2635 matching lines...) Expand 10 before | Expand all | Expand 10 after
6733 6733
6734 v->VisitPointers(blocks_.first(), first_block_limit_); 6734 v->VisitPointers(blocks_.first(), first_block_limit_);
6735 6735
6736 for (int i = 1; i < blocks_.length(); i++) { 6736 for (int i = 1; i < blocks_.length(); i++) {
6737 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); 6737 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]);
6738 } 6738 }
6739 } 6739 }
6740 6740
6741 6741
6742 } } // namespace v8::internal 6742 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698