Changeset 230759 in webkit for trunk/Source/JavaScriptCore/jsc.cpp
- Timestamp:
- Apr 18, 2018, 2:47:19 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/jsc.cpp
r230741 r230759 187 187 } 188 188 189 static bool fillBufferWithContentsOfFile(const String& fileName, Vector<char>& buffer); 189 template<typename Vector> 190 static bool fillBufferWithContentsOfFile(const String& fileName, Vector& buffer); 190 191 static RefPtr<Uint8Array> fillBufferWithContentsOfFile(const String& fileName); 191 192 … … 196 197 template<typename Func> 197 198 int runJSC(CommandLine, bool isWorker, const Func&); 198 static void checkException( GlobalObject*, bool isLastFile, bool hasException, JSValue, CommandLine&, bool& success);199 static void checkException(ExecState*, GlobalObject*, bool isLastFile, bool hasException, JSValue, CommandLine&, bool& success); 199 200 200 201 class Message : public ThreadSafeRefCounted<Message> { … … 845 846 } 846 847 847 static void convertShebangToJSComment(Vector<char>& buffer) 848 template<typename Vector> 849 static void convertShebangToJSComment(Vector& buffer) 848 850 { 849 851 if (buffer.size() >= 2) { … … 883 885 } 884 886 885 static bool fillBufferWithContentsOfFile(FILE* file, Vector<char>& buffer) 887 template<typename Vector> 888 static bool fillBufferWithContentsOfFile(FILE* file, Vector& buffer) 886 889 { 887 890 // We might have injected "use strict"; at the top. … … 921 924 } 922 925 923 static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector<char>& buffer) 926 template<typename Vector> 927 static bool fetchModuleFromLocalFileSystem(const String& fileName, Vector& buffer) 924 928 { 925 929 // We assume that fileName is always an absolute path. … … 972 976 973 977 // Here, now we consider moduleKey as the fileName. 974 Vector< char> utf8;975 if (!fetchModuleFromLocalFileSystem(moduleKey, utf8)) {978 Vector<uint8_t> buffer; 979 if (!fetchModuleFromLocalFileSystem(moduleKey, buffer)) { 976 980 auto result = deferred->reject(exec, createError(exec, makeString("Could not open file '", moduleKey, "'."))); 977 981 scope.releaseAssertNoException(); … … 979 983 } 980 984 981 auto result = deferred->resolve(exec, JSSourceCode::create(vm, makeSource(stringFromUTF(utf8), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module))); 985 #if ENABLE(WEBASSEMBLY) 986 // FileSystem does not have mime-type header. The JSC shell recognizes WebAssembly's magic header. 987 if (buffer.size() >= 4) { 988 if (buffer[0] == '\0' && buffer[1] == 'a' && buffer[2] == 's' && buffer[3] == 'm') { 989 auto result = deferred->resolve(exec, JSSourceCode::create(vm, SourceCode(WebAssemblySourceProvider::create(WTFMove(buffer), SourceOrigin { moduleKey }, moduleKey)))); 990 scope.releaseAssertNoException(); 991 return result; 992 } 993 } 994 #endif 995 996 auto result = deferred->resolve(exec, JSSourceCode::create(vm, makeSource(stringFromUTF(buffer), SourceOrigin { moduleKey }, moduleKey, TextPosition(), SourceProviderSourceType::Module))); 982 997 scope.releaseAssertNoException(); 983 998 return result; … … 1618 1633 if (evaluationException) 1619 1634 result = evaluationException->value(); 1620 checkException(globalObject , true, evaluationException, result, commandLine, success);1635 checkException(globalObject->globalExec(), globalObject, true, evaluationException, result, commandLine, success); 1621 1636 if (!success) 1622 1637 exit(1); … … 2245 2260 } 2246 2261 2247 static void checkException( GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, CommandLine& options, bool& success)2262 static void checkException(ExecState* exec, GlobalObject* globalObject, bool isLastFile, bool hasException, JSValue value, CommandLine& options, bool& success) 2248 2263 { 2249 2264 VM& vm = globalObject->vm(); … … 2257 2272 success = success && !hasException; 2258 2273 if (options.m_dump && !hasException) 2259 printf("End: %s\n", value.toWTFString( globalObject->globalExec()).utf8().data());2274 printf("End: %s\n", value.toWTFString(exec).utf8().data()); 2260 2275 if (hasException) 2261 2276 dumpException(globalObject, value); … … 2310 2325 2311 2326 JSFunction* fulfillHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) { 2312 checkException( globalObject, isLastFile, false, exec->argument(0), options, success);2327 checkException(exec, globalObject, isLastFile, false, exec->argument(0), options, success); 2313 2328 return JSValue::encode(jsUndefined()); 2314 2329 }); 2315 2330 2316 2331 JSFunction* rejectHandler = JSNativeStdFunction::create(vm, globalObject, 1, String(), [&, isLastFile](ExecState* exec) { 2317 checkException( globalObject, isLastFile, true, exec->argument(0), options, success);2332 checkException(exec, globalObject, isLastFile, true, exec->argument(0), options, success); 2318 2333 return JSValue::encode(jsUndefined()); 2319 2334 }); … … 2328 2343 if (evaluationException) 2329 2344 returnValue = evaluationException->value(); 2330 checkException(globalObject , isLastFile, evaluationException, returnValue, options, success);2345 checkException(globalObject->globalExec(), globalObject, isLastFile, evaluationException, returnValue, options, success); 2331 2346 } 2332 2347
Note:
See TracChangeset
for help on using the changeset viewer.