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 5359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5370 } | 5370 } |
5371 } | 5371 } |
5372 | 5372 |
5373 Push(graph()->GetConstant0()); | 5373 Push(graph()->GetConstant0()); |
5374 | 5374 |
5375 HBasicBlock* loop_entry = BuildLoopEntry(stmt); | 5375 HBasicBlock* loop_entry = BuildLoopEntry(stmt); |
5376 | 5376 |
5377 // 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. |
5378 // 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 |
5379 // computation above, but from the OSR entry block. | 5379 // computation above, but from the OSR entry block. |
5380 enumerable = environment()->ExpressionStackAt(4); | |
5381 HValue* index = environment()->ExpressionStackAt(0); | 5380 HValue* index = environment()->ExpressionStackAt(0); |
5382 HValue* limit = environment()->ExpressionStackAt(1); | 5381 HValue* limit = environment()->ExpressionStackAt(1); |
| 5382 HValue* array = environment()->ExpressionStackAt(2); |
| 5383 HValue* type = environment()->ExpressionStackAt(3); |
| 5384 enumerable = environment()->ExpressionStackAt(4); |
5383 | 5385 |
5384 // Check that we still have more keys. | 5386 // Check that we still have more keys. |
5385 HCompareNumericAndBranch* compare_index = | 5387 HCompareNumericAndBranch* compare_index = |
5386 New<HCompareNumericAndBranch>(index, limit, Token::LT); | 5388 New<HCompareNumericAndBranch>(index, limit, Token::LT); |
5387 compare_index->set_observed_input_representation( | 5389 compare_index->set_observed_input_representation( |
5388 Representation::Smi(), Representation::Smi()); | 5390 Representation::Smi(), Representation::Smi()); |
5389 | 5391 |
5390 HBasicBlock* loop_body = graph()->CreateBasicBlock(); | 5392 HBasicBlock* loop_body = graph()->CreateBasicBlock(); |
5391 HBasicBlock* loop_successor = graph()->CreateBasicBlock(); | 5393 HBasicBlock* loop_successor = graph()->CreateBasicBlock(); |
5392 | 5394 |
5393 compare_index->SetSuccessorAt(0, loop_body); | 5395 compare_index->SetSuccessorAt(0, loop_body); |
5394 compare_index->SetSuccessorAt(1, loop_successor); | 5396 compare_index->SetSuccessorAt(1, loop_successor); |
5395 FinishCurrentBlock(compare_index); | 5397 FinishCurrentBlock(compare_index); |
5396 | 5398 |
5397 set_current_block(loop_successor); | 5399 set_current_block(loop_successor); |
5398 Drop(5); | 5400 Drop(5); |
5399 | 5401 |
5400 set_current_block(loop_body); | 5402 set_current_block(loop_body); |
5401 | 5403 |
5402 HValue* key = | 5404 HValue* key = Add<HLoadKeyed>(array, index, index, nullptr, FAST_ELEMENTS); |
5403 Add<HLoadKeyed>(environment()->ExpressionStackAt(2), // Enum cache. | |
5404 index, index, nullptr, FAST_ELEMENTS); | |
5405 | 5405 |
5406 if (fast) { | 5406 if (fast) { |
5407 // Check if the expected map still matches that of the enumerable. | 5407 // Check if the expected map still matches that of the enumerable. |
5408 // If not just deoptimize. | 5408 // If not just deoptimize. |
5409 Add<HCheckMapValue>(enumerable, environment()->ExpressionStackAt(3)); | 5409 Add<HCheckMapValue>(enumerable, type); |
5410 Bind(each_var, key); | 5410 Bind(each_var, key); |
5411 } else { | 5411 } else { |
5412 Add<HPushArguments>(enumerable, key); | 5412 HValue* enumerable_map = |
5413 Runtime::FunctionId function_id = Runtime::kForInFilter; | 5413 Add<HLoadNamedField>(enumerable, nullptr, HObjectAccess::ForMap()); |
5414 key = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 2); | 5414 IfBuilder if_fast(this); |
5415 Push(key); | 5415 if_fast.If<HCompareObjectEqAndBranch>(enumerable_map, type); |
5416 Add<HSimulate>(stmt->FilterId()); | 5416 if_fast.Then(); |
| 5417 { |
| 5418 Push(key); |
| 5419 Add<HSimulate>(stmt->FilterId()); |
| 5420 } |
| 5421 if_fast.Else(); |
| 5422 { |
| 5423 Add<HPushArguments>(enumerable, key); |
| 5424 Runtime::FunctionId function_id = Runtime::kForInFilter; |
| 5425 Push(Add<HCallRuntime>(Runtime::FunctionForId(function_id), 2)); |
| 5426 Add<HSimulate>(stmt->FilterId()); |
| 5427 } |
| 5428 if_fast.End(); |
5417 key = Pop(); | 5429 key = Pop(); |
5418 Bind(each_var, key); | 5430 Bind(each_var, key); |
5419 IfBuilder if_undefined(this); | 5431 IfBuilder if_undefined(this); |
5420 if_undefined.If<HCompareObjectEqAndBranch>(key, | 5432 if_undefined.If<HCompareObjectEqAndBranch>(key, |
5421 graph()->GetConstantUndefined()); | 5433 graph()->GetConstantUndefined()); |
5422 if_undefined.ThenDeopt(Deoptimizer::kUndefined); | 5434 if_undefined.ThenDeopt(Deoptimizer::kUndefined); |
5423 if_undefined.End(); | 5435 if_undefined.End(); |
5424 Add<HSimulate>(stmt->AssignmentId()); | 5436 Add<HSimulate>(stmt->AssignmentId()); |
5425 } | 5437 } |
5426 | 5438 |
(...skipping 8200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13627 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13639 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13628 } | 13640 } |
13629 | 13641 |
13630 #ifdef DEBUG | 13642 #ifdef DEBUG |
13631 graph_->Verify(false); // No full verify. | 13643 graph_->Verify(false); // No full verify. |
13632 #endif | 13644 #endif |
13633 } | 13645 } |
13634 | 13646 |
13635 } // namespace internal | 13647 } // namespace internal |
13636 } // namespace v8 | 13648 } // namespace v8 |
OLD | NEW |