From 735a507385e001401859f8a4e4154113abf2e4f7 Mon Sep 17 00:00:00 2001 From: "bmeurer@chromium.org" Date: Fri, 31 Jan 2014 07:28:46 +0000 Subject: [PATCH] Improve HConstant::ImmortalImmovable() to check for all immortal immovable roots. Move the list to IMMORTAL_IMMOVABLE_ROOT_LIST in heap.h, and automatically include INTERNALIZED_STRING_LIST and STRING_TYPE_LIST. R=hpayer@chromium.org, mstarzinger@chromium.org Review URL: https://codereview.chromium.org/146623003 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@18970 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/heap.h | 45 ++++++++++++++++++++++++++++++++++++++++++++ src/hydrogen-instructions.cc | 35 ++++++++++++++++++++++++++++++++++ src/hydrogen-instructions.h | 29 +--------------------------- src/objects.h | 2 +- 4 files changed, 82 insertions(+), 29 deletions(-) diff --git a/src/heap.h b/src/heap.h index 6a72cb8..bed6105 100644 --- a/src/heap.h +++ b/src/heap.h @@ -208,6 +208,51 @@ namespace internal { STRONG_ROOT_LIST(V) \ V(StringTable, string_table, StringTable) +// Heap roots that are known to be immortal immovable, for which we can safely +// skip write barriers. +#define IMMORTAL_IMMOVABLE_ROOT_LIST(V) \ + V(byte_array_map) \ + V(free_space_map) \ + V(one_pointer_filler_map) \ + V(two_pointer_filler_map) \ + V(undefined_value) \ + V(the_hole_value) \ + V(null_value) \ + V(true_value) \ + V(false_value) \ + V(uninitialized_value) \ + V(cell_map) \ + V(global_property_cell_map) \ + V(shared_function_info_map) \ + V(meta_map) \ + V(heap_number_map) \ + V(native_context_map) \ + V(fixed_array_map) \ + V(code_map) \ + V(scope_info_map) \ + V(fixed_cow_array_map) \ + V(fixed_double_array_map) \ + V(constant_pool_array_map) \ + V(no_interceptor_result_sentinel) \ + V(hash_table_map) \ + V(empty_fixed_array) \ + V(empty_byte_array) \ + V(empty_descriptor_array) \ + V(empty_constant_pool_array) \ + V(arguments_marker) \ + V(symbol_map) \ + V(non_strict_arguments_elements_map) \ + V(function_context_map) \ + V(catch_context_map) \ + V(with_context_map) \ + V(block_context_map) \ + V(module_context_map) \ + V(global_context_map) \ + V(oddball_map) \ + V(message_object_map) \ + V(foreign_map) \ + V(neander_map) + #define INTERNALIZED_STRING_LIST(V) \ V(Array_string, "Array") \ V(Object_string, "Object") \ diff --git a/src/hydrogen-instructions.cc b/src/hydrogen-instructions.cc index 889ebfd..469caf6 100644 --- a/src/hydrogen-instructions.cc +++ b/src/hydrogen-instructions.cc @@ -2611,6 +2611,41 @@ void HConstant::Initialize(Representation r) { } +bool HConstant::ImmortalImmovable() const { + if (has_int32_value_) { + return false; + } + if (has_double_value_) { + if (IsSpecialDouble()) { + return true; + } + return false; + } + if (has_external_reference_value_) { + return false; + } + + ASSERT(!object_.handle().is_null()); + Heap* heap = isolate()->heap(); + ASSERT(!object_.IsKnownGlobal(heap->minus_zero_value())); + ASSERT(!object_.IsKnownGlobal(heap->nan_value())); + return +#define IMMORTAL_IMMOVABLE_ROOT(name) \ + object_.IsKnownGlobal(heap->name()) || + IMMORTAL_IMMOVABLE_ROOT_LIST(IMMORTAL_IMMOVABLE_ROOT) +#undef IMMORTAL_IMMOVABLE_ROOT +#define INTERNALIZED_STRING(name, value) \ + object_.IsKnownGlobal(heap->name()) || + INTERNALIZED_STRING_LIST(INTERNALIZED_STRING) +#undef INTERNALIZED_STRING +#define STRING_TYPE(NAME, size, name, Name) \ + object_.IsKnownGlobal(heap->name##_map()) || + STRING_TYPE_LIST(STRING_TYPE) +#undef STRING_TYPE + false; +} + + bool HConstant::EmitAtUses() { ASSERT(IsLinked()); if (block()->graph()->has_osr() && diff --git a/src/hydrogen-instructions.h b/src/hydrogen-instructions.h index ebbd287..48d5337 100644 --- a/src/hydrogen-instructions.h +++ b/src/hydrogen-instructions.h @@ -3390,34 +3390,7 @@ class HConstant V8_FINAL : public HTemplateInstruction<0> { return is_not_in_new_space_; } - bool ImmortalImmovable() const { - if (has_int32_value_) { - return false; - } - if (has_double_value_) { - if (IsSpecialDouble()) { - return true; - } - return false; - } - if (has_external_reference_value_) { - return false; - } - - ASSERT(!object_.handle().is_null()); - Heap* heap = isolate()->heap(); - ASSERT(!object_.IsKnownGlobal(heap->minus_zero_value())); - ASSERT(!object_.IsKnownGlobal(heap->nan_value())); - return - object_.IsKnownGlobal(heap->undefined_value()) || - object_.IsKnownGlobal(heap->uninitialized_value()) || - object_.IsKnownGlobal(heap->null_value()) || - object_.IsKnownGlobal(heap->true_value()) || - object_.IsKnownGlobal(heap->false_value()) || - object_.IsKnownGlobal(heap->the_hole_value()) || - object_.IsKnownGlobal(heap->empty_string()) || - object_.IsKnownGlobal(heap->empty_fixed_array()); - } + bool ImmortalImmovable() const; bool IsCell() const { return is_cell_; diff --git a/src/objects.h b/src/objects.h index ff21a1f..08aba3e 100644 --- a/src/objects.h +++ b/src/objects.h @@ -489,7 +489,7 @@ const int kStubMinorKeyBits = kBitsPerInt - kSmiTagSize - kStubMajorKeyBits; ExternalAsciiString) \ V(EXTERNAL_STRING_WITH_ONE_BYTE_DATA_TYPE, \ ExternalTwoByteString::kSize, \ - external_string_with_one_bytei_data, \ + external_string_with_one_byte_data, \ ExternalStringWithOneByteData) \ V(SHORT_EXTERNAL_STRING_TYPE, \ ExternalTwoByteString::kShortSize, \ -- 2.7.4