| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/flow_graph_builder.h" | 5 #include "vm/flow_graph_builder.h" |
| 6 | 6 |
| 7 #include "vm/ast_printer.h" | 7 #include "vm/ast_printer.h" |
| 8 #include "vm/code_descriptors.h" | 8 #include "vm/code_descriptors.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| (...skipping 1643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1654 InlineBailout("EffectGraphVisitor::VisitArgumentDefinitionTestNode"); | 1654 InlineBailout("EffectGraphVisitor::VisitArgumentDefinitionTestNode"); |
| 1655 Definition* load = BuildLoadLocal(node->saved_arguments_descriptor()); | 1655 Definition* load = BuildLoadLocal(node->saved_arguments_descriptor()); |
| 1656 Value* arguments_descriptor = Bind(load); | 1656 Value* arguments_descriptor = Bind(load); |
| 1657 ArgumentDefinitionTestInstr* arg_def_test = | 1657 ArgumentDefinitionTestInstr* arg_def_test = |
| 1658 new ArgumentDefinitionTestInstr(node, arguments_descriptor); | 1658 new ArgumentDefinitionTestInstr(node, arguments_descriptor); |
| 1659 ReturnDefinition(arg_def_test); | 1659 ReturnDefinition(arg_def_test); |
| 1660 } | 1660 } |
| 1661 | 1661 |
| 1662 | 1662 |
| 1663 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { | 1663 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { |
| 1664 // Translate the array elements and collect their values. | |
| 1665 ZoneGrowableArray<PushArgumentInstr*>* arguments = | |
| 1666 new ZoneGrowableArray<PushArgumentInstr*>(node->length()); | |
| 1667 for (int i = 0; i < node->length(); ++i) { | |
| 1668 ValueGraphVisitor for_value(owner(), temp_index()); | |
| 1669 node->ElementAt(i)->Visit(&for_value); | |
| 1670 Append(for_value); | |
| 1671 arguments->Add(PushArgument(for_value.value())); | |
| 1672 } | |
| 1673 const AbstractTypeArguments& type_args = | 1664 const AbstractTypeArguments& type_args = |
| 1674 AbstractTypeArguments::ZoneHandle(node->type().arguments()); | 1665 AbstractTypeArguments::ZoneHandle(node->type().arguments()); |
| 1675 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), | 1666 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), |
| 1676 type_args); | 1667 type_args); |
| 1677 CreateArrayInstr* create = new CreateArrayInstr(node->token_pos(), | 1668 CreateArrayInstr* create = new CreateArrayInstr(node->token_pos(), |
| 1678 arguments, | 1669 node->length(), |
| 1679 node->type(), | 1670 node->type(), |
| 1680 element_type); | 1671 element_type); |
| 1681 ReturnDefinition(create); | 1672 Value* array_val = Bind(create); |
| 1673 Definition* store = BuildStoreTemp(node->temp_local(), array_val); |
| 1674 Do(store); |
| 1675 |
| 1676 const intptr_t class_id = create->ResultCid(); |
| 1677 const intptr_t deopt_id = Isolate::kNoDeoptId; |
| 1678 for (int i = 0; i < node->length(); ++i) { |
| 1679 Value* array = Bind( |
| 1680 new LoadLocalInstr(node->temp_local(), owner()->context_level())); |
| 1681 Value* index = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(i)))); |
| 1682 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1683 node->ElementAt(i)->Visit(&for_value); |
| 1684 Append(for_value); |
| 1685 // No store barrier needed for constants. |
| 1686 const bool emit_store_barrier = !for_value.value()->BindsToConstant(); |
| 1687 StoreIndexedInstr* store = new StoreIndexedInstr( |
| 1688 array, index, for_value.value(), |
| 1689 emit_store_barrier, class_id, deopt_id); |
| 1690 Do(store); |
| 1691 } |
| 1692 |
| 1693 ReturnDefinition( |
| 1694 new LoadLocalInstr(node->temp_local(), owner()->context_level())); |
| 1682 } | 1695 } |
| 1683 | 1696 |
| 1684 | 1697 |
| 1685 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1698 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1686 const Function& function = node->function(); | 1699 const Function& function = node->function(); |
| 1687 | 1700 |
| 1688 if (function.IsImplicitStaticClosureFunction()) { | 1701 if (function.IsImplicitStaticClosureFunction()) { |
| 1689 Instance& closure = Instance::ZoneHandle(); | 1702 Instance& closure = Instance::ZoneHandle(); |
| 1690 closure ^= function.implicit_static_closure(); | 1703 closure ^= function.implicit_static_closure(); |
| 1691 if (closure.IsNull()) { | 1704 if (closure.IsNull()) { |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3039 ArgumentListNode* arguments = new ArgumentListNode(args_pos); | 3052 ArgumentListNode* arguments = new ArgumentListNode(args_pos); |
| 3040 // The first argument is the original method name. | 3053 // The first argument is the original method name. |
| 3041 arguments->Add(new LiteralNode(args_pos, method_name)); | 3054 arguments->Add(new LiteralNode(args_pos, method_name)); |
| 3042 // The second argument is the arguments descriptor of the original method. | 3055 // The second argument is the arguments descriptor of the original method. |
| 3043 const Array& args_descriptor = | 3056 const Array& args_descriptor = |
| 3044 Array::ZoneHandle(ArgumentsDescriptor::New(method_arguments->length(), | 3057 Array::ZoneHandle(ArgumentsDescriptor::New(method_arguments->length(), |
| 3045 method_arguments->names())); | 3058 method_arguments->names())); |
| 3046 arguments->Add(new LiteralNode(args_pos, args_descriptor)); | 3059 arguments->Add(new LiteralNode(args_pos, args_descriptor)); |
| 3047 // The third argument is an array containing the original method arguments, | 3060 // The third argument is an array containing the original method arguments, |
| 3048 // including the receiver. | 3061 // including the receiver. |
| 3049 ArrayNode* args_array = | 3062 ArrayNode* args_array = new ArrayNode( |
| 3050 new ArrayNode(args_pos, Type::ZoneHandle(Type::ArrayType())); | 3063 args_pos, |
| 3064 Type::ZoneHandle(Type::ArrayType()), |
| 3065 *owner()->parsed_function().array_literal_var()); |
| 3051 for (intptr_t i = 0; i < method_arguments->length(); i++) { | 3066 for (intptr_t i = 0; i < method_arguments->length(); i++) { |
| 3052 args_array->AddElement(method_arguments->NodeAt(i)); | 3067 args_array->AddElement(method_arguments->NodeAt(i)); |
| 3053 } | 3068 } |
| 3054 arguments->Add(args_array); | 3069 arguments->Add(args_array); |
| 3055 ZoneGrowableArray<PushArgumentInstr*>* allocation_args = | 3070 ZoneGrowableArray<PushArgumentInstr*>* allocation_args = |
| 3056 new ZoneGrowableArray<PushArgumentInstr*>(arguments->length()); | 3071 new ZoneGrowableArray<PushArgumentInstr*>(arguments->length()); |
| 3057 BuildPushArguments(*arguments, allocation_args); | 3072 BuildPushArguments(*arguments, allocation_args); |
| 3058 StaticCallInstr* allocation = new StaticCallInstr(args_pos, | 3073 StaticCallInstr* allocation = new StaticCallInstr(args_pos, |
| 3059 allocation_function, | 3074 allocation_function, |
| 3060 Array::ZoneHandle(), | 3075 Array::ZoneHandle(), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3232 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3247 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3233 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3248 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3234 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3249 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3235 const Error& error = Error::Handle( | 3250 const Error& error = Error::Handle( |
| 3236 LanguageError::New(String::Handle(String::New(chars)))); | 3251 LanguageError::New(String::Handle(String::New(chars)))); |
| 3237 Isolate::Current()->long_jump_base()->Jump(1, error); | 3252 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3238 } | 3253 } |
| 3239 | 3254 |
| 3240 | 3255 |
| 3241 } // namespace dart | 3256 } // namespace dart |
| OLD | NEW |