| 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 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/v8.h" | 10 #include "src/v8.h" |
| (...skipping 6432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6443 } | 6443 } |
| 6444 | 6444 |
| 6445 | 6445 |
| 6446 void HOptimizedGraphBuilder::BuildStore(Expression* expr, | 6446 void HOptimizedGraphBuilder::BuildStore(Expression* expr, |
| 6447 Property* prop, | 6447 Property* prop, |
| 6448 BailoutId ast_id, | 6448 BailoutId ast_id, |
| 6449 BailoutId return_id, | 6449 BailoutId return_id, |
| 6450 bool is_uninitialized) { | 6450 bool is_uninitialized) { |
| 6451 if (!prop->key()->IsPropertyName()) { | 6451 if (!prop->key()->IsPropertyName()) { |
| 6452 // Keyed store. | 6452 // Keyed store. |
| 6453 HValue* value = environment()->ExpressionStackAt(0); | 6453 HValue* value = Pop(); |
| 6454 HValue* key = environment()->ExpressionStackAt(1); | 6454 HValue* key = Pop(); |
| 6455 HValue* object = environment()->ExpressionStackAt(2); | 6455 HValue* object = Pop(); |
| 6456 bool has_side_effects = false; | 6456 bool has_side_effects = false; |
| 6457 HandleKeyedElementAccess(object, key, value, expr, ast_id, return_id, STORE, | 6457 HValue* result = HandleKeyedElementAccess( |
| 6458 &has_side_effects); | 6458 object, key, value, expr, ast_id, return_id, STORE, &has_side_effects); |
| 6459 Drop(3); | 6459 if (has_side_effects) { |
| 6460 Push(value); | 6460 if (!ast_context()->IsEffect()) Push(value); |
| 6461 Add<HSimulate>(return_id, REMOVABLE_SIMULATE); | 6461 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6462 return ast_context()->ReturnValue(Pop()); | 6462 if (!ast_context()->IsEffect()) Drop(1); |
| 6463 } |
| 6464 if (result == NULL) return; |
| 6465 return ast_context()->ReturnValue(value); |
| 6463 } | 6466 } |
| 6464 | 6467 |
| 6465 // Named store. | 6468 // Named store. |
| 6466 HValue* value = Pop(); | 6469 HValue* value = Pop(); |
| 6467 HValue* object = Pop(); | 6470 HValue* object = Pop(); |
| 6468 | 6471 |
| 6469 Literal* key = prop->key()->AsLiteral(); | 6472 Literal* key = prop->key()->AsLiteral(); |
| 6470 Handle<String> name = Handle<String>::cast(key->value()); | 6473 Handle<String> name = Handle<String>::cast(key->value()); |
| 6471 DCHECK(!name.is_null()); | 6474 DCHECK(!name.is_null()); |
| 6472 | 6475 |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7082 if (untransitionable_map->has_slow_elements_kind() || | 7085 if (untransitionable_map->has_slow_elements_kind() || |
| 7083 !untransitionable_map->IsJSObjectMap()) { | 7086 !untransitionable_map->IsJSObjectMap()) { |
| 7084 instr = AddInstruction(BuildKeyedGeneric(access_type, expr, object, key, | 7087 instr = AddInstruction(BuildKeyedGeneric(access_type, expr, object, key, |
| 7085 val)); | 7088 val)); |
| 7086 } else { | 7089 } else { |
| 7087 instr = BuildMonomorphicElementAccess( | 7090 instr = BuildMonomorphicElementAccess( |
| 7088 object, key, val, transition, untransitionable_map, access_type, | 7091 object, key, val, transition, untransitionable_map, access_type, |
| 7089 store_mode); | 7092 store_mode); |
| 7090 } | 7093 } |
| 7091 *has_side_effects |= instr->HasObservableSideEffects(); | 7094 *has_side_effects |= instr->HasObservableSideEffects(); |
| 7092 return access_type == STORE ? NULL : instr; | 7095 return access_type == STORE ? val : instr; |
| 7093 } | 7096 } |
| 7094 | 7097 |
| 7095 HBasicBlock* join = graph()->CreateBasicBlock(); | 7098 HBasicBlock* join = graph()->CreateBasicBlock(); |
| 7096 | 7099 |
| 7097 for (int i = 0; i < untransitionable_maps.length(); ++i) { | 7100 for (int i = 0; i < untransitionable_maps.length(); ++i) { |
| 7098 Handle<Map> map = untransitionable_maps[i]; | 7101 Handle<Map> map = untransitionable_maps[i]; |
| 7099 if (!map->IsJSObjectMap()) continue; | 7102 if (!map->IsJSObjectMap()) continue; |
| 7100 ElementsKind elements_kind = map->elements_kind(); | 7103 ElementsKind elements_kind = map->elements_kind(); |
| 7101 HBasicBlock* this_map = graph()->CreateBasicBlock(); | 7104 HBasicBlock* this_map = graph()->CreateBasicBlock(); |
| 7102 HBasicBlock* other_map = graph()->CreateBasicBlock(); | 7105 HBasicBlock* other_map = graph()->CreateBasicBlock(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7135 | 7138 |
| 7136 // Ensure that we visited at least one map above that goes to join. This is | 7139 // Ensure that we visited at least one map above that goes to join. This is |
| 7137 // necessary because FinishExitWithHardDeoptimization does an AbnormalExit | 7140 // necessary because FinishExitWithHardDeoptimization does an AbnormalExit |
| 7138 // rather than joining the join block. If this becomes an issue, insert a | 7141 // rather than joining the join block. If this becomes an issue, insert a |
| 7139 // generic access in the case length() == 0. | 7142 // generic access in the case length() == 0. |
| 7140 DCHECK(join->predecessors()->length() > 0); | 7143 DCHECK(join->predecessors()->length() > 0); |
| 7141 // Deopt if none of the cases matched. | 7144 // Deopt if none of the cases matched. |
| 7142 NoObservableSideEffectsScope scope(this); | 7145 NoObservableSideEffectsScope scope(this); |
| 7143 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); | 7146 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); |
| 7144 set_current_block(join); | 7147 set_current_block(join); |
| 7145 return access_type == STORE ? NULL : Pop(); | 7148 return access_type == STORE ? val : Pop(); |
| 7146 } | 7149 } |
| 7147 | 7150 |
| 7148 | 7151 |
| 7149 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( | 7152 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( |
| 7150 HValue* obj, HValue* key, HValue* val, Expression* expr, BailoutId ast_id, | 7153 HValue* obj, HValue* key, HValue* val, Expression* expr, BailoutId ast_id, |
| 7151 BailoutId return_id, PropertyAccessType access_type, | 7154 BailoutId return_id, PropertyAccessType access_type, |
| 7152 bool* has_side_effects) { | 7155 bool* has_side_effects) { |
| 7153 if (key->ActualValue()->IsConstant()) { | 7156 if (key->ActualValue()->IsConstant()) { |
| 7154 Handle<Object> constant = | 7157 Handle<Object> constant = |
| 7155 HConstant::cast(key->ActualValue())->handle(isolate()); | 7158 HConstant::cast(key->ActualValue())->handle(isolate()); |
| (...skipping 5385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12541 if (ShouldProduceTraceOutput()) { | 12544 if (ShouldProduceTraceOutput()) { |
| 12542 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12545 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 12543 } | 12546 } |
| 12544 | 12547 |
| 12545 #ifdef DEBUG | 12548 #ifdef DEBUG |
| 12546 graph_->Verify(false); // No full verify. | 12549 graph_->Verify(false); // No full verify. |
| 12547 #endif | 12550 #endif |
| 12548 } | 12551 } |
| 12549 | 12552 |
| 12550 } } // namespace v8::internal | 12553 } } // namespace v8::internal |
| OLD | NEW |