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

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

Issue 10014002: Rename Api::NewLocalHandle -> Api::NewHandle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 8 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 | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_api_state.h » ('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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 "platform/assert.h" 6 #include "platform/assert.h"
7 #include "platform/utils.h" 7 #include "platform/utils.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 EXPECT(!same); 158 EXPECT(!same);
159 159
160 // Different objects. 160 // Different objects.
161 EXPECT_VALID(Dart_IsSame(five, seven, &same)); 161 EXPECT_VALID(Dart_IsSame(five, seven, &same));
162 EXPECT(!same); 162 EXPECT(!same);
163 163
164 // Non-instance objects. 164 // Non-instance objects.
165 { 165 {
166 Isolate* isolate = Isolate::Current(); 166 Isolate* isolate = Isolate::Current();
167 DARTSCOPE_NOCHECKS(isolate); 167 DARTSCOPE_NOCHECKS(isolate);
168 const Object& cls1 = Object::Handle(Object::null_class()); 168 Dart_Handle class1 = Api::NewHandle(isolate, Object::null_class());
169 const Object& cls2 = Object::Handle(Object::class_class()); 169 Dart_Handle class2 = Api::NewHandle(isolate, Object::class_class());
170 Dart_Handle class1 = Api::NewLocalHandle(isolate, cls1);
171 Dart_Handle class2 = Api::NewLocalHandle(isolate, cls2);
172 170
173 EXPECT_VALID(Dart_IsSame(class1, class1, &same)); 171 EXPECT_VALID(Dart_IsSame(class1, class1, &same));
174 EXPECT(same); 172 EXPECT(same);
175 173
176 EXPECT_VALID(Dart_IsSame(class1, class2, &same)); 174 EXPECT_VALID(Dart_IsSame(class1, class2, &same));
177 EXPECT(!same); 175 EXPECT(!same);
178 } 176 }
179 } 177 }
180 178
181 179
(...skipping 940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 Isolate* isolate = Isolate::Current(); 1120 Isolate* isolate = Isolate::Current();
1123 EXPECT(isolate != NULL); 1121 EXPECT(isolate != NULL);
1124 ApiState* state = isolate->api_state(); 1122 ApiState* state = isolate->api_state();
1125 EXPECT(state != NULL); 1123 EXPECT(state != NULL);
1126 ApiLocalScope* scope = state->top_scope(); 1124 ApiLocalScope* scope = state->top_scope();
1127 Dart_EnterScope(); 1125 Dart_EnterScope();
1128 { 1126 {
1129 EXPECT(state->top_scope() != NULL); 1127 EXPECT(state->top_scope() != NULL);
1130 DARTSCOPE_NOCHECKS(isolate); 1128 DARTSCOPE_NOCHECKS(isolate);
1131 const String& str1 = String::Handle(String::New("Test String")); 1129 const String& str1 = String::Handle(String::New("Test String"));
1132 Dart_Handle ref = Api::NewLocalHandle(isolate, str1); 1130 Dart_Handle ref = Api::NewHandle(isolate, str1.raw());
1133 String& str2 = String::Handle(); 1131 String& str2 = String::Handle();
1134 str2 ^= Api::UnwrapHandle(ref); 1132 str2 ^= Api::UnwrapHandle(ref);
1135 EXPECT(str1.Equals(str2)); 1133 EXPECT(str1.Equals(str2));
1136 } 1134 }
1137 Dart_ExitScope(); 1135 Dart_ExitScope();
1138 EXPECT(scope == state->top_scope()); 1136 EXPECT(scope == state->top_scope());
1139 } 1137 }
1140 1138
1141 1139
1142 // Unit test for creating and deleting persistent handles. 1140 // Unit test for creating and deleting persistent handles.
1143 UNIT_TEST_CASE(PersistentHandles) { 1141 UNIT_TEST_CASE(PersistentHandles) {
1144 const char* kTestString1 = "Test String1"; 1142 const char* kTestString1 = "Test String1";
1145 const char* kTestString2 = "Test String2"; 1143 const char* kTestString2 = "Test String2";
1146 TestCase::CreateTestIsolate(); 1144 TestCase::CreateTestIsolate();
1147 Isolate* isolate = Isolate::Current(); 1145 Isolate* isolate = Isolate::Current();
1148 EXPECT(isolate != NULL); 1146 EXPECT(isolate != NULL);
1149 ApiState* state = isolate->api_state(); 1147 ApiState* state = isolate->api_state();
1150 EXPECT(state != NULL); 1148 EXPECT(state != NULL);
1151 ApiLocalScope* scope = state->top_scope(); 1149 ApiLocalScope* scope = state->top_scope();
1152 Dart_Handle handles[2000]; 1150 Dart_Handle handles[2000];
1153 Dart_EnterScope(); 1151 Dart_EnterScope();
1154 { 1152 {
1155 DARTSCOPE_NOCHECKS(isolate); 1153 DARTSCOPE_NOCHECKS(isolate);
1156 const String& str1 = String::Handle(String::New(kTestString1)); 1154 Dart_Handle ref1 = Api::NewHandle(isolate, String::New(kTestString1));
1157 Dart_Handle ref1 = Api::NewLocalHandle(isolate, str1);
1158 for (int i = 0; i < 1000; i++) { 1155 for (int i = 0; i < 1000; i++) {
1159 handles[i] = Dart_NewPersistentHandle(ref1); 1156 handles[i] = Dart_NewPersistentHandle(ref1);
1160 } 1157 }
1161 Dart_EnterScope(); 1158 Dart_EnterScope();
1162 const String& str2 = String::Handle(String::New(kTestString2)); 1159 Dart_Handle ref2 = Api::NewHandle(isolate, String::New(kTestString2));
1163 Dart_Handle ref2 = Api::NewLocalHandle(isolate, str2);
1164 for (int i = 1000; i < 2000; i++) { 1160 for (int i = 1000; i < 2000; i++) {
1165 handles[i] = Dart_NewPersistentHandle(ref2); 1161 handles[i] = Dart_NewPersistentHandle(ref2);
1166 } 1162 }
1167 for (int i = 500; i < 1500; i++) { 1163 for (int i = 500; i < 1500; i++) {
1168 Dart_DeletePersistentHandle(handles[i]); 1164 Dart_DeletePersistentHandle(handles[i]);
1169 } 1165 }
1170 for (int i = 500; i < 1000; i++) { 1166 for (int i = 500; i < 1000; i++) {
1171 handles[i] = Dart_NewPersistentHandle(ref2); 1167 handles[i] = Dart_NewPersistentHandle(ref2);
1172 } 1168 }
1173 for (int i = 1000; i < 1500; i++) { 1169 for (int i = 1000; i < 1500; i++) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 1246
1251 // create an object in new space 1247 // create an object in new space
1252 Dart_Handle new_ref = Dart_NewString("new string"); 1248 Dart_Handle new_ref = Dart_NewString("new string");
1253 EXPECT_VALID(new_ref); 1249 EXPECT_VALID(new_ref);
1254 1250
1255 // create an object in old space 1251 // create an object in old space
1256 Dart_Handle old_ref; 1252 Dart_Handle old_ref;
1257 { 1253 {
1258 Isolate* isolate = Isolate::Current(); 1254 Isolate* isolate = Isolate::Current();
1259 DARTSCOPE(isolate); 1255 DARTSCOPE(isolate);
1260 const String& str = 1256 old_ref = Api::NewHandle(isolate, String::New("old string", Heap::kOld));
1261 String::Handle(String::New("old string", Heap::kOld));
1262 old_ref = Api::NewLocalHandle(isolate, str);
1263 EXPECT_VALID(old_ref); 1257 EXPECT_VALID(old_ref);
1264 } 1258 }
1265 1259
1266 // create a weak ref to the new space object 1260 // create a weak ref to the new space object
1267 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL); 1261 weak_new_ref = Dart_NewWeakPersistentHandle(new_ref, NULL, NULL);
1268 EXPECT_VALID(weak_new_ref); 1262 EXPECT_VALID(weak_new_ref);
1269 EXPECT(!Dart_IsNull(weak_new_ref)); 1263 EXPECT(!Dart_IsNull(weak_new_ref));
1270 1264
1271 // create a weak ref to the old space object 1265 // create a weak ref to the old space object
1272 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL); 1266 weak_old_ref = Dart_NewWeakPersistentHandle(old_ref, NULL, NULL);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1387 Dart_Handle weak3 = Dart_Null(); 1381 Dart_Handle weak3 = Dart_Null();
1388 EXPECT(Dart_IsNull(weak3)); 1382 EXPECT(Dart_IsNull(weak3));
1389 1383
1390 Dart_Handle weak4 = Dart_Null(); 1384 Dart_Handle weak4 = Dart_Null();
1391 EXPECT(Dart_IsNull(weak4)); 1385 EXPECT(Dart_IsNull(weak4));
1392 1386
1393 Dart_EnterScope(); 1387 Dart_EnterScope();
1394 { 1388 {
1395 Isolate* isolate = Isolate::Current(); 1389 Isolate* isolate = Isolate::Current();
1396 DARTSCOPE(isolate); 1390 DARTSCOPE(isolate);
1397 String& str = String::Handle();
1398 1391
1399 str ^= String::New("strongly reachable", Heap::kOld); 1392 strong = Dart_NewPersistentHandle(
1400 strong = Dart_NewPersistentHandle(Api::NewLocalHandle(isolate, str)); 1393 Api::NewHandle(isolate, String::New("strongly reachable", Heap::kOld)));
1401 EXPECT_VALID(strong); 1394 EXPECT_VALID(strong);
1402 EXPECT(!Dart_IsNull(strong)); 1395 EXPECT(!Dart_IsNull(strong));
1403 1396
1404 str ^= String::New("weakly reachable 1", Heap::kOld);
1405 weak1 = Dart_NewWeakPersistentHandle( 1397 weak1 = Dart_NewWeakPersistentHandle(
1406 Api::NewLocalHandle(isolate, str), NULL, NULL); 1398 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
1399 NULL, NULL);
1407 EXPECT_VALID(weak1); 1400 EXPECT_VALID(weak1);
1408 EXPECT(!Dart_IsNull(weak1)); 1401 EXPECT(!Dart_IsNull(weak1));
1409 1402
1410 str ^= String::New("weakly reachable 2", Heap::kOld);
1411 weak2 = Dart_NewWeakPersistentHandle( 1403 weak2 = Dart_NewWeakPersistentHandle(
1412 Api::NewLocalHandle(isolate, str), NULL, NULL); 1404 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
1405 NULL, NULL);
1413 EXPECT_VALID(weak2); 1406 EXPECT_VALID(weak2);
1414 EXPECT(!Dart_IsNull(weak2)); 1407 EXPECT(!Dart_IsNull(weak2));
1415 1408
1416 str ^= String::New("weakly reachable 3", Heap::kOld);
1417 weak3 = Dart_NewWeakPersistentHandle( 1409 weak3 = Dart_NewWeakPersistentHandle(
1418 Api::NewLocalHandle(isolate, str), NULL, NULL); 1410 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
1411 NULL, NULL);
1419 EXPECT_VALID(weak3); 1412 EXPECT_VALID(weak3);
1420 EXPECT(!Dart_IsNull(weak3)); 1413 EXPECT(!Dart_IsNull(weak3));
1421 1414
1422 str ^= String::New("weakly reachable 4", Heap::kOld);
1423 weak4 = Dart_NewWeakPersistentHandle( 1415 weak4 = Dart_NewWeakPersistentHandle(
1424 Api::NewLocalHandle(isolate, str), NULL, NULL); 1416 Api::NewHandle(isolate, String::New("weakly reachable 4", Heap::kOld)),
1417 NULL, NULL);
1425 EXPECT_VALID(weak4); 1418 EXPECT_VALID(weak4);
1426 EXPECT(!Dart_IsNull(weak4)); 1419 EXPECT(!Dart_IsNull(weak4));
1427 } 1420 }
1428 Dart_ExitScope(); 1421 Dart_ExitScope();
1429 1422
1430 EXPECT_VALID(strong); 1423 EXPECT_VALID(strong);
1431 1424
1432 EXPECT_VALID(weak1); 1425 EXPECT_VALID(weak1);
1433 EXPECT_VALID(weak2); 1426 EXPECT_VALID(weak2);
1434 EXPECT_VALID(weak3); 1427 EXPECT_VALID(weak3);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1570 1563
1571 TEST_CASE(PrologueWeakPersistentHandles) { 1564 TEST_CASE(PrologueWeakPersistentHandles) {
1572 Dart_Handle old_pwph = Dart_Null(); 1565 Dart_Handle old_pwph = Dart_Null();
1573 EXPECT(Dart_IsNull(old_pwph)); 1566 EXPECT(Dart_IsNull(old_pwph));
1574 Dart_Handle new_pwph = Dart_Null(); 1567 Dart_Handle new_pwph = Dart_Null();
1575 EXPECT(Dart_IsNull(new_pwph)); 1568 EXPECT(Dart_IsNull(new_pwph));
1576 Dart_EnterScope(); 1569 Dart_EnterScope();
1577 { 1570 {
1578 Isolate* isolate = Isolate::Current(); 1571 Isolate* isolate = Isolate::Current();
1579 DARTSCOPE(isolate); 1572 DARTSCOPE(isolate);
1580 String& str = String::Handle();
1581 str ^= String::New("new space prologue weak", Heap::kNew);
1582 new_pwph = Dart_NewPrologueWeakPersistentHandle( 1573 new_pwph = Dart_NewPrologueWeakPersistentHandle(
1583 Api::NewLocalHandle(isolate, str), NULL, NULL); 1574 Api::NewHandle(isolate,
1575 String::New("new space prologue weak", Heap::kNew)),
1576 NULL, NULL);
1584 EXPECT_VALID(new_pwph); 1577 EXPECT_VALID(new_pwph);
1585 EXPECT(!Dart_IsNull(new_pwph)); 1578 EXPECT(!Dart_IsNull(new_pwph));
1586 str ^= String::New("old space prologue weak", Heap::kOld);
1587 old_pwph = Dart_NewPrologueWeakPersistentHandle( 1579 old_pwph = Dart_NewPrologueWeakPersistentHandle(
1588 Api::NewLocalHandle(isolate, str), NULL, NULL); 1580 Api::NewHandle(isolate,
1581 String::New("old space prologue weak", Heap::kOld)),
1582 NULL, NULL);
1589 EXPECT_VALID(old_pwph); 1583 EXPECT_VALID(old_pwph);
1590 EXPECT(!Dart_IsNull(old_pwph)); 1584 EXPECT(!Dart_IsNull(old_pwph));
1591 str ^= String::null();
1592 } 1585 }
1593 Dart_ExitScope(); 1586 Dart_ExitScope();
1594 EXPECT_VALID(new_pwph); 1587 EXPECT_VALID(new_pwph);
1595 EXPECT(!Dart_IsNull(new_pwph)); 1588 EXPECT(!Dart_IsNull(new_pwph));
1596 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph)); 1589 EXPECT(Dart_IsPrologueWeakPersistentHandle(new_pwph));
1597 EXPECT_VALID(old_pwph); 1590 EXPECT_VALID(old_pwph);
1598 EXPECT(!Dart_IsNull(old_pwph)); 1591 EXPECT(!Dart_IsNull(old_pwph));
1599 EXPECT(Dart_IsPrologueWeakPersistentHandle(old_pwph)); 1592 EXPECT(Dart_IsPrologueWeakPersistentHandle(old_pwph));
1600 // Garbage collect new space without invoking API callbacks. 1593 // Garbage collect new space without invoking API callbacks.
1601 Isolate::Current()->heap()->CollectGarbage(Heap::kNew, 1594 Isolate::Current()->heap()->CollectGarbage(Heap::kNew,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1636 EXPECT(Dart_IsNull(weak2)); 1629 EXPECT(Dart_IsNull(weak2));
1637 1630
1638 Dart_Handle weak3 = Dart_Null(); 1631 Dart_Handle weak3 = Dart_Null();
1639 EXPECT(Dart_IsNull(weak3)); 1632 EXPECT(Dart_IsNull(weak3));
1640 1633
1641 1634
1642 Dart_EnterScope(); 1635 Dart_EnterScope();
1643 { 1636 {
1644 Isolate* isolate = Isolate::Current(); 1637 Isolate* isolate = Isolate::Current();
1645 DARTSCOPE(isolate); 1638 DARTSCOPE(isolate);
1646 String& str = String::Handle();
1647 1639
1648 str ^= String::New("strongly reachable", Heap::kOld); 1640 strong = Dart_NewPersistentHandle(
1649 strong = Dart_NewPersistentHandle(Api::NewLocalHandle(isolate, str)); 1641 Api::NewHandle(isolate, String::New("strongly reachable", Heap::kOld)));
1650 EXPECT(!Dart_IsNull(strong)); 1642 EXPECT(!Dart_IsNull(strong));
1651 EXPECT_VALID(strong); 1643 EXPECT_VALID(strong);
1652 1644
1653 str ^= String::New("weakly reachable 1", Heap::kOld);
1654 weak1 = Dart_NewWeakPersistentHandle( 1645 weak1 = Dart_NewWeakPersistentHandle(
1655 Api::NewLocalHandle(isolate, str), NULL, NULL); 1646 Api::NewHandle(isolate, String::New("weakly reachable 1", Heap::kOld)),
1647 NULL, NULL);
1656 EXPECT(!Dart_IsNull(weak1)); 1648 EXPECT(!Dart_IsNull(weak1));
1657 EXPECT_VALID(weak1); 1649 EXPECT_VALID(weak1);
1658 1650
1659 str ^= String::New("weakly reachable 2", Heap::kOld);
1660 weak2 = Dart_NewWeakPersistentHandle( 1651 weak2 = Dart_NewWeakPersistentHandle(
1661 Api::NewLocalHandle(isolate, str), NULL, NULL); 1652 Api::NewHandle(isolate, String::New("weakly reachable 2", Heap::kOld)),
1653 NULL, NULL);
1662 EXPECT(!Dart_IsNull(weak2)); 1654 EXPECT(!Dart_IsNull(weak2));
1663 EXPECT_VALID(weak2); 1655 EXPECT_VALID(weak2);
1664 1656
1665 str ^= String::New("weakly reachable 3", Heap::kOld);
1666 weak3 = Dart_NewWeakPersistentHandle( 1657 weak3 = Dart_NewWeakPersistentHandle(
1667 Api::NewLocalHandle(isolate, str), NULL, NULL); 1658 Api::NewHandle(isolate, String::New("weakly reachable 3", Heap::kOld)),
1659 NULL, NULL);
1668 EXPECT(!Dart_IsNull(weak3)); 1660 EXPECT(!Dart_IsNull(weak3));
1669 EXPECT_VALID(weak3); 1661 EXPECT_VALID(weak3);
1670 } 1662 }
1671 Dart_ExitScope(); 1663 Dart_ExitScope();
1672 1664
1673 EXPECT_VALID(strong); 1665 EXPECT_VALID(strong);
1674 1666
1675 EXPECT_VALID(weak1); 1667 EXPECT_VALID(weak1);
1676 EXPECT_VALID(weak2); 1668 EXPECT_VALID(weak2);
1677 EXPECT_VALID(weak3); 1669 EXPECT_VALID(weak3);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
1977 EXPECT(state != NULL); 1969 EXPECT(state != NULL);
1978 ApiLocalScope* scope = state->top_scope(); 1970 ApiLocalScope* scope = state->top_scope();
1979 Dart_Handle handles[300]; 1971 Dart_Handle handles[300];
1980 { 1972 {
1981 DARTSCOPE_NOCHECKS(isolate); 1973 DARTSCOPE_NOCHECKS(isolate);
1982 Smi& val = Smi::Handle(); 1974 Smi& val = Smi::Handle();
1983 1975
1984 // Start a new scope and allocate some local handles. 1976 // Start a new scope and allocate some local handles.
1985 Dart_EnterScope(); 1977 Dart_EnterScope();
1986 for (int i = 0; i < 100; i++) { 1978 for (int i = 0; i < 100; i++) {
1987 val ^= Smi::New(i); 1979 handles[i] = Api::NewHandle(isolate, Smi::New(i));
1988 handles[i] = Api::NewLocalHandle(isolate, val);
1989 } 1980 }
1990 EXPECT_EQ(100, state->CountLocalHandles()); 1981 EXPECT_EQ(100, state->CountLocalHandles());
1991 for (int i = 0; i < 100; i++) { 1982 for (int i = 0; i < 100; i++) {
1992 val ^= Api::UnwrapHandle(handles[i]); 1983 val ^= Api::UnwrapHandle(handles[i]);
1993 EXPECT_EQ(i, val.Value()); 1984 EXPECT_EQ(i, val.Value());
1994 } 1985 }
1995 // Start another scope and allocate some more local handles. 1986 // Start another scope and allocate some more local handles.
1996 { 1987 {
1997 Dart_EnterScope(); 1988 Dart_EnterScope();
1998 for (int i = 100; i < 200; i++) { 1989 for (int i = 100; i < 200; i++) {
1999 val ^= Smi::New(i); 1990 handles[i] = Api::NewHandle(isolate, Smi::New(i));
2000 handles[i] = Api::NewLocalHandle(isolate, val);
2001 } 1991 }
2002 EXPECT_EQ(200, state->CountLocalHandles()); 1992 EXPECT_EQ(200, state->CountLocalHandles());
2003 for (int i = 100; i < 200; i++) { 1993 for (int i = 100; i < 200; i++) {
2004 val ^= Api::UnwrapHandle(handles[i]); 1994 val ^= Api::UnwrapHandle(handles[i]);
2005 EXPECT_EQ(i, val.Value()); 1995 EXPECT_EQ(i, val.Value());
2006 } 1996 }
2007 1997
2008 // Start another scope and allocate some more local handles. 1998 // Start another scope and allocate some more local handles.
2009 { 1999 {
2010 Dart_EnterScope(); 2000 Dart_EnterScope();
2011 for (int i = 200; i < 300; i++) { 2001 for (int i = 200; i < 300; i++) {
2012 val ^= Smi::New(i); 2002 handles[i] = Api::NewHandle(isolate, Smi::New(i));
2013 handles[i] = Api::NewLocalHandle(isolate, val);
2014 } 2003 }
2015 EXPECT_EQ(300, state->CountLocalHandles()); 2004 EXPECT_EQ(300, state->CountLocalHandles());
2016 for (int i = 200; i < 300; i++) { 2005 for (int i = 200; i < 300; i++) {
2017 val ^= Api::UnwrapHandle(handles[i]); 2006 val ^= Api::UnwrapHandle(handles[i]);
2018 EXPECT_EQ(i, val.Value()); 2007 EXPECT_EQ(i, val.Value());
2019 } 2008 }
2020 EXPECT_EQ(300, state->CountLocalHandles()); 2009 EXPECT_EQ(300, state->CountLocalHandles());
2021 VERIFY_ON_TRANSITION; 2010 VERIFY_ON_TRANSITION;
2022 Dart_ExitScope(); 2011 Dart_ExitScope();
2023 } 2012 }
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
3536 EXPECT(Dart_IsError(result)); 3525 EXPECT(Dart_IsError(result));
3537 } 3526 }
3538 3527
3539 3528
3540 TEST_CASE(NullReceiver) { 3529 TEST_CASE(NullReceiver) {
3541 Isolate* isolate = Isolate::Current(); 3530 Isolate* isolate = Isolate::Current();
3542 DARTSCOPE_NOCHECKS(isolate); 3531 DARTSCOPE_NOCHECKS(isolate);
3543 3532
3544 Dart_Handle function_name = Dart_NewString("toString"); 3533 Dart_Handle function_name = Dart_NewString("toString");
3545 const int number_of_arguments = 0; 3534 const int number_of_arguments = 0;
3546 Dart_Handle null_receiver = Api::NewLocalHandle(isolate, Object::Handle()); 3535 Dart_Handle result = Dart_InvokeDynamic(Dart_Null(),
3547 Dart_Handle result = Dart_InvokeDynamic(null_receiver,
3548 function_name, 3536 function_name,
3549 number_of_arguments, 3537 number_of_arguments,
3550 NULL); 3538 NULL);
3551 EXPECT_VALID(result); 3539 EXPECT_VALID(result);
3552 EXPECT(Dart_IsString(result)); 3540 EXPECT(Dart_IsString(result));
3553 3541
3554 // Should throw a NullPointerException. Disabled due to bug 5415268. 3542 // Should throw a NullPointerException. Disabled due to bug 5415268.
3555 /* 3543 /*
3556 Dart_Handle function_name2 = Dart_NewString("NoNoNo"); 3544 Dart_Handle function_name2 = Dart_NewString("NoNoNo");
3557 result = Dart_InvokeDynamic(null_receiver, 3545 result = Dart_InvokeDynamic(null_receiver,
(...skipping 1292 matching lines...) Expand 10 before | Expand all | Expand 10 after
4850 EXPECT_VALID(result); 4838 EXPECT_VALID(result);
4851 EXPECT(Dart_IsDouble(result)); 4839 EXPECT(Dart_IsDouble(result));
4852 double out; 4840 double out;
4853 result = Dart_DoubleValue(result, &out); 4841 result = Dart_DoubleValue(result, &out);
4854 fprintf(stderr, "Benchmark_UseDartApi: %f us per iteration\n", out); 4842 fprintf(stderr, "Benchmark_UseDartApi: %f us per iteration\n", out);
4855 } 4843 }
4856 4844
4857 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). 4845 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64).
4858 4846
4859 } // namespace dart 4847 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_api_impl.cc ('k') | runtime/vm/dart_api_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698