Fix [[Prototype]] initialization process for each object creation

* remove duplicated initialization for [[Prototype]] internal slot
* initialize prototype value directly when each Object created
* each prototype candidate object should be first marked as prototype object
* setGlobalIntrinsicObject marks fixed structure and prototype for global object's intrinsic object initialization

Signed-off-by: HyukWoo Park <hyukwoo.park@samsung.com>
This commit is contained in:
HyukWoo Park 2020-03-18 17:18:00 +09:00 committed by Patrick Kim
commit 39a5922437
93 changed files with 464 additions and 566 deletions

View file

@ -24,12 +24,16 @@
namespace Escargot {
StringObject::StringObject(ExecutionState& state, String* value)
: Object(state, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 1, true)
: StringObject(state, state.context()->globalObject()->stringPrototype(), value)
{
}
StringObject::StringObject(ExecutionState& state, Object* proto, String* value)
: Object(state, proto, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 1)
, m_primitiveValue(value)
{
m_structure = state.context()->defaultStructureForStringObject();
m_values[ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER] = Value();
Object::setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->stringPrototype());
}
void* StringObject::operator new(size_t size)
@ -125,11 +129,15 @@ ObjectHasPropertyResult StringObject::hasIndexedProperty(ExecutionState& state,
}
StringIteratorObject::StringIteratorObject(ExecutionState& state, String* s)
: IteratorObject(state)
: StringIteratorObject(state, state.context()->globalObject()->stringIteratorPrototype(), s)
{
}
StringIteratorObject::StringIteratorObject(ExecutionState& state, Object* proto, String* s)
: IteratorObject(state, proto)
, m_string(s)
, m_iteratorNextIndex(0)
{
Object::setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->stringIteratorPrototype());
}
void* StringIteratorObject::operator new(size_t size)