Revision: 5191
Author: [email protected]
Date: Thu Aug  5 13:38:56 2010
Log: [Isolates] Avoid dereferencing Isolate::Current() to check oddball identities.

- Added a kind field and accessors to JS Oddball objects.
- IsTrue/IsFalse/IsBoolean/IsTheHole/IsNull/IsUndefined now look like
  [IsOddball() && Oddball::cast(this)->kind() == Oddball::kUndefined;]
- Some checks of the form [if (foo == HEAP->an_oddball_value())]
  were updated (in such a way that they are resistant to foo being null
  and to the oddballs changing locations after a GC.)
- Removed THIS from heap.cc.

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

Modified:
 /branches/experimental/isolates/src/accessors.cc
 /branches/experimental/isolates/src/ast.h
 /branches/experimental/isolates/src/builtins.cc
 /branches/experimental/isolates/src/debug.cc
 /branches/experimental/isolates/src/disassembler.cc
 /branches/experimental/isolates/src/handles.cc
 /branches/experimental/isolates/src/handles.h
 /branches/experimental/isolates/src/heap-inl.h
 /branches/experimental/isolates/src/heap.cc
 /branches/experimental/isolates/src/heap.h
 /branches/experimental/isolates/src/ia32/codegen-ia32.cc
 /branches/experimental/isolates/src/isolate.h
 /branches/experimental/isolates/src/objects-debug.cc
 /branches/experimental/isolates/src/objects-inl.h
 /branches/experimental/isolates/src/objects.cc
 /branches/experimental/isolates/src/objects.h
 /branches/experimental/isolates/src/prettyprinter.cc
 /branches/experimental/isolates/src/runtime.cc
 /branches/experimental/isolates/src/string-stream.cc
 /branches/experimental/isolates/src/stub-cache.cc
 /branches/experimental/isolates/src/x64/codegen-x64.cc

=======================================
--- /branches/experimental/isolates/src/accessors.cc Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/accessors.cc Thu Aug 5 13:38:56 2010
@@ -39,8 +39,9 @@
 template <class C>
 static C* FindInPrototypeChain(Object* obj, bool* found_it) {
   ASSERT(!*found_it);
+  Heap* heap = HEAP;
   while (!Is<C>(obj)) {
-    if (obj == HEAP->null_value()) return NULL;
+    if (obj == heap->null_value()) return NULL;
     obj = obj->GetPrototype();
   }
   *found_it = true;
=======================================
--- /branches/experimental/isolates/src/ast.h   Fri Jun 25 15:32:52 2010
+++ /branches/experimental/isolates/src/ast.h   Thu Aug  5 13:38:56 2010
@@ -867,10 +867,17 @@
   virtual bool IsCritical();

   // Identity testers.
- bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } - bool IsTrue() const { return handle_.is_identical_to(Factory::true_value()); }
+  bool IsNull() const {
+    ASSERT(!handle_.is_null());
+    return handle_->IsNull();
+  }
+  bool IsTrue() const {
+    ASSERT(!handle_.is_null());
+    return handle_->IsTrue();
+  }
   bool IsFalse() const {
-    return handle_.is_identical_to(Factory::false_value());
+    ASSERT(!handle_.is_null());
+    return handle_->IsFalse();
   }

   Handle<Object> handle() const { return handle_; }
=======================================
--- /branches/experimental/isolates/src/builtins.cc     Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/builtins.cc     Thu Aug  5 13:38:56 2010
@@ -878,14 +878,15 @@
   // If necessary, check the receiver
   Object* recv_type = sig->receiver();

+  Heap* heap = HEAP;
   Object* holder = recv;
   if (!recv_type->IsUndefined()) {
-    for (; holder != HEAP->null_value(); holder = holder->GetPrototype()) {
+    for (; holder != heap->null_value(); holder = holder->GetPrototype()) {
       if (holder->IsInstanceOf(FunctionTemplateInfo::cast(recv_type))) {
         break;
       }
     }
-    if (holder == HEAP->null_value()) return holder;
+    if (holder == heap->null_value()) return holder;
   }
   Object* args_obj = sig->args();
   // If there is no argument signature we're done
@@ -898,13 +899,13 @@
     if (argtype->IsUndefined()) continue;
     Object** arg = &argv[-1 - i];
     Object* current = *arg;
- for (; current != HEAP->null_value(); current = current->GetPrototype()) { + for (; current != heap->null_value(); current = current->GetPrototype()) {
       if (current->IsInstanceOf(FunctionTemplateInfo::cast(argtype))) {
         *arg = current;
         break;
       }
     }
-    if (current == HEAP->null_value()) *arg = HEAP->undefined_value();
+    if (current == heap->null_value()) *arg = heap->undefined_value();
   }
   return holder;
 }
=======================================
--- /branches/experimental/isolates/src/debug.cc        Fri Jul 16 10:48:57 2010
+++ /branches/experimental/isolates/src/debug.cc        Thu Aug  5 13:38:56 2010
@@ -1057,7 +1057,8 @@
   }

   // Return whether the break point is triggered.
-  return *result == HEAP->true_value();
+  ASSERT(!result.is_null());
+  return (*result)->IsTrue();
 }


@@ -1333,7 +1334,8 @@
       // from the code object.
       Handle<Object> obj(
           HEAP->code_stubs()->SlowReverseLookup(*call_function_stub));
-      ASSERT(*obj != HEAP->undefined_value());
+      ASSERT(!obj.is_null());
+      ASSERT(!(*obj)->IsUndefined());
       ASSERT(obj->IsSmi());
       // Get the STUB key and extract major and minor key.
       uint32_t key = Smi::cast(*obj)->value();
=======================================
--- /branches/experimental/isolates/src/disassembler.cc Fri Jun 25 15:32:52 2010 +++ /branches/experimental/isolates/src/disassembler.cc Thu Aug 5 13:38:56 2010
@@ -111,6 +111,7 @@
   NoHandleAllocation ha;
   AssertNoAllocation no_alloc;
   ExternalReferenceEncoder ref_encoder;
+  Heap* heap = HEAP;

   v8::internal::EmbeddedVector<char, 128> decode_buffer;
   v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer;
@@ -252,8 +253,8 @@
         } else if (kind == Code::STUB) {
           // Reverse lookup required as the minor key cannot be retrieved
           // from the code object.
-          Object* obj = HEAP->code_stubs()->SlowReverseLookup(code);
-          if (obj != HEAP->undefined_value()) {
+          Object* obj = heap->code_stubs()->SlowReverseLookup(code);
+          if (obj != heap->undefined_value()) {
             ASSERT(obj->IsSmi());
             // Get the STUB key and extract major and minor key.
             uint32_t key = Smi::cast(obj)->value();
=======================================
--- /branches/experimental/isolates/src/handles.cc      Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/handles.cc      Thu Aug  5 13:38:56 2010
@@ -642,9 +642,10 @@
       Handle<JSFunction>(
           JSFunction::cast(arguments_boilerplate->map()->constructor()));

+  Heap* heap = HEAP;
   // Only collect keys if access is permitted.
   for (Handle<Object> p = object;
-       *p != HEAP->null_value();
+       *p != heap->null_value();
        p = Handle<Object>(p->GetPrototype())) {
     Handle<JSObject> current(JSObject::cast(*p));

=======================================
--- /branches/experimental/isolates/src/handles.h       Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/handles.h       Thu Aug  5 13:38:56 2010
@@ -82,7 +82,7 @@
   }

   static Handle<T> null() { return Handle<T>(); }
-  bool is_null() { return location_ == NULL; }
+  bool is_null() const { return location_ == NULL; }

   // Closes the given scope, but lets this handle escape. See
   // implementation in api.h.
=======================================
--- /branches/experimental/isolates/src/heap-inl.h      Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/heap-inl.h      Thu Aug  5 13:38:56 2010
@@ -506,13 +506,13 @@


 Object* Heap::ToBoolean(bool condition) {
-  return condition ? HEAP->true_value() : HEAP->false_value();
+  return condition ? true_value() : false_value();
 }


 void Heap::CompletelyClearInstanceofCache() {
-  set_instanceof_cache_map(HEAP->the_hole_value());
-  set_instanceof_cache_function(HEAP->the_hole_value());
+  set_instanceof_cache_map(the_hole_value());
+  set_instanceof_cache_function(the_hole_value());
 }


=======================================
--- /branches/experimental/isolates/src/heap.cc Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/heap.cc Thu Aug  5 13:38:56 2010
@@ -46,12 +46,6 @@
 #include "arm/regexp-macro-assembler-arm.h"
 #endif

-// Since we're converting Heap over in stages, this file is in a strange state
-// with regard to static/nonstatic methods. THIS refers to this in a
-// method that will eventually become non-static. HEAP should be used in
-// methods that will remain static.
-#define THIS HEAP
-
 namespace v8 {
 namespace internal {

@@ -362,9 +356,9 @@
   isolate_->counters()->alive_after_last_gc()->Set(SizeOfObjects());

   isolate_->counters()->symbol_table_capacity()->Set(
-      THIS->symbol_table()->Capacity());
+      symbol_table()->Capacity());
   isolate_->counters()->number_of_symbols()->Set(
-      THIS->symbol_table()->NumberOfElements());
+      symbol_table()->NumberOfElements());
 #if defined(DEBUG) || defined(ENABLE_LOGGING_AND_PROFILING)
   ReportStatisticsAfterGC();
 #endif
@@ -755,7 +749,7 @@

   CompletelyClearInstanceofCache();

-  if (is_compacting) THIS->FlushNumberStringCache();
+  if (is_compacting) FlushNumberStringCache();
 }


@@ -1363,7 +1357,7 @@
   if (result->IsFailure()) return result;

   // Map::cast cannot be used due to uninitialized map field.
-  reinterpret_cast<Map*>(result)->set_map(THIS->raw_unchecked_meta_map());
+  reinterpret_cast<Map*>(result)->set_map(raw_unchecked_meta_map());
   reinterpret_cast<Map*>(result)->set_instance_type(instance_type);
   reinterpret_cast<Map*>(result)->set_instance_size(instance_size);
   reinterpret_cast<Map*>(result)->
@@ -1382,7 +1376,7 @@
   if (result->IsFailure()) return result;

   Map* map = reinterpret_cast<Map*>(result);
-  map->set_map(THIS->meta_map());
+  map->set_map(meta_map());
   map->set_instance_type(instance_type);
   map->set_scavenger(GetScavenger(instance_type, instance_size));
   map->set_prototype(null_value());
@@ -1390,8 +1384,8 @@
   map->set_instance_size(instance_size);
   map->set_inobject_properties(0);
   map->set_pre_allocated_property_fields(0);
-  map->set_instance_descriptors(THIS->empty_descriptor_array());
-  map->set_code_cache(THIS->empty_fixed_array());
+  map->set_instance_descriptors(empty_descriptor_array());
+  map->set_code_cache(empty_fixed_array());
   map->set_unused_property_fields(0);
   map->set_bit_field(0);
map->set_bit_field2((1 << Map::kIsExtensible) | (1 << Map::kHasFastElements));
@@ -1410,8 +1404,8 @@
   Object* result = AllocateStruct(CODE_CACHE_TYPE);
   if (result->IsFailure()) return result;
   CodeCache* code_cache = CodeCache::cast(result);
-  code_cache->set_default_cache(THIS->empty_fixed_array());
-  code_cache->set_normal_type_cache(THIS->undefined_value());
+  code_cache->set_default_cache(empty_fixed_array());
+  code_cache->set_normal_type_cache(undefined_value());
   return code_cache;
 }

@@ -1464,6 +1458,7 @@
   obj = Allocate(oddball_map(), OLD_DATA_SPACE);
   if (obj->IsFailure()) return false;
   set_null_value(obj);
+  Oddball::cast(obj)->set_kind(Oddball::kNull);

   // Allocate the empty descriptor array.
   obj = AllocateEmptyFixedArray();
@@ -1617,7 +1612,7 @@
   Object* result = AllocateRaw(HeapNumber::kSize, space, OLD_DATA_SPACE);
   if (result->IsFailure()) return result;

-  HeapObject::cast(result)->set_map(THIS->heap_number_map());
+  HeapObject::cast(result)->set_map(heap_number_map());
   HeapNumber::cast(result)->set_value(value);
   return result;
 }
@@ -1633,7 +1628,7 @@
   ASSERT(allocation_allowed_ && gc_state_ == NOT_IN_GC);
   Object* result = new_space_.AllocateRaw(HeapNumber::kSize);
   if (result->IsFailure()) return result;
-  HeapObject::cast(result)->set_map(THIS->heap_number_map());
+  HeapObject::cast(result)->set_map(heap_number_map());
   HeapNumber::cast(result)->set_value(value);
   return result;
 }
@@ -1642,17 +1637,18 @@
 Object* Heap::AllocateJSGlobalPropertyCell(Object* value) {
   Object* result = AllocateRawCell();
   if (result->IsFailure()) return result;
-  HeapObject::cast(result)->set_map(THIS->global_property_cell_map());
+  HeapObject::cast(result)->set_map(global_property_cell_map());
   JSGlobalPropertyCell::cast(result)->set_value(value);
   return result;
 }


 Object* Heap::CreateOddball(const char* to_string,
-                            Object* to_number) {
+                            Object* to_number,
+                            byte kind) {
   Object* result = Allocate(oddball_map(), OLD_DATA_SPACE);
   if (result->IsFailure()) return result;
-  return Oddball::cast(result)->Initialize(to_string, to_number);
+  return Oddball::cast(result)->Initialize(to_string, to_number, kind);
 }


@@ -1663,7 +1659,7 @@
   if (obj->IsFailure()) return false;
   set_neander_map(Map::cast(obj));

-  obj = AllocateJSObjectFromMap(THIS->neander_map());
+  obj = AllocateJSObjectFromMap(neander_map());
   if (obj->IsFailure()) return false;
   Object* elements = AllocateFixedArray(2);
   if (elements->IsFailure()) return false;
@@ -1740,6 +1736,7 @@
   obj = Allocate(oddball_map(), OLD_DATA_SPACE);
   if (obj->IsFailure()) return false;
   set_undefined_value(obj);
+  Oddball::cast(obj)->set_kind(Oddball::kUndefined);
   ASSERT(!InNewSpace(undefined_value()));

   // Allocate initial symbol table.
@@ -1755,26 +1752,32 @@
   Oddball::cast(undefined_value())->set_to_number(nan_value());

   // Allocate the null_value
-  obj = Oddball::cast(null_value())->Initialize("null", Smi::FromInt(0));
+  obj = Oddball::cast(null_value())->Initialize("null",
+                                                Smi::FromInt(0),
+                                                Oddball::kNull);
   if (obj->IsFailure()) return false;

-  obj = CreateOddball("true", Smi::FromInt(1));
+  obj = CreateOddball("true", Smi::FromInt(1), Oddball::kTrue);
   if (obj->IsFailure()) return false;
   set_true_value(obj);

-  obj = CreateOddball("false", Smi::FromInt(0));
+  obj = CreateOddball("false", Smi::FromInt(0), Oddball::kFalse);
   if (obj->IsFailure()) return false;
   set_false_value(obj);

-  obj = CreateOddball("hole", Smi::FromInt(-1));
+  obj = CreateOddball("hole", Smi::FromInt(-1), Oddball::kTheHole);
   if (obj->IsFailure()) return false;
   set_the_hole_value(obj);

-  obj = CreateOddball("no_interceptor_result_sentinel", Smi::FromInt(-2));
+  obj = CreateOddball("no_interceptor_result_sentinel",
+                      Smi::FromInt(-2),
+                      Oddball::kOther);
   if (obj->IsFailure()) return false;
   set_no_interceptor_result_sentinel(obj);

-  obj = CreateOddball("termination_exception", Smi::FromInt(-3));
+  obj = CreateOddball("termination_exception",
+                      Smi::FromInt(-3),
+                      Oddball::kOther);
   if (obj->IsFailure()) return false;
   set_termination_exception(obj);

@@ -1867,9 +1870,9 @@

 void Heap::FlushNumberStringCache() {
   // Flush the number to string cache.
-  int len = THIS->number_string_cache()->length();
+  int len = number_string_cache()->length();
   for (int i = 0; i < len; i++) {
-    THIS->number_string_cache()->set_undefined(i);
+    number_string_cache()->set_undefined(i);
   }
 }

@@ -1887,35 +1890,35 @@

 Object* Heap::GetNumberStringCache(Object* number) {
   int hash;
-  int mask = (THIS->number_string_cache()->length() >> 1) - 1;
+  int mask = (number_string_cache()->length() >> 1) - 1;
   if (number->IsSmi()) {
     hash = smi_get_hash(Smi::cast(number)) & mask;
   } else {
     hash = double_get_hash(number->Number()) & mask;
   }
-  Object* key = THIS->number_string_cache()->get(hash * 2);
+  Object* key = number_string_cache()->get(hash * 2);
   if (key == number) {
-    return String::cast(THIS->number_string_cache()->get(hash * 2 + 1));
+    return String::cast(number_string_cache()->get(hash * 2 + 1));
   } else if (key->IsHeapNumber() &&
              number->IsHeapNumber() &&
              key->Number() == number->Number()) {
-    return String::cast(THIS->number_string_cache()->get(hash * 2 + 1));
-  }
-  return THIS->undefined_value();
+    return String::cast(number_string_cache()->get(hash * 2 + 1));
+  }
+  return undefined_value();
 }


 void Heap::SetNumberStringCache(Object* number, String* string) {
   int hash;
-  int mask = (THIS->number_string_cache()->length() >> 1) - 1;
+  int mask = (number_string_cache()->length() >> 1) - 1;
   if (number->IsSmi()) {
     hash = smi_get_hash(Smi::cast(number)) & mask;
-    THIS->number_string_cache()->set(hash * 2, Smi::cast(number));
+    number_string_cache()->set(hash * 2, Smi::cast(number));
   } else {
     hash = double_get_hash(number->Number()) & mask;
-    THIS->number_string_cache()->set(hash * 2, number);
-  }
-  THIS->number_string_cache()->set(hash * 2 + 1, string);
+    number_string_cache()->set(hash * 2, number);
+  }
+  number_string_cache()->set(hash * 2 + 1, string);
 }


@@ -1923,7 +1926,7 @@
   isolate_->counters()->number_to_string_runtime()->Increment();
   if (check_number_string_cache) {
     Object* cached = GetNumberStringCache(number);
-    if (cached != THIS->undefined_value()) {
+    if (cached != undefined_value()) {
       return cached;
     }
   }
@@ -2000,7 +2003,7 @@
   // Statically ensure that it is safe to allocate proxies in paged spaces.
   STATIC_ASSERT(Proxy::kSize <= Page::kMaxHeapObjectSize);
AllocationSpace space = (pretenure == TENURED) ? OLD_DATA_SPACE : NEW_SPACE;
-  Object* result = Allocate(THIS->proxy_map(), space);
+  Object* result = Allocate(proxy_map(), space);
   if (result->IsFailure()) return result;

   Proxy::cast(result)->set_proxy(proxy);
@@ -2009,7 +2012,7 @@


 Object* Heap::AllocateSharedFunctionInfo(Object* name) {
-  Object* result = Allocate(THIS->shared_function_info_map(),
+  Object* result = Allocate(shared_function_info_map(),
       OLD_POINTER_SPACE);
   if (result->IsFailure()) return result;

@@ -2024,15 +2027,15 @@
   share->set_expected_nof_properties(0);
   share->set_length(0);
   share->set_formal_parameter_count(0);
-  share->set_instance_class_name(THIS->Object_symbol());
-  share->set_function_data(THIS->undefined_value());
-  share->set_script(THIS->undefined_value());
+  share->set_instance_class_name(Object_symbol());
+  share->set_function_data(undefined_value());
+  share->set_script(undefined_value());
   share->set_start_position_and_type(0);
-  share->set_debug_info(THIS->undefined_value());
-  share->set_inferred_name(THIS->empty_string());
+  share->set_debug_info(undefined_value());
+  share->set_inferred_name(empty_string());
   share->set_compiler_hints(0);
   share->set_this_property_assignments_count(0);
-  share->set_this_property_assignments(THIS->undefined_value());
+  share->set_this_property_assignments(undefined_value());
   share->set_num_literals(0);
   share->set_end_position(0);
   share->set_function_token_position(0);
@@ -2170,7 +2173,7 @@
   }

   Map* map = (is_ascii || is_ascii_data_in_two_byte_string) ?
-      THIS->cons_ascii_string_map() : THIS->cons_string_map();
+      cons_ascii_string_map() : cons_string_map();

   Object* result = Allocate(map, NEW_SPACE);
   if (result->IsFailure()) return result;
@@ -2234,7 +2237,7 @@
     return Failure::OutOfMemoryException();
   }

-  Map* map = THIS->external_ascii_string_map();
+  Map* map = external_ascii_string_map();
   Object* result = Allocate(map, NEW_SPACE);
   if (result->IsFailure()) return result;

@@ -2286,15 +2289,15 @@

 Object* Heap::LookupSingleCharacterStringFromCode(uint16_t code) {
   if (code <= String::kMaxAsciiCharCode) {
-    Object* value = THIS->single_character_string_cache()->get(code);
-    if (value != THIS->undefined_value()) return value;
+    Object* value = single_character_string_cache()->get(code);
+    if (value != undefined_value()) return value;

     char buffer[1];
     buffer[0] = static_cast<char>(code);
     Object* result = LookupSymbol(Vector<const char>(buffer, 1));

     if (result->IsFailure()) return result;
-    THIS->single_character_string_cache()->set(code, result);
+    single_character_string_cache()->set(code, result);
     return result;
   }

@@ -2319,7 +2322,7 @@
       : lo_space_->AllocateRaw(size);
   if (result->IsFailure()) return result;

-  reinterpret_cast<ByteArray*>(result)->set_map(THIS->byte_array_map());
+  reinterpret_cast<ByteArray*>(result)->set_map(byte_array_map());
   reinterpret_cast<ByteArray*>(result)->set_length(length);
   return result;
 }
@@ -2335,7 +2338,7 @@
   Object* result = AllocateRaw(size, space, OLD_DATA_SPACE);
   if (result->IsFailure()) return result;

-  reinterpret_cast<ByteArray*>(result)->set_map(THIS->byte_array_map());
+  reinterpret_cast<ByteArray*>(result)->set_map(byte_array_map());
   reinterpret_cast<ByteArray*>(result)->set_length(length);
   return result;
 }
@@ -2345,11 +2348,11 @@
   if (size == 0) return;
   HeapObject* filler = HeapObject::FromAddress(addr);
   if (size == kPointerSize) {
-    filler->set_map(THIS->one_pointer_filler_map());
+    filler->set_map(one_pointer_filler_map());
   } else if (size == 2 * kPointerSize) {
-    filler->set_map(THIS->two_pointer_filler_map());
+    filler->set_map(two_pointer_filler_map());
   } else {
-    filler->set_map(THIS->byte_array_map());
+    filler->set_map(byte_array_map());
     ByteArray::cast(filler)->set_length(ByteArray::LengthFor(size));
   }
 }
@@ -2362,7 +2365,7 @@
Object* result = AllocateRaw(PixelArray::kAlignedSize, space, OLD_DATA_SPACE);
   if (result->IsFailure()) return result;

-  reinterpret_cast<PixelArray*>(result)->set_map(THIS->pixel_array_map());
+  reinterpret_cast<PixelArray*>(result)->set_map(pixel_array_map());
   reinterpret_cast<PixelArray*>(result)->set_length(length);
reinterpret_cast<PixelArray*>(result)->set_external_pointer(external_pointer);

@@ -2495,7 +2498,7 @@
   if (result->IsFailure()) return result;

   // Initialize the object
-  HeapObject::cast(result)->set_map(THIS->code_map());
+  HeapObject::cast(result)->set_map(code_map());
   Code* code = Code::cast(result);
   ASSERT(!isolate_->code_range()->exists() ||
       isolate_->code_range()->contains(code->address()));
@@ -2620,8 +2623,8 @@
   function->initialize_elements();
   function->set_shared(shared);
   function->set_prototype_or_initial_map(prototype);
-  function->set_context(THIS->undefined_value());
-  function->set_literals(THIS->empty_fixed_array());
+  function->set_context(undefined_value());
+  function->set_literals(empty_fixed_array());
   return function;
 }

@@ -2637,7 +2640,7 @@
   // When creating the prototype for the function we must set its
   // constructor to the function.
   Object* result =
-      JSObject::cast(prototype)->SetProperty(THIS->constructor_symbol(),
+      JSObject::cast(prototype)->SetProperty(constructor_symbol(),
                                              function,
                                              DONT_ENUM);
   if (result->IsFailure()) return result;
@@ -3056,23 +3059,23 @@

   // Find the corresponding symbol map for strings.
   Map* map = string->map();
-  if (map == THIS->ascii_string_map()) {
-    return THIS->ascii_symbol_map();
-  }
-  if (map == THIS->string_map()) {
-    return THIS->symbol_map();
-  }
-  if (map == THIS->cons_string_map()) {
-    return THIS->cons_symbol_map();
-  }
-  if (map == THIS->cons_ascii_string_map()) {
-    return THIS->cons_ascii_symbol_map();
-  }
-  if (map == THIS->external_string_map()) {
-    return THIS->external_symbol_map();
-  }
-  if (map == THIS->external_ascii_string_map()) {
-    return THIS->external_ascii_symbol_map();
+  if (map == ascii_string_map()) {
+    return ascii_symbol_map();
+  }
+  if (map == string_map()) {
+    return symbol_map();
+  }
+  if (map == cons_string_map()) {
+    return cons_symbol_map();
+  }
+  if (map == cons_ascii_string_map()) {
+    return cons_ascii_symbol_map();
+  }
+  if (map == external_string_map()) {
+    return external_symbol_map();
+  }
+  if (map == external_ascii_string_map()) {
+    return external_ascii_symbol_map();
   }
   if (map == external_string_with_ascii_data_map()) {
     return external_symbol_with_ascii_data_map();
@@ -3107,13 +3110,13 @@
     if (chars > SeqAsciiString::kMaxLength) {
       return Failure::OutOfMemoryException();
     }
-    map = THIS->ascii_symbol_map();
+    map = ascii_symbol_map();
     size = SeqAsciiString::SizeFor(chars);
   } else {
     if (chars > SeqTwoByteString::kMaxLength) {
       return Failure::OutOfMemoryException();
     }
-    map = THIS->symbol_map();
+    map = symbol_map();
     size = SeqTwoByteString::SizeFor(chars);
   }

@@ -3165,7 +3168,7 @@
   if (result->IsFailure()) return result;

   // Partially initialize the object.
-  HeapObject::cast(result)->set_map(THIS->ascii_string_map());
+  HeapObject::cast(result)->set_map(ascii_string_map());
   String::cast(result)->set_length(length);
   String::cast(result)->set_hash_field(String::kEmptyHashField);
   ASSERT_EQ(size, HeapObject::cast(result)->Size());
@@ -3197,7 +3200,7 @@
   if (result->IsFailure()) return result;

   // Partially initialize the object.
-  HeapObject::cast(result)->set_map(THIS->string_map());
+  HeapObject::cast(result)->set_map(string_map());
   String::cast(result)->set_length(length);
   String::cast(result)->set_hash_field(String::kEmptyHashField);
   ASSERT_EQ(size, HeapObject::cast(result)->Size());
@@ -3210,7 +3213,7 @@
   Object* result = AllocateRaw(size, OLD_DATA_SPACE, OLD_DATA_SPACE);
   if (result->IsFailure()) return result;
   // Initialize the object.
-  reinterpret_cast<FixedArray*>(result)->set_map(THIS->fixed_array_map());
+  reinterpret_cast<FixedArray*>(result)->set_map(fixed_array_map());
   reinterpret_cast<FixedArray*>(result)->set_length(0);
   return result;
 }
@@ -3253,16 +3256,16 @@

 Object* Heap::AllocateFixedArray(int length) {
   ASSERT(length >= 0);
-  if (length == 0) return THIS->empty_fixed_array();
+  if (length == 0) return empty_fixed_array();
   Object* result = AllocateRawFixedArray(length);
   if (!result->IsFailure()) {
     // Initialize header.
     FixedArray* array = reinterpret_cast<FixedArray*>(result);
-    array->set_map(THIS->fixed_array_map());
+    array->set_map(fixed_array_map());
     array->set_length(length);
     // Initialize body.
-    ASSERT(!InNewSpace(THIS->undefined_value()));
-    MemsetPointer(array->data_start(), THIS->undefined_value(), length);
+    ASSERT(!InNewSpace(undefined_value()));
+    MemsetPointer(array->data_start(), undefined_value(), length);
   }
   return result;
 }
@@ -3338,7 +3341,7 @@
 Object* Heap::AllocateHashTable(int length, PretenureFlag pretenure) {
   Object* result = AllocateFixedArray(length, pretenure);
   if (result->IsFailure()) return result;
-  reinterpret_cast<HeapObject*>(result)->set_map(THIS->hash_table_map());
+  reinterpret_cast<HeapObject*>(result)->set_map(hash_table_map());
   ASSERT(result->IsHashTable());
   return result;
 }
@@ -3348,7 +3351,7 @@
   Object* result = AllocateFixedArray(Context::GLOBAL_CONTEXT_SLOTS);
   if (result->IsFailure()) return result;
   Context* context = reinterpret_cast<Context*>(result);
-  context->set_map(THIS->global_context_map());
+  context->set_map(global_context_map());
   ASSERT(context->IsGlobalContext());
   ASSERT(result->IsContext());
   return result;
@@ -3360,7 +3363,7 @@
   Object* result = AllocateFixedArray(length);
   if (result->IsFailure()) return result;
   Context* context = reinterpret_cast<Context*>(result);
-  context->set_map(THIS->context_map());
+  context->set_map(context_map());
   context->set_closure(function);
   context->set_fcontext(context);
   context->set_previous(NULL);
@@ -3379,8 +3382,8 @@
   Object* result = AllocateFixedArray(Context::MIN_CONTEXT_SLOTS);
   if (result->IsFailure()) return result;
   Context* context = reinterpret_cast<Context*>(result);
-  context->set_map(is_catch_context ? THIS->catch_context_map() :
-      THIS->context_map());
+  context->set_map(is_catch_context ? catch_context_map() :
+      context_map());
   context->set_closure(previous->closure());
   context->set_fcontext(previous->fcontext());
   context->set_previous(previous);
@@ -3397,7 +3400,7 @@
   Map* map;
   switch (type) {
 #define MAKE_CASE(NAME, Name, name) \
-    case NAME##_TYPE: map = THIS->name##_map(); break;
+    case NAME##_TYPE: map = name##_map(); break;
 STRUCT_LIST(MAKE_CASE)
 #undef MAKE_CASE
     default:
@@ -3670,7 +3673,7 @@

 Object* Heap::LookupSymbol(Vector<const char> string) {
   Object* symbol = NULL;
-  Object* new_table = THIS->symbol_table()->LookupSymbol(string, &symbol);
+  Object* new_table = symbol_table()->LookupSymbol(string, &symbol);
   if (new_table->IsFailure()) return new_table;
   // Can't use set_symbol_table because SymbolTable::cast knows that
   // SymbolTable is a singleton and checks for identity.
@@ -3683,7 +3686,7 @@
 Object* Heap::LookupSymbol(String* string) {
   if (string->IsSymbol()) return string;
   Object* symbol = NULL;
-  Object* new_table = THIS->symbol_table()->LookupString(string, &symbol);
+  Object* new_table = symbol_table()->LookupString(string, &symbol);
   if (new_table->IsFailure()) return new_table;
   // Can't use set_symbol_table because SymbolTable::cast knows that
   // SymbolTable is a singleton and checks for identity.
@@ -3698,7 +3701,7 @@
     *symbol = string;
     return true;
   }
-  return THIS->symbol_table()->LookupSymbolIfExists(string, symbol);
+  return symbol_table()->LookupSymbolIfExists(string, symbol);
 }


@@ -4682,11 +4685,11 @@

   if (create_heap_objects) {
     // Create initial maps.
-    if (!THIS->CreateInitialMaps()) return false;
-    if (!THIS->CreateApiObjects()) return false;
+    if (!CreateInitialMaps()) return false;
+    if (!CreateApiObjects()) return false;

     // Create initial objects
-    if (!THIS->CreateInitialObjects()) return false;
+    if (!CreateInitialObjects()) return false;
   }

   LOG(IntEvent("heap-capacity", Capacity()));
@@ -4972,8 +4975,8 @@
 void ExternalStringTable::CleanUp() {
   int last = 0;
   for (int i = 0; i < new_space_strings_.length(); ++i) {
- if (new_space_strings_[i] == HEAP->raw_unchecked_null_value()) continue;
-    if (HEAP->InNewSpace(new_space_strings_[i])) {
+ if (new_space_strings_[i] == heap_->raw_unchecked_null_value()) continue;
+    if (heap_->InNewSpace(new_space_strings_[i])) {
       new_space_strings_[last++] = new_space_strings_[i];
     } else {
       old_space_strings_.Add(new_space_strings_[i]);
@@ -4982,8 +4985,8 @@
   new_space_strings_.Rewind(last);
   last = 0;
   for (int i = 0; i < old_space_strings_.length(); ++i) {
- if (old_space_strings_[i] == HEAP->raw_unchecked_null_value()) continue;
-    ASSERT(!HEAP->InNewSpace(old_space_strings_[i]));
+ if (old_space_strings_[i] == heap_->raw_unchecked_null_value()) continue;
+    ASSERT(!heap_->InNewSpace(old_space_strings_[i]));
     old_space_strings_[last++] = old_space_strings_[i];
   }
   old_space_strings_.Rewind(last);
=======================================
--- /branches/experimental/isolates/src/heap.h  Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/heap.h  Thu Aug  5 13:38:56 2010
@@ -1309,7 +1309,7 @@

   void CreateFixedStubs();

-  Object* CreateOddball(const char* to_string, Object* to_number);
+ Object* CreateOddball(const char* to_string, Object* to_number, byte kind);

   // Allocate empty fixed array.
   Object* AllocateEmptyFixedArray();
=======================================
--- /branches/experimental/isolates/src/ia32/codegen-ia32.cc Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/ia32/codegen-ia32.cc Thu Aug 5 13:38:56 2010
@@ -1439,7 +1439,7 @@
       UNREACHABLE();
       break;
   }
-  if (answer_object == HEAP->undefined_value()) {
+  if (answer_object->IsUndefined()) {
     return false;
   }
   frame_->Push(Handle<Object>(answer_object));
=======================================
--- /branches/experimental/isolates/src/isolate.h       Mon Aug  2 17:41:48 2010
+++ /branches/experimental/isolates/src/isolate.h       Thu Aug  5 13:38:56 2010
@@ -1139,7 +1139,7 @@

 // Tells whether the global context is marked with out of memory.
 inline bool Context::has_out_of_memory() {
-  return global_context()->out_of_memory() == HEAP->true_value();
+  return global_context()->out_of_memory()->IsTrue();
 }


=======================================
--- /branches/experimental/isolates/src/objects-debug.cc Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/objects-debug.cc Thu Aug 5 13:38:56 2010
@@ -1238,8 +1238,9 @@
       int holes = 0;
       FixedArray* e = FixedArray::cast(elements());
       int len = e->length();
+      Heap* heap = HEAP;
       for (int i = 0; i < len; i++) {
-        if (e->get(i) == HEAP->the_hole_value()) holes++;
+        if (e->get(i) == heap->the_hole_value()) holes++;
       }
       info->number_of_fast_used_elements_   += len - holes;
       info->number_of_fast_unused_elements_ += holes;
=======================================
--- /branches/experimental/isolates/src/objects-inl.h Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/objects-inl.h Thu Aug 5 13:38:56 2010
@@ -522,7 +522,8 @@


 bool Object::IsBoolean() {
-  return IsTrue() || IsFalse();
+  return IsOddball() &&
+      ((Oddball::cast(this)->kind() & Oddball::kNotBooleanMask) == 0);
 }


@@ -660,27 +661,27 @@


 bool Object::IsUndefined() {
-  return this == HEAP->undefined_value();
+  return IsOddball() && Oddball::cast(this)->kind() == Oddball::kUndefined;
 }


 bool Object::IsTheHole() {
-  return this == HEAP->the_hole_value();
+  return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTheHole;
 }


 bool Object::IsNull() {
-  return this == HEAP->null_value();
+  return IsOddball() && Oddball::cast(this)->kind() == Oddball::kNull;
 }


 bool Object::IsTrue() {
-  return this == HEAP->true_value();
+  return IsOddball() && Oddball::cast(this)->kind() == Oddball::kTrue;
 }


 bool Object::IsFalse() {
-  return this == HEAP->false_value();
+  return IsOddball() && Oddball::cast(this)->kind() == Oddball::kFalse;
 }


@@ -690,7 +691,6 @@
     ? static_cast<double>(reinterpret_cast<Smi*>(this)->value())
     : reinterpret_cast<HeapNumber*>(this)->value();
 }
-


 Object* Object::ToSmi() {
@@ -1203,6 +1203,16 @@
 ACCESSORS(Oddball, to_number, Object, kToNumberOffset)


+byte Oddball::kind() {
+  return READ_BYTE_FIELD(this, kKindOffset);
+}
+
+
+void Oddball::set_kind(byte value) {
+  WRITE_BYTE_FIELD(this, kKindOffset, value);
+}
+
+
 Object* JSGlobalPropertyCell::value() {
   return READ_FIELD(this, kValueOffset);
 }
@@ -2715,7 +2725,7 @@


 void JSFunction::set_context(Object* value) {
-  ASSERT(value == HEAP->undefined_value() || value->IsContext());
+  ASSERT(value->IsUndefined() || value->IsContext());
   WRITE_FIELD(this, kContextOffset, value);
   WRITE_BARRIER(this, kContextOffset);
 }
=======================================
--- /branches/experimental/isolates/src/objects.cc      Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/objects.cc      Thu Aug  5 13:38:56 2010
@@ -1660,8 +1660,9 @@

 void JSObject::LookupCallbackSetterInPrototypes(String* name,
                                                 LookupResult* result) {
+  Heap* heap = HEAP;
   for (Object* pt = GetPrototype();
-       pt != HEAP->null_value();
+       pt != heap->null_value();
        pt = pt->GetPrototype()) {
     JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
     if (result->IsProperty()) {
@@ -1680,8 +1681,9 @@

 bool JSObject::SetElementWithCallbackSetterInPrototypes(uint32_t index,
                                                         Object* value) {
+  Heap* heap = HEAP;
   for (Object* pt = GetPrototype();
-       pt != HEAP->null_value();
+       pt != heap->null_value();
        pt = pt->GetPrototype()) {
     if (!JSObject::cast(pt)->HasDictionaryElements()) {
         continue;
@@ -1777,8 +1779,9 @@

 void JSObject::LookupRealNamedPropertyInPrototypes(String* name,
                                                    LookupResult* result) {
+  Heap* heap = HEAP;
   for (Object* pt = GetPrototype();
-       pt != HEAP->null_value();
+       pt != heap->null_value();
        pt = JSObject::cast(pt)->GetPrototype()) {
     JSObject::cast(pt)->LocalLookupRealNamedProperty(name, result);
     if (result->IsProperty() && (result->type() != INTERCEPTOR)) return;
@@ -2010,7 +2013,7 @@
   if (continue_search) {
     // Continue searching via the prototype chain.
     Object* pt = GetPrototype();
-    if (pt != HEAP->null_value()) {
+    if (!pt->IsNull()) {
       return JSObject::cast(pt)->
         GetPropertyAttributeWithReceiver(receiver, name);
     }
@@ -2509,7 +2512,7 @@

   // Check if the object is among the named properties.
   Object* key = SlowReverseLookup(obj);
-  if (key != HEAP->undefined_value()) {
+  if (!key->IsUndefined()) {
     return true;
   }

@@ -2540,7 +2543,7 @@
     }
     case DICTIONARY_ELEMENTS: {
       key = element_dictionary()->SlowReverseLookup(obj);
-      if (key != HEAP->undefined_value()) {
+      if (!key->IsUndefined()) {
         return true;
       }
       break;
@@ -2618,8 +2621,9 @@
 // - This object has no elements.
 // - No prototype has enumerable properties/elements.
 bool JSObject::IsSimpleEnum() {
+  Heap* heap = HEAP;
   for (Object* o = this;
-       o != HEAP->null_value();
+       o != heap->null_value();
        o = JSObject::cast(o)->GetPrototype()) {
     JSObject* curr = JSObject::cast(o);
     if (!curr->map()->instance_descriptors()->HasEnumCache()) return false;
@@ -2719,8 +2723,9 @@

 void JSObject::Lookup(String* name, LookupResult* result) {
   // Ecma-262 3rd 8.6.2.4
+  Heap* heap = HEAP;
   for (Object* current = this;
-       current != HEAP->null_value();
+       current != heap->null_value();
        current = JSObject::cast(current)->GetPrototype()) {
     JSObject::cast(current)->LocalLookup(name, result);
     if (result->IsProperty()) return;
@@ -2731,8 +2736,9 @@

 // Search object and it's prototype chain for callback properties.
 void JSObject::LookupCallback(String* name, LookupResult* result) {
+  Heap* heap = HEAP;
   for (Object* current = this;
-       current != HEAP->null_value();
+       current != heap->null_value();
        current = JSObject::cast(current)->GetPrototype()) {
     JSObject::cast(current)->LocalLookupRealNamedProperty(name, result);
     if (result->IsProperty() && result->type() == CALLBACKS) return;
@@ -3013,9 +3019,10 @@
   // Make the lookup and include prototypes.
   int accessor_index = is_getter ? kGetterIndex : kSetterIndex;
   uint32_t index = 0;
+  Heap* heap = HEAP;
   if (name->AsArrayIndex(&index)) {
     for (Object* obj = this;
-         obj != HEAP->null_value();
+         obj != heap->null_value();
          obj = JSObject::cast(obj)->GetPrototype()) {
       JSObject* js_object = JSObject::cast(obj);
       if (js_object->HasDictionaryElements()) {
@@ -3034,7 +3041,7 @@
     }
   } else {
     for (Object* obj = this;
-         obj != HEAP->null_value();
+         obj != heap->null_value();
          obj = JSObject::cast(obj)->GetPrototype()) {
       LookupResult result;
       JSObject::cast(obj)->LocalLookup(name, &result);
@@ -5127,11 +5134,14 @@
 }


-Object* Oddball::Initialize(const char* to_string, Object* to_number) {
+Object* Oddball::Initialize(const char* to_string,
+                            Object* to_number,
+                            byte kind) {
   Object* symbol = HEAP->LookupAsciiSymbol(to_string);
   if (symbol->IsFailure()) return symbol;
   set_to_string(String::cast(symbol));
   set_to_number(to_number);
+  set_kind(kind);
   return this;
 }

@@ -5184,8 +5194,9 @@

// Traverse the proposed prototype chain looking for setters for properties of
   // the same names as are set by the inline constructor.
+  Heap* heap = HEAP;
   for (Object* obj = prototype;
-       obj != HEAP->null_value();
+       obj != heap->null_value();
        obj = obj->GetPrototype()) {
     JSObject* js_object = JSObject::cast(obj);
     for (int i = 0; i < this_property_assignments_count(); i++) {
@@ -5740,7 +5751,8 @@
   // prototype cycles are prevented.
// It is sufficient to validate that the receiver is not in the new prototype
   // chain.
- for (Object* pt = value; pt != HEAP->null_value(); pt = pt->GetPrototype()) {
+  Heap* heap = HEAP;
+ for (Object* pt = value; pt != heap->null_value(); pt = pt->GetPrototype()) {
     if (JSObject::cast(pt) == this) {
       // Cycle detected.
       HandleScope scope;
@@ -5825,7 +5837,7 @@
   if (this->IsStringObjectWithCharacterAt(index)) return true;

   Object* pt = GetPrototype();
-  if (pt == HEAP->null_value()) return false;
+  if (pt->IsNull()) return false;
   return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
 }

@@ -5978,7 +5990,7 @@
   if (this->IsStringObjectWithCharacterAt(index)) return true;

   Object* pt = GetPrototype();
-  if (pt == HEAP->null_value()) return false;
+  if (pt->IsNull()) return false;
   return JSObject::cast(pt)->HasElementWithReceiver(receiver, index);
 }

@@ -6375,7 +6387,7 @@

   // Continue searching via the prototype chain.
   Object* pt = GetPrototype();
-  if (pt == HEAP->null_value()) return HEAP->undefined_value();
+  if (pt->IsNull()) return HEAP->undefined_value();
   return pt->GetElementWithReceiver(receiver, index);
 }

@@ -6522,7 +6534,7 @@
   }

   Object* pt = GetPrototype();
-  if (pt == HEAP->null_value()) return HEAP->undefined_value();
+  if (pt->IsNull()) return HEAP->undefined_value();
   return pt->GetElementWithReceiver(receiver, index);
 }

@@ -6676,7 +6688,7 @@
   // Continue searching via the prototype chain.
   Object* pt = GetPrototype();
   *attributes = ABSENT;
-  if (pt == HEAP->null_value()) return HEAP->undefined_value();
+  if (pt->IsNull()) return HEAP->undefined_value();
   return pt->GetPropertyWithReceiver(receiver, name, attributes);
 }

=======================================
--- /branches/experimental/isolates/src/objects.h       Thu Jul 15 20:09:25 2010
+++ /branches/experimental/isolates/src/objects.h       Thu Aug  5 13:38:56 2010
@@ -4756,6 +4756,9 @@
   // [to_number]: Cached to_number computed at startup.
   DECL_ACCESSORS(to_number, Object)

+  inline byte kind();
+  inline void set_kind(byte kind);
+
   // Casting.
   static inline Oddball* cast(Object* obj);

@@ -4766,12 +4769,21 @@
 #endif

   // Initialize the fields.
-  Object* Initialize(const char* to_string, Object* to_number);
+  Object* Initialize(const char* to_string, Object* to_number, byte kind);

   // Layout description.
   static const int kToStringOffset = HeapObject::kHeaderSize;
   static const int kToNumberOffset = kToStringOffset + kPointerSize;
-  static const int kSize = kToNumberOffset + kPointerSize;
+  static const int kKindOffset = kToNumberOffset + kPointerSize;
+  static const int kSize = kKindOffset + kPointerSize;
+
+  static const byte kFalse = 0;
+  static const byte kTrue = 1;
+  static const byte kNotBooleanMask = ~1;
+  static const byte kTheHole = 2;
+  static const byte kNull = 3;
+  static const byte kUndefined = 4;
+  static const byte kOther = 5;

  private:
   DISALLOW_IMPLICIT_CONSTRUCTORS(Oddball);
=======================================
--- /branches/experimental/isolates/src/prettyprinter.cc Fri Jun 25 15:32:52 2010 +++ /branches/experimental/isolates/src/prettyprinter.cc Thu Aug 5 13:38:56 2010
@@ -514,13 +514,13 @@
       Print("%c", string->Get(i));
     }
     if (quote) Print("\"");
-  } else if (object == HEAP->null_value()) {
+  } else if (object->IsNull()) {
     Print("null");
-  } else if (object == HEAP->true_value()) {
+  } else if (object->IsTrue()) {
     Print("true");
-  } else if (object == HEAP->false_value()) {
+  } else if (object->IsFalse()) {
     Print("false");
-  } else if (object == HEAP->undefined_value()) {
+  } else if (object->IsUndefined()) {
     Print("undefined");
   } else if (object->IsNumber()) {
     Print("%g", object->Number());
=======================================
--- /branches/experimental/isolates/src/runtime.cc      Fri Jul 16 10:48:57 2010
+++ /branches/experimental/isolates/src/runtime.cc      Thu Aug  5 13:38:56 2010
@@ -397,9 +397,11 @@
   CONVERT_SMI_CHECKED(fast_elements, args[3]);
   bool should_have_fast_elements = fast_elements == 1;

+  Heap* heap = Isolate::Current()->heap();
+
   // Check if boilerplate exists. If not, create it first.
   Handle<Object> boilerplate(literals->get(literals_index));
-  if (*boilerplate == HEAP->undefined_value()) {
+  if (*boilerplate == heap->undefined_value()) {
     boilerplate = CreateObjectLiteralBoilerplate(literals,
                                                  constant_properties,
should_have_fast_elements);
@@ -407,7 +409,7 @@
     // Update the functions literal and return the boilerplate.
     literals->set(literals_index, *boilerplate);
   }
-  return DeepCopyBoilerplate(HEAP, JSObject::cast(*boilerplate));
+  return DeepCopyBoilerplate(heap, JSObject::cast(*boilerplate));
 }


@@ -420,9 +422,11 @@
   CONVERT_SMI_CHECKED(fast_elements, args[3]);
   bool should_have_fast_elements = fast_elements == 1;

+  Heap* heap = Isolate::Current()->heap();
+
   // Check if boilerplate exists. If not, create it first.
   Handle<Object> boilerplate(literals->get(literals_index));
-  if (*boilerplate == HEAP->undefined_value()) {
+  if (*boilerplate == heap->undefined_value()) {
     boilerplate = CreateObjectLiteralBoilerplate(literals,
                                                  constant_properties,
should_have_fast_elements);
@@ -430,7 +434,7 @@
     // Update the functions literal and return the boilerplate.
     literals->set(literals_index, *boilerplate);
   }
-  return HEAP->CopyJSObject(JSObject::cast(*boilerplate));
+  return heap->CopyJSObject(JSObject::cast(*boilerplate));
 }


@@ -441,15 +445,17 @@
   CONVERT_SMI_CHECKED(literals_index, args[1]);
   CONVERT_ARG_CHECKED(FixedArray, elements, 2);

+  Heap* heap = Isolate::Current()->heap();
+
   // Check if boilerplate exists. If not, create it first.
   Handle<Object> boilerplate(literals->get(literals_index));
-  if (*boilerplate == HEAP->undefined_value()) {
+  if (*boilerplate == heap->undefined_value()) {
     boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
     if (boilerplate.is_null()) return Failure::Exception();
     // Update the functions literal and return the boilerplate.
     literals->set(literals_index, *boilerplate);
   }
-  return DeepCopyBoilerplate(HEAP, JSObject::cast(*boilerplate));
+  return DeepCopyBoilerplate(heap, JSObject::cast(*boilerplate));
 }


@@ -460,15 +466,17 @@
   CONVERT_SMI_CHECKED(literals_index, args[1]);
   CONVERT_ARG_CHECKED(FixedArray, elements, 2);

+  Heap* heap = Isolate::Current()->heap();
+
   // Check if boilerplate exists. If not, create it first.
   Handle<Object> boilerplate(literals->get(literals_index));
-  if (*boilerplate == HEAP->undefined_value()) {
+  if (*boilerplate == heap->undefined_value()) {
     boilerplate = CreateArrayLiteralBoilerplate(literals, elements);
     if (boilerplate.is_null()) return Failure::Exception();
     // Update the functions literal and return the boilerplate.
     literals->set(literals_index, *boilerplate);
   }
-  return HEAP->CopyJSObject(JSObject::cast(*boilerplate));
+  return heap->CopyJSObject(JSObject::cast(*boilerplate));
 }


=======================================
--- /branches/experimental/isolates/src/string-stream.cc Tue Jun 29 11:05:31 2010 +++ /branches/experimental/isolates/src/string-stream.cc Thu Aug 5 13:38:56 2010
@@ -377,9 +377,10 @@


 void StringStream::PrintFixedArray(FixedArray* array, unsigned int limit) {
+  Heap* heap = HEAP;
   for (unsigned int i = 0; i < 10 && i < limit; i++) {
     Object* element = array->get(i);
-    if (element != HEAP->the_hole_value()) {
+    if (element != heap->the_hole_value()) {
       for (int len = 1; len < 18; len++)
         Put(' ');
       Add("%d: %o\n", i, array->get(i));
@@ -532,10 +533,11 @@
 void StringStream::PrintPrototype(JSFunction* fun, Object* receiver) {
   Object* name = fun->shared()->name();
   bool print_name = false;
- for (Object* p = receiver; p != HEAP->null_value(); p = p->GetPrototype()) {
+  Heap* heap = HEAP;
+ for (Object* p = receiver; p != heap->null_value(); p = p->GetPrototype()) {
     if (p->IsJSObject()) {
       Object* key = JSObject::cast(p)->SlowReverseLookup(fun);
-      if (key != HEAP->undefined_value()) {
+      if (key != heap->undefined_value()) {
         if (!name->IsString() ||
             !key->IsString() ||
             !String::cast(name)->Equals(String::cast(key))) {
=======================================
--- /branches/experimental/isolates/src/stub-cache.cc Thu Jul 15 20:09:25 2010 +++ /branches/experimental/isolates/src/stub-cache.cc Thu Aug 5 13:38:56 2010
@@ -107,7 +107,8 @@
   String* cache_name = HEAP->empty_string();
   if (receiver->IsGlobalObject()) cache_name = name;
   JSObject* last = receiver;
-  while (last->GetPrototype() != HEAP->null_value()) {
+  Heap* heap = HEAP;
+  while (last->GetPrototype() != heap->null_value()) {
     last = JSObject::cast(last->GetPrototype());
     if (last->IsGlobalObject()) cache_name = name;
   }
@@ -663,16 +664,17 @@


 static Object* ProbeCache(Code::Flags flags) {
+  Heap* heap = HEAP;
   Object* probe = GetProbeValue(flags);
-  if (probe != HEAP->undefined_value()) return probe;
+  if (probe != heap->undefined_value()) return probe;
   // Seed the cache with an undefined value to make sure that any
   // generated code object can always be inserted into the cache
   // without causing  allocation failures.
   Object* result =
-      HEAP->non_monomorphic_cache()->AtNumberPut(flags,
-                                                 HEAP->undefined_value());
+      heap->non_monomorphic_cache()->AtNumberPut(flags,
+                                                 heap->undefined_value());
   if (result->IsFailure()) return result;
-  HEAP->public_set_non_monomorphic_cache(NumberDictionary::cast(result));
+  heap->public_set_non_monomorphic_cache(NumberDictionary::cast(result));
   return probe;
 }

@@ -1218,7 +1220,7 @@
   if (!lookup->IsProperty()) {
     lookup->NotFound();
     Object* proto = holder->GetPrototype();
-    if (proto != HEAP->null_value()) {
+    if (!proto->IsNull()) {
       proto->Lookup(name, lookup);
     }
   }
=======================================
--- /branches/experimental/isolates/src/x64/codegen-x64.cc Fri Jul 16 01:56:05 2010 +++ /branches/experimental/isolates/src/x64/codegen-x64.cc Thu Aug 5 13:38:56 2010
@@ -1194,7 +1194,7 @@
       UNREACHABLE();
       break;
   }
-  if (answer_object == HEAP->undefined_value()) {
+  if (answer_object->IsUndefined()) {
     return false;
   }
   frame_->Push(Handle<Object>(answer_object));

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

Reply via email to