summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-10-01 02:43:57 +0200
committerAndreas Kling <kling@serenityos.org>2021-10-01 02:59:29 +0200
commit14c57b4b7fc85cefa70bf85bc4659fe5311e7e0f (patch)
tree8b02a0aec6b917ef5f06a514ea0870ac41891075 /Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
parent46686f7f94a0b494c455a87f06c41178124dc462 (diff)
downloadserenity-14c57b4b7fc85cefa70bf85bc4659fe5311e7e0f.zip
LibJS: Remove transition avoidance & start caching prototype transitions
The way that transition avoidance (foo_without_transition) was implemented led to shapes being unshareable and caused shape explosion instead, precisely what we were trying to avoid. This patch removes all the attempts to avoid transitioning shapes, and instead *adds* transitions when changing an object's prototype. This makes transitions flow naturally, and as a result we end up with way fewer shape objects in real-world situations. When we run out of big problems, we can get back to avoiding transitions as an optimization, but for now, let's avoid ballooning our processes with a unique shape for every object.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/GlobalObject.cpp')
-rw-r--r--Userland/Libraries/LibJS/Runtime/GlobalObject.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
index e93430100a..c2cc6ae825 100644
--- a/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/GlobalObject.cpp
@@ -139,10 +139,8 @@ void GlobalObject::initialize_global_object()
// Normally Heap::allocate() takes care of this, but these are allocated via allocate_without_global_object().
static_cast<FunctionPrototype*>(m_function_prototype)->initialize(*this);
- m_function_prototype->set_initialized(Badge<GlobalObject> {});
static_cast<ObjectPrototype*>(m_object_prototype)->initialize(*this);
- m_object_prototype->set_initialized(Badge<GlobalObject> {});
auto success = Object::internal_set_prototype_of(m_object_prototype).release_value();
VERIFY(success);
@@ -159,7 +157,7 @@ void GlobalObject::initialize_global_object()
// %GeneratorFunction.prototype.prototype% must be initialized separately as it has no
// companion constructor
m_generator_object_prototype = heap().allocate<GeneratorObjectPrototype>(*this, *this);
- m_generator_object_prototype->define_direct_property_without_transition(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
+ m_generator_object_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
if (!m_##snake_name##_prototype) \
@@ -204,13 +202,13 @@ void GlobalObject::initialize_global_object()
vm.throw_exception<TypeError>(global_object, ErrorType::RestrictedFunctionPropertiesAccess);
return Value();
});
- m_throw_type_error_function->define_direct_property_without_transition(vm.names.length, Value(0), 0);
- m_throw_type_error_function->define_direct_property_without_transition(vm.names.name, js_string(vm, ""), 0);
+ m_throw_type_error_function->define_direct_property(vm.names.length, Value(0), 0);
+ m_throw_type_error_function->define_direct_property(vm.names.name, js_string(vm, ""), 0);
(void)m_throw_type_error_function->internal_prevent_extensions();
// 10.2.4 AddRestrictedFunctionProperties ( F, realm ), https://tc39.es/ecma262/#sec-addrestrictedfunctionproperties
- m_function_prototype->define_direct_accessor_without_transition(vm.names.caller, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
- m_function_prototype->define_direct_accessor_without_transition(vm.names.arguments, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
+ m_function_prototype->define_direct_accessor(vm.names.caller, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
+ m_function_prototype->define_direct_accessor(vm.names.arguments, m_throw_type_error_function, m_throw_type_error_function, Attribute::Configurable);
define_native_function(vm.names.encodeURI, encode_uri, 1, attr);
define_native_function(vm.names.decodeURI, decode_uri, 1, attr);
@@ -269,13 +267,11 @@ void GlobalObject::initialize_global_object()
// The generator constructor cannot be initialized with add_constructor as it has no global binding
m_generator_function_constructor = heap().allocate<GeneratorFunctionConstructor>(*this, *this);
// 27.3.3.1 GeneratorFunction.prototype.constructor, https://tc39.es/ecma262/#sec-generatorfunction.prototype.constructor
- m_generator_function_prototype->define_direct_property_without_transition(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
+ m_generator_function_prototype->define_direct_property(vm.names.constructor, m_generator_function_constructor, Attribute::Configurable);
m_array_prototype_values_function = &m_array_prototype->get_without_side_effects(vm.names.values).as_function();
m_eval_function = &get_without_side_effects(vm.names.eval).as_function();
m_temporal_time_zone_prototype_get_offset_nanoseconds_for_function = &m_temporal_time_zone_prototype->get_without_side_effects(vm.names.getOffsetNanosecondsFor).as_function();
-
- set_initialized(Badge<GlobalObject> {});
}
GlobalObject::~GlobalObject()