<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202737] trunk/Source/JavaScriptCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202737">202737</a></dd>
<dt>Author</dt> <dd>mark.lam@apple.com</dd>
<dt>Date</dt> <dd>2016-07-01 09:38:11 -0700 (Fri, 01 Jul 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>Update JSC_functionOverrides to handle the new SourceCode strings that have params.
https://bugs.webkit.org/show_bug.cgi?id=159321
Reviewed by Geoffrey Garen.
And add tests so that this won't fail silently and bit rot anymore.
* API/tests/FunctionOverridesTest.cpp: Added.
(testFunctionOverrides):
* API/tests/FunctionOverridesTest.h: Added.
* API/tests/testapi-function-overrides.js: Added.
* API/tests/testapi.c:
(main):
* JavaScriptCore.xcodeproj/project.pbxproj:
* bytecode/UnlinkedFunctionExecutable.cpp:
(JSC::UnlinkedFunctionExecutable::link):
* shell/PlatformWin.cmake:
* tools/FunctionOverrides.cpp:
(JSC::FunctionOverrides::FunctionOverrides):
(JSC::FunctionOverrides::reinstallOverrides):
(JSC::initializeOverrideInfo):
(JSC::FunctionOverrides::initializeOverrideFor):
* tools/FunctionOverrides.h:
(JSC::FunctionOverrides::clear):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPIteststestapic">trunk/Source/JavaScriptCore/API/tests/testapi.c</a></li>
<li><a href="#trunkSourceJavaScriptCoreChangeLog">trunk/Source/JavaScriptCore/ChangeLog</a></li>
<li><a href="#trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj">trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutablecpp">trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreshellPlatformWincmake">trunk/Source/JavaScriptCore/shell/PlatformWin.cmake</a></li>
<li><a href="#trunkSourceJavaScriptCoretoolsFunctionOverridescpp">trunk/Source/JavaScriptCore/tools/FunctionOverrides.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoretoolsFunctionOverridesh">trunk/Source/JavaScriptCore/tools/FunctionOverrides.h</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceJavaScriptCoreAPItestsFunctionOverridesTestcpp">trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPItestsFunctionOverridesTesth">trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.h</a></li>
<li><a href="#trunkSourceJavaScriptCoreAPIteststestapifunctionoverridesjs">trunk/Source/JavaScriptCore/API/tests/testapi-function-overrides.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceJavaScriptCoreAPItestsFunctionOverridesTestcpp"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp (0 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp         (rev 0)
+++ trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.cpp        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -0,0 +1,92 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * 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.
+ */
+
+#include "config.h"
+#include "FunctionOverridesTest.h"
+
+#include "FunctionOverrides.h"
+#include "InitializeThreading.h"
+#include "JSContextRefPrivate.h"
+#include "JavaScriptCore.h"
+#include "Options.h"
+#include <string>
+#include <wtf/text/StringBuilder.h>
+
+using JSC::Options;
+
+int testFunctionOverrides()
+{
+ bool failed = false;
+
+ JSC::initializeThreading();
+ Options::initialize(); // Ensure options is initialized first.
+
+ const char* oldFunctionOverrides = Options::functionOverrides();
+
+ Options::functionOverrides() = "testapi-function-overrides.js";
+ JSC::FunctionOverrides::reinstallOverrides();
+
+ JSGlobalContextRef context = JSGlobalContextCreateInGroup(nullptr, nullptr);
+
+ JSObjectRef globalObject = JSContextGetGlobalObject(context);
+ ASSERT_UNUSED(globalObject, JSValueIsObject(context, globalObject));
+
+ const char* scriptString =
+ "var str = '';" "\n"
+ "function f1() { /* Original f1 */ }" "\n"
+ "str += f1 + '\\n';" "\n"
+ "var f2 = function() {" "\n"
+ " // Original f2" "\n"
+ "}" "\n"
+ "str += f2 + '\\n';" "\n"
+ "str += (function() { /* Original f3 */ }) + '\\n';" "\n"
+ "var f4Source = '/* Original f4 */'" "\n"
+ "var f4 = new Function(f4Source);" "\n"
+ "str += f4 + '\\n';" "\n"
+ "\n"
+ "var expectedStr =" "\n"
+ "'function f1() { /* Overridden f1 */ }\\n"
+ "function () { /* Overridden f2 */ }\\n"
+ "function () { /* Overridden f3 */ }\\n"
+ "function anonymous() { /* Overridden f4 */ }\\n';"
+ "var result = (str == expectedStr);" "\n"
+ "result";
+
+ JSStringRef script = JSStringCreateWithUTF8CString(scriptString);
+ JSValueRef exception = nullptr;
+ JSValueRef resultRef = JSEvaluateScript(context, script, nullptr, nullptr, 1, &exception);
+
+ if (!JSValueIsBoolean(context, resultRef) || !JSValueToBoolean(context, resultRef))
+ failed = true;
+
+ JSGlobalContextRelease(context);
+
+ JSC::Options::functionOverrides() = oldFunctionOverrides;
+ JSC::FunctionOverrides::reinstallOverrides();
+
+ printf("%s: function override tests.\n", failed ? "FAIL" : "PASS");
+
+ return failed;
+}
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPItestsFunctionOverridesTesth"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.h (0 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.h         (rev 0)
+++ trunk/Source/JavaScriptCore/API/tests/FunctionOverridesTest.h        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -0,0 +1,37 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * 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
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Returns 1 if failures were encountered. Else, returns 0. */
+int testFunctionOverrides();
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIteststestapifunctionoverridesjs"></a>
<div class="addfile"><h4>Added: trunk/Source/JavaScriptCore/API/tests/testapi-function-overrides.js (0 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/testapi-function-overrides.js         (rev 0)
+++ trunk/Source/JavaScriptCore/API/tests/testapi-function-overrides.js        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -0,0 +1,16 @@
</span><ins>+// testapi function overrides for testing.
+override %%%{ /* Original f1 */ }%%%
+with %%%{ /* Overridden f1 */ }%%%
+
+override #$%{
+ // Original f2
+}#$%
+with $$${ /* Overridden f2 */ }$$$
+
+override %%%{ /* Original f3 */ }%%%
+with %%%{ /* Overridden f3 */ }%%%
+
+override %%%{
+/* Original f4 */
+}%%%
+with %%%{ /* Overridden f4 */ }%%%
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoreAPIteststestapic"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/API/tests/testapi.c (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/API/tests/testapi.c        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/API/tests/testapi.c        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -42,6 +42,7 @@
</span><span class="cx"> #include "CompareAndSwapTest.h"
</span><span class="cx"> #include "CustomGlobalObjectClassTest.h"
</span><span class="cx"> #include "ExecutionTimeLimitTest.h"
</span><ins>+#include "FunctionOverridesTest.h"
</ins><span class="cx"> #include "GlobalContextWithFinalizerTest.h"
</span><span class="cx"> #include "PingPongStackOverflowTest.h"
</span><span class="cx"> #include "TypedArrayCTest.h"
</span><span class="lines">@@ -1885,6 +1886,7 @@
</span><span class="cx">
</span><span class="cx"> failed = testTypedArrayCAPI() || failed;
</span><span class="cx"> failed = testExecutionTimeLimit() || failed;
</span><ins>+ failed = testFunctionOverrides() || failed;
</ins><span class="cx"> failed = testGlobalContextWithFinalizer() || failed;
</span><span class="cx"> failed = testPingPongStackOverflow() || failed;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/ChangeLog (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/ChangeLog        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/ChangeLog        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -1,3 +1,30 @@
</span><ins>+2016-07-01 Mark Lam <mark.lam@apple.com>
+
+ Update JSC_functionOverrides to handle the new SourceCode strings that have params.
+ https://bugs.webkit.org/show_bug.cgi?id=159321
+
+ Reviewed by Geoffrey Garen.
+
+ And add tests so that this won't fail silently and bit rot anymore.
+
+ * API/tests/FunctionOverridesTest.cpp: Added.
+ (testFunctionOverrides):
+ * API/tests/FunctionOverridesTest.h: Added.
+ * API/tests/testapi-function-overrides.js: Added.
+ * API/tests/testapi.c:
+ (main):
+ * JavaScriptCore.xcodeproj/project.pbxproj:
+ * bytecode/UnlinkedFunctionExecutable.cpp:
+ (JSC::UnlinkedFunctionExecutable::link):
+ * shell/PlatformWin.cmake:
+ * tools/FunctionOverrides.cpp:
+ (JSC::FunctionOverrides::FunctionOverrides):
+ (JSC::FunctionOverrides::reinstallOverrides):
+ (JSC::initializeOverrideInfo):
+ (JSC::FunctionOverrides::initializeOverrideFor):
+ * tools/FunctionOverrides.h:
+ (JSC::FunctionOverrides::clear):
+
</ins><span class="cx"> 2016-07-01 Caio Lima <ticaiolima@gmail.com>
</span><span class="cx">
</span><span class="cx"> ES6: Implement HasRestrictedGlobalProperty when checking for global lexical tier conflicts
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreJavaScriptCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -2108,6 +2108,8 @@
</span><span class="cx">                 FEB51F6C1A97B688001F921C /* Regress141809.mm in Sources */ = {isa = PBXBuildFile; fileRef = FEB51F6B1A97B688001F921C /* Regress141809.mm */; };
</span><span class="cx">                 FEB58C14187B8B160098EF0B /* ErrorHandlingScope.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */; };
</span><span class="cx">                 FEB58C15187B8B160098EF0B /* ErrorHandlingScope.h in Headers */ = {isa = PBXBuildFile; fileRef = FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                FECB8B271D25BB85006F2463 /* FunctionOverridesTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FECB8B251D25BB6E006F2463 /* FunctionOverridesTest.cpp */; };
+                FECB8B2A1D25CB5A006F2463 /* testapi-function-overrides.js in Copy Support Script */ = {isa = PBXBuildFile; fileRef = FECB8B291D25CABB006F2463 /* testapi-function-overrides.js */; };
</ins><span class="cx">                 FED287B215EC9A5700DA8161 /* LLIntOpcode.h in Headers */ = {isa = PBXBuildFile; fileRef = FED287B115EC9A5700DA8161 /* LLIntOpcode.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 FED94F2E171E3E2300BE77A4 /* Watchdog.cpp in Sources */ = {isa = PBXBuildFile; fileRef = FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */; };
</span><span class="cx">                 FED94F2F171E3E2300BE77A4 /* Watchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = FED94F2C171E3E2300BE77A4 /* Watchdog.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2236,6 +2238,7 @@
</span><span class="cx">                         dstPath = "";
</span><span class="cx">                         dstSubfolderSpec = 16;
</span><span class="cx">                         files = (
</span><ins>+                                FECB8B2A1D25CB5A006F2463 /* testapi-function-overrides.js in Copy Support Script */,
</ins><span class="cx">                                 5DBB151B131D0B310056AD36 /* testapi.js in Copy Support Script */,
</span><span class="cx">                         );
</span><span class="cx">                         name = "Copy Support Script";
</span><span class="lines">@@ -4372,6 +4375,9 @@
</span><span class="cx">                 FEB51F6B1A97B688001F921C /* Regress141809.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = Regress141809.mm; path = API/tests/Regress141809.mm; sourceTree = "<group>"; };
</span><span class="cx">                 FEB58C12187B8B160098EF0B /* ErrorHandlingScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ErrorHandlingScope.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 FEB58C13187B8B160098EF0B /* ErrorHandlingScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ErrorHandlingScope.h; sourceTree = "<group>"; };
</span><ins>+                FECB8B251D25BB6E006F2463 /* FunctionOverridesTest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FunctionOverridesTest.cpp; path = API/tests/FunctionOverridesTest.cpp; sourceTree = "<group>"; };
+                FECB8B261D25BB6E006F2463 /* FunctionOverridesTest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FunctionOverridesTest.h; path = API/tests/FunctionOverridesTest.h; sourceTree = "<group>"; };
+                FECB8B291D25CABB006F2463 /* testapi-function-overrides.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = "testapi-function-overrides.js"; path = "API/tests/testapi-function-overrides.js"; sourceTree = "<group>"; };
</ins><span class="cx">                 FED287B115EC9A5700DA8161 /* LLIntOpcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = LLIntOpcode.h; path = llint/LLIntOpcode.h; sourceTree = "<group>"; };
</span><span class="cx">                 FED94F2B171E3E2300BE77A4 /* Watchdog.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Watchdog.cpp; sourceTree = "<group>"; };
</span><span class="cx">                 FED94F2C171E3E2300BE77A4 /* Watchdog.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Watchdog.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -4957,6 +4963,8 @@
</span><span class="cx">                                 C288B2DD18A54D3E007BE40B /* DateTests.mm */,
</span><span class="cx">                                 FE0D4A041AB8DD0A002F54BF /* ExecutionTimeLimitTest.cpp */,
</span><span class="cx">                                 FE0D4A051AB8DD0A002F54BF /* ExecutionTimeLimitTest.h */,
</span><ins>+                                FECB8B251D25BB6E006F2463 /* FunctionOverridesTest.cpp */,
+                                FECB8B261D25BB6E006F2463 /* FunctionOverridesTest.h */,
</ins><span class="cx">                                 FE0D4A071ABA2437002F54BF /* GlobalContextWithFinalizerTest.cpp */,
</span><span class="cx">                                 FE0D4A081ABA2437002F54BF /* GlobalContextWithFinalizerTest.h */,
</span><span class="cx">                                 C2181FC018A948FB0025A235 /* JSExportTests.h */,
</span><span class="lines">@@ -4970,6 +4978,7 @@
</span><span class="cx">                                 FEB51F6B1A97B688001F921C /* Regress141809.mm */,
</span><span class="cx">                                 14BD5A2D0A3E91F600BAF59C /* testapi.c */,
</span><span class="cx">                                 14D857740A4696C80032146C /* testapi.js */,
</span><ins>+                                FECB8B291D25CABB006F2463 /* testapi-function-overrides.js */,
</ins><span class="cx">                                 86D22219167EF9440024C804 /* testapi.mm */,
</span><span class="cx">                                 651122E5140469BA002B101D /* testRegExp.cpp */,
</span><span class="cx">                         );
</span><span class="lines">@@ -8624,6 +8633,7 @@
</span><span class="cx">                         buildActionMask = 2147483647;
</span><span class="cx">                         files = (
</span><span class="cx">                                 FEF040511AAE662D00BD28B0 /* CompareAndSwapTest.cpp in Sources */,
</span><ins>+                                FECB8B271D25BB85006F2463 /* FunctionOverridesTest.cpp in Sources */,
</ins><span class="cx">                                 C29ECB031804D0ED00D2CBB4 /* CurrentThisInsideBlockGetterTest.mm in Sources */,
</span><span class="cx">                                 C20328201981979D0088B499 /* CustomGlobalObjectClassTest.c in Sources */,
</span><span class="cx">                                 C288B2DE18A54D3E007BE40B /* DateTests.mm in Sources */,
</span></span></pre></div>
<a id="trunkSourceJavaScriptCorebytecodeUnlinkedFunctionExecutablecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/bytecode/UnlinkedFunctionExecutable.cpp        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -145,7 +145,7 @@
</span><span class="cx">
</span><span class="cx"> if (UNLIKELY(Options::functionOverrides())) {
</span><span class="cx"> hasFunctionOverride = FunctionOverrides::initializeOverrideFor(code, overrideInfo);
</span><del>- if (hasFunctionOverride) {
</del><ins>+ if (UNLIKELY(hasFunctionOverride)) {
</ins><span class="cx"> firstLine = overrideInfo.firstLine;
</span><span class="cx"> lineCount = overrideInfo.lineCount;
</span><span class="cx"> startColumn = overrideInfo.startColumn;
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoreshellPlatformWincmake"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/shell/PlatformWin.cmake (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/shell/PlatformWin.cmake        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/shell/PlatformWin.cmake        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> ../API/tests/CompareAndSwapTest.cpp
</span><span class="cx"> ../API/tests/CustomGlobalObjectClassTest.c
</span><span class="cx"> ../API/tests/ExecutionTimeLimitTest.cpp
</span><ins>+ ../API/tests/FunctionOverridesTest.cpp
</ins><span class="cx"> ../API/tests/GlobalContextWithFinalizerTest.cpp
</span><span class="cx"> ../API/tests/PingPongStackOverflowTest.cpp
</span><span class="cx"> ../API/tests/testapi.c
</span><span class="lines">@@ -47,3 +48,8 @@
</span><span class="cx"> DESTINATION
</span><span class="cx"> ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
</span><span class="cx"> )
</span><ins>+file(COPY
+ "${JAVASCRIPTCORE_DIR}/API/tests/testapi-function-overrides.js"
+ DESTINATION
+ ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+)
</ins></span></pre></div>
<a id="trunkSourceJavaScriptCoretoolsFunctionOverridescpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tools/FunctionOverrides.cpp (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tools/FunctionOverrides.cpp        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/tools/FunctionOverrides.cpp        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -104,11 +104,20 @@
</span><span class="cx"> parseOverridesInFile(overridesFileName);
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+void FunctionOverrides::reinstallOverrides()
+{
+ FunctionOverrides& overrides = FunctionOverrides::overrides();
+ const char* overridesFileName = Options::functionOverrides();
+ overrides.clear();
+ overrides.parseOverridesInFile(overridesFileName);
+}
+
</ins><span class="cx"> static void initializeOverrideInfo(const SourceCode& origCode, const String& newBody, FunctionOverrides::OverrideInfo& info)
</span><span class="cx"> {
</span><span class="cx"> String origProviderStr = origCode.provider()->source().toString();
</span><del>- unsigned origBraceStart = origCode.startOffset();
- unsigned origFunctionStart = origProviderStr.reverseFind("function", origBraceStart);
</del><ins>+ unsigned origStart = origCode.startOffset();
+ unsigned origFunctionStart = origProviderStr.reverseFind("function", origStart);
+ unsigned origBraceStart = origProviderStr.find("{", origStart);
</ins><span class="cx"> unsigned headerLength = origBraceStart - origFunctionStart;
</span><span class="cx"> String origHeader = origProviderStr.substring(origFunctionStart, headerLength);
</span><span class="cx">
</span><span class="lines">@@ -127,7 +136,7 @@
</span><span class="cx"> info.typeProfilingEndOffset = newProviderStr.length() - 1;
</span><span class="cx">
</span><span class="cx"> info.sourceCode =
</span><del>- SourceCode(WTFMove(newProvider), info.typeProfilingStartOffset, info.typeProfilingEndOffset + 1, 1, 1);
</del><ins>+ SourceCode(WTFMove(newProvider), info.parametersStartOffset, info.typeProfilingEndOffset + 1, 1, 1);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> bool FunctionOverrides::initializeOverrideFor(const SourceCode& origCode, FunctionOverrides::OverrideInfo& result)
</span><span class="lines">@@ -135,7 +144,13 @@
</span><span class="cx"> ASSERT(Options::functionOverrides());
</span><span class="cx"> FunctionOverrides& overrides = FunctionOverrides::overrides();
</span><span class="cx">
</span><del>- auto it = overrides.m_entries.find(origCode.view().toString());
</del><ins>+ String sourceString = origCode.view().toString();
+ size_t sourceBodyStart = sourceString.find('{');
+ if (sourceBodyStart == notFound)
+ return false;
+ String sourceBodyString = sourceString.substring(sourceBodyStart);
+
+ auto it = overrides.m_entries.find(sourceBodyString);
</ins><span class="cx"> if (it == overrides.m_entries.end())
</span><span class="cx"> return false;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkSourceJavaScriptCoretoolsFunctionOverridesh"></a>
<div class="modfile"><h4>Modified: trunk/Source/JavaScriptCore/tools/FunctionOverrides.h (202736 => 202737)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/JavaScriptCore/tools/FunctionOverrides.h        2016-07-01 15:40:39 UTC (rev 202736)
+++ trunk/Source/JavaScriptCore/tools/FunctionOverrides.h        2016-07-01 16:38:11 UTC (rev 202737)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> /*
</span><del>- * Copyright (C) 2015 Apple Inc. All rights reserved.
</del><ins>+ * Copyright (C) 2015-2016 Apple Inc. All rights reserved.
</ins><span class="cx"> *
</span><span class="cx"> * Redistribution and use in source and binary forms, with or without
</span><span class="cx"> * modification, are permitted provided that the following conditions
</span><span class="lines">@@ -53,8 +53,11 @@
</span><span class="cx">
</span><span class="cx"> static bool initializeOverrideFor(const SourceCode& origCode, OverrideInfo& result);
</span><span class="cx">
</span><ins>+ JS_EXPORT_PRIVATE static void reinstallOverrides();
+
</ins><span class="cx"> private:
</span><span class="cx"> void parseOverridesInFile(const char* fileName);
</span><ins>+ void clear() { m_entries.clear(); }
</ins><span class="cx">
</span><span class="cx"> HashMap<String, String> m_entries;
</span><span class="cx"> };
</span></span></pre>
</div>
</div>
</body>
</html>