Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emsdk upstream #690

Merged
merged 4 commits into from
Aug 26, 2019
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
3 changes: 1 addition & 2 deletions cpp/perspective/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,6 @@ if (PSP_WASM_BUILD)
--bind \
--source-map-base ./build/ \
--memory-init-file 0 \
-fno-rtti \
-DEMSCRIPTEN_HAS_UNBOUND_TYPE_NAMES=0 \
-s NO_EXIT_RUNTIME=1 \
-s NO_FILESYSTEM=1 \
-s ALLOW_MEMORY_GROWTH=1 \
Expand All @@ -186,6 +184,7 @@ if (PSP_WASM_BUILD)
set(OPT_FLAGS " \
-O3 \
-g0 \
-s WASM_OBJECT_FILES=0 \
--llvm-lto 3 \
--closure 1 \
-s AGGRESSIVE_VARIABLE_ELIMINATION=1 \
Expand Down
57 changes: 25 additions & 32 deletions cpp/perspective/src/cpp/emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,12 @@ namespace binding {
void
vecFromTypedArray(
const t_val& typedArray, void* data, std::int32_t length, const char* destType) {
t_val memory = t_val::module_property("buffer");
if (destType == nullptr) {
t_val memoryView = typedArray["constructor"].new_(
memory, reinterpret_cast<std::uintptr_t>(data), length);
memoryView.call<void>("set", typedArray.call<t_val>("slice", 0, length));
} else {
t_val memoryView = t_val::global(destType).new_(
memory, reinterpret_cast<std::uintptr_t>(data), length);
memoryView.call<void>("set", typedArray.call<t_val>("slice", 0, length));
}
t_val constructor = destType == nullptr ? typedArray["constructor"] : t_val::global(destType);
t_val memory = t_val::module_property("HEAP8")["buffer"];
std::uintptr_t ptr = reinterpret_cast<std::uintptr_t>(data);
t_val memoryView = constructor.new_(memory, ptr, length);
t_val slice = typedArray.call<t_val>("slice", 0, length);
memoryView.call<void>("set", slice);
}

template <>
Expand Down Expand Up @@ -1735,59 +1731,56 @@ EMSCRIPTEN_BINDINGS(perspective) {
*/
class_<t_data_table>("t_data_table")
.smart_ptr<std::shared_ptr<t_data_table>>("shared_ptr<t_data_table>")
.function<unsigned long>("size",
.function("size",
reinterpret_cast<unsigned long (t_data_table::*)() const>(&t_data_table::size));

/******************************************************************************
*
* t_schema
*/
class_<t_schema>("t_schema")
.function<const std::vector<std::string>&>(
.function(
"columns", &t_schema::columns, allow_raw_pointers())
.function<const std::vector<t_dtype>>("types", &t_schema::types, allow_raw_pointers());
.function("types", &t_schema::types, allow_raw_pointers());

/******************************************************************************
*
* t_gnode
*/
class_<t_gnode>("t_gnode")
.smart_ptr<std::shared_ptr<t_gnode>>("shared_ptr<t_gnode>")
.function<t_uindex>(
"get_id", reinterpret_cast<t_uindex (t_gnode::*)() const>(&t_gnode::get_id))
.function<t_schema>("get_tblschema", &t_gnode::get_tblschema)
.function<void>("reset", &t_gnode::reset)
.function<t_data_table*>("get_table", &t_gnode::get_table, allow_raw_pointers());
.function(
"get_id", reinterpret_cast<t_uindex (t_gnode::*)() const>(&t_gnode::get_id));

/******************************************************************************
*
* t_data_slice
*/
class_<t_data_slice<t_ctx0>>("t_data_slice_ctx0")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx0>>>("shared_ptr<t_data_slice<t_ctx0>>>")
.function<std::vector<t_tscalar>>(
.function(
"get_column_slice", &t_data_slice<t_ctx0>::get_column_slice)
.function<const std::vector<t_tscalar>&>("get_slice", &t_data_slice<t_ctx0>::get_slice)
.function<const std::vector<std::vector<t_tscalar>>&>(
.function("get_slice", &t_data_slice<t_ctx0>::get_slice)
.function(
"get_column_names", &t_data_slice<t_ctx0>::get_column_names);

class_<t_data_slice<t_ctx1>>("t_data_slice_ctx1")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx1>>>("shared_ptr<t_data_slice<t_ctx1>>>")
.function<std::vector<t_tscalar>>(
.function(
"get_column_slice", &t_data_slice<t_ctx1>::get_column_slice)
.function<const std::vector<t_tscalar>&>("get_slice", &t_data_slice<t_ctx1>::get_slice)
.function<const std::vector<std::vector<t_tscalar>>&>(
.function("get_slice", &t_data_slice<t_ctx1>::get_slice)
.function(
"get_column_names", &t_data_slice<t_ctx1>::get_column_names)
.function<std::vector<t_tscalar>>("get_row_path", &t_data_slice<t_ctx1>::get_row_path);
.function("get_row_path", &t_data_slice<t_ctx1>::get_row_path);

class_<t_data_slice<t_ctx2>>("t_data_slice_ctx2")
.smart_ptr<std::shared_ptr<t_data_slice<t_ctx2>>>("shared_ptr<t_data_slice<t_ctx2>>>")
.function<std::vector<t_tscalar>>(
.function(
"get_column_slice", &t_data_slice<t_ctx2>::get_column_slice)
.function<const std::vector<t_tscalar>&>("get_slice", &t_data_slice<t_ctx2>::get_slice)
.function<const std::vector<std::vector<t_tscalar>>&>(
.function("get_slice", &t_data_slice<t_ctx2>::get_slice)
.function(
"get_column_names", &t_data_slice<t_ctx2>::get_column_names)
.function<std::vector<t_tscalar>>("get_row_path", &t_data_slice<t_ctx2>::get_row_path);
.function("get_row_path", &t_data_slice<t_ctx2>::get_row_path);

/******************************************************************************
*
Expand All @@ -1814,9 +1807,9 @@ EMSCRIPTEN_BINDINGS(perspective) {
class_<t_pool>("t_pool")
.constructor<>()
.smart_ptr<std::shared_ptr<t_pool>>("shared_ptr<t_pool>")
.function<void>("unregister_gnode", &t_pool::unregister_gnode)
.function<void>("_process", &t_pool::_process)
.function<void>("set_update_delegate", &t_pool::set_update_delegate);
.function("unregister_gnode", &t_pool::unregister_gnode)
.function("_process", &t_pool::_process)
.function("set_update_delegate", &t_pool::set_update_delegate);

/******************************************************************************
*
Expand Down
7 changes: 7 additions & 0 deletions cpp/perspective/src/cpp/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@

#include <perspective/first.h>
#include <boost/uuid/uuid_io.hpp>
#ifndef PSP_ENABLE_WASM
// emscripten llvm-upstream fails to compile this module ..
#include <boost/uuid/uuid_generators.hpp>
#endif
#include <perspective/raw_types.h>
#include <string>
#include <sstream>
Expand All @@ -18,8 +21,12 @@ namespace perspective {

std::string
unique_path(const std::string& path_prefix) {
#ifdef PSP_ENABLE_WASM
return "";
#else
std::stringstream ss;
ss << path_prefix << boost::uuids::random_generator()();
return ss.str();
#endif
}
} // namespace perspective
Loading