| 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/hydrogen.h" | 5 #include "src/hydrogen.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "src/v8.h" | 9 #include "src/v8.h" |
| 10 | 10 |
| (...skipping 6408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6419 } | 6419 } |
| 6420 | 6420 |
| 6421 | 6421 |
| 6422 void HOptimizedGraphBuilder::BuildStore(Expression* expr, | 6422 void HOptimizedGraphBuilder::BuildStore(Expression* expr, |
| 6423 Property* prop, | 6423 Property* prop, |
| 6424 BailoutId ast_id, | 6424 BailoutId ast_id, |
| 6425 BailoutId return_id, | 6425 BailoutId return_id, |
| 6426 bool is_uninitialized) { | 6426 bool is_uninitialized) { |
| 6427 if (!prop->key()->IsPropertyName()) { | 6427 if (!prop->key()->IsPropertyName()) { |
| 6428 // Keyed store. | 6428 // Keyed store. |
| 6429 HValue* value = environment()->ExpressionStackAt(0); | 6429 HValue* value = Pop(); |
| 6430 HValue* key = environment()->ExpressionStackAt(1); | 6430 HValue* key = Pop(); |
| 6431 HValue* object = environment()->ExpressionStackAt(2); | 6431 HValue* object = Pop(); |
| 6432 bool has_side_effects = false; | 6432 bool has_side_effects = false; |
| 6433 HandleKeyedElementAccess(object, key, value, expr, ast_id, return_id, STORE, | 6433 HValue* result = HandleKeyedElementAccess( |
| 6434 &has_side_effects); | 6434 object, key, value, expr, ast_id, return_id, STORE, &has_side_effects); |
| 6435 Drop(3); | 6435 if (has_side_effects) { |
| 6436 Push(value); | 6436 if (!ast_context()->IsEffect()) Push(value); |
| 6437 Add<HSimulate>(return_id, REMOVABLE_SIMULATE); | 6437 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6438 return ast_context()->ReturnValue(Pop()); | 6438 if (!ast_context()->IsEffect()) Drop(1); |
| 6439 } |
| 6440 if (result == NULL) return; |
| 6441 return ast_context()->ReturnValue(value); |
| 6439 } | 6442 } |
| 6440 | 6443 |
| 6441 // Named store. | 6444 // Named store. |
| 6442 HValue* value = Pop(); | 6445 HValue* value = Pop(); |
| 6443 HValue* object = Pop(); | 6446 HValue* object = Pop(); |
| 6444 | 6447 |
| 6445 Literal* key = prop->key()->AsLiteral(); | 6448 Literal* key = prop->key()->AsLiteral(); |
| 6446 Handle<String> name = Handle<String>::cast(key->value()); | 6449 Handle<String> name = Handle<String>::cast(key->value()); |
| 6447 DCHECK(!name.is_null()); | 6450 DCHECK(!name.is_null()); |
| 6448 | 6451 |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7058 if (untransitionable_map->has_slow_elements_kind() || | 7061 if (untransitionable_map->has_slow_elements_kind() || |
| 7059 !untransitionable_map->IsJSObjectMap()) { | 7062 !untransitionable_map->IsJSObjectMap()) { |
| 7060 instr = AddInstruction(BuildKeyedGeneric(access_type, expr, object, key, | 7063 instr = AddInstruction(BuildKeyedGeneric(access_type, expr, object, key, |
| 7061 val)); | 7064 val)); |
| 7062 } else { | 7065 } else { |
| 7063 instr = BuildMonomorphicElementAccess( | 7066 instr = BuildMonomorphicElementAccess( |
| 7064 object, key, val, transition, untransitionable_map, access_type, | 7067 object, key, val, transition, untransitionable_map, access_type, |
| 7065 store_mode); | 7068 store_mode); |
| 7066 } | 7069 } |
| 7067 *has_side_effects |= instr->HasObservableSideEffects(); | 7070 *has_side_effects |= instr->HasObservableSideEffects(); |
| 7068 return access_type == STORE ? NULL : instr; | 7071 return access_type == STORE ? val : instr; |
| 7069 } | 7072 } |
| 7070 | 7073 |
| 7071 HBasicBlock* join = graph()->CreateBasicBlock(); | 7074 HBasicBlock* join = graph()->CreateBasicBlock(); |
| 7072 | 7075 |
| 7073 for (int i = 0; i < untransitionable_maps.length(); ++i) { | 7076 for (int i = 0; i < untransitionable_maps.length(); ++i) { |
| 7074 Handle<Map> map = untransitionable_maps[i]; | 7077 Handle<Map> map = untransitionable_maps[i]; |
| 7075 if (!map->IsJSObjectMap()) continue; | 7078 if (!map->IsJSObjectMap()) continue; |
| 7076 ElementsKind elements_kind = map->elements_kind(); | 7079 ElementsKind elements_kind = map->elements_kind(); |
| 7077 HBasicBlock* this_map = graph()->CreateBasicBlock(); | 7080 HBasicBlock* this_map = graph()->CreateBasicBlock(); |
| 7078 HBasicBlock* other_map = graph()->CreateBasicBlock(); | 7081 HBasicBlock* other_map = graph()->CreateBasicBlock(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7111 | 7114 |
| 7112 // Ensure that we visited at least one map above that goes to join. This is | 7115 // Ensure that we visited at least one map above that goes to join. This is |
| 7113 // necessary because FinishExitWithHardDeoptimization does an AbnormalExit | 7116 // necessary because FinishExitWithHardDeoptimization does an AbnormalExit |
| 7114 // rather than joining the join block. If this becomes an issue, insert a | 7117 // rather than joining the join block. If this becomes an issue, insert a |
| 7115 // generic access in the case length() == 0. | 7118 // generic access in the case length() == 0. |
| 7116 DCHECK(join->predecessors()->length() > 0); | 7119 DCHECK(join->predecessors()->length() > 0); |
| 7117 // Deopt if none of the cases matched. | 7120 // Deopt if none of the cases matched. |
| 7118 NoObservableSideEffectsScope scope(this); | 7121 NoObservableSideEffectsScope scope(this); |
| 7119 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); | 7122 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); |
| 7120 set_current_block(join); | 7123 set_current_block(join); |
| 7121 return access_type == STORE ? NULL : Pop(); | 7124 return access_type == STORE ? val : Pop(); |
| 7122 } | 7125 } |
| 7123 | 7126 |
| 7124 | 7127 |
| 7125 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( | 7128 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( |
| 7126 HValue* obj, HValue* key, HValue* val, Expression* expr, BailoutId ast_id, | 7129 HValue* obj, HValue* key, HValue* val, Expression* expr, BailoutId ast_id, |
| 7127 BailoutId return_id, PropertyAccessType access_type, | 7130 BailoutId return_id, PropertyAccessType access_type, |
| 7128 bool* has_side_effects) { | 7131 bool* has_side_effects) { |
| 7129 if (key->ActualValue()->IsConstant()) { | 7132 if (key->ActualValue()->IsConstant()) { |
| 7130 Handle<Object> constant = | 7133 Handle<Object> constant = |
| 7131 HConstant::cast(key->ActualValue())->handle(isolate()); | 7134 HConstant::cast(key->ActualValue())->handle(isolate()); |
| (...skipping 5385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12517 if (ShouldProduceTraceOutput()) { | 12520 if (ShouldProduceTraceOutput()) { |
| 12518 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12521 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12519 } | 12522 } |
| 12520 | 12523 |
| 12521 #ifdef DEBUG | 12524 #ifdef DEBUG |
| 12522 graph_->Verify(false); // No full verify. | 12525 graph_->Verify(false); // No full verify. |
| 12523 #endif | 12526 #endif |
| 12524 } | 12527 } |
| 12525 | 12528 |
| 12526 } } // namespace v8::internal | 12529 } } // namespace v8::internal |
| OLD | NEW |