Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: vm/native_entry.h

Issue 10874072: Use the return value of vm native methods to set the return value, (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #ifndef VM_NATIVE_ENTRY_H_ 5 #ifndef VM_NATIVE_ENTRY_H_
6 #define VM_NATIVE_ENTRY_H_ 6 #define VM_NATIVE_ENTRY_H_
7 7
8 #include "vm/allocation.h" 8 #include "vm/allocation.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 15 matching lines...) Expand all
26 26
27 #define NATIVE_ENTRY_FUNCTION(name) DN_##name 27 #define NATIVE_ENTRY_FUNCTION(name) DN_##name
28 28
29 29
30 // Helper macros for declaring and defining native entries. 30 // Helper macros for declaring and defining native entries.
31 #define REGISTER_NATIVE_ENTRY(name, count) \ 31 #define REGISTER_NATIVE_ENTRY(name, count) \
32 { ""#name, NATIVE_ENTRY_FUNCTION(name), count }, 32 { ""#name, NATIVE_ENTRY_FUNCTION(name), count },
33 33
34 34
35 #define DEFINE_NATIVE_ENTRY(name, argument_count) \ 35 #define DEFINE_NATIVE_ENTRY(name, argument_count) \
36 static void DN_Helper##name(Isolate* isolate, NativeArguments* arguments); \ 36 static RawObject* DN_Helper##name(Isolate* isolate, \
37 NativeArguments* arguments); \
37 void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments args) { \ 38 void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments args) { \
38 CHECK_STACK_ALIGNMENT; \ 39 CHECK_STACK_ALIGNMENT; \
39 VERIFY_ON_TRANSITION; \ 40 VERIFY_ON_TRANSITION; \
40 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); \ 41 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); \
41 ASSERT(arguments->Count() == argument_count); \ 42 ASSERT(arguments->Count() == argument_count); \
42 if (FLAG_trace_natives) OS::Print("Calling native: %s\n", ""#name); \ 43 if (FLAG_trace_natives) OS::Print("Calling native: %s\n", ""#name); \
43 { \ 44 { \
44 Zone zone(arguments->isolate()); \ 45 Zone zone(arguments->isolate()); \
45 HANDLESCOPE(arguments->isolate()); \ 46 HANDLESCOPE(arguments->isolate()); \
46 DN_Helper##name(arguments->isolate(), arguments); \ 47 arguments->SetReturnUnsafe( \
48 DN_Helper##name(arguments->isolate(), arguments)); \
siva 2012/08/28 18:21:20 I was also proposing that we set the return value
47 } \ 49 } \
48 VERIFY_ON_TRANSITION; \ 50 VERIFY_ON_TRANSITION; \
49 } \ 51 } \
50 static void DN_Helper##name(Isolate* isolate, NativeArguments* arguments) 52 static RawObject* DN_Helper##name(Isolate* isolate, \
53 NativeArguments* arguments)
51 54
52 55
53 #define DECLARE_NATIVE_ENTRY(name, argument_count) \ 56 #define DECLARE_NATIVE_ENTRY(name, argument_count) \
54 extern void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments arguments); 57 extern void NATIVE_ENTRY_FUNCTION(name)(Dart_NativeArguments arguments);
55 58
56 // Natives should throw an exception if an illegal argument is passed. 59 // Natives should throw an exception if an illegal argument is passed.
57 // type name = value. 60 // type name = value.
58 #define GET_NATIVE_ARGUMENT(type, name, value) \ 61 #define GET_NATIVE_ARGUMENT(type, name, value) \
59 const Instance& __##name##_instance__ = \ 62 const Instance& __##name##_instance__ = \
60 Instance::CheckedHandle(isolate, value); \ 63 Instance::CheckedHandle(isolate, value); \
(...skipping 11 matching lines...) Expand all
72 public: 75 public:
73 // Resolve specified dart native function to the actual native entrypoint. 76 // Resolve specified dart native function to the actual native entrypoint.
74 static NativeFunction ResolveNative(const Class& cls, 77 static NativeFunction ResolveNative(const Class& cls,
75 const String& function_name, 78 const String& function_name,
76 int number_of_arguments); 79 int number_of_arguments);
77 }; 80 };
78 81
79 } // namespace dart 82 } // namespace dart
80 83
81 #endif // VM_NATIVE_ENTRY_H_ 84 #endif // VM_NATIVE_ENTRY_H_
OLDNEW
« vm/native_arguments.h ('K') | « vm/native_arguments.cc ('k') | vm/native_entry_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698