| 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 5715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5726 // We do not allow external strings in the old pointer space. Instead of | 5726 // We do not allow external strings in the old pointer space. Instead of |
| 5727 // converting the string in-place, we keep the cons/sliced string and | 5727 // converting the string in-place, we keep the cons/sliced string and |
| 5728 // point it to a newly-allocated external string. | 5728 // point it to a newly-allocated external string. |
| 5729 external = NewExternalStringHandle(isolate, resource); | 5729 external = NewExternalStringHandle(isolate, resource); |
| 5730 result = RedirectToExternalString(isolate, obj, external); | 5730 result = RedirectToExternalString(isolate, obj, external); |
| 5731 } else { | 5731 } else { |
| 5732 result = obj->MakeExternal(resource); | 5732 result = obj->MakeExternal(resource); |
| 5733 external = obj; | 5733 external = obj; |
| 5734 } | 5734 } |
| 5735 | 5735 |
| 5736 ASSERT(external->IsExternalString()); | 5736 if (result) { |
| 5737 if (result && !external->IsInternalizedString()) { | 5737 ASSERT(external->IsExternalString()); |
| 5738 isolate->heap()->external_string_table()->AddString(*external); | 5738 isolate->heap()->external_string_table()->AddString(*external); |
| 5739 } | 5739 } |
| 5740 return result; | 5740 return result; |
| 5741 } | 5741 } |
| 5742 | 5742 |
| 5743 | 5743 |
| 5744 Local<String> v8::String::NewExternal( | 5744 Local<String> v8::String::NewExternal( |
| 5745 Isolate* isolate, | 5745 Isolate* isolate, |
| 5746 v8::String::ExternalAsciiStringResource* resource) { | 5746 v8::String::ExternalAsciiStringResource* resource) { |
| 5747 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); | 5747 i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(isolate); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5784 // We do not allow external strings in the old pointer space. Instead of | 5784 // We do not allow external strings in the old pointer space. Instead of |
| 5785 // converting the string in-place, we keep the cons/sliced string and | 5785 // converting the string in-place, we keep the cons/sliced string and |
| 5786 // point it to a newly-allocated external string. | 5786 // point it to a newly-allocated external string. |
| 5787 external = NewExternalAsciiStringHandle(isolate, resource); | 5787 external = NewExternalAsciiStringHandle(isolate, resource); |
| 5788 result = RedirectToExternalString(isolate, obj, external); | 5788 result = RedirectToExternalString(isolate, obj, external); |
| 5789 } else { | 5789 } else { |
| 5790 result = obj->MakeExternal(resource); | 5790 result = obj->MakeExternal(resource); |
| 5791 external = obj; | 5791 external = obj; |
| 5792 } | 5792 } |
| 5793 | 5793 |
| 5794 ASSERT(external->IsExternalString()); | 5794 if (result) { |
| 5795 if (result && !external->IsInternalizedString()) { | 5795 ASSERT(external->IsExternalString()); |
| 5796 isolate->heap()->external_string_table()->AddString(*external); | 5796 isolate->heap()->external_string_table()->AddString(*external); |
| 5797 } | 5797 } |
| 5798 return result; | 5798 return result; |
| 5799 } | 5799 } |
| 5800 | 5800 |
| 5801 | 5801 |
| 5802 bool v8::String::CanMakeExternal() { | 5802 bool v8::String::CanMakeExternal() { |
| 5803 if (!internal::FLAG_clever_optimizations) return false; | 5803 if (!internal::FLAG_clever_optimizations) return false; |
| 5804 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5804 i::Handle<i::String> obj = Utils::OpenHandle(this); |
| 5805 i::Isolate* isolate = obj->GetIsolate(); | 5805 i::Isolate* isolate = obj->GetIsolate(); |
| (...skipping 1973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7779 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7779 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
| 7780 Address callback_address = | 7780 Address callback_address = |
| 7781 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7781 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
| 7782 VMState<EXTERNAL> state(isolate); | 7782 VMState<EXTERNAL> state(isolate); |
| 7783 ExternalCallbackScope call_scope(isolate, callback_address); | 7783 ExternalCallbackScope call_scope(isolate, callback_address); |
| 7784 callback(info); | 7784 callback(info); |
| 7785 } | 7785 } |
| 7786 | 7786 |
| 7787 | 7787 |
| 7788 } } // namespace v8::internal | 7788 } } // namespace v8::internal |
| OLD | NEW |