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

Unified Diff: src/api.cc

Issue 146183006: Allow externalizing strings in old pointer space. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Also fix two-byte String::MakeExternal Created 6 years, 10 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/heap-inl.h » ('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 064a4b013f45e22b2327c4a451fae928cbfff27e..7a412df28dcfe13979722b1aa8bb41a6e10d0aa8 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -5426,23 +5426,6 @@ static i::Handle<i::String> NewExternalAsciiStringHandle(
}
-static bool RedirectToExternalString(i::Isolate* isolate,
- i::Handle<i::String> parent,
- i::Handle<i::String> external) {
- if (parent->IsConsString()) {
- i::Handle<i::ConsString> cons = i::Handle<i::ConsString>::cast(parent);
- cons->set_first(*external);
- cons->set_second(isolate->heap()->empty_string());
- } else {
- ASSERT(parent->IsSlicedString());
- i::Handle<i::SlicedString> slice = i::Handle<i::SlicedString>::cast(parent);
- slice->set_parent(*external);
- slice->set_offset(0);
- }
- return true;
-}
-
-
Local<String> v8::String::NewExternal(
Isolate* isolate,
v8::String::ExternalStringResource* resource) {
@@ -5472,22 +5455,10 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
}
CHECK(resource && resource->data());
- bool result;
- i::Handle<i::String> external;
- if (isolate->heap()->old_pointer_space()->Contains(*obj)) {
- // We do not allow external strings in the old pointer space. Instead of
- // converting the string in-place, we keep the cons/sliced string and
- // point it to a newly-allocated external string.
- external = NewExternalStringHandle(isolate, resource);
- result = RedirectToExternalString(isolate, obj, external);
- } else {
- result = obj->MakeExternal(resource);
- external = obj;
- }
-
+ bool result = obj->MakeExternal(resource);
if (result) {
- ASSERT(external->IsExternalString());
- isolate->heap()->external_string_table()->AddString(*external);
+ ASSERT(obj->IsExternalString());
+ isolate->heap()->external_string_table()->AddString(*obj);
}
return result;
}
@@ -5524,22 +5495,10 @@ bool v8::String::MakeExternal(
}
CHECK(resource && resource->data());
- bool result;
- i::Handle<i::String> external;
- if (isolate->heap()->old_pointer_space()->Contains(*obj)) {
- // We do not allow external strings in the old pointer space. Instead of
- // converting the string in-place, we keep the cons/sliced string and
- // point it to a newly-allocated external string.
- external = NewExternalAsciiStringHandle(isolate, resource);
- result = RedirectToExternalString(isolate, obj, external);
- } else {
- result = obj->MakeExternal(resource);
- external = obj;
- }
-
+ bool result = obj->MakeExternal(resource);
if (result) {
- ASSERT(external->IsExternalString());
- isolate->heap()->external_string_table()->AddString(*external);
+ ASSERT(obj->IsExternalString());
+ isolate->heap()->external_string_table()->AddString(*obj);
}
return result;
}
« no previous file with comments | « no previous file | src/heap-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698