Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: appcelerator/webkit
...
head fork: appcelerator/webkit
  • 3 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Oct 12, 2013
@mrobinson mrobinson Fix a thread identifier leak in the StdThread implementation 0b1aa34
@mrobinson mrobinson Run scripts with the JSC C API
This is an effort to avoid leaking memory when running many scripts
within the same process.
291b91f
@mrobinson mrobinson Fix a bug in the test harness when running strict tests
We need to look at the test contents to see if a test has
to be run in strict mode. If so we need to insert the
proper strict mode header.
fe20f1e
View
19 Source/JavaScriptCore/TestRunner/MainPage.xaml.cs
@@ -77,7 +77,7 @@ private void FilterTestPaths()
String ed = await LoadHarnessFile("ed.js");
String testBuiltinObject = await LoadHarnessFile("testBuiltInObject.js");
String testIntl = await LoadHarnessFile("testIntl.js");
- return cth + sta + ed + testBuiltinObject + testIntl;
+ return cth + sta + ed + testBuiltinObject + testIntl + "\n";
}
private static async Task<String> LoadFileFromInstallationDirectorySubdirectory(string subdirectory, string filePath)
@@ -107,6 +107,14 @@ private void FilterTestPaths()
return testList.Split('\n').Where(t => t.Length > 0 && t[0] != '#').ToArray();
}
+ static String StrictModeString(String testContents)
+ {
+ if (testContents.Contains("@onlyStrict"))
+ return "\"use strict\";\nvar strict_mode = true;\n";
+ else
+ return "var strict_mode = false; \n";
+ }
+
private async void StartTestsCallback(object sender, RoutedEventArgs e)
{
this.StartTestsButton.IsEnabled = false;
@@ -116,14 +124,15 @@ private void FilterTestPaths()
for (int i = 0; i < Progress.Maximum; i++)
{
String script = await LoadSuiteFile(filteredTestPaths[i]);
- String fullScript = harnessString + script;
+ bool positiveTest = !script.Contains("@negative");
+
+ String fullScript = StrictModeString(script) + harnessString + script;
TestRunnerComponent.ScriptResult result = this.scriptRunner.RunScript(fullScript, this.filteredTestPaths[i]);
StatusText.Text = "Ran " + (i + 1) + " of " + Progress.Maximum + " tests (" + this.failedTests.Count + " failed)";
- System.Diagnostics.Debug.WriteLine("Test " + this.filteredTestPaths[i] + "(" + i + ")" + " passed: " + result.Success());
+ System.Diagnostics.Debug.WriteLine("Test " + this.filteredTestPaths[i] + "(" + i + ")" + " passed: " + result.Success() + " should be: " + positiveTest);
// FIXME: This likely deserves a better check.
- bool positiveTest = !script.Contains("@negative");
if (positiveTest != result.Success())
this.failedTests.Add(result);
@@ -152,7 +161,7 @@ private void FailedTestClickedCallback(object sender, System.Windows.Input.Gestu
if (FailedTestsListSelector.SelectedItem is TestRunnerComponent.ScriptResult)
{
TestRunnerComponent.ScriptResult result = (TestRunnerComponent.ScriptResult)FailedTestsListSelector.SelectedItem;
- MessageBox.Show(result.TestPath() + "\n" + result.ExceptionString());
+ MessageBox.Show(result.ExceptionString());
}
}
View
7 Source/JavaScriptCore/TestRunner/TestRunner.csproj
@@ -36,6 +36,7 @@
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
@@ -46,6 +47,7 @@
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@@ -78,6 +80,7 @@
<NoConfig>true</NoConfig>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
+ <RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|ARM' ">
<DebugType>pdbonly</DebugType>
@@ -126,6 +129,10 @@
<None Include="Properties\WMAppManifest.xml">
<SubType>Designer</SubType>
</None>
+ <None Include="TestRunner_2013_10_12_10_58_44.sap" />
+ <None Include="TestRunner_2013_10_12_10_59_58.sap" />
+ <None Include="TestRunner_2013_10_12_11_01_32.sap" />
+ <None Include="TestRunner_2013_10_12_11_01_44.sap" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\AlignmentGrid.png" />
View
19 Source/JavaScriptCore/TestRunner/TestRunner.csproj.user
@@ -1,5 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
+ <CurrentDeployCmdId>256</CurrentDeployCmdId>
+ <CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
+ <CurrentDeployCmdId>256</CurrentDeployCmdId>
+ <CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
+ </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
<CurrentDeployCmdId>256</CurrentDeployCmdId>
<CurrentDeployID>30F105C9-681E-420b-A277-7C086EAD8A4E</CurrentDeployID>
@@ -8,14 +16,19 @@
<CurrentDeployCmdId>256</CurrentDeployCmdId>
<CurrentDeployID>30F105C9-681E-420b-A277-7C086EAD8A4E</CurrentDeployID>
</PropertyGroup>
- <PropertyGroup>
- <ProjectView>ProjectFiles</ProjectView>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
+ <CurrentDeployCmdId>256</CurrentDeployCmdId>
+ <CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
+ <CurrentDeployCmdId>256</CurrentDeployCmdId>
+ <CurrentDeployID>5E7661DF-D928-40ff-B747-A4B1957194F9</CurrentDeployID>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{C089C8C0-30E0-4E22-80C0-CE093F111A43}">
<SilverlightMobileCSProjectFlavor>
- <FullDeploy>False</FullDeploy>
+ <FullDeploy>True</FullDeploy>
<DebuggerType>Native</DebuggerType>
<DebuggerAgentType>Native</DebuggerAgentType>
<Tombstone>False</Tombstone>
View
53 Source/JavaScriptCore/TestRunnerComponent/TestRunnerComponent.cpp
@@ -1,6 +1,8 @@
// TestRunnerComponent.cpp
#include "TestRunnerComponent.h"
+#include <JavaScriptCore/JSContextRef.h>
+#include <JavaScriptCore/JSStringRef.h>
#include <string>
#include <windows.h>
@@ -13,7 +15,7 @@ ScriptRunner::ScriptRunner()
{
}
-std::string convertPlatformStringtoUTF8(Platform::String^ in)
+static std::string convertPlatformStringtoUTF8(Platform::String^ in)
{
size_t sizeRequired = WideCharToMultiByte(CP_UTF8, 0, in->Data(), in->Length(), NULL, 0, NULL, NULL);
std::string result(sizeRequired, 0);
@@ -21,7 +23,7 @@ std::string convertPlatformStringtoUTF8(Platform::String^ in)
return result;
}
-Platform::String^ convertUTF8ToPlatformString(std::string utf8)
+static Platform::String^ convertUTF8ToPlatformString(std::string utf8)
{
size_t sizeRequired = MultiByteToWideChar(CP_UTF8, 0, utf8.c_str(), -1, NULL, 0);
std::wstring result(sizeRequired, 0);
@@ -29,12 +31,57 @@ Platform::String^ convertUTF8ToPlatformString(std::string utf8)
return ref new Platform::String(result.c_str());
}
+static std::string convertJSStringToUTF8(JSStringRef jsString)
+{
+ size_t bytesNeeded = JSStringGetMaximumUTF8CStringSize(jsString);
+
+ std::string result;
+ result.resize(bytesNeeded, '\0');
+ JSStringGetUTF8CString(jsString, &result[0], bytesNeeded);
+
+ return result;
+}
+
+static std::string jsValueGetString(JSContextRef context, JSValueRef value)
+{
+ JSStringRef jsString = JSValueToStringCopy(context, value, NULL);
+ std::string result = convertJSStringToUTF8(jsString);
+ JSStringRelease(jsString);
+ return result;
+}
+
ScriptResult^ ScriptRunner::RunScript(Platform::String^ script, Platform::String^ fileName)
{
std::string scriptString = convertPlatformStringtoUTF8(script);
std::string fileNameString = convertPlatformStringtoUTF8(fileName);
std::string exceptionString;
- bool success = !jscmainRepeatable(scriptString.c_str(), fileNameString.c_str(), exceptionString);
+
+ JSGlobalContextRef context = JSGlobalContextCreate(NULL);
+ JSStringRef jsScriptString = JSStringCreateWithUTF8CString(scriptString.c_str());
+ JSStringRef jsFilenameString = JSStringCreateWithUTF8CString(fileNameString.c_str());
+ JSValueRef exception = NULL;
+
+ JSValueRef result = JSEvaluateScript(context, jsScriptString, NULL, jsFilenameString, 0, &exception);
+ bool success = result && !exception;
+ JSStringRelease(jsScriptString);
+ JSStringRelease(jsFilenameString);
+
+ if (result)
+ JSValueUnprotect(context, result);
+
+ if (exception) {
+ JSStringRef jsStackString = JSStringCreateWithUTF8CString("stack");
+ JSValueRef stack = JSObjectGetProperty(context, JSValueToObject(context, exception, NULL), jsStackString, NULL);
+ JSStringRelease(jsStackString);
+
+ exceptionString = jsValueGetString(context, exception) + "\n" + jsValueGetString(context, stack);
+
+ JSValueUnprotect(context, stack);
+ JSValueUnprotect(context, exception);
+ }
+
+ JSGarbageCollect(context);
+ JSGlobalContextRelease(context);
return ref new ScriptResult(success, fileName, convertUTF8ToPlatformString(exceptionString));
}
View
11 Source/JavaScriptCore/TestRunnerComponent/TestRunnerComponent.vcxproj
@@ -90,6 +90,7 @@
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalUsingDirectories>$(WindowsSDK_MetadataPath);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
<CompileAsWinRT>true</CompileAsWinRT>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
@@ -138,16 +139,6 @@
<ClInclude Include="TestRunnerComponent.h" />
</ItemGroup>
<ItemGroup>
- <ClCompile Include="..\jsc.cpp">
- <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">false</CompileAsWinRT>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">_CRT_SECURE_NO_WARNINGS;_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">_CRT_SECURE_NO_WARNINGS;_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">_CRT_SECURE_NO_WARNINGS;_WINRT_DLL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">_CRT_SECURE_NO_WARNINGS;_WINRT_DLL;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
- <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</CompileAsWinRT>
- <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsWinRT>
- <CompileAsWinRT Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsWinRT>
- </ClCompile>
<ClCompile Include="TestRunnerComponent.cpp" />
</ItemGroup>
<ItemGroup>
View
1  Source/JavaScriptCore/TestRunnerComponent/TestRunnerComponent.vcxproj.filters
@@ -8,7 +8,6 @@
</ItemGroup>
<ItemGroup>
<ClCompile Include="TestRunnerComponent.cpp" />
- <ClCompile Include="..\jsc.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="TestRunnerComponent.h" />
View
30 Source/WTF/wtf/ThreadingStdThread.cpp
@@ -53,12 +53,6 @@ class StdThreadState {
public:
enum JoinableState {
Joinable, // The default thread state. The thread can be joined on.
-
- Joined, // Somebody waited on this thread to exit and this thread finally exited. This state is here because there can be a
- // period of time between when the thread exits (which causes pthread_join to return and the remainder of waitOnThreadCompletion to run)
- // and when threadDidExit is called. We need threadDidExit to take charge and delete the thread data since there's
- // nobody else to pick up the slack in this case (since waitOnThreadCompletion has already returned).
-
Detached // The thread has been detached and can no longer be joined on. At this point, the thread must take care of cleaning up after itself.
};
@@ -87,7 +81,6 @@ class StdThreadState {
std::thread::id stdThreadID() { return m_stdThreadID; }
void didBecomeDetached() { m_joinableState = Detached; }
void didExit() { m_didExit = true; }
- void didJoin() { m_joinableState = Joined; }
bool hasExited() { return m_didExit; }
private:
@@ -140,7 +133,7 @@ static ThreadIdentifier establishIdentifierForStdThreadState(StdThreadState* thr
static ThreadIdentifier establishIdentifierForStdThread(std::thread* threadInstance)
{
- return establishIdentifierForStdThreadState(new StdThreadState(threadInstance));
+ return establishIdentifierForStdThreadState(new StdThreadState(threadInstance));
}
static ThreadIdentifier establishIdentifierForStdThreadID(std::thread::id stdThreadID)
@@ -148,7 +141,7 @@ static ThreadIdentifier establishIdentifierForStdThreadID(std::thread::id stdThr
return establishIdentifierForStdThreadState(new StdThreadState(stdThreadID));
}
-static std::thread * stdThreadForIdentifierWithLockAlreadyHeld(ThreadIdentifier id)
+static std::thread* stdThreadForIdentifierWithLockAlreadyHeld(ThreadIdentifier id)
{
return threadMap().get(id)->threadInstance();
}
@@ -192,6 +185,17 @@ static void* wtfThreadEntryPoint(void* param)
ThreadSpecificThreadExit();
+ ThreadIdentifier currentThreadId = identifierByStdThreadID(std::this_thread::get_id());
+ {
+ MutexLocker locker(threadMapMutex());
+ StdThreadState* state = threadMap().get(currentThreadId);
+ ASSERT(state);
+ state->didExit();
+
+ if (state->joinableState() != StdThreadState::Joinable)
+ threadMap().remove(currentThreadId);
+ }
+
return 0;
}
@@ -247,12 +251,8 @@ int waitForThreadCompletion(ThreadIdentifier threadID)
ASSERT(state->joinableState() == StdThreadState::Joinable);
// The thread has already exited, so clean up after it.
- if (state->hasExited())
- threadMap().remove(threadID);
- // The thread hasn't exited yet, so don't clean anything up. Just signal
- // that we've already joined on it so that it will clean up after itself.
- else
- state->didJoin();
+ ASSERT(state->hasExited());
+ threadMap().remove(threadID);
return joinResult;
}

No commit comments for this range

Something went wrong with that request. Please try again.