OLD | NEW |
---|---|
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 4925 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4936 | 4936 |
4937 Local<String> v8::String::NewExternal(ExternalLatin1StringResource* resource, | 4937 Local<String> v8::String::NewExternal(ExternalLatin1StringResource* resource, |
4938 int encoding) { | 4938 int encoding) { |
4939 typedef v8::internal::Internals I; | 4939 typedef v8::internal::Internals I; |
4940 i::Isolate* isolate = i::Isolate::Current(); | 4940 i::Isolate* isolate = i::Isolate::Current(); |
4941 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); | 4941 EnsureInitializedForIsolate(isolate, "v8::String::NewExternal()"); |
4942 LOG_API(isolate, "String::NewExternal"); | 4942 LOG_API(isolate, "String::NewExternal"); |
4943 ENTER_V8(isolate); | 4943 ENTER_V8(isolate); |
4944 ASSERT((encoding & kStringEncodingMask) == LATIN1_ENCODING); | 4944 ASSERT((encoding & kStringEncodingMask) == LATIN1_ENCODING); |
4945 CHECK(resource && resource->data()); | 4945 CHECK(resource && resource->data()); |
4946 bool ascii_hint = (encoding & kAsciiHintMask); | 4946 int ascii_hint = (encoding & kAsciiHintMask); |
4947 i::Handle<i::String> result; | 4947 i::Handle<i::String> result; |
4948 | 4948 |
4949 if (ascii_hint == ASCII_HINT || | 4949 if (ascii_hint == ASCII_HINT || |
4950 (ascii_hint != NOT_ASCII_HINT && | 4950 (ascii_hint != NOT_ASCII_HINT && |
4951 i::String::IsAscii(resource->data(), resource->length()))) { | 4951 i::String::IsAscii(resource->data(), |
ulan
2012/09/03 15:38:21
One more space so that "i" aligns with "a".
| |
4952 static_cast<int>(resource->length())))) { | |
4952 // Assert that the ascii hint is correct. | 4953 // Assert that the ascii hint is correct. |
4953 ASSERT(ascii_hint != ASCII_HINT || | 4954 ASSERT(ascii_hint != ASCII_HINT || |
4954 i::String::IsAscii(resource->data(), resource->length())); | 4955 i::String::IsAscii(resource->data(), |
4956 static_cast<int>(resource->length()))); | |
4955 result = NewExternalAsciiStringHandle(isolate, resource); | 4957 result = NewExternalAsciiStringHandle(isolate, resource); |
4956 isolate->heap()->external_string_table()->AddString(*result); | 4958 isolate->heap()->external_string_table()->AddString(*result); |
4957 } else { | 4959 } else { |
4958 // We cannot simply take the backing store and use it as an ASCII string, | 4960 // We cannot simply take the backing store and use it as an ASCII string, |
4959 // since it's not. Instead, we convert it to an internal string and dispose | 4961 // since it's not. Instead, we convert it to an internal string and dispose |
4960 // the external resource. | 4962 // the external resource. |
4961 result = isolate->factory()->NewStringFromLatin1( | 4963 result = isolate->factory()->NewStringFromLatin1( |
4962 i::Vector<const char>(resource->data(), resource->length()), | 4964 i::Vector<const char>(resource->data(), resource->length()), |
4963 i::NOT_TENURED, | 4965 i::NOT_TENURED, |
4964 i::String::NOT_ASCII); | 4966 i::String::NOT_ASCII); |
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6651 | 6653 |
6652 v->VisitPointers(blocks_.first(), first_block_limit_); | 6654 v->VisitPointers(blocks_.first(), first_block_limit_); |
6653 | 6655 |
6654 for (int i = 1; i < blocks_.length(); i++) { | 6656 for (int i = 1; i < blocks_.length(); i++) { |
6655 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); | 6657 v->VisitPointers(blocks_[i], &blocks_[i][kHandleBlockSize]); |
6656 } | 6658 } |
6657 } | 6659 } |
6658 | 6660 |
6659 | 6661 |
6660 } } // namespace v8::internal | 6662 } } // namespace v8::internal |
OLD | NEW |