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 "vm/stack_frame.h" | 5 #include "vm/stack_frame.h" |
6 #include "include/dart_api.h" | 6 #include "include/dart_api.h" |
7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_api_impl.h" | 10 #include "vm/dart_api_impl.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 49 } |
50 | 50 |
51 void FUNCTION_NAME(StackFrame_frameCount)(Dart_NativeArguments args) { | 51 void FUNCTION_NAME(StackFrame_frameCount)(Dart_NativeArguments args) { |
52 int count = 0; | 52 int count = 0; |
53 StackFrameIterator frames(StackFrameIterator::kValidateFrames, | 53 StackFrameIterator frames(StackFrameIterator::kValidateFrames, |
54 Thread::Current(), | 54 Thread::Current(), |
55 StackFrameIterator::kNoCrossThreadIteration); | 55 StackFrameIterator::kNoCrossThreadIteration); |
56 while (frames.NextFrame() != NULL) { | 56 while (frames.NextFrame() != NULL) { |
57 count += 1; // Count the frame. | 57 count += 1; // Count the frame. |
58 } | 58 } |
59 VerifyPointersVisitor::VerifyPointers(); | 59 { |
| 60 TransitionNativeToVM transition(Thread::Current()); |
| 61 VerifyPointersVisitor::VerifyPointers(); |
| 62 } |
60 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 63 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
61 arguments->SetReturn(Object::Handle(Smi::New(count))); | 64 arguments->SetReturn(Object::Handle(Smi::New(count))); |
62 } | 65 } |
63 | 66 |
64 void FUNCTION_NAME(StackFrame_dartFrameCount)(Dart_NativeArguments args) { | 67 void FUNCTION_NAME(StackFrame_dartFrameCount)(Dart_NativeArguments args) { |
65 int count = 0; | 68 int count = 0; |
66 DartFrameIterator frames(Thread::Current(), | 69 DartFrameIterator frames(Thread::Current(), |
67 StackFrameIterator::kNoCrossThreadIteration); | 70 StackFrameIterator::kNoCrossThreadIteration); |
68 while (frames.NextFrame() != NULL) { | 71 while (frames.NextFrame() != NULL) { |
69 count += 1; // Count the dart frame. | 72 count += 1; // Count the dart frame. |
70 } | 73 } |
71 VerifyPointersVisitor::VerifyPointers(); | 74 { |
| 75 TransitionNativeToVM transition(Thread::Current()); |
| 76 VerifyPointersVisitor::VerifyPointers(); |
| 77 } |
72 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 78 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
73 arguments->SetReturn(Object::Handle(Smi::New(count))); | 79 arguments->SetReturn(Object::Handle(Smi::New(count))); |
74 } | 80 } |
75 | 81 |
76 void FUNCTION_NAME(StackFrame_validateFrame)(Dart_NativeArguments args) { | 82 void FUNCTION_NAME(StackFrame_validateFrame)(Dart_NativeArguments args) { |
77 Thread* thread = Thread::Current(); | 83 Thread* thread = Thread::Current(); |
78 Zone* zone = thread->zone(); | 84 Zone* zone = thread->zone(); |
79 | 85 |
80 Dart_Handle index = Dart_GetNativeArgument(args, 0); | 86 Dart_Handle index = Dart_GetNativeArgument(args, 0); |
81 Dart_Handle name = Dart_GetNativeArgument(args, 1); | 87 Dart_Handle name = Dart_GetNativeArgument(args, 1); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 " }" | 319 " }" |
314 "}"; | 320 "}"; |
315 } | 321 } |
316 Dart_Handle lib = TestCase::LoadTestScript( | 322 Dart_Handle lib = TestCase::LoadTestScript( |
317 kScriptChars, reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 323 kScriptChars, reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
318 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); | 324 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); |
319 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); | 325 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); |
320 } | 326 } |
321 | 327 |
322 } // namespace dart | 328 } // namespace dart |
OLD | NEW |