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

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

Issue 2748073002: Revert "VM: Simplify lowering of is-tests." (Closed)
Patch Set: Created 3 years, 9 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
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('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 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 const TypeArguments& left_type_arguments = 164 const TypeArguments& left_type_arguments =
165 TypeArguments::Handle(left.GetTypeArguments()); 165 TypeArguments::Handle(left.GetTypeArguments());
166 const TypeArguments& right_type_arguments = 166 const TypeArguments& right_type_arguments =
167 TypeArguments::Handle(right.GetTypeArguments()); 167 TypeArguments::Handle(right.GetTypeArguments());
168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw(); 168 return Bool::Get(left_type_arguments.Equals(right_type_arguments)).raw();
169 } 169 }
170 170
171 171
172 DEFINE_NATIVE_ENTRY(Object_instanceOf, 3) { 172 DEFINE_NATIVE_ENTRY(Object_instanceOf, 4) {
173 const Instance& instance = 173 const Instance& instance =
174 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 174 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
175 const TypeArguments& instantiator_type_arguments = 175 const TypeArguments& instantiator_type_arguments =
176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1)); 176 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
177 const AbstractType& type = 177 const AbstractType& type =
178 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2)); 178 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2));
179 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(3));
179 ASSERT(type.IsFinalized()); 180 ASSERT(type.IsFinalized());
180 ASSERT(!type.IsMalformed()); 181 ASSERT(!type.IsMalformed());
181 ASSERT(!type.IsMalbounded()); 182 ASSERT(!type.IsMalbounded());
182 Error& bound_error = Error::Handle(zone, Error::null()); 183 Error& bound_error = Error::Handle(zone, Error::null());
183 const bool is_instance_of = 184 const bool is_instance_of =
184 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error); 185 instance.IsInstanceOf(type, instantiator_type_arguments, &bound_error);
185 if (FLAG_trace_type_checks) { 186 if (FLAG_trace_type_checks) {
186 const char* result_str = is_instance_of ? "true" : "false"; 187 const char* result_str = is_instance_of ? "true" : "false";
187 OS::Print("Native Object.instanceOf: result %s\n", result_str); 188 OS::Print("Native Object.instanceOf: result %s\n", result_str);
188 const AbstractType& instance_type = 189 const AbstractType& instance_type =
(...skipping 12 matching lines...) Expand all
201 StackFrame* caller_frame = iterator.NextFrame(); 202 StackFrame* caller_frame = iterator.NextFrame();
202 ASSERT(caller_frame != NULL); 203 ASSERT(caller_frame != NULL);
203 const TokenPosition location = caller_frame->GetTokenPos(); 204 const TokenPosition location = caller_frame->GetTokenPos();
204 String& bound_error_message = 205 String& bound_error_message =
205 String::Handle(zone, String::New(bound_error.ToErrorCString())); 206 String::Handle(zone, String::New(bound_error.ToErrorCString()));
206 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone), 207 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone),
207 AbstractType::Handle(zone), 208 AbstractType::Handle(zone),
208 Symbols::Empty(), bound_error_message); 209 Symbols::Empty(), bound_error_message);
209 UNREACHABLE(); 210 UNREACHABLE();
210 } 211 }
211 return Bool::Get(is_instance_of).raw(); 212 return Bool::Get(negate.value() ? !is_instance_of : is_instance_of).raw();
212 } 213 }
213 214
214 DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) { 215 DEFINE_NATIVE_ENTRY(Object_simpleInstanceOf, 2) {
215 // This native is only called when the right hand side passes 216 // This native is only called when the right hand side passes
216 // simpleInstanceOfType and it is a non-negative test. 217 // simpleInstanceOfType and it is a non-negative test.
217 const Instance& instance = 218 const Instance& instance =
218 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 219 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
219 const AbstractType& type = 220 const AbstractType& type =
220 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1)); 221 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(1));
221 const TypeArguments& instantiator_type_arguments = 222 const TypeArguments& instantiator_type_arguments =
(...skipping 13 matching lines...) Expand all
235 String& bound_error_message = 236 String& bound_error_message =
236 String::Handle(zone, String::New(bound_error.ToErrorCString())); 237 String::Handle(zone, String::New(bound_error.ToErrorCString()));
237 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone), 238 Exceptions::CreateAndThrowTypeError(location, AbstractType::Handle(zone),
238 AbstractType::Handle(zone), 239 AbstractType::Handle(zone),
239 Symbols::Empty(), bound_error_message); 240 Symbols::Empty(), bound_error_message);
240 UNREACHABLE(); 241 UNREACHABLE();
241 } 242 }
242 return Bool::Get(is_instance_of).raw(); 243 return Bool::Get(is_instance_of).raw();
243 } 244 }
244 245
246 DEFINE_NATIVE_ENTRY(Object_instanceOfNum, 2) {
247 const Instance& instance =
248 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
249 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
250 bool is_instance_of = instance.IsNumber();
251 if (negate.value()) {
252 is_instance_of = !is_instance_of;
253 }
254 return Bool::Get(is_instance_of).raw();
255 }
256
257
258 DEFINE_NATIVE_ENTRY(Object_instanceOfInt, 2) {
259 const Instance& instance =
260 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
261 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
262 bool is_instance_of = instance.IsInteger();
263 if (negate.value()) {
264 is_instance_of = !is_instance_of;
265 }
266 return Bool::Get(is_instance_of).raw();
267 }
268
269
270 DEFINE_NATIVE_ENTRY(Object_instanceOfSmi, 2) {
271 const Instance& instance =
272 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
273 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
274 bool is_instance_of = instance.IsSmi();
275 if (negate.value()) {
276 is_instance_of = !is_instance_of;
277 }
278 return Bool::Get(is_instance_of).raw();
279 }
280
281
282 DEFINE_NATIVE_ENTRY(Object_instanceOfDouble, 2) {
283 const Instance& instance =
284 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
285 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
286 bool is_instance_of = instance.IsDouble();
287 if (negate.value()) {
288 is_instance_of = !is_instance_of;
289 }
290 return Bool::Get(is_instance_of).raw();
291 }
292
293
294 DEFINE_NATIVE_ENTRY(Object_instanceOfString, 2) {
295 const Instance& instance =
296 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
297 const Bool& negate = Bool::CheckedHandle(zone, arguments->NativeArgAt(1));
298 bool is_instance_of = instance.IsString();
299 if (negate.value()) {
300 is_instance_of = !is_instance_of;
301 }
302 return Bool::Get(is_instance_of).raw();
303 }
304
245 305
246 DEFINE_NATIVE_ENTRY(Object_as, 3) { 306 DEFINE_NATIVE_ENTRY(Object_as, 3) {
247 const Instance& instance = 307 const Instance& instance =
248 Instance::CheckedHandle(zone, arguments->NativeArgAt(0)); 308 Instance::CheckedHandle(zone, arguments->NativeArgAt(0));
249 const TypeArguments& instantiator_type_arguments = 309 const TypeArguments& instantiator_type_arguments =
250 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1)); 310 TypeArguments::CheckedHandle(zone, arguments->NativeArgAt(1));
251 AbstractType& type = 311 AbstractType& type =
252 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2)); 312 AbstractType::CheckedHandle(zone, arguments->NativeArgAt(2));
253 ASSERT(type.IsFinalized()); 313 ASSERT(type.IsFinalized());
254 ASSERT(!type.IsMalformed()); 314 ASSERT(!type.IsMalformed());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 405
346 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) { 406 DEFINE_NATIVE_ENTRY(Internal_inquireIs64Bit, 0) {
347 #if defined(ARCH_IS_64_BIT) 407 #if defined(ARCH_IS_64_BIT)
348 return Bool::True().raw(); 408 return Bool::True().raw();
349 #else 409 #else
350 return Bool::False().raw(); 410 return Bool::False().raw();
351 #endif // defined(ARCH_IS_64_BIT) 411 #endif // defined(ARCH_IS_64_BIT)
352 } 412 }
353 413
354 } // namespace dart 414 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/object_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698