| 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-numbering.h" | 10 #include "src/ast-numbering.h" |
| (...skipping 6920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6931 if (instr->HasObservableSideEffects()) { | 6931 if (instr->HasObservableSideEffects()) { |
| 6932 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6932 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6933 } | 6933 } |
| 6934 } else { | 6934 } else { |
| 6935 HValue* global_object = Add<HLoadNamedField>( | 6935 HValue* global_object = Add<HLoadNamedField>( |
| 6936 context(), nullptr, | 6936 context(), nullptr, |
| 6937 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); | 6937 HObjectAccess::ForContextSlot(Context::GLOBAL_OBJECT_INDEX)); |
| 6938 HStoreNamedGeneric* instr = | 6938 HStoreNamedGeneric* instr = |
| 6939 Add<HStoreNamedGeneric>(global_object, var->name(), value, | 6939 Add<HStoreNamedGeneric>(global_object, var->name(), value, |
| 6940 function_language_mode(), PREMONOMORPHIC); | 6940 function_language_mode(), PREMONOMORPHIC); |
| 6941 if (FLAG_vector_stores) { | 6941 Handle<TypeFeedbackVector> vector = |
| 6942 Handle<TypeFeedbackVector> vector = | 6942 handle(current_feedback_vector(), isolate()); |
| 6943 handle(current_feedback_vector(), isolate()); | 6943 instr->SetVectorAndSlot(vector, slot); |
| 6944 instr->SetVectorAndSlot(vector, slot); | |
| 6945 } | |
| 6946 USE(instr); | 6944 USE(instr); |
| 6947 DCHECK(instr->HasObservableSideEffects()); | 6945 DCHECK(instr->HasObservableSideEffects()); |
| 6948 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6946 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6949 } | 6947 } |
| 6950 } | 6948 } |
| 6951 | 6949 |
| 6952 | 6950 |
| 6953 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { | 6951 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
| 6954 Expression* target = expr->target(); | 6952 Expression* target = expr->target(); |
| 6955 VariableProxy* proxy = target->AsVariableProxy(); | 6953 VariableProxy* proxy = target->AsVariableProxy(); |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7264 object, key, function_language_mode(), PREMONOMORPHIC); | 7262 object, key, function_language_mode(), PREMONOMORPHIC); |
| 7265 result->SetVectorAndSlot(vector, slot); | 7263 result->SetVectorAndSlot(vector, slot); |
| 7266 return result; | 7264 return result; |
| 7267 } | 7265 } |
| 7268 | 7266 |
| 7269 HLoadNamedGeneric* result = New<HLoadNamedGeneric>( | 7267 HLoadNamedGeneric* result = New<HLoadNamedGeneric>( |
| 7270 object, name, function_language_mode(), PREMONOMORPHIC); | 7268 object, name, function_language_mode(), PREMONOMORPHIC); |
| 7271 result->SetVectorAndSlot(vector, slot); | 7269 result->SetVectorAndSlot(vector, slot); |
| 7272 return result; | 7270 return result; |
| 7273 } else { | 7271 } else { |
| 7274 if (FLAG_vector_stores && | 7272 if (current_feedback_vector()->GetKind(slot) == |
| 7275 current_feedback_vector()->GetKind(slot) == | 7273 FeedbackVectorSlotKind::KEYED_STORE_IC) { |
| 7276 FeedbackVectorSlotKind::KEYED_STORE_IC) { | |
| 7277 // It's possible that a keyed store of a constant string was converted | 7274 // It's possible that a keyed store of a constant string was converted |
| 7278 // to a named store. Here, at the last minute, we need to make sure to | 7275 // to a named store. Here, at the last minute, we need to make sure to |
| 7279 // use a generic Keyed Store if we are using the type vector, because | 7276 // use a generic Keyed Store if we are using the type vector, because |
| 7280 // it has to share information with full code. | 7277 // it has to share information with full code. |
| 7281 HConstant* key = Add<HConstant>(name); | 7278 HConstant* key = Add<HConstant>(name); |
| 7282 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( | 7279 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( |
| 7283 object, key, value, function_language_mode(), PREMONOMORPHIC); | 7280 object, key, value, function_language_mode(), PREMONOMORPHIC); |
| 7284 Handle<TypeFeedbackVector> vector = | 7281 Handle<TypeFeedbackVector> vector = |
| 7285 handle(current_feedback_vector(), isolate()); | 7282 handle(current_feedback_vector(), isolate()); |
| 7286 result->SetVectorAndSlot(vector, slot); | 7283 result->SetVectorAndSlot(vector, slot); |
| 7287 return result; | 7284 return result; |
| 7288 } | 7285 } |
| 7289 | 7286 |
| 7290 HStoreNamedGeneric* result = New<HStoreNamedGeneric>( | 7287 HStoreNamedGeneric* result = New<HStoreNamedGeneric>( |
| 7291 object, name, value, function_language_mode(), PREMONOMORPHIC); | 7288 object, name, value, function_language_mode(), PREMONOMORPHIC); |
| 7292 if (FLAG_vector_stores) { | 7289 Handle<TypeFeedbackVector> vector = |
| 7293 Handle<TypeFeedbackVector> vector = | 7290 handle(current_feedback_vector(), isolate()); |
| 7294 handle(current_feedback_vector(), isolate()); | 7291 result->SetVectorAndSlot(vector, slot); |
| 7295 result->SetVectorAndSlot(vector, slot); | |
| 7296 } | |
| 7297 return result; | 7292 return result; |
| 7298 } | 7293 } |
| 7299 } | 7294 } |
| 7300 | 7295 |
| 7301 | 7296 |
| 7302 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( | 7297 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( |
| 7303 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, | 7298 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, |
| 7304 HValue* object, HValue* key, HValue* value) { | 7299 HValue* object, HValue* key, HValue* value) { |
| 7305 if (access_type == LOAD) { | 7300 if (access_type == LOAD) { |
| 7306 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState(); | 7301 InlineCacheState initial_state = expr->AsProperty()->GetInlineCacheState(); |
| 7307 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>( | 7302 HLoadKeyedGeneric* result = New<HLoadKeyedGeneric>( |
| 7308 object, key, function_language_mode(), initial_state); | 7303 object, key, function_language_mode(), initial_state); |
| 7309 // HLoadKeyedGeneric with vector ics benefits from being encoded as | 7304 // HLoadKeyedGeneric with vector ics benefits from being encoded as |
| 7310 // MEGAMORPHIC because the vector/slot combo becomes unnecessary. | 7305 // MEGAMORPHIC because the vector/slot combo becomes unnecessary. |
| 7311 if (initial_state != MEGAMORPHIC) { | 7306 if (initial_state != MEGAMORPHIC) { |
| 7312 // We need to pass vector information. | 7307 // We need to pass vector information. |
| 7313 Handle<TypeFeedbackVector> vector = | 7308 Handle<TypeFeedbackVector> vector = |
| 7314 handle(current_feedback_vector(), isolate()); | 7309 handle(current_feedback_vector(), isolate()); |
| 7315 result->SetVectorAndSlot(vector, slot); | 7310 result->SetVectorAndSlot(vector, slot); |
| 7316 } | 7311 } |
| 7317 return result; | 7312 return result; |
| 7318 } else { | 7313 } else { |
| 7319 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( | 7314 HStoreKeyedGeneric* result = New<HStoreKeyedGeneric>( |
| 7320 object, key, value, function_language_mode(), PREMONOMORPHIC); | 7315 object, key, value, function_language_mode(), PREMONOMORPHIC); |
| 7321 if (FLAG_vector_stores) { | 7316 Handle<TypeFeedbackVector> vector = |
| 7322 Handle<TypeFeedbackVector> vector = | 7317 handle(current_feedback_vector(), isolate()); |
| 7323 handle(current_feedback_vector(), isolate()); | 7318 result->SetVectorAndSlot(vector, slot); |
| 7324 result->SetVectorAndSlot(vector, slot); | |
| 7325 } | |
| 7326 return result; | 7319 return result; |
| 7327 } | 7320 } |
| 7328 } | 7321 } |
| 7329 | 7322 |
| 7330 | 7323 |
| 7331 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { | 7324 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { |
| 7332 // Loads from a "stock" fast holey double arrays can elide the hole check. | 7325 // Loads from a "stock" fast holey double arrays can elide the hole check. |
| 7333 // Loads from a "stock" fast holey array can convert the hole to undefined | 7326 // Loads from a "stock" fast holey array can convert the hole to undefined |
| 7334 // with impunity. | 7327 // with impunity. |
| 7335 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; | 7328 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7633 PropertyAccessType access_type, bool* has_side_effects) { | 7626 PropertyAccessType access_type, bool* has_side_effects) { |
| 7634 // A keyed name access with type feedback may contain the name. | 7627 // A keyed name access with type feedback may contain the name. |
| 7635 Handle<TypeFeedbackVector> vector = | 7628 Handle<TypeFeedbackVector> vector = |
| 7636 handle(current_feedback_vector(), isolate()); | 7629 handle(current_feedback_vector(), isolate()); |
| 7637 HValue* expected_key = key; | 7630 HValue* expected_key = key; |
| 7638 if (!key->ActualValue()->IsConstant()) { | 7631 if (!key->ActualValue()->IsConstant()) { |
| 7639 Name* name = nullptr; | 7632 Name* name = nullptr; |
| 7640 if (access_type == LOAD) { | 7633 if (access_type == LOAD) { |
| 7641 KeyedLoadICNexus nexus(vector, slot); | 7634 KeyedLoadICNexus nexus(vector, slot); |
| 7642 name = nexus.FindFirstName(); | 7635 name = nexus.FindFirstName(); |
| 7643 } else if (FLAG_vector_stores) { | 7636 } else { |
| 7644 KeyedStoreICNexus nexus(vector, slot); | 7637 KeyedStoreICNexus nexus(vector, slot); |
| 7645 name = nexus.FindFirstName(); | 7638 name = nexus.FindFirstName(); |
| 7646 } | 7639 } |
| 7647 if (name != nullptr) { | 7640 if (name != nullptr) { |
| 7648 Handle<Name> handle_name(name); | 7641 Handle<Name> handle_name(name); |
| 7649 expected_key = Add<HConstant>(handle_name); | 7642 expected_key = Add<HConstant>(handle_name); |
| 7650 // We need a check against the key. | 7643 // We need a check against the key. |
| 7651 bool in_new_space = isolate()->heap()->InNewSpace(*handle_name); | 7644 bool in_new_space = isolate()->heap()->InNewSpace(*handle_name); |
| 7652 Unique<Name> unique_name = Unique<Name>::CreateUninitialized(handle_name); | 7645 Unique<Name> unique_name = Unique<Name>::CreateUninitialized(handle_name); |
| 7653 Add<HCheckValue>(key, unique_name, in_new_space); | 7646 Add<HCheckValue>(key, unique_name, in_new_space); |
| (...skipping 5983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13637 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13630 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13638 } | 13631 } |
| 13639 | 13632 |
| 13640 #ifdef DEBUG | 13633 #ifdef DEBUG |
| 13641 graph_->Verify(false); // No full verify. | 13634 graph_->Verify(false); // No full verify. |
| 13642 #endif | 13635 #endif |
| 13643 } | 13636 } |
| 13644 | 13637 |
| 13645 } // namespace internal | 13638 } // namespace internal |
| 13646 } // namespace v8 | 13639 } // namespace v8 |
| OLD | NEW |