Skip to content

Commit

Permalink
core: update nodejs-mobile v0.1.3
Browse files Browse the repository at this point in the history
Update the libnode binaries to v0.1.3 release. Update the header
files and the bridle N-API calls to the new API.
  • Loading branch information
jaimecbernardo committed Oct 31, 2017
1 parent 70c9ac3 commit 7069d4b
Show file tree
Hide file tree
Showing 85 changed files with 11,220 additions and 11,596 deletions.
Binary file modified android/libnode/bin/armeabi-v7a/libnode.so
Binary file not shown.
Binary file modified android/libnode/bin/x86/libnode.so
Binary file not shown.
3 changes: 1 addition & 2 deletions android/libnode/include/node/config.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
'v8_promise_internal_field_count': 1,
'v8_random_seed': 0,
'v8_trace_maps': 0,
'v8_use_snapshot': 'false',
'v8_use_snapshot': 'true',
'want_separate_host_toolset': 0,
'want_separate_host_toolset_mkpeephole': 0,
'xcode_version': '7.0'}}
7 changes: 6 additions & 1 deletion android/libnode/include/node/libplatform/libplatform.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ enum class MessageLoopBehavior : bool {
* If |idle_task_support| is enabled then the platform will accept idle
* tasks (IdleTasksEnabled will return true) and will rely on the embedder
* calling v8::platform::RunIdleTasks to process the idle tasks.
* If |tracing_controller| is nullptr, the default platform will create a
* v8::platform::TracingController instance and use it.
*/
V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform(
int thread_pool_size = 0,
IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled,
InProcessStackDumping in_process_stack_dumping =
InProcessStackDumping::kEnabled);
InProcessStackDumping::kEnabled,
v8::TracingController* tracing_controller = nullptr);

/**
* Pumps the message loop for the given isolate.
Expand Down Expand Up @@ -67,6 +70,8 @@ V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform,
* Attempts to set the tracing controller for the given platform.
*
* The |platform| has to be created using |CreateDefaultPlatform|.
*
* DEPRECATED: Will be removed soon.
*/
V8_PLATFORM_EXPORT void SetTracingController(
v8::Platform* platform,
Expand Down
32 changes: 23 additions & 9 deletions android/libnode/include/node/libplatform/v8-tracing.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ class V8_PLATFORM_EXPORT TraceConfig {
void operator=(const TraceConfig&) = delete;
};

class V8_PLATFORM_EXPORT TracingController {
#if defined(_MSC_VER)
#define V8_PLATFORM_NON_EXPORTED_BASE(code) \
__pragma(warning(suppress : 4275)) code
#else
#define V8_PLATFORM_NON_EXPORTED_BASE(code) code
#endif // defined(_MSC_VER)

class V8_PLATFORM_EXPORT TracingController
: public V8_PLATFORM_NON_EXPORTED_BASE(v8::TracingController) {
public:
enum Mode { DISABLED = 0, RECORDING_MODE };

Expand All @@ -227,25 +235,29 @@ class V8_PLATFORM_EXPORT TracingController {
};

TracingController();
~TracingController();
~TracingController() override;
void Initialize(TraceBuffer* trace_buffer);
const uint8_t* GetCategoryGroupEnabled(const char* category_group);
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);

// v8::TracingController implementation.
const uint8_t* GetCategoryGroupEnabled(const char* category_group) override;
uint64_t AddTraceEvent(
char phase, const uint8_t* category_enabled_flag, const char* name,
const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args,
const char** arg_names, const uint8_t* arg_types,
const uint64_t* arg_values,
std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables,
unsigned int flags);
unsigned int flags) override;
void UpdateTraceEventDuration(const uint8_t* category_enabled_flag,
const char* name, uint64_t handle);
const char* name, uint64_t handle) override;
void AddTraceStateObserver(
v8::TracingController::TraceStateObserver* observer) override;
void RemoveTraceStateObserver(
v8::TracingController::TraceStateObserver* observer) override;

void StartTracing(TraceConfig* trace_config);
void StopTracing();

void AddTraceStateObserver(Platform::TraceStateObserver* observer);
void RemoveTraceStateObserver(Platform::TraceStateObserver* observer);
static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag);

private:
const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group);
Expand All @@ -255,14 +267,16 @@ class V8_PLATFORM_EXPORT TracingController {
std::unique_ptr<TraceBuffer> trace_buffer_;
std::unique_ptr<TraceConfig> trace_config_;
std::unique_ptr<base::Mutex> mutex_;
std::unordered_set<Platform::TraceStateObserver*> observers_;
std::unordered_set<v8::TracingController::TraceStateObserver*> observers_;
Mode mode_ = DISABLED;

// Disallow copy and assign
TracingController(const TracingController&) = delete;
void operator=(const TracingController&) = delete;
};

#undef V8_PLATFORM_NON_EXPORTED_BASE

} // namespace tracing
} // namespace platform
} // namespace v8
Expand Down
59 changes: 55 additions & 4 deletions android/libnode/include/node/node.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ NODE_EXTERN v8::Local<v8::Value> MakeCallback(

} // namespace node

#if defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
#include "node_internals.h"
#endif

#include <assert.h>
#include <stdint.h>

Expand Down Expand Up @@ -595,10 +591,45 @@ NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
const char* name,
async_id trigger_async_id = -1);

NODE_EXTERN async_context EmitAsyncInit(v8::Isolate* isolate,
v8::Local<v8::Object> resource,
v8::Local<v8::String> name,
async_id trigger_async_id = -1);

/* Emit the destroy() callback. */
NODE_EXTERN void EmitAsyncDestroy(v8::Isolate* isolate,
async_context asyncContext);

class InternalCallbackScope;

/* This class works like `MakeCallback()` in that it sets up a specific
* asyncContext as the current one and informs the async_hooks and domains
* modules that this context is currently active.
*
* `MakeCallback()` is a wrapper around this class as well as
* `Function::Call()`. Either one of these mechanisms needs to be used for
* top-level calls into JavaScript (i.e. without any existing JS stack).
*
* This object should be stack-allocated to ensure that it is contained in a
* valid HandleScope.
*/
class NODE_EXTERN CallbackScope {
public:
CallbackScope(v8::Isolate* isolate,
v8::Local<v8::Object> resource,
async_context asyncContext);
~CallbackScope();

private:
InternalCallbackScope* private_;
v8::TryCatch try_catch_;

void operator=(const CallbackScope&) = delete;
void operator=(CallbackScope&&) = delete;
CallbackScope(const CallbackScope&) = delete;
CallbackScope(CallbackScope&&) = delete;
};

/* An API specific to emit before/after callbacks is unnecessary because
* MakeCallback will automatically call them for you.
*
Expand Down Expand Up @@ -676,6 +707,16 @@ class AsyncResource {
trigger_async_id);
}

AsyncResource(v8::Isolate* isolate,
v8::Local<v8::Object> resource,
v8::Local<v8::String> name,
async_id trigger_async_id = -1)
: isolate_(isolate),
resource_(isolate, resource) {
async_context_ = EmitAsyncInit(isolate, resource, name,
trigger_async_id);
}

~AsyncResource() {
EmitAsyncDestroy(isolate_, async_context_);
}
Expand Down Expand Up @@ -724,6 +765,16 @@ class AsyncResource {
async_id get_trigger_async_id() const {
return async_context_.trigger_async_id;
}

protected:
class CallbackScope : public node::CallbackScope {
public:
explicit CallbackScope(AsyncResource* res)
: node::CallbackScope(res->isolate_,
res->resource_.Get(res->isolate_),
res->async_context_) {}
};

private:
v8::Isolate* isolate_;
v8::Persistent<v8::Object> resource_;
Expand Down
73 changes: 57 additions & 16 deletions android/libnode/include/node/node_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@
#endif


typedef void (*napi_addon_register_func)(napi_env env,
napi_value exports,
napi_value module,
void* priv);
typedef napi_value (*napi_addon_register_func)(napi_env env,
napi_value exports);

typedef struct {
int nm_version;
Expand Down Expand Up @@ -102,6 +100,8 @@ typedef struct {
#define NAPI_MODULE(modname, regfunc) \
NAPI_MODULE_X(modname, regfunc, NULL, 0)

#define NAPI_AUTO_LENGTH SIZE_MAX

EXTERN_C_START

NAPI_EXTERN void napi_module_register(napi_module* mod);
Expand All @@ -111,7 +111,9 @@ napi_get_last_error_info(napi_env env,
const napi_extended_error_info** result);

NAPI_EXTERN NAPI_NO_RETURN void napi_fatal_error(const char* location,
const char* message);
size_t location_len,
const char* message,
size_t message_len);

// Getters for defined singletons
NAPI_EXTERN napi_status napi_get_undefined(napi_env env, napi_value* result);
Expand Down Expand Up @@ -156,6 +158,7 @@ NAPI_EXTERN napi_status napi_create_symbol(napi_env env,
napi_value* result);
NAPI_EXTERN napi_status napi_create_function(napi_env env,
const char* utf8name,
size_t length,
napi_callback cb,
void* data,
napi_value* result);
Expand Down Expand Up @@ -320,14 +323,6 @@ NAPI_EXTERN napi_status napi_instanceof(napi_env env,
napi_value constructor,
bool* result);

// Napi version of node::MakeCallback(...)
NAPI_EXTERN napi_status napi_make_callback(napi_env env,
napi_value recv,
napi_value func,
size_t argc,
const napi_value* argv,
napi_value* result);

// Methods to work with napi_callbacks

// Gets all callback info in a single call. (Ugly, but faster.)
Expand All @@ -340,12 +335,13 @@ NAPI_EXTERN napi_status napi_get_cb_info(
napi_value* this_arg, // [out] Receives the JS 'this' arg for the call
void** data); // [out] Receives the data pointer for the callback.

NAPI_EXTERN napi_status napi_is_construct_call(napi_env env,
napi_callback_info cbinfo,
bool* result);
NAPI_EXTERN napi_status napi_get_new_target(napi_env env,
napi_callback_info cbinfo,
napi_value* result);
NAPI_EXTERN napi_status
napi_define_class(napi_env env,
const char* utf8name,
size_t length,
napi_callback constructor,
void* data,
size_t property_count,
Expand All @@ -362,6 +358,9 @@ NAPI_EXTERN napi_status napi_wrap(napi_env env,
NAPI_EXTERN napi_status napi_unwrap(napi_env env,
napi_value js_object,
void** result);
NAPI_EXTERN napi_status napi_remove_wrap(napi_env env,
napi_value js_object,
void** result);
NAPI_EXTERN napi_status napi_create_external(napi_env env,
void* data,
napi_finalize finalize_cb,
Expand Down Expand Up @@ -521,6 +520,8 @@ NAPI_EXTERN napi_status napi_get_dataview_info(napi_env env,
// Methods to manage simple async operations
NAPI_EXTERN
napi_status napi_create_async_work(napi_env env,
napi_value async_resource,
napi_value async_resource_name,
napi_async_execute_callback execute,
napi_async_complete_callback complete,
void* data,
Expand All @@ -532,6 +533,22 @@ NAPI_EXTERN napi_status napi_queue_async_work(napi_env env,
NAPI_EXTERN napi_status napi_cancel_async_work(napi_env env,
napi_async_work work);

// Methods for custom handling of async operations
NAPI_EXTERN napi_status napi_async_init(napi_env env,
napi_value async_resource,
napi_value async_resource_name,
napi_async_context* result);

NAPI_EXTERN napi_status napi_async_destroy(napi_env env,
napi_async_context async_context);

NAPI_EXTERN napi_status napi_make_callback(napi_env env,
napi_async_context async_context,
napi_value recv,
napi_value func,
size_t argc,
const napi_value* argv,
napi_value* result);

// version management
NAPI_EXTERN napi_status napi_get_version(napi_env env, uint32_t* result);
Expand All @@ -540,6 +557,30 @@ NAPI_EXTERN
napi_status napi_get_node_version(napi_env env,
const napi_node_version** version);

// Promises
NAPI_EXTERN napi_status napi_create_promise(napi_env env,
napi_deferred* deferred,
napi_value* promise);
NAPI_EXTERN napi_status napi_resolve_deferred(napi_env env,
napi_deferred deferred,
napi_value resolution);
NAPI_EXTERN napi_status napi_reject_deferred(napi_env env,
napi_deferred deferred,
napi_value rejection);
NAPI_EXTERN napi_status napi_is_promise(napi_env env,
napi_value promise,
bool* is_promise);

// Memory management
NAPI_EXTERN napi_status napi_adjust_external_memory(napi_env env,
int64_t change_in_bytes,
int64_t* adjusted_value);

// Runnig a script
NAPI_EXTERN napi_status napi_run_script(napi_env env,
napi_value script,
napi_value* result);

EXTERN_C_END

#endif // SRC_NODE_API_H_
2 changes: 2 additions & 0 deletions android/libnode/include/node/node_api_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ typedef struct napi_ref__ *napi_ref;
typedef struct napi_handle_scope__ *napi_handle_scope;
typedef struct napi_escapable_handle_scope__ *napi_escapable_handle_scope;
typedef struct napi_callback_info__ *napi_callback_info;
typedef struct napi_async_context__ *napi_async_context;
typedef struct napi_async_work__ *napi_async_work;
typedef struct napi_deferred__ *napi_deferred;

typedef enum {
napi_default = 0,
Expand Down
2 changes: 1 addition & 1 deletion android/libnode/include/node/node_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#define SRC_NODE_VERSION_H_

#define NODE_MAJOR_VERSION 8
#define NODE_MINOR_VERSION 4
#define NODE_MINOR_VERSION 6
#define NODE_PATCH_VERSION 0

#define NODE_VERSION_IS_RELEASE 1
Expand Down

0 comments on commit 7069d4b

Please sign in to comment.