Revision: 13030
Author:   [email protected]
Date:     Wed Nov 21 23:58:59 2012
Log:      Reduced TLS accesses even further.

Thread the Isolate through FindCodeInCache, FindCodeInSpecialCache and
SetProperty. Reduced the number of TLS accesses while running the Octane
benchmark down to 19% compared to the beginning of the cleanups.

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

Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/src/code-stubs.cc
 /branches/bleeding_edge/src/code-stubs.h
 /branches/bleeding_edge/src/handles.cc
 /branches/bleeding_edge/src/handles.h
 /branches/bleeding_edge/src/ic.cc
 /branches/bleeding_edge/src/runtime-profiler.cc
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/test/cctest/test-compiler.cc
 /branches/bleeding_edge/test/cctest/test-debug.cc

=======================================
--- /branches/bleeding_edge/src/api.cc  Wed Nov 21 02:16:07 2012
+++ /branches/bleeding_edge/src/api.cc  Wed Nov 21 23:58:59 2012
@@ -2857,6 +2857,7 @@
   i::Handle<i::Object> value_obj = Utils::OpenHandle(*value);
   EXCEPTION_PREAMBLE(isolate);
   i::Handle<i::Object> obj = i::SetProperty(
+      isolate,
       self,
       key_obj,
       value_obj,
=======================================
--- /branches/bleeding_edge/src/code-stubs.cc   Wed Nov 14 07:59:45 2012
+++ /branches/bleeding_edge/src/code-stubs.cc   Wed Nov 21 23:58:59 2012
@@ -37,11 +37,11 @@
 namespace v8 {
 namespace internal {

-bool CodeStub::FindCodeInCache(Code** code_out) {
-  Heap* heap = Isolate::Current()->heap();
-  int index = heap->code_stubs()->FindEntry(GetKey());
+bool CodeStub::FindCodeInCache(Code** code_out, Isolate* isolate) {
+  UnseededNumberDictionary* stubs = isolate->heap()->code_stubs();
+  int index = stubs->FindEntry(GetKey());
   if (index != UnseededNumberDictionary::kNotFound) {
-    *code_out = Code::cast(heap->code_stubs()->ValueAt(index));
+    *code_out = Code::cast(stubs->ValueAt(index));
     return true;
   }
   return false;
@@ -93,8 +93,8 @@
   Heap* heap = isolate->heap();
   Code* code;
   if (UseSpecialCache()
-      ? FindCodeInSpecialCache(&code)
-      : FindCodeInCache(&code)) {
+      ? FindCodeInSpecialCache(&code, isolate)
+      : FindCodeInCache(&code, isolate)) {
     ASSERT(IsPregenerated() == code->is_pregenerated());
     return Handle<Code>(code);
   }
@@ -297,8 +297,7 @@
 }


-bool ICCompareStub::FindCodeInSpecialCache(Code** code_out) {
-  Isolate* isolate = known_map_->GetIsolate();
+bool ICCompareStub::FindCodeInSpecialCache(Code** code_out, Isolate* isolate) {
   Factory* factory = isolate->factory();
   Code::Flags flags = Code::ComputeFlags(
       static_cast<Code::Kind>(GetCodeKind()),
=======================================
--- /branches/bleeding_edge/src/code-stubs.h    Wed Nov 14 07:59:45 2012
+++ /branches/bleeding_edge/src/code-stubs.h    Wed Nov 21 23:58:59 2012
@@ -141,7 +141,7 @@
   bool CompilingCallsToThisStubIsGCSafe() {
     bool is_pregenerated = IsPregenerated();
     Code* code = NULL;
-    CHECK(!is_pregenerated || FindCodeInCache(&code));
+    CHECK(!is_pregenerated || FindCodeInCache(&code, Isolate::Current()));
     return is_pregenerated;
   }

@@ -160,7 +160,7 @@
   virtual bool SometimesSetsUpAFrame() { return true; }

   // Lookup the code in the (possibly custom) cache.
-  bool FindCodeInCache(Code** code_out);
+  bool FindCodeInCache(Code** code_out, Isolate* isolate);

  protected:
   static bool CanUseFPRegisters();
@@ -202,7 +202,9 @@
   virtual void AddToSpecialCache(Handle<Code> new_object) { }

// Find code in a specialized cache, work is delegated to the specific stub.
-  virtual bool FindCodeInSpecialCache(Code** code_out) { return false; }
+  virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate) {
+    return false;
+  }

   // If a stub uses a special cache override this.
   virtual bool UseSpecialCache() { return false; }
@@ -653,7 +655,7 @@
Condition GetCondition() const { return CompareIC::ComputeCondition(op_); }

   virtual void AddToSpecialCache(Handle<Code> new_object);
-  virtual bool FindCodeInSpecialCache(Code** code_out);
+  virtual bool FindCodeInSpecialCache(Code** code_out, Isolate* isolate);
virtual bool UseSpecialCache() { return state_ == CompareIC::KNOWN_OBJECTS; }

   Token::Value op_;
=======================================
--- /branches/bleeding_edge/src/handles.cc      Wed Nov 21 02:01:05 2012
+++ /branches/bleeding_edge/src/handles.cc      Wed Nov 21 23:58:59 2012
@@ -229,12 +229,12 @@
 }


-Handle<Object> SetProperty(Handle<Object> object,
+Handle<Object> SetProperty(Isolate* isolate,
+                           Handle<Object> object,
                            Handle<Object> key,
                            Handle<Object> value,
                            PropertyAttributes attributes,
                            StrictModeFlag strict_mode) {
-  Isolate* isolate = Isolate::Current();
   CALL_HEAP_FUNCTION(
       isolate,
       Runtime::SetObjectProperty(
=======================================
--- /branches/bleeding_edge/src/handles.h       Fri Nov 16 00:38:11 2012
+++ /branches/bleeding_edge/src/handles.h       Wed Nov 21 23:58:59 2012
@@ -216,7 +216,8 @@

 int Utf8Length(Handle<String> str);

-Handle<Object> SetProperty(Handle<Object> object,
+Handle<Object> SetProperty(Isolate* isolate,
+                           Handle<Object> object,
                            Handle<Object> key,
                            Handle<Object> value,
                            PropertyAttributes attributes,
=======================================
--- /branches/bleeding_edge/src/ic.cc   Wed Nov 21 03:49:15 2012
+++ /branches/bleeding_edge/src/ic.cc   Wed Nov 21 23:58:59 2012
@@ -2559,7 +2559,7 @@
 Code* CompareIC::GetRawUninitialized(Token::Value op) {
   ICCompareStub stub(op, UNINITIALIZED, UNINITIALIZED, UNINITIALIZED);
   Code* code = NULL;
-  CHECK(stub.FindCodeInCache(&code));
+  CHECK(stub.FindCodeInCache(&code, Isolate::Current()));
   return code;
 }

=======================================
--- /branches/bleeding_edge/src/runtime-profiler.cc     Fri Nov 16 02:57:50 2012
+++ /branches/bleeding_edge/src/runtime-profiler.cc     Wed Nov 21 23:58:59 2012
@@ -200,11 +200,11 @@
   Code* stack_check_code = NULL;
   if (FLAG_count_based_interrupts) {
     InterruptStub interrupt_stub;
-    found_code = interrupt_stub.FindCodeInCache(&stack_check_code);
+ found_code = interrupt_stub.FindCodeInCache(&stack_check_code, isolate_);
   } else  // NOLINT
   {  // NOLINT
     StackCheckStub check_stub;
-    found_code = check_stub.FindCodeInCache(&stack_check_code);
+    found_code = check_stub.FindCodeInCache(&stack_check_code, isolate_);
   }
   if (found_code) {
     Code* replacement_code =
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Wed Nov 21 02:01:05 2012
+++ /branches/bleeding_edge/src/runtime.cc      Wed Nov 21 23:58:59 2012
@@ -10639,7 +10639,8 @@

     RETURN_IF_EMPTY_HANDLE_VALUE(
         isolate,
-        SetProperty(scope_object,
+        SetProperty(isolate,
+                    scope_object,
                     Handle<String>(scope_info->ContextLocalName(i)),
                     Handle<Object>(context->get(context_index), isolate),
                     NONE,
@@ -10674,7 +10675,8 @@

     RETURN_IF_EMPTY_HANDLE_VALUE(
         isolate,
-        SetProperty(local_scope,
+        SetProperty(isolate,
+                    local_scope,
                     Handle<String>(scope_info->ParameterName(i)),
                     value,
                     NONE,
@@ -10686,7 +10688,8 @@
   for (int i = 0; i < scope_info->StackLocalCount(); ++i) {
     RETURN_IF_EMPTY_HANDLE_VALUE(
         isolate,
-        SetProperty(local_scope,
+        SetProperty(isolate,
+                    local_scope,
                     Handle<String>(scope_info->StackLocalName(i)),
                     Handle<Object>(frame_inspector->GetExpression(i)),
                     NONE,
@@ -10720,7 +10723,8 @@
           Handle<String> key(String::cast(keys->get(i)));
           RETURN_IF_EMPTY_HANDLE_VALUE(
               isolate,
-              SetProperty(local_scope,
+              SetProperty(isolate,
+                          local_scope,
                           key,
                           GetProperty(ext, key),
                           NONE,
@@ -10781,7 +10785,8 @@
       Handle<String> key(String::cast(keys->get(i)));
        RETURN_IF_EMPTY_HANDLE_VALUE(
           isolate,
-          SetProperty(closure_scope,
+          SetProperty(isolate,
+                      closure_scope,
                       key,
                       GetProperty(ext, key),
                       NONE,
@@ -10805,7 +10810,12 @@
       isolate->factory()->NewJSObject(isolate->object_function());
   RETURN_IF_EMPTY_HANDLE_VALUE(
       isolate,
-      SetProperty(catch_scope, name, thrown_object, NONE, kNonStrictMode),
+      SetProperty(isolate,
+                  catch_scope,
+                  name,
+                  thrown_object,
+                  NONE,
+                  kNonStrictMode),
       Handle<JSObject>());
   return catch_scope;
 }
=======================================
--- /branches/bleeding_edge/test/cctest/test-compiler.cc Thu Sep 13 08:06:15 2012 +++ /branches/bleeding_edge/test/cctest/test-compiler.cc Wed Nov 21 23:58:59 2012
@@ -100,10 +100,11 @@


 static void SetGlobalProperty(const char* name, Object* value) {
+  Isolate* isolate = Isolate::Current();
   Handle<Object> object(value);
   Handle<String> symbol = FACTORY->LookupAsciiSymbol(name);
   Handle<JSObject> global(Isolate::Current()->context()->global_object());
-  SetProperty(global, symbol, object, NONE, kNonStrictMode);
+  SetProperty(isolate, global, symbol, object, NONE, kNonStrictMode);
 }


=======================================
--- /branches/bleeding_edge/test/cctest/test-debug.cc Tue Nov 13 04:27:03 2012 +++ /branches/bleeding_edge/test/cctest/test-debug.cc Wed Nov 21 23:58:59 2012
@@ -146,7 +146,8 @@
   inline v8::Context* operator*() { return *context_; }
   inline bool IsReady() { return !context_.IsEmpty(); }
   void ExposeDebug() {
-    v8::internal::Debug* debug = v8::internal::Isolate::Current()->debug();
+    v8::internal::Isolate* isolate = v8::internal::Isolate::Current();
+    v8::internal::Debug* debug = isolate->debug();
// Expose the debug context global object in the global object for testing.
     debug->Load();
     debug->debug_context()->set_security_token(
@@ -156,7 +157,7 @@
         v8::Utils::OpenHandle(*context_->Global())));
     Handle<v8::internal::String> debug_string =
         FACTORY->LookupAsciiSymbol("debug");
-    SetProperty(global, debug_string,
+    SetProperty(isolate, global, debug_string,
         Handle<Object>(debug->debug_context()->global_proxy()), DONT_ENUM,
         ::v8::internal::kNonStrictMode);
   }

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

Reply via email to