Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(18)

Side by Side Diff: src/hydrogen.h

Issue 152863002: Use Type* in crankshaft rather than HeapType. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/accessors.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2166 matching lines...) Expand 10 before | Expand all | Expand 10 after
2177 template <class Instruction> HInstruction* PreProcessCall(Instruction* call); 2177 template <class Instruction> HInstruction* PreProcessCall(Instruction* call);
2178 void PushArgumentsFromEnvironment(int count); 2178 void PushArgumentsFromEnvironment(int count);
2179 2179
2180 void SetUpScope(Scope* scope); 2180 void SetUpScope(Scope* scope);
2181 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE; 2181 virtual void VisitStatements(ZoneList<Statement*>* statements) V8_OVERRIDE;
2182 2182
2183 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE; 2183 #define DECLARE_VISIT(type) virtual void Visit##type(type* node) V8_OVERRIDE;
2184 AST_NODE_LIST(DECLARE_VISIT) 2184 AST_NODE_LIST(DECLARE_VISIT)
2185 #undef DECLARE_VISIT 2185 #undef DECLARE_VISIT
2186 2186
2187 Type* ToType(Handle<Map> map) { return IC::MapToType<Type>(map, zone()); }
2188
2187 private: 2189 private:
2188 // Helpers for flow graph construction. 2190 // Helpers for flow graph construction.
2189 enum GlobalPropertyAccess { 2191 enum GlobalPropertyAccess {
2190 kUseCell, 2192 kUseCell,
2191 kUseGeneric 2193 kUseGeneric
2192 }; 2194 };
2193 GlobalPropertyAccess LookupGlobalProperty(Variable* var, 2195 GlobalPropertyAccess LookupGlobalProperty(Variable* var,
2194 LookupResult* lookup, 2196 LookupResult* lookup,
2195 bool is_store); 2197 bool is_store);
2196 2198
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
2258 void VisitTypedArrayInitialize(CallRuntime* expr); 2260 void VisitTypedArrayInitialize(CallRuntime* expr);
2259 2261
2260 bool IsCallNewArrayInlineable(CallNew* expr); 2262 bool IsCallNewArrayInlineable(CallNew* expr);
2261 void BuildInlinedCallNewArray(CallNew* expr); 2263 void BuildInlinedCallNewArray(CallNew* expr);
2262 2264
2263 void VisitDataViewInitialize(CallRuntime* expr); 2265 void VisitDataViewInitialize(CallRuntime* expr);
2264 2266
2265 class PropertyAccessInfo { 2267 class PropertyAccessInfo {
2266 public: 2268 public:
2267 PropertyAccessInfo(HOptimizedGraphBuilder* builder, 2269 PropertyAccessInfo(HOptimizedGraphBuilder* builder,
2268 Handle<HeapType> type, 2270 Type* type,
2269 Handle<String> name) 2271 Handle<String> name)
2270 : lookup_(builder->isolate()), 2272 : lookup_(builder->isolate()),
2271 builder_(builder), 2273 builder_(builder),
2272 type_(type), 2274 type_(type),
2273 name_(name), 2275 name_(name),
2274 access_(HObjectAccess::ForMap()) { } 2276 access_(HObjectAccess::ForMap()) { }
2275 2277
2276 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic 2278 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic
2277 // load named. It additionally fills in the fields necessary to generate the 2279 // load named. It additionally fills in the fields necessary to generate the
2278 // lookup code. 2280 // lookup code.
2279 bool CanLoadMonomorphic(); 2281 bool CanLoadMonomorphic();
2280 2282
2281 // Checks whether all types behave uniform when loading name. If all maps 2283 // Checks whether all types behave uniform when loading name. If all maps
2282 // behave the same, a single monomorphic load instruction can be emitted, 2284 // behave the same, a single monomorphic load instruction can be emitted,
2283 // guarded by a single map-checks instruction that whether the receiver is 2285 // guarded by a single map-checks instruction that whether the receiver is
2284 // an instance of any of the types. 2286 // an instance of any of the types.
2285 // This method skips the first type in types, assuming that this 2287 // This method skips the first type in types, assuming that this
2286 // PropertyAccessInfo is built for types->first(). 2288 // PropertyAccessInfo is built for types->first().
2287 bool CanLoadAsMonomorphic(SmallMapList* types); 2289 bool CanLoadAsMonomorphic(SmallMapList* types);
2288 2290
2289 Handle<Map> map() { 2291 Handle<Map> map() {
2290 if (type_->Is(HeapType::Number())) { 2292 if (type_->Is(Type::Number())) {
2291 Context* context = current_info()->closure()->context(); 2293 Context* context = current_info()->closure()->context();
2292 context = context->native_context(); 2294 context = context->native_context();
2293 return handle(context->number_function()->initial_map()); 2295 return handle(context->number_function()->initial_map());
2294 } else if (type_->Is(HeapType::Boolean())) { 2296 } else if (type_->Is(Type::Boolean())) {
2295 Context* context = current_info()->closure()->context(); 2297 Context* context = current_info()->closure()->context();
2296 context = context->native_context(); 2298 context = context->native_context();
2297 return handle(context->boolean_function()->initial_map()); 2299 return handle(context->boolean_function()->initial_map());
2298 } else if (type_->Is(HeapType::String())) { 2300 } else if (type_->Is(Type::String())) {
2299 Context* context = current_info()->closure()->context(); 2301 Context* context = current_info()->closure()->context();
2300 context = context->native_context(); 2302 context = context->native_context();
2301 return handle(context->string_function()->initial_map()); 2303 return handle(context->string_function()->initial_map());
2302 } else { 2304 } else {
2303 return type_->AsClass(); 2305 return type_->AsClass();
2304 } 2306 }
2305 } 2307 }
2306 Handle<HeapType> type() const { return type_; } 2308 Type* type() const { return type_; }
2307 Handle<String> name() const { return name_; } 2309 Handle<String> name() const { return name_; }
2308 2310
2309 bool IsJSObjectFieldAccessor() { 2311 bool IsJSObjectFieldAccessor() {
2310 int offset; // unused 2312 int offset; // unused
2311 return Accessors::IsJSObjectFieldAccessor(type_, name_, &offset); 2313 return Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset);
2312 } 2314 }
2313 2315
2314 bool GetJSObjectFieldAccess(HObjectAccess* access) { 2316 bool GetJSObjectFieldAccess(HObjectAccess* access) {
2315 if (IsArrayLength()) { 2317 if (IsArrayLength()) {
2316 *access = HObjectAccess::ForArrayLength(map()->elements_kind()); 2318 *access = HObjectAccess::ForArrayLength(map()->elements_kind());
2317 return true; 2319 return true;
2318 } 2320 }
2319 int offset; 2321 int offset;
2320 if (Accessors::IsJSObjectFieldAccessor(type_, name_, &offset)) { 2322 if (Accessors::IsJSObjectFieldAccessor<Type>(type_, name_, &offset)) {
2321 if (type_->Is(HeapType::String())) { 2323 if (type_->Is(Type::String())) {
2322 ASSERT(name_->Equals(isolate()->heap()->length_string())); 2324 ASSERT(name_->Equals(isolate()->heap()->length_string()));
2323 *access = HObjectAccess::ForStringLength(); 2325 *access = HObjectAccess::ForStringLength();
2324 } else { 2326 } else {
2325 *access = HObjectAccess::ForJSObjectOffset(offset); 2327 *access = HObjectAccess::ForJSObjectOffset(offset);
2326 } 2328 }
2327 return true; 2329 return true;
2328 } 2330 }
2329 return false; 2331 return false;
2330 } 2332 }
2331 2333
2332 bool has_holder() { return !holder_.is_null(); } 2334 bool has_holder() { return !holder_.is_null(); }
2333 2335
2334 LookupResult* lookup() { return &lookup_; } 2336 LookupResult* lookup() { return &lookup_; }
2335 Handle<JSObject> holder() { return holder_; } 2337 Handle<JSObject> holder() { return holder_; }
2336 Handle<JSFunction> accessor() { return accessor_; } 2338 Handle<JSFunction> accessor() { return accessor_; }
2337 Handle<Object> constant() { return constant_; } 2339 Handle<Object> constant() { return constant_; }
2338 HObjectAccess access() { return access_; } 2340 HObjectAccess access() { return access_; }
2339 2341
2340 private: 2342 private:
2343 Type* ToType(Handle<Map> map) { return builder_->ToType(map); }
2341 Isolate* isolate() { return lookup_.isolate(); } 2344 Isolate* isolate() { return lookup_.isolate(); }
2342 CompilationInfo* current_info() { return builder_->current_info(); } 2345 CompilationInfo* current_info() { return builder_->current_info(); }
2343 2346
2344 bool IsArrayLength() { 2347 bool IsArrayLength() {
2345 return map()->instance_type() == JS_ARRAY_TYPE && 2348 return map()->instance_type() == JS_ARRAY_TYPE &&
2346 name_->Equals(isolate()->heap()->length_string()); 2349 name_->Equals(isolate()->heap()->length_string());
2347 } 2350 }
2348 2351
2349 bool LoadResult(Handle<Map> map); 2352 bool LoadResult(Handle<Map> map);
2350 bool LookupDescriptor(); 2353 bool LookupDescriptor();
2351 bool LookupInPrototypes(); 2354 bool LookupInPrototypes();
2352 bool IsCompatibleForLoad(PropertyAccessInfo* other); 2355 bool IsCompatibleForLoad(PropertyAccessInfo* other);
2353 2356
2354 void GeneralizeRepresentation(Representation r) { 2357 void GeneralizeRepresentation(Representation r) {
2355 access_ = access_.WithRepresentation( 2358 access_ = access_.WithRepresentation(
2356 access_.representation().generalize(r)); 2359 access_.representation().generalize(r));
2357 } 2360 }
2358 2361
2359 LookupResult lookup_; 2362 LookupResult lookup_;
2360 HOptimizedGraphBuilder* builder_; 2363 HOptimizedGraphBuilder* builder_;
2361 Handle<HeapType> type_; 2364 Type* type_;
2362 Handle<String> name_; 2365 Handle<String> name_;
2363 Handle<JSObject> holder_; 2366 Handle<JSObject> holder_;
2364 Handle<JSFunction> accessor_; 2367 Handle<JSFunction> accessor_;
2365 Handle<Object> constant_; 2368 Handle<Object> constant_;
2366 HObjectAccess access_; 2369 HObjectAccess access_;
2367 }; 2370 };
2368 2371
2369 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, 2372 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info,
2370 HValue* object, 2373 HValue* object,
2371 HValue* checked_object, 2374 HValue* checked_object,
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
2716 } 2719 }
2717 2720
2718 private: 2721 private:
2719 HGraphBuilder* builder_; 2722 HGraphBuilder* builder_;
2720 }; 2723 };
2721 2724
2722 2725
2723 } } // namespace v8::internal 2726 } } // namespace v8::internal
2724 2727
2725 #endif // V8_HYDROGEN_H_ 2728 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « src/accessors.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698