From eb06f94a274182d72def56a92c2793bf1ef8757c Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Mon, 4 Jul 2016 02:30:10 +0300 Subject: [PATCH] cleanup JavaScriptCore Signed-off-by: Ivailo Monev --- .../JavaScriptCore/API/JSBase.cpp | 110 ---- .../JavaScriptCore/API/JSBase.h | 50 -- .../JavaScriptCore/API/JSBasePrivate.h | 51 -- .../bytecompiler/NodesCodegen.cpp | 5 +- .../javascriptcore/JavaScriptCore/jsc.cpp | 551 ------------------ .../JavaScriptCore/runtime/Completion.cpp | 68 --- .../JavaScriptCore/runtime/Completion.h | 63 -- src/script/CMakeLists.txt | 2 - 8 files changed, 1 insertion(+), 899 deletions(-) delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/jsc.cpp delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/runtime/Completion.cpp delete mode 100644 src/3rdparty/javascriptcore/JavaScriptCore/runtime/Completion.h diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp deleted file mode 100644 index a7786527e..000000000 --- a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (C) 2006, 2007 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 COMPUTER, INC. ``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 COMPUTER, INC. OR - * 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 "JSBase.h" -#include "JSBasePrivate.h" - -#include "APICast.h" -#include "APIShims.h" -#include "Completion.h" -#include "OpaqueJSString.h" -#include "SourceCode.h" -#include -#include -#include -#include - -using namespace JSC; - -JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) -{ - ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); - - JSObject* jsThisObject = toJS(thisObject); - - // evaluate sets "this" to the global object if it is NULL - JSGlobalObject* globalObject = exec->dynamicGlobalObject(); - SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); - Completion completion = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject); - - if (completion.complType() == Throw) { - if (exception) - *exception = toRef(exec, completion.value()); - return 0; - } - - if (completion.value()) - return toRef(exec, completion.value()); - - // happens, for example, when the only statement is an empty (';') statement - return toRef(exec, jsUndefined()); -} - -bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception) -{ - ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); - - SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber); - Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source); - if (completion.complType() == Throw) { - if (exception) - *exception = toRef(exec, completion.value()); - return false; - } - - return true; -} - -void JSGarbageCollect(JSContextRef ctx) -{ - // We used to recommend passing NULL as an argument here, which caused the only heap to be collected. - // As there is no longer a shared heap, the previously recommended usage became a no-op (but the GC - // will happen when the context group is destroyed). - // Because the function argument was originally ignored, some clients may pass their released context here, - // in which case there is a risk of crashing if another thread performs GC on the same heap in between. - if (!ctx) - return; - - ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); - - JSGlobalData& globalData = exec->globalData(); - if (!globalData.heap.isBusy()) - globalData.heap.collectAllGarbage(); - - // FIXME: Perhaps we should trigger a second mark and sweep - // once the garbage collector is done if this is called when - // the collector is busy. -} - -void JSReportExtraMemoryCost(JSContextRef ctx, size_t size) -{ - ExecState* exec = toJS(ctx); - APIEntryShim entryShim(exec); - exec->globalData().heap.reportExtraMemoryCost(size); -} diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h b/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h index d706f06bb..1f4b65c68 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h +++ b/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBase.h @@ -75,54 +75,4 @@ typedef struct OpaqueJSValue* JSObjectRef; #define JS_EXPORT #endif -#ifdef __cplusplus -extern "C" { -#endif - -/* Script Evaluation */ - -/*! -@function JSEvaluateScript -@abstract Evaluates a string of JavaScript. -@param ctx The execution context to use. -@param script A JSString containing the script to evaluate. -@param thisObject The object to use as "this," or NULL to use the global object as "this." -@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. -@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. -@param exception A pointer to a JSValueRef in which to store an exception, if any. Pass NULL if you do not care to store an exception. -@result The JSValue that results from evaluating script, or NULL if an exception is thrown. -*/ -JS_EXPORT JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); - -/*! -@function JSCheckScriptSyntax -@abstract Checks for syntax errors in a string of JavaScript. -@param ctx The execution context to use. -@param script A JSString containing the script to check for syntax errors. -@param sourceURL A JSString containing a URL for the script's source file. This is only used when reporting exceptions. Pass NULL if you do not care to include source file information in exceptions. -@param startingLineNumber An integer value specifying the script's starting line number in the file located at sourceURL. This is only used when reporting exceptions. -@param exception A pointer to a JSValueRef in which to store a syntax error exception, if any. Pass NULL if you do not care to store a syntax error exception. -@result true if the script is syntactically correct, otherwise false. -*/ -JS_EXPORT bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception); - -/*! -@function JSGarbageCollect -@abstract Performs a JavaScript garbage collection. -@param ctx The execution context to use. -@discussion JavaScript values that are on the machine stack, in a register, - protected by JSValueProtect, set as the global object of an execution context, - or reachable from any such value will not be collected. - - During JavaScript execution, you are not required to call this function; the - JavaScript engine will garbage collect as needed. JavaScript values created - within a context group are automatically destroyed when the last reference - to the context group is released. -*/ -JS_EXPORT void JSGarbageCollect(JSContextRef ctx); - -#ifdef __cplusplus -} -#endif - #endif /* JSBase_h */ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h b/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h deleted file mode 100644 index ba2656a6d..000000000 --- a/src/3rdparty/javascriptcore/JavaScriptCore/API/JSBasePrivate.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2008 Apple Computer, 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 COMPUTER, INC. ``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 COMPUTER, INC. OR - * 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. - */ - -#ifndef JSBasePrivate_h -#define JSBasePrivate_h - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*! -@function -@abstract Reports an object's non-GC memory payload to the garbage collector. -@param ctx The execution context to use. -@param size The payload's size, in bytes. -@discussion Use this function to notify the garbage collector that a GC object -owns a large non-GC memory region. Calling this function will encourage the -garbage collector to collect soon, hoping to reclaim that large non-GC memory -region. -*/ -JS_EXPORT void JSReportExtraMemoryCost(JSContextRef ctx, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif /* JSBasePrivate_h */ diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/NodesCodegen.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/NodesCodegen.cpp index 1a7ae2fe2..1a51eb720 100644 --- a/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/NodesCodegen.cpp +++ b/src/3rdparty/javascriptcore/JavaScriptCore/bytecompiler/NodesCodegen.cpp @@ -1376,7 +1376,6 @@ RegisterID* IfNode::emitBytecode(BytecodeGenerator& generator, RegisterID* dst) generator.emitNode(dst, m_ifBlock); generator.emitLabel(afterThen.get()); - // FIXME: This should return the last statement executed so that it can be returned as a Completion. return 0; } @@ -1407,7 +1406,6 @@ RegisterID* IfElseNode::emitBytecode(BytecodeGenerator& generator, RegisterID* d generator.emitLabel(afterElse.get()); - // FIXME: This should return the last statement executed so that it can be returned as a Completion. return 0; } @@ -1460,8 +1458,7 @@ RegisterID* WhileNode::emitBytecode(BytecodeGenerator& generator, RegisterID* ds } generator.emitLabel(scope->breakTarget()); - - // FIXME: This should return the last statement executed so that it can be returned as a Completion + return 0; } diff --git a/src/3rdparty/javascriptcore/JavaScriptCore/jsc.cpp b/src/3rdparty/javascriptcore/JavaScriptCore/jsc.cpp deleted file mode 100644 index 9e0ab514a..000000000 --- a/src/3rdparty/javascriptcore/JavaScriptCore/jsc.cpp +++ /dev/null @@ -1,551 +0,0 @@ -/* - * Copyright (C) 1999-2000 Harri Porten (porten@kde.org) - * Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. - * Copyright (C) 2006 Bjoern Graf (bjoern.graf@gmail.com) - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - * - */ - -#include "config.h" - -#include "BytecodeGenerator.h" -#include "Completion.h" -#include "CurrentTime.h" -#include "InitializeThreading.h" -#include "JSArray.h" -#include "JSFunction.h" -#include "JSString.h" -#include "PrototypeFunction.h" -#include "SamplingTool.h" -#include -#include -#include -#include - -#if !OS(WINDOWS) -#include -#endif - -#if HAVE(READLINE) -#include -#include -#endif - -#if HAVE(SYS_TIME_H) -#include -#endif - -#if HAVE(SIGNAL_H) -#include -#endif - -#if COMPILER(MSVC) && !OS(WINCE) -#include -#include -#include -#endif - -#include -#include - -using namespace JSC; -using namespace WTF; - -static void cleanupGlobalData(JSGlobalData*); -static bool fillBufferWithContentsOfFile(const UString& fileName, Vector& buffer); - -static JSValue JSC_HOST_CALL functionPrint(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionDebug(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionGC(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionVersion(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionRun(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionLoad(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionCheckSyntax(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionReadline(ExecState*, JSObject*, JSValue, const ArgList&); -static NO_RETURN JSValue JSC_HOST_CALL functionQuit(ExecState*, JSObject*, JSValue, const ArgList&); - -#if ENABLE(SAMPLING_FLAGS) -static JSValue JSC_HOST_CALL functionSetSamplingFlags(ExecState*, JSObject*, JSValue, const ArgList&); -static JSValue JSC_HOST_CALL functionClearSamplingFlags(ExecState*, JSObject*, JSValue, const ArgList&); -#endif - -struct Script { - bool isFile; - char* argument; - - Script(bool isFile, char *argument) - : isFile(isFile) - , argument(argument) - { - } -}; - -struct Options { - Options() - : interactive(false) - , dump(false) - { - } - - bool interactive; - bool dump; - Vector