]> git.saurik.com Git - apple/javascriptcore.git/blobdiff - API/JSBase.cpp
JavaScriptCore-1097.13.tar.gz
[apple/javascriptcore.git] / API / JSBase.cpp
index 2ffe345d44f55c5061c2b56d7b0385319c5e067d..c0fe6ccdef00b1cee8a9e7e5e0e5521beeb7c642 100644 (file)
@@ -28,7 +28,7 @@
 #include "JSBasePrivate.h"
 
 #include "APICast.h"
-#include "Completion.h"
+#include "APIShims.h"
 #include "OpaqueJSString.h"
 #include "SourceCode.h"
 #include <interpreter/CallFrame.h>
 #include <runtime/JSGlobalObject.h>
 #include <runtime/JSLock.h>
 #include <runtime/JSObject.h>
+#include <wtf/text/StringHash.h>
 
 using namespace JSC;
 
 JSValueRef JSEvaluateScript(JSContextRef ctx, JSStringRef script, JSObjectRef thisObject, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
 {
     ExecState* exec = toJS(ctx);
-    exec->globalData().heap.registerThread();
-    JSLock lock(exec);
+    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);
+    SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
 
-    if (completion.complType() == Throw) {
+    JSValue evaluationException;
+    JSValue returnValue = evaluate(globalObject->globalExec(), globalObject->globalScopeChain(), source, jsThisObject, &evaluationException);
+
+    if (evaluationException) {
         if (exception)
-            *exception = toRef(completion.value());
+            *exception = toRef(exec, evaluationException);
         return 0;
     }
-    
-    if (completion.value())
-        return toRef(completion.value());
-    
+
+    if (returnValue)
+        return toRef(exec, returnValue);
+
     // happens, for example, when the only statement is an empty (';') statement
-    return toRef(jsUndefined());
+    return toRef(exec, jsUndefined());
 }
 
 bool JSCheckScriptSyntax(JSContextRef ctx, JSStringRef script, JSStringRef sourceURL, int startingLineNumber, JSValueRef* exception)
 {
     ExecState* exec = toJS(ctx);
-    exec->globalData().heap.registerThread();
-    JSLock lock(exec);
+    APIEntryShim entryShim(exec);
+
+    SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), TextPosition(OrdinalNumber::fromOneBasedInt(startingLineNumber), OrdinalNumber::first()));
+    
+    JSValue syntaxException;
+    bool isValidSyntax = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source, &syntaxException);
 
-    SourceCode source = makeSource(script->ustring(), sourceURL->ustring(), startingLineNumber);
-    Completion completion = checkSyntax(exec->dynamicGlobalObject()->globalExec(), source);
-    if (completion.complType() == Throw) {
+    if (!isValidSyntax) {
         if (exception)
-            *exception = toRef(completion.value());
+            *exception = toRef(exec, syntaxException);
         return false;
     }
-    
+
     return true;
 }
 
@@ -94,23 +98,19 @@ void JSGarbageCollect(JSContextRef ctx)
         return;
 
     ExecState* exec = toJS(ctx);
-    JSGlobalData& globalData = exec->globalData();
-
-    JSLock lock(globalData.isSharedInstance);
+    APIEntryShim entryShim(exec, false);
 
-    if (!globalData.heap.isBusy())
-        globalData.heap.collect();
-
-    // 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.
+    exec->globalData().heap.reportAbandonedObjectGraph();
 }
 
 void JSReportExtraMemoryCost(JSContextRef ctx, size_t size)
 {
     ExecState* exec = toJS(ctx);
-    exec->globalData().heap.registerThread();
-    JSLock lock(exec);
-
+    APIEntryShim entryShim(exec);
     exec->globalData().heap.reportExtraMemoryCost(size);
 }
+
+void JSDisableGCTimer(void)
+{
+    GCActivityCallback::s_shouldCreateGCTimer = false;
+}