OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/compiler/js-create-lowering.h" | 5 #include "src/compiler/js-create-lowering.h" |
6 | 6 |
7 #include "src/allocation-site-scopes.h" | 7 #include "src/allocation-site-scopes.h" |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/compilation-dependencies.h" | 9 #include "src/compilation-dependencies.h" |
10 #include "src/compiler/access-builder.h" | 10 #include "src/compiler/access-builder.h" |
(...skipping 935 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 isolate()); | 946 isolate()); |
947 if (boilerplate_value->IsJSObject()) { | 947 if (boilerplate_value->IsJSObject()) { |
948 Handle<JSObject> boilerplate_object = | 948 Handle<JSObject> boilerplate_object = |
949 Handle<JSObject>::cast(boilerplate_value); | 949 Handle<JSObject>::cast(boilerplate_value); |
950 Handle<AllocationSite> current_site = site_context->EnterNewScope(); | 950 Handle<AllocationSite> current_site = site_context->EnterNewScope(); |
951 value = effect = AllocateFastLiteral(effect, control, | 951 value = effect = AllocateFastLiteral(effect, control, |
952 boilerplate_object, site_context); | 952 boilerplate_object, site_context); |
953 site_context->ExitScope(current_site, boilerplate_object); | 953 site_context->ExitScope(current_site, boilerplate_object); |
954 } else if (property_details.representation().IsDouble()) { | 954 } else if (property_details.representation().IsDouble()) { |
955 // Allocate a mutable HeapNumber box and store the value into it. | 955 // Allocate a mutable HeapNumber box and store the value into it. |
956 value = effect = AllocateMutableHeapNumber( | 956 effect = graph()->NewNode(common()->BeginRegion(), effect); |
957 Handle<HeapNumber>::cast(boilerplate_value)->value(), | 957 value = effect = graph()->NewNode( |
| 958 simplified()->Allocate(NOT_TENURED), |
| 959 jsgraph()->Constant(HeapNumber::kSize), effect, control); |
| 960 effect = graph()->NewNode( |
| 961 simplified()->StoreField(AccessBuilder::ForMap()), value, |
| 962 jsgraph()->HeapConstant(factory()->mutable_heap_number_map()), |
958 effect, control); | 963 effect, control); |
| 964 effect = graph()->NewNode( |
| 965 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), |
| 966 value, jsgraph()->Constant( |
| 967 Handle<HeapNumber>::cast(boilerplate_value)->value()), |
| 968 effect, control); |
| 969 value = effect = |
| 970 graph()->NewNode(common()->FinishRegion(), value, effect); |
959 } else if (property_details.representation().IsSmi()) { | 971 } else if (property_details.representation().IsSmi()) { |
960 // Ensure that value is stored as smi. | 972 // Ensure that value is stored as smi. |
961 value = boilerplate_value->IsUninitialized() | 973 value = boilerplate_value->IsUninitialized() |
962 ? jsgraph()->ZeroConstant() | 974 ? jsgraph()->ZeroConstant() |
963 : jsgraph()->Constant(boilerplate_value); | 975 : jsgraph()->Constant(boilerplate_value); |
964 } else { | 976 } else { |
965 value = jsgraph()->Constant(boilerplate_value); | 977 value = jsgraph()->Constant(boilerplate_value); |
966 } | 978 } |
967 } | 979 } |
968 inobject_fields.push_back(std::make_pair(access, value)); | 980 inobject_fields.push_back(std::make_pair(access, value)); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 ElementAccess const access = | 1081 ElementAccess const access = |
1070 (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) | 1082 (elements_map->instance_type() == FIXED_DOUBLE_ARRAY_TYPE) |
1071 ? AccessBuilder::ForFixedDoubleArrayElement() | 1083 ? AccessBuilder::ForFixedDoubleArrayElement() |
1072 : AccessBuilder::ForFixedArrayElement(); | 1084 : AccessBuilder::ForFixedArrayElement(); |
1073 for (int i = 0; i < elements_length; ++i) { | 1085 for (int i = 0; i < elements_length; ++i) { |
1074 builder.Store(access, jsgraph()->Constant(i), elements_values[i]); | 1086 builder.Store(access, jsgraph()->Constant(i), elements_values[i]); |
1075 } | 1087 } |
1076 return builder.Finish(); | 1088 return builder.Finish(); |
1077 } | 1089 } |
1078 | 1090 |
1079 Node* JSCreateLowering::AllocateMutableHeapNumber(double value, Node* effect, | |
1080 Node* control) { | |
1081 // TODO(turbofan): Support inline allocation of MutableHeapNumber | |
1082 // (requires proper alignment on Allocate, and Begin/FinishRegion). | |
1083 Callable callable = CodeFactory::AllocateMutableHeapNumber(isolate()); | |
1084 CallDescriptor* desc = Linkage::GetStubCallDescriptor( | |
1085 isolate(), jsgraph()->zone(), callable.descriptor(), 0, | |
1086 CallDescriptor::kNoFlags, Operator::kNoThrow); | |
1087 Node* result = effect = graph()->NewNode( | |
1088 common()->Call(desc), jsgraph()->HeapConstant(callable.code()), | |
1089 jsgraph()->NoContextConstant(), effect, control); | |
1090 effect = graph()->NewNode( | |
1091 simplified()->StoreField(AccessBuilder::ForHeapNumberValue()), result, | |
1092 jsgraph()->Constant(value), effect, control); | |
1093 return result; | |
1094 } | |
1095 | |
1096 MaybeHandle<LiteralsArray> JSCreateLowering::GetSpecializationLiterals( | 1091 MaybeHandle<LiteralsArray> JSCreateLowering::GetSpecializationLiterals( |
1097 Node* node) { | 1092 Node* node) { |
1098 Node* const closure = NodeProperties::GetValueInput(node, 0); | 1093 Node* const closure = NodeProperties::GetValueInput(node, 0); |
1099 switch (closure->opcode()) { | 1094 switch (closure->opcode()) { |
1100 case IrOpcode::kHeapConstant: { | 1095 case IrOpcode::kHeapConstant: { |
1101 Handle<HeapObject> object = OpParameter<Handle<HeapObject>>(closure); | 1096 Handle<HeapObject> object = OpParameter<Handle<HeapObject>>(closure); |
1102 return handle(Handle<JSFunction>::cast(object)->literals()); | 1097 return handle(Handle<JSFunction>::cast(object)->literals()); |
1103 } | 1098 } |
1104 case IrOpcode::kParameter: { | 1099 case IrOpcode::kParameter: { |
1105 int const index = ParameterIndexOf(closure->op()); | 1100 int const index = ParameterIndexOf(closure->op()); |
(...skipping 29 matching lines...) Expand all Loading... |
1135 return jsgraph()->simplified(); | 1130 return jsgraph()->simplified(); |
1136 } | 1131 } |
1137 | 1132 |
1138 MachineOperatorBuilder* JSCreateLowering::machine() const { | 1133 MachineOperatorBuilder* JSCreateLowering::machine() const { |
1139 return jsgraph()->machine(); | 1134 return jsgraph()->machine(); |
1140 } | 1135 } |
1141 | 1136 |
1142 } // namespace compiler | 1137 } // namespace compiler |
1143 } // namespace internal | 1138 } // namespace internal |
1144 } // namespace v8 | 1139 } // namespace v8 |
OLD | NEW |