Skip to content

Commit 2fe3425

Browse files
committed
[Wasm] Rename WasmPlatform to WasmEngine.
1 parent 17d77f5 commit 2fe3425

File tree

12 files changed

+83
-83
lines changed

12 files changed

+83
-83
lines changed

include/mutable/backend/WebAssembly.hpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010

1111
namespace m {
1212

13-
/** A `WasmPlatform` provides an environment to compile and execute WebAssembly modules. */
14-
struct WasmPlatform
13+
/** A `WasmEngine` provides an environment to compile and execute WebAssembly modules. */
14+
struct WasmEngine
1515
{
1616
/** the size of a WebAssembly memory page, 64 KiB. */
1717
static constexpr std::size_t WASM_PAGE_SIZE = 1UL << 16;
@@ -88,29 +88,29 @@ struct WasmPlatform
8888
/** Tests if the `WasmContext` with ID `id` exists. */
8989
static bool Has_Wasm_Context(unsigned id) { return contexts_.find(id) != contexts_.end(); }
9090

91-
WasmPlatform() = default;
92-
virtual ~WasmPlatform() { }
93-
WasmPlatform(const WasmPlatform&) = delete;
94-
WasmPlatform(WasmPlatform&&) = default;
91+
WasmEngine() = default;
92+
virtual ~WasmEngine() { }
93+
WasmEngine(const WasmEngine&) = delete;
94+
WasmEngine(WasmEngine&&) = default;
9595

96-
/** Compiles the given `plan` for this `WasmPlatform`. */
96+
/** Compiles the given `plan` for this `WasmEngine`. */
9797
virtual void compile(const Operator &plan) const = 0;
9898

99-
/** Executes the given `plan` on this `WasmPlatform`. */
99+
/** Executes the given `plan` on this `WasmEngine`. */
100100
virtual void execute(const Operator &plan) = 0;
101101
};
102102

103-
/** A `Backend` to execute a plan on a specific `WasmPlatform`. */
103+
/** A `Backend` to execute a plan on a specific `WasmEngine`. */
104104
struct WasmBackend : Backend
105105
{
106106
private:
107-
std::unique_ptr<WasmPlatform> platform_; ///< the `WasmPlatform` of this backend
107+
std::unique_ptr<WasmEngine> engine_; ///< the `WasmEngine` of this backend
108108

109109
public:
110-
WasmBackend(std::unique_ptr<WasmPlatform> platform) : platform_(std::move(platform)) { }
110+
WasmBackend(std::unique_ptr<WasmEngine> engine) : engine_(std::move(engine)) { }
111111

112-
/** Returns this backend's `WasmPlatform`. */
113-
const WasmPlatform & platform() const { return *platform_; }
112+
/** Returns this backend's `WasmEngine`. */
113+
const WasmEngine & engine() const { return *engine_; }
114114

115115
/** Executes the given `plan` with this backend. */
116116
void execute(const Operator &plan) const override;

include/mutable/catalog/Catalog.hpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,18 @@ struct ConcreteCardinalityEstimatorFactory : CardinalityEstimatorFactory
5555
}
5656
};
5757

58-
struct WasmPlatformFactory
58+
struct WasmEngineFactory
5959
{
60-
virtual ~WasmPlatformFactory() { }
60+
virtual ~WasmEngineFactory() { }
6161

62-
virtual std::unique_ptr<m::WasmPlatform> make() const = 0;
62+
virtual std::unique_ptr<m::WasmEngine> make() const = 0;
6363
};
6464

6565
template<typename T>
66-
requires std::derived_from<T, m::WasmPlatform>
67-
struct ConcreteWasmPlatformFactory : WasmPlatformFactory
66+
requires std::derived_from<T, m::WasmEngine>
67+
struct ConcreteWasmEngineFactory : WasmEngineFactory
6868
{
69-
std::unique_ptr<m::WasmPlatform> make() const override { return std::make_unique<T>(); }
69+
std::unique_ptr<m::WasmEngine> make() const override { return std::make_unique<T>(); }
7070
};
7171

7272
struct BackendFactory
@@ -86,10 +86,10 @@ struct ConcreteBackendFactory : BackendFactory
8686
struct ConcreteWasmBackendFactory : BackendFactory
8787
{
8888
private:
89-
std::unique_ptr<WasmPlatformFactory> platform_factory_;
89+
std::unique_ptr<WasmEngineFactory> platform_factory_;
9090

9191
public:
92-
ConcreteWasmBackendFactory(std::unique_ptr<WasmPlatformFactory> platform_factory)
92+
ConcreteWasmBackendFactory(std::unique_ptr<WasmEngineFactory> platform_factory)
9393
: platform_factory_(std::move(platform_factory))
9494
{ }
9595

@@ -440,13 +440,13 @@ struct M_EXPORT Catalog
440440
auto c = Component<BackendFactory>(description, std::make_unique<ConcreteBackendFactory<T>>());
441441
backends_.add(pool(name), std::move(c));
442442
}
443-
/** Registers a new `WasmBackend` using the given `WasmPlatform` with the given `name`. */
443+
/** Registers a new `WasmBackend` using the given `WasmEngine` with the given `name`. */
444444
template<typename T>
445-
requires std::derived_from<T, m::WasmPlatform>
445+
requires std::derived_from<T, m::WasmEngine>
446446
void register_wasm_backend(const char *name, const char *description = nullptr) {
447447
auto c = Component<BackendFactory>(
448448
description,
449-
std::make_unique<ConcreteWasmBackendFactory>(std::make_unique<ConcreteWasmPlatformFactory<T>>())
449+
std::make_unique<ConcreteWasmBackendFactory>(std::make_unique<ConcreteWasmEngineFactory<T>>())
450450
);
451451
backends_.add(pool(name), std::move(c));
452452
}

src/backend/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ set(
77
if(${WITH_V8})
88
list(APPEND BACKEND_SOURCES
99
PhysicalOperator.cpp
10-
V8Platform.cpp
10+
V8Engine.cpp
1111
WasmDSL.cpp
1212
WasmAlgo.cpp
1313
WasmOperator.cpp
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "backend/SpiderMonkeyPlatform.hpp"
1+
#include "backend/SpiderMonkeyEngine.hpp"
22

33
#include "js/ArrayBuffer.h"
44
#include "js/Initialization.h"
@@ -7,9 +7,9 @@
77
using namespace m;
88

99

10-
bool SpiderMonkeyPlatform::is_init_ = false;
10+
bool SpiderMonkeyEngine::is_init_ = false;
1111

12-
SpiderMonkeyPlatform::SpiderMonkeyPlatform()
12+
SpiderMonkeyEngine::SpiderMonkeyEngine()
1313
{
1414
if (not is_init_) {
1515
if (not JS_Init())
@@ -21,21 +21,21 @@ SpiderMonkeyPlatform::SpiderMonkeyPlatform()
2121
}
2222
}
2323

24-
SpiderMonkeyPlatform::~SpiderMonkeyPlatform()
24+
SpiderMonkeyEngine::~SpiderMonkeyEngine()
2525
{
2626
if (ctx_)
2727
JS_DestroyContext(ctx_);
2828
if (is_init_)
2929
JS_ShutDown();
3030
}
3131

32-
void SpiderMonkeyPlatform::execute(const WASMModule &module)
32+
void SpiderMonkeyEngine::execute(const WASMModule &module)
3333
{
34-
std::cerr << "Executing the WASM module on the SpiderMonkey platform.\n";
34+
std::cerr << "Executing the WASM module on the SpiderMonkey engine.\n";
3535
// TODO
3636
}
3737

3838
std::unique_ptr<Backend> Backend::CreateWasmSpiderMonkey()
3939
{
40-
return std::make_unique<WasmBackend>(std::make_unique<SpiderMonkeyPlatform>());
40+
return std::make_unique<WasmBackend>(std::make_unique<SpiderMonkeyEngine>());
4141
}

src/backend/SpiderMonkeyPlatform.hpp renamed to src/backend/SpiderMonkeyEngine.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
namespace m {
88

9-
struct SpiderMonkeyPlatform : WasmPlatform
9+
struct SpiderMonkeyEngine : WasmEngine
1010
{
1111
private:
1212
static bool is_init_;
1313
JSContext *ctx_ = nullptr;
1414

1515
public:
16-
SpiderMonkeyPlatform();
17-
~SpiderMonkeyPlatform();
16+
SpiderMonkeyEngine();
17+
~SpiderMonkeyEngine();
1818

1919
void execute(const WASMModule &module) override;
2020
};

src/backend/V8Platform.cpp renamed to src/backend/V8Engine.cpp

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "backend/V8Platform.hpp"
1+
#include "backend/V8Engine.hpp"
22

33
#include "backend/Interpreter.hpp"
44
#include "backend/PhysicalOperator.hpp"
@@ -55,15 +55,15 @@ uint16_t cdt_port = 0;
5555

5656

5757
/*======================================================================================================================
58-
* V8Platform
58+
* V8Engine
5959
*====================================================================================================================*/
6060

61-
/** The `V8Platform` is a `WasmPlatform` using [V8, Google's open source high-performance JavaScript and WebAssembly
61+
/** The `V8Engine` is a `WasmEngine` using [V8, Google's open source high-performance JavaScript and WebAssembly
6262
* engine] (https://v8.dev/). */
63-
struct V8Platform : m::WasmPlatform
63+
struct V8Engine : m::WasmEngine
6464
{
65-
friend void create_V8Platform();
66-
friend void destroy_V8Platform();
65+
friend void create_V8Engine();
66+
friend void destroy_V8Engine();
6767
friend void register_WasmV8();
6868

6969
private:
@@ -76,11 +76,11 @@ struct V8Platform : m::WasmPlatform
7676
std::unique_ptr<V8InspectorClientImpl> inspector_;
7777

7878
public:
79-
V8Platform();
80-
V8Platform(const V8Platform&) = delete;
81-
V8Platform(V8Platform&&) = default;
79+
V8Engine();
80+
V8Engine(const V8Engine&) = delete;
81+
V8Engine(V8Engine&&) = default;
8282

83-
~V8Platform();
83+
~V8Engine();
8484

8585
static v8::Platform * platform() {
8686
M_insist(bool(PLATFORM_));
@@ -214,7 +214,7 @@ void V8InspectorClientImpl::runMessageLoopOnPause(int)
214214
is_terminated_ = false;
215215
is_nested = true;
216216
while (not is_terminated_ and conn_->wait_on_message())
217-
while (v8::platform::PumpMessageLoop(V8Platform::platform(), isolate_)) { }
217+
while (v8::platform::PumpMessageLoop(V8Engine::platform(), isolate_)) { }
218218
is_terminated_ = true;
219219
is_nested = false;
220220
}
@@ -279,7 +279,7 @@ void m::wasm::detail::set_wasm_instance_raw_memory(const v8::FunctionCallbackInf
279279
v8::Local<v8::WasmModuleObject> wasm_instance = info[0].As<v8::WasmModuleObject>();
280280
v8::Local<v8::Int32> wasm_context_id = info[1].As<v8::Int32>();
281281

282-
auto &wasm_context = WasmPlatform::Get_Wasm_Context_By_ID(wasm_context_id->Value());
282+
auto &wasm_context = WasmEngine::Get_Wasm_Context_By_ID(wasm_context_id->Value());
283283
#ifndef NDEBUG
284284
std::cerr << "Setting Wasm instance raw memory of the given instance to the VM of Wasm context "
285285
<< wasm_context_id->Value() << " at " << wasm_context.vm.addr() << " of " << wasm_context.vm.size()
@@ -290,7 +290,7 @@ void m::wasm::detail::set_wasm_instance_raw_memory(const v8::FunctionCallbackInf
290290

291291
void m::wasm::detail::read_result_set(const v8::FunctionCallbackInfo<v8::Value> &info)
292292
{
293-
auto &context = WasmPlatform::Get_Wasm_Context_By_ID(Module::ID());
293+
auto &context = WasmEngine::Get_Wasm_Context_By_ID(Module::ID());
294294

295295
auto &schema = context.plan.schema();
296296
auto deduplicated_schema = schema.deduplicate();
@@ -509,7 +509,7 @@ void m::wasm::detail::read_result_set(const v8::FunctionCallbackInfo<v8::Value>
509509

510510

511511
/*======================================================================================================================
512-
* V8Platform helper classes
512+
* V8Engine helper classes
513513
*====================================================================================================================*/
514514

515515
namespace {
@@ -609,10 +609,10 @@ struct CollectStringLiterals : ConstOperatorVisitor, ast::ConstASTExprVisitor
609609

610610

611611
/*======================================================================================================================
612-
* V8Platform implementation
612+
* V8Engine implementation
613613
*====================================================================================================================*/
614614

615-
V8Platform::V8Platform()
615+
V8Engine::V8Engine()
616616
{
617617
#define REGISTER(CLASS) phys_opt_.register_operator<m::wasm::CLASS>();
618618
M_WASM_OPERATOR_LIST(REGISTER)
@@ -621,7 +621,7 @@ V8Platform::V8Platform()
621621
initialize();
622622
}
623623

624-
V8Platform::~V8Platform()
624+
V8Engine::~V8Engine()
625625
{
626626
inspector_.reset();
627627
if (isolate_) {
@@ -631,7 +631,7 @@ V8Platform::~V8Platform()
631631
}
632632
}
633633

634-
void V8Platform::initialize()
634+
void V8Engine::initialize()
635635
{
636636
M_insist(not allocator_);
637637
M_insist(not isolate_);
@@ -669,7 +669,7 @@ void V8Platform::initialize()
669669
isolate_ = v8::Isolate::New(create_params);
670670
}
671671

672-
void V8Platform::compile(const Operator &plan) const
672+
void V8Engine::compile(const Operator &plan) const
673673
{
674674
#if 1
675675
/*----- Add print function. --------------------------------------------------------------------------------------*/
@@ -727,7 +727,7 @@ void V8Platform::compile(const Operator &plan) const
727727
#endif
728728
}
729729

730-
void V8Platform::execute(const Operator &plan)
730+
void V8Engine::execute(const Operator &plan)
731731
{
732732
Module::Init();
733733
CodeGenContext::Init(); // fresh context
@@ -819,16 +819,16 @@ void V8Platform::execute(const Operator &plan)
819819
}
820820

821821
__attribute__((constructor(101)))
822-
static void create_V8Platform()
822+
static void create_V8Engine()
823823
{
824-
V8Platform::PLATFORM_ = v8::platform::NewDefaultPlatform().release();
825-
v8::V8::InitializePlatform(V8Platform::PLATFORM_);
824+
V8Engine::PLATFORM_ = v8::platform::NewDefaultPlatform().release();
825+
v8::V8::InitializePlatform(V8Engine::PLATFORM_);
826826
v8::V8::SetFlagsFromString("--no-freeze-flags-after-init"); // allow changing flags after initialization
827827
v8::V8::Initialize();
828828
}
829829

830830
__attribute__((destructor(101)))
831-
static void destroy_V8Platform()
831+
static void destroy_V8Engine()
832832
{
833833
v8::V8::Dispose();
834834
v8::V8::DisposePlatform();
@@ -838,7 +838,7 @@ __attribute__((constructor(202)))
838838
static void register_WasmV8()
839839
{
840840
Catalog &C = Catalog::Get();
841-
C.register_wasm_backend<V8Platform>("WasmV8", "WebAssembly backend using Google's V8 engine");
841+
C.register_wasm_backend<V8Engine>("WasmV8", "WebAssembly backend using Google's V8 engine");
842842

843843
/*----- Command-line arguments -----------------------------------------------------------------------------------*/
844844
C.arg_parser().add<int>(
@@ -908,7 +908,7 @@ v8::Local<v8::WasmModuleObject> m::wasm::detail::instantiate(v8::Isolate &isolat
908908

909909
v8::Local<v8::Object> m::wasm::detail::create_env(v8::Isolate &isolate, const Operator &plan)
910910
{
911-
auto &context = WasmPlatform::Get_Wasm_Context_By_ID(Module::ID());
911+
auto &context = WasmEngine::Get_Wasm_Context_By_ID(Module::ID());
912912
auto Ctx = isolate.GetCurrentContext();
913913
auto env = v8::Object::New(&isolate);
914914

@@ -977,7 +977,7 @@ v8::Local<v8::String> m::wasm::detail::to_json(v8::Isolate &isolate, v8::Local<v
977977
}
978978

979979
std::string m::wasm::detail::create_js_debug_script(v8::Isolate &isolate, v8::Local<v8::Object> env,
980-
const WasmPlatform::WasmContext &wasm_context)
980+
const WasmEngine::WasmContext &wasm_context)
981981
{
982982
std::ostringstream oss;
983983

@@ -1038,7 +1038,7 @@ debugger;";
10381038
void m::wasm::detail::run_inspector(V8InspectorClientImpl &inspector, v8::Isolate &isolate, v8::Local<v8::Object> env)
10391039
{
10401040
auto Ctx = isolate.GetCurrentContext();
1041-
auto &wasm_context = WasmPlatform::Get_Wasm_Context_By_ID(Module::ID());
1041+
auto &wasm_context = WasmEngine::Get_Wasm_Context_By_ID(Module::ID());
10421042

10431043
inspector.register_context(Ctx);
10441044
inspector.start([&]() {

src/backend/V8Platform.hpp renamed to src/backend/V8Engine.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ v8::Local<v8::WasmModuleObject> instantiate(v8::Isolate &isolate, v8::Local<v8::
8888
v8::Local<v8::Object> create_env(v8::Isolate &isolate, const Operator &plan);
8989
v8::Local<v8::String> to_json(v8::Isolate &isolate, v8::Local<v8::Value> val);
9090
std::string create_js_debug_script(v8::Isolate &isolate, v8::Local<v8::Object> env,
91-
const WasmPlatform::WasmContext &wasm_context);
91+
const WasmEngine::WasmContext &wasm_context);
9292
void run_inspector(V8InspectorClientImpl &inspector, v8::Isolate &isolate, v8::Local<v8::Object> env);
9393

9494
}

0 commit comments

Comments
 (0)