Changeset 153457 in webkit for trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
- Timestamp:
- Jul 29, 2013, 9:33:35 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/interpreter/Interpreter.cpp
r153221 r153457 558 558 } 559 559 } 560 560 JSString* Interpreter:: stackTraceAsString(ExecState* exec, Vector<StackFrame> stackTrace) 561 { 562 // FIXME: JSStringJoiner could be more efficient than StringBuilder here. 563 StringBuilder builder; 564 for (unsigned i = 0; i < stackTrace.size(); i++) { 565 builder.append(String(stackTrace[i].toString(exec))); 566 if (i != stackTrace.size() - 1) 567 builder.append('\n'); 568 } 569 return jsString(&exec->vm(), builder.toString()); 570 } 571 561 572 void Interpreter::addStackTraceIfNecessary(CallFrame* callFrame, JSValue error) 562 573 { … … 564 575 ASSERT(callFrame == vm->topCallFrame || callFrame == callFrame->lexicalGlobalObject()->globalExec() || callFrame == callFrame->dynamicGlobalObject()->globalExec()); 565 576 566 if ( error.isObject()) {567 if ( asObject(error)->hasProperty(callFrame, vm->propertyNames->stack))577 if (vm->exceptionStack().size()) { 578 if (!error.isObject() || asObject(error)->hasProperty(callFrame, vm->propertyNames->stack)) 568 579 return; 569 580 } … … 575 586 return; 576 587 577 JSObject* errorObject = asObject(error); 578 JSGlobalObject* globalObject = 0; 579 if (isTerminatedExecutionException(error)) 580 globalObject = vm->dynamicGlobalObject; 581 else 582 globalObject = errorObject->globalObject(); 583 584 // FIXME: JSStringJoiner could be more efficient than StringBuilder here. 585 StringBuilder builder; 586 for (unsigned i = 0; i < stackTrace.size(); i++) { 587 builder.append(String(stackTrace[i].toString(globalObject->globalExec()).impl())); 588 if (i != stackTrace.size() - 1) 589 builder.append('\n'); 590 } 591 592 errorObject->putDirect(*vm, vm->propertyNames->stack, jsString(vm, builder.toString()), ReadOnly | DontDelete); 588 // Note: 'error' might already have a stack property if it was created by the user (e.g. "new Error"). The stack 589 // now, as the error is thrown, might be different from the stack when it was created, so we overwrite it with 590 // the current stack unconditionally. 591 asObject(error)->putDirect(*vm, vm->propertyNames->stack, vm->interpreter->stackTraceAsString(vm->topCallFrame, stackTrace), ReadOnly | DontDelete); 592 593 593 } 594 594
Note:
See TracChangeset
for help on using the changeset viewer.