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 5953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5964 if (result) { | 5964 if (result) { |
5965 DCHECK(obj->IsExternalString()); | 5965 DCHECK(obj->IsExternalString()); |
5966 isolate->heap()->RegisterExternalString(*obj); | 5966 isolate->heap()->RegisterExternalString(*obj); |
5967 } | 5967 } |
5968 return result; | 5968 return result; |
5969 } | 5969 } |
5970 | 5970 |
5971 | 5971 |
5972 bool v8::String::CanMakeExternal() { | 5972 bool v8::String::CanMakeExternal() { |
5973 i::Handle<i::String> obj = Utils::OpenHandle(this); | 5973 i::Handle<i::String> obj = Utils::OpenHandle(this); |
5974 i::Isolate* isolate = obj->GetIsolate(); | 5974 if (obj->IsExternalString()) return false; |
5975 | 5975 |
5976 // Old space strings should be externalized. | 5976 // Old space strings should be externalized. |
5977 if (!isolate->heap()->new_space()->Contains(*obj)) return true; | 5977 i::Isolate* isolate = obj->GetIsolate(); |
5978 int size = obj->Size(); // Byte size of the original string. | 5978 return !isolate->heap()->new_space()->Contains(*obj); |
5979 if (size <= i::ExternalString::kShortSize) return false; | |
5980 i::StringShape shape(*obj); | |
5981 return !shape.IsExternal(); | |
5982 } | 5979 } |
5983 | 5980 |
5984 | 5981 |
5985 Isolate* v8::Object::GetIsolate() { | 5982 Isolate* v8::Object::GetIsolate() { |
5986 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 5983 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); |
5987 return reinterpret_cast<Isolate*>(i_isolate); | 5984 return reinterpret_cast<Isolate*>(i_isolate); |
5988 } | 5985 } |
5989 | 5986 |
5990 | 5987 |
5991 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 5988 Local<v8::Object> v8::Object::New(Isolate* isolate) { |
(...skipping 2786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8778 Address callback_address = | 8775 Address callback_address = |
8779 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8776 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); |
8780 VMState<EXTERNAL> state(isolate); | 8777 VMState<EXTERNAL> state(isolate); |
8781 ExternalCallbackScope call_scope(isolate, callback_address); | 8778 ExternalCallbackScope call_scope(isolate, callback_address); |
8782 callback(info); | 8779 callback(info); |
8783 } | 8780 } |
8784 | 8781 |
8785 | 8782 |
8786 } // namespace internal | 8783 } // namespace internal |
8787 } // namespace v8 | 8784 } // namespace v8 |
OLD | NEW |