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 6412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 = environment()->ExpressionStackAt(0); |
6430 HValue* key = environment()->ExpressionStackAt(1); | 6430 HValue* key = environment()->ExpressionStackAt(1); |
6431 HValue* object = environment()->ExpressionStackAt(2); | 6431 HValue* object = environment()->ExpressionStackAt(2); |
6432 bool has_side_effects = false; | 6432 bool has_side_effects = false; |
6433 HandleKeyedElementAccess(object, key, value, expr, | 6433 HandleKeyedElementAccess(object, key, value, expr, return_id, STORE, |
6434 STORE, &has_side_effects); | 6434 &has_side_effects); |
6435 Drop(3); | 6435 Drop(3); |
6436 Push(value); | 6436 Push(value); |
6437 Add<HSimulate>(return_id, REMOVABLE_SIMULATE); | 6437 Add<HSimulate>(return_id, REMOVABLE_SIMULATE); |
6438 return ast_context()->ReturnValue(Pop()); | 6438 return ast_context()->ReturnValue(Pop()); |
6439 } | 6439 } |
6440 | 6440 |
6441 // Named store. | 6441 // Named store. |
6442 HValue* value = Pop(); | 6442 HValue* value = Pop(); |
6443 HValue* object = Pop(); | 6443 HValue* object = Pop(); |
6444 | 6444 |
(...skipping 671 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7116 DCHECK(join->predecessors()->length() > 0); | 7116 DCHECK(join->predecessors()->length() > 0); |
7117 // Deopt if none of the cases matched. | 7117 // Deopt if none of the cases matched. |
7118 NoObservableSideEffectsScope scope(this); | 7118 NoObservableSideEffectsScope scope(this); |
7119 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); | 7119 FinishExitWithHardDeoptimization("Unknown map in polymorphic element access"); |
7120 set_current_block(join); | 7120 set_current_block(join); |
7121 return access_type == STORE ? NULL : Pop(); | 7121 return access_type == STORE ? NULL : Pop(); |
7122 } | 7122 } |
7123 | 7123 |
7124 | 7124 |
7125 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( | 7125 HValue* HOptimizedGraphBuilder::HandleKeyedElementAccess( |
7126 HValue* obj, | 7126 HValue* obj, HValue* key, HValue* val, Expression* expr, |
7127 HValue* key, | 7127 BailoutId return_id, PropertyAccessType access_type, |
7128 HValue* val, | |
7129 Expression* expr, | |
7130 PropertyAccessType access_type, | |
7131 bool* has_side_effects) { | 7128 bool* has_side_effects) { |
7129 if (key->ActualValue()->IsConstant()) { | |
7130 Handle<Object> constant = | |
7131 HConstant::cast(key->ActualValue())->handle(isolate()); | |
7132 uint32_t array_index; | |
7133 if (constant->IsString() && | |
7134 !Handle<String>::cast(constant)->AsArrayIndex(&array_index)) { | |
7135 HInstruction* instr = | |
7136 BuildNamedAccess(access_type, expr->id(), expr->id(), expr, obj, | |
Igor Sheludko
2014/09/18 11:25:37
As you noticed you didn't use return_id here.
| |
7137 Handle<String>::cast(constant), val, false); | |
Igor Sheludko
2014/09/18 11:25:37
If instr really can't be null here then consider a
| |
7138 if (instr->IsLinked()) { | |
7139 *has_side_effects = false; | |
7140 } else { | |
7141 AddInstruction(instr); | |
7142 *has_side_effects = instr->HasObservableSideEffects(); | |
7143 } | |
7144 return instr; | |
7145 } | |
7146 } | |
7147 | |
7132 DCHECK(!expr->IsPropertyName()); | 7148 DCHECK(!expr->IsPropertyName()); |
7133 HInstruction* instr = NULL; | 7149 HInstruction* instr = NULL; |
7134 | 7150 |
7135 SmallMapList* types; | 7151 SmallMapList* types; |
7136 bool monomorphic = ComputeReceiverTypes(expr, obj, &types, zone()); | 7152 bool monomorphic = ComputeReceiverTypes(expr, obj, &types, zone()); |
7137 | 7153 |
7138 bool force_generic = false; | 7154 bool force_generic = false; |
7139 if (access_type == STORE && | 7155 if (access_type == STORE && |
7140 (monomorphic || (types != NULL && !types->is_empty()))) { | 7156 (monomorphic || (types != NULL && !types->is_empty()))) { |
7141 // Stores can't be mono/polymorphic if their prototype chain has dictionary | 7157 // Stores can't be mono/polymorphic if their prototype chain has dictionary |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7332 object, name, NULL, expr->IsUninitialized()); | 7348 object, name, NULL, expr->IsUninitialized()); |
7333 if (instr == NULL) return; | 7349 if (instr == NULL) return; |
7334 if (instr->IsLinked()) return ast_context()->ReturnValue(instr); | 7350 if (instr->IsLinked()) return ast_context()->ReturnValue(instr); |
7335 | 7351 |
7336 } else { | 7352 } else { |
7337 HValue* key = Pop(); | 7353 HValue* key = Pop(); |
7338 HValue* obj = Pop(); | 7354 HValue* obj = Pop(); |
7339 | 7355 |
7340 bool has_side_effects = false; | 7356 bool has_side_effects = false; |
7341 HValue* load = HandleKeyedElementAccess( | 7357 HValue* load = HandleKeyedElementAccess( |
7342 obj, key, NULL, expr, LOAD, &has_side_effects); | 7358 obj, key, NULL, expr, expr->LoadId(), LOAD, &has_side_effects); |
7343 if (has_side_effects) { | 7359 if (has_side_effects) { |
7344 if (ast_context()->IsEffect()) { | 7360 if (ast_context()->IsEffect()) { |
7345 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 7361 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
7346 } else { | 7362 } else { |
7347 Push(load); | 7363 Push(load); |
7348 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 7364 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
7349 Drop(1); | 7365 Drop(1); |
7350 } | 7366 } |
7351 } | 7367 } |
7352 return ast_context()->ReturnValue(load); | 7368 return ast_context()->ReturnValue(load); |
(...skipping 5134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
12487 if (ShouldProduceTraceOutput()) { | 12503 if (ShouldProduceTraceOutput()) { |
12488 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 12504 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
12489 } | 12505 } |
12490 | 12506 |
12491 #ifdef DEBUG | 12507 #ifdef DEBUG |
12492 graph_->Verify(false); // No full verify. | 12508 graph_->Verify(false); // No full verify. |
12493 #endif | 12509 #endif |
12494 } | 12510 } |
12495 | 12511 |
12496 } } // namespace v8::internal | 12512 } } // namespace v8::internal |
OLD | NEW |