 Chromium Code Reviews
 Chromium Code Reviews Issue 2046933002:
  [V8] Make String::CanMakeExternal ignore the length of new strings  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 2046933002:
  [V8] Make String::CanMakeExternal ignore the length of new strings  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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 5993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6004 isolate->heap()->RegisterExternalString(*obj); | 6004 isolate->heap()->RegisterExternalString(*obj); | 
| 6005 } | 6005 } | 
| 6006 return result; | 6006 return result; | 
| 6007 } | 6007 } | 
| 6008 | 6008 | 
| 6009 | 6009 | 
| 6010 bool v8::String::CanMakeExternal() { | 6010 bool v8::String::CanMakeExternal() { | 
| 6011 i::Handle<i::String> obj = Utils::OpenHandle(this); | 6011 i::Handle<i::String> obj = Utils::OpenHandle(this); | 
| 6012 i::Isolate* isolate = obj->GetIsolate(); | 6012 i::Isolate* isolate = obj->GetIsolate(); | 
| 6013 | 6013 | 
| 6014 // Old space strings should be externalized. | 6014 // Do not externalize new strings. | 
| 6015 if (!isolate->heap()->new_space()->Contains(*obj)) return true; | 6015 return !isolate->heap()->new_space()->Contains(*obj); | 
| 6016 int size = obj->Size(); // Byte size of the original string. | |
| 6017 if (size <= i::ExternalString::kShortSize) return false; | |
| 6018 i::StringShape shape(*obj); | |
| 6019 return !shape.IsExternal(); | |
| 
Yang
2016/06/09 05:45:05
Why drop this condition? If the string is already
 
peria
2016/06/09 06:51:59
I agree that externalized strings should not be ex
 | |
| 6020 } | 6016 } | 
| 6021 | 6017 | 
| 6022 | 6018 | 
| 6023 Isolate* v8::Object::GetIsolate() { | 6019 Isolate* v8::Object::GetIsolate() { | 
| 6024 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 6020 i::Isolate* i_isolate = Utils::OpenHandle(this)->GetIsolate(); | 
| 6025 return reinterpret_cast<Isolate*>(i_isolate); | 6021 return reinterpret_cast<Isolate*>(i_isolate); | 
| 6026 } | 6022 } | 
| 6027 | 6023 | 
| 6028 | 6024 | 
| 6029 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 6025 Local<v8::Object> v8::Object::New(Isolate* isolate) { | 
| (...skipping 2794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8824 Address callback_address = | 8820 Address callback_address = | 
| 8825 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 8821 reinterpret_cast<Address>(reinterpret_cast<intptr_t>(callback)); | 
| 8826 VMState<EXTERNAL> state(isolate); | 8822 VMState<EXTERNAL> state(isolate); | 
| 8827 ExternalCallbackScope call_scope(isolate, callback_address); | 8823 ExternalCallbackScope call_scope(isolate, callback_address); | 
| 8828 callback(info); | 8824 callback(info); | 
| 8829 } | 8825 } | 
| 8830 | 8826 | 
| 8831 | 8827 | 
| 8832 } // namespace internal | 8828 } // namespace internal | 
| 8833 } // namespace v8 | 8829 } // namespace v8 | 
| OLD | NEW |