Expose gc(true) to JavaScript, which triggers a scavenger GC.

With the --expose_gc option, gc() is exposed to JavaScript. Currently gc() triggers a full GC.

To enable JavaScript to test the behavior of a scavenger GC, this patch exposes gc(true). If the first argument is true, gc(...) triggers a scavenger GC. Otherwise, gc(...) triggers a full GC.

BUG=
Test=Manually confirmed that gc() and gc(false) trigger a full GC and that gc(true) triggers a scavenger GC.

Review URL: https://codereview.chromium.org/11232065
Patch from Kentaro Hara <haraken@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@12815 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent e40b33d3
...@@ -40,7 +40,11 @@ v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction( ...@@ -40,7 +40,11 @@ v8::Handle<v8::FunctionTemplate> GCExtension::GetNativeFunction(
v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) { v8::Handle<v8::Value> GCExtension::GC(const v8::Arguments& args) {
HEAP->CollectAllGarbage(Heap::kNoGCFlags, "gc extension"); if (args[0]->BooleanValue()) {
HEAP->CollectGarbage(NEW_SPACE, "gc extension");
} else {
HEAP->CollectAllGarbage(Heap::kNoGCFlags, "gc extension");
}
return v8::Undefined(); return v8::Undefined();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment