Revision: 21096
Author:   [email protected]
Date:     Wed Apr 30 15:13:38 2014 UTC
Log:      ScopeInfo::ContextSlotIndex() handlified.

[email protected]

Review URL: https://codereview.chromium.org/253263003
http://code.google.com/p/v8/source/detail?r=21096

Modified:
 /branches/bleeding_edge/src/contexts.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/scopeinfo.cc
 /branches/bleeding_edge/src/scopes.cc

=======================================
--- /branches/bleeding_edge/src/contexts.cc     Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/contexts.cc     Wed Apr 30 15:13:38 2014 UTC
@@ -137,7 +137,8 @@
       }
       VariableMode mode;
       InitializationFlag init_flag;
- int slot_index = scope_info->ContextSlotIndex(*name, &mode, &init_flag);
+      int slot_index =
+          ScopeInfo::ContextSlotIndex(scope_info, name, &mode, &init_flag);
       ASSERT(slot_index < 0 || slot_index >= MIN_CONTEXT_SLOTS);
       if (slot_index >= 0) {
         if (FLAG_trace_contexts) {
=======================================
--- /branches/bleeding_edge/src/objects.h       Wed Apr 30 14:33:35 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Wed Apr 30 15:13:38 2014 UTC
@@ -4489,9 +4489,10 @@
   // returns a value < 0. The name must be an internalized string.
// If the slot is present and mode != NULL, sets *mode to the corresponding
   // mode for that variable.
-  int ContextSlotIndex(String* name,
-                       VariableMode* mode,
-                       InitializationFlag* init_flag);
+  static int ContextSlotIndex(Handle<ScopeInfo> scope_info,
+                              Handle<String> name,
+                              VariableMode* mode,
+                              InitializationFlag* init_flag);

   // Lookup support for serialized scope info. Returns the
// parameter index for a given parameter name if the parameter is present;
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Apr 30 15:03:18 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Wed Apr 30 15:13:38 2014 UTC
@@ -11277,7 +11277,7 @@
       InitializationFlag init_flag;
       locals->set(local * 2, *name);
       int context_slot_index =
-          scope_info->ContextSlotIndex(*name, &mode, &init_flag);
+          ScopeInfo::ContextSlotIndex(scope_info, name, &mode, &init_flag);
       Object* value = context->get(context_slot_index);
       locals->set(local * 2 + 1, value);
       local++;
@@ -11449,10 +11449,10 @@


 static bool ParameterIsShadowedByContextLocal(Handle<ScopeInfo> info,
-                                              int index) {
+ Handle<String> parameter_name) {
   VariableMode mode;
   InitializationFlag flag;
- return info->ContextSlotIndex(info->ParameterName(index), &mode, &flag) != -1; + return ScopeInfo::ContextSlotIndex(info, parameter_name, &mode, &flag) != -1;
 }


@@ -11470,7 +11470,8 @@
   // First fill all parameters.
   for (int i = 0; i < scope_info->ParameterCount(); ++i) {
// Do not materialize the parameter if it is shadowed by a context local.
-    if (ParameterIsShadowedByContextLocal(scope_info, i)) continue;
+    Handle<String> name(scope_info->ParameterName(i));
+    if (ParameterIsShadowedByContextLocal(scope_info, name)) continue;

     HandleScope scope(isolate);
     Handle<Object> value(i < frame_inspector->GetParametersCount()
@@ -11478,7 +11479,6 @@
                              : isolate->heap()->undefined_value(),
                          isolate);
     ASSERT(!value->IsTheHole());
-    Handle<String> name(scope_info->ParameterName(i));

     RETURN_ON_EXCEPTION(
         isolate,
@@ -11521,11 +11521,11 @@
   // Parameters.
   for (int i = 0; i < scope_info->ParameterCount(); ++i) {
     // Shadowed parameters were not materialized.
-    if (ParameterIsShadowedByContextLocal(scope_info, i)) continue;
+    Handle<String> name(scope_info->ParameterName(i));
+    if (ParameterIsShadowedByContextLocal(scope_info, name)) continue;

     ASSERT(!frame->GetParameter(i)->IsTheHole());
     HandleScope scope(isolate);
-    Handle<String> name(scope_info->ParameterName(i));
     Handle<Object> value =
         Object::GetPropertyOrElement(target, name).ToHandleChecked();
     frame->SetParameterValue(i, *value);
@@ -11626,7 +11626,7 @@
       VariableMode mode;
       InitializationFlag init_flag;
       int context_index =
-          scope_info->ContextSlotIndex(*next_name, &mode, &init_flag);
+ ScopeInfo::ContextSlotIndex(scope_info, next_name, &mode, &init_flag);
       context->set(context_index, *new_value);
       return true;
     }
=======================================
--- /branches/bleeding_edge/src/scopeinfo.cc    Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/scopeinfo.cc    Wed Apr 30 15:13:38 2014 UTC
@@ -281,35 +281,41 @@
 }


-int ScopeInfo::ContextSlotIndex(String* name,
+int ScopeInfo::ContextSlotIndex(Handle<ScopeInfo> scope_info,
+                                Handle<String> name,
                                 VariableMode* mode,
                                 InitializationFlag* init_flag) {
   ASSERT(name->IsInternalizedString());
   ASSERT(mode != NULL);
   ASSERT(init_flag != NULL);
-  if (length() > 0) {
- ContextSlotCache* context_slot_cache = GetIsolate()->context_slot_cache();
-    int result = context_slot_cache->Lookup(this, name, mode, init_flag);
+  if (scope_info->length() > 0) {
+    ContextSlotCache* context_slot_cache =
+        scope_info->GetIsolate()->context_slot_cache();
+    int result =
+        context_slot_cache->Lookup(*scope_info, *name, mode, init_flag);
     if (result != ContextSlotCache::kNotFound) {
-      ASSERT(result < ContextLength());
+      ASSERT(result < scope_info->ContextLength());
       return result;
     }

-    int start = ContextLocalNameEntriesIndex();
-    int end = ContextLocalNameEntriesIndex() + ContextLocalCount();
+    int start = scope_info->ContextLocalNameEntriesIndex();
+    int end = scope_info->ContextLocalNameEntriesIndex() +
+        scope_info->ContextLocalCount();
     for (int i = start; i < end; ++i) {
-      if (name == get(i)) {
+      if (*name == scope_info->get(i)) {
         int var = i - start;
-        *mode = ContextLocalMode(var);
-        *init_flag = ContextLocalInitFlag(var);
+        *mode = scope_info->ContextLocalMode(var);
+        *init_flag = scope_info->ContextLocalInitFlag(var);
         result = Context::MIN_CONTEXT_SLOTS + var;
-        context_slot_cache->Update(this, name, *mode, *init_flag, result);
-        ASSERT(result < ContextLength());
+        context_slot_cache->Update(
+            *scope_info, *name, *mode, *init_flag, result);
+        ASSERT(result < scope_info->ContextLength());
         return result;
       }
     }
     // Cache as not found. Mode and init flag don't matter.
- context_slot_cache->Update(this, name, INTERNAL, kNeedsInitialization, -1);
+    context_slot_cache->Update(
+        *scope_info, *name, INTERNAL, kNeedsInitialization, -1);
   }
   return -1;
 }
=======================================
--- /branches/bleeding_edge/src/scopes.cc       Tue Apr 29 06:42:26 2014 UTC
+++ /branches/bleeding_edge/src/scopes.cc       Wed Apr 30 15:13:38 2014 UTC
@@ -379,7 +379,7 @@
   VariableMode mode;
   Variable::Location location = Variable::CONTEXT;
   InitializationFlag init_flag;
-  int index = scope_info_->ContextSlotIndex(*name, &mode, &init_flag);
+ int index = ScopeInfo::ContextSlotIndex(scope_info_, name, &mode, &init_flag);
   if (index < 0) {
     // Check parameters.
     index = scope_info_->ParameterIndex(*name);

--
--
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/d/optout.

Reply via email to