From 2cf6c8816a73e0132bd8fa3b509d62d7c51b6e47 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Mon, 7 May 2012 11:21:11 +0200 Subject: Imported WebKit commit 7e538425aa020340619e927792f3d895061fb54b (http://svn.webkit.org/repository/webkit/trunk@116286) --- Source/JavaScriptCore/jsc.cpp | 86 ++++++++++++++++++++++--------------------- 1 file changed, 45 insertions(+), 41 deletions(-) (limited to 'Source/JavaScriptCore/jsc.cpp') diff --git a/Source/JavaScriptCore/jsc.cpp b/Source/JavaScriptCore/jsc.cpp index 3d9d1d33e..665333d64 100644 --- a/Source/JavaScriptCore/jsc.cpp +++ b/Source/JavaScriptCore/jsc.cpp @@ -24,7 +24,7 @@ #include "BytecodeGenerator.h" #include "Completion.h" -#include "CurrentTime.h" +#include #include "ExceptionHelpers.h" #include "InitializeThreading.h" #include "Interpreter.h" @@ -33,7 +33,7 @@ #include "JSFunction.h" #include "JSLock.h" #include "JSString.h" -#include "MainThread.h" +#include #include "SamplingTool.h" #include #include @@ -72,10 +72,14 @@ #include #endif +#if PLATFORM(IOS) +#include +#include +#endif + using namespace JSC; using namespace WTF; -static void cleanupGlobalData(JSGlobalData*); static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer); static EncodedJSValue JSC_HOST_CALL functionPrint(ExecState*); @@ -195,8 +199,8 @@ protected: addFunction(globalData, "clearSamplingFlags", functionClearSamplingFlags, 1); #endif -#if ENABLE(COMMANDLINE_TYPEDARRAYS) addConstructableFunction(globalData, "Uint8Array", constructJSUint8Array, 1); + addConstructableFunction(globalData, "Uint8ClampedArray", constructJSUint8ClampedArray, 1); addConstructableFunction(globalData, "Uint16Array", constructJSUint16Array, 1); addConstructableFunction(globalData, "Uint32Array", constructJSUint32Array, 1); addConstructableFunction(globalData, "Int8Array", constructJSInt8Array, 1); @@ -204,7 +208,6 @@ protected: addConstructableFunction(globalData, "Int32Array", constructJSInt32Array, 1); addConstructableFunction(globalData, "Float32Array", constructJSFloat32Array, 1); addConstructableFunction(globalData, "Float64Array", constructJSFloat64Array, 1); -#endif JSArray* array = constructEmptyArray(globalExec()); for (size_t i = 0; i < arguments.size(); ++i) @@ -221,7 +224,7 @@ protected: void addConstructableFunction(JSGlobalData& globalData, const char* name, NativeFunction function, unsigned arguments) { Identifier identifier(globalExec(), name); - putDirect(globalData, identifier, JSFunction::create(globalExec(), this, arguments, identifier, function, function)); + putDirect(globalData, identifier, JSFunction::create(globalExec(), this, arguments, identifier, function, NoIntrinsic, function)); } }; COMPILE_ASSERT(!IsInteger::value, WTF_IsInteger_GlobalObject_false); @@ -277,7 +280,7 @@ EncodedJSValue JSC_HOST_CALL functionJSCStack(ExecState* exec) { String trace = "--> Stack trace:\n"; Vector stackTrace; - Interpreter::getStackTrace(&exec->globalData(), -1, stackTrace); + Interpreter::getStackTrace(&exec->globalData(), stackTrace); int i = 0; for (Vector::iterator iter = stackTrace.begin(); iter < stackTrace.end(); iter++) { @@ -321,11 +324,17 @@ EncodedJSValue JSC_HOST_CALL functionRun(ExecState* exec) GlobalObject* globalObject = GlobalObject::create(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector()); + JSValue exception; StopWatch stopWatch; stopWatch.start(); - evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), jscSource(script.data(), fileName)); + evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), jscSource(script.data(), fileName), JSValue(), &exception); stopWatch.stop(); + if (!!exception) { + throwError(globalObject->globalExec(), exception); + return JSValue::encode(jsUndefined()); + } + return JSValue::encode(jsNumber(stopWatch.getElapsedMS())); } @@ -407,14 +416,8 @@ EncodedJSValue JSC_HOST_CALL functionPreciseTime(ExecState*) return JSValue::encode(jsNumber(currentTime())); } -EncodedJSValue JSC_HOST_CALL functionQuit(ExecState* exec) +EncodedJSValue JSC_HOST_CALL functionQuit(ExecState*) { - // Technically, destroying the heap in the middle of JS execution is a no-no, - // but we want to maintain compatibility with the Mozilla test suite, so - // we pretend that execution has terminated to avoid ASSERTs, then tear down the heap. - exec->globalData().dynamicGlobalObject = 0; - - cleanupGlobalData(&exec->globalData()); exit(EXIT_SUCCESS); #if COMPILER(MSVC) && OS(WINCE) @@ -436,10 +439,18 @@ EncodedJSValue JSC_HOST_CALL functionQuit(ExecState* exec) #define EXCEPT(x) #endif -int jscmain(int argc, char** argv, JSGlobalData*); +int jscmain(int argc, char** argv); int main(int argc, char** argv) { +#if PLATFORM(IOS) + // Enabled IEEE754 denormal support. + fenv_t env; + fegetenv( &env ); + env.__fpscr &= ~0x01000000u; + fesetenv( &env ); +#endif + #if OS(WINDOWS) #if !OS(WINCE) // Cygwin calls ::SetErrorMode(SEM_FAILCRITICALERRORS), which we will inherit. This is bad for @@ -473,23 +484,12 @@ int main(int argc, char** argv) // We can't use destructors in the following code because it uses Windows // Structured Exception Handling int res = 0; - JSGlobalData* globalData = JSGlobalData::create(ThreadStackTypeLarge, LargeHeap).leakRef(); TRY - res = jscmain(argc, argv, globalData); + res = jscmain(argc, argv); EXCEPT(res = 3) - - cleanupGlobalData(globalData); return res; } -static void cleanupGlobalData(JSGlobalData* globalData) -{ - JSLock lock(SilenceAssertionsOnly); - globalData->clearBuiltinStructures(); - globalData->heap.destroy(); - globalData->deref(); -} - static bool runWithScripts(GlobalObject* globalObject, const Vector