Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: src/api.cc

Issue 2046933002: [V8] Make String::CanMakeExternal ignore the length of new strings (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove check of length Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « no previous file | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698