1
0
Просмотр исходного кода

kernel: Less stack members.

Three per call instead of four before.
Herbert Vojčík 7 лет назад
Родитель
Сommit
c440d4a7b6
1 измененных файлов с 10 добавлено и 10 удалено
  1. 10 10
      support/kernel-runtime.js

+ 10 - 10
support/kernel-runtime.js

@@ -315,11 +315,7 @@ define(function () {
 
         var thisContext = null;
 
-        st.withContext = function (worker, setup) {
-            return thisContext != null ?
-                inContext(worker, setup) :
-                inContextWithErrorHandling(worker, setup);
-        };
+        st.withContext = inContext;
 
         /*
          Runs worker function so that error handler is not set up
@@ -329,15 +325,19 @@ define(function () {
          The effect is, $core.seamless(fn)'s exceptions are not
          handed into ST error handler and caller should process them.
          */
-        st.seamless = function (worker) {
-            return inContext(worker, function (ctx) {
+        st.seamless = function inContext (worker) {
+            var oldContext = thisContext;
+            thisContext = new SmalltalkMethodContext(thisContext, function (ctx) {
                 ctx.fill(null, "seamlessDoIt", {}, globals.UndefinedObject);
             });
+            var result = worker(thisContext);
+            thisContext = oldContext;
+            return result;
         };
 
-        function inContextWithErrorHandling (worker, setup) {
+        function resultWithErrorHandling (worker) {
             try {
-                return inContext(worker, setup);
+                return worker(thisContext);
             } catch (error) {
                 globals.ErrorHandler._handleError_(error);
                 thisContext = null;
@@ -349,7 +349,7 @@ define(function () {
         function inContext (worker, setup) {
             var oldContext = thisContext;
             thisContext = new SmalltalkMethodContext(thisContext, setup);
-            var result = worker(thisContext);
+            var result = oldContext == null ? resultWithErrorHandling(worker) : worker(thisContext);
             thisContext = oldContext;
             return result;
         }