• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright JS Foundation and other contributors, http://js.foundation
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "jerryscript-ext/handler.h"
17 
18 /**
19  * Expose garbage collector to scripts.
20  *
21  * @return undefined.
22  */
23 jerry_value_t
jerryx_handler_gc(const jerry_value_t func_obj_val,const jerry_value_t this_p,const jerry_value_t args_p[],const jerry_length_t args_cnt)24 jerryx_handler_gc (const jerry_value_t func_obj_val, /**< function object */
25                    const jerry_value_t this_p, /**< this arg */
26                    const jerry_value_t args_p[], /**< function arguments */
27                    const jerry_length_t args_cnt) /**< number of function arguments */
28 {
29   (void) func_obj_val; /* unused */
30   (void) this_p; /* unused */
31 
32   jerry_gc_mode_t mode = ((args_cnt > 0 && jerry_value_to_boolean (args_p[0])) ? JERRY_GC_PRESSURE_HIGH
33                                                                                : JERRY_GC_PRESSURE_LOW);
34 
35   jerry_gc (mode);
36   return jerry_create_undefined ();
37 } /* jerryx_handler_gc */
38