Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "bin/builtin.h" | 5 #include "bin/builtin.h" |
| 6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
| 7 #include "include/dart_debugger_api.h" | 7 #include "include/dart_debugger_api.h" |
| 8 #include "include/dart_mirrors_api.h" | 8 #include "include/dart_mirrors_api.h" |
| 9 #include "include/dart_native_api.h" | 9 #include "include/dart_native_api.h" |
| 10 #include "platform/assert.h" | 10 #include "platform/assert.h" |
| (...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1015 EXPECT_EQ(41, peer16); | 1015 EXPECT_EQ(41, peer16); |
| 1016 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); | 1016 Isolate::Current()->heap()->CollectGarbage(Heap::kOld); |
| 1017 EXPECT_EQ(40, peer8); | 1017 EXPECT_EQ(40, peer8); |
| 1018 EXPECT_EQ(41, peer16); | 1018 EXPECT_EQ(41, peer16); |
| 1019 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); | 1019 Isolate::Current()->heap()->CollectGarbage(Heap::kNew); |
| 1020 EXPECT_EQ(80, peer8); | 1020 EXPECT_EQ(80, peer8); |
| 1021 EXPECT_EQ(82, peer16); | 1021 EXPECT_EQ(82, peer16); |
| 1022 } | 1022 } |
| 1023 | 1023 |
| 1024 | 1024 |
| 1025 TEST_CASE(ExternalStringPretenure) { | |
| 1026 Isolate* isolate = Isolate::Current(); | |
| 1027 { | |
| 1028 Dart_EnterScope(); | |
| 1029 static const uint8_t big_data8[16*MB] = {0, }; | |
| 1030 Dart_Handle big8 = Dart_NewExternalLatin1String( | |
| 1031 big_data8, | |
| 1032 ARRAY_SIZE(big_data8), | |
| 1033 NULL, | |
| 1034 NULL); | |
| 1035 EXPECT_VALID(big8); | |
| 1036 static const uint16_t big_data16[16*MB/2] = {0, }; | |
| 1037 Dart_Handle big16 = Dart_NewExternalUTF16String( | |
| 1038 big_data16, | |
| 1039 ARRAY_SIZE(big_data16), | |
| 1040 NULL, | |
| 1041 NULL); | |
| 1042 EXPECT_VALID(big16); | |
| 1043 { | |
| 1044 DARTSCOPE(isolate); | |
| 1045 String& handle = String::Handle(); | |
| 1046 handle ^= Api::UnwrapHandle(big8); | |
| 1047 EXPECT(handle.IsOld()); | |
|
Ivan Posva
2014/03/05 20:48:42
How about also testing that small external strings
koda
2014/03/05 21:08:59
Done.
| |
| 1048 handle ^= Api::UnwrapHandle(big16); | |
| 1049 EXPECT(handle.IsOld()); | |
| 1050 } | |
| 1051 Dart_ExitScope(); | |
| 1052 } | |
| 1053 } | |
| 1054 | |
| 1055 | |
| 1056 TEST_CASE(ExternalTypedDataPretenure) { | |
| 1057 Isolate* isolate = Isolate::Current(); | |
| 1058 { | |
| 1059 Dart_EnterScope(); | |
| 1060 static const int kLength = 16*MB/8; | |
| 1061 int64_t* big_data = new int64_t[kLength](); | |
| 1062 Dart_Handle big = Dart_NewExternalTypedData( | |
| 1063 Dart_TypedData_kInt64, | |
| 1064 big_data, | |
| 1065 kLength); | |
| 1066 EXPECT_VALID(big); | |
| 1067 { | |
| 1068 DARTSCOPE(isolate); | |
| 1069 ExternalTypedData& handle = ExternalTypedData::Handle(); | |
| 1070 handle ^= Api::UnwrapHandle(big); | |
| 1071 EXPECT(handle.IsOld()); | |
|
Ivan Posva
2014/03/05 20:48:42
ditto
koda
2014/03/05 21:08:59
Done.
| |
| 1072 } | |
| 1073 delete[] big_data; | |
| 1074 Dart_ExitScope(); | |
| 1075 } | |
| 1076 } | |
| 1077 | |
| 1078 | |
| 1025 TEST_CASE(ListAccess) { | 1079 TEST_CASE(ListAccess) { |
| 1026 const char* kScriptChars = | 1080 const char* kScriptChars = |
| 1027 "List testMain() {" | 1081 "List testMain() {" |
| 1028 " List a = new List();" | 1082 " List a = new List();" |
| 1029 " a.add(10);" | 1083 " a.add(10);" |
| 1030 " a.add(20);" | 1084 " a.add(20);" |
| 1031 " a.add(30);" | 1085 " a.add(30);" |
| 1032 " return a;" | 1086 " return a;" |
| 1033 "}" | 1087 "}" |
| 1034 "" | 1088 "" |
| (...skipping 6882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7917 NewString("main"), | 7971 NewString("main"), |
| 7918 1, | 7972 1, |
| 7919 dart_args); | 7973 dart_args); |
| 7920 int64_t value = 0; | 7974 int64_t value = 0; |
| 7921 result = Dart_IntegerToInt64(result, &value); | 7975 result = Dart_IntegerToInt64(result, &value); |
| 7922 EXPECT_VALID(result); | 7976 EXPECT_VALID(result); |
| 7923 EXPECT_EQ(6, value); | 7977 EXPECT_EQ(6, value); |
| 7924 } | 7978 } |
| 7925 | 7979 |
| 7926 } // namespace dart | 7980 } // namespace dart |
| OLD | NEW |