diff options
author | 2022-03-26 20:35:37 -0700 | |
---|---|---|
committer | 2022-03-26 20:35:37 -0700 | |
commit | 29a759a65512278f1c20d1089ba05dbae268ef24 (patch) | |
tree | 8f922320d54f6a99639bcfe8b53d971cab6a029c /src/javascript/jsc/bindings/bindings.cpp | |
parent | b54a51adb96b3eea6aacff4f83f3ac39ddbc933e (diff) | |
download | bun-29a759a65512278f1c20d1089ba05dbae268ef24.tar.gz bun-29a759a65512278f1c20d1089ba05dbae268ef24.tar.zst bun-29a759a65512278f1c20d1089ba05dbae268ef24.zip |
improve performance of accessing `Bun.Transpiler` and `Bun.unsafe`
Diffstat (limited to 'src/javascript/jsc/bindings/bindings.cpp')
-rw-r--r-- | src/javascript/jsc/bindings/bindings.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/javascript/jsc/bindings/bindings.cpp b/src/javascript/jsc/bindings/bindings.cpp index e4dbdc949..3a155f5dd 100644 --- a/src/javascript/jsc/bindings/bindings.cpp +++ b/src/javascript/jsc/bindings/bindings.cpp @@ -317,6 +317,25 @@ JSC__JSValue JSC__JSValue__parseJSON(JSC__JSValue JSValue0, JSC__JSGlobalObject* return JSC::JSValue::encode(result); } +JSC__JSValue JSC__JSGlobalObject__getCachedObject(JSC__JSGlobalObject* globalObject, const ZigString* arg1) +{ + JSC::VM& vm = globalObject->vm(); + WTF::String string = Zig::toString(*arg1); + auto symbol = vm.privateSymbolRegistry().symbolForKey(string); + JSC::Identifier ident = JSC::Identifier::fromUid(symbol); + JSC::JSValue result = globalObject->getIfPropertyExists(globalObject, ident); + return JSC::JSValue::encode(result); +} +JSC__JSValue JSC__JSGlobalObject__putCachedObject(JSC__JSGlobalObject* globalObject, const ZigString* arg1, JSC__JSValue JSValue2) +{ + JSC::VM& vm = globalObject->vm(); + WTF::String string = Zig::toString(*arg1); + auto symbol = vm.privateSymbolRegistry().symbolForKey(string); + JSC::Identifier ident = JSC::Identifier::fromUid(symbol); + globalObject->putDirect(vm, ident, JSC::JSValue::decode(JSValue2), JSC::PropertyAttribute::DontDelete | JSC::PropertyAttribute::DontEnum); + return JSValue2; +} + void JSC__JSGlobalObject__deleteModuleRegistryEntry(JSC__JSGlobalObject* global, ZigString* arg1) { JSC::JSMap* map = JSC::jsDynamicCast<JSC::JSMap*>( |