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

Side by Side Diff: src/heap.cc

Issue 11530011: Avoid object layout changes during GC. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 8 years 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/messages.js » ('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 // 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 7205 matching lines...) Expand 10 before | Expand all | Expand 10 after
7216 : heap->the_hole_value(); 7216 : heap->the_hole_value();
7217 } 7217 }
7218 } 7218 }
7219 } 7219 }
7220 7220
7221 7221
7222 void ErrorObjectList::DeferredFormatStackTrace(Isolate* isolate) { 7222 void ErrorObjectList::DeferredFormatStackTrace(Isolate* isolate) {
7223 // If formatting the stack trace causes a GC, this method will be 7223 // If formatting the stack trace causes a GC, this method will be
7224 // recursively called. In that case, skip the recursive call, since 7224 // recursively called. In that case, skip the recursive call, since
7225 // the loop modifies the list while iterating over it. 7225 // the loop modifies the list while iterating over it.
7226 if (nested_) return; 7226 if (nested_ || isolate->has_pending_exception()) return;
7227 nested_ = true; 7227 nested_ = true;
7228 HandleScope scope(isolate); 7228 HandleScope scope(isolate);
7229 Handle<String> stack_key = isolate->factory()->stack_symbol(); 7229 Handle<String> stack_key = isolate->factory()->stack_symbol();
7230 int write_index = 0; 7230 int write_index = 0;
7231 int budget = kBudgetPerGC; 7231 int budget = kBudgetPerGC;
7232 for (int i = 0; i < list_.length(); i++) { 7232 for (int i = 0; i < list_.length(); i++) {
7233 Object* object = list_[i]; 7233 Object* object = list_[i];
7234 // Skip possible holes in the list. 7234 // Skip possible holes in the list.
7235 if (object->IsTheHole()) continue; 7235 if (object->IsTheHole()) continue;
7236 if (isolate->heap()->InNewSpace(object) || budget == 0) { 7236 if (isolate->heap()->InNewSpace(object) || budget == 0) {
7237 list_[write_index++] = object; 7237 list_[write_index++] = object;
7238 continue; 7238 continue;
7239 } 7239 }
7240 7240
7241 // Fire the stack property getter, if it is the original marked getter. 7241 // Fire the stack property getter, if it is the original marked getter.
7242 LookupResult lookup(isolate); 7242 LookupResult lookup(isolate);
7243 JSObject::cast(object)->LocalLookupRealNamedProperty(*stack_key, &lookup); 7243 JSObject::cast(object)->LocalLookupRealNamedProperty(*stack_key, &lookup);
7244 if (!lookup.IsFound() || lookup.type() != CALLBACKS) continue; 7244 if (!lookup.IsFound() || lookup.type() != CALLBACKS) continue;
7245 Object* callback = lookup.GetCallbackObject(); 7245 Object* callback = lookup.GetCallbackObject();
7246 if (!callback->IsAccessorPair()) continue; 7246 if (!callback->IsAccessorPair()) continue;
7247 Object* getter_obj = AccessorPair::cast(callback)->getter(); 7247 Object* getter_obj = AccessorPair::cast(callback)->getter();
7248 if (!getter_obj->IsJSFunction()) continue; 7248 if (!getter_obj->IsJSFunction()) continue;
7249 JSFunction* getter_fun = JSFunction::cast(getter_obj); 7249 JSFunction* getter_fun = JSFunction::cast(getter_obj);
7250 String* key = isolate->heap()->hidden_stack_trace_symbol(); 7250 String* key = isolate->heap()->hidden_stack_trace_symbol();
7251 if (key != getter_fun->GetHiddenProperty(key)) continue; 7251 if (key != getter_fun->GetHiddenProperty(key)) continue;
7252 budget--;
7252 bool has_exception = false; 7253 bool has_exception = false;
7253 Execution::Call(Handle<Object>(getter_fun, isolate), 7254 Execution::Call(Handle<Object>(getter_fun, isolate),
7254 Handle<Object>(object, isolate), 7255 Handle<Object>(object, isolate),
7255 0, 7256 0,
7256 NULL, 7257 NULL,
7257 &has_exception); 7258 &has_exception);
7258 ASSERT(!has_exception); 7259 if (has_exception) {
7259 budget--; 7260 // Hit an exception (most likely a stack overflow).
7261 // Wrap up this pass and retry after another GC.
7262 isolate->clear_pending_exception();
7263 list_[write_index++] = object;
7264 budget = 0;
7265 }
7260 } 7266 }
7261 list_.Rewind(write_index); 7267 list_.Rewind(write_index);
7262 list_.Trim(); 7268 list_.Trim();
7263 nested_ = false; 7269 nested_ = false;
7264 } 7270 }
7265 7271
7266 7272
7267 void ErrorObjectList::RemoveUnmarked(Heap* heap) { 7273 void ErrorObjectList::RemoveUnmarked(Heap* heap) {
7268 for (int i = 0; i < list_.length(); i++) { 7274 for (int i = 0; i < list_.length(); i++) {
7269 HeapObject* object = HeapObject::cast(list_[i]); 7275 HeapObject* object = HeapObject::cast(list_[i]);
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
7400 static_cast<int>(object_sizes_last_time_[index])); 7406 static_cast<int>(object_sizes_last_time_[index]));
7401 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT) 7407 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(ADJUST_LAST_TIME_OBJECT_COUNT)
7402 #undef ADJUST_LAST_TIME_OBJECT_COUNT 7408 #undef ADJUST_LAST_TIME_OBJECT_COUNT
7403 7409
7404 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); 7410 memcpy(object_counts_last_time_, object_counts_, sizeof(object_counts_));
7405 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); 7411 memcpy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_));
7406 ClearObjectStats(); 7412 ClearObjectStats();
7407 } 7413 }
7408 7414
7409 } } // namespace v8::internal 7415 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | src/messages.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698