From e1d1aac7bcc37e35d34c87ca900399d6c4c45b17 Mon Sep 17 00:00:00 2001 From: Linus Groh Date: Sun, 28 Jan 2024 22:33:19 +0000 Subject: [PATCH] LibJS/Bytecode: Apply BigInt/Symbol ToObject avoidance in another place Same as d667721b2 but in a different place. --- .../Libraries/LibJS/Bytecode/CommonImplementations.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index 1795bdceee..fa2e3c2dd1 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -64,13 +64,19 @@ ALWAYS_INLINE ThrowCompletionOr> base_object_for_get(VM& vm return base_value.as_object(); // OPTIMIZATION: For various primitives we can avoid actually creating a new object for them. + auto& realm = *vm.current_realm(); if (base_value.is_string()) - return vm.current_realm()->intrinsics().string_prototype(); + return realm.intrinsics().string_prototype(); if (base_value.is_number()) - return vm.current_realm()->intrinsics().number_prototype(); + return realm.intrinsics().number_prototype(); if (base_value.is_boolean()) - return vm.current_realm()->intrinsics().boolean_prototype(); + return realm.intrinsics().boolean_prototype(); + if (base_value.is_bigint()) + return realm.intrinsics().bigint_prototype(); + if (base_value.is_symbol()) + return realm.intrinsics().symbol_prototype(); + // NOTE: At this point this is guaranteed to throw (null or undefined). return base_value.to_object(vm); }