From 02495d54597f071cf7281864df3f89b311113823 Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Tue, 11 Aug 2015 04:29:59 -0700 Subject: [PATCH] [heap] Avoid inclusion of objects-visiting-inl.h header. R=hpayer@chromium.org Review URL: https://codereview.chromium.org/1272933004 Cr-Commit-Position: refs/heads/master@{#30109} --- src/DEPS | 4 -- src/heap/objects-visiting-inl.h | 2 + src/heap/objects-visiting.cc | 130 +++++++++++++++++++++++++++++++++++++++ src/objects.cc | 133 ---------------------------------------- 4 files changed, 132 insertions(+), 137 deletions(-) diff --git a/src/DEPS b/src/DEPS index 37becca..4b95456 100644 --- a/src/DEPS +++ b/src/DEPS @@ -22,8 +22,4 @@ specific_include_rules = { "d8\.cc": [ "+include/libplatform/libplatform.h", ], - # TODO(mstarzinger): Only needed because of Code::CodeIterateBody cyclicity. - "objects\.cc": [ - "+src/heap/objects-visiting-inl.h", - ], } diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h index dbc296e..4838efb 100644 --- a/src/heap/objects-visiting-inl.h +++ b/src/heap/objects-visiting-inl.h @@ -6,6 +6,8 @@ #define V8_OBJECTS_VISITING_INL_H_ #include "src/heap/objects-visiting.h" +#include "src/ic/ic-state.h" +#include "src/macro-assembler.h" namespace v8 { namespace internal { diff --git a/src/heap/objects-visiting.cc b/src/heap/objects-visiting.cc index a65f534..ff5b859 100644 --- a/src/heap/objects-visiting.cc +++ b/src/heap/objects-visiting.cc @@ -6,6 +6,7 @@ #include "src/heap/mark-compact-inl.h" #include "src/heap/objects-visiting.h" +#include "src/heap/objects-visiting-inl.h" namespace v8 { namespace internal { @@ -173,6 +174,135 @@ StaticVisitorBase::VisitorId StaticVisitorBase::GetVisitorId( } +void HeapObject::IterateBody(InstanceType type, int object_size, + ObjectVisitor* v) { + // Avoiding ::cast(this) because it accesses the map pointer field. + // During GC, the map pointer field is encoded. + if (type < FIRST_NONSTRING_TYPE) { + switch (type & kStringRepresentationMask) { + case kSeqStringTag: + break; + case kConsStringTag: + ConsString::BodyDescriptor::IterateBody(this, v); + break; + case kSlicedStringTag: + SlicedString::BodyDescriptor::IterateBody(this, v); + break; + case kExternalStringTag: + if ((type & kStringEncodingMask) == kOneByteStringTag) { + reinterpret_cast(this) + ->ExternalOneByteStringIterateBody(v); + } else { + reinterpret_cast(this) + ->ExternalTwoByteStringIterateBody(v); + } + break; + } + return; + } + + switch (type) { + case FIXED_ARRAY_TYPE: + FixedArray::BodyDescriptor::IterateBody(this, object_size, v); + break; + case FIXED_DOUBLE_ARRAY_TYPE: + break; + case JS_OBJECT_TYPE: + case JS_CONTEXT_EXTENSION_OBJECT_TYPE: + case JS_GENERATOR_OBJECT_TYPE: + case JS_MODULE_TYPE: + case JS_VALUE_TYPE: + case JS_DATE_TYPE: + case JS_ARRAY_TYPE: + case JS_ARRAY_BUFFER_TYPE: + case JS_TYPED_ARRAY_TYPE: + case JS_DATA_VIEW_TYPE: + case JS_SET_TYPE: + case JS_MAP_TYPE: + case JS_SET_ITERATOR_TYPE: + case JS_MAP_ITERATOR_TYPE: + case JS_WEAK_MAP_TYPE: + case JS_WEAK_SET_TYPE: + case JS_REGEXP_TYPE: + case JS_GLOBAL_PROXY_TYPE: + case JS_GLOBAL_OBJECT_TYPE: + case JS_BUILTINS_OBJECT_TYPE: + case JS_MESSAGE_OBJECT_TYPE: + JSObject::BodyDescriptor::IterateBody(this, object_size, v); + break; + case JS_FUNCTION_TYPE: + reinterpret_cast(this) + ->JSFunctionIterateBody(object_size, v); + break; + case ODDBALL_TYPE: + Oddball::BodyDescriptor::IterateBody(this, v); + break; + case JS_PROXY_TYPE: + JSProxy::BodyDescriptor::IterateBody(this, v); + break; + case JS_FUNCTION_PROXY_TYPE: + JSFunctionProxy::BodyDescriptor::IterateBody(this, v); + break; + case FOREIGN_TYPE: + reinterpret_cast(this)->ForeignIterateBody(v); + break; + case MAP_TYPE: + Map::BodyDescriptor::IterateBody(this, v); + break; + case CODE_TYPE: + reinterpret_cast(this)->CodeIterateBody(v); + break; + case CELL_TYPE: + Cell::BodyDescriptor::IterateBody(this, v); + break; + case PROPERTY_CELL_TYPE: + PropertyCell::BodyDescriptor::IterateBody(this, v); + break; + case WEAK_CELL_TYPE: + WeakCell::BodyDescriptor::IterateBody(this, v); + break; + case SYMBOL_TYPE: + Symbol::BodyDescriptor::IterateBody(this, v); + break; + + case HEAP_NUMBER_TYPE: + case MUTABLE_HEAP_NUMBER_TYPE: + case SIMD128_VALUE_TYPE: + case FILLER_TYPE: + case BYTE_ARRAY_TYPE: + case BYTECODE_ARRAY_TYPE: + case FREE_SPACE_TYPE: + break; + +#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ + case FIXED_##TYPE##_ARRAY_TYPE: \ + reinterpret_cast(this) \ + ->FixedTypedArrayBaseIterateBody(v); \ + break; + TYPED_ARRAYS(TYPED_ARRAY_CASE) +#undef TYPED_ARRAY_CASE + + case SHARED_FUNCTION_INFO_TYPE: { + SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); + break; + } + +#define MAKE_STRUCT_CASE(NAME, Name, name) case NAME##_TYPE: + STRUCT_LIST(MAKE_STRUCT_CASE) +#undef MAKE_STRUCT_CASE + if (type == ALLOCATION_SITE_TYPE) { + AllocationSite::BodyDescriptor::IterateBody(this, v); + } else { + StructBodyDescriptor::IterateBody(this, object_size, v); + } + break; + default: + PrintF("Unknown type: %d\n", type); + UNREACHABLE(); + } +} + + // We don't record weak slots during marking or scavenges. Instead we do it // once when we complete mark-compact cycle. Note that write barrier has no // effect if we are already in the middle of compacting mark-sweep cycle and we diff --git a/src/objects.cc b/src/objects.cc index 36b43cc..e45d0cd 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -27,7 +27,6 @@ #include "src/field-index-inl.h" #include "src/field-index.h" #include "src/full-codegen/full-codegen.h" -#include "src/heap/objects-visiting-inl.h" #include "src/hydrogen.h" #include "src/ic/ic.h" #include "src/interpreter/bytecodes.h" @@ -1466,138 +1465,6 @@ void HeapObject::Iterate(ObjectVisitor* v) { } -void HeapObject::IterateBody(InstanceType type, int object_size, - ObjectVisitor* v) { - // Avoiding ::cast(this) because it accesses the map pointer field. - // During GC, the map pointer field is encoded. - if (type < FIRST_NONSTRING_TYPE) { - switch (type & kStringRepresentationMask) { - case kSeqStringTag: - break; - case kConsStringTag: - ConsString::BodyDescriptor::IterateBody(this, v); - break; - case kSlicedStringTag: - SlicedString::BodyDescriptor::IterateBody(this, v); - break; - case kExternalStringTag: - if ((type & kStringEncodingMask) == kOneByteStringTag) { - reinterpret_cast(this) - ->ExternalOneByteStringIterateBody(v); - } else { - reinterpret_cast(this)-> - ExternalTwoByteStringIterateBody(v); - } - break; - } - return; - } - - switch (type) { - case FIXED_ARRAY_TYPE: - FixedArray::BodyDescriptor::IterateBody(this, object_size, v); - break; - case FIXED_DOUBLE_ARRAY_TYPE: - break; - case JS_OBJECT_TYPE: - case JS_CONTEXT_EXTENSION_OBJECT_TYPE: - case JS_GENERATOR_OBJECT_TYPE: - case JS_MODULE_TYPE: - case JS_VALUE_TYPE: - case JS_DATE_TYPE: - case JS_ARRAY_TYPE: - case JS_ARRAY_BUFFER_TYPE: - case JS_TYPED_ARRAY_TYPE: - case JS_DATA_VIEW_TYPE: - case JS_SET_TYPE: - case JS_MAP_TYPE: - case JS_SET_ITERATOR_TYPE: - case JS_MAP_ITERATOR_TYPE: - case JS_WEAK_MAP_TYPE: - case JS_WEAK_SET_TYPE: - case JS_REGEXP_TYPE: - case JS_GLOBAL_PROXY_TYPE: - case JS_GLOBAL_OBJECT_TYPE: - case JS_BUILTINS_OBJECT_TYPE: - case JS_MESSAGE_OBJECT_TYPE: - JSObject::BodyDescriptor::IterateBody(this, object_size, v); - break; - case JS_FUNCTION_TYPE: - reinterpret_cast(this) - ->JSFunctionIterateBody(object_size, v); - break; - case ODDBALL_TYPE: - Oddball::BodyDescriptor::IterateBody(this, v); - break; - case JS_PROXY_TYPE: - JSProxy::BodyDescriptor::IterateBody(this, v); - break; - case JS_FUNCTION_PROXY_TYPE: - JSFunctionProxy::BodyDescriptor::IterateBody(this, v); - break; - case FOREIGN_TYPE: - reinterpret_cast(this)->ForeignIterateBody(v); - break; - case MAP_TYPE: - Map::BodyDescriptor::IterateBody(this, v); - break; - case CODE_TYPE: - reinterpret_cast(this)->CodeIterateBody(v); - break; - case CELL_TYPE: - Cell::BodyDescriptor::IterateBody(this, v); - break; - case PROPERTY_CELL_TYPE: - PropertyCell::BodyDescriptor::IterateBody(this, v); - break; - case WEAK_CELL_TYPE: - WeakCell::BodyDescriptor::IterateBody(this, v); - break; - case SYMBOL_TYPE: - Symbol::BodyDescriptor::IterateBody(this, v); - break; - - case HEAP_NUMBER_TYPE: - case MUTABLE_HEAP_NUMBER_TYPE: - case SIMD128_VALUE_TYPE: - case FILLER_TYPE: - case BYTE_ARRAY_TYPE: - case BYTECODE_ARRAY_TYPE: - case FREE_SPACE_TYPE: - break; - -#define TYPED_ARRAY_CASE(Type, type, TYPE, ctype, size) \ - case FIXED_##TYPE##_ARRAY_TYPE: \ - reinterpret_cast(this) \ - ->FixedTypedArrayBaseIterateBody(v); \ - break; - - - TYPED_ARRAYS(TYPED_ARRAY_CASE) -#undef TYPED_ARRAY_CASE - - case SHARED_FUNCTION_INFO_TYPE: { - SharedFunctionInfo::BodyDescriptor::IterateBody(this, v); - break; - } - -#define MAKE_STRUCT_CASE(NAME, Name, name) \ - case NAME##_TYPE: - STRUCT_LIST(MAKE_STRUCT_CASE) -#undef MAKE_STRUCT_CASE - if (type == ALLOCATION_SITE_TYPE) { - AllocationSite::BodyDescriptor::IterateBody(this, v); - } else { - StructBodyDescriptor::IterateBody(this, object_size, v); - } - break; - default: - PrintF("Unknown type: %d\n", type); - UNREACHABLE(); - } -} - - bool HeapNumber::HeapNumberBooleanValue() { return DoubleToBoolean(value()); } -- 2.7.4