OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/crankshaft/hydrogen.h" | 5 #include "src/crankshaft/hydrogen.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 | 8 |
9 #include "src/allocation-site-scopes.h" | 9 #include "src/allocation-site-scopes.h" |
10 #include "src/ast/ast-numbering.h" | 10 #include "src/ast/ast-numbering.h" |
(...skipping 5297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5308 enumerable, graph()->GetConstantNull()); | 5308 enumerable, graph()->GetConstantNull()); |
5309 if_undefined_or_null.ThenDeopt(Deoptimizer::kUndefinedOrNullInForIn); | 5309 if_undefined_or_null.ThenDeopt(Deoptimizer::kUndefinedOrNullInForIn); |
5310 if_undefined_or_null.End(); | 5310 if_undefined_or_null.End(); |
5311 BuildForInBody(stmt, each_var, enumerable); | 5311 BuildForInBody(stmt, each_var, enumerable); |
5312 } | 5312 } |
5313 | 5313 |
5314 | 5314 |
5315 void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt, | 5315 void HOptimizedGraphBuilder::BuildForInBody(ForInStatement* stmt, |
5316 Variable* each_var, | 5316 Variable* each_var, |
5317 HValue* enumerable) { | 5317 HValue* enumerable) { |
5318 HValue* map; | |
5319 HValue* array; | |
5320 HValue* enum_length; | |
5321 Handle<Map> meta_map = isolate()->factory()->meta_map(); | 5318 Handle<Map> meta_map = isolate()->factory()->meta_map(); |
5322 bool fast = stmt->for_in_type() == ForInStatement::FAST_FOR_IN; | 5319 bool fast = stmt->for_in_type() == ForInStatement::FAST_FOR_IN; |
5323 BuildCheckHeapObject(enumerable); | 5320 BuildCheckHeapObject(enumerable); |
5324 Add<HCheckInstanceType>(enumerable, HCheckInstanceType::IS_JS_RECEIVER); | 5321 Add<HCheckInstanceType>(enumerable, HCheckInstanceType::IS_JS_RECEIVER); |
5325 Add<HSimulate>(stmt->ToObjectId()); | 5322 Add<HSimulate>(stmt->ToObjectId()); |
5326 if (fast) { | 5323 if (fast) { |
5327 map = Add<HForInPrepareMap>(enumerable); | 5324 HForInPrepareMap* map = Add<HForInPrepareMap>(enumerable); |
5328 Push(map); | 5325 Push(map); |
5329 Add<HSimulate>(stmt->EnumId()); | 5326 Add<HSimulate>(stmt->EnumId()); |
5330 Drop(1); | 5327 Drop(1); |
5331 Add<HCheckMaps>(map, meta_map); | 5328 Add<HCheckMaps>(map, meta_map); |
5332 | 5329 |
5333 array = Add<HForInCacheArray>(enumerable, map, | 5330 HForInCacheArray* array = Add<HForInCacheArray>( |
5334 DescriptorArray::kEnumCacheBridgeCacheIndex); | 5331 enumerable, map, DescriptorArray::kEnumCacheBridgeCacheIndex); |
5335 enum_length = BuildEnumLength(map); | 5332 HValue* enum_length = BuildEnumLength(map); |
5336 | 5333 |
5337 HInstruction* index_cache = Add<HForInCacheArray>( | 5334 HForInCacheArray* index_cache = Add<HForInCacheArray>( |
5338 enumerable, map, DescriptorArray::kEnumCacheBridgeIndicesCacheIndex); | 5335 enumerable, map, DescriptorArray::kEnumCacheBridgeIndicesCacheIndex); |
5339 HForInCacheArray::cast(array) | 5336 array->set_index_cache(index_cache); |
5340 ->set_index_cache(HForInCacheArray::cast(index_cache)); | 5337 |
| 5338 Push(map); |
| 5339 Push(array); |
| 5340 Push(enum_length); |
| 5341 Add<HSimulate>(stmt->PrepareId()); |
5341 } else { | 5342 } else { |
5342 Runtime::FunctionId function_id = Runtime::kGetPropertyNamesFast; | 5343 Runtime::FunctionId function_id = Runtime::kGetPropertyNamesFast; |
5343 Add<HPushArguments>(enumerable); | 5344 Add<HPushArguments>(enumerable); |
5344 array = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 1); | 5345 HCallRuntime* array = |
| 5346 Add<HCallRuntime>(Runtime::FunctionForId(function_id), 1); |
5345 Push(array); | 5347 Push(array); |
5346 Add<HSimulate>(stmt->EnumId()); | 5348 Add<HSimulate>(stmt->EnumId()); |
5347 Drop(1); | 5349 Drop(1); |
| 5350 |
| 5351 IfBuilder if_fast(this); |
| 5352 if_fast.If<HCompareMap>(array, meta_map); |
| 5353 if_fast.Then(); |
5348 { | 5354 { |
5349 NoObservableSideEffectsScope scope(this); | 5355 HValue* cache_map = array; |
5350 IfBuilder if_fast(this); | 5356 HForInCacheArray* cache = Add<HForInCacheArray>( |
5351 if_fast.If<HCompareMap>(array, meta_map); | 5357 enumerable, cache_map, DescriptorArray::kEnumCacheBridgeCacheIndex); |
5352 if_fast.Then(); | 5358 HValue* enum_length = BuildEnumLength(cache_map); |
5353 { | 5359 Push(cache_map); |
5354 HValue* cache_map = array; | 5360 Push(cache); |
5355 HForInCacheArray* cache = Add<HForInCacheArray>( | 5361 Push(enum_length); |
5356 enumerable, cache_map, DescriptorArray::kEnumCacheBridgeCacheIndex); | 5362 Add<HSimulate>(stmt->PrepareId(), FIXED_SIMULATE); |
5357 enum_length = BuildEnumLength(cache_map); | 5363 } |
5358 Push(cache_map); | 5364 if_fast.Else(); |
5359 Push(cache); | 5365 { |
5360 Push(enum_length); | 5366 Push(graph()->GetConstant1()); |
5361 } | 5367 Push(array); |
5362 if_fast.Else(); | 5368 Push(AddLoadFixedArrayLength(array)); |
5363 { | 5369 Add<HSimulate>(stmt->PrepareId(), FIXED_SIMULATE); |
5364 Push(graph()->GetConstant1()); | |
5365 Push(array); | |
5366 Push(AddLoadFixedArrayLength(array)); | |
5367 } | |
5368 if_fast.End(); | |
5369 enum_length = Pop(); | |
5370 array = Pop(); | |
5371 map = Pop(); | |
5372 } | 5370 } |
5373 } | 5371 } |
5374 | 5372 |
5375 HInstruction* start_index = Add<HConstant>(0); | 5373 Push(graph()->GetConstant0()); |
5376 | |
5377 Push(map); | |
5378 Push(array); | |
5379 Push(enum_length); | |
5380 Push(start_index); | |
5381 | 5374 |
5382 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 5375 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
5383 | 5376 |
5384 // Reload the values to ensure we have up-to-date values inside of the loop. | 5377 // Reload the values to ensure we have up-to-date values inside of the loop. |
5385 // This is relevant especially for OSR where the values don't come from the | 5378 // This is relevant especially for OSR where the values don't come from the |
5386 // computation above, but from the OSR entry block. | 5379 // computation above, but from the OSR entry block. |
5387 enumerable = environment()->ExpressionStackAt(4); | 5380 enumerable = environment()->ExpressionStackAt(4); |
5388 HValue* index = environment()->ExpressionStackAt(0); | 5381 HValue* index = environment()->ExpressionStackAt(0); |
5389 HValue* limit = environment()->ExpressionStackAt(1); | 5382 HValue* limit = environment()->ExpressionStackAt(1); |
5390 | 5383 |
(...skipping 8248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13639 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13632 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13640 } | 13633 } |
13641 | 13634 |
13642 #ifdef DEBUG | 13635 #ifdef DEBUG |
13643 graph_->Verify(false); // No full verify. | 13636 graph_->Verify(false); // No full verify. |
13644 #endif | 13637 #endif |
13645 } | 13638 } |
13646 | 13639 |
13647 } // namespace internal | 13640 } // namespace internal |
13648 } // namespace v8 | 13641 } // namespace v8 |
OLD | NEW |