Reviewers: ulan,

Description:
Correctly handlify CopyContextLocalsToScopeObject.

Handlified functions that expect allocation must be static, i.e. not allow to
use 'this', since 'this' is not relocated by potential GC.

[email protected]
BUG=

Please review this at https://codereview.chromium.org/25704002/

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

Affected files (+18, -18 lines):
  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 cd651060dc83bab332ec64bc5dc2da299f09addd..a6e59d2745e592202294b2d1305024c91ed672c4 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -4103,9 +4103,9 @@ class ScopeInfo : public FixedArray {


// 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 bool CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
+                                             Handle<Context> context,
+ Handle<JSObject> scope_object);


   static Handle<ScopeInfo> Create(Scope* scope, Zone* zone);
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index d0754609f708ef49769ca799db168d1201e22874..9e3592b1c7aa835588230fc7c5dce45f2e6a9516 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -11395,8 +11395,8 @@ static Handle<JSObject> MaterializeLocalContext(Isolate* isolate,
   // 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, target)) {
+  if (!ScopeInfo::CopyContextLocalsToScopeObject(
+          scope_info, function_context, target)) {
     return Handle<JSObject>();
   }

@@ -11553,8 +11553,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 (!ScopeInfo::CopyContextLocalsToScopeObject(
+          scope_info, context, closure_scope)) {
     return Handle<JSObject>();
   }

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

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

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

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

Index: src/scopeinfo.cc
diff --git a/src/scopeinfo.cc b/src/scopeinfo.cc
index ba138f2addaa5a8cd3e54e4c684c2718a0e50c49..f1ae876ca3081f02ae4b397e22027106c9d589f6 100644
--- a/src/scopeinfo.cc
+++ b/src/scopeinfo.cc
@@ -363,14 +363,14 @@ int ScopeInfo::FunctionContextSlotIndex(String* name, VariableMode* mode) {
 }


-bool ScopeInfo::CopyContextLocalsToScopeObject(
-    Isolate* isolate,
-    Handle<Context> context,
-    Handle<JSObject> scope_object) {
-  int local_count = ContextLocalCount();
+bool ScopeInfo::CopyContextLocalsToScopeObject(Handle<ScopeInfo> scope_info,
+                                               Handle<Context> context,
+ Handle<JSObject> scope_object) {
+  Isolate* isolate = scope_info->GetIsolate();
+  int local_count = scope_info->ContextLocalCount();
   if (local_count == 0) return true;
   // Fill all context locals to the context extension.
-  int start = ContextLocalNameEntriesIndex();
+  int start = scope_info->ContextLocalNameEntriesIndex();
   int end = start + local_count;
   for (int i = start; i < end; ++i) {
     int context_index = Context::MIN_CONTEXT_SLOTS + i - start;
@@ -378,7 +378,7 @@ bool ScopeInfo::CopyContextLocalsToScopeObject(
         isolate,
         SetProperty(isolate,
                     scope_object,
-                    Handle<String>(String::cast(get(i))),
+                    Handle<String>(String::cast(scope_info->get(i))),
                     Handle<Object>(context->get(context_index), isolate),
                     ::NONE,
                     kNonStrictMode),


--
--
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