Revision: 6901
Author: [email protected]
Date: Tue Feb 22 08:07:40 2011
Log: [Isolates] Speed up Context::Lookup by avoiding implicit TLS reads.

Review URL: http://codereview.chromium.org/6538089
http://code.google.com/p/v8/source/detail?r=6901

Modified:
 /branches/experimental/isolates/src/contexts.cc
 /branches/experimental/isolates/src/runtime.cc

=======================================
--- /branches/experimental/isolates/src/contexts.cc     Fri Feb 18 04:13:28 2011
+++ /branches/experimental/isolates/src/contexts.cc     Tue Feb 22 08:07:40 2011
@@ -76,8 +76,8 @@

Handle<Object> Context::Lookup(Handle<String> name, ContextLookupFlags flags, int* index_, PropertyAttributes* attributes) {
-  Heap* heap = GetHeap();
-  Handle<Context> context(this);
+  Isolate* isolate = GetIsolate();
+  Handle<Context> context(this, isolate);

   bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
   *index_ = -1;
@@ -98,7 +98,8 @@

     // check extension/with object
     if (context->has_extension()) {
-      Handle<JSObject> extension = Handle<JSObject>(context->extension());
+      Handle<JSObject> extension = Handle<JSObject>(context->extension(),
+                                                    isolate);
       // Context extension objects needs to behave as if they have no
       // prototype.  So even if we want to follow prototype chains, we
       // need to only do a local lookup for context extension objects.
@@ -123,7 +124,7 @@

       // check non-parameter locals in context
       Handle<SerializedScopeInfo> scope_info(
-          context->closure()->shared()->scope_info());
+          context->closure()->shared()->scope_info(), isolate);
       Variable::Mode mode;
       int index = scope_info->ContextSlotIndex(*name, &mode);
       ASSERT(index < 0 || index >= MIN_CONTEXT_SLOTS);
@@ -156,11 +157,12 @@
       int param_index = scope_info->ParameterIndex(*name);
       if (param_index >= 0) {
         // slot found.
-        int index =
- scope_info->ContextSlotIndex(heap->arguments_shadow_symbol(), NULL);
+        int index = scope_info->ContextSlotIndex(
+            isolate->heap()->arguments_shadow_symbol(), NULL);
ASSERT(index >= 0); // arguments must exist and be in the heap context
-        Handle<JSObject> arguments(JSObject::cast(context->get(index)));
-        ASSERT(arguments->HasLocalProperty(heap->length_symbol()));
+        Handle<JSObject> arguments(JSObject::cast(context->get(index)),
+                                   isolate);
+ ASSERT(arguments->HasLocalProperty(isolate->heap()->length_symbol()));
         if (FLAG_trace_contexts) {
PrintF("=> found parameter %d in arguments object\n", param_index);
         }
@@ -189,9 +191,10 @@
     if (context->IsGlobalContext()) {
       follow_context_chain = false;
     } else if (context->is_function_context()) {
- context = Handle<Context>(Context::cast(context->closure()->context())); + context = Handle<Context>(Context::cast(context->closure()->context()),
+                                isolate);
     } else {
-      context = Handle<Context>(context->previous());
+      context = Handle<Context>(context->previous(), isolate);
     }
   } while (follow_context_chain);

=======================================
--- /branches/experimental/isolates/src/runtime.cc      Tue Feb 22 07:27:46 2011
+++ /branches/experimental/isolates/src/runtime.cc      Tue Feb 22 08:07:40 2011
@@ -5444,7 +5444,7 @@
           isolate->heap()->AllocateUninitializedFixedArray(length);
       if (!maybe_obj->ToObject(&obj)) return maybe_obj;
     }
-    elements = Handle<FixedArray>(FixedArray::cast(obj));
+    elements = Handle<FixedArray>(FixedArray::cast(obj), isolate);

     Vector<const char> chars = s->ToAsciiVector();
     // Note, this will initialize all elements (not only the prefix)
@@ -7893,7 +7893,7 @@
   Handle<Object> receiver;  // Will be overwritten.

   // Compute the calling context.
-  Handle<Context> context = Handle<Context>(isolate->context());
+  Handle<Context> context = Handle<Context>(isolate->context(), isolate);
 #ifdef DEBUG
   // Make sure Isolate::context() agrees with the old code that traversed
   // the stack frames to compute the context.
@@ -7914,9 +7914,10 @@
     // reached.
     if (attributes != ABSENT || context->IsGlobalContext()) break;
     if (context->is_function_context()) {
- context = Handle<Context>(Context::cast(context->closure()->context())); + context = Handle<Context>(Context::cast(context->closure()->context()),
+                                isolate);
     } else {
-      context = Handle<Context>(context->previous());
+      context = Handle<Context>(context->previous(), isolate);
     }
   }

@@ -7938,7 +7939,7 @@
       receiver = Handle<Object>(context->get(index), isolate);
     } else if (receiver->IsJSContextExtensionObject()) {
       receiver = Handle<JSObject>(
-          isolate->context()->global()->global_receiver());
+          isolate->context()->global()->global_receiver(), isolate);
     }
     return MakePair(*callee, *receiver);
   }

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to