| 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 <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 5876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5887 Add<HConstant>(constant_properties), | 5887 Add<HConstant>(constant_properties), |
| 5888 Add<HConstant>(flags)); | 5888 Add<HConstant>(flags)); |
| 5889 | 5889 |
| 5890 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; | 5890 Runtime::FunctionId function_id = Runtime::kCreateObjectLiteral; |
| 5891 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); | 5891 literal = Add<HCallRuntime>(Runtime::FunctionForId(function_id), 4); |
| 5892 } | 5892 } |
| 5893 | 5893 |
| 5894 // The object is expected in the bailout environment during computation | 5894 // The object is expected in the bailout environment during computation |
| 5895 // of the property values and is the value of the entire expression. | 5895 // of the property values and is the value of the entire expression. |
| 5896 Push(literal); | 5896 Push(literal); |
| 5897 int store_slot_index = 0; | |
| 5898 for (int i = 0; i < expr->properties()->length(); i++) { | 5897 for (int i = 0; i < expr->properties()->length(); i++) { |
| 5899 ObjectLiteral::Property* property = expr->properties()->at(i); | 5898 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 5900 if (property->is_computed_name()) return Bailout(kComputedPropertyName); | 5899 if (property->is_computed_name()) return Bailout(kComputedPropertyName); |
| 5901 if (property->IsCompileTimeValue()) continue; | 5900 if (property->IsCompileTimeValue()) continue; |
| 5902 | 5901 |
| 5903 Literal* key = property->key()->AsLiteral(); | 5902 Literal* key = property->key()->AsLiteral(); |
| 5904 Expression* value = property->value(); | 5903 Expression* value = property->value(); |
| 5905 | 5904 |
| 5906 switch (property->kind()) { | 5905 switch (property->kind()) { |
| 5907 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 5906 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 5908 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); | 5907 DCHECK(!CompileTimeValue::IsCompileTimeValue(value)); |
| 5909 // Fall through. | 5908 // Fall through. |
| 5910 case ObjectLiteral::Property::COMPUTED: | 5909 case ObjectLiteral::Property::COMPUTED: |
| 5911 // It is safe to use [[Put]] here because the boilerplate already | 5910 // It is safe to use [[Put]] here because the boilerplate already |
| 5912 // contains computed properties with an uninitialized value. | 5911 // contains computed properties with an uninitialized value. |
| 5913 if (key->value()->IsInternalizedString()) { | 5912 if (key->value()->IsInternalizedString()) { |
| 5914 if (property->emit_store()) { | 5913 if (property->emit_store()) { |
| 5915 CHECK_ALIVE(VisitForValue(value)); | 5914 CHECK_ALIVE(VisitForValue(value)); |
| 5916 HValue* value = Pop(); | 5915 HValue* value = Pop(); |
| 5917 | 5916 |
| 5918 Handle<Map> map = property->GetReceiverType(); | 5917 Handle<Map> map = property->GetReceiverType(); |
| 5919 Handle<String> name = key->AsPropertyName(); | 5918 Handle<String> name = key->AsPropertyName(); |
| 5920 HValue* store; | 5919 HValue* store; |
| 5921 FeedbackVectorICSlot slot = expr->GetNthSlot(store_slot_index++); | 5920 FeedbackVectorICSlot slot = property->GetSlot(); |
| 5922 if (map.is_null()) { | 5921 if (map.is_null()) { |
| 5923 // If we don't know the monomorphic type, do a generic store. | 5922 // If we don't know the monomorphic type, do a generic store. |
| 5924 CHECK_ALIVE(store = BuildNamedGeneric(STORE, NULL, slot, literal, | 5923 CHECK_ALIVE(store = BuildNamedGeneric(STORE, NULL, slot, literal, |
| 5925 name, value)); | 5924 name, value)); |
| 5926 } else { | 5925 } else { |
| 5927 PropertyAccessInfo info(this, STORE, map, name); | 5926 PropertyAccessInfo info(this, STORE, map, name); |
| 5928 if (info.CanAccessMonomorphic()) { | 5927 if (info.CanAccessMonomorphic()) { |
| 5929 HValue* checked_literal = Add<HCheckMaps>(literal, map); | 5928 HValue* checked_literal = Add<HCheckMaps>(literal, map); |
| 5930 DCHECK(!info.IsAccessorConstant()); | 5929 DCHECK(!info.IsAccessorConstant()); |
| 5931 store = BuildMonomorphicAccess( | 5930 store = BuildMonomorphicAccess( |
| 5932 &info, literal, checked_literal, value, | 5931 &info, literal, checked_literal, value, |
| 5933 BailoutId::None(), BailoutId::None()); | 5932 BailoutId::None(), BailoutId::None()); |
| 5934 } else { | 5933 } else { |
| 5935 CHECK_ALIVE(store = BuildNamedGeneric(STORE, NULL, slot, | 5934 CHECK_ALIVE(store = BuildNamedGeneric(STORE, NULL, slot, |
| 5936 literal, name, value)); | 5935 literal, name, value)); |
| 5937 } | 5936 } |
| 5938 } | 5937 } |
| 5939 if (store->IsInstruction()) { | 5938 if (store->IsInstruction()) { |
| 5940 AddInstruction(HInstruction::cast(store)); | 5939 AddInstruction(HInstruction::cast(store)); |
| 5941 } | 5940 } |
| 5942 DCHECK(store->HasObservableSideEffects()); | 5941 DCHECK(store->HasObservableSideEffects()); |
| 5943 Add<HSimulate>(key->id(), REMOVABLE_SIMULATE); | 5942 Add<HSimulate>(key->id(), REMOVABLE_SIMULATE); |
| 5944 | 5943 |
| 5945 // Add [[HomeObject]] to function literals. | 5944 // Add [[HomeObject]] to function literals. |
| 5946 if (FunctionLiteral::NeedsHomeObject(property->value())) { | 5945 if (FunctionLiteral::NeedsHomeObject(property->value())) { |
| 5947 Handle<Symbol> sym = isolate()->factory()->home_object_symbol(); | 5946 Handle<Symbol> sym = isolate()->factory()->home_object_symbol(); |
| 5948 HInstruction* store_home = BuildNamedGeneric( | 5947 HInstruction* store_home = BuildNamedGeneric( |
| 5949 STORE, NULL, expr->GetNthSlot(store_slot_index++), value, sym, | 5948 STORE, NULL, property->GetSlot(1), value, sym, literal); |
| 5950 literal); | |
| 5951 AddInstruction(store_home); | 5949 AddInstruction(store_home); |
| 5952 DCHECK(store_home->HasObservableSideEffects()); | 5950 DCHECK(store_home->HasObservableSideEffects()); |
| 5953 Add<HSimulate>(property->value()->id(), REMOVABLE_SIMULATE); | 5951 Add<HSimulate>(property->value()->id(), REMOVABLE_SIMULATE); |
| 5954 } | 5952 } |
| 5955 } else { | 5953 } else { |
| 5956 CHECK_ALIVE(VisitForEffect(value)); | 5954 CHECK_ALIVE(VisitForEffect(value)); |
| 5957 } | 5955 } |
| 5958 break; | 5956 break; |
| 5959 } | 5957 } |
| 5960 // Fall through. | 5958 // Fall through. |
| 5961 case ObjectLiteral::Property::PROTOTYPE: | 5959 case ObjectLiteral::Property::PROTOTYPE: |
| 5962 case ObjectLiteral::Property::SETTER: | 5960 case ObjectLiteral::Property::SETTER: |
| 5963 case ObjectLiteral::Property::GETTER: | 5961 case ObjectLiteral::Property::GETTER: |
| 5964 return Bailout(kObjectLiteralWithComplexProperty); | 5962 return Bailout(kObjectLiteralWithComplexProperty); |
| 5965 default: UNREACHABLE(); | 5963 default: UNREACHABLE(); |
| 5966 } | 5964 } |
| 5967 } | 5965 } |
| 5968 | 5966 |
| 5969 // Crankshaft may not consume all the slots because it doesn't emit accessors. | |
| 5970 DCHECK(!FLAG_vector_stores || store_slot_index <= expr->slot_count()); | |
| 5971 | |
| 5972 if (expr->has_function()) { | 5967 if (expr->has_function()) { |
| 5973 // Return the result of the transformation to fast properties | 5968 // Return the result of the transformation to fast properties |
| 5974 // instead of the original since this operation changes the map | 5969 // instead of the original since this operation changes the map |
| 5975 // of the object. This makes sure that the original object won't | 5970 // of the object. This makes sure that the original object won't |
| 5976 // be used by other optimized code before it is transformed | 5971 // be used by other optimized code before it is transformed |
| 5977 // (e.g. because of code motion). | 5972 // (e.g. because of code motion). |
| 5978 HToFastProperties* result = Add<HToFastProperties>(Pop()); | 5973 HToFastProperties* result = Add<HToFastProperties>(Pop()); |
| 5979 return ast_context()->ReturnValue(result); | 5974 return ast_context()->ReturnValue(result); |
| 5980 } else { | 5975 } else { |
| 5981 return ast_context()->ReturnValue(Pop()); | 5976 return ast_context()->ReturnValue(Pop()); |
| (...skipping 7575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 13557 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); | 13552 isolate()->GetHTracer()->TraceHydrogen(name(), graph_); |
| 13558 } | 13553 } |
| 13559 | 13554 |
| 13560 #ifdef DEBUG | 13555 #ifdef DEBUG |
| 13561 graph_->Verify(false); // No full verify. | 13556 graph_->Verify(false); // No full verify. |
| 13562 #endif | 13557 #endif |
| 13563 } | 13558 } |
| 13564 | 13559 |
| 13565 } // namespace internal | 13560 } // namespace internal |
| 13566 } // namespace v8 | 13561 } // namespace v8 |
| OLD | NEW |