| 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 static const uint8_t small_data8[] = {'f', 'o', 'o'}; |
| 1043 Dart_Handle small8 = Dart_NewExternalLatin1String( |
| 1044 small_data8, |
| 1045 ARRAY_SIZE(small_data8), |
| 1046 NULL, |
| 1047 NULL); |
| 1048 EXPECT_VALID(small8); |
| 1049 static const uint16_t small_data16[] = {'b', 'a', 'r'}; |
| 1050 Dart_Handle small16 = Dart_NewExternalUTF16String( |
| 1051 small_data16, |
| 1052 ARRAY_SIZE(small_data16), |
| 1053 NULL, |
| 1054 NULL); |
| 1055 EXPECT_VALID(small16); |
| 1056 { |
| 1057 DARTSCOPE(isolate); |
| 1058 String& handle = String::Handle(); |
| 1059 handle ^= Api::UnwrapHandle(big8); |
| 1060 EXPECT(handle.IsOld()); |
| 1061 handle ^= Api::UnwrapHandle(big16); |
| 1062 EXPECT(handle.IsOld()); |
| 1063 handle ^= Api::UnwrapHandle(small8); |
| 1064 EXPECT(handle.IsNew()); |
| 1065 handle ^= Api::UnwrapHandle(small16); |
| 1066 EXPECT(handle.IsNew()); |
| 1067 } |
| 1068 Dart_ExitScope(); |
| 1069 } |
| 1070 } |
| 1071 |
| 1072 |
| 1073 TEST_CASE(ExternalTypedDataPretenure) { |
| 1074 Isolate* isolate = Isolate::Current(); |
| 1075 { |
| 1076 Dart_EnterScope(); |
| 1077 static const int kBigLength = 16*MB/8; |
| 1078 int64_t* big_data = new int64_t[kBigLength](); |
| 1079 Dart_Handle big = Dart_NewExternalTypedData( |
| 1080 Dart_TypedData_kInt64, |
| 1081 big_data, |
| 1082 kBigLength); |
| 1083 EXPECT_VALID(big); |
| 1084 static const int kSmallLength = 16*KB/8; |
| 1085 int64_t* small_data = new int64_t[kSmallLength](); |
| 1086 Dart_Handle small = Dart_NewExternalTypedData( |
| 1087 Dart_TypedData_kInt64, |
| 1088 small_data, |
| 1089 kSmallLength); |
| 1090 EXPECT_VALID(small); |
| 1091 { |
| 1092 DARTSCOPE(isolate); |
| 1093 ExternalTypedData& handle = ExternalTypedData::Handle(); |
| 1094 handle ^= Api::UnwrapHandle(big); |
| 1095 EXPECT(handle.IsOld()); |
| 1096 handle ^= Api::UnwrapHandle(small); |
| 1097 EXPECT(handle.IsNew()); |
| 1098 } |
| 1099 Dart_ExitScope(); |
| 1100 delete[] big_data; |
| 1101 delete[] small_data; |
| 1102 } |
| 1103 } |
| 1104 |
| 1105 |
| 1025 TEST_CASE(ListAccess) { | 1106 TEST_CASE(ListAccess) { |
| 1026 const char* kScriptChars = | 1107 const char* kScriptChars = |
| 1027 "List testMain() {" | 1108 "List testMain() {" |
| 1028 " List a = new List();" | 1109 " List a = new List();" |
| 1029 " a.add(10);" | 1110 " a.add(10);" |
| 1030 " a.add(20);" | 1111 " a.add(20);" |
| 1031 " a.add(30);" | 1112 " a.add(30);" |
| 1032 " return a;" | 1113 " return a;" |
| 1033 "}" | 1114 "}" |
| 1034 "" | 1115 "" |
| (...skipping 6882 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7917 NewString("main"), | 7998 NewString("main"), |
| 7918 1, | 7999 1, |
| 7919 dart_args); | 8000 dart_args); |
| 7920 int64_t value = 0; | 8001 int64_t value = 0; |
| 7921 result = Dart_IntegerToInt64(result, &value); | 8002 result = Dart_IntegerToInt64(result, &value); |
| 7922 EXPECT_VALID(result); | 8003 EXPECT_VALID(result); |
| 7923 EXPECT_EQ(6, value); | 8004 EXPECT_EQ(6, value); |
| 7924 } | 8005 } |
| 7925 | 8006 |
| 7926 } // namespace dart | 8007 } // namespace dart |
| OLD | NEW |