Reviewers: Toon Verwaest,
Message:
Please take a look.
Description:
Add assertion to UniqueValueId constructor.
[email protected]
BUG=
Please review this at https://codereview.chromium.org/23781006/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files (+26, -25 lines):
M src/handles-inl.h
M src/heap.h
M src/hydrogen-instructions.h
M src/hydrogen-instructions.cc
M src/hydrogen.cc
Index: src/handles-inl.h
diff --git a/src/handles-inl.h b/src/handles-inl.h
index
4f4490b75bfa97d2c0aa0d0e03b3833f3a19c8fb..20a5e22a9c1befb12c46879dc36cc854fd51d25d
100644
--- a/src/handles-inl.h
+++ b/src/handles-inl.h
@@ -85,24 +85,20 @@ bool
Handle<T>::IsDereferenceAllowed(DereferenceCheckMode mode) const {
Object* object = *BitCast<T**>(location_);
if (object->IsSmi()) return true;
HeapObject* heap_object = HeapObject::cast(object);
- Isolate* isolate = heap_object->GetIsolate();
- Object** handle = reinterpret_cast<Object**>(location_);
- Object** roots_array_start = isolate->heap()->roots_array_start();
- if (roots_array_start <= handle &&
- handle < roots_array_start + Heap::kStrongRootListLength) {
- return true;
- }
+ Heap* heap = heap_object->GetHeap();
+ Object** handle = reinterpret_cast<Object**>(location_);;
+ if (heap->IsInRootsArray(handle)) return true;
if (!AllowHandleDereference::IsAllowed()) return false;
if (mode == INCLUDE_DEFERRED_CHECK &&
!AllowDeferredHandleDereference::IsAllowed()) {
// Accessing maps and internalized strings is safe.
if (heap_object->IsMap()) return true;
if (heap_object->IsInternalizedString()) return true;
- return !isolate->IsDeferredHandle(handle);
+ return !heap->isolate()->IsDeferredHandle(handle);
}
return true;
}
-#endif
+#endif // DEBUG
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index
4dfa076ebd7745c14e953cbf0deb3bd396eb5c5a..8bd3b0d7f0943181e7a980787f47dae6ca621ac3
100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -1414,6 +1414,12 @@ class Heap {
// Generated code can embed this address to get access to the roots.
Object** roots_array_start() { return roots_; }
+#ifdef DEBUG
+ bool IsInRootsArray(Object** handle) {
+ return roots_ <= handle && handle < roots_ +
Heap::kStrongRootListLength;
+ }
+#endif
+
Address* store_buffer_top_address() {
return reinterpret_cast<Address*>(&roots_[kStoreBufferTopRootIndex]);
}
Index: src/hydrogen-instructions.cc
diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc
index
4c2e3085c70a6b2e56b61e8a1ea00dced20e42ca..216c2374dc0e9024c50e93993e6335b185ec87be
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(isolate()->factory()->free_space_map()));
filler_map->InsertAfter(free_space_instr);
HInstruction* store_map = HStoreNamedField::New(zone, context(),
free_space_instr, HObjectAccess::ForMap(), filler_map);
Index: src/hydrogen-instructions.h
diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h
index
aa2cdae0a83190b00c7dbdd132f9066e518f49ae..a6e5a23e062fc4062b65fdd7052dd58f1e90282a
100644
--- a/src/hydrogen-instructions.h
+++ b/src/hydrogen-instructions.h
@@ -309,12 +309,11 @@ class UniqueValueId V8_FINAL {
public:
UniqueValueId() : raw_address_(NULL) { }
- explicit UniqueValueId(Object* object) {
- raw_address_ = reinterpret_cast<Address>(object);
- ASSERT(IsInitialized());
- }
-
explicit UniqueValueId(Handle<Object> handle) {
+ ASSERT(!AllowHeapAllocation::IsAllowed() ||
+ handle->IsSmi() ||
+ HeapObject::cast(*handle)->GetHeap()->IsInRootsArray(
+ handle.location()));
static const Address kEmptyHandleSentinel =
reinterpret_cast<Address>(1);
if (handle.is_null()) {
raw_address_ = kEmptyHandleSentinel;
@@ -3326,15 +3325,15 @@ 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());
+ Factory* factory = isolate()->factory();
+ ASSERT(unique_id_ != UniqueValueId(factory->minus_zero_value()));
+ ASSERT(unique_id_ != UniqueValueId(factory->nan_value()));
+ return unique_id_ == UniqueValueId(factory->undefined_value()) ||
+ unique_id_ == UniqueValueId(factory->null_value()) ||
+ unique_id_ == UniqueValueId(factory->true_value()) ||
+ unique_id_ == UniqueValueId(factory->false_value()) ||
+ unique_id_ == UniqueValueId(factory->the_hole_value()) ||
+ unique_id_ == UniqueValueId(factory->empty_string());
}
bool IsCell() const {
Index: src/hydrogen.cc
diff --git a/src/hydrogen.cc b/src/hydrogen.cc
index
437d29b82e75a900410352d1e5261c4f6b7791be..de73ba3abee4bc7606a68a75c3b60f0821c7b027
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(isolate()->factory()->name##_value()), \
Representation::Tagged(), \
htype, \
false, \
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.