diff --git a/deps/node/src/env.cc b/deps/node/src/env.cc index a492f27b72..a1e64c74ae 100644 --- a/deps/node/src/env.cc +++ b/deps/node/src/env.cc @@ -259,7 +259,7 @@ void TrackingTraceStateObserver::UpdateTraceCategoryState() { } void Environment::CreateProperties() { - LWNODE_DEV_LOG("[Environment::CreateProperties] start"); + LWNODE_DEV_FATAL_LOG("[Environment::CreateProperties] start"); HandleScope handle_scope(isolate_); Local ctx = context(); @@ -285,7 +285,7 @@ void Environment::CreateProperties() { node::CreateProcessObject(this).FromMaybe(Local()); set_process_object(process_object); - LWNODE_DEV_LOG("[Environment::CreateProperties] end"); + LWNODE_DEV_FATAL_LOG("[Environment::CreateProperties] end"); } std::string GetExecPath(const std::vector& argv) { diff --git a/deps/node/src/lwnode/lwnode-public.cc b/deps/node/src/lwnode/lwnode-public.cc index 5f057122a1..225a855ec9 100644 --- a/deps/node/src/lwnode/lwnode-public.cc +++ b/deps/node/src/lwnode/lwnode-public.cc @@ -73,22 +73,22 @@ class Runtime::Internal { kNoBuiltinFile = 100, }; - Internal() { LWNODE_DEV_LOG("[Runtime::Internal::Internal] new"); } + Internal() { LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Internal] new"); } std::pair Init(int argc, char** argv) { if (state_ != State::kNotInitialized) { - LWNODE_DEV_LOG("[Runtime::Internal::Init] already initialized"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Init] already initialized"); return std::make_pair(true, ExitCode::kFailure); } if (!native_module::initializeLWNodeBuiltinFile( config_.internal_->lwnode_data_path)) { - LWNODE_DEV_LOG( + LWNODE_DEV_FATAL_LOG( "[Runtime::Internal::Init] failed to initialize builtin file"); return std::make_pair(true, ExitCode::kNoBuiltinFile); } - LWNODE_DEV_LOG("[Runtime::Internal::Init]"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Init]"); state_ = State::kInitialized; // Set sendMessageSync callback to isolate context embedder data. @@ -108,12 +108,12 @@ class Runtime::Internal { int Run() { if (state_ != State::kInitialized) { - LWNODE_DEV_LOG("[Runtime::Internal::Run] not initialized"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Run] not initialized"); return -1; } CHECK_NOT_NULL(instance_); - LWNODE_DEV_LOG("[Runtime::Internal::Run]"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Run]"); state_ = State::kRunning; int result = runner_.Run(*instance_); @@ -127,12 +127,12 @@ class Runtime::Internal { std::unique_lock lock(stop_mutex_); if (state_ != State::kRunning) { - LWNODE_DEV_LOG("[Runtime::Internal::Stop] already stopped"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Stop] already stopped"); return; } CHECK_NOT_NULL(instance_); - LWNODE_DEV_LOG("[Runtime::Internal::Stop]"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Stop]"); state_ = State::kStopped; runner_.Stop(); @@ -140,13 +140,13 @@ class Runtime::Internal { void Free() { if (state_ != State::kStopped && state_ != State::kInitialized) { - LWNODE_DEV_LOG("[Runtime::Internal::Free] not stopped"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Free] not stopped"); return; } state_ = State::kReleased; if (instance_) { - LWNODE_DEV_LOG("[Runtime::Internal::Free]"); + LWNODE_DEV_FATAL_LOG("[Runtime::Internal::Free]"); DisposeNode(instance_); } @@ -174,9 +174,9 @@ Runtime::Runtime() : internal_(new Internal()) { ss << "pid " << std::to_string(uv_os_getpid()) << " " << "tid " << std::this_thread::get_id(); - LWNODE_DEV_LOG("[Runtime::Runtime] %d %s", - Internal::instance_count_.load(), - ss.str().c_str()); + LWNODE_DEV_FATAL_LOG("[Runtime::Runtime] %d %s", + Internal::instance_count_.load(), + ss.str().c_str()); } Runtime::Runtime(Configuration&& config) : Runtime() { @@ -185,20 +185,21 @@ Runtime::Runtime(Configuration&& config) : Runtime() { Runtime::~Runtime() { delete internal_; - LWNODE_DEV_LOG("[Runtime::~Runtime]"); + LWNODE_DEV_FATAL_LOG("[Runtime::~Runtime]"); } int Runtime::Start(int argc, char** argv, std::promise&& promise) { LWNODE_PERF_LOG("[Runtime::Start]"); - LWNODE_DEV_LOG("[Runtime] version: %s", LWNODE_VERSION_TAG); + LWNODE_DEV_FATAL_LOG("[Runtime] version: %s", LWNODE_VERSION_TAG); #if defined(NDEBUG) - LWNODE_DEV_LOG("[Runtime] release mode"); + LWNODE_DEV_FATAL_LOG("[Runtime] release mode"); #else - LWNODE_DEV_LOG("[Runtime] debug mode"); + LWNODE_DEV_FATAL_LOG("[Runtime] debug mode"); #endif if (!g_allow_mulitple_instance && Runtime::Internal::instance_count_ > 1) { - LWNODE_DEV_LOG("[Runtime] Runtime can only be started once per process."); + LWNODE_DEV_FATAL_LOG( + "[Runtime] Runtime can only be started once per process."); promise.set_exception(std::make_exception_ptr( std::runtime_error("Runtime can only be started once per process."))); return Runtime::Internal::ExitCode::kFailure; @@ -255,8 +256,8 @@ bool Runtime::Configuration::Set(const std::string& key, const char* value) { std::string value_string = value ? value : ""; if (key == "lwnode_data_path") { - LWNODE_DEV_LOG("[Runtime::Configuration::Set] data path set to %s", - value_string.c_str()); + LWNODE_DEV_FATAL_LOG("[Runtime::Configuration::Set] data path set to %s", + value_string.c_str()); internal_->lwnode_data_path = value_string; return true; } @@ -265,12 +266,12 @@ bool Runtime::Configuration::Set(const std::string& key, const char* value) { bool Runtime::Configuration::Set(const std::string& key, int value) { if (key == "gc_interval") { - LWNODE_DEV_LOG("[Runtime::Configuration::Set] GC interval set to %dms", - value); + LWNODE_DEV_FATAL_LOG( + "[Runtime::Configuration::Set] GC interval set to %dms", value); LWNode::GlobalConfiguration::GetInstance().set_gc_interval(value); return true; } else if (key == "gc_free_space_divisor") { - LWNODE_DEV_LOG( + LWNODE_DEV_FATAL_LOG( "[Runtime::Configuration::Set] GC free space divisor set to %d", value); LWNode::GlobalConfiguration::GetInstance().set_gc_free_space_divisor(value); return true; @@ -310,7 +311,7 @@ bool InitScriptRootPath(const std::string path) { result = uv_chdir(path.c_str()); if (result != 0) { - LWNODE_DEV_LOG("ERROR: Failed to change directory. (%d)\n", -errno); + LWNODE_DEV_FATAL_LOG("ERROR: Failed to change directory. (%d)\n", -errno); return false; } diff --git a/deps/node/src/node.cc b/deps/node/src/node.cc index b7ea9fc4a5..e14f143637 100644 --- a/deps/node/src/node.cc +++ b/deps/node/src/node.cc @@ -176,12 +176,12 @@ MaybeLocal ExecuteBootstrapper(Environment* env, return MaybeLocal(); } - LWNODE_DEV_LOG("[ExecuteBootstrapper]: call %s", id); + LWNODE_DEV_FATAL_LOG("[ExecuteBootstrapper]: call %s", id); MaybeLocal result = fn->Call(env->context(), Undefined(env->isolate()), arguments->size(), arguments->data()); - LWNODE_DEV_LOG("[ExecuteBootstrapper]: /call %s", id); + LWNODE_DEV_FATAL_LOG("[ExecuteBootstrapper]: /call %s", id); // If there was an error during bootstrap, it must be unrecoverable // (e.g. max call stack exceeded). Clear the stack so that the @@ -288,7 +288,7 @@ void Environment::InitializeDiagnostics() { } MaybeLocal Environment::BootstrapInternalLoaders() { - LWNODE_DEV_LOG("[Environment::BootstrapInternalLoaders] start"); + LWNODE_DEV_FATAL_LOG("[Environment::BootstrapInternalLoaders] start"); EscapableHandleScope scope(isolate_); @@ -327,7 +327,7 @@ MaybeLocal Environment::BootstrapInternalLoaders() { CHECK(require->IsFunction()); set_native_module_require(require.As()); - LWNODE_DEV_LOG("[Environment::BootstrapInternalLoaders] end"); + LWNODE_DEV_FATAL_LOG("[Environment::BootstrapInternalLoaders] end"); return scope.Escape(loader_exports); } @@ -390,7 +390,7 @@ MaybeLocal Environment::BootstrapNode() { } MaybeLocal Environment::RunBootstrapping() { - LWNODE_DEV_LOG("[Environment::RunBootstrapping] start"); + LWNODE_DEV_FATAL_LOG("[Environment::RunBootstrapping] start"); EscapableHandleScope scope(isolate_); @@ -414,7 +414,7 @@ MaybeLocal Environment::RunBootstrapping() { set_has_run_bootstrapping_code(true); - LWNODE_DEV_LOG("[Environment::RunBootstrapping] end"); + LWNODE_DEV_FATAL_LOG("[Environment::RunBootstrapping] end"); return scope.Escape(result); } @@ -989,7 +989,7 @@ void Init(int* argc, InitializationResult InitializeOncePerProcess(int argc, char** argv) { // Initialized the enabled list for Debug() calls with system // environment variables. - LWNODE_DEV_LOG("[InitializeOncePerProcess] start"); + LWNODE_DEV_FATAL_LOG("[InitializeOncePerProcess] start"); per_process::enabled_debug_list.Parse(nullptr); atexit(ResetStdio); @@ -1069,7 +1069,7 @@ InitializationResult InitializeOncePerProcess(int argc, char** argv) { performance::performance_v8_start = PERFORMANCE_NOW(); per_process::v8_initialized = true; - LWNODE_DEV_LOG("[InitializeOncePerProcess] end"); + LWNODE_DEV_FATAL_LOG("[InitializeOncePerProcess] end"); return result; } diff --git a/deps/node/src/node_main_instance.cc b/deps/node/src/node_main_instance.cc index 5405aae298..6a247db85c 100644 --- a/deps/node/src/node_main_instance.cc +++ b/deps/node/src/node_main_instance.cc @@ -65,8 +65,8 @@ NodeMainInstance::NodeMainInstance( platform_(platform), isolate_data_(nullptr), owns_isolate_(true) { - LWNODE_DEV_LOG("[NodeMainInstance::NodeMainInstance] start"); - + LWNODE_DEV_FATAL_LOG("[NodeMainInstance::NodeMainInstance] start"); + params->array_buffer_allocator = array_buffer_allocator_.get(); isolate_ = Isolate::Allocate(); CHECK_NOT_NULL(isolate_); @@ -92,7 +92,7 @@ NodeMainInstance::NodeMainInstance( SetIsolateErrorHandlers(isolate_, s); } - LWNODE_DEV_LOG("[NodeMainInstance::NodeMainInstance] end"); + LWNODE_DEV_FATAL_LOG("[NodeMainInstance::NodeMainInstance] end"); } void NodeMainInstance::Dispose() { diff --git a/deps/node/src/node_main_lw_runner-inl.h b/deps/node/src/node_main_lw_runner-inl.h index 720754bb69..a74a4636c5 100644 --- a/deps/node/src/node_main_lw_runner-inl.h +++ b/deps/node/src/node_main_lw_runner-inl.h @@ -104,11 +104,11 @@ class LoopStrategy : public MainLoopStrategy { class LWNodeMainRunner { public: ~LWNodeMainRunner() { - LWNODE_DEV_LOG("[LWNodeMainRunner::~LWNodeMainRunner]"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::~LWNodeMainRunner]"); } int Run(node::NodeMainInstance& nodeMainInstance) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run]"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run]"); // To release array buffer allocator after node is finished, // this runner should has it. @@ -121,12 +121,12 @@ class LWNodeMainRunner { Isolate::Scope isolate_scope(isolate_); HandleScope handle_scope(isolate_); - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] create main environment"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] create main environment"); int exit_code = 0; DeleteFnPtr env_ = nodeMainInstance.CreateMainEnvironment(&exit_code); - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] /create main environment"); - + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] /create main environment"); + Context::Scope context_scope(env_->context()); CHECK_NOT_NULL(env_); @@ -135,7 +135,7 @@ class LWNodeMainRunner { SetProcessExitHandler( environment_, [&](node::Environment* env_, int exit_code) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] process exit handler"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] process exit handler"); if (env_->is_stopping()) { return; } @@ -149,9 +149,9 @@ class LWNodeMainRunner { } if (exit_code == 0) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] load environment"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] load environment"); LoadEnvironment(env_.get()); - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] /load environment"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] /load environment"); IdleGC(isolate_); @@ -159,10 +159,10 @@ class LWNodeMainRunner { try { LWNODE_PERF_LOG("[LWNodeMainRunner::Run] loaded script"); - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] set runtime ready"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] set runtime ready"); promise_.set_value(); } catch (const std::exception& e) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] promise error: %s", e.what()); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] promise error: %s", e.what()); v8::V8::ShutdownPlatform(); return 1; } @@ -175,10 +175,10 @@ class LWNodeMainRunner { // Run main loop std::unique_ptr mainLoop; if (GmainLoopNodeBindings::isEnabled()) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] use gmain loop"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] use gmain loop"); mainLoop = std::make_unique(); } else { - LWNODE_DEV_LOG("[LWNodeMainRunner::Run] use standard loop"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] use standard loop"); mainLoop = std::make_unique(); } @@ -223,9 +223,9 @@ class LWNodeMainRunner { } void Stop() { - LWNODE_DEV_LOG("[LWNodeMainRunner::Stop]"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Stop]"); if (!environment_) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Stop] no environment"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Stop] no environment"); return; } if (environment_->is_stopping()) { @@ -235,7 +235,7 @@ class LWNodeMainRunner { environment_->set_stopping(true); uv_async_init(uv_default_loop(), &stop_task_, [](uv_async_t* handle) { - LWNODE_DEV_LOG("[LWNodeMainRunner::Stop] async task"); + LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Stop] async task"); uv_stop(uv_default_loop()); }); diff --git a/include/lwnode/lwnode-version.h b/include/lwnode/lwnode-version.h index 0179772eb6..85406f610b 100644 --- a/include/lwnode/lwnode-version.h +++ b/include/lwnode/lwnode-version.h @@ -18,5 +18,5 @@ #define LWNODE_VERSION_MAJOR 1 #define LWNODE_VERSION_MINOR 1 - #define LWNODE_VERSION_PATCH 19 - #define LWNODE_VERSION_TAG "v1.1.19" + #define LWNODE_VERSION_PATCH 20 + #define LWNODE_VERSION_TAG "v1.1.20" diff --git a/src/api/isolate.cc b/src/api/isolate.cc index 2a0a509634..eb1564d9db 100755 --- a/src/api/isolate.cc +++ b/src/api/isolate.cc @@ -399,7 +399,7 @@ void IsolateWrap::Initialize(const v8::Isolate::CreateParams& params) { // Do Nothing LWNODE_CALL_TRACE_GC_START(); // NOTE: Calls when vmInstance() is terminated. This happens before GC runs - LWNODE_DEV_LOG("[OnVMInstanceDelete]"); + LWNODE_DEV_FATAL_LOG("[OnVMInstanceDelete]"); LWNODE_CALL_TRACE_GC_END(); }); diff --git a/src/api/stack-trace.h b/src/api/stack-trace.h index 84fec29ea2..92728cbe5b 100644 --- a/src/api/stack-trace.h +++ b/src/api/stack-trace.h @@ -47,8 +47,7 @@ class StackTrace { void setStackValue(ValueRef* stackValue) { stackValue_ = stackValue; } bool hasStackValue() { return stackValue_ != nullptr; } - void* operator new(size_t size) { return GC_MALLOC(size); } - void operator delete(void* ptr) { GC_FREE(ptr); } + void* operator new(size_t size) { return Memory::gcMalloc(size); } private: ArrayObjectRef* stackTrace_ = nullptr; diff --git a/src/api/utils/logger/logger.h b/src/api/utils/logger/logger.h index efd258d60e..aa3cb04fed 100644 --- a/src/api/utils/logger/logger.h +++ b/src/api/utils/logger/logger.h @@ -29,10 +29,13 @@ #if defined(HOST_TIZEN) #define LWNODE_DEV_LOG(...) dlog_print(DLOG_INFO, "LWNODE", __VA_ARGS__); +#define LWNODE_DEV_FATAL_LOG(...) dlog_print(DLOG_FATAL, "LWNODE", __VA_ARGS__); #elif defined(DEV) #define LWNODE_DEV_LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__); +#define LWNODE_DEV_FATAL_LOG(fmt, ...) printf(fmt "\n", ##__VA_ARGS__); #else #define LWNODE_DEV_LOG(fmt, ...) +#define LWNODE_DEV_FATAL_LOG(fmt, ...) #endif #define LWNODE_DEV_LOGF(fmt, ...) \ diff --git a/src/lwnode/lwnode.cc b/src/lwnode/lwnode.cc index 8d47dc4bb7..70ef90eed2 100644 --- a/src/lwnode/lwnode.cc +++ b/src/lwnode/lwnode.cc @@ -330,13 +330,13 @@ void InitializeProcessMethods(Local target, Local context) { } void IdleGC(v8::Isolate* isolate) { - LWNODE_DEV_LOG("[GC] running idle GC..."); + LWNODE_DEV_FATAL_LOG("[GC] running idle GC..."); if (isolate) { IsolateWrap::fromV8(isolate)->vmInstance()->enterIdleMode(); } Escargot::Memory::gc(); malloc_trim(0); - LWNODE_DEV_LOG("[GC] heap %zu", Escargot::Memory::heapSize()); + LWNODE_DEV_FATAL_LOG("[GC] heap %zu", Escargot::Memory::heapSize()); } void initDebugger() { diff --git a/src/lwnode/nd-vm-main-message-port.cc b/src/lwnode/nd-vm-main-message-port.cc index 67e90e64c4..1893d4c3d7 100644 --- a/src/lwnode/nd-vm-main-message-port.cc +++ b/src/lwnode/nd-vm-main-message-port.cc @@ -36,7 +36,7 @@ MainMessagePort::MainMessagePort(std::shared_ptr port, } MainMessagePort::~MainMessagePort() { - LWNODE_DEV_LOG("[MainMessagePort::~MainMessagePort]"); + LWNODE_DEV_FATAL_LOG("[MainMessagePort::~MainMessagePort]"); Channel::DeletePendingMessages(); } @@ -49,7 +49,7 @@ Escargot::FunctionObjectRef* MainMessagePort::MessageEventClass() { } void MainMessagePort::Init(ContextRef* context, uv_loop_t* loop) { - LWNODE_DEV_LOG("[MainMessagePort::Init] start"); + LWNODE_DEV_FATAL_LOG("[MainMessagePort::Init] start"); context_ = context; uv_loop_ = loop; @@ -57,9 +57,9 @@ void MainMessagePort::Init(ContextRef* context, uv_loop_t* loop) { try { internal_->uv_promise_.set_value(uv_loop_); } catch (const std::exception& e) { - LWNODE_DEV_LOG("[MainMessagePort::Init] promise error: %s", e.what()); + LWNODE_DEV_FATAL_LOG("[MainMessagePort::Init] promise error: %s", e.what()); } Channel::DrainPendingMessages(uv_loop_); - LWNODE_DEV_LOG("[MainMessagePort::Init] end"); + LWNODE_DEV_FATAL_LOG("[MainMessagePort::Init] end"); }