Commit c019d7f4 authored by danno's avatar danno Committed by Commit bot

Use big-boy Types to annotate interface descriptor parameters

- Thread Type::FunctionType through stubs and the TF pipeline.
- Augment Typer to decorate parameter nodes with types from
  a Type::FunctionType associated with interface descriptors.
- Factor interface descriptors into platform-specific and
  platform-independent components so that all descriptors share
  a common Type::FunctionType for all platforms.

Review URL: https://codereview.chromium.org/1197703002

Cr-Commit-Position: refs/heads/master@{#29248}
parent b7f4981c
This diff is collapsed.
This diff is collapsed.
......@@ -136,7 +136,8 @@ bool CodeStubGraphBuilderBase::BuildGraph() {
bool runtime_stack_params = descriptor_.stack_parameter_count().is_valid();
HInstruction* stack_parameter_count = NULL;
for (int i = 0; i < param_count; ++i) {
Representation r = descriptor_.GetEnvironmentParameterRepresentation(i);
Representation r =
RepresentationFromType(descriptor_.GetEnvironmentParameterType(i));
HParameter* param = Add<HParameter>(i,
HParameter::REGISTER_PARAMETER, r);
start_environment->Bind(i, param);
......
......@@ -502,6 +502,7 @@ Handle<Code> TurboFanCodeStub::GenerateCode() {
// Build a "hybrid" CompilationInfo for a JSFunction/CodeStub pair.
ParseInfo parse_info(&zone, inner);
CompilationInfo info(&parse_info);
info.SetFunctionType(GetCallInterfaceDescriptor().GetFunctionType());
info.SetStub(this);
return info.GenerateCodeStub();
}
......@@ -1046,5 +1047,21 @@ InternalArrayConstructorStub::InternalArrayConstructorStub(
}
Representation RepresentationFromType(Type* type) {
if (type->Is(Type::UntaggedSigned()) || type->Is(Type::UntaggedUnsigned())) {
return Representation::Integer32();
}
if (type->Is(Type::TaggedSigned())) {
return Representation::Smi();
}
if (type->Is(Type::UntaggedPointer())) {
return Representation::External();
}
DCHECK(!type->Is(Type::Untagged()));
return Representation::Tagged();
}
} // namespace internal
} // namespace v8
......@@ -431,8 +431,8 @@ class CodeStubDescriptor {
return call_descriptor().GetEnvironmentParameterCount();
}
Representation GetEnvironmentParameterRepresentation(int index) const {
return call_descriptor().GetEnvironmentParameterRepresentation(index);
Type* GetEnvironmentParameterType(int index) const {
return call_descriptor().GetEnvironmentParameterType(index);
}
ExternalReference miss_handler() const {
......@@ -2963,6 +2963,8 @@ class StringCompareStub : public PlatformCodeStub {
#undef DEFINE_HYDROGEN_CODE_STUB
#undef DEFINE_CODE_STUB
#undef DEFINE_CODE_STUB_BASE
extern Representation RepresentationFromType(Type* type);
} } // namespace v8::internal
#endif // V8_CODE_STUBS_H_
......@@ -153,7 +153,8 @@ CompilationInfo::CompilationInfo(ParseInfo* parse_info, CodeStub* code_stub,
opt_count_(has_shared_info() ? shared_info()->opt_count() : 0),
parameter_count_(0),
optimization_id_(-1),
osr_expr_stack_height_(0) {}
osr_expr_stack_height_(0),
function_type_(nullptr) {}
CompilationInfo::~CompilationInfo() {
......
......@@ -9,6 +9,7 @@
#include "src/ast.h"
#include "src/bailout-reason.h"
#include "src/compilation-dependencies.h"
#include "src/signature.h"
#include "src/zone.h"
namespace v8 {
......@@ -288,6 +289,11 @@ class CompilationInfo {
optimization_id_ = isolate()->NextOptimizationId();
}
void SetFunctionType(Type::FunctionType* function_type) {
function_type_ = function_type;
}
Type::FunctionType* function_type() const { return function_type_; }
void SetStub(CodeStub* code_stub) {
SetMode(STUB);
code_stub_ = code_stub;
......@@ -479,6 +485,8 @@ class CompilationInfo {
int osr_expr_stack_height_;
Type::FunctionType* function_type_;
DISALLOW_COPY_AND_ASSIGN(CompilationInfo);
};
......
......@@ -165,7 +165,7 @@ class LinkageHelper {
// The first parameters go in registers.
Register reg = descriptor.GetEnvironmentParameterRegister(i);
Representation rep =
descriptor.GetEnvironmentParameterRepresentation(i);
RepresentationFromType(descriptor.GetEnvironmentParameterType(i));
locations.AddParam(regloc(reg));
types.AddParam(reptyp(rep));
} else {
......
......@@ -1050,7 +1050,8 @@ Handle<Code> Pipeline::GenerateCode() {
SmartPointer<Typer> typer;
if (info()->is_typing_enabled()) {
// Type the graph.
typer.Reset(new Typer(isolate(), data.graph(), info()->context()));
typer.Reset(new Typer(isolate(), data.graph(), info()->function_type(),
info()->context()));
Run<TyperPhase>(typer.get());
RunPrintAndVerify("Typed");
}
......
......@@ -176,9 +176,11 @@ class Typer::Decorator final : public GraphDecorator {
};
Typer::Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context)
Typer::Typer(Isolate* isolate, Graph* graph, Type::FunctionType* function_type,
MaybeHandle<Context> context)
: isolate_(isolate),
graph_(graph),
function_type_(function_type),
context_(context),
decorator_(NULL),
cache_(new (graph->zone()) LazyTypeCache(isolate, graph->zone())) {
......@@ -634,6 +636,12 @@ Bounds Typer::Visitor::TypeIfException(Node* node) {
Bounds Typer::Visitor::TypeParameter(Node* node) {
int param = OpParameter<int>(node);
Type::FunctionType* function_type = typer_->function_type();
if (function_type != nullptr && param >= 0 &&
param < static_cast<int>(function_type->Arity())) {
return Bounds(Type::None(), function_type->Parameter(param));
}
return Bounds::Unbounded(zone());
}
......
......@@ -18,7 +18,8 @@ class LazyTypeCache;
class Typer {
public:
Typer(Isolate* isolate, Graph* graph, MaybeHandle<Context> context);
Typer(Isolate* isolate, Graph* graph, Type::FunctionType* function_type,
MaybeHandle<Context> context);
~Typer();
void Run();
......@@ -33,9 +34,11 @@ class Typer {
MaybeHandle<Context> context() const { return context_; }
Zone* zone() const { return graph()->zone(); }
Isolate* isolate() const { return isolate_; }
Type::FunctionType* function_type() const { return function_type_; }
Isolate* const isolate_;
Graph* const graph_;
Type::FunctionType* function_type_;
MaybeHandle<Context> const context_;
Decorator* decorator_;
......
......@@ -2276,7 +2276,7 @@ class HCallWithDescriptor final : public HInstruction {
} else {
int par_index = index - 1;
DCHECK(par_index < descriptor_.GetEnvironmentLength());
return descriptor_.GetParameterRepresentation(par_index);
return RepresentationFromType(descriptor_.GetParameterType(par_index));
}
}
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -886,6 +886,7 @@ class Isolate {
return handle_scope_implementer_;
}
Zone* runtime_zone() { return &runtime_zone_; }
Zone* interface_descriptor_zone() { return &interface_descriptor_zone_; }
UnicodeCache* unicode_cache() {
return unicode_cache_;
......@@ -1271,6 +1272,7 @@ class Isolate {
HandleScopeImplementer* handle_scope_implementer_;
UnicodeCache* unicode_cache_;
Zone runtime_zone_;
Zone interface_descriptor_zone_;
InnerPointerToCodeCache* inner_pointer_to_code_cache_;
GlobalHandles* global_handles_;
EternalHandles* eternal_handles_;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -126,7 +126,7 @@ class ChangesLoweringTester : public GraphBuilderTester<ReturnType> {
void LowerChange(Node* change) {
// Run the graph reducer with changes lowering on a single node.
Typer typer(this->isolate(), this->graph(), Handle<Context>());
Typer typer(this->isolate(), this->graph(), nullptr, Handle<Context>());
typer.Run();
ChangeLowering change_lowering(&jsgraph);
SelectLowering select_lowering(this->graph(), this->common());
......
......@@ -21,7 +21,7 @@ class JSCacheTesterHelper {
: main_graph_(zone),
main_common_(zone),
main_javascript_(zone),
main_typer_(isolate, &main_graph_, MaybeHandle<Context>()),
main_typer_(isolate, &main_graph_, nullptr, MaybeHandle<Context>()),
main_machine_(zone) {}
Graph main_graph_;
CommonOperatorBuilder main_common_;
......
......@@ -38,7 +38,7 @@ class JSTypedLoweringTester : public HandleAndZoneScope {
simplified(main_zone()),
common(main_zone()),
graph(main_zone()),
typer(main_isolate(), &graph, MaybeHandle<Context>()),
typer(main_isolate(), &graph, nullptr, MaybeHandle<Context>()),
context_node(NULL) {
graph.SetStart(graph.NewNode(common.Start(num_parameters)));
graph.SetEnd(graph.NewNode(common.End(1)));
......
......@@ -60,7 +60,7 @@ class ReducerTester : public HandleAndZoneScope {
common(main_zone()),
graph(main_zone()),
javascript(main_zone()),
typer(isolate, &graph, MaybeHandle<Context>()),
typer(isolate, &graph, nullptr, MaybeHandle<Context>()),
jsgraph(isolate, &graph, &common, &javascript, &machine),
maxuint32(Constant<int32_t>(kMaxUInt32)) {
Node* s = graph.NewNode(common.Start(num_parameters));
......
......@@ -35,7 +35,7 @@ class SimplifiedLoweringTester : public GraphBuilderTester<ReturnType> {
SimplifiedLoweringTester(MachineType p0 = kMachNone,
MachineType p1 = kMachNone)
: GraphBuilderTester<ReturnType>(p0, p1),
typer(this->isolate(), this->graph(), MaybeHandle<Context>()),
typer(this->isolate(), this->graph(), nullptr, MaybeHandle<Context>()),
javascript(this->zone()),
jsgraph(this->isolate(), this->graph(), this->common(), &javascript,
this->machine()),
......@@ -710,7 +710,7 @@ class TestingGraph : public HandleAndZoneScope, public GraphAndBuilders {
explicit TestingGraph(Type* p0_type, Type* p1_type = Type::None(),
Type* p2_type = Type::None())
: GraphAndBuilders(main_zone()),
typer(main_isolate(), graph(), MaybeHandle<Context>()),
typer(main_isolate(), graph(), nullptr, MaybeHandle<Context>()),
javascript(main_zone()),
jsgraph(main_isolate(), graph(), common(), &javascript, machine()) {
start = graph()->NewNode(common()->Start(2));
......
......@@ -111,7 +111,7 @@ Matcher<Node*> GraphTest::IsUndefinedConstant() {
TypedGraphTest::TypedGraphTest(int num_parameters)
: GraphTest(num_parameters),
typer_(isolate(), graph(), MaybeHandle<Context>()) {}
typer_(isolate(), graph(), nullptr, MaybeHandle<Context>()) {}
TypedGraphTest::~TypedGraphTest() {}
......
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