mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibJS: Start implementing object shapes
This patch adds JS::Shape, which implements a transition tree for our Object class. Object property keys, prototypes and attributes are now stored in a Shape, and each Object has a Shape. When adding a property to an Object, we make a transition from the old Shape to a new Shape. If we've made the same exact transition in the past (with another Object), we reuse the same transition and both objects may now share a Shape. This will become the foundation of inline caching and other engine optimizations in the future. :^)
This commit is contained in:
@@ -29,6 +29,7 @@
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/ObjectConstructor.h>
|
||||
#include <LibJS/Runtime/Shape.h>
|
||||
|
||||
namespace JS {
|
||||
|
||||
@@ -68,7 +69,7 @@ Value ObjectConstructor::get_own_property_names(Interpreter& interpreter)
|
||||
for (i32 i = 0; i < array->length(); ++i)
|
||||
result->push(js_string(interpreter.heap(), String::number(i)));
|
||||
}
|
||||
for (auto& it : object->own_properties())
|
||||
for (auto& it : object->shape().property_table())
|
||||
result->push(js_string(interpreter.heap(), it.key));
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user