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