Commit 8ac80c53 authored by verwaest@chromium.org's avatar verwaest@chromium.org

Use Type* in crankshaft rather than HeapType.

R=rossberg@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19069 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c270bad7
......@@ -91,12 +91,15 @@ static V8_INLINE bool CheckForName(Handle<String> name,
}
bool Accessors::IsJSObjectFieldAccessor(Handle<HeapType> type,
// Returns true for properties that are accessors to object fields.
// If true, *object_offset contains offset of object field.
template <class T>
bool Accessors::IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name,
int* object_offset) {
Isolate* isolate = name->GetIsolate();
if (type->Is(HeapType::String())) {
if (type->Is(T::String())) {
return CheckForName(name, isolate->heap()->length_string(),
String::kLengthOffset, object_offset);
}
......@@ -137,6 +140,18 @@ bool Accessors::IsJSObjectFieldAccessor(Handle<HeapType> type,
}
template
bool Accessors::IsJSObjectFieldAccessor<Type>(Type* type,
Handle<String> name,
int* object_offset);
template
bool Accessors::IsJSObjectFieldAccessor<HeapType>(Handle<HeapType> type,
Handle<String> name,
int* object_offset);
//
// Accessors::ArrayLength
//
......
......@@ -88,8 +88,10 @@ class Accessors : public AllStatic {
// Returns true for properties that are accessors to object fields.
// If true, *object_offset contains offset of object field.
static bool IsJSObjectFieldAccessor(
Handle<HeapType> map, Handle<String> name, int* object_offset);
template <class T>
static bool IsJSObjectFieldAccessor(typename T::TypeHandle type,
Handle<String> name,
int* object_offset);
private:
......
This diff is collapsed.
......@@ -2184,6 +2184,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
AST_NODE_LIST(DECLARE_VISIT)
#undef DECLARE_VISIT
Type* ToType(Handle<Map> map) { return IC::MapToType<Type>(map, zone()); }
private:
// Helpers for flow graph construction.
enum GlobalPropertyAccess {
......@@ -2265,7 +2267,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
class PropertyAccessInfo {
public:
PropertyAccessInfo(HOptimizedGraphBuilder* builder,
Handle<HeapType> type,
Type* type,
Handle<String> name)
: lookup_(builder->isolate()),
builder_(builder),
......@@ -2287,15 +2289,15 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
bool CanLoadAsMonomorphic(SmallMapList* types);
Handle<Map> map() {
if (type_->Is(HeapType::Number())) {
if (type_->Is(Type::Number())) {
Context* context = current_info()->closure()->context();
context = context->native_context();
return handle(context->number_function()->initial_map());
} else if (type_->Is(HeapType::Boolean())) {
} else if (type_->Is(Type::Boolean())) {
Context* context = current_info()->closure()->context();
context = context->native_context();
return handle(context->boolean_function()->initial_map());
} else if (type_->Is(HeapType::String())) {
} else if (type_->Is(Type::String())) {
Context* context = current_info()->closure()->context();
context = context->native_context();
return handle(context->string_function()->initial_map());
......@@ -2303,12 +2305,12 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
return type_->AsClass();
}
}
Handle<HeapType> type() const { return type_; }
Type* type() const { return type_; }
Handle<String> name() const { return name_; }
bool IsJSObjectFieldAccessor() {
int offset; // unused
return Accessors::IsJSObjectFieldAccessor(type_, name_, &offset);
return Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset);
}
bool GetJSObjectFieldAccess(HObjectAccess* access) {
......@@ -2317,8 +2319,8 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
return true;
}
int offset;
if (Accessors::IsJSObjectFieldAccessor(type_, name_, &offset)) {
if (type_->Is(HeapType::String())) {
if (Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset)) {
if (type_->Is(Type::String())) {
ASSERT(name_->Equals(isolate()->heap()->length_string()));
*access = HObjectAccess::ForStringLength();
} else {
......@@ -2338,6 +2340,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
HObjectAccess access() { return access_; }
private:
Type* ToType(Handle<Map> map) { return builder_->ToType(map); }
Isolate* isolate() { return lookup_.isolate(); }
CompilationInfo* current_info() { return builder_->current_info(); }
......@@ -2358,7 +2361,7 @@ class HOptimizedGraphBuilder : public HGraphBuilder, public AstVisitor {
LookupResult lookup_;
HOptimizedGraphBuilder* builder_;
Handle<HeapType> type_;
Type* type_;
Handle<String> name_;
Handle<JSObject> holder_;
Handle<JSFunction> accessor_;
......
......@@ -670,19 +670,28 @@ Handle<Map> IC::TypeToMap(HeapType* type, Isolate* isolate) {
}
Handle<HeapType> IC::MapToType(Handle<Map> map) {
Isolate* isolate = map->GetIsolate();
template <class T>
typename T::TypeHandle IC::MapToType(Handle<Map> map,
typename T::Region* region) {
if (map->instance_type() == HEAP_NUMBER_TYPE) {
return HeapType::Number(isolate);
return T::Number(region);
} else if (map->instance_type() == ODDBALL_TYPE) {
// The only oddballs that can be recorded in ICs are booleans.
return HeapType::Boolean(isolate);
return T::Boolean(region);
} else {
return HeapType::Class(map, isolate);
return T::Class(map, region);
}
}
template
Type* IC::MapToType<Type>(Handle<Map> map, Zone* zone);
template
Handle<HeapType> IC::MapToType<HeapType>(Handle<Map> map, Isolate* region);
void IC::UpdateMonomorphicIC(Handle<HeapType> type,
Handle<Code> handler,
Handle<String> name) {
......@@ -908,9 +917,11 @@ Handle<Code> LoadIC::CompileHandler(LookupResult* lookup,
// Use simple field loads for some well-known callback properties.
if (object->IsJSObject()) {
Handle<JSObject> receiver = Handle<JSObject>::cast(object);
Handle<HeapType> type = IC::MapToType(handle(receiver->map()));
Handle<HeapType> type = IC::MapToType<HeapType>(
handle(receiver->map()), isolate());
int object_offset;
if (Accessors::IsJSObjectFieldAccessor(type, name, &object_offset)) {
if (Accessors::IsJSObjectFieldAccessor<HeapType>(
type, name, &object_offset)) {
return SimpleFieldLoad(object_offset / kPointerSize);
}
}
......@@ -1436,7 +1447,8 @@ Handle<Code> KeyedStoreIC::StoreElementStub(Handle<JSObject> receiver,
transitioned_receiver_map =
ComputeTransitionedMap(receiver, store_mode);
}
if (IsTransitionOfMonomorphicTarget(MapToType(transitioned_receiver_map))) {
if (IsTransitionOfMonomorphicTarget(
MapToType<HeapType>(transitioned_receiver_map, isolate()))) {
// Element family is the same, use the "worst" case map.
store_mode = GetNonTransitioningStoreMode(store_mode);
return isolate()->stub_cache()->ComputeKeyedStoreElement(
......
......@@ -139,9 +139,12 @@ class IC {
// well as smis.
// - The oddball map is only used for booleans.
static Handle<Map> TypeToMap(HeapType* type, Isolate* isolate);
static Handle<HeapType> MapToType(Handle<Map> map);
static Handle<HeapType> CurrentTypeOf(
Handle<Object> object, Isolate* isolate);
template <class T>
static typename T::TypeHandle MapToType(Handle<Map> map,
typename T::Region* region);
static Handle<HeapType> CurrentTypeOf(Handle<Object> object,
Isolate* isolate);
protected:
// Get the call-site target; used for determining the state.
......
......@@ -10514,7 +10514,7 @@ void Code::FindAllTypes(TypeHandleList* types) {
Object* object = info->target_object();
if (object->IsMap()) {
Handle<Map> map(Map::cast(object));
types->Add(IC::MapToType(map));
types->Add(IC::MapToType<HeapType>(map, map->GetIsolate()));
}
}
}
......
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