コード例 #1
0
ファイル: NPJSObject.cpp プロジェクト: Moondee/Artemis
bool NPJSObject::construct(const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
    ExecState* exec = m_objectMap->globalExec();
    if (!exec)
        return false;

    JSLock lock(SilenceAssertionsOnly);

    ConstructData constructData;
    ConstructType constructType = getConstructData(m_jsObject.get(), constructData);
    if (constructType == ConstructTypeNone)
        return false;

    // Convert the passed in arguments.
    MarkedArgumentBuffer argumentList;
    for (uint32_t i = 0; i < argumentCount; ++i)
        argumentList.append(m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), arguments[i]));

    exec->globalData().timeoutChecker.start();
    JSValue value = JSC::construct(exec, m_jsObject.get(), constructType, constructData, argumentList);
    exec->globalData().timeoutChecker.stop();
    
    // Convert and return the new object.
    m_objectMap->convertJSValueToNPVariant(exec, value, *result);
    exec->clearException();

    return true;
}
コード例 #2
0
ファイル: NPJSObject.cpp プロジェクト: eocanha/webkit
bool NPJSObject::construct(const NPVariant* arguments, uint32_t argumentCount, NPVariant* result)
{
    ExecState* exec = m_objectMap->globalExec();
    if (!exec)
        return false;

    VM& vm = exec->vm();
    JSLockHolder lock(vm);
    auto scope = DECLARE_CATCH_SCOPE(vm);

    ConstructData constructData;
    ConstructType constructType = getConstructData(m_jsObject.get(), constructData);
    if (constructType == ConstructType::None)
        return false;

    // Convert the passed in arguments.
    MarkedArgumentBuffer argumentList;
    for (uint32_t i = 0; i < argumentCount; ++i)
        argumentList.append(m_objectMap->convertNPVariantToJSValue(exec, m_objectMap->globalObject(), arguments[i]));

    JSValue value = JSC::construct(exec, m_jsObject.get(), constructType, constructData, argumentList);
    
    // Convert and return the new object.
    m_objectMap->convertJSValueToNPVariant(exec, value, *result);
    scope.clearException();

    return true;
}
コード例 #3
0
ファイル: DFGOperations.cpp プロジェクト: sysrqb/chromium-src
static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializationKind kind)
{
    ExecState* exec = execCallee->callerFrame();
    JSGlobalData* globalData = &exec->globalData();
    if (kind == CodeForCall) {
        CallData callData;
        CallType callType = getCallData(callee, callData);
    
        ASSERT(callType != CallTypeJS);
    
        if (callType == CallTypeHost) {
            if (!globalData->interpreter->registerFile().grow(execCallee->registers())) {
                globalData->exception = createStackOverflowError(exec);
                return 0;
            }
        
            execCallee->setScopeChain(exec->scopeChain());
        
            globalData->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
        
            if (globalData->exception)
                return 0;
            return reinterpret_cast<void*>(getHostCallReturnValue);
        }
    
        ASSERT(callType == CallTypeNone);
        exec->globalData().exception = createNotAFunctionError(exec, callee);
        return 0;
    }

    ASSERT(kind == CodeForConstruct);
    
    ConstructData constructData;
    ConstructType constructType = getConstructData(callee, constructData);
    
    ASSERT(constructType != ConstructTypeJS);
    
    if (constructType == ConstructTypeHost) {
        if (!globalData->interpreter->registerFile().grow(execCallee->registers())) {
            globalData->exception = createStackOverflowError(exec);
            return 0;
        }
        
        execCallee->setScopeChain(exec->scopeChain());
        
        globalData->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
        
        if (globalData->exception)
            return 0;
        return reinterpret_cast<void*>(getHostCallReturnValue);
    }
    
    ASSERT(constructType == ConstructTypeNone);
    exec->globalData().exception = createNotAConstructorError(exec, callee);
    return 0;
}
コード例 #4
0
JSPromise* constructPromise(ExecState* exec, JSGlobalObject* globalObject, JSFunction* resolver)
{
    JSPromiseConstructor* promiseConstructor = globalObject->promiseConstructor();

    ConstructData constructData;
    ConstructType constructType = getConstructData(promiseConstructor, constructData);
    ASSERT(constructType != ConstructTypeNone);

    MarkedArgumentBuffer arguments;
    arguments.append(resolver);

    return jsCast<JSPromise*>(construct(exec, promiseConstructor, constructType, constructData, arguments));
}
コード例 #5
0
ファイル: JITOperations.cpp プロジェクト: webOS-ports/webkit
static void* handleHostCall(ExecState* execCallee, JSValue callee, CodeSpecializationKind kind)
{
    ExecState* exec = execCallee->callerFrame();
    VM* vm = &exec->vm();

    execCallee->setScope(exec->scope());
    execCallee->setCodeBlock(0);

    if (kind == CodeForCall) {
        CallData callData;
        CallType callType = getCallData(callee, callData);
    
        ASSERT(callType != CallTypeJS);
    
        if (callType == CallTypeHost) {
            NativeCallFrameTracer tracer(vm, execCallee);
            execCallee->setCallee(asObject(callee));
            vm->hostCallReturnValue = JSValue::decode(callData.native.function(execCallee));
            if (vm->exception())
                return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();

            return reinterpret_cast<void*>(getHostCallReturnValue);
        }
    
        ASSERT(callType == CallTypeNone);
        exec->vm().throwException(exec, createNotAFunctionError(exec, callee));
        return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
    }

    ASSERT(kind == CodeForConstruct);
    
    ConstructData constructData;
    ConstructType constructType = getConstructData(callee, constructData);
    
    ASSERT(constructType != ConstructTypeJS);
    
    if (constructType == ConstructTypeHost) {
        NativeCallFrameTracer tracer(vm, execCallee);
        execCallee->setCallee(asObject(callee));
        vm->hostCallReturnValue = JSValue::decode(constructData.native.function(execCallee));
        if (vm->exception())
            return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();

        return reinterpret_cast<void*>(getHostCallReturnValue);
    }
    
    ASSERT(constructType == ConstructTypeNone);
    exec->vm().throwException(exec, createNotAConstructorError(exec, callee));
    return vm->getCTIStub(throwExceptionFromCallSlowPathGenerator).code().executableAddress();
}
コード例 #6
0
EncodedJSValue JSC_HOST_CALL boundThisNoArgsFunctionConstruct(ExecState* exec)
{
    JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->jsCallee());

    MarkedArgumentBuffer args;
    for (unsigned i = 0; i < exec->argumentCount(); ++i)
        args.append(exec->uncheckedArgument(i));

    JSFunction* targetFunction = jsCast<JSFunction*>(boundFunction->targetFunction());
    ConstructData constructData;
    ConstructType constructType = getConstructData(targetFunction, constructData);
    ASSERT(constructType != ConstructType::None);
    return JSValue::encode(construct(exec, targetFunction, constructType, constructData, args));
}
コード例 #7
0
JSValue createJSPromiseDeferredFromConstructor(ExecState* exec, JSValue C)
{
    // -- This implements the GetDeferred(C) abstract operation --

    // 1. If IsConstructor(C) is false, throw a TypeError.
    if (!C.isObject())
        return throwTypeError(exec);

    ConstructData constructData;
    ConstructType constructType = getConstructData(C, constructData);
    if (constructType == ConstructTypeNone)
        return throwTypeError(exec);

    VM& vm = exec->vm();

    // 2. Let 'resolver' be a new built-in function object as defined in Deferred Construction Functions.
    JSFunction* resolver = createDeferredConstructionFunction(vm, asObject(C)->globalObject());

    // 3. Let 'promise' be the result of calling the [[Construct]] internal method of 'C' with
    //    an argument list containing the single item resolver.
    MarkedArgumentBuffer constructArguments;
    constructArguments.append(resolver);
    JSObject* promise = construct(exec, C, constructType, constructData, constructArguments);

    // 4. ReturnIfAbrupt(promise).
    if (exec->hadException())
        return jsUndefined();

    // 5. Let 'resolve' be the value of resolver's [[Resolve]] internal slot.
    JSValue resolve = resolver->get(exec, vm.propertyNames->resolvePrivateName);

    // 6. If IsCallable(resolve) is false, throw a TypeError.
    CallData resolveCallData;
    CallType resolveCallType = getCallData(resolve, resolveCallData);
    if (resolveCallType == CallTypeNone)
        return throwTypeError(exec);

    // 7. Let 'reject' be the value of resolver's [[Reject]] internal slot.
    JSValue reject = resolver->get(exec, vm.propertyNames->rejectPrivateName);

    // 8. If IsCallable(reject) is false, throw a TypeError.
    CallData rejectCallData;
    CallType rejectCallType = getCallData(reject, rejectCallData);
    if (rejectCallType == CallTypeNone)
        return throwTypeError(exec);

    // 9. Return the Deferred { [[Promise]]: promise, [[Resolve]]: resolve, [[Reject]]: reject }.
    return JSPromiseDeferred::create(exec->vm(), promise, resolve, reject);
}
コード例 #8
0
EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState* exec)
{
    JSBoundFunction* boundFunction = jsCast<JSBoundFunction*>(exec->callee());

    ASSERT(isJSArray(boundFunction->boundArgs())); // Currently this is true!
    JSArray* boundArgs = asArray(boundFunction->boundArgs());

    MarkedArgumentBuffer args;
    for (unsigned i = 0; i < boundArgs->length(); ++i)
        args.append(boundArgs->getIndexQuickly(i));
    for (unsigned i = 0; i < exec->argumentCount(); ++i)
        args.append(exec->argument(i));

    JSObject* targetFunction = boundFunction->targetFunction();
    ConstructData constructData;
    ConstructType constructType = getConstructData(targetFunction, constructData);
    ASSERT(constructType != ConstructTypeNone);
    return JSValue::encode(construct(exec, targetFunction, constructType, constructData, args));
}
コード例 #9
0
ConstructType JSCallbackConstructor::getConstructDataVirtual(ConstructData& constructData)
{
    return getConstructData(this, constructData);
}
コード例 #10
0
ファイル: DateConstructor.cpp プロジェクト: 1833183060/wke
ConstructType DateConstructor::getConstructDataVirtual(ConstructData& constructData)
{
    return getConstructData(this, constructData);
}
コード例 #11
0
ConstructType NativeErrorConstructor::getConstructDataVirtual(ConstructData& constructData)
{
    return getConstructData(this, constructData);
}
コード例 #12
0
ファイル: runtime_object.cpp プロジェクト: vizcount/work
ConstructType RuntimeObject::getConstructDataVirtual(ConstructData& constructData)
{
    return getConstructData(this, constructData);
}