| OLD | NEW |
| 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 2238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2249 | 2249 |
| 2250 void VisitTypedArrayInitialize(CallRuntime* expr); | 2250 void VisitTypedArrayInitialize(CallRuntime* expr); |
| 2251 | 2251 |
| 2252 bool IsCallNewArrayInlineable(CallNew* expr); | 2252 bool IsCallNewArrayInlineable(CallNew* expr); |
| 2253 void BuildInlinedCallNewArray(CallNew* expr); | 2253 void BuildInlinedCallNewArray(CallNew* expr); |
| 2254 | 2254 |
| 2255 void VisitDataViewInitialize(CallRuntime* expr); | 2255 void VisitDataViewInitialize(CallRuntime* expr); |
| 2256 | 2256 |
| 2257 class PropertyAccessInfo { | 2257 class PropertyAccessInfo { |
| 2258 public: | 2258 public: |
| 2259 PropertyAccessInfo(Isolate* isolate, Handle<Map> map, Handle<String> name) | 2259 PropertyAccessInfo(HOptimizedGraphBuilder* builder, |
| 2260 : lookup_(isolate), | 2260 Handle<HeapType> type, |
| 2261 map_(map), | 2261 Handle<String> name) |
| 2262 : lookup_(builder->isolate()), |
| 2263 builder_(builder), |
| 2264 type_(type), |
| 2262 name_(name), | 2265 name_(name), |
| 2263 access_(HObjectAccess::ForMap()) { } | 2266 access_(HObjectAccess::ForMap()) { } |
| 2264 | 2267 |
| 2265 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic | 2268 // Checkes whether this PropertyAccessInfo can be handled as a monomorphic |
| 2266 // load named. It additionally fills in the fields necessary to generate the | 2269 // load named. It additionally fills in the fields necessary to generate the |
| 2267 // lookup code. | 2270 // lookup code. |
| 2268 bool CanLoadMonomorphic(); | 2271 bool CanLoadMonomorphic(); |
| 2269 | 2272 |
| 2270 // Checks whether all types behave uniform when loading name. If all maps | 2273 // Checks whether all types behave uniform when loading name. If all maps |
| 2271 // behave the same, a single monomorphic load instruction can be emitted, | 2274 // behave the same, a single monomorphic load instruction can be emitted, |
| 2272 // guarded by a single map-checks instruction that whether the receiver is | 2275 // guarded by a single map-checks instruction that whether the receiver is |
| 2273 // an instance of any of the types. | 2276 // an instance of any of the types. |
| 2274 // This method skips the first type in types, assuming that this | 2277 // This method skips the first type in types, assuming that this |
| 2275 // PropertyAccessInfo is built for types->first(). | 2278 // PropertyAccessInfo is built for types->first(). |
| 2276 bool CanLoadAsMonomorphic(SmallMapList* types); | 2279 bool CanLoadAsMonomorphic(SmallMapList* types); |
| 2277 | 2280 |
| 2281 Handle<Map> map() { |
| 2282 if (type_->Is(HeapType::Number())) { |
| 2283 Context* context = current_info()->closure()->context(); |
| 2284 context = context->native_context(); |
| 2285 return handle(context->number_function()->initial_map()); |
| 2286 } else if (type_->Is(HeapType::String())) { |
| 2287 Context* context = current_info()->closure()->context(); |
| 2288 context = context->native_context(); |
| 2289 return handle(context->string_function()->initial_map()); |
| 2290 } else { |
| 2291 return type_->AsClass(); |
| 2292 } |
| 2293 } |
| 2294 Handle<HeapType> type() const { return type_; } |
| 2295 Handle<String> name() const { return name_; } |
| 2296 |
| 2278 bool IsJSObjectFieldAccessor() { | 2297 bool IsJSObjectFieldAccessor() { |
| 2279 int offset; // unused | 2298 int offset; // unused |
| 2280 return Accessors::IsJSObjectFieldAccessor(map_, name_, &offset); | 2299 return Accessors::IsJSObjectFieldAccessor(type_, name_, &offset); |
| 2281 } | 2300 } |
| 2282 | 2301 |
| 2283 bool GetJSObjectFieldAccess(HObjectAccess* access) { | 2302 bool GetJSObjectFieldAccess(HObjectAccess* access) { |
| 2284 if (IsStringLength()) { | 2303 if (IsArrayLength()) { |
| 2285 *access = HObjectAccess::ForStringLength(); | 2304 *access = HObjectAccess::ForArrayLength(map()->elements_kind()); |
| 2286 return true; | 2305 return true; |
| 2287 } else if (IsArrayLength()) { | 2306 } |
| 2288 *access = HObjectAccess::ForArrayLength(map_->elements_kind()); | 2307 int offset; |
| 2308 if (Accessors::IsJSObjectFieldAccessor(type_, name_, &offset)) { |
| 2309 if (type_->Is(HeapType::String())) { |
| 2310 ASSERT(name_->Equals(isolate()->heap()->length_string())); |
| 2311 *access = HObjectAccess::ForStringLength(); |
| 2312 } else { |
| 2313 *access = HObjectAccess::ForJSObjectOffset(offset); |
| 2314 } |
| 2289 return true; | 2315 return true; |
| 2290 } else { | |
| 2291 int offset; | |
| 2292 if (Accessors::IsJSObjectFieldAccessor(map_, name_, &offset)) { | |
| 2293 *access = HObjectAccess::ForJSObjectOffset(offset); | |
| 2294 return true; | |
| 2295 } | |
| 2296 return false; | |
| 2297 } | 2316 } |
| 2317 return false; |
| 2298 } | 2318 } |
| 2299 | 2319 |
| 2300 bool has_holder() { return !holder_.is_null(); } | 2320 bool has_holder() { return !holder_.is_null(); } |
| 2301 | 2321 |
| 2302 LookupResult* lookup() { return &lookup_; } | 2322 LookupResult* lookup() { return &lookup_; } |
| 2303 Handle<Map> map() { return map_; } | |
| 2304 Handle<JSObject> holder() { return holder_; } | 2323 Handle<JSObject> holder() { return holder_; } |
| 2305 Handle<JSFunction> accessor() { return accessor_; } | 2324 Handle<JSFunction> accessor() { return accessor_; } |
| 2306 Handle<Object> constant() { return constant_; } | 2325 Handle<Object> constant() { return constant_; } |
| 2307 HObjectAccess access() { return access_; } | 2326 HObjectAccess access() { return access_; } |
| 2308 | 2327 |
| 2309 private: | 2328 private: |
| 2310 Isolate* isolate() { return lookup_.isolate(); } | 2329 Isolate* isolate() { return lookup_.isolate(); } |
| 2330 CompilationInfo* current_info() { return builder_->current_info(); } |
| 2311 | 2331 |
| 2312 bool IsStringLength() { | 2332 bool IsArrayLength() { |
| 2313 return map_->instance_type() < FIRST_NONSTRING_TYPE && | 2333 return map()->instance_type() == JS_ARRAY_TYPE && |
| 2314 name_->Equals(isolate()->heap()->length_string()); | 2334 name_->Equals(isolate()->heap()->length_string()); |
| 2315 } | 2335 } |
| 2316 | 2336 |
| 2317 bool IsArrayLength() { | |
| 2318 return map_->instance_type() == JS_ARRAY_TYPE && | |
| 2319 name_->Equals(isolate()->heap()->length_string()); | |
| 2320 } | |
| 2321 | |
| 2322 bool LoadResult(Handle<Map> map); | 2337 bool LoadResult(Handle<Map> map); |
| 2323 bool LookupDescriptor(); | 2338 bool LookupDescriptor(); |
| 2324 bool LookupInPrototypes(); | 2339 bool LookupInPrototypes(); |
| 2325 bool IsCompatibleForLoad(PropertyAccessInfo* other); | 2340 bool IsCompatibleForLoad(PropertyAccessInfo* other); |
| 2326 | 2341 |
| 2327 void GeneralizeRepresentation(Representation r) { | 2342 void GeneralizeRepresentation(Representation r) { |
| 2328 access_ = access_.WithRepresentation( | 2343 access_ = access_.WithRepresentation( |
| 2329 access_.representation().generalize(r)); | 2344 access_.representation().generalize(r)); |
| 2330 } | 2345 } |
| 2331 | 2346 |
| 2332 LookupResult lookup_; | 2347 LookupResult lookup_; |
| 2333 Handle<Map> map_; | 2348 HOptimizedGraphBuilder* builder_; |
| 2349 Handle<HeapType> type_; |
| 2334 Handle<String> name_; | 2350 Handle<String> name_; |
| 2335 Handle<JSObject> holder_; | 2351 Handle<JSObject> holder_; |
| 2336 Handle<JSFunction> accessor_; | 2352 Handle<JSFunction> accessor_; |
| 2337 Handle<Object> constant_; | 2353 Handle<Object> constant_; |
| 2338 HObjectAccess access_; | 2354 HObjectAccess access_; |
| 2339 }; | 2355 }; |
| 2340 | 2356 |
| 2341 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, | 2357 HInstruction* BuildLoadMonomorphic(PropertyAccessInfo* info, |
| 2342 HValue* object, | 2358 HValue* object, |
| 2343 HInstruction* checked_object, | 2359 HValue* checked_object, |
| 2344 BailoutId ast_id, | 2360 BailoutId ast_id, |
| 2345 BailoutId return_id, | 2361 BailoutId return_id, |
| 2346 bool can_inline_accessor = true); | 2362 bool can_inline_accessor = true); |
| 2347 | 2363 |
| 2348 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, | 2364 void HandlePolymorphicStoreNamedField(BailoutId assignment_id, |
| 2349 HValue* object, | 2365 HValue* object, |
| 2350 HValue* value, | 2366 HValue* value, |
| 2351 SmallMapList* types, | 2367 SmallMapList* types, |
| 2352 Handle<String> name); | 2368 Handle<String> name); |
| 2353 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, | 2369 bool TryStorePolymorphicAsMonomorphic(BailoutId assignment_id, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2700 } | 2716 } |
| 2701 | 2717 |
| 2702 private: | 2718 private: |
| 2703 HGraphBuilder* builder_; | 2719 HGraphBuilder* builder_; |
| 2704 }; | 2720 }; |
| 2705 | 2721 |
| 2706 | 2722 |
| 2707 } } // namespace v8::internal | 2723 } } // namespace v8::internal |
| 2708 | 2724 |
| 2709 #endif // V8_HYDROGEN_H_ | 2725 #endif // V8_HYDROGEN_H_ |
| OLD | NEW |