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

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

Issue 23464073: Make Dart_IdentityEqual live up to its spec and not leak boxing implementation detail. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/identical.h"
siva 2013/09/17 00:06:24 I don't think we want to include stuff from "lib/.
10 #include "vm/bigint_operations.h" 11 #include "vm/bigint_operations.h"
11 #include "vm/class_finalizer.h" 12 #include "vm/class_finalizer.h"
12 #include "vm/compiler.h" 13 #include "vm/compiler.h"
13 #include "vm/dart.h" 14 #include "vm/dart.h"
14 #include "vm/dart_api_impl.h" 15 #include "vm/dart_api_impl.h"
15 #include "vm/dart_api_message.h" 16 #include "vm/dart_api_message.h"
16 #include "vm/dart_api_state.h" 17 #include "vm/dart_api_state.h"
17 #include "vm/dart_entry.h" 18 #include "vm/dart_entry.h"
18 #include "vm/debuginfo.h" 19 #include "vm/debuginfo.h"
19 #include "vm/exceptions.h" 20 #include "vm/exceptions.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 CHECK_CALLBACK_STATE(isolate); 491 CHECK_CALLBACK_STATE(isolate);
491 // This is a VM internal object. Call the C++ method of printing. 492 // This is a VM internal object. Call the C++ method of printing.
492 return Api::NewHandle(isolate, String::New(obj.ToCString())); 493 return Api::NewHandle(isolate, String::New(obj.ToCString()));
493 } 494 }
494 } 495 }
495 496
496 497
497 DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2) { 498 DART_EXPORT bool Dart_IdentityEquals(Dart_Handle obj1, Dart_Handle obj2) {
498 Isolate* isolate = Isolate::Current(); 499 Isolate* isolate = Isolate::Current();
499 CHECK_ISOLATE(isolate); 500 CHECK_ISOLATE(isolate);
501
502 const Object& object1 = Object::Handle(isolate, Api::UnwrapHandle(obj1));
503 const Object& object2 = Object::Handle(isolate, Api::UnwrapHandle(obj2));
504 if (object1.IsInstance() && object2.IsInstance()) {
505 const Bool& result =
506 Bool::Handle(isolate, Identical(Instance::Cast(object1),
507 Instance::Cast(object2)));
508 return result.value();
509 }
510
500 NoGCScope ngc; 511 NoGCScope ngc;
501 return Api::UnwrapHandle(obj1) == Api::UnwrapHandle(obj2); 512 return object1.raw() == object2.raw();
siva 2013/09/17 00:06:24 Wouldn't it be more efficient to first compare the
502 } 513 }
503 514
504 515
505 DART_EXPORT Dart_Handle Dart_HandleFromPersistent( 516 DART_EXPORT Dart_Handle Dart_HandleFromPersistent(
506 Dart_PersistentHandle object) { 517 Dart_PersistentHandle object) {
507 Isolate* isolate = Isolate::Current(); 518 Isolate* isolate = Isolate::Current();
508 DARTSCOPE(isolate); 519 DARTSCOPE(isolate);
509 ApiState* state = isolate->api_state(); 520 ApiState* state = isolate->api_state();
510 ASSERT(state != NULL); 521 ASSERT(state != NULL);
511 ASSERT(state->IsValidPersistentHandle(object)); 522 ASSERT(state->IsValidPersistentHandle(object));
(...skipping 3825 matching lines...) Expand 10 before | Expand all | Expand 10 after
4337 } 4348 }
4338 { 4349 {
4339 NoGCScope no_gc; 4350 NoGCScope no_gc;
4340 RawObject* raw_obj = obj.raw(); 4351 RawObject* raw_obj = obj.raw();
4341 isolate->heap()->SetPeer(raw_obj, peer); 4352 isolate->heap()->SetPeer(raw_obj, peer);
4342 } 4353 }
4343 return Api::Success(); 4354 return Api::Success();
4344 } 4355 }
4345 4356
4346 } // namespace dart 4357 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698