Commit 299d2b49 authored by Georg Neis's avatar Georg Neis Committed by Commit Bot

[turbofan] Brokerize typed optimization.

Bug: v8:7790
Change-Id: Ia9526c507769f8a7f973a9ed7aedd7cc56d169d0
Reviewed-on: https://chromium-review.googlesource.com/1128756
Commit-Queue: Georg Neis <neis@chromium.org>
Reviewed-by: 's avatarMaya Lekova <mslekova@chromium.org>
Reviewed-by: 's avatarJaroslav Sevcik <jarin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54322}
parent 084d472f
...@@ -17,6 +17,7 @@ HeapObjectRef::HeapObjectRef(Handle<Object> object) : ObjectRef(object) { ...@@ -17,6 +17,7 @@ HeapObjectRef::HeapObjectRef(Handle<Object> object) : ObjectRef(object) {
} }
MapRef HeapObjectRef::map(const JSHeapBroker* broker) const { MapRef HeapObjectRef::map(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<HeapObject>()->map(), broker->isolate())); return MapRef(handle(object<HeapObject>()->map(), broker->isolate()));
} }
...@@ -68,6 +69,11 @@ bool ObjectRef::equals(const ObjectRef& other) const { ...@@ -68,6 +69,11 @@ bool ObjectRef::equals(const ObjectRef& other) const {
return object<Object>().equals(other.object<Object>()); return object<Object>().equals(other.object<Object>());
} }
StringRef ObjectRef::TypeOf(const JSHeapBroker* broker) const {
AllowHandleDereference handle_dereference;
return StringRef(Object::TypeOf(broker->isolate(), object<Object>()));
}
base::Optional<ContextRef> ContextRef::previous( base::Optional<ContextRef> ContextRef::previous(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation; AllowHandleAllocation handle_allocation;
...@@ -179,6 +185,12 @@ MapRef JSFunctionRef::DependOnInitialMap( ...@@ -179,6 +185,12 @@ MapRef JSFunctionRef::DependOnInitialMap(
return MapRef(initial_map); return MapRef(initial_map);
} }
void MapRef::DependOnStableMap(const JSHeapBroker* broker,
CompilationDependencies* dependencies) const {
AllowHandleDereference allow_handle_dereference;
dependencies->DependOnStableMap(object<Map>());
}
int JSFunctionRef::GetInstanceSizeWithFinishedSlackTracking() const { int JSFunctionRef::GetInstanceSizeWithFinishedSlackTracking() const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
object<JSFunction>()->CompleteInobjectSlackTrackingIfActive(); object<JSFunction>()->CompleteInobjectSlackTrackingIfActive();
...@@ -226,6 +238,7 @@ ScriptContextTableRef::lookup(const NameRef& name) const { ...@@ -226,6 +238,7 @@ ScriptContextTableRef::lookup(const NameRef& name) const {
ScriptContextTableRef NativeContextRef::script_context_table( ScriptContextTableRef NativeContextRef::script_context_table(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
return ScriptContextTableRef( return ScriptContextTableRef(
handle(object<Context>()->script_context_table(), broker->isolate())); handle(object<Context>()->script_context_table(), broker->isolate()));
...@@ -263,12 +276,14 @@ double JSObjectRef::RawFastDoublePropertyAt(FieldIndex index) const { ...@@ -263,12 +276,14 @@ double JSObjectRef::RawFastDoublePropertyAt(FieldIndex index) const {
ObjectRef JSObjectRef::RawFastPropertyAt(const JSHeapBroker* broker, ObjectRef JSObjectRef::RawFastPropertyAt(const JSHeapBroker* broker,
FieldIndex index) const { FieldIndex index) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
return ObjectRef( return ObjectRef(
handle(object<JSObject>()->RawFastPropertyAt(index), broker->isolate())); handle(object<JSObject>()->RawFastPropertyAt(index), broker->isolate()));
} }
FixedArrayBaseRef JSObjectRef::elements(const JSHeapBroker* broker) const { FixedArrayBaseRef JSObjectRef::elements(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference handle_dereference; AllowHandleDereference handle_dereference;
return FixedArrayBaseRef( return FixedArrayBaseRef(
handle(object<JSObject>()->elements(), broker->isolate())); handle(object<JSObject>()->elements(), broker->isolate()));
...@@ -435,6 +450,7 @@ PropertyDetails MapRef::GetPropertyDetails(int i) const { ...@@ -435,6 +450,7 @@ PropertyDetails MapRef::GetPropertyDetails(int i) const {
} }
NameRef MapRef::GetPropertyKey(const JSHeapBroker* broker, int i) const { NameRef MapRef::GetPropertyKey(const JSHeapBroker* broker, int i) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return NameRef(handle(object<Map>()->instance_descriptors()->GetKey(i), return NameRef(handle(object<Map>()->instance_descriptors()->GetKey(i),
broker->isolate())); broker->isolate()));
...@@ -461,39 +477,65 @@ bool MapRef::has_prototype_slot() const { ...@@ -461,39 +477,65 @@ bool MapRef::has_prototype_slot() const {
return object<Map>()->has_prototype_slot(); return object<Map>()->has_prototype_slot();
} }
bool MapRef::is_stable() const {
AllowHandleDereference allow_handle_dereference;
return object<Map>()->is_stable();
}
bool MapRef::CanTransition() const {
AllowHandleDereference allow_handle_dereference;
return object<Map>()->CanTransition();
}
ElementsKind JSArrayRef::GetElementsKind() const { ElementsKind JSArrayRef::GetElementsKind() const {
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return object<JSArray>()->GetElementsKind(); return object<JSArray>()->GetElementsKind();
} }
ObjectRef JSArrayRef::length(const JSHeapBroker* broker) const { ObjectRef JSArrayRef::length(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<JSArray>()->length(), broker->isolate())); return ObjectRef(handle(object<JSArray>()->length(), broker->isolate()));
} }
int StringRef::length() const {
AllowHandleDereference allow_handle_dereference;
return object<String>()->length();
}
uint16_t StringRef::GetFirstChar() {
AllowHandleDereference allow_handle_dereference;
return object<String>()->Get(0);
}
ObjectRef JSRegExpRef::raw_properties_or_hash( ObjectRef JSRegExpRef::raw_properties_or_hash(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef( return ObjectRef(
handle(object<JSRegExp>()->raw_properties_or_hash(), broker->isolate())); handle(object<JSRegExp>()->raw_properties_or_hash(), broker->isolate()));
} }
ObjectRef JSRegExpRef::data(const JSHeapBroker* broker) const { ObjectRef JSRegExpRef::data(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<JSRegExp>()->data(), broker->isolate())); return ObjectRef(handle(object<JSRegExp>()->data(), broker->isolate()));
} }
ObjectRef JSRegExpRef::source(const JSHeapBroker* broker) const { ObjectRef JSRegExpRef::source(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<JSRegExp>()->source(), broker->isolate())); return ObjectRef(handle(object<JSRegExp>()->source(), broker->isolate()));
} }
ObjectRef JSRegExpRef::flags(const JSHeapBroker* broker) const { ObjectRef JSRegExpRef::flags(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<JSRegExp>()->flags(), broker->isolate())); return ObjectRef(handle(object<JSRegExp>()->flags(), broker->isolate()));
} }
ObjectRef JSRegExpRef::last_index(const JSHeapBroker* broker) const { ObjectRef JSRegExpRef::last_index(const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<JSRegExp>()->last_index(), broker->isolate())); return ObjectRef(handle(object<JSRegExp>()->last_index(), broker->isolate()));
} }
...@@ -509,6 +551,7 @@ bool FixedArrayRef::is_the_hole(const JSHeapBroker* broker, int i) const { ...@@ -509,6 +551,7 @@ bool FixedArrayRef::is_the_hole(const JSHeapBroker* broker, int i) const {
} }
ObjectRef FixedArrayRef::get(const JSHeapBroker* broker, int i) const { ObjectRef FixedArrayRef::get(const JSHeapBroker* broker, int i) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return ObjectRef(handle(object<FixedArray>()->get(i), broker->isolate())); return ObjectRef(handle(object<FixedArray>()->get(i), broker->isolate()));
} }
...@@ -545,6 +588,7 @@ bool SharedFunctionInfoRef::has_duplicate_parameters() const { ...@@ -545,6 +588,7 @@ bool SharedFunctionInfoRef::has_duplicate_parameters() const {
MapRef NativeContextRef::fast_aliased_arguments_map( MapRef NativeContextRef::fast_aliased_arguments_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->fast_aliased_arguments_map(), return MapRef(handle(object<Context>()->fast_aliased_arguments_map(),
broker->isolate())); broker->isolate()));
...@@ -552,6 +596,7 @@ MapRef NativeContextRef::fast_aliased_arguments_map( ...@@ -552,6 +596,7 @@ MapRef NativeContextRef::fast_aliased_arguments_map(
MapRef NativeContextRef::sloppy_arguments_map( MapRef NativeContextRef::sloppy_arguments_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef( return MapRef(
handle(object<Context>()->sloppy_arguments_map(), broker->isolate())); handle(object<Context>()->sloppy_arguments_map(), broker->isolate()));
...@@ -559,6 +604,7 @@ MapRef NativeContextRef::sloppy_arguments_map( ...@@ -559,6 +604,7 @@ MapRef NativeContextRef::sloppy_arguments_map(
MapRef NativeContextRef::strict_arguments_map( MapRef NativeContextRef::strict_arguments_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef( return MapRef(
handle(object<Context>()->strict_arguments_map(), broker->isolate())); handle(object<Context>()->strict_arguments_map(), broker->isolate()));
...@@ -566,6 +612,7 @@ MapRef NativeContextRef::strict_arguments_map( ...@@ -566,6 +612,7 @@ MapRef NativeContextRef::strict_arguments_map(
MapRef NativeContextRef::js_array_fast_elements_map_index( MapRef NativeContextRef::js_array_fast_elements_map_index(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->js_array_fast_elements_map_index(), return MapRef(handle(object<Context>()->js_array_fast_elements_map_index(),
broker->isolate())); broker->isolate()));
...@@ -573,6 +620,7 @@ MapRef NativeContextRef::js_array_fast_elements_map_index( ...@@ -573,6 +620,7 @@ MapRef NativeContextRef::js_array_fast_elements_map_index(
MapRef NativeContextRef::initial_array_iterator_map( MapRef NativeContextRef::initial_array_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->initial_array_iterator_map(), return MapRef(handle(object<Context>()->initial_array_iterator_map(),
broker->isolate())); broker->isolate()));
...@@ -580,6 +628,7 @@ MapRef NativeContextRef::initial_array_iterator_map( ...@@ -580,6 +628,7 @@ MapRef NativeContextRef::initial_array_iterator_map(
MapRef NativeContextRef::set_value_iterator_map( MapRef NativeContextRef::set_value_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef( return MapRef(
handle(object<Context>()->set_value_iterator_map(), broker->isolate())); handle(object<Context>()->set_value_iterator_map(), broker->isolate()));
...@@ -587,6 +636,7 @@ MapRef NativeContextRef::set_value_iterator_map( ...@@ -587,6 +636,7 @@ MapRef NativeContextRef::set_value_iterator_map(
MapRef NativeContextRef::set_key_value_iterator_map( MapRef NativeContextRef::set_key_value_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->set_key_value_iterator_map(), return MapRef(handle(object<Context>()->set_key_value_iterator_map(),
broker->isolate())); broker->isolate()));
...@@ -594,6 +644,7 @@ MapRef NativeContextRef::set_key_value_iterator_map( ...@@ -594,6 +644,7 @@ MapRef NativeContextRef::set_key_value_iterator_map(
MapRef NativeContextRef::map_key_iterator_map( MapRef NativeContextRef::map_key_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef( return MapRef(
handle(object<Context>()->map_key_iterator_map(), broker->isolate())); handle(object<Context>()->map_key_iterator_map(), broker->isolate()));
...@@ -601,6 +652,7 @@ MapRef NativeContextRef::map_key_iterator_map( ...@@ -601,6 +652,7 @@ MapRef NativeContextRef::map_key_iterator_map(
MapRef NativeContextRef::map_value_iterator_map( MapRef NativeContextRef::map_value_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef( return MapRef(
handle(object<Context>()->map_value_iterator_map(), broker->isolate())); handle(object<Context>()->map_value_iterator_map(), broker->isolate()));
...@@ -608,6 +660,7 @@ MapRef NativeContextRef::map_value_iterator_map( ...@@ -608,6 +660,7 @@ MapRef NativeContextRef::map_value_iterator_map(
MapRef NativeContextRef::map_key_value_iterator_map( MapRef NativeContextRef::map_key_value_iterator_map(
const JSHeapBroker* broker) const { const JSHeapBroker* broker) const {
AllowHandleAllocation handle_allocation;
AllowHandleDereference allow_handle_dereference; AllowHandleDereference allow_handle_dereference;
return MapRef(handle(object<Context>()->map_key_value_iterator_map(), return MapRef(handle(object<Context>()->map_key_value_iterator_map(),
broker->isolate())); broker->isolate()));
......
...@@ -73,12 +73,12 @@ class HeapObjectType { ...@@ -73,12 +73,12 @@ class HeapObjectType {
V(ScopeInfo) \ V(ScopeInfo) \
V(ScriptContextTable) \ V(ScriptContextTable) \
V(SharedFunctionInfo) \ V(SharedFunctionInfo) \
V(Map) V(Map) \
V(String)
#define HEAP_BROKER_KIND_LIST(V) \ #define HEAP_BROKER_KIND_LIST(V) \
HEAP_BROKER_DATA_LIST(V) \ HEAP_BROKER_DATA_LIST(V) \
V(InternalizedString) \ V(InternalizedString)
V(String)
#define FORWARD_DECL(Name) class Name##Ref; #define FORWARD_DECL(Name) class Name##Ref;
HEAP_BROKER_DATA_LIST(FORWARD_DECL) HEAP_BROKER_DATA_LIST(FORWARD_DECL)
...@@ -99,6 +99,8 @@ class ObjectRef { ...@@ -99,6 +99,8 @@ class ObjectRef {
OddballType oddball_type(const JSHeapBroker* broker) const; OddballType oddball_type(const JSHeapBroker* broker) const;
StringRef TypeOf(const JSHeapBroker* broker) const;
bool IsSmi() const; bool IsSmi() const;
int AsSmi() const; int AsSmi() const;
...@@ -282,9 +284,14 @@ class MapRef : public HeapObjectRef { ...@@ -282,9 +284,14 @@ class MapRef : public HeapObjectRef {
bool IsJSArrayMap() const; bool IsJSArrayMap() const;
bool IsFixedCowArrayMap(const JSHeapBroker* broker) const; bool IsFixedCowArrayMap(const JSHeapBroker* broker) const;
bool is_stable() const;
bool has_prototype_slot() const; bool has_prototype_slot() const;
bool CanTransition() const;
bool IsInobjectSlackTrackingInProgress() const; bool IsInobjectSlackTrackingInProgress() const;
void DependOnStableMap(const JSHeapBroker* broker,
CompilationDependencies* dependencies) const;
}; };
class FixedArrayBaseRef : public HeapObjectRef { class FixedArrayBaseRef : public HeapObjectRef {
...@@ -338,6 +345,14 @@ class SharedFunctionInfoRef : public HeapObjectRef { ...@@ -338,6 +345,14 @@ class SharedFunctionInfoRef : public HeapObjectRef {
int function_map_index() const; int function_map_index() const;
}; };
class StringRef : public NameRef {
public:
explicit StringRef(Handle<Object> object) : NameRef(object) {}
int length() const;
uint16_t GetFirstChar();
};
} // namespace compiler } // namespace compiler
} // namespace internal } // namespace internal
} // namespace v8 } // namespace v8
......
This diff is collapsed.
...@@ -58,20 +58,24 @@ class V8_EXPORT_PRIVATE TypedOptimization final ...@@ -58,20 +58,24 @@ class V8_EXPORT_PRIVATE TypedOptimization final
Reduction ReduceToBoolean(Node* node); Reduction ReduceToBoolean(Node* node);
Reduction TryReduceStringComparisonOfStringFromSingleCharCode( Reduction TryReduceStringComparisonOfStringFromSingleCharCode(
Node* comparison, Node* from_char_code, Node* constant, bool inverted); Node* comparison, Node* from_char_code, Type constant_type,
bool inverted);
Reduction TryReduceStringComparisonOfStringFromSingleCharCodeToConstant( Reduction TryReduceStringComparisonOfStringFromSingleCharCodeToConstant(
Node* comparison, Handle<String> string, bool inverted); Node* comparison, const StringRef& string, bool inverted);
const Operator* NumberComparisonFor(const Operator* op); const Operator* NumberComparisonFor(const Operator* op);
CompilationDependencies* dependencies() const { return dependencies_; } SimplifiedOperatorBuilder* simplified() const;
Factory* factory() const; Factory* factory() const;
Graph* graph() const; Graph* graph() const;
Isolate* isolate() const; Isolate* isolate() const;
CompilationDependencies* dependencies() const { return dependencies_; }
JSGraph* jsgraph() const { return jsgraph_; } JSGraph* jsgraph() const { return jsgraph_; }
SimplifiedOperatorBuilder* simplified() const; const JSHeapBroker* js_heap_broker() const { return js_heap_broker_; }
CompilationDependencies* const dependencies_; CompilationDependencies* const dependencies_;
JSGraph* const jsgraph_; JSGraph* const jsgraph_;
const JSHeapBroker* js_heap_broker_;
Type const true_type_; Type const true_type_;
Type const false_type_; Type const false_type_;
TypeCache const& type_cache_; TypeCache const& type_cache_;
......
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