-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce new way of create object in script #1303
Conversation
Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
* Prepare the property and key list before object creation * The new way reduce size of object structure with transition Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
NEVER_INLINE void InterpreterSlowPath::createArrayOperation(ExecutionState& state, CreateArray* code, ByteCodeBlock* byteCodeBlock, Value* registerFile) | ||
{ | ||
registerFile[code->m_registerIndex] = new ArrayObject(state, (uint64_t)code->m_length); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add a function for creating Array
object here?
This method seems quite simple, so it might be better to embed this function body into the interpreter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my opinion, calling GC_MALLOC is quite complicated, so inlining the new expression into the interpreter is not very efficient.
It's only a small effort to reduce the size of the interpreter function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh,, I see
if (m_properties.size() >= ESCARGOT_OBJECT_STRUCTURE_TRANSITION_MODE_MAX_SIZE) { | ||
size_t objectCreationDataIndex = SIZE_MAX; | ||
size_t initCodePosition = codeBlock->currentCodeSize(); | ||
if (m_properties.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement could be removed since m_properties
has always elements in this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! this if statement was needed for testing.
I am going to remove it
if (m_properties.size()) { | ||
codeBlock->peekCode<CreateObjectPrepare>(initCodePosition)->m_propertyReserveSize = propertyIndex; | ||
context->giveUpRegister(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This if statement could be removed too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops! this if statement was needed for testing.
I am going to remove it
Object* obj = registerFile[code->m_registerIndex].asObject(); | ||
ObjectStructureItemTightVector properties; | ||
properties.reset(data->m_properties.takeBuffer(), data->m_values.size()); | ||
obj->m_structure = ObjectStructure::create(state.context(), std::move(properties)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of allocating a temporal ObjectStructureItemTightVector(properties)
to copy the data->m_properties
here,
What about defining data->m_properties
as ObjectStructureItemTightVector
to just move the data directly?
Is this not possible because properties of the same name could be initialized together ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ObjectExpression not always have immutable count of properties. ex) spread element, duplicated key
But TightVector needs GC_MALLOC every expand of property
That's why I use Vector for data->m_properties
* It should support methods and spread element Signed-off-by: Seonghyun Kim <sh8281.kim@samsung.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
No description provided.