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