blob: 9eb453b98687a88206f57137844949c859fc8d7e [file] [log] [blame]
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -08001// Copyright 2010 the V8 project authors. All rights reserved.
Ben Murdochb8a8cc12014-11-26 15:28:44 +00002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -08004
Ben Murdochb8a8cc12014-11-26 15:28:44 +00005#include "src/extensions/gc-extension.h"
6
7#include "src/base/platform/platform.h"
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -08008
9namespace v8 {
10namespace internal {
11
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080012
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000013v8::Local<v8::FunctionTemplate> GCExtension::GetNativeFunctionTemplate(
14 v8::Isolate* isolate, v8::Local<v8::String> str) {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000015 return v8::FunctionTemplate::New(isolate, GCExtension::GC);
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080016}
17
18
Ben Murdochb8a8cc12014-11-26 15:28:44 +000019void GCExtension::GC(const v8::FunctionCallbackInfo<v8::Value>& args) {
20 args.GetIsolate()->RequestGarbageCollectionForTesting(
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021 args[0]
22 ->BooleanValue(args.GetIsolate()->GetCurrentContext())
23 .FromMaybe(false)
24 ? v8::Isolate::kMinorGarbageCollection
25 : v8::Isolate::kFullGarbageCollection);
Shimeng (Simon) Wang8a31eba2010-12-06 19:01:33 -080026}
27
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000028} // namespace internal
29} // namespace v8