| 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 3618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3629 int String::WriteUtf8(char* buffer, | 3629 int String::WriteUtf8(char* buffer, |
| 3630 int capacity, | 3630 int capacity, |
| 3631 int* nchars_ref, | 3631 int* nchars_ref, |
| 3632 int options) const { | 3632 int options) const { |
| 3633 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); | 3633 i::Isolate* isolate = Utils::OpenHandle(this)->GetIsolate(); |
| 3634 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; | 3634 if (IsDeadCheck(isolate, "v8::String::WriteUtf8()")) return 0; |
| 3635 LOG_API(isolate, "String::WriteUtf8"); | 3635 LOG_API(isolate, "String::WriteUtf8"); |
| 3636 ENTER_V8(isolate); | 3636 ENTER_V8(isolate); |
| 3637 i::Handle<i::String> str = Utils::OpenHandle(this); | 3637 i::Handle<i::String> str = Utils::OpenHandle(this); |
| 3638 if (str->IsAsciiRepresentation()) { | 3638 if (str->IsAsciiRepresentation()) { |
| 3639 if (capacity == -1) capacity = str->length() + 1; | 3639 int len; |
| 3640 int len = i::Min(capacity, str->length()); | 3640 if (capacity == -1) { |
| 3641 capacity = str->length() + 1; |
| 3642 len = str->length(); |
| 3643 } else { |
| 3644 len = i::Min(capacity, str->length()); |
| 3645 } |
| 3641 i::String::WriteToFlat(*str, buffer, 0, len); | 3646 i::String::WriteToFlat(*str, buffer, 0, len); |
| 3642 if (nchars_ref != NULL) *nchars_ref = len; | 3647 if (nchars_ref != NULL) *nchars_ref = len; |
| 3643 if (!(options & NO_NULL_TERMINATION) && capacity > len) { | 3648 if (!(options & NO_NULL_TERMINATION) && capacity > len) { |
| 3644 buffer[len] = '\0'; | 3649 buffer[len] = '\0'; |
| 3645 return len + 1; | 3650 return len + 1; |
| 3646 } | 3651 } |
| 3647 return len; | 3652 return len; |
| 3648 } | 3653 } |
| 3649 | 3654 |
| 3650 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); | 3655 i::StringInputBuffer& write_input_buffer = *isolate->write_input_buffer(); |
| (...skipping 2435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6086 | 6091 |
| 6087 | 6092 |
| 6088 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { | 6093 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { |
| 6089 HandleScopeImplementer* scope_implementer = | 6094 HandleScopeImplementer* scope_implementer = |
| 6090 reinterpret_cast<HandleScopeImplementer*>(storage); | 6095 reinterpret_cast<HandleScopeImplementer*>(storage); |
| 6091 scope_implementer->IterateThis(v); | 6096 scope_implementer->IterateThis(v); |
| 6092 return storage + ArchiveSpacePerThread(); | 6097 return storage + ArchiveSpacePerThread(); |
| 6093 } | 6098 } |
| 6094 | 6099 |
| 6095 } } // namespace v8::internal | 6100 } } // namespace v8::internal |
| OLD | NEW |