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/globals.h" | 6 #include "vm/globals.h" |
7 | 7 |
8 #include "vm/ast.h" | 8 #include "vm/ast.h" |
9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
10 #include "vm/code_descriptors.h" | 10 #include "vm/code_descriptors.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 | 171 |
172 | 172 |
173 static void NativeFunc(Dart_NativeArguments args) { | 173 static void NativeFunc(Dart_NativeArguments args) { |
174 Dart_Handle i = Dart_GetNativeArgument(args, 0); | 174 Dart_Handle i = Dart_GetNativeArgument(args, 0); |
175 Dart_Handle k = Dart_GetNativeArgument(args, 1); | 175 Dart_Handle k = Dart_GetNativeArgument(args, 1); |
176 int64_t value = -1; | 176 int64_t value = -1; |
177 EXPECT_VALID(Dart_IntegerToInt64(i, &value)); | 177 EXPECT_VALID(Dart_IntegerToInt64(i, &value)); |
178 EXPECT_EQ(10, value); | 178 EXPECT_EQ(10, value); |
179 EXPECT_VALID(Dart_IntegerToInt64(k, &value)); | 179 EXPECT_VALID(Dart_IntegerToInt64(k, &value)); |
180 EXPECT_EQ(20, value); | 180 EXPECT_EQ(20, value); |
181 Isolate::Current()->heap()->CollectAllGarbage(); | 181 { |
| 182 TransitionNativeToVM transition(Thread::Current()); |
| 183 Isolate::Current()->heap()->CollectAllGarbage(); |
| 184 } |
182 } | 185 } |
183 | 186 |
184 | 187 |
185 static Dart_NativeFunction native_resolver(Dart_Handle name, | 188 static Dart_NativeFunction native_resolver(Dart_Handle name, |
186 int argument_count, | 189 int argument_count, |
187 bool* auto_setup_scope) { | 190 bool* auto_setup_scope) { |
188 ASSERT(auto_setup_scope); | 191 ASSERT(auto_setup_scope); |
189 *auto_setup_scope = false; | 192 *auto_setup_scope = false; |
190 return reinterpret_cast<Dart_NativeFunction>(&NativeFunc); | 193 return reinterpret_cast<Dart_NativeFunction>(&NativeFunc); |
191 } | 194 } |
(...skipping 12 matching lines...) Expand all Loading... |
204 " i = 10; s1 = 'abcd'; k = 20; s2 = 'B'; s3 = 'C';" | 207 " i = 10; s1 = 'abcd'; k = 20; s2 = 'B'; s3 = 'C';" |
205 " func(i, k);" | 208 " func(i, k);" |
206 " return i + k; }" | 209 " return i + k; }" |
207 " static int moo() {" | 210 " static int moo() {" |
208 " var i = A.foo();" | 211 " var i = A.foo();" |
209 " Expect.equals(30, i);" | 212 " Expect.equals(30, i);" |
210 " }\n" | 213 " }\n" |
211 "}\n"; | 214 "}\n"; |
212 // First setup the script and compile the script. | 215 // First setup the script and compile the script. |
213 TestCase::LoadTestScript(kScriptChars, native_resolver); | 216 TestCase::LoadTestScript(kScriptChars, native_resolver); |
| 217 TransitionNativeToVM transition(thread); |
| 218 |
214 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 219 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
215 const String& name = String::Handle(String::New(TestCase::url())); | 220 const String& name = String::Handle(String::New(TestCase::url())); |
216 const Library& lib = Library::Handle(Library::LookupLibrary(name)); | 221 const Library& lib = Library::Handle(Library::LookupLibrary(name)); |
217 EXPECT(!lib.IsNull()); | 222 EXPECT(!lib.IsNull()); |
218 Class& cls = Class::Handle( | 223 Class& cls = Class::Handle( |
219 lib.LookupClass(String::Handle(Symbols::New("A")))); | 224 lib.LookupClass(String::Handle(Symbols::New("A")))); |
220 EXPECT(!cls.IsNull()); | 225 EXPECT(!cls.IsNull()); |
221 | 226 |
222 // Now compile the two functions 'A.foo' and 'A.moo' | 227 // Now compile the two functions 'A.foo' and 'A.moo' |
223 String& function_moo_name = String::Handle(String::New("moo")); | 228 String& function_moo_name = String::Handle(String::New("moo")); |
(...skipping 17 matching lines...) Expand all Loading... |
241 stack_bitmap->Set(0, false); // var i. | 246 stack_bitmap->Set(0, false); // var i. |
242 stack_bitmap->Set(1, true); // var s1. | 247 stack_bitmap->Set(1, true); // var s1. |
243 stack_bitmap->Set(2, false); // var k. | 248 stack_bitmap->Set(2, false); // var k. |
244 stack_bitmap->Set(3, true); // var s2. | 249 stack_bitmap->Set(3, true); // var s2. |
245 stack_bitmap->Set(4, true); // var s3. | 250 stack_bitmap->Set(4, true); // var s3. |
246 const Code& code = Code::Handle(function_foo.unoptimized_code()); | 251 const Code& code = Code::Handle(function_foo.unoptimized_code()); |
247 // Search for the pc of the call to 'func'. | 252 // Search for the pc of the call to 'func'. |
248 const PcDescriptors& descriptors = | 253 const PcDescriptors& descriptors = |
249 PcDescriptors::Handle(code.pc_descriptors()); | 254 PcDescriptors::Handle(code.pc_descriptors()); |
250 int call_count = 0; | 255 int call_count = 0; |
251 PcDescriptors::Iterator iter(descriptors, RawPcDescriptors::kUnoptStaticCall); | 256 PcDescriptors::Iterator iter(descriptors, |
| 257 RawPcDescriptors::kUnoptStaticCall); |
252 while (iter.MoveNext()) { | 258 while (iter.MoveNext()) { |
253 stackmap_table_builder->AddEntry(iter.PcOffset(), stack_bitmap, 0); | 259 stackmap_table_builder->AddEntry(iter.PcOffset(), stack_bitmap, 0); |
254 ++call_count; | 260 ++call_count; |
255 } | 261 } |
256 // We can't easily check that we put the stackmap at the correct pc, but | 262 // We can't easily check that we put the stackmap at the correct pc, but |
257 // we did if there was exactly one call seen. | 263 // we did if there was exactly one call seen. |
258 EXPECT(call_count == 1); | 264 EXPECT(call_count == 1); |
259 const Array& stack_maps = | 265 const Array& stack_maps = |
260 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); | 266 Array::Handle(stackmap_table_builder->FinalizeStackmaps(code)); |
261 code.set_stackmaps(stack_maps); | 267 code.set_stackmaps(stack_maps); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 if (token_positions[i] != it.TokenPos()) { | 364 if (token_positions[i] != it.TokenPos()) { |
359 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", | 365 OS::Print("[%" Pd "]: Expected: %" Pd " != %" Pd "\n", |
360 i, token_positions[i], it.TokenPos()); | 366 i, token_positions[i], it.TokenPos()); |
361 } | 367 } |
362 EXPECT(token_positions[i] == it.TokenPos()); | 368 EXPECT(token_positions[i] == it.TokenPos()); |
363 i++; | 369 i++; |
364 } | 370 } |
365 } | 371 } |
366 | 372 |
367 } // namespace dart | 373 } // namespace dart |
OLD | NEW |