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

Side by Side Diff: src/hydrogen.h

Issue 153933002: Use PropertyAccessInfo to compute stores in crankshaft. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase and fixes 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 | « no previous file | 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 2246 matching lines...) Expand 10 before | Expand all | Expand 10 after
2257 SmallMapList* types, 2257 SmallMapList* types,
2258 Handle<String> name); 2258 Handle<String> name);
2259 2259
2260 void VisitTypedArrayInitialize(CallRuntime* expr); 2260 void VisitTypedArrayInitialize(CallRuntime* expr);
2261 2261
2262 bool IsCallNewArrayInlineable(CallNew* expr); 2262 bool IsCallNewArrayInlineable(CallNew* expr);
2263 void BuildInlinedCallNewArray(CallNew* expr); 2263 void BuildInlinedCallNewArray(CallNew* expr);
2264 2264
2265 void VisitDataViewInitialize(CallRuntime* expr); 2265 void VisitDataViewInitialize(CallRuntime* expr);
2266 2266
2267 enum PropertyAccessType { LOAD, STORE };
2267 class PropertyAccessInfo { 2268 class PropertyAccessInfo {
2268 public: 2269 public:
2269 PropertyAccessInfo(HOptimizedGraphBuilder* builder, 2270 PropertyAccessInfo(HOptimizedGraphBuilder* builder,
2271 PropertyAccessType access_type,
2270 Type* type, 2272 Type* type,
2271 Handle<String> name) 2273 Handle<String> name)
2272 : lookup_(builder->isolate()), 2274 : lookup_(builder->isolate()),
2273 builder_(builder), 2275 builder_(builder),
2276 access_type_(access_type),
2274 type_(type), 2277 type_(type),
2275 name_(name), 2278 name_(name),
2276 access_(HObjectAccess::ForMap()) { } 2279 access_(HObjectAccess::ForMap()) { }
2277 2280
2278 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic 2281 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic
2279 // load named. It additionally fills in the fields necessary to generate the 2282 // load named. It additionally fills in the fields necessary to generate the
2280 // lookup code. 2283 // lookup code.
2281 bool CanLoadMonomorphic(); 2284 bool CanAccessMonomorphic();
2282 2285
2283 // Checks whether all types behave uniform when loading name. If all maps 2286 // Checks whether all types behave uniform when loading name. If all maps
2284 // behave the same, a single monomorphic load instruction can be emitted, 2287 // behave the same, a single monomorphic load instruction can be emitted,
2285 // guarded by a single map-checks instruction that whether the receiver is 2288 // guarded by a single map-checks instruction that whether the receiver is
2286 // an instance of any of the types. 2289 // an instance of any of the types.
2287 // This method skips the first type in types, assuming that this 2290 // This method skips the first type in types, assuming that this
2288 // PropertyAccessInfo is built for types->first(). 2291 // PropertyAccessInfo is built for types->first().
2289 bool CanLoadAsMonomorphic(SmallMapList* types); 2292 bool CanAccessAsMonomorphic(SmallMapList* types);
2290 2293
2291 Handle<Map> map() { 2294 Handle<Map> map() {
2292 if (type_->Is(Type::Number())) { 2295 if (type_->Is(Type::Number())) {
2293 Context* context = current_info()->closure()->context(); 2296 Context* context = current_info()->closure()->context();
2294 context = context->native_context(); 2297 context = context->native_context();
2295 return handle(context->number_function()->initial_map()); 2298 return handle(context->number_function()->initial_map());
2296 } else if (type_->Is(Type::Boolean())) { 2299 } else if (type_->Is(Type::Boolean())) {
2297 Context* context = current_info()->closure()->context(); 2300 Context* context = current_info()->closure()->context();
2298 context = context->native_context(); 2301 context = context->native_context();
2299 return handle(context->boolean_function()->initial_map()); 2302 return handle(context->boolean_function()->initial_map());
(...skipping 30 matching lines...) Expand all
2330 } 2333 }
2331 return false; 2334 return false;
2332 } 2335 }
2333 2336
2334 bool has_holder() { return !holder_.is_null(); } 2337 bool has_holder() { return !holder_.is_null(); }
2335 2338
2336 LookupResult* lookup() { return &lookup_; } 2339 LookupResult* lookup() { return &lookup_; }
2337 Handle<JSObject> holder() { return holder_; } 2340 Handle<JSObject> holder() { return holder_; }
2338 Handle<JSFunction> accessor() { return accessor_; } 2341 Handle<JSFunction> accessor() { return accessor_; }
2339 Handle<Object> constant() { return constant_; } 2342 Handle<Object> constant() { return constant_; }
2343 Handle<Object> transition() { return transition_; }
2340 HObjectAccess access() { return access_; } 2344 HObjectAccess access() { return access_; }
2341 2345
2342 private: 2346 private:
2343 Type* ToType(Handle<Map> map) { return builder_->ToType(map); } 2347 Type* ToType(Handle<Map> map) { return builder_->ToType(map); }
2344 Isolate* isolate() { return lookup_.isolate(); } 2348 Isolate* isolate() { return lookup_.isolate(); }
2345 CompilationInfo* current_info() { return builder_->current_info(); } 2349 CompilationInfo* current_info() { return builder_->current_info(); }
2346 2350
2347 bool IsArrayLength() { 2351 bool IsArrayLength() {
2348 return map()->instance_type() == JS_ARRAY_TYPE && 2352 return map()->instance_type() == JS_ARRAY_TYPE &&
2349 name_->Equals(isolate()->heap()->length_string()); 2353 name_->Equals(isolate()->heap()->length_string());
2350 } 2354 }
2351 2355
2352 bool LoadResult(Handle<Map> map); 2356 bool LoadResult(Handle<Map> map);
2353 bool LookupDescriptor(); 2357 bool LookupDescriptor();
2354 bool LookupInPrototypes(); 2358 bool LookupInPrototypes();
2355 bool IsCompatibleForLoad(PropertyAccessInfo* other); 2359 bool IsCompatible(PropertyAccessInfo* other);
2360 bool IsLoad() const { return access_type_ == LOAD; }
2356 2361
2357 void GeneralizeRepresentation(Representation r) { 2362 void GeneralizeRepresentation(Representation r) {
2358 access_ = access_.WithRepresentation( 2363 access_ = access_.WithRepresentation(
2359 access_.representation().generalize(r)); 2364 access_.representation().generalize(r));
2360 } 2365 }
2361 2366
2362 LookupResult lookup_; 2367 LookupResult lookup_;
2363 HOptimizedGraphBuilder* builder_; 2368 HOptimizedGraphBuilder* builder_;
2369 PropertyAccessType access_type_;
2364 Type* type_; 2370 Type* type_;
2365 Handle<String> name_; 2371 Handle<String> name_;
2366 Handle<JSObject> holder_; 2372 Handle<JSObject> holder_;
2367 Handle<JSFunction> accessor_; 2373 Handle<JSFunction> accessor_;
2368 Handle<Object> constant_; 2374 Handle<Object> constant_;
2375 Handle<Map> transition_;
2369 HObjectAccess access_; 2376 HObjectAccess access_;
2370 }; 2377 };
2371 2378
2372 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, 2379 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info,
2373 HValue* object, 2380 HValue* object,
2374 HValue* checked_object, 2381 HValue* checked_object,
2375 BailoutId ast_id, 2382 BailoutId ast_id,
2376 BailoutId return_id, 2383 BailoutId return_id,
2377 bool can_inline_accessor = true); 2384 bool can_inline_accessor = true);
2378 2385
2386 HInstruction* BuildStoreMonomorphic(PropertyAccessInfo* info,
2387 HValue* checked_object,
2388 HValue* value,
2389 BailoutId ast_id,
2390 BailoutId return_id,
2391 bool can_inline_accessor = true);
2392
2379 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, 2393 void HandlePolymorphicStoreNamedField(BailoutId assignment_id,
2394 BailoutId return_id,
2380 HValue* object, 2395 HValue* object,
2381 HValue* value, 2396 HValue* value,
2382 SmallMapList* types, 2397 SmallMapList* types,
2383 Handle<String> name);
2384 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id,
2385 HValue* object,
2386 HValue* value,
2387 SmallMapList* types,
2388 Handle<String> name); 2398 Handle<String> name);
2389 void HandlePolymorphicCallNamed(Call* expr, 2399 void HandlePolymorphicCallNamed(Call* expr,
2390 HValue* receiver, 2400 HValue* receiver,
2391 SmallMapList* types, 2401 SmallMapList* types,
2392 Handle<String> name); 2402 Handle<String> name);
2393 void HandleLiteralCompareTypeof(CompareOperation* expr, 2403 void HandleLiteralCompareTypeof(CompareOperation* expr,
2394 Expression* sub_expr, 2404 Expression* sub_expr,
2395 Handle<String> check); 2405 Handle<String> check);
2396 void HandleLiteralCompareNil(CompareOperation* expr, 2406 void HandleLiteralCompareNil(CompareOperation* expr,
2397 Expression* sub_expr, 2407 Expression* sub_expr,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2465 HValue* object, 2475 HValue* object,
2466 HValue* key, 2476 HValue* key,
2467 HValue* value); 2477 HValue* value);
2468 2478
2469 void BuildStore(Expression* expression, 2479 void BuildStore(Expression* expression,
2470 Property* prop, 2480 Property* prop,
2471 BailoutId ast_id, 2481 BailoutId ast_id,
2472 BailoutId return_id, 2482 BailoutId return_id,
2473 bool is_uninitialized = false); 2483 bool is_uninitialized = false);
2474 2484
2475 HInstruction* BuildStoreNamedField(HValue* object, 2485 HInstruction* BuildStoreNamedField(PropertyAccessInfo* info,
2476 Handle<String> name, 2486 HValue* checked_object,
2477 HValue* value, 2487 HValue* value);
2478 Handle<Map> map,
2479 LookupResult* lookup);
2480 HInstruction* BuildStoreNamedGeneric(HValue* object, 2488 HInstruction* BuildStoreNamedGeneric(HValue* object,
2481 Handle<String> name, 2489 Handle<String> name,
2482 HValue* value); 2490 HValue* value,
2483 HInstruction* BuildStoreNamedMonomorphic(HValue* object, 2491 bool is_uninitialized = false);
2484 Handle<String> name,
2485 HValue* value,
2486 Handle<Map> map);
2487 HInstruction* BuildStoreKeyedGeneric(HValue* object, 2492 HInstruction* BuildStoreKeyedGeneric(HValue* object,
2488 HValue* key, 2493 HValue* key,
2489 HValue* value); 2494 HValue* value);
2490 2495
2491 HValue* BuildContextChainWalk(Variable* var); 2496 HValue* BuildContextChainWalk(Variable* var);
2492 2497
2493 HInstruction* BuildThisFunction(); 2498 HInstruction* BuildThisFunction();
2494 2499
2495 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object, 2500 HInstruction* BuildFastLiteral(Handle<JSObject> boilerplate_object,
2496 AllocationSiteUsageContext* site_context); 2501 AllocationSiteUsageContext* site_context);
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2719 } 2724 }
2720 2725
2721 private: 2726 private:
2722 HGraphBuilder* builder_; 2727 HGraphBuilder* builder_;
2723 }; 2728 };
2724 2729
2725 2730
2726 } } // namespace v8::internal 2731 } } // namespace v8::internal
2727 2732
2728 #endif // V8_HYDROGEN_H_ 2733 #endif // V8_HYDROGEN_H_
OLDNEW
« no previous file with comments | « no previous file | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698