aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-12 01:17:44 -0700
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2022-08-12 01:18:31 -0700
commitc9cd8bd13b799a161392e8aefb64eb2d0ff3a31e (patch)
tree292d752d4e4632d5d311f7a020d80d6940f00eb6 /src
parent5c1ca0cc479526967397247a874ea7792787f249 (diff)
downloadbun-c9cd8bd13b799a161392e8aefb64eb2d0ff3a31e.tar.gz
bun-c9cd8bd13b799a161392e8aefb64eb2d0ff3a31e.tar.zst
bun-c9cd8bd13b799a161392e8aefb64eb2d0ff3a31e.zip
Update WebKit
Diffstat (limited to 'src')
m---------src/bun.js/WebKit0
-rw-r--r--src/bun.js/bindings/ZigGlobalObject.cpp99
2 files changed, 91 insertions, 8 deletions
diff --git a/src/bun.js/WebKit b/src/bun.js/WebKit
-Subproject 7d9e2ffa4365e676a4aa96a9941154a68e54f0f
+Subproject d128052f960d06aad225db6499c3797e0b0363b
diff --git a/src/bun.js/bindings/ZigGlobalObject.cpp b/src/bun.js/bindings/ZigGlobalObject.cpp
index bdd750904..af3ecedbc 100644
--- a/src/bun.js/bindings/ZigGlobalObject.cpp
+++ b/src/bun.js/bindings/ZigGlobalObject.cpp
@@ -142,6 +142,13 @@ using JSBuffer = WebCore::JSBuffer;
#include "JSSink.h"
#include "ImportMetaObject.h"
+#include <JavaScriptCore/DOMJITAbstractHeap.h>
+#include "DOMJITIDLConvert.h"
+#include "DOMJITIDLType.h"
+#include "DOMJITIDLTypeFilter.h"
+#include "DOMJITHelpers.h"
+#include <JavaScriptCore/DFGAbstractHeap.h>
+
// #include <iostream>
static bool has_loaded_jsc = false;
@@ -376,8 +383,8 @@ void GlobalObject::promiseRejectionTracker(JSGlobalObject* obj, JSC::JSPromise*
globalObj->m_aboutToBeNotifiedRejectedPromises.append(JSC::Strong<JSPromise>(obj->vm(), promise));
break;
case JSPromiseRejectionOperation::Handle:
- globalObj->m_aboutToBeNotifiedRejectedPromises.removeFirstMatching([&] (Strong<JSPromise>& unhandledPromise) {
- return unhandledPromise.get() == promise;
+ globalObj->m_aboutToBeNotifiedRejectedPromises.removeFirstMatching([&](Strong<JSPromise>& unhandledPromise) {
+ return unhandledPromise.get() == promise;
});
break;
}
@@ -1501,9 +1508,7 @@ JSC_DEFINE_HOST_FUNCTION(functionConcatTypedArrays, (JSGlobalObject * globalObje
extern "C" uint64_t Bun__readOriginTimer(void*);
-JSC_DECLARE_HOST_FUNCTION(functionPerformanceNow);
-
-JSC_DEFINE_HOST_FUNCTION(functionPerformanceNow, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+static inline EncodedJSValue functionPerformanceNowBody(JSGlobalObject* globalObject)
{
auto* global = reinterpret_cast<GlobalObject*>(globalObject);
// nanoseconds to seconds
@@ -1512,12 +1517,81 @@ JSC_DEFINE_HOST_FUNCTION(functionPerformanceNow, (JSGlobalObject * globalObject,
return JSValue::encode(jsNumber(result));
}
+extern "C" {
+class JSPerformanceObject;
+static JSC_DECLARE_HOST_FUNCTION(functionPerformanceNow);
+static JSC_DECLARE_JIT_OPERATION_WITHOUT_WTF_INTERNAL(functionPerformanceNowWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject*, JSPerformanceObject*));
+}
+
+class JSPerformanceObject final : public JSC::JSNonFinalObject {
+public:
+ using Base = JSC::JSNonFinalObject;
+ static JSPerformanceObject* create(JSC::VM& vm, JSDOMGlobalObject* globalObject, JSC::Structure* structure)
+ {
+ JSPerformanceObject* ptr = new (NotNull, JSC::allocateCell<JSPerformanceObject>(vm)) JSPerformanceObject(vm, globalObject, structure);
+ ptr->finishCreation(vm);
+ return ptr;
+ }
+
+ DECLARE_INFO;
+ template<typename CellType, JSC::SubspaceAccess>
+ static JSC::GCClient::IsoSubspace* subspaceFor(JSC::VM& vm)
+ {
+ STATIC_ASSERT_ISO_SUBSPACE_SHARABLE(JSPerformanceObject, Base);
+ return &vm.plainObjectSpace();
+ }
+ static JSC::Structure* createStructure(JSC::VM& vm, JSC::JSGlobalObject* globalObject, JSC::JSValue prototype)
+ {
+ return JSC::Structure::create(vm, globalObject, prototype, JSC::TypeInfo(JSC::ObjectType, StructureFlags), info());
+ }
+
+private:
+ JSPerformanceObject(JSC::VM& vm, JSC::JSGlobalObject*, JSC::Structure* structure)
+ : JSC::JSNonFinalObject(vm, structure)
+ {
+ }
+
+ void finishCreation(JSC::VM& vm)
+ {
+ static const JSC::DOMJIT::Signature DOMJITSignatureForPerformanceNow(
+ functionPerformanceNowWithoutTypeCheck,
+ JSPerformanceObject::info(),
+ JSC::DOMJIT::Effect::forReadWrite(JSC::DOMJIT::HeapRange::top(), JSC::DOMJIT::HeapRange::top()),
+ WebCore::DOMJIT::IDLResultTypeFilter<IDLUnsignedLong>::value);
+
+ JSFunction* function = JSFunction::create(
+ vm,
+ globalObject(),
+ 0,
+ String("now"_s),
+ functionPerformanceNow, NoIntrinsic, functionPerformanceNow,
+ &DOMJITSignatureForPerformanceNow);
+
+ this->putDirect(vm, JSC::Identifier::fromString(vm, "now"_s), function, JSC::PropertyAttribute::DOMJITFunction | JSC::PropertyAttribute::Function);
+ }
+};
+const ClassInfo JSPerformanceObject::s_info = { "Performance"_s, &Base::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSPerformanceObject) };
+
+JSC_DEFINE_HOST_FUNCTION(functionPerformanceNow, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
+{
+ return functionPerformanceNowBody(globalObject);
+}
+
+JSC_DEFINE_JIT_OPERATION(functionPerformanceNowWithoutTypeCheck, JSC::EncodedJSValue, (JSC::JSGlobalObject * lexicalGlobalObject, JSPerformanceObject* castedThis))
+{
+ VM& vm = JSC::getVM(lexicalGlobalObject);
+ IGNORE_WARNINGS_BEGIN("frame-address")
+ CallFrame* callFrame = DECLARE_CALL_FRAME(vm);
+ IGNORE_WARNINGS_END
+ JSC::JITOperationPrologueCallFrameTracer tracer(vm, callFrame);
+ return functionPerformanceNowBody(lexicalGlobalObject);
+}
+
JSC_DECLARE_HOST_FUNCTION(functionBunNanoseconds);
JSC_DEFINE_HOST_FUNCTION(functionBunNanoseconds, (JSGlobalObject * globalObject, JSC::CallFrame* callFrame))
{
auto* global = reinterpret_cast<GlobalObject*>(globalObject);
- // nanoseconds to seconds
uint64_t time = Bun__readOriginTimer(global->bunVM());
return JSValue::encode(jsNumber(time));
}
@@ -1712,8 +1786,9 @@ void GlobalObject::finishCreation(VM& vm)
m_performanceObject.initLater(
[](const JSC::LazyProperty<JSC::JSGlobalObject, JSC::JSObject>::Initializer& init) {
- JSC::JSObject* object = JSC::constructEmptyObject(init.owner, init.owner->objectPrototype(), 1);
- object->putDirectNativeFunction(init.vm, init.owner, JSC::Identifier::fromString(init.vm, "now"_s), 1, functionPerformanceNow, NoIntrinsic, 0);
+ JSPerformanceObject* object = JSPerformanceObject::create(init.vm, reinterpret_cast<Zig::GlobalObject*>(init.owner),
+ JSPerformanceObject::createStructure(init.vm, init.owner, init.owner->objectPrototype()));
+
init.set(object);
});
@@ -1752,6 +1827,14 @@ void GlobalObject::finishCreation(VM& vm)
init.set(map);
});
+ m_encodeIntoObjectPrototype.initLater(
+ [](const JSC::LazyProperty<JSC::JSGlobalObject, JSC::JSObject>::Initializer& init) {
+ JSC::JSObject* object = JSC::constructEmptyObject(init.owner, init.owner->objectPrototype(), 2);
+ object->putDirect(init.vm, JSC::Identifier::fromString(init.vm, "read"_s), JSC::jsNumber(0), 0);
+ object->putDirect(init.vm, JSC::Identifier::fromString(init.vm, "written"_s), JSC::jsNumber(0), 0);
+ init.set(object);
+ });
+
m_JSArrayBufferSinkClassStructure.initLater(
[](LazyClassStructure::Initializer& init) {
auto* prototype = createJSSinkPrototype(init.vm, init.global, WebCore::SinkID::ArrayBufferSink);