Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions deps/node/src/env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context> ctx = context();

Expand All @@ -285,7 +285,7 @@ void Environment::CreateProperties() {
node::CreateProcessObject(this).FromMaybe(Local<Object>());
set_process_object(process_object);

LWNODE_DEV_LOG("[Environment::CreateProperties] end");
LWNODE_DEV_FATAL_LOG("[Environment::CreateProperties] end");
}

std::string GetExecPath(const std::vector<std::string>& argv) {
Expand Down
49 changes: 25 additions & 24 deletions deps/node/src/lwnode/lwnode-public.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, int> 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.
Expand All @@ -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_);
Expand All @@ -127,26 +127,26 @@ class Runtime::Internal {
std::unique_lock<std::mutex> 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();
}

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_);
}

Expand Down Expand Up @@ -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() {
Expand All @@ -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<void>&& 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;
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down
16 changes: 8 additions & 8 deletions deps/node/src/node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,12 @@ MaybeLocal<Value> ExecuteBootstrapper(Environment* env,
return MaybeLocal<Value>();
}

LWNODE_DEV_LOG("[ExecuteBootstrapper]: call %s", id);
LWNODE_DEV_FATAL_LOG("[ExecuteBootstrapper]: call %s", id);
MaybeLocal<Value> 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
Expand Down Expand Up @@ -288,7 +288,7 @@ void Environment::InitializeDiagnostics() {
}

MaybeLocal<Value> Environment::BootstrapInternalLoaders() {
LWNODE_DEV_LOG("[Environment::BootstrapInternalLoaders] start");
LWNODE_DEV_FATAL_LOG("[Environment::BootstrapInternalLoaders] start");

EscapableHandleScope scope(isolate_);

Expand Down Expand Up @@ -327,7 +327,7 @@ MaybeLocal<Value> Environment::BootstrapInternalLoaders() {
CHECK(require->IsFunction());
set_native_module_require(require.As<Function>());

LWNODE_DEV_LOG("[Environment::BootstrapInternalLoaders] end");
LWNODE_DEV_FATAL_LOG("[Environment::BootstrapInternalLoaders] end");
return scope.Escape(loader_exports);
}

Expand Down Expand Up @@ -390,7 +390,7 @@ MaybeLocal<Value> Environment::BootstrapNode() {
}

MaybeLocal<Value> Environment::RunBootstrapping() {
LWNODE_DEV_LOG("[Environment::RunBootstrapping] start");
LWNODE_DEV_FATAL_LOG("[Environment::RunBootstrapping] start");

EscapableHandleScope scope(isolate_);

Expand All @@ -414,7 +414,7 @@ MaybeLocal<Value> 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);
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions deps/node/src/node_main_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand All @@ -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() {
Expand Down
30 changes: 15 additions & 15 deletions deps/node/src/node_main_lw_runner-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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<Environment, FreeEnvironment> 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_);
Expand All @@ -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;
}
Expand All @@ -149,20 +149,20 @@ 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_);

env_->set_trace_sync_io(env_->options()->trace_sync_io);

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;
}
Expand All @@ -175,10 +175,10 @@ class LWNodeMainRunner {
// Run main loop
std::unique_ptr<MainLoopStrategy> 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<GmainLoopStrategy>();
} else {
LWNODE_DEV_LOG("[LWNodeMainRunner::Run] use standard loop");
LWNODE_DEV_FATAL_LOG("[LWNodeMainRunner::Run] use standard loop");
mainLoop = std::make_unique<LoopStrategy>();
}

Expand Down Expand Up @@ -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()) {
Expand All @@ -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());
});

Expand Down
4 changes: 2 additions & 2 deletions include/lwnode/lwnode-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion src/api/isolate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down
3 changes: 1 addition & 2 deletions src/api/stack-trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/api/utils/logger/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...) \
Expand Down
Loading