| Index: Source/bindings/dart/DartController.cpp
|
| diff --git a/Source/bindings/dart/DartController.cpp b/Source/bindings/dart/DartController.cpp
|
| index 4aec7a9161a004cdaec8cf4f69dc24eb1c8c15bd..fbf3aa957d47656583626f951fce16f11d0f8a3f 100644
|
| --- a/Source/bindings/dart/DartController.cpp
|
| +++ b/Source/bindings/dart/DartController.cpp
|
| @@ -200,6 +200,7 @@ Dart_Isolate DartController::createIsolate(const char* scriptURL, const char* en
|
|
|
| DartDebugServer::shared().registerIsolate(isolate);
|
| }
|
| +
|
| return isolate;
|
| }
|
|
|
| @@ -882,20 +883,51 @@ void DartController::collectScriptStates(ScriptState* v8ScriptState, Vector<Scri
|
| collectScriptStatesForIsolate(m_isolate, v8Context, result);
|
| }
|
|
|
| -void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, Vector<ScriptState*>& result)
|
| +LibraryIdMap* DartController::libraryIdMapForIsolate(Dart_Isolate isolate)
|
| {
|
| - if (!isolate)
|
| - return;
|
| - DartIsolateScope scope(isolate);
|
| - DartApiScope apiScope;
|
| - ScriptStatesMap::iterator it = m_scriptStates.find(isolate);
|
| LibraryIdMap* libraryIdMap;
|
| + ScriptStatesMap::iterator it = m_scriptStates.find(isolate);
|
| if (it == m_scriptStates.end()) {
|
| libraryIdMap = new LibraryIdMap();
|
| m_scriptStates.set(isolate, libraryIdMap);
|
| } else {
|
| libraryIdMap = it->value;
|
| }
|
| + return libraryIdMap;
|
| +}
|
| +
|
| +DartScriptState* DartController::lookupScriptState(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, intptr_t libraryId)
|
| +{
|
| + return lookupScriptStateFromLibraryIdMap(isolate, v8Context, libraryIdMapForIsolate(isolate), libraryId);
|
| +}
|
| +
|
| +DartScriptState* DartController::lookupScriptStateFromLibraryIdMap(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, LibraryIdMap* libraryIdMap, intptr_t libraryId)
|
| +{
|
| + // -1 cannot be used as a HashMap key however library ids are
|
| + // guaranteed to be non-negative so it is a non-issue.
|
| + ASSERT(libraryId >= 0);
|
| + // 0 cannot be used as a HashMap key so we add 1 to the library id to
|
| + // create a valid key.
|
| + intptr_t libraryIdKey = libraryId + 1;
|
| + LibraryIdMap::iterator libraryIter = libraryIdMap->find(libraryIdKey);
|
| + DartScriptState* scriptState;
|
| + if (libraryIter == libraryIdMap->end()) {
|
| + scriptState = new DartScriptState(isolate, libraryId, v8Context);
|
| + libraryIdMap->set(libraryIdKey, scriptState);
|
| + } else {
|
| + scriptState = libraryIter->value;
|
| + ASSERT(scriptState);
|
| + }
|
| + return scriptState;
|
| +}
|
| +
|
| +void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Handle<v8::Context> v8Context, Vector<ScriptState*>& result)
|
| +{
|
| + if (!isolate)
|
| + return;
|
| + DartIsolateScope scope(isolate);
|
| + DartApiScope apiScope;
|
| + LibraryIdMap* libraryIdMap = libraryIdMapForIsolate(isolate);
|
| Dart_Handle libraryIdList = Dart_GetLibraryIds();
|
|
|
| intptr_t length = 0;
|
| @@ -906,21 +938,7 @@ void DartController::collectScriptStatesForIsolate(Dart_Isolate isolate, v8::Han
|
| Dart_Handle exception = 0;
|
| intptr_t libraryId = DartUtilities::toInteger(libraryIdHandle, exception);
|
| ASSERT(!exception);
|
| - // -1 cannot be used as a HashMap key however library ids are
|
| - // guaranteed to be non-negative so it is a non-issue.
|
| - ASSERT(libraryId >= 0);
|
| - // 0 cannot be used as a HashMap key so we add 1 to the library id to
|
| - // create a valid key.
|
| - intptr_t libraryIdKey = libraryId + 1;
|
| - LibraryIdMap::iterator libraryIter = libraryIdMap->find(libraryIdKey);
|
| - DartScriptState* scriptState;
|
| - if (libraryIter == libraryIdMap->end()) {
|
| - scriptState = new DartScriptState(isolate, libraryId, v8Context);
|
| - libraryIdMap->set(libraryIdKey, scriptState);
|
| - } else {
|
| - scriptState = libraryIter->value;
|
| - ASSERT(scriptState);
|
| - }
|
| + DartScriptState* scriptState = lookupScriptStateFromLibraryIdMap(isolate, v8Context, libraryIdMap, libraryId);
|
| result.append(scriptState);
|
| }
|
| }
|
|
|