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

Unified Diff: src/api.cc

Issue 462643002: Small clean up of externalizing strings. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: change Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 7098859de3cfa9fa85d786b29cf8eef56846f086..304a8fa2eff64b818559e74f1fdfd6ebdd8e3537 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5475,7 +5475,7 @@ Local<String> v8::String::NewExternal(
bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
i::Handle<i::String> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
- if (i::StringShape(*obj).IsExternalTwoByte()) {
+ if (i::StringShape(*obj).IsExternal()) {
return false; // Already an external string.
}
ENTER_V8(isolate);
@@ -5488,6 +5488,8 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
CHECK(resource && resource->data());
bool result = obj->MakeExternal(resource);
+ // Assert that if CanMakeExternal(), then externalizing actually succeeds.
+ DCHECK(!CanMakeExternal() || result);
if (result) {
DCHECK(obj->IsExternalString());
isolate->heap()->external_string_table()->AddString(*obj);
@@ -5515,7 +5517,7 @@ bool v8::String::MakeExternal(
v8::String::ExternalAsciiStringResource* resource) {
i::Handle<i::String> obj = Utils::OpenHandle(this);
i::Isolate* isolate = obj->GetIsolate();
- if (i::StringShape(*obj).IsExternalTwoByte()) {
+ if (i::StringShape(*obj).IsExternal()) {
return false; // Already an external string.
}
ENTER_V8(isolate);
@@ -5528,6 +5530,8 @@ bool v8::String::MakeExternal(
CHECK(resource && resource->data());
bool result = obj->MakeExternal(resource);
+ // Assert that if CanMakeExternal(), then externalizing actually succeeds.
+ DCHECK(!CanMakeExternal() || result);
if (result) {
DCHECK(obj->IsExternalString());
isolate->heap()->external_string_table()->AddString(*obj);
« no previous file with comments | « no previous file | src/factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698