| 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/class_finalizer.h" | 6 #include "vm/class_finalizer.h" |
| 7 #include "vm/code_patcher.h" | 7 #include "vm/code_patcher.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); | 155 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
| 156 } | 156 } |
| 157 | 157 |
| 158 | 158 |
| 159 TEST_CASE(EvalExpressionExhaustCIDs) { | 159 TEST_CASE(EvalExpressionExhaustCIDs) { |
| 160 Library& lib = Library::Handle(Library::CoreLibrary()); | 160 Library& lib = Library::Handle(Library::CoreLibrary()); |
| 161 | 161 |
| 162 const String& expression = String::Handle(String::New("3 + 4")); | 162 const String& expression = String::Handle(String::New("3 + 4")); |
| 163 Object& val = Object::Handle(); | 163 Object& val = Object::Handle(); |
| 164 | 164 |
| 165 const intptr_t classTableSize = 1 << RawObject::kClassIdTagSize; | 165 // Run once to ensure everything we touch is compiled. |
| 166 for (intptr_t i = 0; i < classTableSize; i++) { | 166 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); |
| 167 StackZone zone(Isolate::Current()); | |
| 168 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); | |
| 169 } | |
| 170 | |
| 171 EXPECT(!val.IsNull()); | 167 EXPECT(!val.IsNull()); |
| 172 EXPECT(!val.IsError()); | 168 EXPECT(!val.IsError()); |
| 173 EXPECT(val.IsInteger()); | 169 EXPECT(val.IsInteger()); |
| 174 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); | 170 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
| 171 |
| 172 intptr_t initial_class_table_size = |
| 173 Isolate::Current()->class_table()->NumCids(); |
| 174 |
| 175 val = lib.Evaluate(expression, Array::empty_array(), Array::empty_array()); |
| 176 EXPECT(!val.IsNull()); |
| 177 EXPECT(!val.IsError()); |
| 178 EXPECT(val.IsInteger()); |
| 179 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); |
| 180 |
| 181 intptr_t final_class_table_size = |
| 182 Isolate::Current()->class_table()->NumCids(); |
| 183 // Eval should not eat into this non-renewable resource. |
| 184 EXPECT_EQ(initial_class_table_size, final_class_table_size); |
| 175 } | 185 } |
| 176 | 186 |
| 177 } // namespace dart | 187 } // namespace dart |
| OLD | NEW |