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

Side by Side Diff: src/api.cc

Issue 7105016: Ensure strings are never externalized as a side-effect of doing a GC. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/heap.h » ('j') | src/heap.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 4246 matching lines...) Expand 10 before | Expand all | Expand 10 after
4257 i::Handle<i::String> obj = Utils::OpenHandle(this); 4257 i::Handle<i::String> obj = Utils::OpenHandle(this);
4258 i::Isolate* isolate = obj->GetIsolate(); 4258 i::Isolate* isolate = obj->GetIsolate();
4259 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4259 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4260 if (i::StringShape(*obj).IsExternalTwoByte()) { 4260 if (i::StringShape(*obj).IsExternalTwoByte()) {
4261 return false; // Already an external string. 4261 return false; // Already an external string.
4262 } 4262 }
4263 ENTER_V8(isolate); 4263 ENTER_V8(isolate);
4264 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4264 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4265 return false; 4265 return false;
4266 } 4266 }
4267 if (isolate->heap()->gc_post_process_count() > 0) {
4268 return false;
4269 }
4267 bool result = obj->MakeExternal(resource); 4270 bool result = obj->MakeExternal(resource);
4268 if (result && !obj->IsSymbol()) { 4271 if (result && !obj->IsSymbol()) {
4269 isolate->heap()->external_string_table()->AddString(*obj); 4272 isolate->heap()->external_string_table()->AddString(*obj);
4270 } 4273 }
4271 return result; 4274 return result;
4272 } 4275 }
4273 4276
4274 4277
4275 Local<String> v8::String::NewExternal( 4278 Local<String> v8::String::NewExternal(
4276 v8::String::ExternalAsciiStringResource* resource) { 4279 v8::String::ExternalAsciiStringResource* resource) {
(...skipping 12 matching lines...) Expand all
4289 i::Handle<i::String> obj = Utils::OpenHandle(this); 4292 i::Handle<i::String> obj = Utils::OpenHandle(this);
4290 i::Isolate* isolate = obj->GetIsolate(); 4293 i::Isolate* isolate = obj->GetIsolate();
4291 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false; 4294 if (IsDeadCheck(isolate, "v8::String::MakeExternal()")) return false;
4292 if (i::StringShape(*obj).IsExternalTwoByte()) { 4295 if (i::StringShape(*obj).IsExternalTwoByte()) {
4293 return false; // Already an external string. 4296 return false; // Already an external string.
4294 } 4297 }
4295 ENTER_V8(isolate); 4298 ENTER_V8(isolate);
4296 if (isolate->string_tracker()->IsFreshUnusedString(obj)) { 4299 if (isolate->string_tracker()->IsFreshUnusedString(obj)) {
4297 return false; 4300 return false;
4298 } 4301 }
4302 if (isolate->heap()->gc_post_process_count() > 0) {
4303 return false;
4304 }
4299 bool result = obj->MakeExternal(resource); 4305 bool result = obj->MakeExternal(resource);
4300 if (result && !obj->IsSymbol()) { 4306 if (result && !obj->IsSymbol()) {
4301 isolate->heap()->external_string_table()->AddString(*obj); 4307 isolate->heap()->external_string_table()->AddString(*obj);
4302 } 4308 }
4303 return result; 4309 return result;
4304 } 4310 }
4305 4311
4306 4312
4307 bool v8::String::CanMakeExternal() { 4313 bool v8::String::CanMakeExternal() {
4308 i::Handle<i::String> obj = Utils::OpenHandle(this); 4314 i::Handle<i::String> obj = Utils::OpenHandle(this);
(...skipping 1529 matching lines...) Expand 10 before | Expand all | Expand 10 after
5838 5844
5839 5845
5840 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) { 5846 char* HandleScopeImplementer::Iterate(ObjectVisitor* v, char* storage) {
5841 HandleScopeImplementer* scope_implementer = 5847 HandleScopeImplementer* scope_implementer =
5842 reinterpret_cast<HandleScopeImplementer*>(storage); 5848 reinterpret_cast<HandleScopeImplementer*>(storage);
5843 scope_implementer->IterateThis(v); 5849 scope_implementer->IterateThis(v);
5844 return storage + ArchiveSpacePerThread(); 5850 return storage + ArchiveSpacePerThread();
5845 } 5851 }
5846 5852
5847 } } // namespace v8::internal 5853 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/heap.h » ('j') | src/heap.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698