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

[turbofan] Serialize SharedFunctionInfo.

GetBytecodeArrayRegisterCount is still missing.

Bug: v8:7790
Change-Id: I7255e60ef13e48a514cc09231cdb3cc42328d441
Reviewed-on: https://chromium-review.googlesource.com/1181568Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#55248}
parent 29a112bb
...@@ -355,7 +355,27 @@ class FixedArrayData : public FixedArrayBaseData {}; ...@@ -355,7 +355,27 @@ class FixedArrayData : public FixedArrayBaseData {};
class FixedDoubleArrayData : public FixedArrayBaseData {}; class FixedDoubleArrayData : public FixedArrayBaseData {};
class JSArrayData : public JSObjectData {}; class JSArrayData : public JSObjectData {};
class ScopeInfoData : public HeapObjectData {}; class ScopeInfoData : public HeapObjectData {};
class SharedFunctionInfoData : public HeapObjectData {};
class SharedFunctionInfoData : public HeapObjectData {
public:
int const builtin_id;
#define DECL_MEMBER(type, name) type const name;
BROKER_SFI_FIELDS(DECL_MEMBER)
#undef DECL_MEMBER
SharedFunctionInfoData(JSHeapBroker* broker_,
Handle<SharedFunctionInfo> object_,
HeapObjectType type_)
: HeapObjectData(broker_, object_, type_),
builtin_id(object_->HasBuiltinId() ? object_->builtin_id()
: Builtins::kNoBuiltinId)
#define INIT_MEMBER(type, name) , name(object_->name())
BROKER_SFI_FIELDS(INIT_MEMBER)
#undef INIT_MEMBER
{
}
};
class ModuleData : public HeapObjectData {}; class ModuleData : public HeapObjectData {};
class CellData : public HeapObjectData {}; class CellData : public HeapObjectData {};
class JSGlobalProxyData : public JSObjectData {}; class JSGlobalProxyData : public JSObjectData {};
...@@ -416,6 +436,9 @@ HeapObjectData* HeapObjectData::Serialize(JSHeapBroker* broker, ...@@ -416,6 +436,9 @@ HeapObjectData* HeapObjectData::Serialize(JSHeapBroker* broker,
} else if (object->IsName()) { } else if (object->IsName()) {
result = result =
new (broker->zone()) NameData(broker, Handle<Name>::cast(object), type); new (broker->zone()) NameData(broker, Handle<Name>::cast(object), type);
} else if (object->IsSharedFunctionInfo()) {
result = new (broker->zone()) SharedFunctionInfoData(
broker, Handle<SharedFunctionInfo>::cast(object), type);
} else if (object->IsFeedbackVector()) { } else if (object->IsFeedbackVector()) {
result = new (broker->zone()) result = new (broker->zone())
FeedbackVectorData(broker, Handle<FeedbackVector>::cast(object), type); FeedbackVectorData(broker, Handle<FeedbackVector>::cast(object), type);
...@@ -956,17 +979,11 @@ HANDLE_ACCESSOR_C(PropertyCell, PropertyDetails, property_details) ...@@ -956,17 +979,11 @@ HANDLE_ACCESSOR_C(PropertyCell, PropertyDetails, property_details)
HANDLE_ACCESSOR_C(ScopeInfo, int, ContextLength) HANDLE_ACCESSOR_C(ScopeInfo, int, ContextLength)
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, construct_as_builtin) BIMODAL_ACCESSOR_C(SharedFunctionInfo, int, builtin_id)
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, HasBreakInfo) #define DEF_SFI_ACCESSOR(type, name) \
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, HasBuiltinId) BIMODAL_ACCESSOR_C(SharedFunctionInfo, type, name)
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, HasBytecodeArray) BROKER_SFI_FIELDS(DEF_SFI_ACCESSOR)
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, has_duplicate_parameters) #undef DEF_SFI_ACCESSOR
HANDLE_ACCESSOR_C(SharedFunctionInfo, bool, native)
HANDLE_ACCESSOR_C(SharedFunctionInfo, FunctionKind, kind)
HANDLE_ACCESSOR_C(SharedFunctionInfo, int, builtin_id)
HANDLE_ACCESSOR_C(SharedFunctionInfo, int, function_map_index)
HANDLE_ACCESSOR_C(SharedFunctionInfo, int, internal_formal_parameter_count)
HANDLE_ACCESSOR_C(SharedFunctionInfo, LanguageMode, language_mode)
BIMODAL_ACCESSOR_C(String, int, length) BIMODAL_ACCESSOR_C(String, int, length)
...@@ -977,16 +994,6 @@ bool JSFunctionRef::has_initial_map() const { ...@@ -977,16 +994,6 @@ bool JSFunctionRef::has_initial_map() const {
return data()->AsJSFunction()->initial_map != nullptr; return data()->AsJSFunction()->initial_map != nullptr;
} }
bool JSFunctionRef::HasBuiltinFunctionId() const {
AllowHandleDereference allow_handle_dereference;
return object<JSFunction>()->shared()->HasBuiltinFunctionId();
}
BuiltinFunctionId JSFunctionRef::GetBuiltinFunctionId() const {
AllowHandleDereference allow_handle_dereference;
return object<JSFunction>()->shared()->builtin_function_id();
}
MapRef NativeContextRef::GetFunctionMapFromIndex(int index) const { MapRef NativeContextRef::GetFunctionMapFromIndex(int index) const {
DCHECK_LE(index, Context::LAST_FUNCTION_MAP_INDEX); DCHECK_LE(index, Context::LAST_FUNCTION_MAP_INDEX);
DCHECK_GE(index, Context::FIRST_FUNCTION_MAP_INDEX); DCHECK_GE(index, Context::FIRST_FUNCTION_MAP_INDEX);
......
...@@ -167,8 +167,6 @@ class JSFunctionRef : public JSObjectRef { ...@@ -167,8 +167,6 @@ class JSFunctionRef : public JSObjectRef {
public: public:
using JSObjectRef::JSObjectRef; using JSObjectRef::JSObjectRef;
bool HasBuiltinFunctionId() const;
BuiltinFunctionId GetBuiltinFunctionId() const;
bool IsConstructor() const; bool IsConstructor() const;
bool has_initial_map() const; bool has_initial_map() const;
MapRef initial_map() const; MapRef initial_map() const;
...@@ -362,21 +360,29 @@ class ScopeInfoRef : public HeapObjectRef { ...@@ -362,21 +360,29 @@ class ScopeInfoRef : public HeapObjectRef {
int ContextLength() const; int ContextLength() const;
}; };
#define BROKER_SFI_FIELDS(V) \
V(int, internal_formal_parameter_count) \
V(bool, has_duplicate_parameters) \
V(int, function_map_index) \
V(FunctionKind, kind) \
V(LanguageMode, language_mode) \
V(bool, native) \
V(bool, HasBreakInfo) \
V(bool, HasBuiltinFunctionId) \
V(bool, HasBuiltinId) \
V(BuiltinFunctionId, builtin_function_id) \
V(bool, construct_as_builtin) \
V(bool, HasBytecodeArray)
class SharedFunctionInfoRef : public HeapObjectRef { class SharedFunctionInfoRef : public HeapObjectRef {
public: public:
using HeapObjectRef::HeapObjectRef; using HeapObjectRef::HeapObjectRef;
int internal_formal_parameter_count() const;
bool has_duplicate_parameters() const;
int function_map_index() const;
FunctionKind kind() const;
LanguageMode language_mode() const;
bool native() const;
bool HasBreakInfo() const;
bool HasBuiltinId() const;
int builtin_id() const; int builtin_id() const;
bool construct_as_builtin() const; #define DECL_ACCESSOR(type, name) type name() const;
bool HasBytecodeArray() const; BROKER_SFI_FIELDS(DECL_ACCESSOR)
#undef DECL_ACCSESOR
int GetBytecodeArrayRegisterCount() const; int GetBytecodeArrayRegisterCount() const;
}; };
......
...@@ -1419,10 +1419,10 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) { ...@@ -1419,10 +1419,10 @@ Type Typer::Visitor::JSCallTyper(Type fun, Typer* t) {
return Type::NonInternal(); return Type::NonInternal();
} }
JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction(); JSFunctionRef function = fun.AsHeapConstant()->Ref().AsJSFunction();
if (!function.HasBuiltinFunctionId()) { if (!function.shared().HasBuiltinFunctionId()) {
return Type::NonInternal(); return Type::NonInternal();
} }
switch (function.GetBuiltinFunctionId()) { switch (function.shared().builtin_function_id()) {
case BuiltinFunctionId::kMathRandom: case BuiltinFunctionId::kMathRandom:
return Type::PlainNumber(); return Type::PlainNumber();
case BuiltinFunctionId::kMathFloor: case BuiltinFunctionId::kMathFloor:
......
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