From: yangguo@chromium.org Date: Wed, 11 Sep 2013 13:00:27 +0000 (+0000) Subject: Add assertion to UniqueValueId constructor. X-Git-Tag: upstream/4.7.83~12560 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=64bb1800a5d2d7aa19ba85e7258f3b21a6c923a4;p=platform%2Fupstream%2Fv8.git Add assertion to UniqueValueId constructor. R=verwaest@chromium.org BUG= Review URL: https://codereview.chromium.org/23781006 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16652 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 4c2e308..cca95b9 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -3455,7 +3455,7 @@ void HAllocate::CreateFreeSpaceFiller(int32_t free_space_size) { zone, context(), isolate()->factory()->free_space_map(), - UniqueValueId(isolate()->heap()->free_space_map())); + UniqueValueId::free_space_map(isolate()->heap())); filler_map->InsertAfter(free_space_instr); HInstruction* store_map = HStoreNamedField::New(zone, context(), free_space_instr, HObjectAccess::ForMap(), filler_map); diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index aa2cdae..7d33141 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -309,12 +309,8 @@ class UniqueValueId V8_FINAL { public: UniqueValueId() : raw_address_(NULL) { } - explicit UniqueValueId(Object* object) { - raw_address_ = reinterpret_cast
(object); - ASSERT(IsInitialized()); - } - explicit UniqueValueId(Handle handle) { + ASSERT(!AllowHeapAllocation::IsAllowed()); static const Address kEmptyHandleSentinel = reinterpret_cast
(1); if (handle.is_null()) { raw_address_ = kEmptyHandleSentinel; @@ -342,8 +338,28 @@ class UniqueValueId V8_FINAL { return reinterpret_cast(raw_address_); } +#define IMMOVABLE_UNIQUE_VALUE_ID(name) \ + static UniqueValueId name(Heap* heap) { return UniqueValueId(heap->name()); } + + IMMOVABLE_UNIQUE_VALUE_ID(free_space_map) + IMMOVABLE_UNIQUE_VALUE_ID(minus_zero_value) + IMMOVABLE_UNIQUE_VALUE_ID(nan_value) + IMMOVABLE_UNIQUE_VALUE_ID(undefined_value) + IMMOVABLE_UNIQUE_VALUE_ID(null_value) + IMMOVABLE_UNIQUE_VALUE_ID(true_value) + IMMOVABLE_UNIQUE_VALUE_ID(false_value) + IMMOVABLE_UNIQUE_VALUE_ID(the_hole_value) + IMMOVABLE_UNIQUE_VALUE_ID(empty_string) + +#undef IMMOVABLE_UNIQUE_VALUE_ID + private: Address raw_address_; + + explicit UniqueValueId(Object* object) { + raw_address_ = reinterpret_cast
(object); + ASSERT(IsInitialized()); + } }; @@ -3327,14 +3343,14 @@ class HConstant V8_FINAL : public HTemplateInstruction<0> { ASSERT(!handle_.is_null()); Heap* heap = isolate()->heap(); - ASSERT(unique_id_ != UniqueValueId(heap->minus_zero_value())); - ASSERT(unique_id_ != UniqueValueId(heap->nan_value())); - return unique_id_ == UniqueValueId(heap->undefined_value()) || - unique_id_ == UniqueValueId(heap->null_value()) || - unique_id_ == UniqueValueId(heap->true_value()) || - unique_id_ == UniqueValueId(heap->false_value()) || - unique_id_ == UniqueValueId(heap->the_hole_value()) || - unique_id_ == UniqueValueId(heap->empty_string()); + ASSERT(unique_id_ != UniqueValueId::minus_zero_value(heap)); + ASSERT(unique_id_ != UniqueValueId::nan_value(heap)); + return unique_id_ == UniqueValueId::undefined_value(heap) || + unique_id_ == UniqueValueId::null_value(heap) || + unique_id_ == UniqueValueId::true_value(heap) || + unique_id_ == UniqueValueId::false_value(heap) || + unique_id_ == UniqueValueId::the_hole_value(heap) || + unique_id_ == UniqueValueId::empty_string(heap); } bool IsCell() const { diff --git a/src/hydrogen.cc b/src/hydrogen.cc index 437d29b..ebdf1d4 100644 --- a/src/hydrogen.cc +++ b/src/hydrogen.cc @@ -649,7 +649,7 @@ HConstant* HGraph::GetConstant##Name() { \ if (!constant_##name##_.is_set()) { \ HConstant* constant = new(zone()) HConstant( \ isolate()->factory()->name##_value(), \ - UniqueValueId(isolate()->heap()->name##_value()), \ + UniqueValueId::name##_value(isolate()->heap()), \ Representation::Tagged(), \ htype, \ false, \