static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec)
{
    JSGlobalObject* globalObject = exec->callee()->globalObject();
    VM& vm = exec->vm();

    JSValue newTarget = exec->newTarget();
    if (!newTarget || newTarget.isUndefined())
        return throwVMTypeError(exec);

    JSPromise* promise = JSPromise::create(vm, globalObject->promiseStructure());
    if (!jsDynamicCast<JSPromiseConstructor*>(newTarget)) {
        JSValue proto = asObject(newTarget)->getDirect(vm, vm.propertyNames->prototype);
        asObject(promise)->setPrototypeWithCycleCheck(exec, proto);
    }
    promise->initialize(exec, globalObject, exec->argument(0));

    return JSValue::encode(promise);
}
static EncodedJSValue JSC_HOST_CALL constructPromise(ExecState* exec)
{
    VM& vm = exec->vm();
    auto scope = DECLARE_THROW_SCOPE(vm);
    JSGlobalObject* globalObject = exec->jsCallee()->globalObject();

    JSValue newTarget = exec->newTarget();
    if (newTarget.isUndefined())
        return throwVMTypeError(exec, scope);

    Structure* promiseStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), globalObject->promiseStructure());
    RETURN_IF_EXCEPTION(scope, encodedJSValue());
    JSPromise* promise = JSPromise::create(vm, promiseStructure);
    promise->initialize(exec, globalObject, exec->argument(0));

    return JSValue::encode(promise);
}