Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1427)

Side by Side Diff: runtime/vm/code_generator.cc

Issue 285543002: Recognize List constructor and turn it into CreateArray ... (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 } 91 }
92 92
93 93
94 // Allocation of a fixed length array of given element type. 94 // Allocation of a fixed length array of given element type.
95 // This runtime entry is never called for allocating a List of a generic type, 95 // This runtime entry is never called for allocating a List of a generic type,
96 // because a prior run time call instantiates the element type if necessary. 96 // because a prior run time call instantiates the element type if necessary.
97 // Arg0: array length. 97 // Arg0: array length.
98 // Arg1: array type arguments, i.e. vector of 1 type, the element type. 98 // Arg1: array type arguments, i.e. vector of 1 type, the element type.
99 // Return value: newly allocated array of length arg0. 99 // Return value: newly allocated array of length arg0.
100 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) { 100 DEFINE_RUNTIME_ENTRY(AllocateArray, 2) {
101 const Smi& length = Smi::CheckedHandle(arguments.ArgAt(0)); 101 const Instance& length = Instance::CheckedHandle(arguments.ArgAt(0));
102 const Array& array = Array::Handle(Array::New(length.Value())); 102 if (!length.IsSmi()) {
103 const String& error = String::Handle(String::NewFormatted(
104 "Length must be an integer in the range [0..%" Pd "].",
105 Array::kMaxElements));
106 Exceptions::ThrowArgumentError(error);
107 }
108 const intptr_t len = Smi::Cast(length).Value();
109 if (len < 0) {
110 const String& error = String::Handle(String::NewFormatted(
111 "Length (%" Pd ") must be an integer in the range [0..%" Pd "].",
112 len, Array::kMaxElements));
113 Exceptions::ThrowArgumentError(error);
114 }
115
116 const Array& array = Array::Handle(Array::New(len));
103 arguments.SetReturn(array); 117 arguments.SetReturn(array);
104 TypeArguments& element_type = 118 TypeArguments& element_type =
105 TypeArguments::CheckedHandle(arguments.ArgAt(1)); 119 TypeArguments::CheckedHandle(arguments.ArgAt(1));
106 // An Array is raw or takes one type argument. However, its type argument 120 // An Array is raw or takes one type argument. However, its type argument
107 // vector may be longer than 1 due to a type optimization reusing the type 121 // vector may be longer than 1 due to a type optimization reusing the type
108 // argument vector of the instantiator. 122 // argument vector of the instantiator.
109 ASSERT(element_type.IsNull() || 123 ASSERT(element_type.IsNull() ||
110 ((element_type.Length() >= 1) && element_type.IsInstantiated())); 124 ((element_type.Length() >= 1) && element_type.IsInstantiated()));
111 array.SetTypeArguments(element_type); // May be null. 125 array.SetTypeArguments(element_type); // May be null.
112 } 126 }
(...skipping 1405 matching lines...) Expand 10 before | Expand all | Expand 10 after
1518 // of the given value. 1532 // of the given value.
1519 // Arg0: Field object; 1533 // Arg0: Field object;
1520 // Arg1: Value that is being stored. 1534 // Arg1: Value that is being stored.
1521 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1535 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1522 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1536 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1523 const Object& value = Object::Handle(arguments.ArgAt(1)); 1537 const Object& value = Object::Handle(arguments.ArgAt(1));
1524 field.UpdateGuardedCidAndLength(value); 1538 field.UpdateGuardedCidAndLength(value);
1525 } 1539 }
1526 1540
1527 } // namespace dart 1541 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/flow_graph_optimizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698