Chromium Code Reviews| Index: Source/bindings/dart/DartInjectedScript.cpp |
| diff --git a/Source/bindings/dart/DartInjectedScript.cpp b/Source/bindings/dart/DartInjectedScript.cpp |
| index 1db544cb97232e05f7bd4c0a257ad3cfecb849ef..e241ef0da4b89ce4e79b71c8de78b09f494deabf 100644 |
| --- a/Source/bindings/dart/DartInjectedScript.cpp |
| +++ b/Source/bindings/dart/DartInjectedScript.cpp |
| @@ -57,6 +57,8 @@ using WebCore::TypeBuilder::Runtime::PropertyPreview; |
| namespace WebCore { |
| +static const uint64_t kMaxSafeIntegerForDouble = 0x1fffffffffffffUL; |
| + |
| Dart_Handle getLibraryUrl(Dart_Handle handle) |
| { |
| intptr_t libraryId = 0; |
| @@ -744,7 +746,7 @@ void DartInjectedScript::restartFrame(ErrorString* errorString, const StackTrace |
| void DartInjectedScript::getStepInPositions(ErrorString* errorString, const StackTrace& callFrames, const String& callFrameId, RefPtr<Array<TypeBuilder::Debugger::Location> >& positions) |
| { |
| - ASSERT(!callFrames.isJavaScript()); |
| + ASSERT(callFrames.isJavaScript()); |
| if (!m_scriptState) { |
| *errorString = "Invalid DartInjectedScript"; |
| return; |
| @@ -757,13 +759,13 @@ void DartInjectedScript::getStepInPositions(ErrorString* errorString, const Stac |
| void DartInjectedScript::setVariableValue(ErrorString* errorString, const StackTrace& callFrames, const String* callFrameIdOpt, const String* functionObjectIdOpt, int scopeNumber, const String& variableName, const String& newValueStr) |
| { |
| + ASSERT(callFrames.isJavaScript()); |
| if (!m_scriptState) { |
| *errorString = "Invalid DartInjectedScript"; |
| return; |
| } |
| DartIsolateScope scope(m_scriptState->isolate()); |
| DartApiScope apiScope; |
| - ASSERT(!callFrames.isJavaScript()); |
| *errorString = "Not supported by Dart."; |
| return; |
| } |
| @@ -843,7 +845,7 @@ void addCompletions(Dart_Handle completions, RefPtr<TypeBuilder::Array<String> > |
| void DartInjectedScript::getCompletionsOnCallFrame(ErrorString* errorString, const StackTrace& callFrames, const Vector<StackTrace>& asyncCallStacks, const String& callFrameId, const String& expression, RefPtr<TypeBuilder::Array<String> >* result) |
| { |
| - ASSERT(!callFrames.isJavaScript()); |
| + ASSERT(callFrames.isJavaScript()); |
| *result = TypeBuilder::Array<String>::create(); |
| if (!m_scriptState) { |
| *errorString = "Invalid DartInjectedScript"; |
| @@ -1215,8 +1217,9 @@ Dart_ActivationFrame DartInjectedScript::callFrameForId(const StackTrace& callFr |
| if (asyncOrdinal > 0) { // 1-based index |
| ASSERT(asyncOrdinal <= (int)asyncCallStacks.size()); |
| if (asyncOrdinal <= (int)asyncCallStacks.size()) { |
| - ASSERT(!asyncCallStacks[asyncOrdinal-1].isJavaScript()); |
| - result = Dart_GetActivationFrame(asyncCallStacks[asyncOrdinal-1].asDart(), ordinal, &frame); |
| + StackTrace asyncCallStack = asyncCallStacks[asyncOrdinal-1]; |
| + ASSERT(!asyncCallStack.isJavaScript()); |
| + result = Dart_GetActivationFrame(asyncCallStack.asDart(), ordinal, &frame); |
| } else { |
| return 0; |
| } |
| @@ -1232,6 +1235,8 @@ PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac |
| ASSERT(!callFrames.isJavaScript()); |
| if (callFrames.isJavaScript()) |
| return nullptr; |
| + DartIsolateScope scope(m_scriptState->isolate()); |
| + DartApiScope apiScope; |
| Dart_StackTrace trace = callFrames.asDart(); |
| intptr_t length = 0; |
| Dart_Handle ALLOW_UNUSED result; |
| @@ -1240,6 +1245,7 @@ PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac |
| ASSERT(!Dart_IsError(result)); |
| DartScriptDebugServer& debugServer = DartScriptDebugServer::shared(); |
| Dart_Handle libraries = Dart_GetLibraryIds(); |
| + |
| for (intptr_t i = 0; i < length; i++) { |
| Dart_ActivationFrame frame = 0; |
| result = Dart_GetActivationFrame(trace, i, &frame); |
| @@ -1247,7 +1253,9 @@ PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac |
| Dart_Handle functionName = 0; |
| Dart_Handle function = 0; |
| Dart_CodeLocation location; |
| - Dart_ActivationFrameGetLocation(frame, &functionName, &function, &location); |
| + result = Dart_ActivationFrameGetLocation(frame, &functionName, &function, &location); |
| + ASSERT(!Dart_IsError(result)); |
| + |
| const String& url = DartUtilities::toString(location.script_url); |
| intptr_t line = 0; |
| intptr_t column = 0; |
| @@ -1302,13 +1310,24 @@ PassRefPtr<Array<CallFrame> > DartInjectedScript::wrapCallFrames(const StackTrac |
| .setObject(wrapDartHandle(libraries, DartDebuggerObject::Isolate, "backtrace", false)) |
| .release()); |
| - ret->addItem(CallFrame::create() |
| + RefPtr<CallFrame> callFrame = CallFrame::create() |
| .setCallFrameId(getCallFrameId(i, asyncOrdinal)) |
| .setFunctionName(DartUtilities::toString(functionName)) |
| .setLocation(locationJson) |
| .setScopeChain(scopeChain) |
| .setThis(thisObject) |
| - .release()); |
| + .release(); |
| + |
| + uintptr_t framePointer = 0; |
| + result = Dart_ActivationFrameGetFramePointer(frame, &framePointer); |
|
rmacnak
2014/09/08 22:51:44
Why not represent the frame pointer as a string or
Jacob
2014/09/10 17:58:56
I've switched to high and low halves instead of tr
|
| + // No frame pointers will actually be larger than 2^48 on a current x64 |
| + // machine but we truncate to 52 bits of precision to future proof the |
| + // method. As we don't care about the exact frame pointer only the |
| + // order of frame pointers, truncating to 52 bits will still generate the |
| + // correct ordering with high probability. |
| + framePointer = framePointer & kMaxSafeIntegerForDouble; |
| + callFrame->setFramePointer(static_cast<double>(framePointer)); |
| + ret->addItem(callFrame); |
| } |
| return ret; |
| } |