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

Side by Side Diff: runtime/lib/object.cc

Issue 2509013002: Allocate generic types in new-space before canonicalizing. (Closed)
Patch Set: formatting Created 4 years, 1 month 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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/class_finalizer.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/code_patcher.h" 8 #include "vm/code_patcher.h"
9 #include "vm/exceptions.h" 9 #include "vm/exceptions.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 116
117 DEFINE_NATIVE_ENTRY(Object_runtimeType, 1) { 117 DEFINE_NATIVE_ENTRY(Object_runtimeType, 1) {
118 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0)); 118 const Instance& instance = Instance::CheckedHandle(arguments->NativeArgAt(0));
119 if (instance.IsString()) { 119 if (instance.IsString()) {
120 return Type::StringType(); 120 return Type::StringType();
121 } else if (instance.IsInteger()) { 121 } else if (instance.IsInteger()) {
122 return Type::IntType(); 122 return Type::IntType();
123 } else if (instance.IsDouble()) { 123 } else if (instance.IsDouble()) {
124 return Type::Double(); 124 return Type::Double();
125 } 125 }
126 return instance.GetType(); 126 return instance.GetType(Heap::kNew);
127 } 127 }
128 128
129 129
130 DEFINE_NATIVE_ENTRY(Object_haveSameRuntimeType, 2) { 130 DEFINE_NATIVE_ENTRY(Object_haveSameRuntimeType, 2) {
131 const Instance& left = Instance::CheckedHandle(arguments->NativeArgAt(0)); 131 const Instance& left = Instance::CheckedHandle(arguments->NativeArgAt(0));
132 const Instance& right = Instance::CheckedHandle(arguments->NativeArgAt(1)); 132 const Instance& right = Instance::CheckedHandle(arguments->NativeArgAt(1));
133 133
134 const intptr_t left_cid = left.GetClassId(); 134 const intptr_t left_cid = left.GetClassId();
135 const intptr_t right_cid = right.GetClassId(); 135 const intptr_t right_cid = right.GetClassId();
136 136
137 if (left_cid != right_cid) { 137 if (left_cid != right_cid) {
138 if (RawObject::IsIntegerClassId(left_cid)) { 138 if (RawObject::IsIntegerClassId(left_cid)) {
139 return Bool::Get(RawObject::IsIntegerClassId(right_cid)).raw(); 139 return Bool::Get(RawObject::IsIntegerClassId(right_cid)).raw();
140 } else if (RawObject::IsStringClassId(right_cid)) { 140 } else if (RawObject::IsStringClassId(right_cid)) {
141 return Bool::Get(RawObject::IsStringClassId(right_cid)).raw(); 141 return Bool::Get(RawObject::IsStringClassId(right_cid)).raw();
142 } else { 142 } else {
143 return Bool::False().raw(); 143 return Bool::False().raw();
144 } 144 }
145 } 145 }
146 146
147 const Class& cls = Class::Handle(left.clazz()); 147 const Class& cls = Class::Handle(left.clazz());
148 if (cls.IsClosureClass()) { 148 if (cls.IsClosureClass()) {
149 // TODO(vegorov): provide faster implementation for closure classes. 149 // TODO(vegorov): provide faster implementation for closure classes.
150 const AbstractType& left_type = AbstractType::Handle(left.GetType()); 150 const AbstractType& left_type =
151 const AbstractType& right_type = AbstractType::Handle(right.GetType()); 151 AbstractType::Handle(left.GetType(Heap::kNew));
152 const AbstractType& right_type =
153 AbstractType::Handle(right.GetType(Heap::kNew));
152 return Bool::Get(left_type.raw() == right_type.raw()).raw(); 154 return Bool::Get(left_type.raw() == right_type.raw()).raw();
153 } 155 }
154 156
155 if (!cls.IsGeneric()) { 157 if (!cls.IsGeneric()) {
156 return Bool::True().raw(); 158 return Bool::True().raw();
157 } 159 }
158 160
159 const TypeArguments& left_type_arguments = 161 const TypeArguments& left_type_arguments =
160 TypeArguments::Handle(left.GetTypeArguments()); 162 TypeArguments::Handle(left.GetTypeArguments());
161 const TypeArguments& right_type_arguments = 163 const TypeArguments& right_type_arguments =
(...skipping 13 matching lines...) Expand all
175 ASSERT(type.IsFinalized()); 177 ASSERT(type.IsFinalized());
176 ASSERT(!type.IsMalformed()); 178 ASSERT(!type.IsMalformed());
177 ASSERT(!type.IsMalbounded()); 179 ASSERT(!type.IsMalbounded());
178 Error& bound_error = Error::Handle(zone, Error::null()); 180 Error& bound_error = Error::Handle(zone, Error::null());
179 const bool is_instance_of = 181 const bool is_instance_of =
180 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error); 182 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error);
181 if (FLAG_trace_type_checks) { 183 if (FLAG_trace_type_checks) {
182 const char* result_str = is_instance_of ? "true" : "false"; 184 const char* result_str = is_instance_of ? "true" : "false";
183 OS::Print("Native Object.instanceOf: result %s\n", result_str); 185 OS::Print("Native Object.instanceOf: result %s\n", result_str);
184 const AbstractType& instance_type = 186 const AbstractType& instance_type =
185 AbstractType::Handle(zone, instance.GetType()); 187 AbstractType::Handle(zone, instance.GetType(Heap::kNew));
186 OS::Print(" instance type: %s\n", 188 OS::Print(" instance type: %s\n",
187 String::Handle(zone, instance_type.Name()).ToCString()); 189 String::Handle(zone, instance_type.Name()).ToCString());
188 OS::Print(" test type: %s\n", 190 OS::Print(" test type: %s\n",
189 String::Handle(zone, type.Name()).ToCString()); 191 String::Handle(zone, type.Name()).ToCString());
190 if (!bound_error.IsNull()) { 192 if (!bound_error.IsNull()) {
191 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); 193 OS::Print(" bound error: %s\n", bound_error.ToErrorCString());
192 } 194 }
193 } 195 }
194 if (!is_instance_of && !bound_error.IsNull()) { 196 if (!is_instance_of && !bound_error.IsNull()) {
195 // Throw a dynamic type error only if the instanceof test fails. 197 // Throw a dynamic type error only if the instanceof test fails.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 Error& bound_error = Error::Handle(zone); 313 Error& bound_error = Error::Handle(zone);
312 if (instance.IsNull()) { 314 if (instance.IsNull()) {
313 return instance.raw(); 315 return instance.raw();
314 } 316 }
315 const bool is_instance_of = 317 const bool is_instance_of =
316 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error); 318 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error);
317 if (FLAG_trace_type_checks) { 319 if (FLAG_trace_type_checks) {
318 const char* result_str = is_instance_of ? "true" : "false"; 320 const char* result_str = is_instance_of ? "true" : "false";
319 OS::Print("Object.as: result %s\n", result_str); 321 OS::Print("Object.as: result %s\n", result_str);
320 const AbstractType& instance_type = 322 const AbstractType& instance_type =
321 AbstractType::Handle(zone, instance.GetType()); 323 AbstractType::Handle(zone, instance.GetType(Heap::kNew));
322 OS::Print(" instance type: %s\n", 324 OS::Print(" instance type: %s\n",
323 String::Handle(zone, instance_type.Name()).ToCString()); 325 String::Handle(zone, instance_type.Name()).ToCString());
324 OS::Print(" cast type: %s\n", 326 OS::Print(" cast type: %s\n",
325 String::Handle(zone, type.Name()).ToCString()); 327 String::Handle(zone, type.Name()).ToCString());
326 if (!bound_error.IsNull()) { 328 if (!bound_error.IsNull()) {
327 OS::Print(" bound error: %s\n", bound_error.ToErrorCString()); 329 OS::Print(" bound error: %s\n", bound_error.ToErrorCString());
328 } 330 }
329 } 331 }
330 if (!is_instance_of) { 332 if (!is_instance_of) {
331 DartFrameIterator iterator; 333 DartFrameIterator iterator;
332 StackFrame* caller_frame = iterator.NextFrame(); 334 StackFrame* caller_frame = iterator.NextFrame();
333 ASSERT(caller_frame != NULL); 335 ASSERT(caller_frame != NULL);
334 const TokenPosition location = caller_frame->GetTokenPos(); 336 const TokenPosition location = caller_frame->GetTokenPos();
335 const AbstractType& instance_type = 337 const AbstractType& instance_type =
336 AbstractType::Handle(zone, instance.GetType()); 338 AbstractType::Handle(zone, instance.GetType(Heap::kNew));
337 if (!type.IsInstantiated()) { 339 if (!type.IsInstantiated()) {
338 // Instantiate type before reporting the error. 340 // Instantiate type before reporting the error.
339 type = type.InstantiateFrom(instantiator_type_arguments, NULL, NULL, NULL, 341 type = type.InstantiateFrom(instantiator_type_arguments, NULL, NULL, NULL,
340 Heap::kNew); 342 Heap::kNew);
341 // Note that the instantiated type may be malformed. 343 // Note that the instantiated type may be malformed.
342 } 344 }
343 if (bound_error.IsNull()) { 345 if (bound_error.IsNull()) {
344 Exceptions::CreateAndThrowTypeError(location, instance_type, type, 346 Exceptions::CreateAndThrowTypeError(location, instance_type, type,
345 Symbols::InTypeCast(), 347 Symbols::InTypeCast(),
346 Object::null_string()); 348 Object::null_string());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 404
403 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { 405 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) {
404 #if defined(ARCH_IS_64_BIT) 406 #if defined(ARCH_IS_64_BIT)
405 return Bool::True().raw(); 407 return Bool::True().raw();
406 #else 408 #else
407 return Bool::False().raw(); 409 return Bool::False().raw();
408 #endif // defined(ARCH_IS_64_BIT) 410 #endif // defined(ARCH_IS_64_BIT)
409 } 411 }
410 412
411 } // namespace dart 413 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/class_finalizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698