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

@ -31,35 +31,29 @@
namespace Escargot {
RegExpObject::RegExpObject(ExecutionState& state, String* source, String* option)
: Object(state, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 5, true)
, m_source(NULL)
, m_optionString(NULL)
, m_option(None)
, m_yarrPattern(NULL)
, m_bytecodePattern(NULL)
, m_lastIndex(Value(0))
, m_lastExecutedString(NULL)
: RegExpObject(state, state.context()->globalObject()->regexpPrototype(), source, option)
{
}
RegExpObject::RegExpObject(ExecutionState& state, Object* proto, String* source, String* option)
: RegExpObject(state, proto, true)
{
initRegExpObject(state, true);
init(state, source, option);
}
RegExpObject::RegExpObject(ExecutionState& state, String* source, unsigned int option)
: Object(state, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 5, true)
, m_source(NULL)
, m_optionString(NULL)
, m_option(None)
, m_yarrPattern(NULL)
, m_bytecodePattern(NULL)
, m_lastIndex(Value(0))
, m_lastExecutedString(NULL)
: RegExpObject(state, state.context()->globalObject()->regexpPrototype(), source, option)
{
}
RegExpObject::RegExpObject(ExecutionState& state, Object* proto, String* source, unsigned int option)
: RegExpObject(state, proto, true)
{
initRegExpObject(state, true);
initWithOption(state, source, (Option)option);
}
RegExpObject::RegExpObject(ExecutionState& state, bool hasLastIndex)
: Object(state, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + (hasLastIndex ? 5 : 4), true)
RegExpObject::RegExpObject(ExecutionState& state, Object* proto, bool hasLastIndex)
: Object(state, proto, ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + (hasLastIndex ? 5 : 4))
, m_source(NULL)
, m_optionString(NULL)
, m_option(None)
@ -69,7 +63,6 @@ RegExpObject::RegExpObject(ExecutionState& state, bool hasLastIndex)
, m_lastExecutedString(NULL)
{
initRegExpObject(state, hasLastIndex);
init(state, String::emptyString, String::emptyString);
}
void RegExpObject::initRegExpObject(ExecutionState& state, bool hasLastIndex)
@ -78,12 +71,10 @@ void RegExpObject::initRegExpObject(ExecutionState& state, bool hasLastIndex)
for (size_t i = 0; i < ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 5; i++)
m_values[i] = Value();
m_structure = state.context()->defaultStructureForRegExpObject();
setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->regexpPrototype());
} else {
for (size_t i = 0; i < ESCARGOT_OBJECT_BUILTIN_PROPERTY_NUMBER + 4; i++)
m_values[i] = Value();
m_structure = state.context()->defaultStructureForObject();
setPrototypeForIntrinsicObjectCreation(state, state.context()->globalObject()->regexpPrototype());
}
}