Diff
Modified: trunk/JSTests/ChangeLog (210148 => 210149)
--- trunk/JSTests/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/JSTests/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,13 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ * stress/source-origin.js: Added.
+ (shouldBe):
+
2016-12-24 Caio Lima <[email protected]>
[test262] Fixing mapped arguments object property test case
Added: trunk/JSTests/stress/source-origin.js (0 => 210149)
--- trunk/JSTests/stress/source-origin.js (rev 0)
+++ trunk/JSTests/stress/source-origin.js 2016-12-26 06:35:07 UTC (rev 210149)
@@ -0,0 +1,11 @@
+function shouldBe(actual, expected) {
+ if (actual !== expected)
+ throw new Error('bad value: ' + actual);
+}
+
+shouldBe(callerSourceOrigin().endsWith('source-origin.js'), true);
+shouldBe([ 0 ].map(callerSourceOrigin)[0].endsWith('source-origin.js'), true);
+shouldBe(eval(`callerSourceOrigin()`).endsWith('source-origin.js'), true);
+shouldBe((0, eval)(`callerSourceOrigin()`).endsWith('source-origin.js'), true);
+shouldBe((new Function(`return callerSourceOrigin()`))().endsWith('source-origin.js'), true);
+shouldBe((Function(`return callerSourceOrigin()`))().endsWith('source-origin.js'), true);
Modified: trunk/Source/_javascript_Core/API/JSBase.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/API/JSBase.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/API/JSBase.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -62,7 +62,8 @@
// evaluate sets "this" to the global object if it is NULL
JSGlobalObject* globalObject = exec->vmEntryGlobalObject();
- SourceCode source = makeSource(script->string(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
+ auto sourceURLString = sourceURL ? sourceURL->string() : String();
+ SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
NakedPtr<Exception> evaluationException;
JSValue returnValue = profiledEvaluate(globalObject->globalExec(), ProfilingReason::API, source, jsThisObject, evaluationException);
@@ -99,7 +100,8 @@
startingLineNumber = std::max(1, startingLineNumber);
- SourceCode source = makeSource(script->string(), sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
+ auto sourceURLString = sourceURL ? sourceURL->string() : String();
+ SourceCode source = makeSource(script->string(), SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
JSValue syntaxException;
bool isValidSyntax = checkSyntax(exec->vmEntryGlobalObject()->globalExec(), source, &syntaxException);
Modified: trunk/Source/_javascript_Core/API/JSObjectRef.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/API/JSObjectRef.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -146,7 +146,8 @@
args.append(jsString(exec, parameterNames[i]->string()));
args.append(jsString(exec, body->string()));
- JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, sourceURL ? sourceURL->string() : String(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
+ auto sourceURLString = sourceURL ? sourceURL->string() : String();
+ JSObject* result = constructFunction(exec, exec->lexicalGlobalObject(), args, nameID, SourceOrigin { sourceURLString }, sourceURLString, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()));
if (handleExceptionIfNeeded(exec, exception) == ExceptionStatus::DidThrow)
result = 0;
return toRef(result);
Modified: trunk/Source/_javascript_Core/API/JSScriptRef.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/API/JSScriptRef.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/API/JSScriptRef.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -41,9 +41,9 @@
struct OpaqueJSScript : public SourceProvider {
public:
- static WTF::RefPtr<OpaqueJSScript> create(VM* vm, const String& url, int startingLineNumber, const String& source)
+ static WTF::RefPtr<OpaqueJSScript> create(VM& vm, const SourceOrigin& sourceOrigin, const String& url, int startingLineNumber, const String& source)
{
- return WTF::adoptRef(*new OpaqueJSScript(vm, url, startingLineNumber, source));
+ return WTF::adoptRef(*new OpaqueJSScript(vm, sourceOrigin, url, startingLineNumber, source));
}
unsigned hash() const override
@@ -56,11 +56,11 @@
return m_source.get();
}
- VM* vm() const { return m_vm; }
+ VM& vm() const { return m_vm; }
private:
- OpaqueJSScript(VM* vm, const String& url, int startingLineNumber, const String& source)
- : SourceProvider(url, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()), SourceProviderSourceType::Program)
+ OpaqueJSScript(VM& vm, const SourceOrigin& sourceOrigin, const String& url, int startingLineNumber, const String& source)
+ : SourceProvider(sourceOrigin, url, TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber()), SourceProviderSourceType::Program)
, m_vm(vm)
, m_source(source.isNull() ? *StringImpl::empty() : *source.impl())
{
@@ -68,14 +68,14 @@
virtual ~OpaqueJSScript() { }
- VM* m_vm;
+ VM& m_vm;
Ref<StringImpl> m_source;
};
-static bool parseScript(VM* vm, const SourceCode& source, ParserError& error)
+static bool parseScript(VM& vm, const SourceCode& source, ParserError& error)
{
return !!JSC::parse<JSC::ProgramNode>(
- vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
+ &vm, source, Identifier(), JSParserBuiltinMode::NotBuiltin,
JSParserStrictMode::NotStrict, JSParserScriptMode::Classic, SourceParseMode::ProgramMode, SuperBinding::NotNeeded,
error);
}
@@ -84,8 +84,8 @@
JSScriptRef JSScriptCreateReferencingImmortalASCIIText(JSContextGroupRef contextGroup, JSStringRef url, int startingLineNumber, const char* source, size_t length, JSStringRef* errorMessage, int* errorLine)
{
- VM* vm = toJS(contextGroup);
- JSLockHolder locker(vm);
+ auto& vm = *toJS(contextGroup);
+ JSLockHolder locker(&vm);
for (size_t i = 0; i < length; i++) {
if (!isASCII(source[i]))
return 0;
@@ -93,7 +93,8 @@
startingLineNumber = std::max(1, startingLineNumber);
- auto result = OpaqueJSScript::create(vm, url ? url->string() : String(), startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
+ auto sourceURLString = url ? url->string() : String();
+ auto result = OpaqueJSScript::create(vm, SourceOrigin { sourceURLString }, sourceURLString, startingLineNumber, String(StringImpl::createFromLiteral(source, length)));
ParserError error;
if (!parseScript(vm, SourceCode(result), error)) {
@@ -109,12 +110,13 @@
JSScriptRef JSScriptCreateFromString(JSContextGroupRef contextGroup, JSStringRef url, int startingLineNumber, JSStringRef source, JSStringRef* errorMessage, int* errorLine)
{
- VM* vm = toJS(contextGroup);
- JSLockHolder locker(vm);
+ auto& vm = *toJS(contextGroup);
+ JSLockHolder locker(&vm);
startingLineNumber = std::max(1, startingLineNumber);
- auto result = OpaqueJSScript::create(vm, url ? url->string() : String(), startingLineNumber, source->string());
+ auto sourceURLString = url ? url->string() : String();
+ auto result = OpaqueJSScript::create(vm, SourceOrigin { sourceURLString }, sourceURLString, startingLineNumber, source->string());
ParserError error;
if (!parseScript(vm, SourceCode(result), error)) {
@@ -130,13 +132,13 @@
void JSScriptRetain(JSScriptRef script)
{
- JSLockHolder locker(script->vm());
+ JSLockHolder locker(&script->vm());
script->ref();
}
void JSScriptRelease(JSScriptRef script)
{
- JSLockHolder locker(script->vm());
+ JSLockHolder locker(&script->vm());
script->deref();
}
@@ -144,7 +146,7 @@
{
ExecState* exec = toJS(context);
JSLockHolder locker(exec);
- if (script->vm() != &exec->vm()) {
+ if (&script->vm() != &exec->vm()) {
RELEASE_ASSERT_NOT_REACHED();
return 0;
}
Modified: trunk/Source/_javascript_Core/ChangeLog (210148 => 210149)
--- trunk/Source/_javascript_Core/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,106 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ This patch introduces CallFrame::callerSourceOrigin, SourceOrigin class
+ and SourceProvider::m_sourceOrigin. CallFrame::callerSourceOrigin returns
+ an appropriate SourceOrigin if possible. If we cannot find the appropriate
+ one, we just return null SourceOrigin.
+
+ This paves the way for implementing the module dynamic-import[1].
+ When the import operator is evaluated, it will resolve the module
+ specifier with this propagated source origin of the caller function.
+
+ To support import operator inside the dynamic code generation
+ functions (like `eval`, `new Function`, indirect call to `eval`),
+ we need to propagate the caller's source origin to the generated
+ source code.
+
+ We do not use sourceURL for that purpose. This is because we
+ would like to keep sourceURL for `eval` / `new Function` null.
+ This sourceURL will be used for the stack dump for errors with line/column
+ numbers. Dumping the caller's sourceURL with line/column numbers are
+ meaningless. So we would like to keep it null while we would like
+ to propagate SourceOrigin for dynamic imports.
+
+ [1]: https://github.com/tc39/proposal-dynamic-import
+
+ * API/JSBase.cpp:
+ (JSEvaluateScript):
+ (JSCheckScriptSyntax):
+ * API/JSObjectRef.cpp:
+ (JSObjectMakeFunction):
+ * API/JSScriptRef.cpp:
+ (OpaqueJSScript::create):
+ (OpaqueJSScript::vm):
+ (OpaqueJSScript::OpaqueJSScript):
+ (parseScript):
+ * _javascript_Core.xcodeproj/project.pbxproj:
+ * Scripts/builtins/builtins_templates.py:
+ * Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result:
+ * Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result:
+ * Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result:
+ * Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result:
+ * Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result:
+ * Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result:
+ * builtins/BuiltinExecutables.cpp:
+ (JSC::BuiltinExecutables::BuiltinExecutables):
+ (JSC::BuiltinExecutables::createDefaultConstructor):
+ * debugger/DebuggerCallFrame.cpp:
+ (JSC::DebuggerCallFrame::evaluateWithScopeExtension):
+ * inspector/InjectedScriptManager.cpp:
+ (Inspector::InjectedScriptManager::createInjectedScript):
+ * inspector/JSInjectedScriptHost.cpp:
+ (Inspector::JSInjectedScriptHost::evaluateWithScopeExtension):
+ * inspector/agents/InspectorRuntimeAgent.cpp:
+ (Inspector::InspectorRuntimeAgent::parse):
+ * interpreter/CallFrame.cpp:
+ (JSC::CallFrame::callerSourceOrigin):
+ * interpreter/CallFrame.h:
+ * interpreter/Interpreter.cpp:
+ (JSC::eval):
+ * jsc.cpp:
+ (jscSource):
+ (GlobalObject::finishCreation):
+ (extractDirectoryName):
+ (currentWorkingDirectory):
+ (GlobalObject::moduleLoaderResolve):
+ (functionRunString):
+ (functionLoadString):
+ (functionCallerSourceOrigin):
+ (functionCreateBuiltin):
+ (functionCheckModuleSyntax):
+ (runInteractive):
+ * parser/SourceCode.h:
+ (JSC::makeSource):
+ * parser/SourceProvider.cpp:
+ (JSC::SourceProvider::SourceProvider):
+ * parser/SourceProvider.h:
+ (JSC::SourceProvider::sourceOrigin):
+ (JSC::StringSourceProvider::create):
+ (JSC::StringSourceProvider::StringSourceProvider):
+ (JSC::WebAssemblySourceProvider::create):
+ (JSC::WebAssemblySourceProvider::WebAssemblySourceProvider):
+ * runtime/FunctionConstructor.cpp:
+ (JSC::constructFunction):
+ (JSC::constructFunctionSkippingEvalEnabledCheck):
+ * runtime/FunctionConstructor.h:
+ * runtime/JSGlobalObjectFunctions.cpp:
+ (JSC::globalFuncEval):
+ * runtime/ModuleLoaderPrototype.cpp:
+ (JSC::moduleLoaderPrototypeParseModule):
+ * runtime/ScriptExecutable.h:
+ (JSC::ScriptExecutable::sourceOrigin):
+ * runtime/SourceOrigin.h: Added.
+ (JSC::SourceOrigin::SourceOrigin):
+ (JSC::SourceOrigin::string):
+ (JSC::SourceOrigin::isNull):
+ * tools/FunctionOverrides.cpp:
+ (JSC::initializeOverrideInfo):
+
2016-12-24 Caio Lima <[email protected]>
[test262] Fixing mapped arguments object property test case
Modified: trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj (210148 => 210149)
--- trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/_javascript_Core.xcodeproj/project.pbxproj 2016-12-26 06:35:07 UTC (rev 210149)
@@ -2361,6 +2361,7 @@
FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */; };
FEFD6FC61D5E7992008F2F0B /* JSStringInlines.h in Headers */ = {isa = PBXBuildFile; fileRef = FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ 2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */ = {isa = PBXBuildFile; fileRef = 425BA1337E4344E1B269A671 /* SourceOrigin.h */; settings = {ATTRIBUTES = (Private, ); }; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@@ -4878,6 +4879,7 @@
FEF040501AAE662D00BD28B0 /* CompareAndSwapTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CompareAndSwapTest.cpp; path = API/tests/CompareAndSwapTest.cpp; sourceTree = "<group>"; };
FEF040521AAEC4ED00BD28B0 /* CompareAndSwapTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CompareAndSwapTest.h; path = API/tests/CompareAndSwapTest.h; sourceTree = "<group>"; };
FEFD6FC51D5E7970008F2F0B /* JSStringInlines.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSStringInlines.h; sourceTree = "<group>"; };
+ 425BA1337E4344E1B269A671 /* SourceOrigin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SourceOrigin.h; path = SourceOrigin.h; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -6707,6 +6709,7 @@
709FB8661AE335C60039D069 /* WeakSetPrototype.h */,
A7DCB77912E3D90500911940 /* WriteBarrier.h */,
C2B6D75218A33793004A9301 /* WriteBarrierInlines.h */,
+ 425BA1337E4344E1B269A671 /* SourceOrigin.h */,
);
path = runtime;
sourceTree = "<group>";
@@ -9075,6 +9078,7 @@
86704B8812DBA33700A9FE7B /* YarrParser.h in Headers */,
86704B8A12DBA33700A9FE7B /* YarrPattern.h in Headers */,
86704B4312DB8A8100A9FE7B /* YarrSyntaxChecker.h in Headers */,
+ 2D342F36F7244096804ADB24 /* SourceOrigin.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: trunk/Source/_javascript_Core/Scripts/builtins/builtins_templates.py (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/builtins/builtins_templates.py 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/builtins/builtins_templates.py 2016-12-26 06:35:07 UTC (rev 210149)
@@ -132,7 +132,7 @@
explicit ${objectName}BuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
${macroPrefix}_FOREACH_${objectMacro}_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-AnotherGuardedInternalBuiltin-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -70,7 +70,7 @@
explicit AnotherGuardedInternalBuiltinBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_ANOTHERGUARDEDINTERNALBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-ArbitraryConditionalGuard-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -71,7 +71,7 @@
explicit ArbitraryConditionalGuardBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_ARBITRARYCONDITIONALGUARD_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedBuiltin-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -71,7 +71,7 @@
explicit GuardedBuiltinBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_GUARDEDBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-GuardedInternalBuiltin-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -71,7 +71,7 @@
explicit GuardedInternalBuiltinBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_GUARDEDINTERNALBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-UnguardedBuiltin-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -69,7 +69,7 @@
explicit UnguardedBuiltinBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_UNGUARDEDBUILTIN_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result (210148 => 210149)
--- trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/Scripts/tests/builtins/expected/WebCore-xmlCasingTest-Separate.js-result 2016-12-26 06:35:07 UTC (rev 210149)
@@ -85,7 +85,7 @@
explicit xmlCasingTestBuiltinsWrapper(JSC::VM* vm)
: m_vm(*vm)
WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_FUNCTION_NAME(INITIALIZE_BUILTIN_NAMES)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(JSC::makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
WEBCORE_FOREACH_XMLCASINGTEST_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef INITIALIZE_BUILTIN_SOURCE_MEMBERS
{
Modified: trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/builtins/BuiltinExecutables.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -36,7 +36,7 @@
BuiltinExecutables::BuiltinExecutables(VM& vm)
: m_vm(vm)
-#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length)))
+#define INITIALIZE_BUILTIN_SOURCE_MEMBERS(name, functionName, length) , m_##name##Source(makeSource(StringImpl::createFromLiteral(s_##name, length), { }))
JSC_FOREACH_BUILTIN_CODE(INITIALIZE_BUILTIN_SOURCE_MEMBERS)
#undef EXPOSE_BUILTIN_STRINGS
{
@@ -51,9 +51,9 @@
case ConstructorKind::None:
break;
case ConstructorKind::Base:
- return createExecutable(m_vm, makeSource(baseConstructorCode), name, constructorKind, ConstructAbility::CanConstruct);
+ return createExecutable(m_vm, makeSource(baseConstructorCode, { }), name, constructorKind, ConstructAbility::CanConstruct);
case ConstructorKind::Extends:
- return createExecutable(m_vm, makeSource(derivedConstructorCode), name, constructorKind, ConstructAbility::CanConstruct);
+ return createExecutable(m_vm, makeSource(derivedConstructorCode, { }), name, constructorKind, ConstructAbility::CanConstruct);
}
ASSERT_NOT_REACHED();
return nullptr;
Modified: trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/debugger/DebuggerCallFrame.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -243,7 +243,7 @@
VariableEnvironment variablesUnderTDZ;
JSScope::collectClosureVariablesUnderTDZ(scope()->jsScope(), variablesUnderTDZ);
- EvalExecutable* eval = DirectEvalExecutable::create(callFrame, makeSource(script), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
+ auto* eval = DirectEvalExecutable::create(callFrame, makeSource(script, callFrame->callerSourceOrigin()), codeBlock->isStrictMode(), codeBlock->unlinkedCodeBlock()->derivedContextType(), codeBlock->unlinkedCodeBlock()->isArrowFunction(), evalContextType, &variablesUnderTDZ);
if (UNLIKELY(catchScope.exception())) {
exception = catchScope.exception();
catchScope.clearException();
Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptManager.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -138,7 +138,7 @@
JSLockHolder lock(vm);
auto scope = DECLARE_CATCH_SCOPE(vm);
- SourceCode sourceCode = makeSource(source);
+ SourceCode sourceCode = makeSource(source, { });
JSGlobalObject* globalObject = scriptState->lexicalGlobalObject();
JSValue globalThisValue = scriptState->globalThisValue();
Modified: trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/inspector/JSInjectedScriptHost.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -107,7 +107,7 @@
NakedPtr<Exception> exception;
JSObject* scopeExtension = exec->argument(1).getObject();
- JSValue result = JSC::evaluateWithScopeExtension(exec, makeSource(program), scopeExtension, exception);
+ JSValue result = JSC::evaluateWithScopeExtension(exec, makeSource(program, exec->callerSourceOrigin()), scopeExtension, exception);
if (exception)
throwException(exec, scope, exception);
Modified: trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/inspector/agents/InspectorRuntimeAgent.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -89,7 +89,7 @@
JSLockHolder lock(m_vm);
ParserError error;
- checkSyntax(m_vm, JSC::makeSource(_expression_), error);
+ checkSyntax(m_vm, JSC::makeSource(_expression_, { }), error);
switch (error.syntaxErrorType()) {
case ParserError::SyntaxErrorNone:
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -217,6 +217,48 @@
return static_cast<CallFrame*>(unsafeCallerFrameOrVMEntryFrame());
}
+SourceOrigin CallFrame::callerSourceOrigin()
+{
+ SourceOrigin sourceOrigin;
+ bool haveSkippedFirstFrame = false;
+ StackVisitor::visit(this, [&](StackVisitor& visitor) {
+ if (!std::exchange(haveSkippedFirstFrame, true))
+ return StackVisitor::Status::Continue;
+
+ switch (visitor->codeType()) {
+ case StackVisitor::Frame::CodeType::Function:
+ // Skip the builtin functions since they should not pass the source origin to the dynamic code generation calls.
+ // Consider the following code.
+ //
+ // [ "42 + 44" ].forEach(eval);
+ //
+ // In the above case, the eval function will be interpreted as the indirect call to eval inside forEach function.
+ // At that time, the generated eval code should have the source origin to the original caller of the forEach function
+ // instead of the source origin of the forEach function.
+ if (static_cast<FunctionExecutable*>(visitor->codeBlock()->ownerScriptExecutable())->isBuiltinFunction())
+ return StackVisitor::Status::Continue;
+ FALLTHROUGH;
+
+ case StackVisitor::Frame::CodeType::Eval:
+ case StackVisitor::Frame::CodeType::Module:
+ case StackVisitor::Frame::CodeType::Global:
+ sourceOrigin = visitor->codeBlock()->ownerScriptExecutable()->sourceOrigin();
+ return StackVisitor::Status::Done;
+
+ case StackVisitor::Frame::CodeType::Native:
+ return StackVisitor::Status::Continue;
+
+ case StackVisitor::Frame::CodeType::Wasm:
+ // FIXME: Should return the source origin for WASM.
+ return StackVisitor::Status::Done;
+ }
+
+ RELEASE_ASSERT_NOT_REACHED();
+ return StackVisitor::Status::Done;
+ });
+ return sourceOrigin;
+}
+
String CallFrame::friendlyFunctionName()
{
CodeBlock* codeBlock = this->codeBlock();
Modified: trunk/Source/_javascript_Core/interpreter/CallFrame.h (210148 => 210149)
--- trunk/Source/_javascript_Core/interpreter/CallFrame.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/interpreter/CallFrame.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -137,6 +137,8 @@
CallFrame* unsafeCallerFrame(VMEntryFrame*&);
JS_EXPORT_PRIVATE CallFrame* callerFrame(VMEntryFrame*&);
+ JS_EXPORT_PRIVATE SourceOrigin callerSourceOrigin();
+
static ptrdiff_t callerFrameOffset() { return OBJECT_OFFSETOF(CallerFrameAndPC, callerFrame); }
ReturnAddressPtr returnPC() const { return ReturnAddressPtr(callerFrameAndPC().pc); }
Modified: trunk/Source/_javascript_Core/interpreter/Interpreter.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/interpreter/Interpreter.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -151,7 +151,7 @@
VariableEnvironment variablesUnderTDZ;
JSScope::collectClosureVariablesUnderTDZ(callerScopeChain, variablesUnderTDZ);
- eval = DirectEvalExecutable::create(callFrame, makeSource(programSource), callerCodeBlock->isStrictMode(), derivedContextType, isArrowFunctionContext, evalContextType, &variablesUnderTDZ);
+ eval = DirectEvalExecutable::create(callFrame, makeSource(programSource, callerCodeBlock->source()->sourceOrigin()), callerCodeBlock->isStrictMode(), derivedContextType, isArrowFunctionContext, evalContextType, &variablesUnderTDZ);
if (!eval)
return jsUndefined();
Modified: trunk/Source/_javascript_Core/jsc.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/jsc.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/jsc.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1009,6 +1009,7 @@
static EncodedJSValue JSC_HOST_CALL functionGetRandomSeed(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionSetRandomSeed(ExecState*);
static EncodedJSValue JSC_HOST_CALL functionIsRope(ExecState*);
+static EncodedJSValue JSC_HOST_CALL functionCallerSourceOrigin(ExecState*);
struct Script {
enum class StrictMode {
@@ -1103,7 +1104,7 @@
static inline SourceCode jscSource(const Vector& utf8, const String& filename)
{
String str = stringFromUTF(utf8);
- return makeSource(str, filename);
+ return makeSource(str, SourceOrigin { filename }, filename);
}
class GlobalObject : public JSGlobalObject {
@@ -1232,6 +1233,7 @@
addFunction(vm, "getRandomSeed", functionGetRandomSeed, 0);
addFunction(vm, "setRandomSeed", functionSetRandomSeed, 1);
addFunction(vm, "isRope", functionIsRope, 1);
+ addFunction(vm, "callerSourceOrigin", functionCallerSourceOrigin, 0);
addFunction(vm, "is32BitPlatform", functionIs32BitPlatform, 0);
@@ -1332,11 +1334,12 @@
moduleName.split('/', true, queries);
}
-static bool extractDirectoryName(const String& absolutePathToFile, DirectoryName& directoryName)
+static std::optional<DirectoryName> extractDirectoryName(const String& absolutePathToFile)
{
size_t firstSeparatorPosition = absolutePathToFile.find(pathSeparator());
if (firstSeparatorPosition == notFound)
- return false;
+ return std::nullopt;
+ DirectoryName directoryName;
directoryName.rootName = absolutePathToFile.substring(0, firstSeparatorPosition + 1); // Include the separator.
size_t lastSeparatorPosition = absolutePathToFile.reverseFind(pathSeparator());
ASSERT_WITH_MESSAGE(lastSeparatorPosition != notFound, "If the separator is not found, this function already returns when performing the forward search.");
@@ -1347,10 +1350,10 @@
size_t queryLength = lastSeparatorPosition - queryStartPosition; // Not include the last separator.
directoryName.queryName = absolutePathToFile.substring(queryStartPosition, queryLength);
}
- return true;
+ return directoryName;
}
-static bool currentWorkingDirectory(DirectoryName& directoryName)
+static std::optional<DirectoryName> currentWorkingDirectory()
{
#if OS(WINDOWS)
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364934.aspx
@@ -1364,7 +1367,7 @@
// In the path utility functions inside the JSC shell, we does not handle the UNC and UNCW including the network host name.
DWORD bufferLength = ::GetCurrentDirectoryW(0, nullptr);
if (!bufferLength)
- return false;
+ return std::nullopt;
// In Windows, wchar_t is the UTF-16LE.
// https://msdn.microsoft.com/en-us/library/dd374081.aspx
// https://msdn.microsoft.com/en-us/library/windows/desktop/ff381407.aspx
@@ -1374,20 +1377,20 @@
String directoryString = String(reinterpret_cast<UChar*>(buffer.get()));
// We don't support network path like \\host\share\<path name>.
if (directoryString.startsWith("\\\\"))
- return false;
+ return std::nullopt;
#else
auto buffer = std::make_unique<char[]>(PATH_MAX);
if (!getcwd(buffer.get(), PATH_MAX))
- return false;
+ return std::nullopt;
String directoryString = String::fromUTF8(buffer.get());
#endif
if (directoryString.isEmpty())
- return false;
+ return std::nullopt;
if (directoryString[directoryString.length() - 1] == pathSeparator())
- return extractDirectoryName(directoryString, directoryName);
+ return extractDirectoryName(directoryString);
// Append the seperator to represents the file name. extractDirectoryName only accepts the absolute file name.
- return extractDirectoryName(makeString(directoryString, pathSeparator()), directoryName);
+ return extractDirectoryName(makeString(directoryString, pathSeparator()));
}
static String resolvePath(const DirectoryName& directoryName, const ModuleName& moduleName)
@@ -1433,28 +1436,32 @@
if (key.isSymbol())
return deferred->resolve(exec, keyValue);
- DirectoryName directoryName;
if (referrerValue.isUndefined()) {
- if (!currentWorkingDirectory(directoryName))
+ auto directoryName = currentWorkingDirectory();
+ if (!directoryName)
return deferred->reject(exec, createError(exec, ASCIILiteral("Could not resolve the current working directory.")));
- } else {
- const Identifier referrer = referrerValue.toPropertyKey(exec);
- if (UNLIKELY(scope.exception())) {
- JSValue exception = scope.exception();
- scope.clearException();
- return deferred->reject(exec, exception);
- }
- if (referrer.isSymbol()) {
- if (!currentWorkingDirectory(directoryName))
- return deferred->reject(exec, createError(exec, ASCIILiteral("Could not resolve the current working directory.")));
- } else {
- // If the referrer exists, we assume that the referrer is the correct absolute path.
- if (!extractDirectoryName(referrer.impl(), directoryName))
- return deferred->reject(exec, createError(exec, makeString("Could not resolve the referrer name '", String(referrer.impl()), "'.")));
- }
+ return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
}
- return deferred->resolve(exec, jsString(exec, resolvePath(directoryName, ModuleName(key.impl()))));
+ const Identifier referrer = referrerValue.toPropertyKey(exec);
+ if (UNLIKELY(scope.exception())) {
+ JSValue exception = scope.exception();
+ scope.clearException();
+ return deferred->reject(exec, exception);
+ }
+
+ if (referrer.isSymbol()) {
+ auto directoryName = currentWorkingDirectory();
+ if (!directoryName)
+ return deferred->reject(exec, createError(exec, ASCIILiteral("Could not resolve the current working directory.")));
+ return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
+ }
+
+ // If the referrer exists, we assume that the referrer is the correct absolute path.
+ auto directoryName = extractDirectoryName(referrer.impl());
+ if (!directoryName)
+ return deferred->reject(exec, createError(exec, makeString("Could not resolve the referrer name '", String(referrer.impl()), "'.")));
+ return deferred->resolve(exec, jsString(exec, resolvePath(directoryName.value(), ModuleName(key.impl()))));
}
static void convertShebangToJSComment(Vector<char>& buffer)
@@ -1945,7 +1952,7 @@
vm, Identifier::fromString(globalObject->globalExec(), "arguments"), array);
NakedPtr<Exception> exception;
- evaluate(globalObject->globalExec(), makeSource(source), JSValue(), exception);
+ evaluate(globalObject->globalExec(), makeSource(source, exec->callerSourceOrigin()), JSValue(), exception);
if (exception) {
scope.throwException(globalObject->globalExec(), exception);
@@ -1985,7 +1992,7 @@
JSGlobalObject* globalObject = exec->lexicalGlobalObject();
NakedPtr<Exception> evaluationException;
- JSValue result = evaluate(globalObject->globalExec(), makeSource(sourceCode), JSValue(), evaluationException);
+ JSValue result = evaluate(globalObject->globalExec(), makeSource(sourceCode, exec->callerSourceOrigin()), JSValue(), evaluationException);
if (evaluationException)
throwException(exec, scope, evaluationException);
return JSValue::encode(result);
@@ -2106,6 +2113,14 @@
return JSValue::encode(jsBoolean(!impl));
}
+EncodedJSValue JSC_HOST_CALL functionCallerSourceOrigin(ExecState* state)
+{
+ SourceOrigin sourceOrigin = state->callerSourceOrigin();
+ if (sourceOrigin.isNull())
+ return JSValue::encode(jsNull());
+ return JSValue::encode(jsString(state, sourceOrigin.string()));
+}
+
EncodedJSValue JSC_HOST_CALL functionReadline(ExecState* exec)
{
Vector<char, 256> line;
@@ -2404,7 +2419,7 @@
String functionText = asString(exec->argument(0))->value(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
- const SourceCode& source = makeSource(functionText);
+ const SourceCode& source = makeSource(functionText, { });
JSFunction* func = JSFunction::createBuiltinFunction(vm, createBuiltinExecutable(vm, source, Identifier::fromString(&vm, "foo"), ConstructorKind::None, ConstructAbility::CannotConstruct)->link(vm, source), exec->lexicalGlobalObject());
return JSValue::encode(func);
@@ -2428,7 +2443,7 @@
stopWatch.start();
ParserError error;
- bool validSyntax = checkModuleSyntax(exec, makeSource(source, String(), TextPosition(), SourceProviderSourceType::Module), error);
+ bool validSyntax = checkModuleSyntax(exec, makeSource(source, { }, String(), TextPosition(), SourceProviderSourceType::Module), error);
stopWatch.stop();
if (!validSyntax)
@@ -2947,7 +2962,10 @@
VM& vm = globalObject->vm();
auto scope = DECLARE_CATCH_SCOPE(vm);
- String interpreterName(ASCIILiteral("Interpreter"));
+ std::optional<DirectoryName> directoryName = currentWorkingDirectory();
+ if (!directoryName)
+ return;
+ SourceOrigin sourceOrigin(resolvePath(directoryName.value(), ModuleName("interpreter")));
bool shouldQuit = false;
while (!shouldQuit) {
@@ -2962,7 +2980,7 @@
break;
source = source + line;
source = source + '\n';
- checkSyntax(globalObject->vm(), makeSource(source, interpreterName), error);
+ checkSyntax(globalObject->vm(), makeSource(source, sourceOrigin), error);
if (!line[0]) {
free(line);
break;
@@ -2978,7 +2996,7 @@
NakedPtr<Exception> evaluationException;
- JSValue returnValue = evaluate(globalObject->globalExec(), makeSource(source, interpreterName), JSValue(), evaluationException);
+ JSValue returnValue = evaluate(globalObject->globalExec(), makeSource(source, sourceOrigin), JSValue(), evaluationException);
#else
printf("%s", interactivePrompt);
Vector<char, 256> line;
@@ -2993,7 +3011,7 @@
break;
NakedPtr<Exception> evaluationException;
- JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(line, interpreterName), JSValue(), evaluationException);
+ JSValue returnValue = evaluate(globalObject->globalExec(), jscSource(line, sourceOrigin.string()), JSValue(), evaluationException);
#endif
if (evaluationException)
printf("Exception: %s\n", evaluationException->value().toWTFString(globalObject->globalExec()).utf8().data());
Modified: trunk/Source/_javascript_Core/parser/SourceCode.h (210148 => 210149)
--- trunk/Source/_javascript_Core/parser/SourceCode.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/parser/SourceCode.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -79,9 +79,9 @@
OrdinalNumber m_startColumn;
};
- inline SourceCode makeSource(const String& source, const String& url = "" const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
+ inline SourceCode makeSource(const String& source, const SourceOrigin& sourceOrigin, const String& url = "" const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
{
- return SourceCode(StringSourceProvider::create(source, url, startPosition, sourceType), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
+ return SourceCode(StringSourceProvider::create(source, sourceOrigin, url, startPosition, sourceType), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
}
inline SourceCode SourceCode::subExpression(unsigned openBrace, unsigned closeBrace, int firstLine, int startColumn)
Modified: trunk/Source/_javascript_Core/parser/SourceProvider.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -31,8 +31,9 @@
namespace JSC {
-SourceProvider::SourceProvider(const String& url, const TextPosition& startPosition, SourceProviderSourceType sourceType)
- : m_url(url)
+SourceProvider::SourceProvider(const SourceOrigin& sourceOrigin, const String& url, const TextPosition& startPosition, SourceProviderSourceType sourceType)
+ : m_sourceOrigin(sourceOrigin)
+ , m_url(url)
, m_startPosition(startPosition)
, m_sourceType(sourceType)
, m_validated(false)
Modified: trunk/Source/_javascript_Core/parser/SourceProvider.h (210148 => 210149)
--- trunk/Source/_javascript_Core/parser/SourceProvider.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/parser/SourceProvider.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -28,6 +28,7 @@
#pragma once
+#include "SourceOrigin.h"
#include <wtf/RefCounted.h>
#include <wtf/text/TextPosition.h>
#include <wtf/text/WTFString.h>
@@ -44,7 +45,7 @@
public:
static const intptr_t nullID = 1;
- JS_EXPORT_PRIVATE SourceProvider(const String& url, const TextPosition& startPosition, SourceProviderSourceType);
+ JS_EXPORT_PRIVATE SourceProvider(const SourceOrigin&, const String& url, const TextPosition& startPosition, SourceProviderSourceType);
JS_EXPORT_PRIVATE virtual ~SourceProvider();
@@ -55,6 +56,7 @@
return source().substring(start, end - start);
}
+ const SourceOrigin& sourceOrigin() const { return m_sourceOrigin; }
const String& url() const { return m_url; }
const String& sourceURL() const { return m_sourceURLDirective; }
const String& sourceMappingURL() const { return m_sourceMappingURLDirective; }
@@ -78,6 +80,7 @@
private:
JS_EXPORT_PRIVATE void getID();
+ SourceOrigin m_sourceOrigin;
String m_url;
String m_sourceURLDirective;
String m_sourceMappingURLDirective;
@@ -89,9 +92,9 @@
class StringSourceProvider : public SourceProvider {
public:
- static Ref<StringSourceProvider> create(const String& source, const String& url, const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
+ static Ref<StringSourceProvider> create(const String& source, const SourceOrigin& sourceOrigin, const String& url, const TextPosition& startPosition = TextPosition(), SourceProviderSourceType sourceType = SourceProviderSourceType::Program)
{
- return adoptRef(*new StringSourceProvider(source, url, startPosition, sourceType));
+ return adoptRef(*new StringSourceProvider(source, sourceOrigin, url, startPosition, sourceType));
}
unsigned hash() const override
@@ -105,8 +108,8 @@
}
private:
- StringSourceProvider(const String& source, const String& url, const TextPosition& startPosition, SourceProviderSourceType sourceType)
- : SourceProvider(url, startPosition, sourceType)
+ StringSourceProvider(const String& source, const SourceOrigin& sourceOrigin, const String& url, const TextPosition& startPosition, SourceProviderSourceType sourceType)
+ : SourceProvider(sourceOrigin, url, startPosition, sourceType)
, m_source(source.isNull() ? *StringImpl::empty() : *source.impl())
{
}
@@ -117,9 +120,9 @@
#if ENABLE(WEBASSEMBLY)
class WebAssemblySourceProvider : public SourceProvider {
public:
- static Ref<WebAssemblySourceProvider> create(const Vector<uint8_t>& data, const String& url)
+ static Ref<WebAssemblySourceProvider> create(const Vector<uint8_t>& data, const SourceOrigin& sourceOrigin, const String& url)
{
- return adoptRef(*new WebAssemblySourceProvider(data, url));
+ return adoptRef(*new WebAssemblySourceProvider(data, sourceOrigin, url));
}
unsigned hash() const override
@@ -138,8 +141,8 @@
}
private:
- WebAssemblySourceProvider(const Vector<uint8_t>& data, const String& url)
- : SourceProvider(url, TextPosition(), SourceProviderSourceType::WebAssembly)
+ WebAssemblySourceProvider(const Vector<uint8_t>& data, const SourceOrigin& sourceOrigin, const String& url)
+ : SourceProvider(sourceOrigin, url, TextPosition(), SourceProviderSourceType::WebAssembly)
, m_source("[WebAssembly source]")
, m_data(data)
{
Modified: trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/runtime/FunctionConstructor.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -76,7 +76,7 @@
}
// ECMA 15.3.2 The Function Constructor
-JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const String& sourceURL, const TextPosition& position, FunctionConstructionMode functionConstructionMode, JSValue newTarget)
+JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, const Identifier& functionName, const SourceOrigin& sourceOrigin, const String& sourceURL, const TextPosition& position, FunctionConstructionMode functionConstructionMode, JSValue newTarget)
{
VM& vm = exec->vm();
auto scope = DECLARE_THROW_SCOPE(vm);
@@ -84,12 +84,12 @@
if (!globalObject->evalEnabled())
return throwException(exec, scope, createEvalError(exec, globalObject->evalDisabledErrorMessage()));
scope.release();
- return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceURL, position, -1, functionConstructionMode, newTarget);
+ return constructFunctionSkippingEvalEnabledCheck(exec, globalObject, args, functionName, sourceOrigin, sourceURL, position, -1, functionConstructionMode, newTarget);
}
JSObject* constructFunctionSkippingEvalEnabledCheck(
ExecState* exec, JSGlobalObject* globalObject, const ArgList& args,
- const Identifier& functionName, const String& sourceURL,
+ const Identifier& functionName, const SourceOrigin& sourceOrigin, const String& sourceURL,
const TextPosition& position, int overrideLineNumber, FunctionConstructionMode functionConstructionMode, JSValue newTarget)
{
VM& vm = exec->vm();
@@ -143,7 +143,7 @@
program = builder.toString();
}
- SourceCode source = makeSource(program, sourceURL, position);
+ SourceCode source = makeSource(program, sourceOrigin, sourceURL, position);
JSObject* exception = nullptr;
FunctionExecutable* function = FunctionExecutable::fromGlobalCode(functionName, *exec, source, exception, overrideLineNumber);
if (!function) {
@@ -170,7 +170,7 @@
// ECMA 15.3.2 The Function Constructor
JSObject* constructFunction(ExecState* exec, JSGlobalObject* globalObject, const ArgList& args, FunctionConstructionMode functionConstructionMode, JSValue newTarget)
{
- return constructFunction(exec, globalObject, args, exec->propertyNames().anonymous, String(), TextPosition(), functionConstructionMode, newTarget);
+ return constructFunction(exec, globalObject, args, exec->propertyNames().anonymous, exec->callerSourceOrigin(), String(), TextPosition(), functionConstructionMode, newTarget);
}
} // namespace JSC
Modified: trunk/Source/_javascript_Core/runtime/FunctionConstructor.h (210148 => 210149)
--- trunk/Source/_javascript_Core/runtime/FunctionConstructor.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/runtime/FunctionConstructor.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -61,11 +61,11 @@
Async,
};
-JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&, const Identifier& functionName, const String& sourceURL, const WTF::TextPosition&, FunctionConstructionMode = FunctionConstructionMode::Function, JSValue newTarget = JSValue());
+JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&, const Identifier& functionName, const SourceOrigin&, const String& sourceURL, const WTF::TextPosition&, FunctionConstructionMode = FunctionConstructionMode::Function, JSValue newTarget = JSValue());
JSObject* constructFunction(ExecState*, JSGlobalObject*, const ArgList&, FunctionConstructionMode = FunctionConstructionMode::Function, JSValue newTarget = JSValue());
JS_EXPORT_PRIVATE JSObject* constructFunctionSkippingEvalEnabledCheck(
- ExecState*, JSGlobalObject*, const ArgList&, const Identifier&,
+ ExecState*, JSGlobalObject*, const ArgList&, const Identifier&, const SourceOrigin&,
const String&, const WTF::TextPosition&, int overrideLineNumber = -1,
FunctionConstructionMode = FunctionConstructionMode::Function, JSValue newTarget = JSValue());
Modified: trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/runtime/JSGlobalObjectFunctions.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -679,8 +679,9 @@
return JSValue::encode(parsedObject);
}
+ SourceOrigin sourceOrigin = exec->callerSourceOrigin();
JSGlobalObject* calleeGlobalObject = exec->jsCallee()->globalObject();
- EvalExecutable* eval = IndirectEvalExecutable::create(exec, makeSource(s), false, DerivedContextType::None, false, EvalContextType::None);
+ EvalExecutable* eval = IndirectEvalExecutable::create(exec, makeSource(s, sourceOrigin), false, DerivedContextType::None, false, EvalContextType::None);
if (!eval)
return JSValue::encode(jsUndefined());
Modified: trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/runtime/ModuleLoaderPrototype.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -111,7 +111,7 @@
String source = exec->argument(1).toWTFString(exec);
RETURN_IF_EXCEPTION(scope, encodedJSValue());
- SourceCode sourceCode = makeSource(source, moduleKey.impl(), TextPosition(), SourceProviderSourceType::Module);
+ SourceCode sourceCode = makeSource(source, SourceOrigin { moduleKey.impl() }, moduleKey.impl(), TextPosition(), SourceProviderSourceType::Module);
CodeProfiling profile(sourceCode);
Modified: trunk/Source/_javascript_Core/runtime/ScriptExecutable.h (210148 => 210149)
--- trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/runtime/ScriptExecutable.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -40,6 +40,7 @@
const SourceCode& source() const { return m_source; }
intptr_t sourceID() const { return m_source.providerID(); }
+ const SourceOrigin& sourceOrigin() const { return m_source.provider()->sourceOrigin(); }
const String& sourceURL() const { return m_source.provider()->url(); }
int firstLine() const { return m_source.firstLine().oneBasedInt(); }
void setOverrideLineNumber(int overrideLineNumber) { m_overrideLineNumber = overrideLineNumber; }
Added: trunk/Source/_javascript_Core/runtime/SourceOrigin.h (0 => 210149)
--- trunk/Source/_javascript_Core/runtime/SourceOrigin.h (rev 0)
+++ trunk/Source/_javascript_Core/runtime/SourceOrigin.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 Yusuke Suzuki <[email protected]>.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <wtf/text/WTFString.h>
+
+namespace JSC {
+
+class SourceOrigin {
+public:
+ explicit SourceOrigin(const String& string)
+ : m_string(string)
+ {
+ }
+
+ SourceOrigin() = default;
+
+ const String& string() const { return m_string; }
+ bool isNull() const { return m_string.isNull(); }
+
+private:
+ String m_string;
+};
+
+} // namespace JSC
Modified: trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp (210148 => 210149)
--- trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/_javascript_Core/tools/FunctionOverrides.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -125,7 +125,7 @@
newProviderStr.append(origHeader);
newProviderStr.append(newBody);
- auto newProvider = StringSourceProvider::create(newProviderStr, "<overridden>");
+ auto newProvider = StringSourceProvider::create(newProviderStr, SourceOrigin { "<overridden>" }, "<overridden>");
info.firstLine = 1;
info.lineCount = 1; // Faking it. This doesn't really matter for now.
Modified: trunk/Source/WebCore/ChangeLog (210148 => 210149)
--- trunk/Source/WebCore/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,21 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ * bindings/js/CachedScriptSourceProvider.h:
+ (WebCore::CachedScriptSourceProvider::CachedScriptSourceProvider):
+ * bindings/js/JSLazyEventListener.cpp:
+ (WebCore::JSLazyEventListener::initializeJSFunction):
+ * bindings/js/ScriptSourceCode.h:
+ (WebCore::ScriptSourceCode::ScriptSourceCode):
+ * bridge/NP_jsobject.cpp:
+ (_NPN_Evaluate):
+ * bridge/objc/WebScriptObject.mm:
+ (-[WebScriptObject evaluateWebScript:]):
+
2016-12-24 Sam Weinig <[email protected]>
[WebIDL] Remove (most) custom bindings for the IndexedDB code
Modified: trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h (210148 => 210149)
--- trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/bindings/js/CachedScriptSourceProvider.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -48,7 +48,7 @@
private:
CachedScriptSourceProvider(CachedScript* cachedScript, JSC::SourceProviderSourceType sourceType)
- : SourceProvider(cachedScript->response().url(), TextPosition(), sourceType)
+ : SourceProvider(JSC::SourceOrigin { cachedScript->response().url() }, cachedScript->response().url(), TextPosition(), sourceType)
, m_cachedScript(cachedScript)
{
m_cachedScript->addClient(*this);
Modified: trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp (210148 => 210149)
--- trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/bindings/js/JSLazyEventListener.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -112,7 +112,7 @@
JSObject* jsFunction = constructFunctionSkippingEvalEnabledCheck(
exec, exec->lexicalGlobalObject(), args, Identifier::fromString(exec, m_functionName),
- m_sourceURL, m_sourcePosition, overrideLineNumber);
+ SourceOrigin { m_sourceURL }, m_sourceURL, m_sourcePosition, overrideLineNumber);
if (UNLIKELY(scope.exception())) {
reportCurrentException(exec);
Modified: trunk/Source/WebCore/bindings/js/ScriptSourceCode.h (210148 => 210149)
--- trunk/Source/WebCore/bindings/js/ScriptSourceCode.h 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/bindings/js/ScriptSourceCode.h 2016-12-26 06:35:07 UTC (rev 210149)
@@ -43,7 +43,7 @@
class ScriptSourceCode {
public:
ScriptSourceCode(const String& source, const URL& url = "" const TextPosition& startPosition = TextPosition(), JSC::SourceProviderSourceType sourceType = JSC::SourceProviderSourceType::Program)
- : m_provider(JSC::StringSourceProvider::create(source, url.isNull() ? String() : url.string(), startPosition, sourceType))
+ : m_provider(JSC::StringSourceProvider::create(source, JSC::SourceOrigin { url.string() }, url.string(), startPosition, sourceType))
, m_code(m_provider, startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt())
, m_url(url)
{
Modified: trunk/Source/WebCore/bridge/NP_jsobject.cpp (210148 => 210149)
--- trunk/Source/WebCore/bridge/NP_jsobject.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/bridge/NP_jsobject.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -277,7 +277,7 @@
ExecState* exec = globalObject->globalExec();
String scriptString = convertNPStringToUTF16(s);
- JSValue returnValue = JSC::evaluate(exec, makeSource(scriptString), JSC::JSValue());
+ JSValue returnValue = JSC::evaluate(exec, JSC::makeSource(scriptString, { }), JSC::JSValue());
convertValueToNPVariant(exec, returnValue, variant);
scope.clearException();
Modified: trunk/Source/WebCore/bridge/objc/WebScriptObject.mm (210148 => 210149)
--- trunk/Source/WebCore/bridge/objc/WebScriptObject.mm 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebCore/bridge/objc/WebScriptObject.mm 2016-12-26 06:35:07 UTC (rev 210149)
@@ -381,7 +381,7 @@
ExecState* exec = globalObject->globalExec();
UNUSED_PARAM(scope);
- JSC::JSValue returnValue = JSMainThreadExecState::profiledEvaluate(exec, JSC::ProfilingReason::Other, makeSource(String(script)), JSC::JSValue());
+ JSC::JSValue returnValue = JSMainThreadExecState::profiledEvaluate(exec, JSC::ProfilingReason::Other, makeSource(String(script), { }), JSC::JSValue());
id resultObj = [WebScriptObject _convertValueToObjcValue:returnValue originRootObject:[self _originRootObject] rootObject:[self _rootObject]];
Modified: trunk/Source/WebKit/mac/ChangeLog (210148 => 210149)
--- trunk/Source/WebKit/mac/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit/mac/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,13 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ * Plugins/Hosted/NetscapePluginInstanceProxy.mm:
+ (WebKit::NetscapePluginInstanceProxy::evaluate):
+
2016-12-23 Andy Estes <[email protected]>
[iOS] DumpRenderTree triggers an assertion failure when calling +[WebPreferences _switchNetworkLoaderToNewTestingSession]
Modified: trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm (210148 => 210149)
--- trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit/mac/Plugins/Hosted/NetscapePluginInstanceProxy.mm 2016-12-26 06:35:07 UTC (rev 210149)
@@ -891,7 +891,7 @@
UserGestureIndicator gestureIndicator(allowPopups ? std::optional<ProcessingUserGestureState>(ProcessingUserGesture) : std::nullopt);
- JSValue result = JSC::evaluate(exec, makeSource(script));
+ JSValue result = JSC::evaluate(exec, JSC::makeSource(script, { }));
marshalValue(exec, result, resultData, resultLength);
scope.clearException();
Modified: trunk/Source/WebKit/win/ChangeLog (210148 => 210149)
--- trunk/Source/WebKit/win/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit/win/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,14 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ * Plugins/PluginPackage.cpp:
+ (WebCore::NPN_Evaluate):
+ (WebCore::makeSource): Deleted.
+
2016-12-22 Andy Estes <[email protected]>
Make WebCore::EditorInsertAction an enum class
Modified: trunk/Source/WebKit/win/Plugins/PluginPackage.cpp (210148 => 210149)
--- trunk/Source/WebKit/win/Plugins/PluginPackage.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit/win/Plugins/PluginPackage.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -192,11 +192,6 @@
aList.append(JSC::Bindings::convertNPVariantToValue(exec, &args[i], rootObject));
}
-static inline JSC::SourceCode makeSource(const String& source, const String& url = "" const TextPosition& startPosition = TextPosition())
-{
- return JSC::SourceCode(JSC::StringSourceProvider::create(source, url, startPosition), startPosition.m_line.oneBasedInt(), startPosition.m_column.oneBasedInt());
-}
-
static bool NPN_Evaluate(NPP instance, NPObject* o, NPString* s, NPVariant* variant)
{
if (o->_class == NPScriptObjectClass) {
@@ -218,7 +213,7 @@
JSC::ExecState* exec = globalObject->globalExec();
String scriptString = JSC::Bindings::convertNPStringToUTF16(s);
- JSC::JSValue returnValue = JSC::evaluate(exec, makeSource(scriptString), JSC::JSValue());
+ JSC::JSValue returnValue = JSC::evaluate(exec, JSC::makeSource(scriptString, { }), JSC::JSValue());
JSC::Bindings::convertValueToNPVariant(exec, returnValue, variant);
scope.clearException();
Modified: trunk/Source/WebKit2/ChangeLog (210148 => 210149)
--- trunk/Source/WebKit2/ChangeLog 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit2/ChangeLog 2016-12-26 06:35:07 UTC (rev 210149)
@@ -1,3 +1,13 @@
+2016-12-25 Yusuke Suzuki <[email protected]>
+
+ Propagate the source origin as much as possible
+ https://bugs.webkit.org/show_bug.cgi?id=166348
+
+ Reviewed by Darin Adler.
+
+ * WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp:
+ (WebKit::NPRuntimeObjectMap::evaluate):
+
2016-12-22 Andy Estes <[email protected]>
Reduce QuickLook.h include overhead
Modified: trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp (210148 => 210149)
--- trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp 2016-12-26 01:33:33 UTC (rev 210148)
+++ trunk/Source/WebKit2/WebProcess/Plugins/Netscape/NPRuntimeObjectMap.cpp 2016-12-26 06:35:07 UTC (rev 210149)
@@ -193,7 +193,7 @@
JSLockHolder lock(exec);
JSValue thisValue = getOrCreateJSObject(globalObject.get(), npObject);
- JSValue resultValue = JSC::evaluate(exec, makeSource(scriptString), thisValue);
+ JSValue resultValue = JSC::evaluate(exec, makeSource(scriptString, { }), thisValue);
convertJSValueToNPVariant(exec, resultValue, *result);
return true;