/[jscoverage]/trunk/js/jscntxt.cpp
ViewVC logotype

Diff of /trunk/js/jscntxt.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 506 by siliconforks, Sat Sep 26 23:15:22 2009 UTC revision 507 by siliconforks, Sun Jan 10 07:23:34 2010 UTC
# Line 1  Line 1 
1  /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-  /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2   * vim: set ts=8 sw=4 et tw=80:   * vim: set ts=8 sw=4 et tw=80:
3   *   *
4   * ***** BEGIN LICENSE BLOCK *****   * ***** BEGIN LICENSE BLOCK *****
# Line 41  Line 41 
41  /*  /*
42   * JS execution context.   * JS execution context.
43   */   */
44  #include "jsstddef.h"  #include <new>
45  #include <stdarg.h>  #include <stdarg.h>
46  #include <stdlib.h>  #include <stdlib.h>
47  #include <string.h>  #include <string.h>
48  #include "jstypes.h"  #include "jstypes.h"
49    #include "jsstdint.h"
50  #include "jsarena.h" /* Added by JSIFY */  #include "jsarena.h" /* Added by JSIFY */
51  #include "jsutil.h" /* Added by JSIFY */  #include "jsutil.h" /* Added by JSIFY */
52  #include "jsclist.h"  #include "jsclist.h"
# Line 58  Line 59 
59  #include "jsfun.h"  #include "jsfun.h"
60  #include "jsgc.h"  #include "jsgc.h"
61  #include "jslock.h"  #include "jslock.h"
62    #include "jsmath.h"
63  #include "jsnum.h"  #include "jsnum.h"
64  #include "jsobj.h"  #include "jsobj.h"
65  #include "jsopcode.h"  #include "jsopcode.h"
# Line 83  Line 85 
85  #ifdef JS_TRACER  #ifdef JS_TRACER
86      js_InitJIT(&data->traceMonitor);      js_InitJIT(&data->traceMonitor);
87  #endif  #endif
88        js_InitRandom(data);
89  }  }
90    
91  static void  static void
# Line 92  Line 95 
95      /* All GC-related things must be already removed at this point. */      /* All GC-related things must be already removed at this point. */
96      for (size_t i = 0; i != JS_ARRAY_LENGTH(data->scriptsToGC); ++i)      for (size_t i = 0; i != JS_ARRAY_LENGTH(data->scriptsToGC); ++i)
97          JS_ASSERT(!data->scriptsToGC[i]);          JS_ASSERT(!data->scriptsToGC[i]);
98        for (size_t i = 0; i != JS_ARRAY_LENGTH(data->nativeEnumCache); ++i)
99            JS_ASSERT(!data->nativeEnumCache[i]);
100  #endif  #endif
101    
102      js_FinishGSNCache(&data->gsnCache);      js_FinishGSNCache(&data->gsnCache);
# Line 104  Line 109 
109  static void  static void
110  PurgeThreadData(JSContext *cx, JSThreadData *data)  PurgeThreadData(JSContext *cx, JSThreadData *data)
111  {  {
112        js_PurgeGSNCache(&data->gsnCache);
113    
114        /* FIXME: bug 506341. */
115        js_PurgePropertyCache(cx, &data->propertyCache);
116    
117  # ifdef JS_TRACER  # ifdef JS_TRACER
118      JSTraceMonitor *tm = &data->traceMonitor;      JSTraceMonitor *tm = &data->traceMonitor;
     tm->reservedDoublePoolPtr = tm->reservedDoublePool;  
     tm->needFlush = JS_TRUE;  
119    
120      if (tm->recorder)      /*
121          tm->recorder->deepAbort();       * If we are about to regenerate shapes, we have to flush the JIT cache,
122         * which will eventually abort any current recording.
123         */
124        if (cx->runtime->gcRegenShapes)
125            tm->needFlush = JS_TRUE;
126    
127      /*      /*
128       * We want to keep tm->reservedObjects after the GC. So, unless we are       * We want to keep reserved doubles and objects after the GC. So, unless we
129       * shutting down, we don't purge them here and rather mark them during       * are shutting down, we don't purge them here and rather mark them during
130       * the GC, see MarkReservedObjects in jsgc.cpp.       * the GC, see MarkReservedObjects in jsgc.cpp.
131       */       */
132      if (cx->runtime->state == JSRTS_LANDING)      if (cx->runtime->state == JSRTS_LANDING) {
133            tm->reservedDoublePoolPtr = tm->reservedDoublePool;
134          tm->reservedObjects = NULL;          tm->reservedObjects = NULL;
135        }
136  # endif  # endif
137    
138      /* Destroy eval'ed scripts. */      /* Destroy eval'ed scripts. */
139      js_DestroyScriptsToGC(cx, data);      js_DestroyScriptsToGC(cx, data);
140    
141      js_PurgeGSNCache(&data->gsnCache);      js_PurgeCachedNativeEnumerators(cx, data);
     js_PurgePropertyCache(cx, &data->propertyCache);  
142  }  }
143    
144  #ifdef JS_THREADSAFE  #ifdef JS_THREADSAFE
# Line 134  Line 147 
147  NewThread(jsword id)  NewThread(jsword id)
148  {  {
149      JS_ASSERT(js_CurrentThreadId() == id);      JS_ASSERT(js_CurrentThreadId() == id);
150      JSThread *thread = (JSThread *) calloc(1, sizeof(JSThread));      JSThread *thread = (JSThread *) js_calloc(sizeof(JSThread));
151      if (!thread)      if (!thread)
152          return NULL;          return NULL;
153      JS_INIT_CLIST(&thread->contextList);      JS_INIT_CLIST(&thread->contextList);
# Line 150  Line 163 
163      JS_ASSERT(JS_CLIST_IS_EMPTY(&thread->contextList));      JS_ASSERT(JS_CLIST_IS_EMPTY(&thread->contextList));
164      JS_ASSERT(!thread->titleToShare);      JS_ASSERT(!thread->titleToShare);
165      FinishThreadData(&thread->data);      FinishThreadData(&thread->data);
166      free(thread);      js_free(thread);
167  }  }
168    
169  JSBool  JSThread *
170  js_InitContextThread(JSContext *cx)  js_CurrentThread(JSRuntime *rt)
171  {  {
     JS_ASSERT(!cx->thread);  
172      jsword id = js_CurrentThreadId();      jsword id = js_CurrentThreadId();
     JSRuntime *rt = cx->runtime;  
173      JS_LOCK_GC(rt);      JS_LOCK_GC(rt);
174    
175      /*      /*
# Line 178  Line 189 
189          JS_UNLOCK_GC(rt);          JS_UNLOCK_GC(rt);
190          thread = NewThread(id);          thread = NewThread(id);
191          if (!thread)          if (!thread)
192              return false;              return NULL;
193          JS_LOCK_GC(rt);          JS_LOCK_GC(rt);
194          js_WaitForGC(rt);          js_WaitForGC(rt);
195          entry = (JSThreadsHashEntry *)          entry = (JSThreadsHashEntry *)
# Line 187  Line 198 
198          if (!entry) {          if (!entry) {
199              JS_UNLOCK_GC(rt);              JS_UNLOCK_GC(rt);
200              DestroyThread(thread);              DestroyThread(thread);
201              return false;              return NULL;
202          }          }
203    
204          /* Another thread cannot initialize entry->thread. */          /* Another thread cannot initialize entry->thread. */
# Line 195  Line 206 
206          entry->thread = thread;          entry->thread = thread;
207      }      }
208    
209        return thread;
210    }
211    
212    JSBool
213    js_InitContextThread(JSContext *cx)
214    {
215        JSThread *thread = js_CurrentThread(cx->runtime);
216        if (!thread)
217            return false;
218    
219      JS_APPEND_LINK(&cx->threadLinks, &thread->contextList);      JS_APPEND_LINK(&cx->threadLinks, &thread->contextList);
220      cx->thread = thread;      cx->thread = thread;
221      return true;      return true;
# Line 251  Line 272 
272      if (JS_CLIST_IS_EMPTY(&thread->contextList)) {      if (JS_CLIST_IS_EMPTY(&thread->contextList)) {
273          JS_ASSERT(cx->thread != thread);          JS_ASSERT(cx->thread != thread);
274          js_DestroyScriptsToGC(cx, &thread->data);          js_DestroyScriptsToGC(cx, &thread->data);
275    
276            /*
277             * The following is potentially suboptimal as it also zeros the cache
278             * in data, but the code simplicity wins here.
279             */
280            js_PurgeCachedNativeEnumerators(cx, &thread->data);
281          DestroyThread(thread);          DestroyThread(thread);
282          return JS_DHASH_REMOVE;          return JS_DHASH_REMOVE;
283      }      }
284      PurgeThreadData(cx, &thread->data);      PurgeThreadData(cx, &thread->data);
285        memset(thread->gcFreeLists, 0, sizeof(thread->gcFreeLists));
286        return JS_DHASH_NEXT;
287    }
288    
289    static JSDHashOperator
290    thread_tracer(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32 /* index */,
291                  void *arg)
292    {
293        JSThread *thread = ((JSThreadsHashEntry *) hdr)->thread;
294        thread->data.mark((JSTracer *)arg);
295      return JS_DHASH_NEXT;      return JS_DHASH_NEXT;
296  }  }
297    
298  #endif /* JS_THREADSAFE */  #endif /* JS_THREADSAFE */
299    
300    JSThreadData *
301    js_CurrentThreadData(JSRuntime *rt)
302    {
303    #ifdef JS_THREADSAFE
304        JSThread *thread = js_CurrentThread(rt);
305        if (!thread)
306            return NULL;
307    
308        return &thread->data;
309    #else
310        return &rt->threadData;
311    #endif
312    }
313    
314  JSBool  JSBool
315  js_InitThreads(JSRuntime *rt)  js_InitThreads(JSRuntime *rt)
316  {  {
# Line 299  Line 350 
350  #endif  #endif
351  }  }
352    
353    void
354    js_TraceThreads(JSRuntime *rt, JSTracer *trc)
355    {
356    #ifdef JS_THREADSAFE
357        JS_DHashTableEnumerate(&rt->threads, thread_tracer, trc);
358    #else
359        rt->threadData.mark(trc);
360    #endif
361    }
362    
363  /*  /*
364   * JSOPTION_XML and JSOPTION_ANONFUNFIX must be part of the JS version   * JSOPTION_XML and JSOPTION_ANONFUNFIX must be part of the JS version
365   * associated with scripts, so in addition to storing them in cx->options we   * associated with scripts, so in addition to storing them in cx->options we
# Line 361  Line 422 
422       * runtime list. After that it can be accessed from another thread via       * runtime list. After that it can be accessed from another thread via
423       * js_ContextIterator.       * js_ContextIterator.
424       */       */
425      cx = (JSContext *) calloc(1, sizeof *cx);      void *mem = js_calloc(sizeof *cx);
426      if (!cx)      if (!mem)
427          return NULL;          return NULL;
428    
429      cx->runtime = rt;      cx = new (mem) JSContext(rt);
430      cx->debugHooks = &rt->globalDebugHooks;      cx->debugHooks = &rt->globalDebugHooks;
431  #if JS_STACK_GROWTH_DIRECTION > 0  #if JS_STACK_GROWTH_DIRECTION > 0
432      cx->stackLimit = (jsuword) -1;      cx->stackLimit = (jsuword) -1;
433  #endif  #endif
434      cx->scriptStackQuota = JS_DEFAULT_SCRIPT_STACK_QUOTA;      cx->scriptStackQuota = JS_DEFAULT_SCRIPT_STACK_QUOTA;
 #ifdef JS_THREADSAFE  
     cx->gcLocalFreeLists = (JSGCFreeListSet *) &js_GCEmptyFreeListSet;  
 #endif  
435      JS_STATIC_ASSERT(JSVERSION_DEFAULT == 0);      JS_STATIC_ASSERT(JSVERSION_DEFAULT == 0);
436      JS_ASSERT(cx->version == JSVERSION_DEFAULT);      JS_ASSERT(cx->version == JSVERSION_DEFAULT);
437      VOUCH_DOES_NOT_REQUIRE_STACK();      VOUCH_DOES_NOT_REQUIRE_STACK();
# Line 387  Line 445 
445      js_InitRegExpStatics(cx);      js_InitRegExpStatics(cx);
446      JS_ASSERT(cx->resolveFlags == 0);      JS_ASSERT(cx->resolveFlags == 0);
447    
448        if (!js_InitContextBusyArrayTable(cx)) {
449            FreeContext(cx);
450            return NULL;
451        }
452    
453  #ifdef JS_THREADSAFE  #ifdef JS_THREADSAFE
454      if (!js_InitContextThread(cx)) {      if (!js_InitContextThread(cx)) {
455          FreeContext(cx);          FreeContext(cx);
# Line 525  Line 588 
588              );              );
589      for (uintN i = 0; i < JS_ARRAY_LENGTH(table); ++i) {      for (uintN i = 0; i < JS_ARRAY_LENGTH(table); ++i) {
590          fprintf(fp, "%-8.8s  %llu\n",          fprintf(fp, "%-8.8s  %llu\n",
591                  table[i].name, *(uint64 *)((uint8 *)ecm + table[i].offset));                  table[i].name,
592                    (unsigned long long int) *(uint64 *)((uint8 *)ecm + table[i].offset));
593      }      }
594      fprintf(fp, "hit ratio %g%%\n", ecm->hit * 100. / ecm->probe);      fprintf(fp, "hit ratio %g%%\n", ecm->hit * 100. / ecm->probe);
595      fprintf(fp, "avg steps %g\n", double(ecm->step) / ecm->probe);      fprintf(fp, "avg steps %g\n", double(ecm->step) / ecm->probe);
# Line 620  Line 684 
684       */       */
685      if (cx->requestDepth == 0)      if (cx->requestDepth == 0)
686          js_WaitForGC(rt);          js_WaitForGC(rt);
     js_RevokeGCLocalFreeLists(cx);  
687  #endif  #endif
688      JS_REMOVE_LINK(&cx->link);      JS_REMOVE_LINK(&cx->link);
689      last = (rt->contextList.next == &rt->contextList);      last = (rt->contextList.next == &rt->contextList);
# Line 679  Line 742 
742  #endif  #endif
743    
744          if (last) {          if (last) {
             /* Clear builtin functions, which are recreated on demand. */  
             memset(rt->builtinFunctions, 0, sizeof rt->builtinFunctions);  
   
745              js_GC(cx, GC_LAST_CONTEXT);              js_GC(cx, GC_LAST_CONTEXT);
746              DUMP_EVAL_CACHE_METER(cx);              DUMP_EVAL_CACHE_METER(cx);
747              DUMP_FUNCTION_METER(cx);              DUMP_FUNCTION_METER(cx);
748    
             /*  
              * Free the script filename table if it exists and is empty. Do this  
              * after the last GC to avoid finalizers tripping on free memory.  
              */  
             if (rt->scriptFilenameTable &&  
                 rt->scriptFilenameTable->nentries == 0) {  
                 js_FinishRuntimeScriptState(rt);  
             }  
   
749              /* Take the runtime down, now that it has no contexts or atoms. */              /* Take the runtime down, now that it has no contexts or atoms. */
750              JS_LOCK_GC(rt);              JS_LOCK_GC(rt);
751              rt->state = JSRTS_DOWN;              rt->state = JSRTS_DOWN;
# Line 733  Line 784 
784      JS_FinishArenaPool(&cx->tempPool);      JS_FinishArenaPool(&cx->tempPool);
785    
786      if (cx->lastMessage)      if (cx->lastMessage)
787          free(cx->lastMessage);          js_free(cx->lastMessage);
788    
789      /* Remove any argument formatters. */      /* Remove any argument formatters. */
790      map = cx->argumentFormatMap;      map = cx->argumentFormatMap;
791      while (map) {      while (map) {
792          JSArgumentFormatMap *temp = map;          JSArgumentFormatMap *temp = map;
793          map = map->next;          map = map->next;
794          JS_free(cx, temp);          cx->free(temp);
795        }
796    
797        /* Destroy the busy array table. */
798        if (cx->busyArrayTable) {
799            JS_HashTableDestroy(cx->busyArrayTable);
800            cx->busyArrayTable = NULL;
801      }      }
802    
803      /* Destroy the resolve recursion damper. */      /* Destroy the resolve recursion damper. */
# Line 753  Line 810 
810      if (lrs) {      if (lrs) {
811          while ((lrc = lrs->topChunk) != &lrs->firstChunk) {          while ((lrc = lrs->topChunk) != &lrs->firstChunk) {
812              lrs->topChunk = lrc->down;              lrs->topChunk = lrc->down;
813              JS_free(cx, lrc);              cx->free(lrc);
814          }          }
815          JS_free(cx, lrs);          cx->free(lrs);
816      }      }
817    
818      /* Finally, free cx itself. */      /* Finally, free cx itself. */
819      free(cx);      js_free(cx);
820  }  }
821    
822  JSBool  JSBool
# Line 803  Line 860 
860      return cx;      return cx;
861  #else  #else
862      return js_ContextIterator(rt, JS_FALSE, &iter);      return js_ContextIterator(rt, JS_FALSE, &iter);
863  #endif            #endif
864  }  }
865    
866  #ifdef JS_THREADSAFE  #ifdef JS_THREADSAFE
# Line 997  Line 1054 
1054    
1055      lrs = cx->localRootStack;      lrs = cx->localRootStack;
1056      if (!lrs) {      if (!lrs) {
1057          lrs = (JSLocalRootStack *) JS_malloc(cx, sizeof *lrs);          lrs = (JSLocalRootStack *) cx->malloc(sizeof *lrs);
1058          if (!lrs)          if (!lrs)
1059              return JS_FALSE;              return JS_FALSE;
1060          lrs->scopeMark = JSLRS_NULL_MARK;          lrs->scopeMark = JSLRS_NULL_MARK;
# Line 1040  Line 1097 
1097          lrc = lrs->topChunk;          lrc = lrs->topChunk;
1098          JS_ASSERT(lrc != &lrs->firstChunk);          JS_ASSERT(lrc != &lrs->firstChunk);
1099          lrs->topChunk = lrc->down;          lrs->topChunk = lrc->down;
1100          JS_free(cx, lrc);          cx->free(lrc);
1101          --n;          --n;
1102      }      }
1103    
# Line 1080  Line 1137 
1137       */       */
1138      if (mark == 0) {      if (mark == 0) {
1139          cx->localRootStack = NULL;          cx->localRootStack = NULL;
1140          JS_free(cx, lrs);          cx->free(lrs);
1141      } else if (m == 0) {      } else if (m == 0) {
1142          lrs->topChunk = lrc->down;          lrs->topChunk = lrc->down;
1143          JS_free(cx, lrc);          cx->free(lrc);
1144      }      }
1145  }  }
1146    
# Line 1142  Line 1199 
1199          JS_ASSERT(n != 0);          JS_ASSERT(n != 0);
1200          JS_ASSERT(lrc != &lrs->firstChunk);          JS_ASSERT(lrc != &lrs->firstChunk);
1201          lrs->topChunk = lrc->down;          lrs->topChunk = lrc->down;
1202          JS_free(cx, lrc);          cx->free(lrc);
1203      }      }
1204  }  }
1205    
# Line 1171  Line 1228 
1228           * After lrs->firstChunk, trying to index at a power-of-two chunk           * After lrs->firstChunk, trying to index at a power-of-two chunk
1229           * boundary: need a new chunk.           * boundary: need a new chunk.
1230           */           */
1231          lrc = (JSLocalRootChunk *) JS_malloc(cx, sizeof *lrc);          lrc = (JSLocalRootChunk *) cx->malloc(sizeof *lrc);
1232          if (!lrc)          if (!lrc)
1233              return -1;              return -1;
1234          lrc->down = lrs->topChunk;          lrc->down = lrs->topChunk;
# Line 1364  Line 1421 
1421      }      }
1422    
1423      ReportError(cx, message, &report);      ReportError(cx, message, &report);
1424      free(message);      js_free(message);
1425      JS_free(cx, ucmessage);      cx->free(ucmessage);
1426      return warning;      return warning;
1427  }  }
1428    
# Line 1416  Line 1473 
1473               * pointers later.               * pointers later.
1474               */               */
1475              reportp->messageArgs = (const jschar **)              reportp->messageArgs = (const jschar **)
1476                  JS_malloc(cx, sizeof(jschar *) * (argCount + 1));                  cx->malloc(sizeof(jschar *) * (argCount + 1));
1477              if (!reportp->messageArgs)              if (!reportp->messageArgs)
1478                  return JS_FALSE;                  return JS_FALSE;
1479              reportp->messageArgs[argCount] = NULL;              reportp->messageArgs[argCount] = NULL;
# Line 1460  Line 1517 
1517                  * is used once and only once in the expansion !!!                  * is used once and only once in the expansion !!!
1518                  */                  */
1519                  reportp->ucmessage = out = (jschar *)                  reportp->ucmessage = out = (jschar *)
1520                      JS_malloc(cx, (expandedLength + 1) * sizeof(jschar));                      cx->malloc((expandedLength + 1) * sizeof(jschar));
1521                  if (!out) {                  if (!out) {
1522                      JS_free (cx, buffer);                      cx->free(buffer);
1523                      goto error;                      goto error;
1524                  }                  }
1525                  while (*fmt) {                  while (*fmt) {
# Line 1482  Line 1539 
1539                  }                  }
1540                  JS_ASSERT(expandedArgs == argCount);                  JS_ASSERT(expandedArgs == argCount);
1541                  *out = 0;                  *out = 0;
1542                  JS_free (cx, buffer);                  cx->free(buffer);
1543                  *messagep =                  *messagep =
1544                      js_DeflateString(cx, reportp->ucmessage,                      js_DeflateString(cx, reportp->ucmessage,
1545                                       (size_t)(out - reportp->ucmessage));                                       (size_t)(out - reportp->ucmessage));
# Line 1511  Line 1568 
1568          const char *defaultErrorMessage          const char *defaultErrorMessage
1569              = "No error message available for error number %d";              = "No error message available for error number %d";
1570          size_t nbytes = strlen(defaultErrorMessage) + 16;          size_t nbytes = strlen(defaultErrorMessage) + 16;
1571          *messagep = (char *)JS_malloc(cx, nbytes);          *messagep = (char *)cx->malloc(nbytes);
1572          if (!*messagep)          if (!*messagep)
1573              goto error;              goto error;
1574          JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);          JS_snprintf(*messagep, nbytes, defaultErrorMessage, errorNumber);
# Line 1524  Line 1581 
1581          if (charArgs) {          if (charArgs) {
1582              i = 0;              i = 0;
1583              while (reportp->messageArgs[i])              while (reportp->messageArgs[i])
1584                  JS_free(cx, (void *)reportp->messageArgs[i++]);                  cx->free((void *)reportp->messageArgs[i++]);
1585          }          }
1586          JS_free(cx, (void *)reportp->messageArgs);          cx->free((void *)reportp->messageArgs);
1587          reportp->messageArgs = NULL;          reportp->messageArgs = NULL;
1588      }      }
1589      if (reportp->ucmessage) {      if (reportp->ucmessage) {
1590          JS_free(cx, (void *)reportp->ucmessage);          cx->free((void *)reportp->ucmessage);
1591          reportp->ucmessage = NULL;          reportp->ucmessage = NULL;
1592      }      }
1593      if (*messagep) {      if (*messagep) {
1594          JS_free(cx, (void *)*messagep);          cx->free((void *)*messagep);
1595          *messagep = NULL;          *messagep = NULL;
1596      }      }
1597      return JS_FALSE;      return JS_FALSE;
# Line 1565  Line 1622 
1622      ReportError(cx, message, &report);      ReportError(cx, message, &report);
1623    
1624      if (message)      if (message)
1625          JS_free(cx, message);          cx->free(message);
1626      if (report.messageArgs) {      if (report.messageArgs) {
1627          /*          /*
1628           * js_ExpandErrorArguments owns its messageArgs only if it had to           * js_ExpandErrorArguments owns its messageArgs only if it had to
# Line 1574  Line 1631 
1631          if (charArgs) {          if (charArgs) {
1632              int i = 0;              int i = 0;
1633              while (report.messageArgs[i])              while (report.messageArgs[i])
1634                  JS_free(cx, (void *)report.messageArgs[i++]);                  cx->free((void *)report.messageArgs[i++]);
1635          }          }
1636          JS_free(cx, (void *)report.messageArgs);          cx->free((void *)report.messageArgs);
1637      }      }
1638      if (report.ucmessage)      if (report.ucmessage)
1639          JS_free(cx, (void *)report.ucmessage);          cx->free((void *)report.ucmessage);
1640    
1641      return warning;      return warning;
1642  }  }
# Line 1593  Line 1650 
1650          return;          return;
1651    
1652      if (cx->lastMessage)      if (cx->lastMessage)
1653          free(cx->lastMessage);          js_free(cx->lastMessage);
1654      cx->lastMessage = JS_strdup(cx, message);      cx->lastMessage = JS_strdup(cx, message);
1655      if (!cx->lastMessage)      if (!cx->lastMessage)
1656          return;          return;
# Line 1651  Line 1708 
1708                                            js_null_str, NULL);                                            js_null_str, NULL);
1709      }      }
1710    
1711      JS_free(cx, bytes);      cx->free(bytes);
1712      return ok;      return ok;
1713  }  }
1714    
# Line 1674  Line 1731 
1731      JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,      JS_ReportErrorNumber(cx, js_GetErrorMessage, NULL,
1732                           JSMSG_MISSING_FUN_ARG, argbuf,                           JSMSG_MISSING_FUN_ARG, argbuf,
1733                           bytes ? bytes : "");                           bytes ? bytes : "");
1734      JS_free(cx, bytes);      cx->free(bytes);
1735  }  }
1736    
1737  JSBool  JSBool
# Line 1693  Line 1750 
1750    
1751      ok = JS_ReportErrorFlagsAndNumber(cx, flags, js_GetErrorMessage,      ok = JS_ReportErrorFlagsAndNumber(cx, flags, js_GetErrorMessage,
1752                                        NULL, errorNumber, bytes, arg1, arg2);                                        NULL, errorNumber, bytes, arg1, arg2);
1753      JS_free(cx, bytes);      cx->free(bytes);
1754      return ok;      return ok;
1755  }  }
1756    
# Line 1722  Line 1779 
1779  js_InvokeOperationCallback(JSContext *cx)  js_InvokeOperationCallback(JSContext *cx)
1780  {  {
1781      JS_ASSERT(cx->operationCallbackFlag);      JS_ASSERT(cx->operationCallbackFlag);
1782        
1783      /*      /*
1784       * Reset the callback flag first, then yield. If another thread is racing       * Reset the callback flag first, then yield. If another thread is racing
1785       * us here we will accumulate another callback request which will be       * us here we will accumulate another callback request which will be
1786       * serviced at the next opportunity.       * serviced at the next opportunity.
1787       */       */
1788      cx->operationCallbackFlag = 0;      cx->operationCallbackFlag = 0;
# Line 1739  Line 1796 
1796       */       */
1797      if (cx->runtime->gcIsNeeded)      if (cx->runtime->gcIsNeeded)
1798          js_GC(cx, GC_NORMAL);          js_GC(cx, GC_NORMAL);
1799  #ifdef JS_THREADSAFE      #ifdef JS_THREADSAFE
1800      else      else
1801          JS_YieldRequest(cx);          JS_YieldRequest(cx);
1802  #endif  #endif
# Line 1814  Line 1871 
1871       */       */
1872      return (*pc == JSOP_CALL && imacpc) ? imacpc : pc;      return (*pc == JSOP_CALL && imacpc) ? imacpc : pc;
1873  }  }
1874    
1875    bool
1876    js_CurrentPCIsInImacro(JSContext *cx)
1877    {
1878    #ifdef JS_TRACER
1879        VOUCH_DOES_NOT_REQUIRE_STACK();
1880        return (JS_ON_TRACE(cx) ? cx->bailExit->imacpc : cx->fp->imacpc) != NULL;
1881    #else
1882        return false;
1883    #endif
1884    }

Legend:
Removed from v.506  
changed lines
  Added in v.507

  ViewVC Help
Powered by ViewVC 1.1.24