Skip to content

Commit ec13a63

Browse files
authored
refactor: remove the component adapter implementation (#864)
1 parent 06c754d commit ec13a63

34 files changed

+3173
-17907
lines changed

.github/workflows/main.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ jobs:
140140
if-no-files-found: error
141141
path: |
142142
js-compute-runtime.wasm
143-
js-compute-runtime-component.wasm
144143
145144
ensure_cargo_installs:
146145
name: Ensure that all required "cargo install" commands are run, or we have a cache hit

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ tests/wpt-harness/wpt-test-runner.js
2121
wpt-runtime.wasm
2222
docs-app/bin/main.wasm
2323
docs-app/pkg/*.tar.gz
24-
runtime/js-compute-runtime/fastly-world/fastly_world_component_type.o
2524

2625
*.a
2726
yarn-error.log

runtime/fastly/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.27)
22

33
include("../StarlingMonkey/cmake/add_as_subproject.cmake")
44

5-
add_builtin(fastly::runtime SRC handler.cpp common/ip_octets_to_js_string.cpp host-api/component/fastly_world_adapter.cpp)
5+
add_builtin(fastly::runtime SRC handler.cpp common/ip_octets_to_js_string.cpp)
66
add_builtin(fastly::cache_simple SRC builtins/cache-simple.cpp DEPENDENCIES OpenSSL)
77
add_builtin(fastly::fastly SRC builtins/fastly.cpp)
88
add_builtin(fastly::backend SRC builtins/backend.cpp)

runtime/fastly/builtins/backend.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -815,8 +815,9 @@ JS::Result<mozilla::Ok> Backend::register_dynamic_backend(JSContext *cx, JS::Han
815815

816816
auto client_cert_key_slot = JS::GetReservedSlot(backend, Backend::Slots::ClientCertKey);
817817

818-
backend_config.client_cert = host_api::ClientCert{
819-
.cert = std::move(client_cert_chars), .key = (FastlyHandle)client_cert_key_slot.toInt32()};
818+
backend_config.client_cert =
819+
host_api::ClientCert{.cert = std::move(client_cert_chars),
820+
.key = (host_api::CertKey)client_cert_key_slot.toInt32()};
820821
}
821822

822823
auto res = host_api::HttpReq::register_dynamic_backend(name_str, target_str, backend_config);

runtime/fastly/builtins/fetch-event.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,9 @@ void dispatch_fetch_event(HandleObject event, double *total_compute) {
454454
dispatch_fetch_event(event);
455455
double diff = duration_cast<microseconds>(system_clock::now() - pre_handler).count();
456456
*total_compute += diff;
457-
printf("Request handler took %fms\n", diff / 1000);
457+
if (ENGINE->debug_logging_enabled()) {
458+
printf("Request handler took %fms\n", diff / 1000);
459+
}
458460
}
459461

460462
JSObject *FetchEvent::prepare_downstream_request(JSContext *cx) {

runtime/fastly/builtins/fetch/fetch.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ class FetchTask final : public api::AsyncTask {
2222
Heap<JSObject *> promise_;
2323

2424
public:
25-
explicit FetchTask(FastlyHandle handle, JS::HandleObject request, JS::HandleObject promise)
25+
explicit FetchTask(host_api::HttpPendingReq::Handle handle, JS::HandleObject request,
26+
JS::HandleObject promise)
2627
: request_(request), promise_(promise) {
2728
if (static_cast<int32_t>(handle) < 0)
2829
abort();

runtime/fastly/builtins/fetch/request-response.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ bool error_stream_controller_with_pending_exception(JSContext *cx, JS::HandleObj
7575

7676
constexpr size_t HANDLE_READ_CHUNK_SIZE = 8192;
7777

78-
bool process_body_read(JSContext *cx, FastlyHandle handle, JS::HandleObject context,
78+
bool process_body_read(JSContext *cx, host_api::HttpBody::Handle handle, JS::HandleObject context,
7979
JS::HandleObject promise) {
8080
MOZ_ASSERT(context);
8181
JS::RootedObject streamSource(cx, context);
@@ -196,7 +196,8 @@ ReadResult read_from_handle_all(JSContext *cx, host_api::HttpBody body) {
196196

197197
} // namespace
198198

199-
bool RequestOrResponse::process_pending_request(JSContext *cx, FastlyHandle handle,
199+
bool RequestOrResponse::process_pending_request(JSContext *cx,
200+
host_api::HttpPendingReq::Handle handle,
200201
JS::HandleObject context,
201202
JS::HandleObject promise) {
202203
MOZ_ASSERT(Request::is_instance(context));
@@ -409,8 +410,9 @@ bool RequestOrResponse::extract_body(JSContext *cx, JS::HandleObject self,
409410
length = str.len;
410411
}
411412

412-
if (!text)
413+
if (!text) {
413414
return false;
415+
}
414416
buf = text.get();
415417
content_type = "text/plain;charset=UTF-8";
416418
}
@@ -3072,8 +3074,9 @@ bool Response::constructor(JSContext *cx, unsigned argc, JS::Value *vp) {
30723074
JS::RootedObject headers(cx);
30733075
JS::RootedObject headersInstance(
30743076
cx, JS_NewObjectWithGivenProto(cx, &Headers::class_, Headers::proto_obj));
3075-
if (!headersInstance)
3077+
if (!headersInstance) {
30763078
return false;
3079+
}
30773080

30783081
headers = Headers::create(cx, headersInstance, Headers::Mode::ProxyToResponse, response,
30793082
headers_val, false);

runtime/fastly/builtins/fetch/request-response.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ class RequestOrResponse final {
3535
static void set_manual_framing_headers(JSContext *cx, JSObject *obj, JS::HandleValue url);
3636
static bool body_unusable(JSContext *cx, JS::HandleObject body);
3737
static bool extract_body(JSContext *cx, JS::HandleObject self, JS::HandleValue body_val);
38-
static bool process_pending_request(JSContext *cx, FastlyHandle handle, JS::HandleObject context,
39-
JS::HandleObject promise);
38+
static bool process_pending_request(JSContext *cx, host_api::HttpPendingReq::Handle handle,
39+
JS::HandleObject context, JS::HandleObject promise);
4040

4141
/**
4242
* Returns the RequestOrResponse's Headers if it has been reified, nullptr if

runtime/fastly/builtins/kv-store.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ bool parse_and_validate_key(JSContext *cx, const char *key, size_t len) {
185185

186186
} // namespace
187187

188-
bool KVStore::process_pending_kv_store_delete(JSContext *cx, FastlyHandle handle,
188+
bool KVStore::process_pending_kv_store_delete(JSContext *cx,
189+
host_api::ObjectStorePendingDelete::Handle handle,
189190
JS::HandleObject context, JS::HandleObject promise) {
190191
host_api::ObjectStorePendingDelete pending_delete(handle);
191192

@@ -239,7 +240,8 @@ bool KVStore::delete_(JSContext *cx, unsigned argc, JS::Value *vp) {
239240
return true;
240241
}
241242

242-
bool KVStore::process_pending_kv_store_lookup(JSContext *cx, FastlyHandle handle,
243+
bool KVStore::process_pending_kv_store_lookup(JSContext *cx,
244+
host_api::ObjectStorePendingLookup::Handle handle,
243245
JS::HandleObject context, JS::HandleObject promise) {
244246
host_api::ObjectStorePendingLookup pending_lookup(handle);
245247

runtime/fastly/builtins/kv-store.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,11 @@ class KVStore final : public builtins::BuiltinImpl<KVStore> {
4848
static const unsigned ctor_length = 1;
4949

5050
static bool constructor(JSContext *cx, unsigned argc, JS::Value *vp);
51-
static bool process_pending_kv_store_lookup(JSContext *cx, FastlyHandle handle,
51+
static bool process_pending_kv_store_lookup(JSContext *cx,
52+
host_api::ObjectStorePendingLookup::Handle handle,
5253
JS::HandleObject context, JS::HandleObject promise);
53-
static bool process_pending_kv_store_delete(JSContext *cx, FastlyHandle handle,
54+
static bool process_pending_kv_store_delete(JSContext *cx,
55+
host_api::ObjectStorePendingDelete::Handle handle,
5456
JS::HandleObject context, JS::HandleObject promise);
5557
};
5658

0 commit comments

Comments
 (0)