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 "include/dart_api.h" | 5 #include "include/dart_api.h" |
6 #include "platform/assert.h" | 6 #include "platform/assert.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.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/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 while (frames.NextFrame() != NULL) { | 68 while (frames.NextFrame() != NULL) { |
69 count += 1; // Count the dart frame. | 69 count += 1; // Count the dart frame. |
70 } | 70 } |
71 VerifyPointersVisitor::VerifyPointers(); | 71 VerifyPointersVisitor::VerifyPointers(); |
72 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 72 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
73 arguments->SetReturn(Object::Handle(Smi::New(count))); | 73 arguments->SetReturn(Object::Handle(Smi::New(count))); |
74 } | 74 } |
75 | 75 |
76 | 76 |
77 void FUNCTION_NAME(StackFrame_validateFrame)(Dart_NativeArguments args) { | 77 void FUNCTION_NAME(StackFrame_validateFrame)(Dart_NativeArguments args) { |
78 Dart_EnterScope(); | |
79 Dart_Handle index = Dart_GetNativeArgument(args, 0); | 78 Dart_Handle index = Dart_GetNativeArgument(args, 0); |
80 Dart_Handle name = Dart_GetNativeArgument(args, 1); | 79 Dart_Handle name = Dart_GetNativeArgument(args, 1); |
81 const Smi& frame_index_smi = Smi::CheckedHandle(Api::UnwrapHandle(index)); | 80 const Smi& frame_index_smi = Smi::CheckedHandle(Api::UnwrapHandle(index)); |
82 const char* expected_name = | 81 const char* expected_name = |
83 String::CheckedHandle(Api::UnwrapHandle(name)).ToCString(); | 82 String::CheckedHandle(Api::UnwrapHandle(name)).ToCString(); |
84 int frame_index = frame_index_smi.Value(); | 83 int frame_index = frame_index_smi.Value(); |
85 int count = 0; | 84 int count = 0; |
86 DartFrameIterator frames; | 85 DartFrameIterator frames; |
87 StackFrame* frame = frames.NextFrame(); | 86 StackFrame* frame = frames.NextFrame(); |
88 while (frame != NULL) { | 87 while (frame != NULL) { |
(...skipping 12 matching lines...) Expand all Loading... |
101 const Library& lib = Library::Handle(Library::LookupLibrary(url)); | 100 const Library& lib = Library::Handle(Library::LookupLibrary(url)); |
102 ASSERT(!lib.IsNull()); | 101 ASSERT(!lib.IsNull()); |
103 const char* lib_name = String::Handle(lib.url()).ToCString(); | 102 const char* lib_name = String::Handle(lib.url()).ToCString(); |
104 intptr_t length = OS::SNPrint(NULL, 0, "%s_%s", lib_name, expected_name); | 103 intptr_t length = OS::SNPrint(NULL, 0, "%s_%s", lib_name, expected_name); |
105 char* full_name = isolate->current_zone()->Alloc<char>(length + 1); | 104 char* full_name = isolate->current_zone()->Alloc<char>(length + 1); |
106 ASSERT(full_name != NULL); | 105 ASSERT(full_name != NULL); |
107 OS::SNPrint(full_name, (length + 1), "%s_%s", lib_name, expected_name); | 106 OS::SNPrint(full_name, (length + 1), "%s_%s", lib_name, expected_name); |
108 if (strcmp(full_name, name) != 0) { | 107 if (strcmp(full_name, name) != 0) { |
109 FATAL("StackFrame_validateFrame fails, incorrect frame.\n"); | 108 FATAL("StackFrame_validateFrame fails, incorrect frame.\n"); |
110 } | 109 } |
111 Dart_ExitScope(); | |
112 return; | 110 return; |
113 } | 111 } |
114 count += 1; // Count the dart frames. | 112 count += 1; // Count the dart frames. |
115 frame = frames.NextFrame(); | 113 frame = frames.NextFrame(); |
116 } | 114 } |
117 FATAL("StackFrame_validateFrame fails, frame count < index passed in.\n"); | 115 FATAL("StackFrame_validateFrame fails, frame count < index passed in.\n"); |
118 } | 116 } |
119 | 117 |
120 | 118 |
121 // List all native functions implemented in the vm or core boot strap dart | 119 // List all native functions implemented in the vm or core boot strap dart |
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 " }" | 278 " }" |
281 "}"; | 279 "}"; |
282 Dart_Handle lib = TestCase::LoadTestScript( | 280 Dart_Handle lib = TestCase::LoadTestScript( |
283 kScriptChars, | 281 kScriptChars, |
284 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 282 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
285 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); | 283 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); |
286 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); | 284 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); |
287 } | 285 } |
288 | 286 |
289 } // namespace dart | 287 } // namespace dart |
OLD | NEW |