OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/api.h" | 5 #include "src/api.h" |
6 | 6 |
7 #include <string.h> // For memcpy, strlen. | 7 #include <string.h> // For memcpy, strlen. |
8 #ifdef V8_USE_ADDRESS_SANITIZER | 8 #ifdef V8_USE_ADDRESS_SANITIZER |
9 #include <sanitizer/asan_interface.h> | 9 #include <sanitizer/asan_interface.h> |
10 #endif // V8_USE_ADDRESS_SANITIZER | 10 #endif // V8_USE_ADDRESS_SANITIZER |
(...skipping 5638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5649 DCHECK(!CanMakeExternal() || result); | 5649 DCHECK(!CanMakeExternal() || result); |
5650 if (result) { | 5650 if (result) { |
5651 DCHECK(obj->IsExternalString()); | 5651 DCHECK(obj->IsExternalString()); |
5652 isolate->heap()->external_string_table()->AddString(*obj); | 5652 isolate->heap()->external_string_table()->AddString(*obj); |
5653 } | 5653 } |
5654 return result; | 5654 return result; |
5655 } | 5655 } |
5656 | 5656 |
5657 | 5657 |
5658 bool v8::String::CanMakeExternal() { | 5658 bool v8::String::CanMakeExternal() { |
5659 if (!internal::FLAG_clever_optimizations) return false; | |
5660 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5659 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5661 i::Isolate* isolate = obj->GetIsolate(); | 5660 i::Isolate* isolate = obj->GetIsolate(); |
5662 | 5661 |
5663 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; | 5662 if (isolate->string_tracker()->IsFreshUnusedString(obj)) return false; |
5664 int size = obj->Size(); // Byte size of the original string. | 5663 int size = obj->Size(); // Byte size of the original string. |
5665 if (size < i::ExternalString::kShortSize) return false; | 5664 if (size < i::ExternalString::kShortSize) return false; |
5666 i::StringShape shape(*obj); | 5665 i::StringShape shape(*obj); |
5667 return !shape.IsExternal(); | 5666 return !shape.IsExternal(); |
5668 } | 5667 } |
5669 | 5668 |
(...skipping 2113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7783 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); | 7782 Isolate* isolate = reinterpret_cast<Isolate*>(info.GetIsolate()); |
7784 Address callback_address = | 7783 Address callback_address = |
7785 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 7784 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
7786 VMState<EXTERNAL> state(isolate); | 7785 VMState<EXTERNAL> state(isolate); |
7787 ExternalCallbackScope call_scope(isolate, callback_address); | 7786 ExternalCallbackScope call_scope(isolate, callback_address); |
7788 callback(info); | 7787 callback(info); |
7789 } | 7788 } |
7790 | 7789 |
7791 | 7790 |
7792 } } // namespace v8::internal | 7791 } } // namespace v8::internal |
OLD | NEW |