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); |