Reviewers: Toon Verwaest,

Message:
PTAL. Link to the original CL: https://chromiumcodereview.appspot.com/12326009

Description:
Revert r13699 "Debugger: ScopeMirror has N^2 algorithm when building closure
mirrors." because of WebKit crashes.

BUG=v8:2554
[email protected]


Please review this at https://chromiumcodereview.appspot.com/12321108/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/objects.h
  M src/runtime.cc
  M src/scopeinfo.cc


Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index e15eee346141985d42fc3a8f64c5cdaefc11de86..600faeeafe56f25d2cb0da753ee19432fd78570b 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3559,13 +3559,6 @@ class ScopeInfo : public FixedArray {
   // must be a symbol (canonicalized).
   int FunctionContextSlotIndex(String* name, VariableMode* mode);

-
- // Copies all the context locals into an object used to materialize a scope.
-  bool CopyContextLocalsToScopeObject(Isolate* isolate,
-                                      Handle<Context> context,
-                                      Handle<JSObject> scope_object);
-
-
   static Handle<ScopeInfo> Create(Scope* scope, Zone* zone);

   // Serializes empty scope info.
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index 37286463b17efc42f29c5189828459cbbeef9dbf..d9b226e430b02e377300c216cd69206bf179f5a1 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10588,6 +10588,34 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
 }


+// Copy all the context locals into an object used to materialize a scope.
+static bool CopyContextLocalsToScopeObject(
+    Isolate* isolate,
+    Handle<ScopeInfo> scope_info,
+    Handle<Context> context,
+    Handle<JSObject> scope_object) {
+  // Fill all context locals to the context extension.
+  for (int i = 0; i < scope_info->ContextLocalCount(); i++) {
+    VariableMode mode;
+    InitializationFlag init_flag;
+    int context_index = scope_info->ContextSlotIndex(
+        scope_info->ContextLocalName(i), &mode, &init_flag);
+
+    RETURN_IF_EMPTY_HANDLE_VALUE(
+        isolate,
+        SetProperty(isolate,
+                    scope_object,
+                    Handle<String>(scope_info->ContextLocalName(i)),
+                    Handle<Object>(context->get(context_index), isolate),
+                    NONE,
+                    kNonStrictMode),
+        false);
+  }
+
+  return true;
+}
+
+
// Create a plain JSObject which materializes the local scope for the specified
 // frame.
 static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
@@ -10637,8 +10665,8 @@ static Handle<JSObject> MaterializeLocalScopeWithFrameInspector(
     // Third fill all context locals.
     Handle<Context> frame_context(Context::cast(frame->context()));
     Handle<Context> function_context(frame_context->declaration_context());
-    if (!scope_info->CopyContextLocalsToScopeObject(
-            isolate, function_context, local_scope)) {
+    if (!CopyContextLocalsToScopeObject(
+            isolate, scope_info, function_context, local_scope)) {
       return Handle<JSObject>();
     }

@@ -10790,8 +10818,8 @@ static Handle<JSObject> MaterializeClosure(Isolate* isolate,
       isolate->factory()->NewJSObject(isolate->object_function());

   // Fill all context locals to the context extension.
-  if (!scope_info->CopyContextLocalsToScopeObject(
-          isolate, context, closure_scope)) {
+  if (!CopyContextLocalsToScopeObject(
+          isolate, scope_info, context, closure_scope)) {
     return Handle<JSObject>();
   }

@@ -10910,8 +10938,8 @@ static Handle<JSObject> MaterializeBlockScope(
       isolate->factory()->NewJSObject(isolate->object_function());

   // Fill all context locals.
-  if (!scope_info->CopyContextLocalsToScopeObject(
-          isolate, context, block_scope)) {
+  if (!CopyContextLocalsToScopeObject(
+          isolate, scope_info, context, block_scope)) {
     return Handle<JSObject>();
   }

@@ -10933,8 +10961,8 @@ static Handle<JSObject> MaterializeModuleScope(
       isolate->factory()->NewJSObject(isolate->object_function());

   // Fill all context locals.
-  if (!scope_info->CopyContextLocalsToScopeObject(
-          isolate, context, module_scope)) {
+  if (!CopyContextLocalsToScopeObject(
+          isolate, scope_info, context, module_scope)) {
     return Handle<JSObject>();
   }

Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index 5ec2527cc79d14290106b38c1e08772350d1b56d..c0b2c4c8e6cf4799ccf7a5257cea87ba989f1c31 100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -362,29 +362,6 @@ int ScopeInfo::FunctionContextSlotIndex(String* name, VariableMode* mode) {
 }


-bool ScopeInfo::CopyContextLocalsToScopeObject(
-    Isolate* isolate,
-    Handle<Context> context,
-    Handle<JSObject> scope_object) {
-  // Fill all context locals to the context extension.
-  int start = ContextLocalNameEntriesIndex();
-  int end = start + ContextLocalCount();
-  for (int i = start; i < end; ++i) {
-    int context_index = Context::MIN_CONTEXT_SLOTS + i - start;
-    RETURN_IF_EMPTY_HANDLE_VALUE(
-        isolate,
-        SetProperty(isolate,
-                    scope_object,
-                    Handle<String>(String::cast(get(i))),
-                    Handle<Object>(context->get(context_index), isolate),
-                    ::NONE,
-                    kNonStrictMode),
-        false);
-  }
-  return true;
-}
-
-
 int ScopeInfo::ParameterEntriesIndex() {
   ASSERT(length() > 0);
   return kVariablePartIndex;


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to