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