Changeset 1864 in webkit for trunk/JavaScriptCore/kjs/function.cpp
- Timestamp:
- Aug 19, 2002, 1:54:20 AM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/JavaScriptCore/kjs/function.cpp
r1859 r1864 56 56 : InternalFunctionImp( 57 57 static_cast<FunctionPrototypeImp*>(exec->interpreter()->builtinFunctionPrototype().imp()) 58 ), param(0L), ident(n) , argStack(0)58 ), param(0L), ident(n) 59 59 { 60 60 Value protect(this); 61 argStack = new ListImp(); 62 Value protectArgStack( argStack ); // this also calls setGcAllowed on argStack 63 //fprintf(stderr,"FunctionImp::FunctionImp this=%p argStack=%p\n"); 61 //fprintf(stderr,"FunctionImp::FunctionImp this=%p\n"); 64 62 put(exec,"arguments",Null(),ReadOnly|DontDelete|DontEnum); 65 63 } … … 67 65 FunctionImp::~FunctionImp() 68 66 { 69 // The function shouldn't be deleted while it is still executed; argStack70 // should be set to 0 by the last call to popArgs()71 //assert(argStack->isEmpty());72 // Accessing argStack from here is a problem though.73 // When the function isn't used anymore, it's not marked, and neither is the74 // argStack, so both can be deleted - in any order!75 67 delete param; 76 68 } … … 79 71 { 80 72 InternalFunctionImp::mark(); 81 if (argStack && !argStack->marked())82 argStack->mark();83 73 } 84 74 … … 115 105 newExec.setException(exec->exception()); // could be null 116 106 117 // In order to maintain our "arguments" property, we maintain a list of arguments118 // properties from earlier in the execution stack. Upon return, we restore the119 // previous arguments object using popArgs().107 // In order to maintain our "arguments" property, we save the old 108 // value from a possible earlier call. Upon return, we restore the 109 // previous arguments object. 120 110 // Note: this does not appear to be part of the spec 111 Value oldArgs = get(&newExec, "arguments"); 112 121 113 if (codeType() == FunctionCode) { 122 114 assert(ctx.activationObject().inherits(&ActivationImp::info)); 123 115 Object argsObj = static_cast<ActivationImp*>(ctx.activationObject().imp())->argumentsObject(); 124 116 put(&newExec, "arguments", argsObj, DontDelete|DontEnum|ReadOnly); 125 pushArgs(&newExec, argsObj);126 117 } 127 118 … … 137 128 exec->setException(newExec.exception()); 138 129 if (codeType() == FunctionCode) 139 p opArgs(&newExec);130 put(&newExec, "arguments", oldArgs, DontDelete|DontEnum|ReadOnly); 140 131 141 132 #ifdef KJS_VERBOSE … … 228 219 void FunctionImp::processVarDecls(ExecState */*exec*/) 229 220 { 230 }231 232 void FunctionImp::pushArgs(ExecState *exec, const Object &args)233 {234 argStack->append(args);235 put(exec,"arguments",args,ReadOnly|DontDelete|DontEnum);236 }237 238 void FunctionImp::popArgs(ExecState *exec)239 {240 argStack->removeLast();241 if (argStack->isEmpty()) {242 put(exec,"arguments",Null(),ReadOnly|DontDelete|DontEnum);243 }244 else245 put(exec,"arguments",argStack->at(argStack->size()-1),ReadOnly|DontDelete|DontEnum);246 221 } 247 222
Note:
See TracChangeset
for help on using the changeset viewer.