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 5880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5891 field_maps, HType::HeapObject()); | 5891 field_maps, HType::HeapObject()); |
5892 } | 5892 } |
5893 instr->ClearDependsOnFlag(kInobjectFields); | 5893 instr->ClearDependsOnFlag(kInobjectFields); |
5894 instr->SetDependsOnFlag(kGlobalVars); | 5894 instr->SetDependsOnFlag(kGlobalVars); |
5895 return ast_context()->ReturnInstruction(instr, expr->id()); | 5895 return ast_context()->ReturnInstruction(instr, expr->id()); |
5896 } | 5896 } |
5897 } else { | 5897 } else { |
5898 HValue* global_object = Add<HLoadNamedField>( | 5898 HValue* global_object = Add<HLoadNamedField>( |
5899 BuildGetNativeContext(), nullptr, | 5899 BuildGetNativeContext(), nullptr, |
5900 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); | 5900 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); |
| 5901 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
5901 HLoadGlobalGeneric* instr = New<HLoadGlobalGeneric>( | 5902 HLoadGlobalGeneric* instr = New<HLoadGlobalGeneric>( |
5902 global_object, variable->name(), ast_context()->typeof_mode()); | 5903 global_object, variable->name(), ast_context()->typeof_mode(), |
5903 instr->SetVectorAndSlot(handle(current_feedback_vector(), isolate()), | 5904 vector, expr->VariableFeedbackSlot()); |
5904 expr->VariableFeedbackSlot()); | |
5905 return ast_context()->ReturnInstruction(instr, expr->id()); | 5905 return ast_context()->ReturnInstruction(instr, expr->id()); |
5906 } | 5906 } |
5907 } | 5907 } |
5908 | 5908 |
5909 case VariableLocation::PARAMETER: | 5909 case VariableLocation::PARAMETER: |
5910 case VariableLocation::LOCAL: { | 5910 case VariableLocation::LOCAL: { |
5911 HValue* value = LookupAndMakeLive(variable); | 5911 HValue* value = LookupAndMakeLive(variable); |
5912 if (value == graph()->GetConstantHole()) { | 5912 if (value == graph()->GetConstantHole()) { |
5913 DCHECK(IsDeclaredVariableMode(variable->mode()) && | 5913 DCHECK(IsDeclaredVariableMode(variable->mode()) && |
5914 variable->mode() != VAR); | 5914 variable->mode() != VAR); |
(...skipping 1164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7079 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value); | 7079 HInstruction* instr = Add<HStoreNamedField>(cell_constant, access, value); |
7080 instr->ClearChangesFlag(kInobjectFields); | 7080 instr->ClearChangesFlag(kInobjectFields); |
7081 instr->SetChangesFlag(kGlobalVars); | 7081 instr->SetChangesFlag(kGlobalVars); |
7082 if (instr->HasObservableSideEffects()) { | 7082 if (instr->HasObservableSideEffects()) { |
7083 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 7083 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
7084 } | 7084 } |
7085 } else { | 7085 } else { |
7086 HValue* global_object = Add<HLoadNamedField>( | 7086 HValue* global_object = Add<HLoadNamedField>( |
7087 BuildGetNativeContext(), nullptr, | 7087 BuildGetNativeContext(), nullptr, |
7088 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); | 7088 HObjectAccess::ForContextSlot(Context::EXTENSION_INDEX)); |
| 7089 Handle<TypeFeedbackVector> vector = |
| 7090 handle(current_feedback_vector(), isolate()); |
7089 HStoreNamedGeneric* instr = | 7091 HStoreNamedGeneric* instr = |
7090 Add<HStoreNamedGeneric>(global_object, var->name(), value, | 7092 Add<HStoreNamedGeneric>(global_object, var->name(), value, |
7091 function_language_mode(), PREMONOMORPHIC); | 7093 function_language_mode(), vector, slot); |
7092 Handle<TypeFeedbackVector> vector = | |
7093 handle(current_feedback_vector(), isolate()); | |
7094 instr->SetVectorAndSlot(vector, slot); | |
7095 USE(instr); | 7094 USE(instr); |
7096 DCHECK(instr->HasObservableSideEffects()); | 7095 DCHECK(instr->HasObservableSideEffects()); |
7097 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 7096 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
7098 } | 7097 } |
7099 } | 7098 } |
7100 | 7099 |
7101 | 7100 |
7102 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { | 7101 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
7103 Expression* target = expr->target(); | 7102 Expression* target = expr->target(); |
7104 VariableProxy* proxy = target->AsVariableProxy(); | 7103 VariableProxy* proxy = target->AsVariableProxy(); |
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7410 Handle<TypeFeedbackVector> vector = | 7409 Handle<TypeFeedbackVector> vector = |
7411 handle(current_feedback_vector(), isolate()); | 7410 handle(current_feedback_vector(), isolate()); |
7412 | 7411 |
7413 if (!expr->AsProperty()->key()->IsPropertyName()) { | 7412 if (!expr->AsProperty()->key()->IsPropertyName()) { |
7414 // It's possible that a keyed load of a constant string was converted | 7413 // It's possible that a keyed load of a constant string was converted |
7415 // to a named load. Here, at the last minute, we need to make sure to | 7414 // to a named load. Here, at the last minute, we need to make sure to |
7416 // use a generic Keyed Load if we are using the type vector, because | 7415 // use a generic Keyed Load if we are using the type vector, because |
7417 // it has to share information with full code. | 7416 // it has to share information with full code. |
7418 HConstant* key = Add<HConstant>(name); | 7417 HConstant* key = Add<HConstant>(name); |
7419 HLoadKeyedGeneric* result = | 7418 HLoadKeyedGeneric* result = |
7420 New<HLoadKeyedGeneric>(object, key, PREMONOMORPHIC); | 7419 New<HLoadKeyedGeneric>(object, key, vector, slot); |
7421 result->SetVectorAndSlot(vector, slot); | |
7422 return result; | 7420 return result; |
7423 } | 7421 } |
7424 | 7422 |
7425 HLoadNamedGeneric* result = | 7423 HLoadNamedGeneric* result = |
7426 New<HLoadNamedGeneric>(object, name, PREMONOMORPHIC); | 7424 New<HLoadNamedGeneric>(object, name, vector, slot); |
7427 result->SetVectorAndSlot(vector, slot); | |
7428 return result; | 7425 return result; |
7429 } else { | 7426 } else { |
| 7427 Handle<TypeFeedbackVector> vector = |
| 7428 handle(current_feedback_vector(), isolate()); |
| 7429 |
7430 if (current_feedback_vector()->GetKind(slot) == | 7430 if (current_feedback_vector()->GetKind(slot) == |
7431 FeedbackVectorSlotKind::KEYED_STORE_IC) { | 7431 FeedbackVectorSlotKind::KEYED_STORE_IC) { |
7432 // It's possible that a keyed store of a constant string was converted | 7432 // It's possible that a keyed store of a constant string was converted |
7433 // to a named store. Here, at the last minute, we need to make sure to | 7433 // to a named store. Here, at the last minute, we need to make sure to |
7434 // use a generic Keyed Store if we are using the type vector, because | 7434 // use a generic Keyed Store if we are using the type vector, because |
7435 // it has to share information with full code. | 7435 // it has to share information with full code. |
7436 HConstant* key = Add<HConstant>(name); | 7436 HConstant* key = Add<HConstant>(name); |
7437 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( | 7437 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( |
7438 object, key, value, function_language_mode(), PREMONOMORPHIC); | 7438 object, key, value, function_language_mode(), vector, slot); |
7439 Handle<TypeFeedbackVector> vector = | |
7440 handle(current_feedback_vector(), isolate()); | |
7441 result->SetVectorAndSlot(vector, slot); | |
7442 return result; | 7439 return result; |
7443 } | 7440 } |
7444 | 7441 |
7445 HStoreNamedGeneric* result = New<HStoreNamedGeneric>( | 7442 HStoreNamedGeneric* result = New<HStoreNamedGeneric>( |
7446 object, name, value, function_language_mode(), PREMONOMORPHIC); | 7443 object, name, value, function_language_mode(), vector, slot); |
7447 Handle<TypeFeedbackVector> vector = | |
7448 handle(current_feedback_vector(), isolate()); | |
7449 result->SetVectorAndSlot(vector, slot); | |
7450 return result; | 7444 return result; |
7451 } | 7445 } |
7452 } | 7446 } |
7453 | 7447 |
7454 | 7448 |
7455 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( | 7449 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( |
7456 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, | 7450 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, |
7457 HValue* object, HValue* key, HValue* value) { | 7451 HValue* object, HValue* key, HValue* value) { |
| 7452 Handle<TypeFeedbackVector> vector = |
| 7453 handle(current_feedback_vector(), isolate()); |
7458 if (access_type == LOAD) { | 7454 if (access_type == LOAD) { |
7459 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState(); | |
7460 HLoadKeyedGeneric* result = | 7455 HLoadKeyedGeneric* result = |
7461 New<HLoadKeyedGeneric>(object, key, initial_state); | 7456 New<HLoadKeyedGeneric>(object, key, vector, slot); |
7462 // HLoadKeyedGeneric with vector ics benefits from being encoded as | |
7463 // MEGAMORPHIC because the vector/slot combo becomes unnecessary. | |
7464 if (initial_state != MEGAMORPHIC) { | |
7465 // We need to pass vector information. | |
7466 Handle<TypeFeedbackVector> vector = | |
7467 handle(current_feedback_vector(), isolate()); | |
7468 result->SetVectorAndSlot(vector, slot); | |
7469 } | |
7470 return result; | 7457 return result; |
7471 } else { | 7458 } else { |
7472 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( | 7459 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( |
7473 object, key, value, function_language_mode(), PREMONOMORPHIC); | 7460 object, key, value, function_language_mode(), vector, slot); |
7474 Handle<TypeFeedbackVector> vector = | |
7475 handle(current_feedback_vector(), isolate()); | |
7476 result->SetVectorAndSlot(vector, slot); | |
7477 return result; | 7461 return result; |
7478 } | 7462 } |
7479 } | 7463 } |
7480 | 7464 |
7481 | 7465 |
7482 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { | 7466 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { |
7483 // Loads from a "stock" fast holey double arrays can elide the hole check. | 7467 // Loads from a "stock" fast holey double arrays can elide the hole check. |
7484 // Loads from a "stock" fast holey array can convert the hole to undefined | 7468 // Loads from a "stock" fast holey array can convert the hole to undefined |
7485 // with impunity. | 7469 // with impunity. |
7486 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; | 7470 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
(...skipping 6168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13655 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13639 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
13656 } | 13640 } |
13657 | 13641 |
13658 #ifdef DEBUG | 13642 #ifdef DEBUG |
13659 graph_->Verify(false); // No full verify. | 13643 graph_->Verify(false); // No full verify. |
13660 #endif | 13644 #endif |
13661 } | 13645 } |
13662 | 13646 |
13663 } // namespace internal | 13647 } // namespace internal |
13664 } // namespace v8 | 13648 } // namespace v8 |
OLD | NEW |