| OLD | NEW |
| 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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/assert.h" | 7 #include "vm/assert.h" |
| 8 #include "vm/dart_api_impl.h" | 8 #include "vm/dart_api_impl.h" |
| 9 #include "vm/dart_api_state.h" | 9 #include "vm/dart_api_state.h" |
| 10 #include "vm/unit_test.h" | 10 #include "vm/unit_test.h" |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 0, | 1075 0, |
| 1076 NULL); | 1076 NULL); |
| 1077 EXPECT_VALID(result); | 1077 EXPECT_VALID(result); |
| 1078 DARTSCOPE_NOCHECKS(Isolate::Current()); | 1078 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1079 Instance& obj = Instance::Handle(); | 1079 Instance& obj = Instance::Handle(); |
| 1080 obj ^= Api::UnwrapHandle(result); | 1080 obj ^= Api::UnwrapHandle(result); |
| 1081 const Class& cls = Class::Handle(obj.clazz()); | 1081 const Class& cls = Class::Handle(obj.clazz()); |
| 1082 // We expect the newly created "NativeFields" object to have | 1082 // We expect the newly created "NativeFields" object to have |
| 1083 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. | 1083 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. |
| 1084 // Hence the size of an instance of "NativeFields" should be | 1084 // Hence the size of an instance of "NativeFields" should be |
| 1085 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. | 1085 // (kNumNativeFields + 2) * kWordSize + size of object header. |
| 1086 // We check to make sure the instance size computed by the VM matches | 1086 // We check to make sure the instance size computed by the VM matches |
| 1087 // our expectations. | 1087 // our expectations. |
| 1088 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, | 1088 intptr_t header_size = sizeof(RawObject); |
| 1089 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + header_size, |
| 1089 kObjectAlignment), | 1090 kObjectAlignment), |
| 1090 cls.instance_size()); | 1091 cls.instance_size()); |
| 1091 } | 1092 } |
| 1092 } | 1093 } |
| 1093 | 1094 |
| 1094 | 1095 |
| 1095 UNIT_TEST_CASE(InjectNativeFields2) { | 1096 UNIT_TEST_CASE(InjectNativeFields2) { |
| 1096 const char* kScriptChars = | 1097 const char* kScriptChars = |
| 1097 "class NativeFields extends NativeFieldsWrapper {\n" | 1098 "class NativeFields extends NativeFieldsWrapper {\n" |
| 1098 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" | 1099 " NativeFields(int i, int j) : fld1 = i, fld2 = j {}\n" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1161 0, | 1162 0, |
| 1162 NULL); | 1163 NULL); |
| 1163 EXPECT_VALID(result); | 1164 EXPECT_VALID(result); |
| 1164 DARTSCOPE_NOCHECKS(Isolate::Current()); | 1165 DARTSCOPE_NOCHECKS(Isolate::Current()); |
| 1165 Instance& obj = Instance::Handle(); | 1166 Instance& obj = Instance::Handle(); |
| 1166 obj ^= Api::UnwrapHandle(result); | 1167 obj ^= Api::UnwrapHandle(result); |
| 1167 const Class& cls = Class::Handle(obj.clazz()); | 1168 const Class& cls = Class::Handle(obj.clazz()); |
| 1168 // We expect the newly created "NativeFields" object to have | 1169 // We expect the newly created "NativeFields" object to have |
| 1169 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. | 1170 // 2 dart instance fields (fld1, fld2) and kNumNativeFields native fields. |
| 1170 // Hence the size of an instance of "NativeFields" should be | 1171 // Hence the size of an instance of "NativeFields" should be |
| 1171 // (kNumNativeFields + 2) * kWordSize + sizeof the header word. | 1172 // (kNumNativeFields + 2) * kWordSize + size of object header. |
| 1172 // We check to make sure the instance size computed by the VM matches | 1173 // We check to make sure the instance size computed by the VM matches |
| 1173 // our expectations. | 1174 // our expectations. |
| 1174 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + kWordSize, | 1175 intptr_t header_size = sizeof(RawObject); |
| 1176 EXPECT_EQ(Utils::RoundUp(((kNumNativeFields + 2) * kWordSize) + header_size, |
| 1175 kObjectAlignment), | 1177 kObjectAlignment), |
| 1176 cls.instance_size()); | 1178 cls.instance_size()); |
| 1177 } | 1179 } |
| 1178 } | 1180 } |
| 1179 | 1181 |
| 1180 | 1182 |
| 1181 UNIT_TEST_CASE(InjectNativeFields4) { | 1183 UNIT_TEST_CASE(InjectNativeFields4) { |
| 1182 const char* kScriptChars = | 1184 const char* kScriptChars = |
| 1183 "#import('dart:nativewrappers');" | 1185 "#import('dart:nativewrappers');" |
| 1184 "class NativeFields extends NativeFieldWrapperClass2 {\n" | 1186 "class NativeFields extends NativeFieldWrapperClass2 {\n" |
| (...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2764 } | 2766 } |
| 2765 | 2767 |
| 2766 | 2768 |
| 2767 UNIT_TEST_CASE(RunLoop_Exception) { | 2769 UNIT_TEST_CASE(RunLoop_Exception) { |
| 2768 RunLoopTest(true); | 2770 RunLoopTest(true); |
| 2769 } | 2771 } |
| 2770 | 2772 |
| 2771 #endif // TARGET_ARCH_IA32. | 2773 #endif // TARGET_ARCH_IA32. |
| 2772 | 2774 |
| 2773 } // namespace dart | 2775 } // namespace dart |
| OLD | NEW |