Skip to content

Commit

Permalink
global, refactor: Fix capitalization of GC function.
Browse files Browse the repository at this point in the history
  • Loading branch information
xicilion committed Dec 21, 2023
1 parent 7b53c2c commit 4c8c144
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 18 deletions.
10 changes: 5 additions & 5 deletions fibjs/include/ifs/global.h
Expand Up @@ -43,7 +43,7 @@ class global_base : public object_base {
static result_t clearImmediate(v8::Local<v8::Value> t);
static result_t btoa(Buffer_base* data, bool url, exlib::string& retVal);
static result_t atob(exlib::string data, obj_ptr<Buffer_base>& retVal);
static result_t GC();
static result_t gc();

public:
static void s__new(const v8::FunctionCallbackInfo<v8::Value>& args)
Expand All @@ -69,7 +69,7 @@ class global_base : public object_base {
static void s_static_clearImmediate(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_static_btoa(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_static_atob(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_static_GC(const v8::FunctionCallbackInfo<v8::Value>& args);
static void s_static_gc(const v8::FunctionCallbackInfo<v8::Value>& args);
};
}

Expand Down Expand Up @@ -98,7 +98,7 @@ inline ClassInfo& global_base::class_info()
{ "clearImmediate", s_static_clearImmediate, true, false },
{ "btoa", s_static_btoa, true, false },
{ "atob", s_static_atob, true, false },
{ "GC", s_static_GC, true, false }
{ "gc", s_static_gc, true, false }
};

static ClassData::ClassObject s_object[] = {
Expand Down Expand Up @@ -327,13 +327,13 @@ inline void global_base::s_static_atob(const v8::FunctionCallbackInfo<v8::Value>
METHOD_RETURN();
}

inline void global_base::s_static_GC(const v8::FunctionCallbackInfo<v8::Value>& args)
inline void global_base::s_static_gc(const v8::FunctionCallbackInfo<v8::Value>& args)
{
METHOD_ENTER();

METHOD_OVER(0, 0);

hr = GC();
hr = gc();

METHOD_VOID();
}
Expand Down
2 changes: 1 addition & 1 deletion fibjs/src/global/global.cpp
Expand Up @@ -22,7 +22,7 @@ result_t global_base::get_globalThis(v8::Local<v8::Object>& retVal)
return 0;
}

result_t global_base::GC()
result_t global_base::gc()
{
Isolate::current()->m_isolate->LowMemoryNotification();
return 0;
Expand Down
6 changes: 3 additions & 3 deletions fibjs/src/profiler/HeapSnapshot.cpp
Expand Up @@ -44,7 +44,7 @@ class BufferStream : public v8::OutputStream {

result_t profiler_base::takeSnapshot(obj_ptr<HeapSnapshot_base>& retVal)
{
global_base::GC();
global_base::gc();

v8::HeapProfiler* profiler = Isolate::current()->m_isolate->GetHeapProfiler();
retVal = new HeapSnapshotProxy(profiler->TakeHeapSnapshot());
Expand All @@ -57,12 +57,12 @@ result_t profiler_base::diff(v8::Local<v8::Function> test, v8::Local<v8::Object>
v8::HeapProfiler* profiler = isolate->m_isolate->GetHeapProfiler();
obj_ptr<HeapSnapshot_base> s1, s2;

global_base::GC();
global_base::gc();
s1 = new HeapSnapshotProxy(profiler->TakeHeapSnapshot());

test->Call(test->GetCreationContextChecked(), v8::Undefined(isolate->m_isolate), 0, NULL).IsEmpty();

global_base::GC();
global_base::gc();
s2 = new HeapSnapshotProxy(profiler->TakeHeapSnapshot());

return s2->diff(s1, retVal);
Expand Down
2 changes: 1 addition & 1 deletion idl/zh-cn/global.idl
Expand Up @@ -174,5 +174,5 @@ module global
static Buffer atob(String data);

/*! @brief 强制要求进行垃圾回收*/
static GC();
static gc();
};
2 changes: 1 addition & 1 deletion npm/types/dts/module/global.d.ts
Expand Up @@ -228,7 +228,7 @@ declare module 'global' {
/**
* @description 强制要求进行垃圾回收
*/
function GC(): void;
function gc(): void;

}

8 changes: 4 additions & 4 deletions test/addons_test.js
Expand Up @@ -272,7 +272,7 @@ describe('addons api', () => {
assert.strictEqual(binding.newExternalBuffer().toString(), binding.theText);

assert.strictEqual(binding.getDeleterCallCount(), 0);
GC();
gc();
assert.strictEqual(binding.getDeleterCallCount(), 1);
assert.strictEqual(binding.copyBuffer().toString(), binding.theText);

Expand All @@ -284,7 +284,7 @@ describe('addons api', () => {

buffer = null;
assert.strictEqual(binding.getDeleterCallCount(), 1);
GC();
gc();
assert.strictEqual(binding.getDeleterCallCount(), 2);

});
Expand Down Expand Up @@ -895,7 +895,7 @@ describe('addons api', () => {
// let tracked_function = test_function.MakeTrackedFunction(common.mustCall());
// assert(!!tracked_function);
// tracked_function = null;
global.GC();
gc();

assert.deepEqual(test_function.TestCreateFunctionParameters(), {
envIsNull: 'Invalid argument',
Expand Down Expand Up @@ -1976,7 +1976,7 @@ describe('addons api', () => {
for (let i = 0; i < 1000; i++) {
const wrapObject = new Object();
test_reference.validateDeleteBeforeFinalize(wrapObject);
global.GC();
gc();
}
});

Expand Down
4 changes: 2 additions & 2 deletions test/coroutine_test.js
Expand Up @@ -92,9 +92,9 @@ describe('coroutine', () => {
assert.equal(n, 1300);
});

it('do not recycle fiber objects during GC', () => {
it('do not recycle fiber objects during gc', () => {
coroutine.current().v = 100;
GC();
gc();
assert.equal(coroutine.current().v, 100);
});

Expand Down
2 changes: 1 addition & 1 deletion test/test_util.js
Expand Up @@ -43,7 +43,7 @@ exports.gc = () => {
var t1 = new Date();
while (new Date() - t1 < 1000) {
coroutine.sleep(1);
GC();
gc();
}
}

Expand Down

0 comments on commit 4c8c144

Please sign in to comment.