| 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 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1649 InlineBailout("EffectGraphVisitor::VisitArgumentDefinitionTestNode"); | 1649 InlineBailout("EffectGraphVisitor::VisitArgumentDefinitionTestNode"); |
| 1650 Definition* load = BuildLoadLocal(node->saved_arguments_descriptor()); | 1650 Definition* load = BuildLoadLocal(node->saved_arguments_descriptor()); |
| 1651 Value* arguments_descriptor = Bind(load); | 1651 Value* arguments_descriptor = Bind(load); |
| 1652 ArgumentDefinitionTestInstr* arg_def_test = | 1652 ArgumentDefinitionTestInstr* arg_def_test = |
| 1653 new ArgumentDefinitionTestInstr(node, arguments_descriptor); | 1653 new ArgumentDefinitionTestInstr(node, arguments_descriptor); |
| 1654 ReturnDefinition(arg_def_test); | 1654 ReturnDefinition(arg_def_test); |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 | 1657 |
| 1658 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { | 1658 void EffectGraphVisitor::VisitArrayNode(ArrayNode* node) { |
| 1659 // Translate the array elements and collect their values. | |
| 1660 ZoneGrowableArray<PushArgumentInstr*>* arguments = | |
| 1661 new ZoneGrowableArray<PushArgumentInstr*>(node->length()); | |
| 1662 for (int i = 0; i < node->length(); ++i) { | |
| 1663 ValueGraphVisitor for_value(owner(), temp_index()); | |
| 1664 node->ElementAt(i)->Visit(&for_value); | |
| 1665 Append(for_value); | |
| 1666 arguments->Add(PushArgument(for_value.value())); | |
| 1667 } | |
| 1668 const AbstractTypeArguments& type_args = | 1659 const AbstractTypeArguments& type_args = |
| 1669 AbstractTypeArguments::ZoneHandle(node->type().arguments()); | 1660 AbstractTypeArguments::ZoneHandle(node->type().arguments()); |
| 1670 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), | 1661 Value* element_type = BuildInstantiatedTypeArguments(node->token_pos(), |
| 1671 type_args); | 1662 type_args); |
| 1672 CreateArrayInstr* create = new CreateArrayInstr(node->token_pos(), | 1663 CreateArrayInstr* create = new CreateArrayInstr(node->token_pos(), |
| 1673 arguments, | 1664 node->length(), |
| 1674 node->type(), | 1665 node->type(), |
| 1675 element_type); | 1666 element_type); |
| 1676 ReturnDefinition(create); | 1667 Value* array_val = Bind(create); |
| 1668 Definition* store = BuildStoreTemp(node->temp_local(), array_val); |
| 1669 Do(store); |
| 1670 |
| 1671 const intptr_t class_id = create->Type()->ToCid(); |
| 1672 const intptr_t deopt_id = Isolate::kNoDeoptId; |
| 1673 for (int i = 0; i < node->length(); ++i) { |
| 1674 Value* array = Bind( |
| 1675 new LoadLocalInstr(node->temp_local(), owner()->context_level())); |
| 1676 Value* index = Bind(new ConstantInstr(Smi::ZoneHandle(Smi::New(i)))); |
| 1677 ValueGraphVisitor for_value(owner(), temp_index()); |
| 1678 node->ElementAt(i)->Visit(&for_value); |
| 1679 Append(for_value); |
| 1680 // No store barrier needed for constants. |
| 1681 const bool emit_store_barrier = !for_value.value()->BindsToConstant(); |
| 1682 StoreIndexedInstr* store = new StoreIndexedInstr( |
| 1683 array, index, for_value.value(), |
| 1684 emit_store_barrier, class_id, deopt_id); |
| 1685 Do(store); |
| 1686 } |
| 1687 |
| 1688 ReturnDefinition( |
| 1689 new LoadLocalInstr(node->temp_local(), owner()->context_level())); |
| 1677 } | 1690 } |
| 1678 | 1691 |
| 1679 | 1692 |
| 1680 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { | 1693 void EffectGraphVisitor::VisitClosureNode(ClosureNode* node) { |
| 1681 const Function& function = node->function(); | 1694 const Function& function = node->function(); |
| 1682 | 1695 |
| 1683 if (function.IsImplicitStaticClosureFunction()) { | 1696 if (function.IsImplicitStaticClosureFunction()) { |
| 1684 Instance& closure = Instance::ZoneHandle(); | 1697 Instance& closure = Instance::ZoneHandle(); |
| 1685 closure ^= function.implicit_static_closure(); | 1698 closure ^= function.implicit_static_closure(); |
| 1686 if (closure.IsNull()) { | 1699 if (closure.IsNull()) { |
| (...skipping 1347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3034 ArgumentListNode* arguments = new ArgumentListNode(args_pos); | 3047 ArgumentListNode* arguments = new ArgumentListNode(args_pos); |
| 3035 // The first argument is the original method name. | 3048 // The first argument is the original method name. |
| 3036 arguments->Add(new LiteralNode(args_pos, method_name)); | 3049 arguments->Add(new LiteralNode(args_pos, method_name)); |
| 3037 // The second argument is the arguments descriptor of the original method. | 3050 // The second argument is the arguments descriptor of the original method. |
| 3038 const Array& args_descriptor = | 3051 const Array& args_descriptor = |
| 3039 Array::ZoneHandle(ArgumentsDescriptor::New(method_arguments->length(), | 3052 Array::ZoneHandle(ArgumentsDescriptor::New(method_arguments->length(), |
| 3040 method_arguments->names())); | 3053 method_arguments->names())); |
| 3041 arguments->Add(new LiteralNode(args_pos, args_descriptor)); | 3054 arguments->Add(new LiteralNode(args_pos, args_descriptor)); |
| 3042 // The third argument is an array containing the original method arguments, | 3055 // The third argument is an array containing the original method arguments, |
| 3043 // including the receiver. | 3056 // including the receiver. |
| 3044 ArrayNode* args_array = | 3057 ArrayNode* args_array = new ArrayNode( |
| 3045 new ArrayNode(args_pos, Type::ZoneHandle(Type::ArrayType())); | 3058 args_pos, |
| 3059 Type::ZoneHandle(Type::ArrayType()), |
| 3060 *owner()->parsed_function().array_literal_var()); |
| 3046 for (intptr_t i = 0; i < method_arguments->length(); i++) { | 3061 for (intptr_t i = 0; i < method_arguments->length(); i++) { |
| 3047 args_array->AddElement(method_arguments->NodeAt(i)); | 3062 args_array->AddElement(method_arguments->NodeAt(i)); |
| 3048 } | 3063 } |
| 3049 arguments->Add(args_array); | 3064 arguments->Add(args_array); |
| 3050 ZoneGrowableArray<PushArgumentInstr*>* allocation_args = | 3065 ZoneGrowableArray<PushArgumentInstr*>* allocation_args = |
| 3051 new ZoneGrowableArray<PushArgumentInstr*>(arguments->length()); | 3066 new ZoneGrowableArray<PushArgumentInstr*>(arguments->length()); |
| 3052 BuildPushArguments(*arguments, allocation_args); | 3067 BuildPushArguments(*arguments, allocation_args); |
| 3053 StaticCallInstr* allocation = new StaticCallInstr(args_pos, | 3068 StaticCallInstr* allocation = new StaticCallInstr(args_pos, |
| 3054 allocation_function, | 3069 allocation_function, |
| 3055 Array::ZoneHandle(), | 3070 Array::ZoneHandle(), |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3227 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; | 3242 intptr_t len = OS::SNPrint(NULL, 0, kFormat, function_name, reason) + 1; |
| 3228 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); | 3243 char* chars = Isolate::Current()->current_zone()->Alloc<char>(len); |
| 3229 OS::SNPrint(chars, len, kFormat, function_name, reason); | 3244 OS::SNPrint(chars, len, kFormat, function_name, reason); |
| 3230 const Error& error = Error::Handle( | 3245 const Error& error = Error::Handle( |
| 3231 LanguageError::New(String::Handle(String::New(chars)))); | 3246 LanguageError::New(String::Handle(String::New(chars)))); |
| 3232 Isolate::Current()->long_jump_base()->Jump(1, error); | 3247 Isolate::Current()->long_jump_base()->Jump(1, error); |
| 3233 } | 3248 } |
| 3234 | 3249 |
| 3235 | 3250 |
| 3236 } // namespace dart | 3251 } // namespace dart |
| OLD | NEW |