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 Thread* thread = Thread::Current(); |
| 79 Zone* zone = thread->zone(); |
| 80 |
78 Dart_Handle index = Dart_GetNativeArgument(args, 0); | 81 Dart_Handle index = Dart_GetNativeArgument(args, 0); |
79 Dart_Handle name = Dart_GetNativeArgument(args, 1); | 82 Dart_Handle name = Dart_GetNativeArgument(args, 1); |
80 const Smi& frame_index_smi = Smi::CheckedHandle(Api::UnwrapHandle(index)); | 83 const Smi& frame_index_smi = Smi::CheckedHandle(Api::UnwrapHandle(index)); |
81 const char* expected_name = | 84 const char* expected_name = |
82 String::CheckedHandle(Api::UnwrapHandle(name)).ToCString(); | 85 String::CheckedHandle(Api::UnwrapHandle(name)).ToCString(); |
83 int frame_index = frame_index_smi.Value(); | 86 int frame_index = frame_index_smi.Value(); |
84 int count = 0; | 87 int count = 0; |
85 DartFrameIterator frames; | 88 DartFrameIterator frames; |
86 StackFrame* frame = frames.NextFrame(); | 89 StackFrame* frame = frames.NextFrame(); |
87 while (frame != NULL) { | 90 while (frame != NULL) { |
88 if (count == frame_index) { | 91 if (count == frame_index) { |
89 // Find the function corresponding to this frame and check if it | 92 // Find the function corresponding to this frame and check if it |
90 // matches the function name passed in. | 93 // matches the function name passed in. |
91 const Function& function = | 94 const Function& function = |
92 Function::Handle(frame->LookupDartFunction()); | 95 Function::Handle(zone, frame->LookupDartFunction()); |
93 if (function.IsNull()) { | 96 if (function.IsNull()) { |
94 FATAL("StackFrame_validateFrame fails, invalid dart frame.\n"); | 97 FATAL("StackFrame_validateFrame fails, invalid dart frame.\n"); |
95 } | 98 } |
96 const char* name = function.ToFullyQualifiedCString(); | 99 const char* name = function.ToFullyQualifiedCString(); |
97 // Currently all unit tests are loaded as being part of dart:core-lib. | 100 // Currently all unit tests are loaded as being part of dart:core-lib. |
98 String& url = String::Handle(String::New(TestCase::url())); | 101 String& url = String::Handle(zone, String::New(TestCase::url())); |
99 const Library& lib = Library::Handle(Library::LookupLibrary(url)); | 102 const Library& lib = Library::Handle(zone, |
| 103 Library::LookupLibrary(thread, url)); |
100 ASSERT(!lib.IsNull()); | 104 ASSERT(!lib.IsNull()); |
101 const char* lib_name = String::Handle(lib.url()).ToCString(); | 105 const char* lib_name = String::Handle(zone, lib.url()).ToCString(); |
102 char* full_name = OS::SCreate(Thread::Current()->zone(), | 106 char* full_name = OS::SCreate(zone, "%s_%s", lib_name, expected_name); |
103 "%s_%s", lib_name, expected_name); | |
104 if (strcmp(full_name, name) != 0) { | 107 if (strcmp(full_name, name) != 0) { |
105 FATAL("StackFrame_validateFrame fails, incorrect frame.\n"); | 108 FATAL("StackFrame_validateFrame fails, incorrect frame.\n"); |
106 } | 109 } |
107 return; | 110 return; |
108 } | 111 } |
109 count += 1; // Count the dart frames. | 112 count += 1; // Count the dart frames. |
110 frame = frames.NextFrame(); | 113 frame = frames.NextFrame(); |
111 } | 114 } |
112 FATAL("StackFrame_validateFrame fails, frame count < index passed in.\n"); | 115 FATAL("StackFrame_validateFrame fails, frame count < index passed in.\n"); |
113 } | 116 } |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 "}"; | 319 "}"; |
317 } | 320 } |
318 Dart_Handle lib = TestCase::LoadTestScript( | 321 Dart_Handle lib = TestCase::LoadTestScript( |
319 kScriptChars, | 322 kScriptChars, |
320 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); | 323 reinterpret_cast<Dart_NativeEntryResolver>(native_lookup)); |
321 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); | 324 Dart_Handle cls = Dart_GetClass(lib, NewString("StackFrame2Test")); |
322 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); | 325 EXPECT_VALID(Dart_Invoke(cls, NewString("testMain"), 0, NULL)); |
323 } | 326 } |
324 | 327 |
325 } // namespace dart | 328 } // namespace dart |
OLD | NEW |