mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 17:28:48 +00:00
LibJS: Use the same StringPrototype globally
To make sure that everyone has the same instance of StringPrototype, hang a global prototype off of the Interpreter that can be fetched when constructing new StringObjects.
This commit is contained in:
parent
9b4358e150
commit
8dc6416bba
Notes:
sideshowbarker
2024-07-19 08:17:51 +09:00
Author: https://github.com/awesomekling
Commit: 8dc6416bba
3 changed files with 8 additions and 1 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/NativeFunction.h>
|
||||
#include <LibJS/Object.h>
|
||||
#include <LibJS/StringPrototype.h>
|
||||
#include <LibJS/Value.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -38,6 +39,7 @@ Interpreter::Interpreter()
|
|||
: m_heap(*this)
|
||||
{
|
||||
m_global_object = heap().allocate<GlobalObject>();
|
||||
m_string_prototype = heap().allocate<StringPrototype>();
|
||||
}
|
||||
|
||||
Interpreter::~Interpreter()
|
||||
|
@ -137,6 +139,7 @@ Value Interpreter::get_variable(const String& name)
|
|||
void Interpreter::collect_roots(Badge<Heap>, HashTable<Cell*>& roots)
|
||||
{
|
||||
roots.set(m_global_object);
|
||||
roots.set(m_string_prototype);
|
||||
|
||||
for (auto& scope : m_scope_stack) {
|
||||
for (auto& it : scope.variables) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue