EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec) { String fileName = exec->argument(0).toString(exec)->value(exec); Vector<char> script; if (!fillBufferWithContentsOfFile(fileName, script)) return JSValue::encode(exec->vm().throwException(exec, createError(exec, "Could not open file."))); GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>()); JSArray* array = constructEmptyArray(globalObject->globalExec(), 0); for (unsigned i = 1; i < exec->argumentCount(); ++i) array->putDirectIndex(globalObject->globalExec(), i - 1, exec->uncheckedArgument(i)); globalObject->putDirect( exec->vm(), Identifier(globalObject->globalExec(), "arguments"), array); JSValue exception; StopWatch stopWatch; stopWatch.start(); evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), &exception); stopWatch.stop(); if (!!exception) { exec->vm().throwException(globalObject->globalExec(), exception); return JSValue::encode(jsUndefined()); } return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); }
EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec) { String fileName = exec->argument(0).toString(exec)->value(exec); Vector<char> script; if (!fillBufferWithContentsOfFile(fileName, script)) return JSValue::encode(throwError(exec, createError(exec, "Could not open file."))); GlobalObject* globalObject = GlobalObject::create(exec->vm(), GlobalObject::createStructure(exec->vm(), jsNull()), Vector<String>()); JSValue exception; StopWatch stopWatch; stopWatch.start(); evaluate(globalObject->globalExec(), jscSource(script.data(), fileName), JSValue(), &exception); stopWatch.stop(); if (!!exception) { throwError(globalObject->globalExec(), exception); return JSValue::encode(jsUndefined()); } return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); }
EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec) { UString fileName = exec->argument(0).toString(exec); Vector<char> script; if (!fillBufferWithContentsOfFile(fileName, script)) return JSValue::encode(throwError(exec, createError(exec, "Could not open file."))); GlobalObject* globalObject = new (&exec->globalData()) GlobalObject(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>()); StopWatch stopWatch; stopWatch.start(); evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), makeSource(script.data(), fileName)); stopWatch.stop(); return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); }