| 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 <memory> | 7 #include <memory> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 | 9 |
| 10 #include "src/allocation-site-scopes.h" | 10 #include "src/allocation-site-scopes.h" |
| (...skipping 5580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5591 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); | 5591 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
| 5592 | 5592 |
| 5593 HValue* vector_value = Add<HConstant>(vector); | 5593 HValue* vector_value = Add<HConstant>(vector); |
| 5594 HValue* slot_value = | 5594 HValue* slot_value = |
| 5595 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); | 5595 Add<HConstant>(vector->GetIndex(expr->VariableFeedbackSlot())); |
| 5596 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( | 5596 Callable callable = CodeFactory::LoadGlobalICInOptimizedCode( |
| 5597 isolate(), ast_context()->typeof_mode()); | 5597 isolate(), ast_context()->typeof_mode()); |
| 5598 HValue* stub = Add<HConstant>(callable.code()); | 5598 HValue* stub = Add<HConstant>(callable.code()); |
| 5599 HValue* values[] = {slot_value, vector_value}; | 5599 HValue* values[] = {slot_value, vector_value}; |
| 5600 HCallWithDescriptor* instr = New<HCallWithDescriptor>( | 5600 HCallWithDescriptor* instr = New<HCallWithDescriptor>( |
| 5601 stub, 0, callable.descriptor(), ArrayVector(values)); | 5601 Code::LOAD_GLOBAL_IC, stub, 0, callable.descriptor(), |
| 5602 ArrayVector(values)); |
| 5602 return ast_context()->ReturnInstruction(instr, expr->id()); | 5603 return ast_context()->ReturnInstruction(instr, expr->id()); |
| 5603 } | 5604 } |
| 5604 } | 5605 } |
| 5605 | 5606 |
| 5606 case VariableLocation::PARAMETER: | 5607 case VariableLocation::PARAMETER: |
| 5607 case VariableLocation::LOCAL: { | 5608 case VariableLocation::LOCAL: { |
| 5608 HValue* value = LookupAndMakeLive(variable); | 5609 HValue* value = LookupAndMakeLive(variable); |
| 5609 if (value == graph()->GetConstantHole()) { | 5610 if (value == graph()->GetConstantHole()) { |
| 5610 DCHECK(IsDeclaredVariableMode(variable->mode()) && | 5611 DCHECK(IsDeclaredVariableMode(variable->mode()) && |
| 5611 variable->mode() != VAR); | 5612 variable->mode() != VAR); |
| (...skipping 1177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6789 Handle<TypeFeedbackVector> vector = | 6790 Handle<TypeFeedbackVector> vector = |
| 6790 handle(current_feedback_vector(), isolate()); | 6791 handle(current_feedback_vector(), isolate()); |
| 6791 HValue* name = Add<HConstant>(var->name()); | 6792 HValue* name = Add<HConstant>(var->name()); |
| 6792 HValue* vector_value = Add<HConstant>(vector); | 6793 HValue* vector_value = Add<HConstant>(vector); |
| 6793 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); | 6794 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); |
| 6794 Callable callable = CodeFactory::StoreICInOptimizedCode( | 6795 Callable callable = CodeFactory::StoreICInOptimizedCode( |
| 6795 isolate(), function_language_mode()); | 6796 isolate(), function_language_mode()); |
| 6796 HValue* stub = Add<HConstant>(callable.code()); | 6797 HValue* stub = Add<HConstant>(callable.code()); |
| 6797 HValue* values[] = {global_object, name, value, slot_value, vector_value}; | 6798 HValue* values[] = {global_object, name, value, slot_value, vector_value}; |
| 6798 HCallWithDescriptor* instr = Add<HCallWithDescriptor>( | 6799 HCallWithDescriptor* instr = Add<HCallWithDescriptor>( |
| 6799 stub, 0, callable.descriptor(), ArrayVector(values)); | 6800 Code::STORE_IC, stub, 0, callable.descriptor(), ArrayVector(values)); |
| 6800 USE(instr); | 6801 USE(instr); |
| 6801 DCHECK(instr->HasObservableSideEffects()); | 6802 DCHECK(instr->HasObservableSideEffects()); |
| 6802 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); | 6803 Add<HSimulate>(ast_id, REMOVABLE_SIMULATE); |
| 6803 } | 6804 } |
| 6804 } | 6805 } |
| 6805 | 6806 |
| 6806 | 6807 |
| 6807 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { | 6808 void HOptimizedGraphBuilder::HandleCompoundAssignment(Assignment* expr) { |
| 6808 Expression* target = expr->target(); | 6809 Expression* target = expr->target(); |
| 6809 VariableProxy* proxy = target->AsVariableProxy(); | 6810 VariableProxy* proxy = target->AsVariableProxy(); |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7101 HValue* vector_value = Add<HConstant>(vector); | 7102 HValue* vector_value = Add<HConstant>(vector); |
| 7102 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); | 7103 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); |
| 7103 | 7104 |
| 7104 if (access_type == LOAD) { | 7105 if (access_type == LOAD) { |
| 7105 HValue* values[] = {object, key, slot_value, vector_value}; | 7106 HValue* values[] = {object, key, slot_value, vector_value}; |
| 7106 if (!expr->AsProperty()->key()->IsPropertyName()) { | 7107 if (!expr->AsProperty()->key()->IsPropertyName()) { |
| 7107 // It's possible that a keyed load of a constant string was converted | 7108 // It's possible that a keyed load of a constant string was converted |
| 7108 // to a named load. Here, at the last minute, we need to make sure to | 7109 // to a named load. Here, at the last minute, we need to make sure to |
| 7109 // use a generic Keyed Load if we are using the type vector, because | 7110 // use a generic Keyed Load if we are using the type vector, because |
| 7110 // it has to share information with full code. | 7111 // it has to share information with full code. |
| 7111 HLoadKeyedGeneric* result = | 7112 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); |
| 7112 New<HLoadKeyedGeneric>(object, key, vector, slot); | 7113 HValue* stub = Add<HConstant>(callable.code()); |
| 7114 HCallWithDescriptor* result = |
| 7115 New<HCallWithDescriptor>(Code::KEYED_LOAD_IC, stub, 0, |
| 7116 callable.descriptor(), ArrayVector(values)); |
| 7113 return result; | 7117 return result; |
| 7114 } | 7118 } |
| 7115 | |
| 7116 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); | 7119 Callable callable = CodeFactory::LoadICInOptimizedCode(isolate()); |
| 7117 HValue* stub = Add<HConstant>(callable.code()); | 7120 HValue* stub = Add<HConstant>(callable.code()); |
| 7118 HCallWithDescriptor* result = New<HCallWithDescriptor>( | 7121 HCallWithDescriptor* result = New<HCallWithDescriptor>( |
| 7119 stub, 0, callable.descriptor(), ArrayVector(values)); | 7122 Code::LOAD_IC, stub, 0, callable.descriptor(), ArrayVector(values)); |
| 7120 return result; | 7123 return result; |
| 7121 | 7124 |
| 7122 } else { | 7125 } else { |
| 7123 HValue* values[] = {object, key, value, slot_value, vector_value}; | 7126 HValue* values[] = {object, key, value, slot_value, vector_value}; |
| 7124 if (vector->GetKind(slot) == FeedbackVectorSlotKind::KEYED_STORE_IC) { | 7127 if (vector->GetKind(slot) == FeedbackVectorSlotKind::KEYED_STORE_IC) { |
| 7125 // It's possible that a keyed store of a constant string was converted | 7128 // It's possible that a keyed store of a constant string was converted |
| 7126 // to a named store. Here, at the last minute, we need to make sure to | 7129 // to a named store. Here, at the last minute, we need to make sure to |
| 7127 // use a generic Keyed Store if we are using the type vector, because | 7130 // use a generic Keyed Store if we are using the type vector, because |
| 7128 // it has to share information with full code. | 7131 // it has to share information with full code. |
| 7129 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( | 7132 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( |
| 7130 isolate(), function_language_mode()); | 7133 isolate(), function_language_mode()); |
| 7131 HValue* stub = Add<HConstant>(callable.code()); | 7134 HValue* stub = Add<HConstant>(callable.code()); |
| 7132 HCallWithDescriptor* result = New<HCallWithDescriptor>( | 7135 HCallWithDescriptor* result = |
| 7133 stub, 0, callable.descriptor(), ArrayVector(values)); | 7136 New<HCallWithDescriptor>(Code::KEYED_STORE_IC, stub, 0, |
| 7137 callable.descriptor(), ArrayVector(values)); |
| 7134 return result; | 7138 return result; |
| 7135 } | 7139 } |
| 7136 Callable callable = CodeFactory::StoreICInOptimizedCode( | 7140 Callable callable = CodeFactory::StoreICInOptimizedCode( |
| 7137 isolate(), function_language_mode()); | 7141 isolate(), function_language_mode()); |
| 7138 HValue* stub = Add<HConstant>(callable.code()); | 7142 HValue* stub = Add<HConstant>(callable.code()); |
| 7139 HCallWithDescriptor* result = New<HCallWithDescriptor>( | 7143 HCallWithDescriptor* result = New<HCallWithDescriptor>( |
| 7140 stub, 0, callable.descriptor(), ArrayVector(values)); | 7144 Code::STORE_IC, stub, 0, callable.descriptor(), ArrayVector(values)); |
| 7141 return result; | 7145 return result; |
| 7142 } | 7146 } |
| 7143 } | 7147 } |
| 7144 | 7148 |
| 7145 | 7149 |
| 7146 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( | 7150 HInstruction* HOptimizedGraphBuilder::BuildKeyedGeneric( |
| 7147 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, | 7151 PropertyAccessType access_type, Expression* expr, FeedbackVectorSlot slot, |
| 7148 HValue* object, HValue* key, HValue* value) { | 7152 HValue* object, HValue* key, HValue* value) { |
| 7149 Handle<TypeFeedbackVector> vector = | 7153 Handle<TypeFeedbackVector> vector(current_feedback_vector(), isolate()); |
| 7150 handle(current_feedback_vector(), isolate()); | 7154 HValue* vector_value = Add<HConstant>(vector); |
| 7155 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); |
| 7156 |
| 7151 if (access_type == LOAD) { | 7157 if (access_type == LOAD) { |
| 7152 HLoadKeyedGeneric* result = | 7158 HValue* values[] = {object, key, slot_value, vector_value}; |
| 7153 New<HLoadKeyedGeneric>(object, key, vector, slot); | 7159 |
| 7160 Callable callable = CodeFactory::KeyedLoadICInOptimizedCode(isolate()); |
| 7161 HValue* stub = Add<HConstant>(callable.code()); |
| 7162 HCallWithDescriptor* result = |
| 7163 New<HCallWithDescriptor>(Code::KEYED_LOAD_IC, stub, 0, |
| 7164 callable.descriptor(), ArrayVector(values)); |
| 7154 return result; | 7165 return result; |
| 7155 } else { | 7166 } else { |
| 7156 HValue* vector_value = Add<HConstant>(vector); | |
| 7157 HValue* slot_value = Add<HConstant>(vector->GetIndex(slot)); | |
| 7158 HValue* values[] = {object, key, value, slot_value, vector_value}; | 7167 HValue* values[] = {object, key, value, slot_value, vector_value}; |
| 7159 | 7168 |
| 7160 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( | 7169 Callable callable = CodeFactory::KeyedStoreICInOptimizedCode( |
| 7161 isolate(), function_language_mode()); | 7170 isolate(), function_language_mode()); |
| 7162 HValue* stub = Add<HConstant>(callable.code()); | 7171 HValue* stub = Add<HConstant>(callable.code()); |
| 7163 HCallWithDescriptor* result = New<HCallWithDescriptor>( | 7172 HCallWithDescriptor* result = |
| 7164 stub, 0, callable.descriptor(), ArrayVector(values)); | 7173 New<HCallWithDescriptor>(Code::KEYED_STORE_IC, stub, 0, |
| 7174 callable.descriptor(), ArrayVector(values)); |
| 7165 return result; | 7175 return result; |
| 7166 } | 7176 } |
| 7167 } | 7177 } |
| 7168 | 7178 |
| 7169 | 7179 |
| 7170 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { | 7180 LoadKeyedHoleMode HOptimizedGraphBuilder::BuildKeyedHoleMode(Handle<Map> map) { |
| 7171 // Loads from a "stock" fast holey double arrays can elide the hole check. | 7181 // Loads from a "stock" fast holey double arrays can elide the hole check. |
| 7172 // Loads from a "stock" fast holey array can convert the hole to undefined | 7182 // Loads from a "stock" fast holey array can convert the hole to undefined |
| 7173 // with impunity. | 7183 // with impunity. |
| 7174 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; | 7184 LoadKeyedHoleMode load_mode = NEVER_RETURN_HOLE; |
| (...skipping 6102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13277 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13287 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13278 } | 13288 } |
| 13279 | 13289 |
| 13280 #ifdef DEBUG | 13290 #ifdef DEBUG |
| 13281 graph_->Verify(false); // No full verify. | 13291 graph_->Verify(false); // No full verify. |
| 13282 #endif | 13292 #endif |
| 13283 } | 13293 } |
| 13284 | 13294 |
| 13285 } // namespace internal | 13295 } // namespace internal |
| 13286 } // namespace v8 | 13296 } // namespace v8 |
| OLD | NEW |