Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 1 | // Copyright 2010 the V8 project authors. All rights reserved. |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 4 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 5 | #include "src/extensions/gc-extension.h" |
| 6 | |
| 7 | #include "src/base/platform/platform.h" |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 8 | |
| 9 | namespace v8 { |
| 10 | namespace internal { |
| 11 | |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 12 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 13 | v8::Local<v8::FunctionTemplate> GCExtension::GetNativeFunctionTemplate( |
| 14 | v8::Isolate* isolate, v8::Local<v8::String> str) { |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 15 | return v8::FunctionTemplate::New(isolate, GCExtension::GC); |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 16 | } |
| 17 | |
| 18 | |
Ben Murdoch | b8a8cc1 | 2014-11-26 15:28:44 +0000 | [diff] [blame] | 19 | void GCExtension::GC(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 20 | args.GetIsolate()->RequestGarbageCollectionForTesting( |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 21 | args[0] |
| 22 | ->BooleanValue(args.GetIsolate()->GetCurrentContext()) |
| 23 | .FromMaybe(false) |
| 24 | ? v8::Isolate::kMinorGarbageCollection |
| 25 | : v8::Isolate::kFullGarbageCollection); |
Shimeng (Simon) Wang | 8a31eba | 2010-12-06 19:01:33 -0800 | [diff] [blame] | 26 | } |
| 27 | |
Ben Murdoch | 4a90d5f | 2016-03-22 12:00:34 +0000 | [diff] [blame] | 28 | } // namespace internal |
| 29 | } // namespace v8 |