Revision: 5250
Author: [email protected]
Date: Wed Aug 11 17:28:10 2010
Log: [Isolates] Use ::GetHeap() more often.

++ indicates v8 tests (higher is better, reference/runtime)
-- indicates closure tests (lower is better, usec)

This patch (ia32):
++Crypto: 1877.750000
--closure-json-raw: 357.500000
++EarleyBoyer: 5594.500000
++ws-longfact: 99.900000
--closure-datetime-raw: 187.250000
++Score (version 6 (candidate)): 530.000000
--closure-uri-raw: 174.000000
++Solve: 73.775000
++Splay: 329.000000
++RegExp: 1442.250000
++Richards: 2429.250000
--closure-queue2-raw: 3939.500000
--closure-eval2-raw: 119.750000
++ws-IEEE754Conv: 79.975000
++Genetic: 80.900000
++RayTrace: 4155.250000
--closure-log-formatter-raw: 234.250000
++ws-huffman: 91.525000
++DeltaBlue: 2242.500000

Isolates head r5232 (ia32):
++Crypto: 1853.750000
--closure-json-raw: 371.750000
++EarleyBoyer: 5499.250000
++ws-longfact: 96.575000
--closure-datetime-raw: 187.750000
++Score (version 6 (candidate)): 524.000000
--closure-uri-raw: 173.500000
++Solve: 79.925000
++Splay: 323.750000
++RegExp: 1408.250000
++Richards: 2451.250000
--closure-queue2-raw: 4028.750000
--closure-eval2-raw: 115.500000
++ws-IEEE754Conv: 74.225000
++Genetic: 79.000000
++RayTrace: 4040.000000
--closure-log-formatter-raw: 241.000000
++ws-huffman: 91.350000
++DeltaBlue: 2245.250000

This patch (x64):
++Crypto: 2001.750000
--closure-json-raw: 355.250000
++EarleyBoyer: 5079.500000
++ws-longfact: 101.500000
--closure-datetime-raw: 209.250000
++Score (version 6 (candidate)): 519.500000
--closure-uri-raw: 180.750000
++Solve: 85.325000
++Splay: 297.500000
++RegExp: 1386.500000
++Richards: 2281.500000
--closure-queue2-raw: 3591.500000
--closure-eval2-raw: 133.250000
++ws-IEEE754Conv: 90.275000
++Genetic: 87.750000
++RayTrace: 3687.500000
--closure-log-formatter-raw: 260.000000
++ws-huffman: 86.300000
++DeltaBlue: 1852.500000

Isolates head r5232 (x64):
++Crypto: 1990.000000
--closure-json-raw: 365.500000
++EarleyBoyer: 5091.000000
++ws-longfact: 104.000000
--closure-datetime-raw: 213.500000
++Score (version 6 (candidate)): 516.500000
--closure-uri-raw: 189.500000
++Solve: 82.000000
++Splay: 301.000000
++RegExp: 1381.750000
++Richards: 2263.000000
--closure-queue2-raw: 3723.500000
--closure-eval2-raw: 134.500000
++ws-IEEE754Conv: 86.000000
++Genetic: 89.500000
++RayTrace: 3633.750000
--closure-log-formatter-raw: 265.000000
++ws-huffman: 87.050000
++DeltaBlue: 1840.500000

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

Modified:
 /branches/experimental/isolates/src/contexts.cc
 /branches/experimental/isolates/src/objects-inl.h
 /branches/experimental/isolates/src/objects.cc

=======================================
--- /branches/experimental/isolates/src/contexts.cc     Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/contexts.cc     Wed Aug 11 17:28:10 2010
@@ -76,6 +76,7 @@

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

   bool follow_context_chain = (flags & FOLLOW_CONTEXT_CHAIN) != 0;
@@ -155,10 +156,10 @@
       if (param_index >= 0) {
         // slot found.
         int index =
- scope_info->ContextSlotIndex(HEAP->arguments_shadow_symbol(), NULL); + scope_info->ContextSlotIndex(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()));
+        ASSERT(arguments->HasLocalProperty(heap->length_symbol()));
         if (FLAG_trace_contexts) {
PrintF("=> found parameter %d in arguments object\n", param_index);
         }
=======================================
--- /branches/experimental/isolates/src/objects-inl.h Fri Aug 6 16:03:39 2010 +++ /branches/experimental/isolates/src/objects-inl.h Wed Aug 11 17:28:10 2010
@@ -105,9 +105,6 @@
   void holder::set_##name(bool value) {                    \
     set_##field(BooleanBit::set(field(), offset, value));  \
   }
-
-
-#define GET_HEAP (HeapObject::cast(this)->GetHeap())


 bool Object::IsInstanceOf(FunctionTemplateInfo* expected) {
@@ -451,22 +448,27 @@


 bool Object::IsContext() {
-  return Object::IsHeapObject()
-    && (HeapObject::cast(this)->map() == GET_HEAP->context_map() ||
-        HeapObject::cast(this)->map() == GET_HEAP->catch_context_map() ||
-        HeapObject::cast(this)->map() == GET_HEAP->global_context_map());
+  if (Object::IsHeapObject()) {
+    Heap* heap = HeapObject::cast(this)->GetHeap();
+    return (HeapObject::cast(this)->map() == heap->context_map() ||
+            HeapObject::cast(this)->map() == heap->catch_context_map() ||
+            HeapObject::cast(this)->map() == heap->global_context_map());
+  }
+  return false;
 }


 bool Object::IsCatchContext() {
-  return Object::IsHeapObject()
-    && HeapObject::cast(this)->map() == GET_HEAP->catch_context_map();
+  return Object::IsHeapObject() &&
+      HeapObject::cast(this)->map() ==
+      HeapObject::cast(this)->GetHeap()->catch_context_map();
 }


 bool Object::IsGlobalContext() {
-  return Object::IsHeapObject()
-    && HeapObject::cast(this)->map() == GET_HEAP->global_context_map();
+  return Object::IsHeapObject() &&
+      HeapObject::cast(this)->map() ==
+      HeapObject::cast(this)->GetHeap()->global_context_map();
 }


@@ -548,18 +550,21 @@


 bool Object::IsHashTable() {
-  return Object::IsHeapObject()
-    && HeapObject::cast(this)->map() == GET_HEAP->hash_table_map();
+  return Object::IsHeapObject() &&
+      HeapObject::cast(this)->map() ==
+      HeapObject::cast(this)->GetHeap()->hash_table_map();
 }


 bool Object::IsDictionary() {
-  return IsHashTable() && this != GET_HEAP->symbol_table();
+  return IsHashTable() && this !=
+         HeapObject::cast(this)->GetHeap()->symbol_table();
 }


 bool Object::IsSymbolTable() {
-  return IsHashTable() && this == GET_HEAP->raw_unchecked_symbol_table();
+  return IsHashTable() && this ==
+         HeapObject::cast(this)->GetHeap()->raw_unchecked_symbol_table();
 }


@@ -1472,7 +1477,7 @@


 void FixedArray::set_null(int index) {
-  set_null(GetHeap(),index);
+  set_null(GetHeap(), index);
 }


@@ -2100,7 +2105,7 @@
   Scavenger callback = reinterpret_cast<Scavenger>(
       READ_INTPTR_FIELD(this, kScavengerCallbackOffset));

- ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. + ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead.
   ASSERT(callback == Heap::GetScavenger(instance_type(),
                                         instance_size()));

@@ -2108,7 +2113,7 @@
 }

 inline void Map::set_scavenger(Scavenger callback) {
- ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead. + ASSERT(instance_type() != MAP_TYPE); // MAP_TYPE has Heap pointer instead.
   WRITE_INTPTR_FIELD(this,
                      kScavengerCallbackOffset,
                      reinterpret_cast<intptr_t>(callback));
=======================================
--- /branches/experimental/isolates/src/objects.cc      Mon Aug  9 14:00:56 2010
+++ /branches/experimental/isolates/src/objects.cc      Wed Aug 11 17:28:10 2010
@@ -43,7 +43,6 @@
 #include "disassembler.h"
 #endif

-
 namespace v8 {
 namespace internal {

@@ -54,7 +53,7 @@


 static Object* CreateJSValue(JSFunction* constructor, Object* value) {
-  Object* result = HEAP->AllocateJSObject(constructor);
+  Object* result = constructor->GetHeap()->AllocateJSObject(constructor);
   if (result->IsFailure()) return result;
   JSValue::cast(result)->set_value(value);
   return result;
@@ -75,14 +74,19 @@


 Object* Object::ToObject() {
- Context* global_context = Isolate::Current()->context()->global_context();
   if (IsJSObject()) {
     return this;
   } else if (IsNumber()) {
+    Isolate* isolate = Isolate::Current();
+    Context* global_context = isolate->context()->global_context();
     return CreateJSValue(global_context->number_function(), this);
   } else if (IsBoolean()) {
+    Heap* heap = HeapObject::cast(this)->GetHeap();
+    Context* global_context = heap->isolate()->context()->global_context();
     return CreateJSValue(global_context->boolean_function(), this);
   } else if (IsString()) {
+    Heap* heap = HeapObject::cast(this)->GetHeap();
+    Context* global_context = heap->isolate()->context()->global_context();
     return CreateJSValue(global_context->string_function(), this);
   }

@@ -92,35 +96,43 @@


 Object* Object::ToBoolean() {
-  if (IsTrue()) return HEAP->true_value();
-  if (IsFalse()) return HEAP->false_value();
+  if (IsTrue()) return this;
+  if (IsFalse()) return this;
   if (IsSmi()) {
-    return HEAP->ToBoolean(Smi::cast(this)->value() != 0);
-  }
-  if (IsUndefined() || IsNull()) return HEAP->false_value();
+ return Isolate::Current()->heap()->ToBoolean(Smi::cast(this)->value() != 0);
+  }
+  if (IsUndefined() || IsNull()) {
+    return HeapObject::cast(this)->GetHeap()->false_value();
+  }
   // Undetectable object is false
   if (IsUndetectableObject()) {
-    return HEAP->false_value();
+    return HeapObject::cast(this)->GetHeap()->false_value();
   }
   if (IsString()) {
-    return HEAP->ToBoolean(String::cast(this)->length() != 0);
+    return HeapObject::cast(this)->GetHeap()->ToBoolean(
+        String::cast(this)->length() != 0);
   }
   if (IsHeapNumber()) {
     return HeapNumber::cast(this)->HeapNumberToBoolean();
   }
-  return HEAP->true_value();
+  return Isolate::Current()->heap()->true_value();
 }


 void Object::Lookup(String* name, LookupResult* result) {
   if (IsJSObject()) return JSObject::cast(this)->Lookup(name, result);
   Object* holder = NULL;
- Context* global_context = Isolate::Current()->context()->global_context();
   if (IsString()) {
+    Heap* heap = HeapObject::cast(this)->GetHeap();
+    Context* global_context = heap->isolate()->context()->global_context();
     holder = global_context->string_function()->instance_prototype();
   } else if (IsNumber()) {
+    Heap* heap = Isolate::Current()->heap();
+    Context* global_context = heap->isolate()->context()->global_context();
     holder = global_context->number_function()->instance_prototype();
   } else if (IsBoolean()) {
+    Heap* heap = HeapObject::cast(this)->GetHeap();
+    Context* global_context = heap->isolate()->context()->global_context();
     holder = global_context->boolean_function()->instance_prototype();
   }
   ASSERT(holder != NULL);  // Cannot handle null or undefined.
@@ -153,6 +165,8 @@
     RETURN_IF_SCHEDULED_EXCEPTION();
     return value;
   }
+
+  Heap* heap = name->GetHeap();

   // api style callbacks.
   if (structure->IsAccessorInfo()) {
@@ -173,7 +187,9 @@
       result = call_fun(v8::Utils::ToLocal(key), info);
     }
     RETURN_IF_SCHEDULED_EXCEPTION();
-    if (result.IsEmpty()) return HEAP->undefined_value();
+    if (result.IsEmpty()) {
+      return heap->undefined_value();
+    }
     return *v8::Utils::OpenHandle(*result);
   }

@@ -185,7 +201,7 @@
JSFunction::cast(getter));
     }
     // Getter is not a function.
-    return HEAP->undefined_value();
+    return heap->undefined_value();
   }

   UNREACHABLE();
@@ -199,7 +215,7 @@
   Handle<JSFunction> fun(JSFunction::cast(getter));
   Handle<Object> self(receiver);
 #ifdef ENABLE_DEBUGGER_SUPPORT
-  Debug* debug = Isolate::Current()->debug();
+  Debug* debug = fun->GetHeap()->isolate()->debug();
   // Handle stepping into a getter if step into is active.
   if (debug->StepInActive()) {
     debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
@@ -220,6 +236,7 @@
     LookupResult* result,
     String* name,
     PropertyAttributes* attributes) {
+  Heap* heap = name->GetHeap();
   if (result->IsProperty()) {
     switch (result->type()) {
       case CALLBACKS: {
@@ -271,8 +288,8 @@

   // No accessible property found.
   *attributes = ABSENT;
-  Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
-  return HEAP->undefined_value();
+  heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_GET);
+  return heap->undefined_value();
 }


@@ -281,6 +298,7 @@
     LookupResult* result,
     String* name,
     bool continue_search) {
+  Heap* heap = name->GetHeap();
   if (result->IsProperty()) {
     switch (result->type()) {
       case CALLBACKS: {
@@ -334,7 +352,7 @@
     }
   }

-  Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
+  heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_HAS);
   return ABSENT;
 }

@@ -368,11 +386,12 @@
                                         Object* value,
                                         PropertyDetails details) {
   ASSERT(!HasFastProperties());
+  Heap* heap = name->GetHeap();
   int entry = property_dictionary()->FindEntry(name);
   if (entry == StringDictionary::kNotFound) {
     Object* store_value = value;
     if (IsGlobalObject()) {
-      store_value = HEAP->AllocateJSGlobalPropertyCell(value);
+      store_value = heap->AllocateJSGlobalPropertyCell(value);
       if (store_value->IsFailure()) return store_value;
     }
     Object* dict = property_dictionary()->Add(name, store_value, details);
@@ -399,6 +418,7 @@

 Object* JSObject::DeleteNormalizedProperty(String* name, DeleteMode mode) {
   ASSERT(!HasFastProperties());
+  Heap* heap = GetHeap();
   StringDictionary* dictionary = property_dictionary();
   int entry = dictionary->FindEntry(name);
   if (entry != StringDictionary::kNotFound) {
@@ -406,7 +426,7 @@
     if (IsGlobalObject()) {
       PropertyDetails details = dictionary->DetailsAt(entry);
       if (details.IsDontDelete()) {
-        if (mode != FORCE_DELETION) return HEAP->false_value();
+        if (mode != FORCE_DELETION) return heap->false_value();
         // When forced to delete global properties, we have to make a
         // map change to invalidate any ICs that think they can load
         // from the DontDelete cell without checking if it contains
@@ -417,13 +437,13 @@
       }
       JSGlobalPropertyCell* cell =
           JSGlobalPropertyCell::cast(dictionary->ValueAt(entry));
-      cell->set_value(HEAP->the_hole_value());
+      cell->set_value(heap->the_hole_value());
       dictionary->DetailsAtPut(entry, details.AsDeleted());
     } else {
       return dictionary->DeleteProperty(entry, mode);
     }
   }
-  return HEAP->true_value();
+  return heap->true_value();
 }


@@ -449,6 +469,7 @@
   // Make sure that the top context does not change when doing
   // callbacks or interceptor calls.
   AssertNoContextChange ncc;
+  Heap* heap = name->GetHeap();

   // Traverse the prototype chain from the current object (this) to
   // the holder and check for access rights. This avoid traversing the
@@ -456,7 +477,7 @@
   // holder will always be the interceptor holder and the search may
   // only continue with a current object just after the interceptor
   // holder in the prototype chain.
- Object* last = result->IsProperty() ? result->holder() : HEAP->null_value(); + Object* last = result->IsProperty() ? result->holder() : heap->null_value();
   for (Object* current = this; true; current = current->GetPrototype()) {
     if (current->IsAccessCheckNeeded()) {
       // Check if we're allowed to read from the current object. Note
@@ -464,7 +485,7 @@
       // property from the current object, we still check that we have
       // access to it.
       JSObject* checked = JSObject::cast(current);
- if (!Isolate::Current()->MayNamedAccess(checked, name, v8::ACCESS_GET)) { + if (!heap->isolate()->MayNamedAccess(checked, name, v8::ACCESS_GET)) {
         return checked->GetPropertyWithFailedAccessCheck(receiver,
                                                          result,
                                                          name,
@@ -479,7 +500,7 @@

   if (!result->IsProperty()) {
     *attributes = ABSENT;
-    return HEAP->undefined_value();
+    return heap->undefined_value();
   }
   *attributes = result->GetAttributes();
   Object* value;
@@ -488,11 +509,11 @@
     case NORMAL:
       value = holder->GetNormalizedProperty(result);
       ASSERT(!value->IsTheHole() || result->IsReadOnly());
-      return value->IsTheHole() ? HEAP->undefined_value() : value;
+      return value->IsTheHole() ? heap->undefined_value() : value;
     case FIELD:
       value = holder->FastPropertyAt(result->GetFieldIndex());
       ASSERT(!value->IsTheHole() || result->IsReadOnly());
-      return value->IsTheHole() ? HEAP->undefined_value() : value;
+      return value->IsTheHole() ? heap->undefined_value() : value;
     case CONSTANT_FUNCTION:
       return result->GetConstantFunction();
     case CALLBACKS:
@@ -513,7 +534,7 @@

 Object* Object::GetElementWithReceiver(Object* receiver, uint32_t index) {
   // Non-JS objects do not have integer indexed properties.
-  if (!IsJSObject()) return HEAP->undefined_value();
+  if (!IsJSObject()) return Isolate::Current()->heap()->undefined_value();
return JSObject::cast(this)->GetElementWithReceiver(JSObject::cast(receiver),
                                                       index);
 }
@@ -522,14 +543,15 @@
 Object* Object::GetPrototype() {
// The object is either a number, a string, a boolean, or a real JS object.
   if (IsJSObject()) return JSObject::cast(this)->map()->prototype();
-  Context* context = Isolate::Current()->context()->global_context();
+  Heap* heap = Isolate::Current()->heap();
+  Context* context = heap->isolate()->context()->global_context();

   if (IsNumber()) return context->number_function()->instance_prototype();
   if (IsString()) return context->string_function()->instance_prototype();
   if (IsBoolean()) {
     return context->boolean_function()->instance_prototype();
   } else {
-    return HEAP->null_value();
+    return heap->null_value();
   }
 }

@@ -628,6 +650,7 @@
   if (!HEAP->IsAllocationAllowed()) return this;
 #endif

+  Heap* heap = GetHeap();
   switch (StringShape(this).representation_tag()) {
     case kConsStringTag: {
       ConsString* cs = ConsString::cast(this);
@@ -637,12 +660,12 @@
// There's little point in putting the flat string in new space if the
       // cons string is in old space.  It can never get GCed until there is
       // an old space GC.
-      PretenureFlag tenure = HEAP->InNewSpace(this) ? pretenure : TENURED;
+      PretenureFlag tenure = heap->InNewSpace(this) ? pretenure : TENURED;
       int len = length();
       Object* object;
       String* result;
       if (IsAsciiRepresentation()) {
-        object = HEAP->AllocateRawAsciiString(len, tenure);
+        object = heap->AllocateRawAsciiString(len, tenure);
         if (object->IsFailure()) return object;
         result = String::cast(object);
         String* first = cs->first();
@@ -655,7 +678,7 @@
                     0,
                     len - first_length);
       } else {
-        object = HEAP->AllocateRawTwoByteString(len, tenure);
+        object = heap->AllocateRawTwoByteString(len, tenure);
         if (object->IsFailure()) return object;
         result = String::cast(object);
         uc16* dest = SeqTwoByteString::cast(result)->GetChars();
@@ -669,7 +692,7 @@
                     len - first_length);
       }
       cs->set_first(result);
-      cs->set_second(HEAP->empty_string());
+      cs->set_second(heap->empty_string());
       return result;
     }
     default:
@@ -693,7 +716,7 @@
                   resource->length() * sizeof(smart_chars[0])) == 0);
   }
 #endif  // DEBUG
-
+  Heap* heap = GetHeap();
   int size = this->Size();  // Byte size of the original string.
   if (size < ExternalString::kSize) {
// The string is too small to fit an external String in its place. This can
@@ -709,8 +732,8 @@
   // Morph the object to an external string by adjusting the map and
   // reinitializing the fields.
   this->set_map(is_ascii ?
-                HEAP->external_string_with_ascii_data_map() :
-                HEAP->external_string_map());
+                heap->external_string_with_ascii_data_map() :
+                heap->external_string_map());
   ExternalTwoByteString* self = ExternalTwoByteString::cast(this);
   self->set_length(length);
   self->set_hash_field(hash_field);
@@ -721,13 +744,13 @@
     self->Hash();  // Force regeneration of the hash value.
     // Now morph this external string into a external symbol.
     this->set_map(is_ascii ?
-                  HEAP->external_symbol_with_ascii_data_map() :
-                  HEAP->external_symbol_map());
+                  heap->external_symbol_with_ascii_data_map() :
+                  heap->external_symbol_map());
   }

   // Fill the remainder of the string with dead wood.
   int new_size = this->Size();  // Byte size of the external String object.
-  HEAP->CreateFillerObjectAt(this->address() + new_size, size - new_size);
+  heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
   return true;
 }

@@ -744,7 +767,7 @@
                   resource->length() * sizeof(smart_chars[0])) == 0);
   }
 #endif  // DEBUG
-
+  Heap* heap = GetHeap();
   int size = this->Size();  // Byte size of the original string.
   if (size < ExternalString::kSize) {
// The string is too small to fit an external String in its place. This can
@@ -758,7 +781,7 @@

   // Morph the object to an external string by adjusting the map and
   // reinitializing the fields.
-  this->set_map(HEAP->external_ascii_string_map());
+  this->set_map(heap->external_ascii_string_map());
   ExternalAsciiString* self = ExternalAsciiString::cast(this);
   self->set_length(length);
   self->set_hash_field(hash_field);
@@ -768,12 +791,12 @@
   if (is_symbol) {
     self->Hash();  // Force regeneration of the hash value.
     // Now morph this external string into a external symbol.
-    this->set_map(HEAP->external_ascii_symbol_map());
+    this->set_map(heap->external_ascii_symbol_map());
   }

   // Fill the remainder of the string with dead wood.
   int new_size = this->Size();  // Byte size of the external String object.
-  HEAP->CreateFillerObjectAt(this->address() + new_size, size - new_size);
+  heap->CreateFillerObjectAt(this->address() + new_size, size - new_size);
   return true;
 }

@@ -872,15 +895,16 @@
     // All other JSObjects are rather similar to each other (JSObject,
     // JSGlobalProxy, JSGlobalObject, JSUndetectableObject, JSValue).
     default: {
+      Heap* heap = GetHeap();
       Object* constructor = map()->constructor();
       bool printed = false;
       if (constructor->IsHeapObject() &&
-          !HEAP->Contains(HeapObject::cast(constructor))) {
+          !heap->Contains(HeapObject::cast(constructor))) {
         accumulator->Add("!!!INVALID CONSTRUCTOR!!!");
       } else {
         bool global_object = IsJSGlobalProxy();
         if (constructor->IsJSFunction()) {
-          if (!HEAP->Contains(JSFunction::cast(constructor)->shared())) {
+          if (!heap->Contains(JSFunction::cast(constructor)->shared())) {
             accumulator->Add("!!!INVALID SHARED ON CONSTRUCTOR!!!");
           } else {
             Object* constructor_name =
@@ -916,11 +940,12 @@

 void HeapObject::HeapObjectShortPrint(StringStream* accumulator) {
   // if (!Heap::InNewSpace(this)) PrintF("*", this);
-  if (!HEAP->Contains(this)) {
+  Heap* heap = GetHeap();
+  if (!heap->Contains(this)) {
     accumulator->Add("!!!INVALID POINTER!!!");
     return;
   }
-  if (!HEAP->Contains(map())) {
+  if (!heap->Contains(map())) {
     accumulator->Add("!!!INVALID MAP!!!");
     return;
   }
@@ -1159,8 +1184,8 @@
   // NaN, +0, and -0 should return the false object
   switch (fpclassify(value())) {
     case FP_NAN:  // fall through
-    case FP_ZERO: return HEAP->false_value();
-    default: return HEAP->true_value();
+    case FP_ZERO: return GetHeap()->false_value();
+    default: return GetHeap()->true_value();
   }
 }

@@ -1185,20 +1210,20 @@

 String* JSObject::class_name() {
   if (IsJSFunction()) {
-    return HEAP->function_class_symbol();
+    return GetHeap()->function_class_symbol();
   }
   if (map()->constructor()->IsJSFunction()) {
     JSFunction* constructor = JSFunction::cast(map()->constructor());
     return String::cast(constructor->shared()->instance_class_name());
   }
   // If the constructor is not present, return "Object".
-  return HEAP->Object_symbol();
+  return GetHeap()->Object_symbol();
 }


 String* JSObject::constructor_name() {
   if (IsJSFunction()) {
-    return HEAP->closure_symbol();
+    return GetHeap()->closure_symbol();
   }
   if (map()->constructor()->IsJSFunction()) {
     JSFunction* constructor = JSFunction::cast(map()->constructor());
@@ -1206,7 +1231,7 @@
return name->length() > 0 ? name : constructor->shared()->inferred_name();
   }
   // If the constructor is not present, return "Object".
-  return HEAP->Object_symbol();
+  return GetHeap()->Object_symbol();
 }


@@ -1238,8 +1263,8 @@
                                   PropertyAttributes attributes) {
   // Normalize the object if the name is an actual string (not the
   // hidden symbols) and is not a real identifier.
+  Isolate* isolate = GetHeap()->isolate();
   StringInputBuffer buffer(name);
-  Isolate* isolate = Isolate::Current();
   if (!isolate->scanner_character_classes()->IsIdentifier(&buffer) &&
       name != isolate->heap()->hidden_symbol()) {
     Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
@@ -1261,7 +1286,7 @@
   // global object_function's map and there is not a transition for name.
   bool allow_map_transition =
         !old_descriptors->Contains(name) &&
- (Isolate::Current()->context()->global_context()->object_function()->
+        (isolate->context()->global_context()->object_function()->
             map() != map());

   ASSERT(index < map()->inobject_properties() ||
@@ -1308,6 +1333,8 @@
PropertyAttributes attributes) {
   ASSERT(!HEAP->InNewSpace(function));

+  Heap* heap = GetHeap();
+
   // Allocate new instance descriptors with (name, function) added
   ConstantFunctionDescriptor d(name, function, attributes);
   Object* new_descriptors =
@@ -1325,7 +1352,7 @@

   // If the old map is the global object map (from new Object()),
   // then transitions are not added to it, so we are done.
-  if (old_map == Isolate::Current()->context()->global_context()->
+  if (old_map == heap->isolate()->context()->global_context()->
       object_function()->map()) {
     return function;
   }
@@ -1359,6 +1386,7 @@
                                   Object* value,
                                   PropertyAttributes attributes) {
   ASSERT(!HasFastProperties());
+  Heap* heap = GetHeap();
   StringDictionary* dict = property_dictionary();
   Object* store_value = value;
   if (IsGlobalObject()) {
@@ -1375,7 +1403,7 @@
       dict->SetEntry(entry, name, store_value, details);
       return value;
     }
-    store_value = HEAP->AllocateJSGlobalPropertyCell(value);
+    store_value = heap->AllocateJSGlobalPropertyCell(value);
     if (store_value->IsFailure()) return store_value;
     JSGlobalPropertyCell::cast(store_value)->set_value(value);
   }
@@ -1391,16 +1419,17 @@
                               Object* value,
                               PropertyAttributes attributes) {
   ASSERT(!IsJSGlobalProxy());
+  Heap* heap = GetHeap();
   if (!map()->is_extensible()) {
     Handle<Object> args[1] = {Handle<String>(name)};
-    return Isolate::Current()->Throw(
+    return heap->isolate()->Throw(
*Factory::NewTypeError("object_not_extensible", HandleVector(args, 1)));
   }
   if (HasFastProperties()) {
     // Ensure the descriptor array does not get too big.
     if (map()->instance_descriptors()->number_of_descriptors() <
         DescriptorArray::kMaxNumberOfDescriptors) {
-      if (value->IsJSFunction() && !HEAP->InNewSpace(value)) {
+      if (value->IsJSFunction() && !heap->InNewSpace(value)) {
         return AddConstantFunctionProperty(name,
                                            JSFunction::cast(value),
                                            attributes);
@@ -1464,7 +1493,7 @@
     return result;
   }
   // Do not add transitions to the map of "new Object()".
-  if (map() == Isolate::Current()->context()->global_context()->
+  if (map() == GetHeap()->isolate()->context()->global_context()->
       object_function()->map()) {
     return result;
   }
@@ -1532,6 +1561,7 @@
 Object* JSObject::SetPropertyWithInterceptor(String* name,
                                              Object* value,
PropertyAttributes attributes) {
+  Heap* heap = GetHeap();
   HandleScope scope;
   Handle<JSObject> this_handle(this);
   Handle<String> name_handle(name);
@@ -1548,7 +1578,7 @@
       // Leaving JavaScript.
       VMState state(EXTERNAL);
       Handle<Object> value_unhole(value->IsTheHole() ?
-                                  HEAP->undefined_value() :
+                                  heap->undefined_value() :
                                   value);
       result = setter(v8::Utils::ToLocal(name_handle),
                       v8::Utils::ToLocal(value_unhole),
@@ -1578,6 +1608,7 @@
                                           String* name,
                                           Object* value,
                                           JSObject* holder) {
+  Heap* heap = GetHeap();
   HandleScope scope;

   // We should never get here to initialize a const with the hole
@@ -1626,7 +1657,7 @@
       Handle<String> key(name);
       Handle<Object> holder_handle(holder);
       Handle<Object> args[2] = { key, holder_handle };
-      return Isolate::Current()->Throw(
+      return heap->isolate()->Throw(
           *Factory::NewTypeError("no_setter_in_callback",
           HandleVector(args, 2)));
     }
@@ -1639,11 +1670,12 @@

 Object* JSObject::SetPropertyWithDefinedSetter(JSFunction* setter,
                                                Object* value) {
+  Heap* heap = GetHeap();
   Handle<Object> value_handle(value);
   Handle<JSFunction> fun(JSFunction::cast(setter));
   Handle<JSObject> self(this);
 #ifdef ENABLE_DEBUGGER_SUPPORT
-  Debug* debug = Isolate::Current()->debug();
+  Debug* debug = heap->isolate()->debug();
   // Handle stepping into a setter if step into is active.
   if (debug->StepInActive()) {
     debug->HandleStepIn(fun, Handle<Object>::null(), 0, false);
@@ -1660,7 +1692,7 @@

 void JSObject::LookupCallbackSetterInPrototypes(String* name,
                                                 LookupResult* result) {
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* pt = GetPrototype();
        pt != heap->null_value();
        pt = pt->GetPrototype()) {
@@ -1681,7 +1713,7 @@

 bool JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
                                                         Object* value) {
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* pt = GetPrototype();
        pt != heap->null_value();
        pt = pt->GetPrototype()) {
@@ -1704,8 +1736,9 @@


 void JSObject::LookupInDescriptor(String* name, LookupResult* result) {
+  Heap* heap = GetHeap();
   DescriptorArray* descriptors = map()->instance_descriptors();
-  DescriptorLookupCache* descriptor_lookup_cache = Isolate::Current()->
+  DescriptorLookupCache* descriptor_lookup_cache = heap->isolate()->
       descriptor_lookup_cache();
   int number = descriptor_lookup_cache->Lookup(descriptors, name);

@@ -1779,7 +1812,7 @@

 void JSObject::LookupRealNamedPropertyInPrototypes(String* name,
                                                    LookupResult* result) {
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* pt = GetPrototype();
        pt != heap->null_value();
        pt = JSObject::cast(pt)->GetPrototype()) {
@@ -1794,6 +1827,8 @@
 Object* JSObject::SetPropertyWithFailedAccessCheck(LookupResult* result,
                                                    String* name,
                                                    Object* value) {
+  Heap* heap = GetHeap();
+
   if (!result->IsProperty()) {
     LookupCallbackSetterInPrototypes(name, result);
   }
@@ -1831,7 +1866,7 @@
     }
   }

-  Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
+  heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_SET);
   return value;
 }

@@ -1840,6 +1875,8 @@
                               String* name,
                               Object* value,
                               PropertyAttributes attributes) {
+  Heap* heap = GetHeap();
+
   // Make sure that the top context does not change when doing callbacks or
   // interceptor calls.
   AssertNoContextChange ncc;
@@ -1848,13 +1885,13 @@
   // dictionary.  We make these short keys into symbols to avoid constantly
   // reallocating them.
   if (!name->IsSymbol() && name->length() <= 2) {
-    Object* symbol_version = HEAP->LookupSymbol(name);
+    Object* symbol_version = heap->LookupSymbol(name);
     if (!symbol_version->IsFailure()) name = String::cast(symbol_version);
   }

   // Check access rights if needed.
   if (IsAccessCheckNeeded()
-      && !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
+      && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
     return SetPropertyWithFailedAccessCheck(result, name, value);
   }

@@ -1934,6 +1971,8 @@
     String* name,
     Object* value,
     PropertyAttributes attributes) {
+  Heap* heap = GetHeap();
+
   // Make sure that the top context does not change when doing callbacks or
   // interceptor calls.
   AssertNoContextChange ncc;
@@ -1941,7 +1980,7 @@
   LocalLookup(name, &result);
   // Check access rights if needed.
   if (IsAccessCheckNeeded()
-      && !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
+      && !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_SET)) {
     return SetPropertyWithFailedAccessCheck(&result, name, value);
   }

@@ -2088,9 +2127,10 @@
                                                   LookupResult* result,
                                                   String* name,
                                                   bool continue_search) {
+  Heap* heap = GetHeap();
   // Check access rights if needed.
   if (IsAccessCheckNeeded() &&
-      !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
+      !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_HAS)) {
     return GetPropertyAttributeWithFailedAccessCheck(receiver,
                                                      result,
                                                      name,
@@ -2135,6 +2175,8 @@
   // The global object is always normalized.
   ASSERT(!IsGlobalObject());

+  Heap* heap = GetHeap();
+
   // Allocate new content.
   int property_count = map()->NumberOfDescribedProperties();
   if (expected_additional_properties > 0) {
@@ -2204,9 +2246,9 @@
     int new_instance_size = map()->instance_size() - instance_size_delta;
     new_map->set_inobject_properties(0);
     new_map->set_instance_size(new_instance_size);
-    new_map->set_scavenger(HEAP->GetScavenger(new_map->instance_type(),
+    new_map->set_scavenger(heap->GetScavenger(new_map->instance_type(),
                                               new_map->instance_size()));
-    HEAP->CreateFillerObjectAt(this->address() + new_instance_size,
+    heap->CreateFillerObjectAt(this->address() + new_instance_size,
                                instance_size_delta);
   }
   new_map->set_unused_property_fields(0);
@@ -2214,11 +2256,11 @@
   // We have now successfully allocated all the necessary objects.
// Changes can now be made with the guarantee that all of them take effect.
   set_map(new_map);
-  map()->set_instance_descriptors(HEAP->empty_descriptor_array());
+  map()->set_instance_descriptors(heap->empty_descriptor_array());

   set_properties(dictionary);

-  COUNTERS->props_to_dictionary()->Increment();
+  heap->isolate()->counters()->props_to_dictionary()->Increment();

 #ifdef DEBUG
   if (FLAG_trace_normalization) {
@@ -2273,7 +2315,8 @@
   set_map(new_map);
   set_elements(dictionary);

-  COUNTERS->elements_to_dictionary()->Increment();
+  new_map->GetHeap()->isolate()->counters()->elements_to_dictionary()->
+      Increment();

 #ifdef DEBUG
   if (FLAG_trace_normalization) {
@@ -2288,9 +2331,10 @@

Object* JSObject::DeletePropertyPostInterceptor(String* name, DeleteMode mode) {
   // Check local property, ignore interceptor.
+  Heap* heap = GetHeap();
   LookupResult result;
   LocalLookupRealNamedProperty(name, &result);
-  if (!result.IsProperty()) return HEAP->true_value();
+  if (!result.IsProperty()) return heap->true_value();

   // Normalize object if needed.
   Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES, 0);
@@ -2333,6 +2377,7 @@
 Object* JSObject::DeleteElementPostInterceptor(uint32_t index,
                                                DeleteMode mode) {
   ASSERT(!HasPixelElements() && !HasExternalArrayElements());
+  Heap* heap = GetHeap();
   switch (GetElementsKind()) {
     case FAST_ELEMENTS: {
       uint32_t length = IsJSArray() ?
@@ -2355,17 +2400,18 @@
       UNREACHABLE();
       break;
   }
-  return HEAP->true_value();
+  return heap->true_value();
 }


 Object* JSObject::DeleteElementWithInterceptor(uint32_t index) {
+  Heap* heap = GetHeap();
   // Make sure that the top context does not change when doing
   // callbacks or interceptor calls.
   AssertNoContextChange ncc;
   HandleScope scope;
   Handle<InterceptorInfo> interceptor(GetIndexedInterceptor());
-  if (interceptor->deleter()->IsUndefined()) return HEAP->false_value();
+  if (interceptor->deleter()->IsUndefined()) return heap->false_value();
   v8::IndexedPropertyDeleter deleter =
       v8::ToCData<v8::IndexedPropertyDeleter>(interceptor->deleter());
   Handle<JSObject> this_handle(this);
@@ -2391,16 +2437,17 @@


 Object* JSObject::DeleteElement(uint32_t index, DeleteMode mode) {
+  Heap* heap = GetHeap();
   // Check access rights if needed.
   if (IsAccessCheckNeeded() &&
- !Isolate::Current()->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
-    Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
-    return HEAP->false_value();
+      !heap->isolate()->MayIndexedAccess(this, index, v8::ACCESS_DELETE)) {
+    heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
+    return heap->false_value();
   }

   if (IsJSGlobalProxy()) {
     Object* proto = GetPrototype();
-    if (proto->IsNull()) return HEAP->false_value();
+    if (proto->IsNull()) return heap->false_value();
     ASSERT(proto->IsJSGlobalObject());
     return JSGlobalObject::cast(proto)->DeleteElement(index, mode);
   }
@@ -2446,24 +2493,25 @@
       UNREACHABLE();
       break;
   }
-  return HEAP->true_value();
+  return heap->true_value();
 }


 Object* JSObject::DeleteProperty(String* name, DeleteMode mode) {
+  Heap* heap = GetHeap();
   // ECMA-262, 3rd, 8.6.2.5
   ASSERT(name->IsString());

   // Check access rights if needed.
   if (IsAccessCheckNeeded() &&
-      !Isolate::Current()->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
-    Isolate::Current()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
-    return HEAP->false_value();
+      !heap->isolate()->MayNamedAccess(this, name, v8::ACCESS_DELETE)) {
+    heap->isolate()->ReportFailedAccessCheck(this, v8::ACCESS_DELETE);
+    return heap->false_value();
   }

   if (IsJSGlobalProxy()) {
     Object* proto = GetPrototype();
-    if (proto->IsNull()) return HEAP->false_value();
+    if (proto->IsNull()) return heap->false_value();
     ASSERT(proto->IsJSGlobalObject());
     return JSGlobalObject::cast(proto)->DeleteProperty(name, mode);
   }
@@ -2474,10 +2522,10 @@
   } else {
     LookupResult result;
     LocalLookup(name, &result);
-    if (!result.IsProperty()) return HEAP->true_value();
+    if (!result.IsProperty()) return heap->true_value();
     // Ignore attributes if forcing a deletion.
     if (result.IsDontDelete() && mode != FORCE_DELETION) {
-      return HEAP->false_value();
+      return heap->false_value();
     }
     // Check for interceptor.
     if (result.type() == INTERCEPTOR) {
@@ -2498,6 +2546,7 @@

 // Check whether this object references another object.
 bool JSObject::ReferencesObject(Object* obj) {
+  Heap* heap = GetHeap();
   AssertNoAllocation no_alloc;

   // Is the object the constructor for this object?
@@ -2557,7 +2606,7 @@
   if (IsJSFunction()) {
     // Get the constructor function for arguments array.
     JSObject* arguments_boilerplate =
-        Isolate::Current()->context()->global_context()->
+        heap->isolate()->context()->global_context()->
             arguments_boilerplate();
     JSFunction* arguments_function =
         JSFunction::cast(arguments_boilerplate->map()->constructor());
@@ -2621,7 +2670,7 @@
 // - This object has no elements.
 // - No prototype has enumerable properties/elements.
 bool JSObject::IsSimpleEnum() {
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* o = this;
        o != heap->null_value();
        o = JSObject::cast(o)->GetPrototype()) {
@@ -2689,6 +2738,8 @@
 void JSObject::LocalLookup(String* name, LookupResult* result) {
   ASSERT(name->IsString());

+  Heap* heap = GetHeap();
+
   if (IsJSGlobalProxy()) {
     Object* proto = GetPrototype();
     if (proto->IsNull()) return result->NotFound();
@@ -2701,18 +2752,16 @@
   if (!IsJSGlobalProxy() && IsAccessCheckNeeded()) {
     result->DisallowCaching();
   }
-
-  Isolate* isolate = Isolate::Current();

   // Check __proto__ before interceptor.
-  if (name->Equals(isolate->heap()->Proto_symbol()) &&
+  if (name->Equals(heap->Proto_symbol()) &&
       !IsJSContextExtensionObject()) {
     result->ConstantResult(this);
     return;
   }

   // Check for lookup interceptor except when bootstrapping.
-  if (HasNamedInterceptor() && !isolate->bootstrapper()->IsActive()) {
+ if (HasNamedInterceptor() && !heap->isolate()->bootstrapper()->IsActive()) {
     result->InterceptorResult(this);
     return;
   }
@@ -2723,7 +2772,7 @@

 void JSObject::Lookup(String* name, LookupResult* result) {
   // Ecma-262 3rd 8.6.2.4
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* current = this;
        current != heap->null_value();
        current = JSObject::cast(current)->GetPrototype()) {
@@ -2736,7 +2785,7 @@

 // Search object and it's prototype chain for callback properties.
 void JSObject::LookupCallback(String* name, LookupResult* result) {
-  Heap* heap = HEAP;
+  Heap* heap = GetHeap();
   for (Object* current = this;
        current != heap->null_value();
        current = JSObject::cast(current)->GetPrototype()) {
@@ -2749,6 +2798,8 @@

 Object* JSObject::DefineGetterSetter(String* name,
                                      PropertyAttributes attributes) {
+  Heap* heap = GetHeap();
+
   // Make sure that the top context does not change when doing callbacks or
   // interceptor calls.
   AssertNoContextChange ncc;
@@ -2757,12 +2808,12 @@
   name->TryFlatten();

   if (!CanSetCallback(name)) {
-    return HEAP->undefined_value();
+    return heap->undefined_value();
   }

   uint32_t index = 0;
   bool is_element = name->AsArrayIndex(&index);
-  if (is_element && IsJSArray()) return HEAP->undefined_value();
+  if (is_element && IsJSArray()) return heap->undefined_value();

   if (is_element) {
     switch (GetElementsKind()) {
@@ -2778,7 +2829,7 @@
       case EXTERNAL_FLOAT_ELEMENTS:
         // Ignore getters and setters on pixel and external array
         // elements.
-        return HEAP->undefined_value();
+        return heap->undefined_value();
       case DICTIONARY_ELEMENTS: {
         // Lookup the index.
         NumberDictionary* dictionary = element_dictionary();
@@ -2786,7 +2837,7 @@
         if (entry != NumberDictionary::kNotFound) {
           Object* result = dictionary->ValueAt(entry);
           PropertyDetails details = dictionary->DetailsAt(entry);
-          if (details.IsReadOnly()) return HEAP->undefined_value();
+          if (details.IsReadOnly()) return heap->undefined_value();
           if (details.type() == CALLBACKS) {
             if (result->IsFixedArray()) {
               return result;
@@ -2805,7 +2856,7 @@
     LookupResult result;
     LocalLookup(name, &result);
     if (result.IsProperty()) {
-      if (result.IsReadOnly()) return HEAP->undefined_value();
+      if (result.IsReadOnly()) return heap->undefined_value();
       if (result.type() == CALLBACKS) {
         Object* obj = result.GetCallbackObject();
         // Need to preserve old getters/setters.
@@ -2818,7 +2869,7 @@
   }

***The diff for this file has been truncated for email.***

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

Reply via email to