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

Diff of /trunk/js/jsscript.cpp

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

revision 584 by siliconforks, Sun Jan 10 07:23:34 2010 UTC revision 585 by siliconforks, Sun Sep 12 15:13:23 2010 UTC
# Line 67  Line 67 
67    
68  #include "jsscriptinlines.h"  #include "jsscriptinlines.h"
69    
70    const uint32 JSSLOT_EXEC_DEPTH          = JSSLOT_PRIVATE + 1;
71    const uint32 JSSCRIPT_RESERVED_SLOTS    = 1;
72    
73  #if JS_HAS_SCRIPT_OBJECT  #if JS_HAS_SCRIPT_OBJECT
74    
75  static const char js_script_exec_str[]    = "Script.prototype.exec";  static const char js_script_exec_str[]    = "Script.prototype.exec";
76  static const char js_script_compile_str[] = "Script.prototype.compile";  static const char js_script_compile_str[] = "Script.prototype.compile";
77    
 /*  
  * This routine requires that obj has been locked previously.  
  */  
78  static jsint  static jsint
79  GetScriptExecDepth(JSContext *cx, JSObject *obj)  GetScriptExecDepth(JSObject *obj)
80  {  {
81      jsval v;      jsval v = obj->fslots[JSSLOT_EXEC_DEPTH];
   
     JS_ASSERT(JS_IS_OBJ_LOCKED(cx, obj));  
     v = LOCKED_OBJ_GET_SLOT(obj, JSSLOT_START(&js_ScriptClass));  
82      return JSVAL_TO_INT(v);      return JSVAL_TO_INT(v);
83  }  }
84    
85  static void  static void
86  AdjustScriptExecDepth(JSContext *cx, JSObject *obj, jsint delta)  AdjustScriptExecDepth(JSObject *obj, jsint delta)
87  {  {
88      jsint execDepth;      jsint execDepth = GetScriptExecDepth(obj);
89        obj->fslots[JSSLOT_EXEC_DEPTH] = INT_TO_JSVAL(execDepth + delta);
     JS_LOCK_OBJ(cx, obj);  
     execDepth = GetScriptExecDepth(cx, obj);  
     LOCKED_OBJ_SET_SLOT(obj, JSSLOT_START(&js_ScriptClass),  
                         INT_TO_JSVAL(execDepth + delta));  
     JS_UNLOCK_OBJ(cx, obj);  
90  }  }
91    
92  #if JS_HAS_TOSOURCE  #if JS_HAS_TOSOURCE
# Line 271  Line 263 
263          return JS_FALSE;          return JS_FALSE;
264    
265      JS_LOCK_OBJ(cx, obj);      JS_LOCK_OBJ(cx, obj);
266      execDepth = GetScriptExecDepth(cx, obj);      execDepth = GetScriptExecDepth(obj);
267    
268      /*      /*
269       * execDepth must be 0 to allow compilation here, otherwise the JSScript       * execDepth must be 0 to allow compilation here, otherwise the JSScript
# Line 377  Line 369 
369          return JS_FALSE;          return JS_FALSE;
370    
371      /* Keep track of nesting depth for the script. */      /* Keep track of nesting depth for the script. */
372      AdjustScriptExecDepth(cx, obj, 1);      AdjustScriptExecDepth(obj, 1);
373    
374      /* Must get to out label after this */      /* Must get to out label after this */
375      script = (JSScript *) obj->getPrivate();      script = (JSScript *) obj->getPrivate();
# Line 396  Line 388 
388      ok = js_Execute(cx, scopeobj, script, caller, JSFRAME_EVAL, rval);      ok = js_Execute(cx, scopeobj, script, caller, JSFRAME_EVAL, rval);
389    
390  out:  out:
391      AdjustScriptExecDepth(cx, obj, -1);      AdjustScriptExecDepth(obj, -1);
392      return ok;      return ok;
393  }  }
394    
# Line 806  Line 798 
798      }      }
799    
800      JS_LOCK_OBJ(cx, obj);      JS_LOCK_OBJ(cx, obj);
801      execDepth = GetScriptExecDepth(cx, obj);      execDepth = GetScriptExecDepth(obj);
802    
803      /*      /*
804       * execDepth must be 0 to allow compilation here, otherwise the JSScript       * execDepth must be 0 to allow compilation here, otherwise the JSScript
# Line 899  Line 891 
891    
892  JS_FRIEND_DATA(JSClass) js_ScriptClass = {  JS_FRIEND_DATA(JSClass) js_ScriptClass = {
893      js_Script_str,      js_Script_str,
894      JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(1) |      JSCLASS_HAS_PRIVATE | JSCLASS_HAS_RESERVED_SLOTS(JSSCRIPT_RESERVED_SLOTS) |
895      JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_Script),      JSCLASS_MARK_IS_TRACE | JSCLASS_HAS_CACHED_PROTO(JSProto_Script),
896      JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,      JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,  JS_PropertyStub,
897      JS_EnumerateStub, JS_ResolveStub,   JS_ConvertStub,   script_finalize,      JS_EnumerateStub, JS_ResolveStub,   JS_ConvertStub,   script_finalize,

Legend:
Removed from v.584  
changed lines
  Added in v.585

  ViewVC Help
Powered by ViewVC 1.1.24