37#define FUNCTION_NAME(name) StackFrame_##name
38#define REGISTER_FUNCTION(name, count) {"" #name, FUNCTION_NAME(name), count},
45 Instance::CheckedHandle(zone, arguments->
NativeArgAt(0));
47 Instance::CheckedHandle(zone, arguments->
NativeArgAt(1));
90 const Smi& frame_index_smi =
92 const char* expected_name =
94 int frame_index = frame_index_smi.
Value();
98 while (
frame !=
nullptr) {
99 if (
count == frame_index) {
105 FATAL(
"StackFrame_validateFrame fails, invalid dart frame.\n");
114 char* full_name =
OS::SCreate(zone,
"%s_%s", lib_name, expected_name);
115 EXPECT_STREQ(full_name,
name);
121 FATAL(
"StackFrame_validateFrame fails, frame count < index passed in.\n");
127#define STACKFRAME_NATIVE_LIST(V) \
128 V(StackFrame_equals, 2) \
129 V(StackFrame_frameCount, 0) \
130 V(StackFrame_dartFrameCount, 0) \
131 V(StackFrame_validateFrame, 2)
133static struct NativeEntries {
141 bool* auto_setup_scope) {
142 ASSERT(auto_setup_scope !=
nullptr);
143 *auto_setup_scope =
false;
150 for (
int i = 0;
i < num_entries;
i++) {
163 const char* kScriptChars =
165 " @pragma('vm:external-name', 'StackFrame_equals')\n"
166 " external static equals(var obj1, var obj2);\n"
167 " @pragma('vm:external-name', 'StackFrame_frameCount')\n"
168 " external static int frameCount();\n"
169 " @pragma('vm:external-name', 'StackFrame_dartFrameCount')\n"
170 " external static int dartFrameCount();\n"
171 " @pragma('vm:external-name', 'StackFrame_validateFrame')\n"
172 " external static validateFrame(int index, String name);"
176 " int? method1(int? param) {"
178 " param = method2(200);"
180 " param = method2(100);"
183 " int? method2(int param) {"
184 " if (param == 200) {"
185 " First.staticmethod(this, param);"
187 " First.staticmethod(this, 10);"
190 " static int? staticmethod(First obj, int param) {"
191 " if (param == 10) {"
197 " method3(int param) {"
198 " StackFrame.equals(9, StackFrame.frameCount());"
199 " StackFrame.equals(7, StackFrame.dartFrameCount());"
200 " StackFrame.validateFrame(0, \"StackFrame_validateFrame\");"
201 " StackFrame.validateFrame(1, \"First_method3\");"
202 " StackFrame.validateFrame(2, \"First_staticmethod\");"
203 " StackFrame.validateFrame(3, \"First_method2\");"
204 " StackFrame.validateFrame(4, \"First_method1\");"
205 " StackFrame.validateFrame(5, \"Second_method1\");"
206 " StackFrame.validateFrame(6, \"StackFrameTest_testMain\");"
211 " int? method1(int? param) {"
213 " param = method2(200);"
215 " First obj = new First();"
216 " param = obj.method1(1);"
217 " param = obj.method1(2);"
220 " int? method2(int param) {"
221 " Second.staticmethod(this, param);"
223 " static int? staticmethod(Second obj, int param) {"
226 " method3(int param) {"
227 " StackFrame.equals(8, StackFrame.frameCount());"
228 " StackFrame.equals(6, StackFrame.dartFrameCount());"
229 " StackFrame.validateFrame(0, \"StackFrame_validateFrame\");"
230 " StackFrame.validateFrame(1, \"Second_method3\");"
231 " StackFrame.validateFrame(2, \"Second_staticmethod\");"
232 " StackFrame.validateFrame(3, \"Second_method2\");"
233 " StackFrame.validateFrame(4, \"Second_method1\");"
234 " StackFrame.validateFrame(5, \"StackFrameTest_testMain\");"
237 "class StackFrameTest {"
238 " static testMain() {"
239 " Second obj = new Second();"
253 const char*
const kScriptChars =
255 " @pragma('vm:external-name', 'StackFrame_equals')\n"
256 " external static equals(var obj1, var obj2);\n"
257 " @pragma('vm:external-name', 'StackFrame_frameCount')\n"
258 " external static int frameCount();\n"
259 " @pragma('vm:external-name', 'StackFrame_dartFrameCount')\n"
260 " external static int dartFrameCount();\n"
261 " @pragma('vm:external-name', 'StackFrame_validateFrame')\n"
262 " external static validateFrame(int index, String name);"
264 "class StackFrame2Test {"
265 " StackFrame2Test() {}"
266 " noSuchMethod(Invocation im) {"
267 " /* We should have 6 general frames and 4 dart frames as follows:"
269 " * dart frame corresponding to StackFrame.frameCount"
270 " * dart frame corresponding to StackFrame2Test.noSuchMethod"
271 " * frame for instance function invocation stub calling "
273 " * dart frame corresponding to StackFrame2Test.testMain"
276 " StackFrame.equals(6, StackFrame.frameCount());"
277 " StackFrame.equals(4, StackFrame.dartFrameCount());"
278 " StackFrame.validateFrame(0, \"StackFrame_validateFrame\");"
279 " StackFrame.validateFrame(1, \"StackFrame2Test_noSuchMethod\");"
280 " StackFrame.validateFrame(2, \"StackFrame2Test_foo\");"
281 " StackFrame.validateFrame(3, \"StackFrame2Test_testMain\");"
284 " static testMain() {"
285 " /* Declare |obj| dynamic so that noSuchMethod can be"
286 " * called in strong mode. */"
287 " dynamic obj = new StackFrame2Test();"
288 " StackFrame.equals(5, obj.foo(101, 202));"
static ObjectPtr UnwrapHandle(Dart_Handle object)
virtual bool OperatorEquals(const Instance &other) const
static LibraryPtr LookupLibrary(Thread *thread, const String &url)
void SetReturn(const Object &value) const
ObjectPtr NativeArgAt(int index) const
static void static void PrintErr(const char *format,...) PRINTF_ATTRIBUTE(1
static char * SCreate(Zone *zone, const char *format,...) PRINTF_ATTRIBUTE(2
virtual const char * ToCString() const
static SmiPtr New(intptr_t value)
bool HasNextFrame() const
@ kNoCrossThreadIteration
static StringPtr New(const char *cstr, Heap::Space space=Heap::kNew)
static Dart_Handle LoadTestScript(const char *script, Dart_NativeEntryResolver resolver, const char *lib_uri=RESOLVED_USER_TEST_URI, bool finalize=true, bool allow_compile_errors=false)
static const char * url()
static Thread * Current()
static void VerifyPointers(const char *msg, MarkExpectation mark_expectation=kForbidMarked)
struct _Dart_Handle * Dart_Handle
Dart_NativeFunction(* Dart_NativeEntryResolver)(Dart_Handle name, int num_of_arguments, bool *auto_setup_scope)
struct _Dart_NativeArguments * Dart_NativeArguments
void(* Dart_NativeFunction)(Dart_NativeArguments arguments)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Dart_NativeFunction function
void FUNCTION_NAME() StackFrame_dartFrameCount(Dart_NativeArguments args)
DART_EXPORT Dart_Handle Dart_Invoke(Dart_Handle target, Dart_Handle name, int number_of_arguments, Dart_Handle *arguments)
DART_EXPORT Dart_Handle Dart_GetClass(Dart_Handle library, Dart_Handle class_name)
void FUNCTION_NAME() StackFrame_validateFrame(Dart_NativeArguments args)
static Dart_NativeFunction native_lookup(Dart_Handle name, int argument_count, bool *auto_setup_scope)
static struct dart::NativeEntries BuiltinEntries[]
ISOLATE_UNIT_TEST_CASE(StackAllocatedDestruction)
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
TEST_CASE(DirectoryCurrent)
Dart_Handle NewString(const char *str)
void FUNCTION_NAME() StackFrame_equals(Dart_NativeArguments args)
void FUNCTION_NAME() StackFrame_frameCount(Dart_NativeArguments args)
const char *const function_name
#define STACKFRAME_NATIVE_LIST(V)
#define REGISTER_FUNCTION(name, count)
#define FUNCTION_NAME(name)
const int argument_count_
#define EXPECT_VALID(handle)