Commit cfbd826b authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Refactor storage of JSFunctionData::initial_map.

Bug: v8:7790
Change-Id: I1834893f05229834289bc368b00dc314e7de1b65
Reviewed-on: https://chromium-review.googlesource.com/1177746Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55176}
parent 8ede7430
...@@ -74,7 +74,7 @@ class JSObjectData : public HeapObjectData { ...@@ -74,7 +74,7 @@ class JSObjectData : public HeapObjectData {
class JSFunctionData : public JSObjectData { class JSFunctionData : public JSObjectData {
public: public:
ObjectData* const global_proxy; ObjectData* const global_proxy;
ObjectData* const prototype_or_initial_map; ObjectData* const initial_map; // Can be nullptr.
ObjectData* const shared; ObjectData* const shared;
JSFunctionData(JSHeapBroker* broker_, Handle<JSFunction> object_, JSFunctionData(JSHeapBroker* broker_, Handle<JSFunction> object_,
...@@ -195,16 +195,13 @@ JSFunctionData::JSFunctionData(JSHeapBroker* broker_, ...@@ -195,16 +195,13 @@ JSFunctionData::JSFunctionData(JSHeapBroker* broker_,
Handle<JSFunction> object_, HeapObjectType type_) Handle<JSFunction> object_, HeapObjectType type_)
: JSObjectData(broker_, object_, type_), : JSObjectData(broker_, object_, type_),
global_proxy(GET_OR_CREATE(global_proxy)), global_proxy(GET_OR_CREATE(global_proxy)),
prototype_or_initial_map(object_->map()->has_prototype_slot() initial_map(object_->has_prototype_slot() && object_->has_initial_map()
? GET_OR_CREATE(prototype_or_initial_map) ? GET_OR_CREATE(initial_map)
: nullptr), : nullptr),
shared(GET_OR_CREATE(shared)) { shared(GET_OR_CREATE(shared)) {
if (prototype_or_initial_map != nullptr && if (initial_map != nullptr &&
prototype_or_initial_map->IsMap()) { initial_map->AsMap()->instance_type == JS_ARRAY_TYPE) {
MapData* initial_map = prototype_or_initial_map->AsMap(); initial_map->AsMap()->SerializeElementsKindGeneralizations();
if (initial_map->instance_type == JS_ARRAY_TYPE) {
initial_map->SerializeElementsKindGeneralizations();
}
} }
} }
...@@ -803,6 +800,13 @@ int SharedFunctionInfoRef::GetBytecodeArrayRegisterCount() const { ...@@ -803,6 +800,13 @@ int SharedFunctionInfoRef::GetBytecodeArrayRegisterCount() const {
return object<SharedFunctionInfo>()->GetBytecodeArray()->register_count(); return object<SharedFunctionInfo>()->GetBytecodeArray()->register_count();
} }
#define IF_BROKER_DISABLED_ACCESS_HANDLE_C(holder, name) \
if (broker()->mode() == JSHeapBroker::kDisabled) { \
AllowHandleAllocation handle_allocation; \
AllowHandleDereference allow_handle_dereference; \
return object<holder>()->name(); \
}
// Macros for definining a const getter that, depending on the broker mode, // Macros for definining a const getter that, depending on the broker mode,
// either looks into the handle or into the serialized data. The first one is // either looks into the handle or into the serialized data. The first one is
// used for the rare case of a XYZRef class that does not have a corresponding // used for the rare case of a XYZRef class that does not have a corresponding
...@@ -822,27 +826,17 @@ int SharedFunctionInfoRef::GetBytecodeArrayRegisterCount() const { ...@@ -822,27 +826,17 @@ int SharedFunctionInfoRef::GetBytecodeArrayRegisterCount() const {
BIMODAL_ACCESSOR_(holder, holder, result, name) BIMODAL_ACCESSOR_(holder, holder, result, name)
// Like HANDLE_ACCESSOR except that the result type is not an XYZRef. // Like HANDLE_ACCESSOR except that the result type is not an XYZRef.
#define BIMODAL_ACCESSOR_C(holder, result, name) \ #define BIMODAL_ACCESSOR_C(holder, result, name) \
result holder##Ref::name() const { \ result holder##Ref::name() const { \
if (broker()->mode() == JSHeapBroker::kDisabled) { \ IF_BROKER_DISABLED_ACCESS_HANDLE_C(holder, name); \
AllowHandleAllocation handle_allocation; \ return data()->As##holder()->name; \
AllowHandleDereference allow_handle_dereference; \
return object<holder>()->name(); \
} else { \
return data()->As##holder()->name; \
} \
} }
// Like HANDLE_ACCESSOR_C but for BitFields. // Like HANDLE_ACCESSOR_C but for BitFields.
#define BIMODAL_ACCESSOR_B(holder, field, name, BitField) \ #define BIMODAL_ACCESSOR_B(holder, field, name, BitField) \
typename BitField::FieldType holder##Ref::name() const { \ typename BitField::FieldType holder##Ref::name() const { \
if (broker()->mode() == JSHeapBroker::kDisabled) { \ IF_BROKER_DISABLED_ACCESS_HANDLE_C(holder, name); \
AllowHandleAllocation handle_allocation; \ return BitField::decode(data()->As##holder()->field); \
AllowHandleDereference allow_handle_dereference; \
return object<holder>()->name(); \
} else { \
return BitField::decode(data()->As##holder()->field); \
} \
} }
// Macros for definining a const getter that always looks into the handle. // Macros for definining a const getter that always looks into the handle.
...@@ -885,10 +879,9 @@ HANDLE_ACCESSOR_C(HeapNumber, double, value) ...@@ -885,10 +879,9 @@ HANDLE_ACCESSOR_C(HeapNumber, double, value)
HANDLE_ACCESSOR_C(JSArray, ElementsKind, GetElementsKind) HANDLE_ACCESSOR_C(JSArray, ElementsKind, GetElementsKind)
HANDLE_ACCESSOR(JSArray, Object, length) HANDLE_ACCESSOR(JSArray, Object, length)
HANDLE_ACCESSOR_C(JSFunction, bool, has_initial_map) BIMODAL_ACCESSOR(JSFunction, Map, initial_map)
HANDLE_ACCESSOR_C(JSFunction, bool, IsConstructor) HANDLE_ACCESSOR_C(JSFunction, bool, IsConstructor)
HANDLE_ACCESSOR(JSFunction, JSGlobalProxy, global_proxy) HANDLE_ACCESSOR(JSFunction, JSGlobalProxy, global_proxy)
HANDLE_ACCESSOR(JSFunction, Map, initial_map)
HANDLE_ACCESSOR(JSFunction, SharedFunctionInfo, shared) HANDLE_ACCESSOR(JSFunction, SharedFunctionInfo, shared)
HANDLE_ACCESSOR_C(JSObject, ElementsKind, GetElementsKind) HANDLE_ACCESSOR_C(JSObject, ElementsKind, GetElementsKind)
...@@ -953,6 +946,11 @@ HANDLE_ACCESSOR_C(SharedFunctionInfo, LanguageMode, language_mode) ...@@ -953,6 +946,11 @@ HANDLE_ACCESSOR_C(SharedFunctionInfo, LanguageMode, language_mode)
// TODO(neis): Provide StringShape() on StringRef. // TODO(neis): Provide StringShape() on StringRef.
bool JSFunctionRef::has_initial_map() const {
IF_BROKER_DISABLED_ACCESS_HANDLE_C(JSFunction, has_initial_map);
return data()->AsJSFunction()->initial_map != nullptr;
}
bool JSFunctionRef::HasBuiltinFunctionId() const { bool JSFunctionRef::HasBuiltinFunctionId() const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return object<JSFunction>()->shared()->HasBuiltinFunctionId(); return object<JSFunction>()->shared()->HasBuiltinFunctionId();
...@@ -1075,6 +1073,7 @@ Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker, ...@@ -1075,6 +1073,7 @@ Reduction NoChangeBecauseOfMissingData(JSHeapBroker* broker,
#undef HANDLE_ACCESSOR #undef HANDLE_ACCESSOR
#undef HANDLE_ACCESSOR_ #undef HANDLE_ACCESSOR_
#undef HANDLE_ACCESSOR_C #undef HANDLE_ACCESSOR_C
#undef IF_BROKER_DISABLED_ACCESS_HANDLE_C
#undef NATIVE_CONTEXT_DATA #undef NATIVE_CONTEXT_DATA
} // namespace compiler } // namespace compiler
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment