OLD | NEW |
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/code_patcher.h" | 9 #include "vm/code_patcher.h" |
10 #include "vm/compiler.h" | 10 #include "vm/compiler.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 Exceptions::ThrowArgumentError(error); | 110 Exceptions::ThrowArgumentError(error); |
111 } | 111 } |
112 const intptr_t len = Smi::Cast(length).Value(); | 112 const intptr_t len = Smi::Cast(length).Value(); |
113 if (len < 0) { | 113 if (len < 0) { |
114 const String& error = String::Handle(String::NewFormatted( | 114 const String& error = String::Handle(String::NewFormatted( |
115 "Length (%" Pd ") must be an integer in the range [0..%" Pd "].", | 115 "Length (%" Pd ") must be an integer in the range [0..%" Pd "].", |
116 len, Array::kMaxElements)); | 116 len, Array::kMaxElements)); |
117 Exceptions::ThrowArgumentError(error); | 117 Exceptions::ThrowArgumentError(error); |
118 } | 118 } |
119 | 119 |
120 const Array& array = Array::Handle(Array::New(len)); | 120 Heap::Space space = isolate->heap()->SpaceForAllocation(kArrayCid); |
| 121 const Array& array = Array::Handle(Array::New(len, space)); |
121 arguments.SetReturn(array); | 122 arguments.SetReturn(array); |
122 TypeArguments& element_type = | 123 TypeArguments& element_type = |
123 TypeArguments::CheckedHandle(arguments.ArgAt(1)); | 124 TypeArguments::CheckedHandle(arguments.ArgAt(1)); |
124 // An Array is raw or takes one type argument. However, its type argument | 125 // An Array is raw or takes one type argument. However, its type argument |
125 // vector may be longer than 1 due to a type optimization reusing the type | 126 // vector may be longer than 1 due to a type optimization reusing the type |
126 // argument vector of the instantiator. | 127 // argument vector of the instantiator. |
127 ASSERT(element_type.IsNull() || | 128 ASSERT(element_type.IsNull() || |
128 ((element_type.Length() >= 1) && element_type.IsInstantiated())); | 129 ((element_type.Length() >= 1) && element_type.IsInstantiated())); |
129 array.SetTypeArguments(element_type); // May be null. | 130 array.SetTypeArguments(element_type); // May be null. |
130 } | 131 } |
(...skipping 18 matching lines...) Expand all Loading... |
149 #ifdef DEBUG | 150 #ifdef DEBUG |
150 if (FLAG_gc_at_instance_allocation != NULL) { | 151 if (FLAG_gc_at_instance_allocation != NULL) { |
151 const String& name = String::Handle(cls.Name()); | 152 const String& name = String::Handle(cls.Name()); |
152 if (String::EqualsIgnoringPrivateKey( | 153 if (String::EqualsIgnoringPrivateKey( |
153 name, | 154 name, |
154 String::Handle(String::New(FLAG_gc_at_instance_allocation)))) { | 155 String::Handle(String::New(FLAG_gc_at_instance_allocation)))) { |
155 Isolate::Current()->heap()->CollectAllGarbage(); | 156 Isolate::Current()->heap()->CollectAllGarbage(); |
156 } | 157 } |
157 } | 158 } |
158 #endif | 159 #endif |
159 | 160 Heap::Space space = isolate->heap()->SpaceForAllocation(cls.id()); |
160 const Instance& instance = Instance::Handle(Instance::New(cls)); | 161 const Instance& instance = Instance::Handle(Instance::New(cls, space)); |
161 | 162 |
162 arguments.SetReturn(instance); | 163 arguments.SetReturn(instance); |
163 if (cls.NumTypeArguments() == 0) { | 164 if (cls.NumTypeArguments() == 0) { |
164 // No type arguments required for a non-parameterized type. | 165 // No type arguments required for a non-parameterized type. |
165 ASSERT(Instance::CheckedHandle(arguments.ArgAt(1)).IsNull()); | 166 ASSERT(Instance::CheckedHandle(arguments.ArgAt(1)).IsNull()); |
166 return; | 167 return; |
167 } | 168 } |
168 TypeArguments& type_arguments = | 169 TypeArguments& type_arguments = |
169 TypeArguments::CheckedHandle(arguments.ArgAt(1)); | 170 TypeArguments::CheckedHandle(arguments.ArgAt(1)); |
170 // Unless null (for a raw type), the type argument vector may be longer than | 171 // Unless null (for a raw type), the type argument vector may be longer than |
(...skipping 1451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1622 field.RecordStore(value); | 1623 field.RecordStore(value); |
1623 } | 1624 } |
1624 | 1625 |
1625 | 1626 |
1626 DEFINE_RUNTIME_ENTRY(InitStaticField, 1) { | 1627 DEFINE_RUNTIME_ENTRY(InitStaticField, 1) { |
1627 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); | 1628 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); |
1628 field.EvaluateInitializer(); | 1629 field.EvaluateInitializer(); |
1629 } | 1630 } |
1630 | 1631 |
1631 } // namespace dart | 1632 } // namespace dart |
OLD | NEW |